{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://odexa.io/schemas/1.2.0-draft.3/asset.schema.json",
  "title": "Odexa explicit native asset publication and closed derivation evidence",
  "$comment": "Structural only. Signatures, exact original bytes, independent history/current pins, immutable versions, scoped publication, graph closure and source-qualified delivery correlation require semantic checks. No content access is granted.",
  "oneOf": [
    {
      "$ref": "#/$defs/manifest"
    },
    {
      "$ref": "#/$defs/bundle"
    }
  ],
  "$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.3"
        },
        "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
        },
        "profile": {
          "const": "asset_evidence_v1"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^https://[^?#]+$"
        },
        "delegation_id": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096,
              "pattern": "^https://[^?#]+$"
            },
            {
              "type": "null"
            }
          ]
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "publication": {
          "$ref": "https://odexa.io/schemas/1.2.0-draft.3/delegation.schema.json#/$defs/operation"
        },
        "content_variants": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/content_variant"
          },
          "minItems": 0,
          "maxItems": 64
        },
        "derived_from": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/derivation"
          },
          "minItems": 0,
          "maxItems": 32
        }
      },
      "required": [
        "protocol_version",
        "origin",
        "asset_id",
        "version_id",
        "published_at",
        "authority",
        "representations",
        "profile",
        "issuer",
        "delegation_id",
        "policy_digest",
        "publication",
        "content_variants",
        "derived_from"
      ]
    },
    "content_variant": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "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}$"
        },
        "content_codings": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,31}$",
            "not": {
              "const": "identity"
            }
          },
          "minItems": 1,
          "maxItems": 8
        },
        "content_length": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "content_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "representation_id",
        "content_codings",
        "content_length",
        "content_digest"
      ]
    },
    "derivation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "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}$"
        },
        "source": {
          "$ref": "#/$defs/asset_ref"
        },
        "relationship": {
          "enum": [
            "copy",
            "extract",
            "transform"
          ]
        }
      },
      "required": [
        "representation_id",
        "source",
        "relationship"
      ]
    },
    "document": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "body_b64url": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "maxLength": 174763
        }
      },
      "required": [
        "digest",
        "body_b64url"
      ]
    },
    "bundle": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "1.2.0-draft.3"
        },
        "profile": {
          "const": "asset_evidence_v1"
        },
        "roots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/asset_ref"
          },
          "minItems": 1,
          "maxItems": 64,
          "uniqueItems": true
        },
        "manifests": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$",
            "maxLength": 262144
          },
          "minItems": 1,
          "maxItems": 32
        },
        "documents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/document"
          },
          "minItems": 1,
          "maxItems": 64
        }
      },
      "required": [
        "protocol_version",
        "profile",
        "roots",
        "manifests",
        "documents"
      ]
    }
  }
}
