{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "ingest-payload-what.schema.json",
  "title": "创作知识 Ingest Payload · What(构成)",
  "$comment": "What 颗 = 界定/列举/分类某创作对象。content 是【结构化实体的 JSON 字符串】（接口要求 content 为 string，故对象 json.dumps 后传）；解析后结构 = name + kind + 维度拆分规则 + body[]。概要放进 custom_ext。一颗知识 = 一个 payload；同帖多颗共享 source.id。",
  "type": "object",
  "required": ["source", "title", "content", "dim_creations", "dim_attributes", "scopes"],
  "additionalProperties": false,
  "properties": {
    "source": {
      "type": "object",
      "required": ["id", "source_type", "title"],
      "additionalProperties": true,
      "properties": {
        "id": { "type": "string", "$comment": "xhs_<content_id> / dy_<id> 等；同帖多颗共享" },
        "source_type": { "type": "string", "$comment": "通常 post" },
        "title": { "type": "string", "$comment": "原帖标题" },
        "author": { "type": "string" },
        "source_metadata": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "platform": { "type": "string" },
            "url": { "type": "string" },
            "date": { "type": "string" }
          }
        }
      }
    },
    "title": { "type": "string", "minLength": 1, "$comment": "知识名，如 剧本冲突的四种类型" },
    "content": {
      "type": "string",
      "minLength": 1,
      "$comment": "结构化实体的 JSON 字符串（json.dumps(ensure_ascii=False)）。解析后对象（对应前端「知识实体 JSON」）= { name(知识名,通常同title) + kind(子集|多维关系|序列) + 维度拆分规则(仅子集填,沿哪个维度切分；否则null) + body[](扁平条目: item_name + item_desc + 作用域[](item级,当前留空占位[],仅用颗级 scopes)) }。结构校验见 lint-payload.py。"
    },
    "dim_creations": {
      "type": "array",
      "items": { "const": "创作" },
      "minItems": 1,
      "maxItems": 1,
      "$comment": "恒 [\"创作\"]，写死"
    },
    "dim_attributes": {
      "type": "array",
      "items": { "const": "what" },
      "minItems": 1,
      "maxItems": 1
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["scope_type", "value"],
        "additionalProperties": false,
        "properties": {
          "scope_type": { "type": "string", "enum": ["substance", "form", "feeling", "effect", "intent"] },
          "value": { "type": "string", "minLength": 1, "$comment": "带值；定位到 5 棵树现有节点，对得上复用原名" }
        }
      },
      "minItems": 1,
      "$comment": "颗级 scope；同类可多条（平铺多值）"
    },
    "custom_ext": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["key", "type", "value"],
        "additionalProperties": false,
        "properties": {
          "key": { "type": "string", "enum": ["业务阶段", "概要", "出自"] },
          "type": { "const": "str" },
          "value": { "type": "string", "minLength": 1 }
        }
      },
      "$comment": "业务阶段(灵感/选题/脚本) + 概要(一句话锚点，从旧字段迁来)；组件颗加「出自」。What 无创作阶段/动作"
    }
  }
}
