{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://studio.funly-ai.com/schemas/campaign-manifest-v1.schema.json",
  "title": "织影详情页生产批次 Manifest v1",
  "type": "object",
  "required": ["schema_version", "id", "name", "anchors", "styles"],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{3,80}$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "description": {
      "type": "string",
      "maxLength": 2000
    },
    "anchors": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "required": ["id", "name", "source_url"],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{3,80}$"
          },
          "name": {
            "type": "string"
          },
          "source_url": {
            "type": "string",
            "description": "允许已入库锚点、商品图或 runtime-data 中当前项目的 source/assets 图片。",
            "pattern": "^\\./(assets/(anchors|products)/[A-Za-z0-9_.-]+|runtime-data/jobs/[A-Za-z0-9_-]+/(source|assets)/[A-Za-z0-9_.-]+)$"
          },
          "complexity": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "styles": {
      "description": "矩阵列。既可表示旧版全局风格，也可仅表示量身风格的槽位列；实际单元风格以 cells 覆盖字段优先。",
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "required": ["id", "name", "scene_catalog_id"],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{3,80}$"
          },
          "name": {
            "type": "string"
          },
          "scene_catalog_id": {
            "type": "string",
            "pattern": "^SC[0-9]{2}$"
          }
        },
        "additionalProperties": true
      }
    },
    "cells": {
      "description": "可选。省略时服务器按旧版兼容逻辑建立 anchors × styles 笛卡尔积（10场景+4事实）；提供时每个单元可拥有独立量身风格（默认9场景+7事实）。",
      "type": "array",
      "items": {
        "type": "object",
        "required": ["anchor_id", "style_id"],
        "properties": {
          "id": {
            "type": "string"
          },
          "anchor_id": {
            "type": "string"
          },
          "style_id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "单元自己的风格显示名，优先于列槽位名称。"
          },
          "production_style_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{3,80}$",
            "description": "真实生产风格 ID；style_id 可以只是 SLOT1/SLOT2/SLOT3。"
          },
          "scene_catalog_id": {
            "type": "string",
            "pattern": "^SC[0-9]{2}$",
            "description": "单元自己的场景目录映射，优先于列槽位的映射。"
          },
          "external_task_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "可选的外部分镜/生成任务 ID，用于追溯。"
          },
          "job_id": {
            "type": ["string", "null"]
          },
          "channel": {
            "type": "string",
            "default": "auto"
          },
          "target_marketing_scenes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 9
          },
          "fact_modules": {
            "type": "integer",
            "minimum": 0,
            "maximum": 7,
            "default": 7
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}
