{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.agenttool.dev/schemas/agenttool-deepseek-source-binding-v0.1.schema.json",
  "title": "AgentTool DeepSeek source binding v0.1",
  "description": "Closed structural schema for caller-supplied, content-addressed primary-source metadata. Runtime validation recomputes binding IDs and cross-field evidence relations.",
  "$comment": "Schema acceptance does not verify source association, publisher claims, claim truth, license compatibility, or permission.",
  "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
      }
    }
  },
  "$defs": {
    "sha256Id": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "id160": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160,
      "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 },
    "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" }
      ]
    },
    "deepseekRepo": {
      "type": "string",
      "pattern": "^deepseek-ai/[A-Za-z0-9][A-Za-z0-9._-]{0,95}$"
    },
    "sha40": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
    "date": { "type": "string", "format": "date" },
    "relativePath": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.?(?:/|$))(?!.*//)(?!.*\\\\).+$"
    }
  }
}
