{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/sigr-chain-v1.json",
  "title": "SiGR Chain v1, signed inference guarantee chain receipt",
  "description": "Canonical schema for the Hive SiGR Chain receipt, canonical type sigr.chain. Binds an ordered, step sealed sequence of an agent run, reasoning, tool calls, retrieval, and a final answer, into one Ed25519 signature over a recomputable payload_sha256 and a recomputable chain_root. The receipt attests that the recorded steps array, hashed in order into chain_root, is exactly the sequence this signer received and sealed, in that order, with no step dropped, reordered, or altered after sealing. It does not attest that any step's content is correct, that any tool call actually executed as described, or that the final answer is fit for any purpose.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_sigr\\.chain_[0-9]{10,}_[0-9a-f]{12}$"
    },
    "payload_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "sig_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" },
    "key_id": { "type": "string", "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$" },
    "algorithm": { "type": "string", "const": "Ed25519" },
    "ts": { "type": "integer", "minimum": 1000000000 },
    "signed_body": {
      "type": "object",
      "required": [
        "receipt_type",
        "schema",
        "run_id",
        "tenant_id",
        "agent_ref",
        "steps",
        "chain_root",
        "sealed_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "sigr.chain" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "run_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "tenant_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "agent_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Caller supplied identifier of the agent or agent version that produced this run. Recorded as a claim, not independently verified."
        },
        "steps": {
          "type": "array",
          "minItems": 1,
          "maxItems": 512,
          "description": "Ordered sequence of step seals. Each entry names a step_index, a kind, and a content_sha256 digest of that step's content. The array order is significant and is exactly what chain_root is folded over.",
          "items": {
            "type": "object",
            "required": ["step_index", "kind", "content_sha256"],
            "additionalProperties": false,
            "properties": {
              "step_index": { "type": "integer", "minimum": 0, "maximum": 511 },
              "kind": {
                "type": "string",
                "enum": ["reasoning", "tool_call", "retrieval", "final", "system", "decomposition"]
              },
              "content_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$",
                "description": "Digest of the step's own content. The signer never receives or stores the raw content, only this digest."
              },
              "tool_ref": {
                "type": "string",
                "maxLength": 256,
                "description": "Optional. Present only when kind is tool_call, names the tool invoked."
              }
            }
          }
        },
        "chain_root": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "sha256 fold of steps[].content_sha256 in array order, prefixed by step_index and kind for each fold input. Recomputed by the verifier; a caller supplied chain_root that does not match the recomputation fails CHAIN_ROOT."
        },
        "final_step_index": {
          "type": "integer",
          "minimum": 0,
          "maximum": 511,
          "description": "Optional. When present, must name the step_index of the single steps entry whose kind is final."
        },
        "sealed_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$",
          "description": "Instant the signer sealed the chain. Set by the signer at mint time, never accepted as a caller supplied value that predates minting."
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests that the steps array recorded in signed_body, hashed in order, recomputes to chain_root, and that the sequence was sealed at sealed_at with no step dropped, reordered, or altered afterward. It does not attest that any step's content is accurate, that a tool_call step actually executed against the named tool, or that the agent's final answer is correct or fit for any purpose."
        }
      }
    }
  }
}
