{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/delegation-attenuation-v1.json",
  "title": "Delegation Attenuation Receipt, v1",
  "description": "Canonical schema for the Hive delegation attenuation receipt, canonical type delegation.attenuation.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_delegation\\.attenuation_[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",
        "delegation_chain_id",
        "root_authority",
        "links",
        "action",
        "attenuation_finding",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "delegation.attenuation"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "delegation_chain_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:]{1,128}$"
        },
        "root_authority": {
          "type": "object",
          "required": [
            "authority_commitment",
            "root_class",
            "root_maximum_onward_delegation_depth",
            "category_commitment_context"
          ],
          "additionalProperties": false,
          "properties": {
            "authority_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "root_class": {
              "type": "string",
              "enum": [
                "issuer_resolved_signed_credential",
                "caller_supplied_signed_credential",
                "asserted_without_credential"
              ]
            },
            "root_maximum_onward_delegation_depth": {
              "type": "integer",
              "minimum": 1,
              "maximum": 15
            },
            "category_commitment_context": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "links": {
          "type": "array",
          "minItems": 2,
          "maxItems": 16,
          "items": {
            "type": "object",
            "required": [
              "ordinal",
              "granting_party_commitment",
              "receiving_party_commitment",
              "credential_envelope_sha256",
              "issued_at",
              "expires_at",
              "per_action_ceiling_minor",
              "category_commitments",
              "maximum_onward_delegation_depth"
            ],
            "additionalProperties": false,
            "properties": {
              "ordinal": {
                "type": "integer",
                "minimum": 0,
                "maximum": 15
              },
              "granting_party_commitment": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "receiving_party_commitment": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "credential_envelope_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "issued_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$"
              },
              "expires_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$"
              },
              "per_action_ceiling_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9223372036854775807
              },
              "category_commitments": {
                "type": "array",
                "minItems": 1,
                "maxItems": 256,
                "items": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              },
              "maximum_onward_delegation_depth": {
                "type": "integer",
                "minimum": 0,
                "maximum": 15
              }
            }
          }
        },
        "action": {
          "type": "object",
          "required": [
            "action_id",
            "action_record_sha256",
            "actor_party_commitment",
            "action_at",
            "amount_minor",
            "category_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "action_id": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:]{1,128}$"
            },
            "action_record_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "actor_party_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "action_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$"
            },
            "amount_minor": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9223372036854775807
            },
            "category_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "attenuation_finding": {
          "type": "string",
          "enum": [
            "conforms",
            "does_not_conform",
            "indeterminate"
          ]
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests only that the supplied delegation links and supplied action assertion satisfy the stated mechanical attenuation comparisons at verification. It does not attest that the root authority is valid, that a grantor is entitled to delegate, that the supplied chain is complete or exclusive, that any linked credential is the one an acceptor uses, that an action occurs, that the action is authorized, lawful, effective, enforceable, paid, settled, or accepted, that any party has knowledge or notice, that a category name is revealed, or that any person bears responsibility, loss, harm, fault, or liability. It cannot decide whether authority exists outside the supplied chain, whether a missing link exists, whether an action is proper, or whether an external rule permits it."
        }
      }
    }
  }
}
