# DISPATCH — Worker 1 (Milestone M4: Scene Concat, Audio Mastering & Final Assembly)

## Mission
Implement Milestone M4 deliverables for the Ep01 Re-production Campaign (Scenes 01–10) following the architectural blueprints authored by Explorer 1 and Explorer 2:
1. **Audio-Preserving FFmpeg Concat (`AGENTS.md §4`)**:
   - In `05_Production_Pipeline/production_orchestrator.py`:
     * Upgrade `concat_scene_shots`: explicitly pass `mode="boundary_smoothing"` (Mode A: 30ms micro-fade with `curve=qsin`) as default to prevent timeline duration shrinkage in multi-shot scenes.
     * Add `--mode` CLI argument to `production_orchestrator.py`.
     * Add missing audio stream fallback handling to ensure clips without audio tracks receive silence rather than causing FFmpeg errors.
2. **EBU R128 Audio Mastering & Multi-Stem Mixing (`AGENTS.md §5`, `CINEMATIC_AUDIO_PIPELINE.md`)**:
   - In `05_Production_Pipeline/production_orchestrator.py`:
     * Add `resolve_audio_asset(asset_name_or_path: Optional[str]) -> Optional[Path]` to locate BGM, Ambience, and Foley across `04_Assets/audio/`, `04_Assets/audio_sfx/`, and repo paths.
     * Upgrade `master_scene_audio`: utilize `resolve_audio_asset` for both BGM and Ambience stems, support naming options (`_master_audio_v*` and `_cinematic_master_v*`), and execute two-pass linear EBU R128 loudness normalization (-14.0 LUFS ± 0.5, TP <= -1.0 dBTP).
3. **Multi-Scene Feature Master Assembly (`assemble_episode_master`)**:
   - In `05_Production_Pipeline/production_orchestrator.py`:
     * Add `resolve_scene_master(scene_id: str) -> Optional[Path]` prioritizing versioned cinematic/audio masters (`_master_audio_v*` > `_cinematic_master_v*` > `_master_v*`).
     * Implement `assemble_episode_master(episode_id="ep01", scene_ids=None, output_path=None, dry_run=False, check_only=False, normalize_final=True) -> Optional[Path]`.
     * Stitches all 10 canonical scenes of Ep01 (`ep01_scene01` to `ep01_scene10`, 140 shots = 23m20s) into `06_Exports/ep01_full_feature_master_v1.mp4` via FFmpeg `filter_complex concat` with two-pass linear EBU R128 normalization.
     * Add CLI arguments: `--assemble-episode`, `--scenes`, `--check`, `--dry-run`, `--mode`.
   - In `05_Production_Pipeline/assemble_ep01_feature.py`:
     * Upgrade `resolve_scene_part()` to scan `*_master_audio*` candidates.
     * Support `--scenes 10` so 10-scene campaign assembly succeeds into `06_Exports/ep01_full_feature_master_v1.mp4`.
4. **E2E Verification Test Suite**:
   - Author comprehensive test suite `tests/test_production_pipeline_m4.py` implementing the 5 test groups from Explorer 2's blueprint:
     * `TestAudioPreservingConcat` (FFmpeg filter_complex concat retains AAC 48k stereo, Mode A zero timeline drift).
     * `TestEBUR128AudioMastering` (Two-pass loudnorm achieves -14.0 LUFS ± 0.5, TP <= -1.0 dBTP, export hierarchy).
     * `TestSceneGatePreflightGating` (Scene Gate approval allows concat, rejection halts concat).
     * `TestMultiSceneFullEpisodeAssembly` (Stitches 10 synthetic scene masters into `ep01_full_feature_master_v1.mp4`).
     * `TestNegativeScenariosAndFaultTolerance` (Aborts on missing scene, silent video fallback without crash).
   - Fast dry-run execution: all tests must complete in < 20s using synthetic clips.

## Mandatory Reading
- `c:\Projects\KieuStory\.agents\teamwork\ORIGINAL_REQUEST.md` (read completely first)
- `c:\Projects\KieuStory\.agents\teamwork\orchestrator_1\PROJECT.md`
- `c:\Projects\KieuStory\.agents\teamwork\explorer_m4_1\m4_concat_audio_blueprint.md`
- `c:\Projects\KieuStory\.agents\teamwork\explorer_m4_2\m4_assembly_test_blueprint.md`
- `c:\Projects\KieuStory\AGENTS.md` (Sections 4, 5, and 6)
- `c:\Projects\KieuStory\00_Project_Bible/CINEMATIC_AUDIO_PIPELINE.md`

## Mandatory Integrity Warning
DO NOT CHEAT. All implementations must be genuine. DO NOT hardcode test results, create dummy/facade implementations, or circumvent the intended task. A teamwork_preview_auditor will independently verify your work. Integrity violations WILL be detected and your work WILL be rejected.

## Exclusive Write Ownership
- `05_Production_Pipeline/production_orchestrator.py`
- `05_Production_Pipeline/assemble_ep01_feature.py`
- `05_Production_Pipeline/audio_continuity_engine.py` (if minor helper needed)
- `tests/test_production_pipeline_m4.py`
- READ-ONLY: `04_Assets/characters/` (DO NOT MODIFY OR DELETE)
- PRESERVE: `04_Assets/archive/ep01_legacy_v1/` (DO NOT MODIFY OR DELETE)

## Output
Write your handoff report to:
`c:\Projects\KieuStory\.agents\teamwork\worker_m4_assembly_1\handoff.md`
Notify parent orchestrator when complete.
