{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "ingest-payload-how.schema.json",
  "title": "创作知识 Ingest Payload · How(工序)",
  "$comment": "How 颗 = 不可跳步的有序工序。content 为拍平字符串：目标(=purpose) + 步骤N(输入/方法/产出)。一颗知识 = 一个 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" },
            "unique_key": { "type": "string" },
            "platform_item_id": { "type": "string" },
            "content_type": { "type": "string" },
            "content_mode": { "type": "string" },
            "media_count": { "type": "integer" },
            "cover_url": { "type": "string" },
            "date": { "type": "string" }
          }
        }
      }
    },
    "title": { "type": "string", "minLength": 1, "$comment": "知识名（框架名），如 撕裂共识选题框架" },
    "content": {
      "type": "string",
      "minLength": 1,
      "$comment": "拍平字符串：目标(=purpose) + 步骤N(输入/方法/产出)"
    },
    "dim_creations": {
      "type": "array",
      "items": { "const": "创作" },
      "minItems": 1,
      "maxItems": 1,
      "$comment": "恒 [\"创作\"]，写死"
    },
    "dim_attributes": {
      "type": "array",
      "items": { "const": "how" },
      "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": "业务阶段(灵感/选题/脚本) + 创作阶段(定向/构思/结构/成文/打磨，逐步去重) + 动作(开放，逐步)；多值各一条"
    }
  }
}
