{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://vclaw.dev/schemas/video/artifacts/ad-intel.schema.json",
  "title": "AdIntelArtifact",
  "description": "One competitor ad, torn down by skills/ad-intel/scripts/ad_intel.py: where it came from (the public Meta Ad Library card, a public video URL, or a local file), the media that was analysed, whisper's transcript, and the model's reading under references/teardown-framework.md. Written to artifacts/ad-intel/<id>.json. Observed fields (claims, offer, cta, proof) and readings (angles, objections, visual_pattern, ugc_script) are kept apart by name; angle categories are the ugc strategy vocabulary.",
  "type": "object",
  "required": ["schemaVersion", "id", "generatedAt", "model", "source", "media", "transcript", "analysis", "warnings"],
  "additionalProperties": false,
  "properties": {
    "schemaVersion": { "const": 1 },
    "id": { "type": "string", "minLength": 1, "description": "The Library ID for an Ad Library card; url-<hash> for a URL; the file stem for a local file." },
    "generatedAt": { "type": "string" },
    "model": { "type": "string", "description": "The Gemini model, or 'recorded' when written from --record." },
    "source": {
      "type": "object",
      "required": ["kind"],
      "additionalProperties": true,
      "properties": {
        "kind": { "enum": ["meta-ad-library", "url", "file"] },
        "url": { "type": ["string", "null"] },
        "libraryId": { "type": ["string", "null"] },
        "status": { "type": ["string", "null"] },
        "startedOn": { "type": ["string", "null"], "description": "ISO date parsed from 'Started running on …'; null when unparseable." },
        "startedOnText": { "type": ["string", "null"] },
        "versions": { "type": "integer", "minimum": 1, "description": "'N ads use this creative and text' on the card; 1 when the card shows no such line." },
        "pageName": { "type": ["string", "null"] },
        "pageUrl": { "type": ["string", "null"] },
        "primaryText": { "type": ["string", "null"] },
        "headline": { "type": ["string", "null"] },
        "description": { "type": ["string", "null"] },
        "cta": { "type": ["string", "null"] },
        "landingUrl": { "type": ["string", "null"] },
        "landingDomain": { "type": ["string", "null"] },
        "searchUrl": { "type": ["string", "null"] },
        "host": { "type": ["string", "null"] },
        "file": { "type": ["string", "null"] }
      }
    },
    "media": {
      "type": "object",
      "required": ["file", "sha256", "seconds"],
      "additionalProperties": false,
      "properties": {
        "file": { "type": ["string", "null"] },
        "sha256": { "type": ["string", "null"] },
        "seconds": { "type": ["number", "null"] }
      }
    },
    "transcript": {
      "type": "object",
      "required": ["text", "segments", "wordCount", "noSpeech", "language", "whisperModel"],
      "additionalProperties": false,
      "properties": {
        "text": { "type": "string" },
        "segments": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["start", "end", "text"],
            "additionalProperties": false,
            "properties": {
              "start": { "type": "number" },
              "end": { "type": "number" },
              "text": { "type": "string" }
            }
          }
        },
        "wordCount": { "type": "integer", "minimum": 0 },
        "noSpeech": { "type": "boolean" },
        "language": { "type": "string" },
        "whisperModel": { "type": "string" }
      }
    },
    "analysis": {
      "type": "object",
      "required": ["summary", "hook", "structure", "claims", "offer", "cta", "proof", "objections", "angles", "visual_pattern", "ugc_script"],
      "additionalProperties": false,
      "properties": {
        "summary": { "type": "string" },
        "hook": { "type": "string", "description": "Verbatim — the first spoken or shown words." },
        "structure": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["segment", "start", "end", "note"],
            "additionalProperties": false,
            "properties": {
              "segment": { "enum": ["hook", "setup", "claim", "evidence", "payoff", "cta", "other"] },
              "start": { "type": "number" },
              "end": { "type": "number" },
              "note": { "type": "string" }
            }
          }
        },
        "claims": { "type": "array", "items": { "type": "string" } },
        "offer": { "type": "string" },
        "cta": { "type": "string" },
        "proof": { "type": "array", "items": { "type": "string" } },
        "objections": { "type": "array", "items": { "type": "string" } },
        "angles": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["angle", "category"],
            "additionalProperties": false,
            "properties": {
              "angle": { "type": "string", "minLength": 1 },
              "category": { "enum": ["problem", "mechanism", "proof", "offer", "urgency", "trust"], "description": "skills/ugc/templates/strategy_schema.json beliefs[].category" }
            }
          }
        },
        "visual_pattern": { "type": "string" },
        "ugc_script": { "type": "string", "description": "A script for the OPERATOR'S brand in our voice — never the competitor's lines." }
      }
    },
    "warnings": { "type": "array", "items": { "type": "string" } },
    "_meta": { "type": "object", "additionalProperties": true, "description": "raplib.write_json_atomic provenance (generatedAt, input hashes)." }
  }
}
