{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/receipt-registry-sovereign-v2.json",
  "title": "Sovereign AI Receipt Registry v1",
  "description": "Sovereign AI Receipt Registry checkpoint. It verifies the operator signature, canonical entry leaves, registry root, entry count, declared status transitions, and a supplied predecessor link. jurisdiction_ref is descriptive metadata only and does not confer governmental authority or legal recognition.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_receipt\\.registry\\.sovereign_[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",
        "registry_entry_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "jurisdiction_ref",
        "operator_policy_sha256",
        "epoch",
        "previous_checkpoint_sha256",
        "entries",
        "checkpoint_at",
        "entry_leaves",
        "registry_root_sha256",
        "entry_count",
        "status_transition_relations",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "receipt.registry.sovereign"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "registry_entry_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9._:-]{1,256}$"
        },
        "evidence_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the caller-held evidence bundle this receipt attests was recorded. The service never receives or inspects the underlying evidence, only its digest."
        },
        "recorded_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$"
        },
        "verdict": {
          "type": "object",
          "description": "Service-computed honesty boundary fields. Never caller overridable; recomputed and checked at verify time.",
          "required": [
            "jurisdictional_authority_confirmed"
          ],
          "additionalProperties": false,
          "properties": {
            "jurisdictional_authority_confirmed": {
              "type": "boolean",
              "const": false
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Sovereign AI Receipt Registry checkpoint. It verifies the operator signature, canonical entry leaves, registry root, entry count, declared status transitions, and a supplied predecessor link. jurisdiction_ref is descriptive metadata only and does not confer governmental authority or legal recognition."
        },
        "jurisdiction_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Descriptive metadata only. This value grants no authority or recognition."
        },
        "operator_policy_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "epoch": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "previous_checkpoint_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "prior_checkpoint": {
          "type": "object",
          "required": [
            "epoch",
            "checkpoint_sha256"
          ],
          "additionalProperties": false,
          "properties": {
            "epoch": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "checkpoint_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "entries": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "receipt_id",
              "payload_sha256",
              "status",
              "prior_status",
              "status_at"
            ],
            "additionalProperties": false,
            "properties": {
              "receipt_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "payload_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "suspended",
                  "revoked",
                  "superseded"
                ]
              },
              "prior_status": {
                "type": "string",
                "enum": [
                  "none",
                  "active",
                  "suspended",
                  "revoked",
                  "superseded"
                ]
              },
              "status_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$"
              }
            }
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "checkpoint_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$"
        },
        "entry_leaves": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "registry_root_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "entry_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4096
        },
        "status_transition_relations": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "receipt_id",
              "relation"
            ],
            "additionalProperties": false,
            "properties": {
              "receipt_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "relation": {
                "type": "string",
                "enum": [
                  "valid",
                  "invalid"
                ]
              }
            }
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "elements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "duplicate_receipt",
              "invalid_status_transition",
              "prior_checkpoint_mismatch"
            ]
          },
          "minItems": 0,
          "maxItems": 3
        },
        "outcome": {
          "type": "string",
          "enum": [
            "checkpoint_consistent",
            "checkpoint_inconsistent",
            "continuity_unresolved"
          ]
        }
      }
    }
  }
}
