{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usedeed.app/contracts/deed.formal_proof_package.v1.schema.json",
  "title": "DEED formal proof package v1",
  "description": "Manifest for the reproducible DEED Q-anamorphism proof package. It proves package integrity and type-check reproducibility; it grants no custody or execution authority.",
  "type": "object",
  "required": [
    "$schema",
    "schema_version",
    "package_id",
    "status",
    "subject",
    "boundaries",
    "vendored_dependency",
    "toolchain",
    "reproduction",
    "package_files_hash_algorithm",
    "package_files",
    "standalone_verifier_package",
    "external_reviewer_entrypoint"
  ],
  "properties": {
    "$schema": { "const": "https://usedeed.app/contracts/deed.formal_proof_package.v1.schema.json" },
    "schema_version": { "const": "deed.formal_proof_package.v1" },
    "package_id": { "const": "deed.q_anamorphism.formal_proof.v1" },
    "status": { "const": "repo_ready_reproducible_package" },
    "subject": {
      "type": "object",
      "required": ["theorem_module", "theorem_file", "theorem_summary", "bridge_contract", "bridge_runtime"],
      "properties": {
        "theorem_module": { "const": "DEED.QAnamorphism" },
        "theorem_file": { "const": "formal/DEED/QAnamorphism.agda" },
        "theorem_summary": { "type": "string", "minLength": 1 },
        "bridge_contract": { "const": "formal/runtime-state-contract.json" },
        "bridge_runtime": { "const": "formal/runtime-frontier-state.mjs" }
      },
      "additionalProperties": false
    },
    "boundaries": {
      "type": "object",
      "required": ["self_custody", "deed_holds_user_keys", "grants_execution_authority", "grants_custody", "grants_revocation_authority", "note"],
      "properties": {
        "self_custody": { "const": true },
        "deed_holds_user_keys": { "const": false },
        "grants_execution_authority": { "const": false },
        "grants_custody": { "const": false },
        "grants_revocation_authority": { "const": false },
        "note": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "vendored_dependency": {
      "type": "object",
      "required": ["library", "source", "provenance_url", "provenance_commit", "vendor_dir", "closure_file", "tree_hash_algorithm", "tree_hash", "file_count", "import_closure_modules", "imported_roots"],
      "properties": {
        "library": { "const": "agda/cubical" },
        "source": { "const": "vendored-import-closure" },
        "provenance_url": { "const": "https://github.com/agda/cubical.git" },
        "provenance_commit": { "$ref": "#/$defs/gitSha" },
        "vendor_dir": { "const": "formal/vendor/cubical" },
        "closure_file": { "const": "formal/cubical-import-closure.json" },
        "tree_hash_algorithm": { "type": "string", "minLength": 1 },
        "tree_hash": { "$ref": "#/$defs/sha256" },
        "file_count": { "type": "integer", "minimum": 1 },
        "import_closure_modules": { "type": "integer", "minimum": 1 },
        "imported_roots": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1, "uniqueItems": true }
      },
      "additionalProperties": false
    },
    "toolchain": { "type": "object", "required": ["agda", "agda_flags", "dockerfile", "docker_base", "node_in_docker"], "additionalProperties": { "type": "string", "minLength": 1 } },
    "reproduction": { "type": "object", "required": ["working_directory", "manifest_check", "bridge_conformance", "offline_typecheck", "negative_digest", "negative_offline_missing", "docker_build", "docker_run_offline", "pass_marker"], "additionalProperties": { "type": "string", "minLength": 1 } },
    "package_files_hash_algorithm": { "const": "sha256-file-v1" },
    "package_files": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["path", "bytes", "sha256"],
        "properties": {
          "path": { "type": "string", "minLength": 1 },
          "bytes": { "type": "integer", "minimum": 1 },
          "sha256": { "$ref": "#/$defs/sha256" }
        },
        "additionalProperties": false
      }
    },
    "standalone_verifier_package": {
      "type": "object",
      "required": ["path", "name", "version", "filename", "artifactAlgorithm", "integrity", "shasum", "entryCount", "unpackedSize", "files", "bundled", "source"],
      "properties": {
        "path": { "const": "packages/deed-card-verify" },
        "name": { "const": "@usedeed/card-verify" },
        "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
        "filename": { "type": "string", "pattern": "^usedeed-card-verify-[0-9]+\\.[0-9]+\\.[0-9]+\\.tgz$" },
        "artifactAlgorithm": { "type": "string", "minLength": 1 },
        "integrity": { "type": "string", "pattern": "^sha512-" },
        "shasum": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "entryCount": { "type": "integer", "minimum": 1 },
        "unpackedSize": { "type": "integer", "minimum": 1 },
        "files": { "type": "array", "items": { "type": "object" }, "minItems": 1 },
        "bundled": { "type": "array" },
        "source": { "type": "object", "required": ["path", "hashAlgorithm", "sha256"] }
      },
      "additionalProperties": false
    },
    "external_reviewer_entrypoint": { "type": "object", "required": ["read_first", "fast_manifest_check", "full_offline_reproduction"], "additionalProperties": { "type": "string", "minLength": 1 } }
  },
  "$defs": {
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "gitSha": { "type": "string", "pattern": "^[0-9a-f]{40}$" }
  },
  "additionalProperties": false
}
