Three new tracks identified by analyzing product.md requirements against
actual codebase state using 1M-context Opus with all architecture docs loaded:
1. mma_pipeline_fix_20260301 (P0, blocker):
- Diagnoses why Tier 3 worker output never reaches mma_streams in GUI
- Identifies 4 root cause candidates: positional arg ordering, asyncio.Queue
thread-safety violation, ai_client.reset_session() side effects, token
stats stub returning empty dict
- 2 phases, 6 tasks with exact line references
2. simulation_hardening_20260301 (P1, depends on pipeline fix):
- Addresses 3 documented issues from robust_live_simulation session compression
- Mock triggers wrong approval popup, popup state desync, approval ambiguity
- 3 phases, 9 tasks including standalone mock test suite
3. context_token_viz_20260301 (P2):
- Builds UI for product.md primary use case #2 'Context & Memory Management'
- Backend already complete (get_history_bleed_stats, 140 lines)
- Token budget bar, proportion breakdown, trimming preview, cache status
- 3 phases, 10 tasks
Execution order: pipeline_fix -> simulation_hardening -> gui_ux (parallel w/ token_viz)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2.7 KiB
Track Specification: MMA Pipeline Fix & Worker Stream Verification
Overview
The MMA pipeline has a verified code path from run_worker_lifecycle → _queue_put("response", ...) → _process_event_queue → _pending_gui_tasks("handle_ai_response") → mma_streams[stream_id] = text. However, the robust_live_simulation track's session compression (2026-02-28) documented that Tier 3 worker output never appears in mma_streams during actual GUI operation. The simulation only ever sees 'Tier 1' in mma_streams keys.
This track diagnoses and fixes the pipeline break, then verifies end-to-end that worker output flows from ai_client.send() through to the GUI's mma_streams dict.
Root Cause Candidates (from code analysis)
-
run_in_executorpositional arg ordering:run_worker_lifecyclehas 7 parameters. The call atmulti_agent_conductor.py:118-127passes them positionally. If the order is wrong,loopcould beNoneand_queue_putwould silently fail (theif loop:branch is skipped, falling toevent_queue._queue.put_nowait()which may not work from a thread-pool thread becauseasyncio.Queue.put_nowaitis not thread-safe when called from outside the event loop). -
asyncio.Queuethread safety:_queue_putusesasyncio.run_coroutine_threadsafe()which IS thread-safe. But theelsebranch (event_queue._queue.put_nowait(...)) is NOT —asyncio.Queueis NOT thread-safe for cross-thread access. IfloopisNone, this branch silently corrupts or drops the event. -
ai_client.reset_session()side effects: Called at the start ofrun_worker_lifecycle, this resets the global_gemini_cli_adapter.session_id = None. If the adapter is shared state and the GUI's Tier 2 call is still in-flight, this could corrupt the provider state. -
Token stats stub:
engine.tier_usageupdate usesstats = {}(empty dict, commented "ai_client.get_token_stats() is not available"), soprompt_tokensandcandidates_tokensare always 0. Not a stream bug but a data bug.
Goals
- Fix Tier 3 worker responses reaching
mma_streamsin the GUI. - Fix token usage tracking for Tier 3 workers.
- Verify via
ApiHookClient.get_mma_status()thatmma_streamscontains Tier 3 output after a mock MMA run.
Architecture Reference
- Threading model: docs/guide_architecture.md — see "Cross-Thread Data Structures" and "Pattern A: AsyncEventQueue"
- Worker lifecycle: docs/guide_mma.md — see "Tier 3: Worker Lifecycle"
- Frame-sync: docs/guide_architecture.md — see "Frame-Sync Mechanism" action catalog (
handle_ai_responsewithstream_id)