{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usedeed.app/contracts/deed.journal_root_artifact.v2.schema.json",
  "title": "DEED public journal-root artifact",
  "description": "The current unsigned public artifact served at /api/journal-roots/<sha256-slug>. The artifact proves claimed-hash match and entry-chain linkage; the embedded deed.journal_root.v2 object is the material that proves the Ed25519 signature. Retired artifacts remain readable only through their frozen contract and bounded verifier path.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema_version",
    "kind",
    "root_hash",
    "canonical_url",
    "generated_at",
    "replay_count",
    "streams",
    "entries",
    "integrity"
  ],
  "properties": {
    "schema_version": { "const": "deed.journal_root_artifact.v2" },
    "kind": { "const": "journal_root_artifact" },
    "root_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "canonical_url": { "type": "string", "format": "uri" },
    "generated_at": { "type": "string", "format": "date-time" },
    "deployment_id": { "type": ["string", "null"] },
    "verifier": { "type": "string" },
    "anchor_url": { "type": ["string", "null"] },
    "signed_root": {
      "type": ["object", "null"],
      "description": "The stored Ed25519-signed root object exactly as the deployment posted it (never synthesized). Shape: deed.journal_root.v2.schema.json."
    },
    "signed_root_url": { "type": ["string", "null"], "description": "canonical_url + ?form=signed when a signed root is stored; null otherwise." },
    "replay_count": { "type": "integer", "minimum": 0 },
    "streams": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": ["stream", "count"],
        "properties": {
          "stream": { "type": "string" },
          "count": { "type": "integer", "minimum": 0 }
        }
      }
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": ["replay_id", "entry_hash"],
        "properties": {
          "replay_id": { "type": "string" },
          "occurred_at": { "type": ["string", "null"] },
          "source_type": { "type": ["string", "null"] },
          "source_ref": { "type": ["string", "null"] },
          "stream": { "type": ["string", "null"] },
          "seq": { "type": ["integer", "null"] },
          "payload_hash": { "type": ["string", "null"] },
          "entry_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
          "prev_hash": { "type": ["string", "null"] },
          "replay_url": { "type": "string", "format": "uri" },
          "replay_json_url": { "type": "string", "format": "uri" }
        }
      }
    },
    "integrity": {
      "type": "object",
      "additionalProperties": true,
      "required": ["complete_entries", "note"],
      "properties": {
        "complete_entries": { "type": "boolean" },
        "note": { "type": "string" }
      }
    }
  }
}
