{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://compo.kluchna24.ru/schemas/compo-creative-engine/v1/creative-request.schema.json",
  "title": "COMPO CreativeRequest v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "request_id", "client", "brief", "output", "idempotency_key"],
  "properties": {
    "schema": {"const": "compo-creative-engine/v1/creative-request"},
    "request_id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{2,127}$"},
    "client": {"type": "string", "enum": ["web", "figma", "hermes", "external_api", "content_batch", "workbench"]},
    "tenant_ref": {"type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$"},
    "brief": {"type": "string", "minLength": 1, "maxLength": 12000},
    "profile_ref": {"$ref": "creative_profile.schema.json#/$defs/profileRef"},
    "assets": {"type": "array", "maxItems": 64, "items": {"$ref": "#/$defs/assetRef"}},
    "output": {"$ref": "#/$defs/outputSpec"},
    "review_mode": {"type": "string", "enum": ["owner_required", "team_review", "draft_only"]},
    "idempotency_key": {"type": "string", "minLength": 8, "maxLength": 200},
    "callback": {"$ref": "#/$defs/callback"}
  },
  "$defs": {
    "assetRef": {
      "type": "object", "additionalProperties": false,
      "required": ["asset_ref", "mime_type", "sha256"],
      "properties": {
        "asset_ref": {"type": "string", "pattern": "^[A-Za-z0-9_.:/-]{1,256}$"},
        "mime_type": {"type": "string", "enum": ["image/png", "image/jpeg", "image/webp", "image/svg+xml"]},
        "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
        "role_hint": {"type": "string", "enum": ["reference", "subject", "background", "logo", "texture", "unknown"]}
      }
    },
    "outputSpec": {
      "type": "object", "additionalProperties": false,
      "required": ["width", "height", "formats", "editable_scene"],
      "properties": {
        "width": {"type": "integer", "minimum": 256, "maximum": 4096},
        "height": {"type": "integer", "minimum": 256, "maximum": 4096},
        "formats": {"type": "array", "minItems": 1, "maxItems": 4, "items": {"type": "string", "enum": ["scene", "png", "webp", "html"]}},
        "editable_scene": {"type": "boolean"},
        "channel": {"type": "string", "enum": ["web", "figma", "hermes_smm", "external"]}
      }
    },
    "callback": {
      "type": "object", "additionalProperties": false,
      "required": ["mode"],
      "properties": {
        "mode": {"type": "string", "enum": ["poll", "webhook"]},
        "url": {"type": "string", "format": "uri", "maxLength": 2048}
      }
    }
  }
}
