{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/usap-egress-v2.json",
  "title": "Egress Bond v1",
  "description": "Compares a supplied transfer observation with a precommitted policy. It does not prove complete network visibility or classifier correctness.",
  "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\\.egress_[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",
        "egress_manifest_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "policy_sha256",
        "policy_committed_at",
        "transfer_id",
        "transfer_observed_at",
        "declared_destinations",
        "declared_channels",
        "declared_content_classes",
        "declared_byte_limit",
        "observed_destination",
        "observed_channel",
        "observed_content_class",
        "observed_bytes",
        "destination_relation",
        "channel_relation",
        "content_class_relation",
        "quantity_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "usap.egress"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "egress_manifest_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": [
                "within_declared_egress",
                "outside_declared_egress",
                "indeterminate"
              ]
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Compares a supplied transfer observation with a precommitted policy. It does not prove complete network visibility or classifier correctness."
        },
        "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$"
        },
        "transfer_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "transfer_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$"
        },
        "declared_destinations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_channels": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:/]+$"
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_content_classes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:/]+$"
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_byte_limit": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1125899906842624
        },
        "observed_destination": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "observed_channel": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._:/]+$"
        },
        "observed_content_class": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._:/]+$"
        },
        "observed_bytes": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1125899906842624
        },
        "destination_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "channel_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "content_class_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "quantity_relation": {
          "type": "string",
          "enum": [
            "within_limit",
            "exceeds_limit"
          ]
        },
        "elements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "destination_outside_policy",
              "channel_outside_policy",
              "content_class_outside_policy",
              "byte_budget_exceeded"
            ]
          },
          "minItems": 0,
          "maxItems": 4
        },
        "outcome": {
          "type": "string",
          "enum": [
            "within_declared_egress",
            "outside_declared_egress",
            "indeterminate"
          ]
        }
      }
    }
  }
}
