## 2026-10-09T04:31:54Z
You are Worker 2 for Milestone M1 Iteration 2 (Critic Gate & Character Safeguards Remediation).

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

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 EXPLORER REMEDIATION BLUEPRINTS:
You must read and strictly follow the drop-in specifications authored by the Explorers:
1. Explorer 1 Specification: c:\Projects\KieuStory\.agents\teamwork\explorer_m1_remediation_1\remediation_critic_gate.md
2. Explorer 2 Specification: c:\Projects\KieuStory\.agents\teamwork\explorer_m1_remediation_2\remediation_prompts_safeguards.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:
- c:\Projects\KieuStory\05_Production_Pipeline\antigravity_critic_gate.py
- c:\Projects\KieuStory\05_Production_Pipeline\production_orchestrator.py
- c:\Projects\KieuStory\episodes\ep01\prompts\muse_prompts.json
- c:\Projects\KieuStory\02_AI_Prompts\gemini_banana_prompts.json
- c:\Projects\KieuStory\02_AI_Prompts\muse_ai_video_prompts.json (via sync command)
- c:\Projects\KieuStory\tests\test_critic_gate.py
- c:\Projects\KieuStory\tests\test_m1_challenger2_probe.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. Patch 05_Production_Pipeline/antigravity_critic_gate.py per Explorer 1's exact code blocks in Section 3:
   - Patch Block 1: Helper functions (_extract_keyframe_bytes, _extract_junction_frame_bytes, _check_audio_stream parsing JSON).
   - Patch Block 2: OfflineHeuristicEngine.evaluate_shot (severe defect penalty docking >= 0.35, capping score <= 0.65 for frozen/corrupt/short videos; universal wiring of _find_character_portrait and Thúy Kiều cross-correlation check).
   - Patch Block 3: OfflineHeuristicEngine.evaluate_scene (upfront validation loop rejecting missing, empty, or unopenable video files with score 0.0, approved=False, suggested_action='RETAKE_SHOT').
   - Patch Block 4: AntigravitySDKEngine and GoogleGenAIEngine (binding genuine JPEG byte Parts to MLLM contents, with clean None fallback if offline or API key missing).

2. Patch 05_Production_Pipeline/production_orchestrator.py per Explorer 2's Section II §3.1:
   - Update get_character_anchor() with heuristic title-based fallback.
   - Update resolve_start_frame() with complete Bilateral & Multi-character Safeguards (is_kim_trong, is_thuy_kieu, is_vuong_quan, is_vuong_ong, is_thuy_van) across Step A, Step C, and Step D.

3. Update Prompt Registries per Explorer 2's Section III:
   - In episodes/ep01/prompts/muse_prompts.json:
     * Scene 10: restore Thúy Kiều portrait for shots 03, 06, 09, 11, 12; Kim Trọng portrait for shots 04, 05, 07, 08, 10, 13; null for shots 01, 02, 14.
     * Scene 06: assign exact character_asset_ref for all 14 shots per Section II §2.2 (Kim Trọng shots 03, 04, 06, 10, 12, 14; Vương Quan shot 07; Kiều shots 08, 09, 11, 13; Tiểu Đồng shot 05; null for 01, 02).
     * Scene 05: assign Vương Quan portrait for shots 13, 16, 24.
   - In 02_AI_Prompts/gemini_banana_prompts.json:
     * Update character_anchor for Scene 10, Scene 06, and Scene 05 per Explorer 2's Section II tables.
   - Run python 05_Production_Pipeline/episode_manager.py --sync-to-master to synchronize master prompt registry.

4. Harden Test Suites:
   - In tests/test_critic_gate.py: replace TestKimTrongSafeguard with TestBilateralAndCharacterSafeguards from Explorer 2's Section II §4.2, testing live shot_data via po.get_all_shots(). Also ensure tests verify evaluate_shot_gate frozen video rejection, black frame rejection, and evaluate_scene_gate missing file rejection.
   - In tests/test_m1_challenger2_probe.py: update assertions in test_scene06_kim_trong_anomaly_audit, test_vuong_quan_scene05_uncovered_defects, and test_kim_trong_11_fixes_present_in_master so they assert 0 anomalies and 0 defects (as instructed in Explorer 2 §4.3).

5. Run Full Verification Suite:
   - python -m pytest tests/test_critic_gate.py -v
   - python -m pytest tests/test_m2_hygiene.py -v
   - pytest tests/test_tier1_features.py -k "not test_render" -v
   - python -m pytest tests/test_m1_challenger2_probe.py -v
   Capture verbatim outputs demonstrating 100% tests PASS across all suites.
