{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Batch Summary",
  "description": "Output of generate_batch_summary.py. Captures thread, beat, and pattern metadata for a completed batch of 5 episodes. Consumed by orchestrator for cross-series verification.",
  "type": "object",
  "required": ["batch", "timestamp", "episodes", "batch_summary", "continuity_notes"],
  "properties": {
    "batch": {
      "type": "integer",
      "minimum": 1,
      "maximum": 12,
      "description": "Batch number (1-12 for 60 episodes at 5 per batch)."
    },
    "timestamp": {
      "type": "string",
      "description": "ISO 8601 timestamp of summary generation."
    },
    "episodes": {
      "type": "array",
      "description": "Per-episode analysis data for each episode in the batch.",
      "items": {
        "type": "object",
        "required": ["episode", "word_count", "dialogue_percent", "exchanges", "hook_type", "cliffhanger_type", "threads"],
        "properties": {
          "episode": { "type": "integer", "minimum": 1, "maximum": 60 },
          "word_count": { "type": "integer" },
          "dialogue_percent": { "type": "number" },
          "exchanges": { "type": "integer" },
          "hook_type": { "type": "string", "enum": ["silent", "dialogue"] },
          "hook_subtype": { "type": "string" },
          "cliffhanger_type": { "type": "string", "enum": ["mid-action", "aftermath"] },
          "cliffhanger_subtype": { "type": "string" },
          "cliffhanger_image": { "type": "string" },
          "emotional_beat": { "type": ["string", "null"] },
          "threads": {
            "type": "object",
            "properties": {
              "planted": { "type": "array", "items": { "type": "string" } },
              "advanced": { "type": "array", "items": { "type": "string" } },
              "paid_off": { "type": "array", "items": { "type": "string" } }
            }
          }
        }
      }
    },
    "batch_summary": {
      "type": "object",
      "required": ["threads_planted_this_batch", "threads_advanced_this_batch", "threads_paid_off_this_batch", "emotional_beats_hit_this_batch", "pattern_distribution", "validation_passed", "issues_flagged"],
      "properties": {
        "threads_planted_this_batch": { "type": "array", "items": { "type": "string" } },
        "threads_advanced_this_batch": { "type": "array", "items": { "type": "string" } },
        "threads_paid_off_this_batch": { "type": "array", "items": { "type": "string" } },
        "emotional_beats_hit_this_batch": { "type": "array", "items": { "type": "string" } },
        "pattern_distribution": {
          "type": "object",
          "properties": {
            "hooks": {
              "type": "object",
              "properties": {
                "silent": { "type": "integer" },
                "dialogue": { "type": "integer" }
              }
            },
            "cliffhangers": {
              "type": "object",
              "properties": {
                "mid_action": { "type": "integer" },
                "aftermath": { "type": "integer" }
              }
            }
          }
        },
        "validation_passed": { "type": "boolean" },
        "issues_flagged": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "episode": { "type": "integer" },
              "issue_type": { "type": "string" },
              "description": { "type": "string" },
              "severity": { "type": "string", "enum": ["error", "warning", "info"] }
            }
          }
        }
      }
    },
    "continuity_notes": {
      "type": "object",
      "properties": {
        "last_location": { "type": "string" },
        "open_tension": { "type": "string" },
        "next_batch_setup": { "type": "string" }
      }
    }
  }
}
