{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://odexa.io/schemas/1.2.0-draft.3/storage-portable.schema.json",
  "title": "Odexa explicitly selected storage free evidence snapshot",
  "description": "Structural shape only. Original selected offer/assent/receipt, exact copy-parent closure, independent origin and reporter pins, source qualification and current export authority require semantic verification. No access reactivation.",
  "$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"
          ]
        },
        "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
        }
      },
      "required": [
        "records_max_seq",
        "records_count",
        "status_history",
        "status_attestations_count",
        "admissions_count",
        "decisions_count",
        "public_keys_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-free-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_free_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-free-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"
          ]
        },
        "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"
      ]
    }
  }
}
