{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/usap-refusal-v2.json",
  "title": "Refusal Ledger v1",
  "description": "Records a refusal decision and a supplied post decision observation. It does not establish policy authorization, zero knowledge properties, or absence of every side effect.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_usap\\.refusal_[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",
        "refusal_event_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "policy_sha256",
        "policy_committed_at",
        "request_sha256",
        "requested_at",
        "disposition",
        "reason_code",
        "decided_at",
        "post_decision_observation",
        "policy_timing_relation",
        "decision_timing_relation",
        "refusal_relation",
        "mutation_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "usap.refusal"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "refusal_event_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": [
            "outcome"
          ],
          "additionalProperties": false,
          "properties": {
            "outcome": {
              "type": "string",
              "enum": [
                "refusal_record_consistent",
                "refusal_record_inconsistent",
                "indeterminate"
              ]
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Records a refusal decision and a supplied post decision observation. It does not establish policy authorization, zero knowledge properties, or absence of every side effect."
        },
        "policy_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "policy_committed_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$"
        },
        "request_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "requested_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$"
        },
        "disposition": {
          "type": "string",
          "enum": [
            "refused",
            "accepted",
            "deferred"
          ]
        },
        "reason_code": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._:/]+$"
        },
        "decided_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$"
        },
        "post_decision_observation": {
          "type": "object",
          "required": [
            "observed_at",
            "mutation_state"
          ],
          "additionalProperties": false,
          "properties": {
            "observed_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$"
            },
            "mutation_state": {
              "type": "string",
              "enum": [
                "unchanged",
                "changed",
                "unresolved"
              ]
            }
          }
        },
        "policy_timing_relation": {
          "type": "string",
          "enum": [
            "precommitted",
            "not_precommitted"
          ]
        },
        "decision_timing_relation": {
          "type": "string",
          "enum": [
            "ordered",
            "out_of_order"
          ]
        },
        "refusal_relation": {
          "type": "string",
          "enum": [
            "refused",
            "not_refused"
          ]
        },
        "mutation_relation": {
          "type": "string",
          "enum": [
            "unchanged",
            "changed",
            "unresolved"
          ]
        },
        "elements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "request_not_refused",
              "mutation_after_refusal",
              "post_decision_state_unresolved"
            ]
          },
          "minItems": 0,
          "maxItems": 3
        },
        "outcome": {
          "type": "string",
          "enum": [
            "refusal_record_consistent",
            "refusal_record_inconsistent",
            "indeterminate"
          ]
        }
      }
    }
  }
}
