{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dharma-ai.io/schemas/repository-package-transfer.schema.json",
  "title": "Repository package byte-transfer index; not release authority",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "organizationId", "repositoryAgentId", "releaseId", "gitCommit", "totalBytes", "files"],
  "properties": {
    "schema": { "const": "dharma.repository-package-transfer/v1" },
    "organizationId": { "type": "string", "pattern": "^org_[A-Za-z0-9_]{1,156}(?![\\s\\S])" },
    "repositoryAgentId": { "$ref": "#/$defs/id" },
    "releaseId": { "$ref": "#/$defs/id" },
    "gitCommit": { "type": "string", "pattern": "^(?:[0-9a-f]{40}|[0-9a-f]{64})(?![\\s\\S])" },
    "totalBytes": { "type": "integer", "minimum": 0, "maximum": 4194304 },
    "files": {
      "type": "array", "minItems": 1, "maxItems": 512,
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["path", "sha256", "sizeBytes", "chunkHashes"],
        "properties": {
          "path": { "type": "string", "minLength": 1, "maxLength": 500 },
          "sha256": { "$ref": "#/$defs/digest" },
          "sizeBytes": { "type": "integer", "minimum": 0, "maximum": 262144 },
          "chunkHashes": { "type": "array", "maxItems": 4, "items": { "$ref": "#/$defs/digest" } }
        }
      }
    }
  },
  "$defs": {
    "id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,159}(?![\\s\\S])" },
    "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" }
  },
  "$comment": "Runtime additionally checks normalized safe relative paths, case collisions, whole-release totals, chunk lengths, empty-file hashes and index size. Expected scope and index hash must come from protected enrollment and the existing verified signed release."
}
