{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "ingest-payload-why.schema.json",
  "title": "创作知识 Ingest Payload · Why(原理)",
  "$comment": "Why 颗 = 解释某做法/判断背后的道理。content 是结构化对象 {name,desc} 的 JSON 字符串（接口要求 content 为 string，故 json.dumps 后传）：name=原理名，desc=阐述(是什么+为什么,忠实整合原帖；不含'怎么用')。一颗知识 = 一个 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": "结构化对象 {name,desc} 的 JSON 字符串（json.dumps(ensure_ascii=False)）。解析后：name=原理名(通常同title) + desc=阐述(是什么+为什么,忠实整合原帖,不含'怎么用')。结构校验见 lint-payload.py。"
    },
    "dim_creations": {
      "type": "array",
      "items": { "const": "创作" },
      "minItems": 1,
      "maxItems": 1,
      "$comment": "恒 [\"创作\"]，写死"
    },
    "dim_attributes": {
      "type": "array",
      "items": { "const": "why原理" },
      "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": "业务阶段(灵感/选题/脚本)；组件颗加「出自」=出自哪个 how 第几步。Why 无创作阶段/动作"
    }
  }
}
