{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usedeed.app/contracts/deed.journal_root.v2.schema.json",
  "title": "DEED signed journal root",
  "description": "The current Ed25519-signed daily journal root object minted by the runtime (engine generate_root + sign_root). root_hash and signature canonicalization are defined by the published journal hash recipe (deed.journal_hash_recipe.v1.json). Retired signed objects remain readable only through their frozen contract and bounded verifier path.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "version",
    "deployment_id",
    "streams",
    "root_hash"
  ],
  "properties": {
    "version": {
      "description": "Current DEED signed-root schema id.",
      "const": "deed.journal_root.v2"
    },
    "generated_at": {
      "type": "string",
      "description": "Mint timestamp. Deliberately outside the hashed body (the root hash is a pure function of the entry set); tamper-evident via the Ed25519 signature payload."
    },
    "deployment_id": { "type": "string" },
    "streams": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": ["stream", "count", "head_hash"],
        "properties": {
          "stream": { "type": "string", "minLength": 1 },
          "count": { "type": "integer", "minimum": 0 },
          "head_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
          "first_ts": { "type": ["string", "null"] },
          "last_ts": { "type": ["string", "null"] }
        }
      }
    },
    "root_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "anchor": {
      "type": "object",
      "description": "Timestamp-anchor receipt attached after signing; excluded from root_hash and the signature payload."
    },
    "signing_key_id": { "type": "string" },
    "signing_public_key_b64": {
      "type": "string",
      "description": "base64 of the raw 32-byte Ed25519 public key."
    },
    "signature": {
      "type": "string",
      "description": "base64 Ed25519 signature over the canonical signature payload (see the journal hash recipe)."
    }
  }
}
