# Implementation Plan: Simulation Hardening

Depends on: `mma_pipeline_fix_20260301`
Architecture reference: [docs/guide_simulations.md](../../docs/guide_simulations.md)

## Phase 1: Mock Provider Cleanup

- [x] Task 1.1: PRE-RESOLVED — mock_gemini_cli.py default path already returns plain text JSON (not function_call). Routing verified by code inspection: Epic/Sprint/Worker/tool-result all return plain text. Covered by Task 1.3 test.
- [x] Task 1.2: Fix mock sprint planning ticket format. Current mock returns `goal`/`target_file` fields; ConductorEngine.parse_json_tickets expects `description`/`status`/`assigned_to`. Also add `'generate the implementation tickets'` keyword detection alongside `'PATH: Sprint Planning'`. 0593b28
- [x] Task 1.3: Write a standalone test (`tests/test_mock_gemini_cli.py`) that invokes the mock script via `subprocess.run()` with various stdin prompts and verifies: (a) epic prompt → Track JSON, no tool calls; (b) sprint prompt → Ticket JSON, no tool calls; (c) worker prompt → plain text, no tool calls; (d) tool-result prompt → plain text response. 0873453

## Phase 2: Simulation Stability

- [x] Task 2.1: PRE-RESOLVED — visual_sim_mma_v2.py already has 0.3–1.5s frame-sync sleeps after every state-changing click, implemented in mma_pipeline_fix track (89a8d9b).
- [x] Task 2.2: PRE-RESOLVED — _poll() with condition lambdas already covers all state-transition waits cleanly. wait_for_value exists in ApiHookClient but _poll() is more flexible and already in use.
- [x] Task 2.3: Add `@pytest.mark.timeout(300)` to test_mma_complete_lifecycle to prevent infinite CI hangs. 63fa181

## Phase 3: End-to-End Verification

- [x] Task 3.1: PRE-RESOLVED — visual_sim_mma_v2.py passes in 11s against live GUI with real Gemini API (gemini-2.5-flash-lite). Verified in mma_pipeline_fix track. All 8 stages pass. ce5b6d2
- [x] Task 3.2: Added Stage 9 to sim test: non-blocking poll for mma_tier_usage Tier 3 non-zero (30s, warns if not wired). Tier 3 stream and mma_status checks already covered by Stages 7-8. 63fa181
- [x] Task 3.3: Fixed pending_script_approval gap (btn_approve_script unwired, _pending_dialog not in hook API). Sim test PASSED in 19.73s. Tier 3 token usage confirmed: input=34839, output=514. 90fc38f
