{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/knowledge-unit/latest.json",
  "title": "Knowledge Unit",
  "description": "A verified knowledge artifact produced through structured multi-model deliberation, as defined in draft-farley-acta-knowledge-units-00 (IETF Internet-Draft).",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/knowledge-unit.json",
    "sourceSha256": "eca318be68c12c07a0cc55c455ed9afa94e5a312e6b9be945e132e8c532099e2",
    "fileMatch": [
      "ku-*.json",
      "knowledge-unit.json",
      "**/ku/*.json"
    ],
    "parsers": [
      "json"
    ]
  },
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ku-[a-z0-9]{12}$",
      "description": "Unique identifier. Format: ku- followed by 12 alphanumeric characters."
    },
    "version": {
      "type": "integer",
      "const": 1,
      "description": "Schema version number. Current version is 1."
    },
    "canonical_question": {
      "type": "string",
      "minLength": 1,
      "description": "The definitive question this KU answers."
    },
    "domain": {
      "type": "string",
      "enum": [
        "technology",
        "science",
        "health",
        "policy",
        "economics",
        "agent_security",
        "agent_governance",
        "research",
        "engineering"
      ],
      "description": "Topic classification."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9-]+$"
      },
      "description": "Additional classification labels for cross-domain discovery."
    },
    "consensus_level": {
      "type": "string",
      "enum": [
        "unanimous",
        "strong",
        "split",
        "divergent"
      ],
      "description": "Structural classification of agreement among participating models."
    },
    "agreed": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "required": [
              "claim"
            ],
            "properties": {
              "claim": {
                "type": "string"
              },
              "confidence": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ]
              },
              "evidence": {
                "type": "string"
              },
              "source_refs": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        ]
      },
      "description": "Points where all participating models converge."
    },
    "disputed": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "claim",
          "positions"
        ],
        "properties": {
          "claim": {
            "type": "string"
          },
          "positions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "significance": {
            "type": "string",
            "enum": [
              "core",
              "framing",
              "edge_case"
            ]
          }
        }
      },
      "description": "Points where models diverge, with per-model positions."
    },
    "uncertain": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "required": [
              "claim"
            ],
            "properties": {
              "claim": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            }
          }
        ]
      },
      "description": "Points that no model could resolve with confidence."
    },
    "synthesis": {
      "type": "string",
      "description": "Editorial summary. NOT canonical - the agreed/disputed/uncertain arrays are authoritative."
    },
    "models_used": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 2,
      "description": "Model identifiers (provider/model format)."
    },
    "roster_version": {
      "type": "string",
      "format": "date",
      "description": "ISO 8601 date of the model roster snapshot."
    },
    "roster_hash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 hash of the sorted models_used array."
    },
    "process_template": {
      "type": "string",
      "default": "3-round",
      "description": "Deliberation process template used."
    },
    "total_tokens": {
      "type": "integer",
      "minimum": 0,
      "description": "Total tokens consumed across all rounds and models."
    },
    "total_cost_cents": {
      "type": "number",
      "minimum": 0,
      "description": "Total API cost in US cents."
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "uri",
          "content_hash",
          "ingested_at"
        ],
        "properties": {
          "uri": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "content_hash": {
            "type": "string",
            "pattern": "^sha256:[a-f0-9]{64}$"
          },
          "ingested_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "description": "Source documents with content hashes for freshness validation."
    },
    "source_url": {
      "type": "string",
      "format": "uri",
      "description": "Primary source URL (backwards compatibility)."
    },
    "source_title": {
      "type": "string",
      "description": "Primary source title (backwards compatibility)."
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "stale",
        "superseded"
      ],
      "description": "Current lifecycle state."
    },
    "fresh_until": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 datetime after which this KU should be considered potentially stale."
    },
    "volatility": {
      "type": "string",
      "enum": [
        "stable",
        "evolving",
        "volatile"
      ],
      "default": "evolving",
      "description": "Expected rate of change for this knowledge domain."
    },
    "supersedes": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^ku-[a-z0-9]{12}$",
      "description": "ID of the KU this KU replaces."
    },
    "parent_ku_id": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^ku-[a-z0-9]{12}$",
      "description": "ID of a parent KU from which this question was derived."
    },
    "published_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 datetime of publication."
    },
    "receipt_sig": {
      "type": "string",
      "pattern": "^[a-f0-9]{128}$",
      "description": "Aggregate Ed25519 signature over the receipt chain hash."
    },
    "receipt_kid": {
      "type": "string",
      "description": "Key identifier for the signing key."
    },
    "receipt_hash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 hash of the chained per-round receipt hashes."
    },
    "relations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "target_ku_id",
          "relation"
        ],
        "properties": {
          "target_ku_id": {
            "type": "string",
            "pattern": "^ku-[a-z0-9]{12}$"
          },
          "relation": {
            "type": "string",
            "enum": [
              "supports",
              "contradicts",
              "refines",
              "extends",
              "depends_on"
            ]
          },
          "claims": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "description": "Typed relations to other Knowledge Units."
    }
  },
  "required": [
    "id",
    "version",
    "canonical_question",
    "consensus_level",
    "agreed",
    "models_used",
    "process_template",
    "status",
    "fresh_until",
    "receipt_sig",
    "receipt_kid",
    "receipt_hash"
  ],
  "additionalProperties": false
}
