{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/recovery-determination-v1.json",
  "title": "Recovery Determination Receipt, v1",
  "description": "Canonical schema for the Hive recovery determination receipt, canonical type recovery.determination.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": { "type": "string", "pattern": "^r_recovery\\.determination_[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",
        "recovery_determination",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "recovery.determination" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "recovery_determination": {
          "type": "object",
          "required": [
            "determination_id",
            "determined_at",
            "attribution_ref",
            "loss_event_ref",
            "allocation_table_ref",
            "claimant_pseudonym",
            "respondent_pseudonym",
            "attribution_outcome_key",
            "allocation_entry_digest",
            "settlement_position",
            "precedence_class",
            "evidence_access_class",
            "salt_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "determination_id": { "type": "string", "pattern": "^rd_[0-9a-f]{16,64}$" },
            "determined_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
            "attribution_ref": {
              "type": "object",
              "required": ["receipt_id", "payload_sha256", "attributed_at"],
              "additionalProperties": false,
              "properties": {
                "receipt_id": { "type": "string", "pattern": "^r_fault\\.attribution_[0-9]{10,}_[0-9a-f]{12}$" },
                "payload_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "attributed_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" }
              }
            },
            "loss_event_ref": {
              "type": "object",
              "required": ["event_id", "payload_sha256", "occurred_at"],
              "additionalProperties": false,
              "properties": {
                "event_id": { "type": "string", "pattern": "^le_[0-9a-f]{16,64}$" },
                "payload_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "occurred_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" }
              }
            },
            "allocation_table_ref": {
              "type": "object",
              "required": ["table_id", "table_digest", "committed_at"],
              "additionalProperties": false,
              "properties": {
                "table_id": { "type": "string", "pattern": "^at_[0-9a-z_]{1,48}$" },
                "table_digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "committed_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" }
              }
            },
            "claimant_pseudonym": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "respondent_pseudonym": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "attribution_outcome_key": {
              "type": "string",
              "enum": [
                "single_party:principal",
                "single_party:agent_operator",
                "single_party:acceptor",
                "single_party:issuer",
                "shared:none",
                "no_violation_found:none",
                "indeterminate:none"
              ]
            },
            "allocation_entry_digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "settlement_position": { "type": "string", "enum": ["respondent_bears", "claimant_bears", "shared_position", "no_position"] },
            "precedence_class": { "type": "string", "enum": ["table_precedes_loss", "table_follows_loss"] },
            "evidence_access_class": { "type": "string", "enum": ["confidential_independent", "issuer_only", "public_commitment_only"] },
            "salt_commitment": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
          }
        },
        "boundary": {
          "type": "string",
          "minLength": 1,
          "const": "This receipt attests only that a named observer recomputed a settlement position between two named parties from one named fault attribution outcome and a precommitted allocation table whose digest was committed before the loss instant. It does not attest that any amount is owed, that any party will pay, that the allocation table is enforceable, or that any contract exists between the named parties. Whether the recomputed position entitles anyone to payment is decided solely by the parties' own agreement."
        }
      }
    }
  }
}
