{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://odexa.io/schemas/1.2.0-draft.2/reference/offer.schema.json",
  "title": "Odexa reference offer",
  "$comment": "Structural contract only; strict lexical JSON, signatures, origin/scope bindings and semantic checks are mandatory.",
  "$ref": "#/$defs/offer",
  "$defs": {
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "service_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "origin",
        "service_id",
        "revision",
        "url",
        "digest"
      ]
    },
    "asset_ref": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "asset_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "version_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "manifest_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "representation_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        }
      },
      "required": [
        "asset_id",
        "version_id",
        "manifest_digest",
        "representation_id"
      ]
    },
    "representation_metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "media_type": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*$"
        },
        "media_parameters": {
          "type": "object",
          "maxProperties": 16,
          "propertyNames": {
            "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*$"
          },
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z]{1,8}(?:-[a-z0-9]{1,8})*$"
          },
          "minItems": 0,
          "maxItems": 16,
          "uniqueItems": true
        }
      },
      "required": [
        "media_type",
        "media_parameters",
        "languages"
      ]
    },
    "representation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "media_type": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*$"
        },
        "media_parameters": {
          "type": "object",
          "maxProperties": 16,
          "propertyNames": {
            "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*$"
          },
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z]{1,8}(?:-[a-z0-9]{1,8})*$"
          },
          "minItems": 0,
          "maxItems": 16,
          "uniqueItems": true
        },
        "representation_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "decoded_length": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "decoded_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "media_type",
        "media_parameters",
        "languages",
        "representation_id",
        "decoded_length",
        "decoded_digest"
      ]
    },
    "manifest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "asset_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "version_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "published_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "authority": {
          "$ref": "#/$defs/authority"
        },
        "representations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/representation"
          },
          "minItems": 1,
          "maxItems": 64
        }
      },
      "required": [
        "protocol_version",
        "origin",
        "asset_id",
        "version_id",
        "published_at",
        "authority",
        "representations"
      ]
    },
    "range": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "first": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "last": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "complete_length": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "first",
        "last",
        "complete_length"
      ]
    },
    "http": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "method": {
          "enum": [
            "GET",
            "HEAD"
          ]
        },
        "status": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 100,
              "maximum": 599
            },
            {
              "type": "null"
            }
          ]
        },
        "kind": {
          "enum": [
            "full",
            "partial",
            "head",
            "no_content",
            "not_modified",
            "redirect",
            "error",
            "unsupported_partial",
            "unsupported_status",
            "unknown",
            "protocol_error"
          ]
        },
        "delivery_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "hop_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "ingress_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "hop_role": {
          "enum": [
            "end_client",
            "upstream"
          ]
        },
        "boundary_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "cache_status": {
          "enum": [
            "bypass",
            "miss",
            "hit",
            "revalidated",
            "stale",
            "unknown"
          ]
        },
        "content_codings": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(?!identity$)[a-z0-9][a-z0-9-]{0,31}$"
          },
          "minItems": 0,
          "maxItems": 8
        },
        "content_bytes": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "content_digest": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "decoded_bytes": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "decoded_digest": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "range": {
          "anyOf": [
            {
              "$ref": "#/$defs/range"
            },
            {
              "type": "null"
            }
          ]
        },
        "representation_metadata": {
          "anyOf": [
            {
              "$ref": "#/$defs/representation_metadata"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "method",
        "status",
        "kind",
        "delivery_id",
        "hop_id",
        "ingress_id",
        "hop_role",
        "boundary_id",
        "cache_status",
        "content_codings",
        "content_bytes",
        "content_digest",
        "decoded_bytes",
        "decoded_digest",
        "range",
        "representation_metadata"
      ]
    },
    "operation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "started_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "ended_at": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "state": {
          "enum": [
            "completed",
            "failed",
            "in_progress"
          ]
        }
      },
      "required": [
        "id",
        "started_at",
        "ended_at",
        "state"
      ]
    },
    "related_event": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "reporter_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "event_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "payload_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "reporter_id",
        "event_id",
        "payload_digest"
      ]
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "event_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "event_type": {
          "enum": [
            "use.reported",
            "access.authorized",
            "access.denied",
            "delivery.completed",
            "delivery.failed",
            "response.completed",
            "response.failed",
            "policy.observed",
            "offer.issued",
            "acceptance.recorded",
            "agreement.active",
            "agreement.revoked"
          ]
        },
        "occurred_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "reporter_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "source": {
          "enum": [
            "client_reported",
            "origin_observed",
            "service_recorded"
          ]
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "resource_url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "policy_id": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^?#]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "policy_revision": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "actions": {
          "type": "array",
          "items": {
            "enum": [
              "retrieve",
              "store",
              "transform",
              "redistribute"
            ]
          },
          "minItems": 0,
          "maxItems": 4,
          "uniqueItems": true
        },
        "purposes": {
          "type": "array",
          "items": {
            "enum": [
              "search_indexing",
              "public_retrieval",
              "internal_knowledge",
              "model_training",
              "model_fine_tuning",
              "redistribution"
            ]
          },
          "minItems": 0,
          "maxItems": 6,
          "uniqueItems": true
        },
        "agreement_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "asset_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/asset_ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "operation": {
          "anyOf": [
            {
              "$ref": "#/$defs/operation"
            },
            {
              "type": "null"
            }
          ]
        },
        "http": {
          "anyOf": [
            {
              "$ref": "#/$defs/http"
            },
            {
              "type": "null"
            }
          ]
        },
        "quantity": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "unit": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._:-]{0,63}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "related_events": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/related_event"
          },
          "minItems": 0,
          "maxItems": 64,
          "uniqueItems": true
        },
        "derived_from": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/asset_ref"
          },
          "minItems": 0,
          "maxItems": 64,
          "uniqueItems": true
        }
      },
      "required": [
        "protocol_version",
        "event_id",
        "event_type",
        "occurred_at",
        "reporter_id",
        "source",
        "origin",
        "resource_url",
        "policy_id",
        "policy_revision",
        "actions",
        "purposes",
        "agreement_id",
        "asset_ref",
        "operation",
        "http",
        "quantity",
        "unit",
        "related_events",
        "derived_from"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "source": {
                "const": "client_reported"
              }
            }
          },
          "then": {
            "properties": {
              "event_type": {
                "enum": [
                  "use.reported"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "source": {
                "const": "origin_observed"
              }
            }
          },
          "then": {
            "properties": {
              "event_type": {
                "enum": [
                  "access.authorized",
                  "access.denied",
                  "delivery.completed",
                  "delivery.failed",
                  "response.completed",
                  "response.failed"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "source": {
                "const": "service_recorded"
              }
            }
          },
          "then": {
            "properties": {
              "event_type": {
                "enum": [
                  "policy.observed",
                  "offer.issued",
                  "acceptance.recorded",
                  "agreement.active",
                  "agreement.revoked"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "event_type": {
                "enum": [
                  "delivery.completed",
                  "delivery.failed",
                  "response.completed",
                  "response.failed"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "http": {
                "$ref": "#/$defs/http"
              }
            }
          },
          "else": {
            "properties": {
              "http": {
                "type": "null"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "event_type": {
                "const": "use.reported"
              }
            }
          },
          "then": {
            "properties": {
              "operation": {
                "$ref": "#/$defs/operation"
              },
              "actions": {
                "type": "array",
                "items": {
                  "enum": [
                    "retrieve",
                    "store",
                    "transform",
                    "redistribute"
                  ]
                },
                "minItems": 1,
                "maxItems": 1,
                "uniqueItems": true
              },
              "purposes": {
                "type": "array",
                "items": {
                  "enum": [
                    "search_indexing",
                    "public_retrieval",
                    "internal_knowledge",
                    "model_training",
                    "model_fine_tuning",
                    "redistribution"
                  ]
                },
                "minItems": 1,
                "maxItems": 6,
                "uniqueItems": true
              }
            }
          }
        }
      ]
    },
    "intake": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "record_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "collector_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "received_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "assurance": {
          "enum": [
            "unverified",
            "client_key_verified",
            "origin_key_verified",
            "service_key_verified"
          ]
        },
        "authenticated_reporter_id": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^?#]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "payload_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "payload_b64url": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 174764
        },
        "reporter_jws": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 1048576,
              "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "authority": {
          "$ref": "#/$defs/authority"
        }
      },
      "required": [
        "protocol_version",
        "record_id",
        "collector_id",
        "received_at",
        "assurance",
        "authenticated_reporter_id",
        "payload_digest",
        "payload_b64url",
        "reporter_jws",
        "authority"
      ]
    },
    "request": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "actions": {
          "type": "array",
          "items": {
            "enum": [
              "retrieve",
              "store",
              "transform",
              "redistribute"
            ]
          },
          "minItems": 1,
          "maxItems": 4,
          "uniqueItems": true
        },
        "purposes": {
          "type": "array",
          "items": {
            "enum": [
              "search_indexing",
              "public_retrieval",
              "internal_knowledge",
              "model_training",
              "model_fine_tuning",
              "redistribution"
            ]
          },
          "minItems": 1,
          "maxItems": 6,
          "uniqueItems": true
        },
        "supported_obligations": {
          "type": "array",
          "items": {
            "enum": [
              "attribution",
              "retention",
              "report_usage"
            ]
          },
          "minItems": 0,
          "maxItems": 3,
          "uniqueItems": true
        }
      },
      "required": [
        "url",
        "actions",
        "purposes"
      ]
    },
    "offer_request": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "principal_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "request": {
          "$ref": "#/$defs/request"
        },
        "access_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31536000
        },
        "use_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31536000
        }
      },
      "required": [
        "principal_id",
        "request",
        "access_seconds",
        "use_seconds"
      ]
    },
    "obligation": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "attribution"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "url": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^#]+$"
            }
          },
          "required": [
            "type",
            "name",
            "url"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "retention"
            },
            "max_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "type",
            "max_seconds"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "const": "report_usage"
            },
            "endpoint": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^#]+$"
            },
            "deadline_seconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "type",
            "endpoint",
            "deadline_seconds"
          ]
        }
      ]
    },
    "context": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "role": {
          "enum": [
            "policy",
            "human_terms",
            "origin_authority"
          ]
        },
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "media_type": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        }
      },
      "required": [
        "role",
        "url",
        "digest",
        "media_type"
      ]
    },
    "offer": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "offer_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "service_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "client_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        "principal_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "policy_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "policy_revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "request": {
          "$ref": "#/$defs/request"
        },
        "obligations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/obligation"
          },
          "minItems": 0,
          "maxItems": 64
        },
        "context": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/context"
          },
          "minItems": 3,
          "maxItems": 3
        },
        "nonce": {
          "type": "string",
          "minLength": 43,
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 43
        },
        "issued_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}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}Z$"
        },
        "access_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31536000
        },
        "use_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31536000
        },
        "revocation": {
          "const": "future_access_only"
        },
        "payment": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "required": {
              "const": false
            }
          },
          "required": [
            "required"
          ]
        }
      },
      "required": [
        "protocol_version",
        "offer_id",
        "issuer",
        "service_id",
        "origin",
        "client_id",
        "principal_id",
        "policy_id",
        "policy_revision",
        "policy_digest",
        "request",
        "obligations",
        "context",
        "nonce",
        "issued_at",
        "expires_at",
        "access_seconds",
        "use_seconds",
        "revocation",
        "payment"
      ]
    },
    "acceptance": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "service_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "offer_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "offer_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "client_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        "principal_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "intent": {
          "const": "accept"
        },
        "nonce": {
          "type": "string",
          "minLength": 43,
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 43
        },
        "accepted_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "idempotency_key": {
          "type": "string",
          "minLength": 16,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_-]+$"
        }
      },
      "required": [
        "protocol_version",
        "service_id",
        "offer_id",
        "offer_digest",
        "client_id",
        "principal_id",
        "intent",
        "nonce",
        "accepted_at",
        "idempotency_key"
      ]
    },
    "receipt": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "record_type": {
          "const": "agreement.accepted"
        },
        "agreement_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "service_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "client_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        "principal_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "offer_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "offer_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "acceptance_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "recorded_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "access_expires_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "use_expires_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "state_at_issue": {
          "const": "active"
        },
        "payment_required": {
          "const": false
        },
        "access_credential": {
          "const": false
        }
      },
      "required": [
        "protocol_version",
        "record_type",
        "agreement_id",
        "issuer",
        "service_id",
        "origin",
        "client_id",
        "principal_id",
        "offer_id",
        "offer_digest",
        "acceptance_digest",
        "recorded_at",
        "access_expires_at",
        "use_expires_at",
        "state_at_issue",
        "payment_required",
        "access_credential"
      ]
    },
    "status": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "record_type": {
          "const": "agreement.status"
        },
        "agreement_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "state": {
          "enum": [
            "active",
            "revoked",
            "expired"
          ]
        },
        "effective_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "status_version": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "issued_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        }
      },
      "required": [
        "protocol_version",
        "record_type",
        "agreement_id",
        "issuer",
        "state",
        "effective_at",
        "reason",
        "status_version",
        "issued_at"
      ]
    },
    "revoke_request": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "idempotency_key": {
          "type": "string",
          "minLength": 16,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_-]+$"
        }
      },
      "required": [
        "reason",
        "idempotency_key"
      ]
    },
    "token_request": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "agreement_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        }
      },
      "required": [
        "agreement_id"
      ]
    },
    "token_response": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "token_type": {
          "const": "Bearer"
        },
        "access_token": {
          "type": "string",
          "minLength": 43,
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 43
        },
        "expires_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "agreement_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        }
      },
      "required": [
        "token_type",
        "access_token",
        "expires_at",
        "agreement_id"
      ]
    },
    "introspection_request": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "token": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        "resource_url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "method": {
          "enum": [
            "GET",
            "HEAD"
          ]
        },
        "actions": {
          "type": "array",
          "items": {
            "enum": [
              "retrieve",
              "store",
              "transform",
              "redistribute"
            ]
          },
          "minItems": 1,
          "maxItems": 4,
          "uniqueItems": true
        },
        "purposes": {
          "type": "array",
          "items": {
            "enum": [
              "search_indexing",
              "public_retrieval",
              "internal_knowledge",
              "model_training",
              "model_fine_tuning",
              "redistribution"
            ]
          },
          "minItems": 1,
          "maxItems": 6,
          "uniqueItems": true
        },
        "request_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        }
      },
      "required": [
        "token",
        "resource_url",
        "method",
        "actions",
        "purposes",
        "request_id"
      ]
    },
    "introspection_response": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "protocol_version": {
              "const": "1.2.0-draft.2"
            },
            "active": {
              "const": true
            },
            "permitted": {
              "const": true
            },
            "agreement_id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            "origin": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^?#]+$"
            },
            "resource_url": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^#]+$"
            },
            "method": {
              "enum": [
                "GET",
                "HEAD"
              ]
            },
            "actions": {
              "type": "array",
              "items": {
                "enum": [
                  "retrieve",
                  "store",
                  "transform",
                  "redistribute"
                ]
              },
              "minItems": 1,
              "maxItems": 4,
              "uniqueItems": true
            },
            "purposes": {
              "type": "array",
              "items": {
                "enum": [
                  "search_indexing",
                  "public_retrieval",
                  "internal_knowledge",
                  "model_training",
                  "model_fine_tuning",
                  "redistribution"
                ]
              },
              "minItems": 1,
              "maxItems": 6,
              "uniqueItems": true
            },
            "expires_at": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            "checked_at": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            "request_id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            "decision_id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            "status_version": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "authority_revision": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "authority_digest": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "authority_checked_at": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            "policy_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^?#]+$"
            },
            "policy_revision": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "protocol_version",
            "active",
            "permitted",
            "agreement_id",
            "origin",
            "resource_url",
            "method",
            "actions",
            "purposes",
            "expires_at",
            "checked_at",
            "request_id",
            "decision_id",
            "status_version",
            "authority_revision",
            "authority_digest",
            "authority_checked_at",
            "policy_id",
            "policy_revision"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "active": {
              "const": false
            },
            "permitted": {
              "const": false
            }
          },
          "required": [
            "active",
            "permitted"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "active": {
              "const": true
            },
            "permitted": {
              "const": false
            },
            "reason": {
              "const": "scope_mismatch"
            }
          },
          "required": [
            "active",
            "permitted",
            "reason"
          ]
        }
      ]
    },
    "export_page": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "records": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1048576,
            "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
          },
          "minItems": 0,
          "maxItems": 1000
        },
        "next_cursor": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "records",
        "next_cursor"
      ]
    },
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "error": {
          "type": "string",
          "pattern": "^[a-z][a-z_]+$"
        },
        "request_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        }
      },
      "required": [
        "error",
        "request_id"
      ]
    },
    "jwk": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "kty": {
          "const": "EC"
        },
        "crv": {
          "const": "P-256"
        },
        "x": {
          "type": "string",
          "minLength": 43,
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 43
        },
        "y": {
          "type": "string",
          "minLength": 43,
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 43
        }
      },
      "required": [
        "kty",
        "crv",
        "x",
        "y"
      ]
    },
    "signing_key": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "kid": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "public_jwk": {
          "$ref": "#/$defs/jwk"
        },
        "uses": {
          "type": "array",
          "items": {
            "enum": [
              "odexa-receipt+jws",
              "odexa-status+jws",
              "odexa-event+jws",
              "odexa-event-record+jws",
              "odexa-asset-manifest+jws"
            ]
          },
          "minItems": 1,
          "maxItems": 5,
          "uniqueItems": true
        },
        "not_before": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "not_after": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "state": {
          "enum": [
            "active",
            "retired",
            "revoked"
          ]
        },
        "retired_at": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "revoked_at": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "kid",
        "public_jwk",
        "uses",
        "not_before",
        "not_after",
        "state",
        "retired_at",
        "revoked_at"
      ]
    },
    "service": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "base_url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "capabilities": {
          "type": "array",
          "items": {
            "enum": [
              "issue_agreements",
              "issue_tokens",
              "introspect",
              "receive_events",
              "publish_assets"
            ]
          },
          "minItems": 1,
          "maxItems": 5,
          "uniqueItems": true
        },
        "signing_keys": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/signing_key"
          },
          "minItems": 1,
          "maxItems": 16
        },
        "limits": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "max_offer_seconds": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 600
                },
                "max_access_seconds": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 31536000
                },
                "max_use_seconds": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 31536000
                },
                "payment_mode": {
                  "const": "none"
                }
              },
              "required": [
                "max_offer_seconds",
                "max_access_seconds",
                "max_use_seconds",
                "payment_mode"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "base_url",
        "issuer",
        "capabilities",
        "signing_keys",
        "limits"
      ]
    },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "policy_protocol_version": {
          "const": "1.2.0-draft.1"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "policy_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "issued_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}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}Z$"
        },
        "services": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/service"
          },
          "minItems": 1,
          "maxItems": 16
        },
        "delegations": {
          "type": "array",
          "items": {},
          "minItems": 0,
          "maxItems": 0
        }
      },
      "required": [
        "protocol_version",
        "policy_protocol_version",
        "origin",
        "policy_id",
        "revision",
        "issued_at",
        "expires_at",
        "services",
        "delegations"
      ]
    },
    "material_document": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^/",
          "maxLength": 4096
        },
        "media_type": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "body_b64url": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[A-Za-z0-9_-]+$"
        }
      },
      "required": [
        "path",
        "media_type",
        "body_b64url"
      ]
    },
    "material_agreement": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "offer_b64url": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        "acceptance_jws": {
          "type": "string",
          "maxLength": 1048576,
          "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
        },
        "receipt_jws": {
          "type": "string",
          "maxLength": 1048576,
          "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
        },
        "status_history": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1048576,
            "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
          },
          "minItems": 1
        }
      },
      "required": [
        "offer_b64url",
        "acceptance_jws",
        "receipt_jws",
        "status_history"
      ]
    },
    "material_admission": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "active": {
          "const": true
        },
        "permitted": {
          "const": true
        },
        "agreement_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "resource_url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^#]+$"
        },
        "method": {
          "enum": [
            "GET",
            "HEAD"
          ]
        },
        "actions": {
          "type": "array",
          "items": {
            "enum": [
              "retrieve",
              "store",
              "transform",
              "redistribute"
            ]
          },
          "minItems": 1,
          "maxItems": 4,
          "uniqueItems": true
        },
        "purposes": {
          "type": "array",
          "items": {
            "enum": [
              "search_indexing",
              "public_retrieval",
              "internal_knowledge",
              "model_training",
              "model_fine_tuning",
              "redistribution"
            ]
          },
          "minItems": 1,
          "maxItems": 6,
          "uniqueItems": true
        },
        "expires_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "checked_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "request_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "decision_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "status_version": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "authority_revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "authority_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "authority_checked_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "policy_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "policy_revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "terminal_event_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "protocol_version",
        "active",
        "permitted",
        "agreement_id",
        "origin",
        "resource_url",
        "method",
        "actions",
        "purposes",
        "expires_at",
        "checked_at",
        "request_id",
        "decision_id",
        "status_version",
        "authority_revision",
        "authority_digest",
        "authority_checked_at",
        "policy_id",
        "policy_revision",
        "terminal_event_id"
      ]
    },
    "materials": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.2"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "documents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/material_document"
          }
        },
        "agreements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/material_agreement"
          }
        },
        "admissions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/material_admission"
          }
        },
        "records": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1048576,
            "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
          },
          "minItems": 0,
          "maxItems": 1000
        }
      },
      "required": [
        "protocol_version",
        "origin",
        "documents",
        "agreements",
        "admissions",
        "records"
      ]
    }
  }
}
