subsystem: phases
# The pipeline spine — the stages a generation flows through, end to end. Each phase FKs its real
# entrypoint + artifact nodes; next[] forms the spine. Investor view + reduced "Phases (spine)" render from these.
# Phase ids are globally unique (the checker enforces one id namespace across all node types).

phases:
  - id: script_breakdown
    summary: >
      Episode script (ep_NNN.md) is broken down into the per-episode mention ledger — the scene→
      location/sublocation/prop/wardrobe/character mentions that downstream ref resolution reads.
    entrypoints: [breakdown_extract_cli, breakdown_gate_cli]
    produces: [mention_ledger]
    next: [scene_assembly]

  - id: asset_prep
    summary: >
      Reference assets are produced + promoted: character angle sheets, composite ref SHEETS, and the
      sublocation/location registry. Feeds both board and video ref resolution. (Currently fragmented across
      three promotion writers — see ref_promotion_three_writers divergence.)
    entrypoints: [prep_character_angles_cli, generate_composite_sheet_cli, gen_sublocations_cli]
    produces: [composite_sheets, location_registry, promoted_hero_top_level, asset_pool_refs]
    next: [storyboard, payload_dispatch]

  - id: scene_assembly
    summary: >
      Shots are clustered into scenes/beats/takes by the grouping strategy and persisted as the scene SSOT
      (BATCH/ONER ids). Board + video both re-read these persisted scenes.
    entrypoints: [episode_runner_module, run_overnight_cli, generate_cli]
    produces: [persisted_scene]
    next: [storyboard, payload_dispatch]

  - id: storyboard
    summary: >
      Storyboard generation: a pencil-tier strip is proposed + story-gated, then (on approval) a full-size
      photoreal finish. Board CHAR/prop refs are per-kind individual; the LOCATION ref is the composite SHEET when
      locked + use_composite_sheets on (REC-213 C3, same resolve_sheet_asset route as video — ref_system_split).
    entrypoints: [board_cli, build_and_dispatch_board, render_board_finish]
    produces: [pencil_strip, photoreal_finish, story_gate_verdict, board_record]
    next: [payload_dispatch]

  - id: payload_dispatch
    summary: >
      Typed payload assembly + the single dispatch entry point: refs collected (composite sheets for video),
      prompt authored, payload validated, modality runner resolved. Emits the receipt log.
    entrypoints: [dispatch, audit_dispatch_cli, dispatch_cli]
    produces: [receipts_jsonl, video_ref_manifest]
    next: [generation]

  - id: generation
    summary: >
      Generation execution: StepRunner drives the provider adapters (Flora primary / fal / atlas) to render
      video takes + keyframes; polls to terminal; writes takes + sidecars.
    entrypoints: [step_runner, video_model_client, generate_cli]
    produces: [video_take_mp4, video_sidecar_json, keyframe_png, observability_log]
    next: [review_reroll]

  - id: review_reroll
    summary: >
      Takes are story-gated / human-reviewed; failures re-enter via the reroll surface + the strategy engine
      (structured retry under the budget guard) until approved or exhausted.
    entrypoints: [reroll_route, generate_cli_new_take]
    produces: [board_review_comments_json]
    next: []
