## 2026-10-09T05:53:41Z
You are Worker 1 for Milestone M3: Ep01 10-Scene Production Pipeline Implementation.

Your working directory is: c:\Projects\KieuStory\.agents\teamwork\worker_m3_pipeline_1

MANDATORY FIRST STEP:
Read c:\Projects\KieuStory\.agents\teamwork\ORIGINAL_REQUEST.md completely. Do not skip this.
Read c:\Projects\KieuStory\.agents\teamwork\orchestrator_1\PROJECT.md.

MANDATORY SPECIFICATION BLUEPRINT:
Read c:\Projects\KieuStory\.agents\teamwork\explorer_m3_1\production_pipeline_readiness.md.
Follow the exact implementation recipes and architecture in Section 6.

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:
- c:\Projects\KieuStory\05_Production_Pipeline\production_orchestrator.py
- c:\Projects\KieuStory\05_Production_Pipeline\run_shot.py
- c:\Projects\KieuStory\episodes\ep01\prompts\muse_prompts.json
- c:\Projects\KieuStory\02_AI_Prompts\gemini_banana_prompts.json
- c:\Projects\KieuStory\04_Assets\keyframes\ (prologue_shot{N}/ keyframes)
- c:\Projects\KieuStory\tests\test_production_pipeline_m3.py
- READ-ONLY: 04_Assets/characters/ (DO NOT MODIFY OR DELETE)
- PRESERVE: 04_Assets/archive/ep01_legacy_v1/ (DO NOT MODIFY OR DELETE)

TASKS TO EXECUTE IN EXACT ORDER:
1. Start Frame 100% Coverage across 140 Shots (Ep01 Scenes 01 to 10):
   - In episodes/ep01/prompts/muse_prompts.json and production_orchestrator.py:
     * Map ep01_scene04_shot01 to 04_Assets/keyframes/crowd_qingming_festival_720p.png.
     * In 04_Assets/keyframes/: organize clean 720p prologue keyframes prologue_shot1 through prologue_shot21 (extract frame 0 from clean archived videos or keyframe templates if needed).
     * Update resolve_start_frame() in production_orchestrator.py so that every single Cinematic Cut across Scenes 01 to 10 resolves to an existing file on disk (100% resolution rate!).
   - Sync prompt master using python 05_Production_Pipeline/episode_manager.py --sync-to-master.

2. Integrate Shot Gate & Automated Retake Loop into production_orchestrator.py:
   - In render_single_shot(): after successful video generation, call evaluate_shot_gate(shot_id, str(video_path), expected_char, prompt).
   - If verdict.overall_score < 0.8 or verdict.suggested_action == "RETAKE_SHOT":
     trigger an automated retake loop (up to max_retakes=2), incrementing version string (_v2, _v3) and appending critique notes to guide the retake.
   - If score >= 0.8: accept video, extract clean_frame_239.jpg tail frame, and return success.

3. Integrate Scene Gate into batch_render_scene() and concat_scene_shots():
   - In batch_render_scene() / concat_scene_shots(): call evaluate_scene_gate(scene_id, shot_video_paths).
   - Verify junction smoothness, 180-degree rule, and color continuity before proceeding with FFmpeg concat.

4. Synchronize Audio Guard Formatting in run_shot.py:
   - Update lines 136-140 to use the exact AGENTS.md §3 prefix:
     " Quy tắc âm thanh: Tuyệt đối KHÔNG sinh nhạc nền (no music/BGM), không âm thanh điện tử, không tạp âm rè nhiễu. Chỉ sinh âm thanh môi trường tự nhiên (foley, ambience) và thoại nhân vật chân thực."
   - Add pre-flight validation in production_orchestrator.py ensuring all prompts dispatched to workers carry the Audio Guard.

5. Implement MUSE_DRY_RUN Mock Engine:
   - Support environment variable MUSE_DRY_RUN=1 (or parameter in run_shot_pipeline): when active, generate a synthetic 1280x720 video with FFmpeg lavfi color + AAC 48kHz sine tone and extract clean_frame_239.jpg, allowing automated test suites to run end-to-end in < 15 seconds without hanging on external browser sessions.

6. Author Comprehensive Test Suite tests/test_production_pipeline_m3.py:
   - Test 1: Verify 100% of the 140 shots across Scenes 01 to 10 resolve to physically existing image files on disk.
   - Test 2: Character invariant check: verify 0 character misidentifications (no Thúy Kiều portrait returned for Kim Trọng, Thúy Vân, Vương Quan, Vương Ông, or attendant).
   - Test 3: Shot Gate integration: verify retake loop triggers on mock score < 0.8 and accepts on score >= 0.8.
   - Test 4: Scene Gate integration: verify evaluate_scene_gate is invoked and validates scene junctions.
   - Test 5: Audio Guard verification: verify 100% of Ep01 prompts strictly enforce the No-BGM directive.
   - Test 6: Dry-run pipeline execution: test a multi-shot sequence with Head-Tail chaining and critic validation.

7. Execute Full Verification Suites:
   - python -m pytest tests/test_production_pipeline_m3.py -v
   - python -m pytest tests/test_critic_gate.py -v
   - python -m pytest tests/test_m1_challenger2_probe.py -v
   - pytest tests/test_tier1_features.py -k "not test_render" -v
   - python -m pytest tests/test_m2_hygiene.py -v
   Confirm 100% test pass rate with zero regressions.

8. Output your detailed handoff report to c:\Projects\KieuStory\.agents\teamwork\worker_m3_pipeline_1\handoff.md and send a message to parent orchestrator.
