{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wishyouerehere9610.github.io/fde-insight/knowledge/fde-insight.schema.json",
  "title": "FDE Insight 领域图谱 Schema",
  "description": "用于描述 FDE 领域实体、类型化关系及证据边界的 Schema，内容来自报告证据和明确标注的工程归纳。",
  "type": "object",
  "required": ["meta", "nodes", "relations"],
  "additionalProperties": false,
  "properties": {
    "meta": {
      "type": "object",
      "required": ["title", "version", "schemaVersion", "language", "updated", "sourcePolicy"],
      "additionalProperties": false,
      "properties": {
        "title": {"type": "string", "minLength": 3},
        "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
        "schemaVersion": {"type": "string", "const": "1.0.0"},
        "language": {"type": "string", "const": "zh-CN"},
        "updated": {"type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},
        "sourcePolicy": {"type": "string", "minLength": 24},
        "generatedFrom": {"type": "string", "const": "knowledge/report-analysis.json"}
      }
    },
    "nodes": {
      "type": "array",
      "minItems": 80,
      "items": {"$ref": "#/$defs/node"}
    },
    "relations": {
      "type": "array",
      "minItems": 100,
      "items": {"$ref": "#/$defs/relation"}
    }
  },
  "$defs": {
    "sourceRef": {
      "type": "string",
      "pattern": "^(report:p[0-9]+(-[0-9]+)?|project:synthesis|needs-verification)$"
    },
    "nodeType": {
      "type": "string",
      "enum": [
        "principle",
        "role",
        "stage",
        "mechanism",
        "capability",
        "deliverable",
        "metric",
        "risk",
        "asset",
        "system",
        "market",
        "job-profile",
        "compensation"
      ]
    },
    "relationType": {
      "type": "string",
      "enum": [
        "owns",
        "produces",
        "measured_by",
        "mitigates",
        "depends_on",
        "feeds_back_to",
        "reused_in",
        "precedes",
        "enables",
        "governs",
        "observed_in",
        "requires",
        "compared_with"
      ]
    },
    "node": {
      "type": "object",
      "required": ["id", "type", "name", "definition", "sourceRefs"],
      "additionalProperties": false,
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z0-9-]+$"},
        "type": {"$ref": "#/$defs/nodeType"},
        "name": {"type": "string", "minLength": 2},
        "nameEn": {"type": "string", "minLength": 2},
        "definition": {"type": "string", "minLength": 24},
        "sourceRefs": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {"$ref": "#/$defs/sourceRef"}
        }
      }
    },
    "relation": {
      "type": "object",
      "required": ["from", "to", "type"],
      "additionalProperties": false,
      "properties": {
        "from": {"type": "string", "pattern": "^[a-z0-9-]+$"},
        "to": {"type": "string", "pattern": "^[a-z0-9-]+$"},
        "type": {"$ref": "#/$defs/relationType"}
      }
    }
  }
}
