{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://odexa.io/schemas/1.2.0-draft.3/storage-paid-portable.schema.json",
  "title": "Odexa explicitly selected paid evidence snapshot: odexa-storage-paid-evidence-snapshot-1",
  "description": "Structural only. Independently pinned payer identity, original provider signatures and origin history, exact ordered audit replay, selected dependencies and current export authority require semantic verification. An inert archive grants no access and proves no bank settlement.",
  "$ref": "#/$defs/bundle",
  "$defs": {
    "inventory_item": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "agreement",
            "offer",
            "acceptance",
            "acceptance_jws",
            "receipt_jws",
            "status_jws",
            "intake_jws",
            "admission",
            "decision",
            "document",
            "client_key",
            "payment_quote",
            "payment_accepted",
            "payment_state",
            "payer_proof",
            "payment_audit"
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1048576
        },
        "media_type": {
          "enum": [
            "application/json",
            "application/jose",
            "text/plain"
          ]
        }
      },
      "required": [
        "kind",
        "id",
        "digest",
        "size",
        "media_type"
      ]
    },
    "blob": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "body_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        }
      },
      "required": [
        "digest",
        "body_b64url"
      ]
    },
    "cut": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "records_max_seq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "records_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "status_history": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "version": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "digest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              }
            },
            "required": [
              "version",
              "digest"
            ]
          },
          "minItems": 0,
          "maxItems": 2048
        },
        "status_attestations_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "admissions_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "decisions_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "public_keys_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "payment_audit_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "payment_audit_max_seq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "payer_proofs_count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "records_max_seq",
        "records_count",
        "status_history",
        "status_attestations_count",
        "admissions_count",
        "decisions_count",
        "public_keys_count",
        "payment_audit_count",
        "payment_audit_max_seq",
        "payer_proofs_count"
      ]
    },
    "manifest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.3"
        },
        "origin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "service_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "delegation_id": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^?#]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "profile": {
          "const": "odexa-storage-paid-evidence-snapshot-1"
        },
        "bundle_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}$"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "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}$"
        },
        "cut": {
          "$ref": "#/$defs/cut"
        },
        "source_scope": {
          "const": "all_retained_storage_paid_material_for_one_agreement_at_sqlite_snapshot"
        },
        "global_completeness_claimed": {
          "const": false
        },
        "reactivates_access": {
          "const": false
        },
        "operation": {
          "$ref": "https://odexa.io/schemas/1.2.0-draft.3/delegation.schema.json#/$defs/operation"
        },
        "authority_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "inventory": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/inventory_item"
          },
          "minItems": 1,
          "maxItems": 2048
        }
      },
      "required": [
        "protocol_version",
        "origin",
        "service_id",
        "issuer",
        "delegation_id",
        "profile",
        "bundle_id",
        "created_at",
        "agreement_id",
        "cut",
        "source_scope",
        "global_completeness_claimed",
        "reactivates_access",
        "operation",
        "authority_digest",
        "policy_digest",
        "inventory"
      ]
    },
    "bundle": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.3"
        },
        "profile": {
          "const": "odexa-storage-paid-evidence-snapshot-1"
        },
        "manifest_jws": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1048576,
          "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
        },
        "blobs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/blob"
          },
          "minItems": 1,
          "maxItems": 2048
        }
      },
      "required": [
        "protocol_version",
        "profile",
        "manifest_jws",
        "blobs"
      ]
    },
    "agreement": {
      "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}$"
        },
        "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}$"
        },
        "client_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "principal_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "state": {
          "enum": [
            "active",
            "revoked",
            "expired",
            "pending_payment"
          ]
        },
        "status_version": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "effective_at": {
          "type": "string",
          "format": "date-time",
          "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
        },
        "access_expires_at": {
          "type": "string",
          "format": "date-time",
          "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",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        }
      },
      "required": [
        "id",
        "offer_id",
        "client_id",
        "principal_id",
        "state",
        "status_version",
        "effective_at",
        "reason",
        "access_expires_at",
        "use_expires_at"
      ]
    },
    "client_key": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "client_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "role": {
          "enum": [
            "agent",
            "gateway"
          ]
        },
        "principals": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096,
            "pattern": "^https://[^?#]+$"
          },
          "minItems": 1,
          "maxItems": 256,
          "uniqueItems": true
        },
        "reporter_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "key_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "public_jwk": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "kty": {
              "const": "EC"
            },
            "crv": {
              "const": "P-256"
            },
            "x": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$",
              "maxLength": 43,
              "minLength": 43
            },
            "y": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$",
              "maxLength": 43,
              "minLength": 43
            }
          },
          "required": [
            "kty",
            "crv",
            "x",
            "y"
          ]
        }
      },
      "required": [
        "client_id",
        "role",
        "principals",
        "reporter_id",
        "key_id",
        "public_jwk"
      ]
    },
    "admission": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "gateway_client_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "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"
            }
          ]
        },
        "response_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        }
      },
      "required": [
        "gateway_client_id",
        "terminal_event_id",
        "response_b64url"
      ]
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "operation_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        },
        "decision_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        },
        "observation_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        },
        "authority_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "operation_b64url",
        "decision_b64url",
        "observation_b64url",
        "authority_digest",
        "policy_digest"
      ]
    },
    "payment_quote": {
      "$ref": "https://odexa.io/schemas/1.2.0-draft.3/payment.schema.json#/$defs/quote"
    },
    "payment_accepted": {
      "$ref": "https://odexa.io/schemas/1.2.0-draft.3/payment.schema.json#/$defs/accepted_binding"
    },
    "payer_proof": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "payer_client_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,128}$"
        },
        "mandate_jws": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1048576,
          "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
        },
        "payload_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        },
        "public_identity_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 1398102
        }
      },
      "required": [
        "payer_client_id",
        "mandate_jws",
        "payload_b64url",
        "public_identity_b64url"
      ]
    },
    "payment_audit": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "sequence": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "kind": {
          "enum": [
            "accepted",
            "payer_mandate",
            "verification",
            "expired",
            "revoked"
          ]
        },
        "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$"
        },
        "state_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "input_b64url": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$",
              "maxLength": 1398102
            },
            {
              "type": "null"
            }
          ]
        },
        "context_b64url": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$",
              "maxLength": 1398102
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "sequence",
        "kind",
        "recorded_at",
        "state_digest",
        "input_b64url",
        "context_b64url"
      ]
    },
    "payment_state": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "payment_state": {
          "enum": [
            "pending",
            "failed",
            "confirmed",
            "reversed"
          ]
        },
        "access_state": {
          "enum": [
            "pending_payment",
            "active",
            "expired",
            "revoked"
          ]
        },
        "checks": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "prefixItems": [
              {
                "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": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              }
            ],
            "items": false
          }
        },
        "last_sequence": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "last_effective_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"
            }
          ]
        },
        "provider_reference": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "payment_state",
        "access_state",
        "checks",
        "last_sequence",
        "last_effective_at",
        "provider_reference"
      ]
    }
  }
}
