Files
manual_slop/conductor/tracks/mma_pipeline_fix_20260301/spec.md
Ed_ 0d2b6049d1 conductor: Create 3 MVP tracks with surgical specs from full codebase analysis
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>
2026-03-01 09:58:34 -05:00

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)

  1. run_in_executor positional arg ordering: run_worker_lifecycle has 7 parameters. The call at multi_agent_conductor.py:118-127 passes them positionally. If the order is wrong, loop could be None and _queue_put would silently fail (the if loop: branch is skipped, falling to event_queue._queue.put_nowait() which may not work from a thread-pool thread because asyncio.Queue.put_nowait is not thread-safe when called from outside the event loop).

  2. asyncio.Queue thread safety: _queue_put uses asyncio.run_coroutine_threadsafe() which IS thread-safe. But the else branch (event_queue._queue.put_nowait(...)) is NOT — asyncio.Queue is NOT thread-safe for cross-thread access. If loop is None, this branch silently corrupts or drops the event.

  3. ai_client.reset_session() side effects: Called at the start of run_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.

  4. Token stats stub: engine.tier_usage update uses stats = {} (empty dict, commented "ai_client.get_token_stats() is not available"), so prompt_tokens and candidates_tokens are always 0. Not a stream bug but a data bug.

Goals

  1. Fix Tier 3 worker responses reaching mma_streams in the GUI.
  2. Fix token usage tracking for Tier 3 workers.
  3. Verify via ApiHookClient.get_mma_status() that mma_streams contains Tier 3 output after a mock MMA run.

Architecture Reference