{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.agenttool.dev/schemas/kingdom-deepseek-proposal-v0.1.schema.json",
  "title": "KINGDOM DeepSeek proposal v0.1",
  "description": "Closed proposal-only schema with an embedded standalone DeepSeek source binding.",
  "$comment": "Runtime validation recomputes content IDs, ordering, and cross-references. Acceptance does not apply a proposal or verify claims, identity, license compatibility, safety, or authority.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "_format",
    "proposal_id",
    "proposal_key",
    "source",
    "target",
    "delta",
    "integration",
    "state",
    "effects",
    "authority",
    "license_boundary"
  ],
  "properties": {
    "_format": { "const": "kingdom.deepseek-proposal/0.1" },
    "proposal_id": { "$ref": "#/$defs/sha256Id" },
    "proposal_key": { "$ref": "#/$defs/id200" },
    "source": { "$ref": "#/$defs/sourceBinding" },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": ["consumer", "kingdom_snapshot_sha256"],
      "properties": {
        "consumer": {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "id"],
          "properties": {
            "kind": { "enum": ["kingdom_extension", "artbitrage"] },
            "id": { "$ref": "#/$defs/id160" }
          }
        },
        "kingdom_snapshot_sha256": { "$ref": "#/$defs/sha256Id" }
      }
    },
    "delta": {
      "type": "object",
      "additionalProperties": false,
      "required": ["candidates"],
      "properties": {
        "candidates": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "candidate_id",
              "candidate_kind",
              "lane",
              "title",
              "claim_refs",
              "evidence_refs",
              "status",
              "review_required"
            ],
            "properties": {
              "candidate_id": { "$ref": "#/$defs/id160" },
              "candidate_kind": {
                "enum": [
                  "architecture_pattern",
                  "training_pattern",
                  "evaluation_fixture",
                  "dataset_candidate",
                  "model_candidate",
                  "infrastructure_pattern"
                ]
              },
              "lane": {
                "enum": [
                  "reasoning",
                  "formal_verification",
                  "multimodal",
                  "long_context",
                  "conditional_memory",
                  "training_systems",
                  "evaluation",
                  "research_provenance"
                ]
              },
              "title": { "$ref": "#/$defs/text200" },
              "claim_refs": {
                "type": "array",
                "minItems": 1,
                "maxItems": 64,
                "uniqueItems": true,
                "items": { "$ref": "#/$defs/id160" }
              },
              "evidence_refs": {
                "type": "array",
                "minItems": 1,
                "maxItems": 1,
                "uniqueItems": true,
                "items": { "$ref": "#/$defs/sha256Id" }
              },
              "status": { "const": "proposed" },
              "review_required": { "const": true }
            }
          }
        }
      }
    },
    "integration": {
      "const": {
        "kingdom": {
          "relationship": "unaccepted_proposal",
          "registry_write_performed": false
        },
        "karma": {
          "relationship": "proposal_input_candidate",
          "compatibility_claimed": false,
          "import_performed": false
        },
        "dark_continent": {
          "contract_id": "agenttool.dark-continent/0.1",
          "source_snapshot_sha256": "sha256:f47e1c3ca9da1b97676e1d454cf7235eddd612902c19debe580a6934adcd2b86",
          "walls_status": "not_checked",
          "recommendation": "hold"
        }
      }
    },
    "state": { "const": "proposed_unaccepted" },
    "effects": {
      "const": {
        "network_reads": 0,
        "network_writes": 0,
        "credential_reads": 0,
        "artifact_downloads": 0,
        "model_executions": 0,
        "remote_compute_calls": 0,
        "graph_writes": 0,
        "registry_writes": 0,
        "score_writes": 0,
        "reward_writes": 0
      }
    },
    "authority": {
      "const": {
        "advisory": true,
        "verifies_claims": false,
        "verifies_identity": false,
        "grants_permission": false,
        "approves_license": false,
        "authorizes_inference": false,
        "authorizes_download": false,
        "authorizes_publication": false,
        "authorizes_deployment": false,
        "authorizes_kingdom_registration": false,
        "accepts_karma_proposal": false,
        "assigns_score": false,
        "assigns_rank": false
      }
    },
    "license_boundary": {
      "const": {
        "adapter_license": "Apache-2.0",
        "adapter_license_applies_to_upstream_assets": false,
        "upstream_assets_bundled": false,
        "upstream_license_review_required": true,
        "license_compatibility_verified": false,
        "permission_granted": false
      }
    }
  },
  "$defs": {
    "sha256Id": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "sha40": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
    "date": { "type": "string", "format": "date" },
    "id160": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+\\-]*$"
    },
    "id200": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+\\-]*$"
    },
    "safeText": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u206f]+$"
    },
    "text120": { "type": "string", "allOf": [{ "$ref": "#/$defs/safeText" }], "maxLength": 120 },
    "text160": { "type": "string", "allOf": [{ "$ref": "#/$defs/safeText" }], "maxLength": 160 },
    "text200": { "type": "string", "allOf": [{ "$ref": "#/$defs/safeText" }], "maxLength": 200 },
    "text280": { "type": "string", "allOf": [{ "$ref": "#/$defs/safeText" }], "maxLength": 280 },
    "deepseekRepo": {
      "type": "string",
      "pattern": "^deepseek-ai/[A-Za-z0-9][A-Za-z0-9._-]{0,95}$"
    },
    "relativePath": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.?(?:/|$))(?!.*//)(?!.*\\\\).+$"
    },
    "githubEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["origin", "resource_kind", "repository_id", "revision", "path", "sha256", "observed_on"],
      "properties": {
        "origin": { "const": "deepseek_github" },
        "resource_kind": { "const": "code_repository" },
        "repository_id": { "$ref": "#/$defs/deepseekRepo" },
        "revision": { "$ref": "#/$defs/sha40" },
        "path": { "$ref": "#/$defs/relativePath" },
        "sha256": { "$ref": "#/$defs/sha256Id" },
        "observed_on": { "$ref": "#/$defs/date" }
      }
    },
    "hfEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["origin", "resource_kind", "repository_id", "revision", "path", "sha256", "observed_on"],
      "properties": {
        "origin": { "const": "deepseek_huggingface" },
        "resource_kind": { "enum": ["model_repository", "dataset_repository"] },
        "repository_id": { "$ref": "#/$defs/deepseekRepo" },
        "revision": { "$ref": "#/$defs/sha40" },
        "path": { "$ref": "#/$defs/relativePath" },
        "sha256": { "$ref": "#/$defs/sha256Id" },
        "observed_on": { "$ref": "#/$defs/date" }
      }
    },
    "arxivEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["origin", "resource_kind", "repository_id", "revision", "path", "sha256", "observed_on"],
      "properties": {
        "origin": { "const": "arxiv_primary" },
        "resource_kind": { "const": "paper" },
        "repository_id": { "type": "string", "pattern": "^\\d{4}\\.\\d{4,5}$" },
        "revision": { "type": "string", "pattern": "^\\d{4}\\.\\d{4,5}v[1-9][0-9]*$" },
        "path": { "type": "null" },
        "sha256": { "$ref": "#/$defs/sha256Id" },
        "observed_on": { "$ref": "#/$defs/date" }
      }
    },
    "evidence": {
      "oneOf": [
        { "$ref": "#/$defs/githubEvidence" },
        { "$ref": "#/$defs/hfEvidence" },
        { "$ref": "#/$defs/arxivEvidence" }
      ]
    },
    "sourceBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": ["_format", "binding_id", "publisher", "subject", "license", "claims", "status", "boundaries"],
      "properties": {
        "_format": { "const": "agenttool.deepseek-source-binding/0.1" },
        "binding_id": { "$ref": "#/$defs/sha256Id" },
        "publisher": { "const": "deepseek-ai" },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": ["label", "evidence", "evidence_ref"],
          "properties": {
            "label": { "$ref": "#/$defs/text200" },
            "evidence": { "$ref": "#/$defs/evidence" },
            "evidence_ref": { "$ref": "#/$defs/sha256Id" }
          }
        },
        "license": {
          "type": "object",
          "additionalProperties": false,
          "required": ["scope", "declared_expression", "evidence", "review_status", "basis"],
          "properties": {
            "scope": { "enum": ["code", "model_weights", "dataset", "paper", "mixed_repository"] },
            "declared_expression": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/text120" }] },
            "evidence": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/evidence" }] },
            "review_status": { "enum": ["not_reviewed", "caller_reviewed"] },
            "basis": { "const": "caller_reported" }
          },
          "allOf": [
            {
              "if": { "properties": { "declared_expression": { "type": "null" } } },
              "then": { "properties": { "evidence": { "type": "null" } } },
              "else": { "properties": { "evidence": { "$ref": "#/$defs/evidence" } } }
            }
          ]
        },
        "claims": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["claim_id", "claim_kind", "summary", "source_anchor", "basis", "verification"],
            "properties": {
              "claim_id": { "$ref": "#/$defs/id160" },
              "claim_kind": { "enum": ["architecture", "training_method", "evaluation", "dataset_lineage", "infrastructure", "capability", "limitation"] },
              "summary": { "$ref": "#/$defs/text280" },
              "source_anchor": { "$ref": "#/$defs/text160" },
              "basis": { "const": "caller_asserted_from_primary_source" },
              "verification": { "const": "not_performed" }
            }
          }
        },
        "status": { "const": "metadata_bound" },
        "boundaries": {
          "const": {
            "immutable_evidence_required": true,
            "repository_association_verified": false,
            "publisher_claims_verified": false,
            "claim_truth_verified": false,
            "license_compatibility_verified": false,
            "source_bytes_downloaded_by_adapter": false,
            "model_code_executed": false
          }
        }
      }
    }
  }
}
