# Implementation Plan: Fix Concurrent MMA Live GUI Tests

## Phase 1: Investigate Test Infrastructure
- [x] Task: Compare test_mma_concurrent_tracks_sim.py with working tests - Same fixture, same pattern
- [x] Task: Check subprocess/port cleanup between live_gui fixture tests - Not cleanup issue, single test also times out
- [x] Task: Verify get_mma_workers() API returns expected format - Returns {"workers": Dict[str, str]}
- [x] Task: Run isolated concurrent test with verbose debugging - Confirmed: only ONE worker appears when starting two tracks

## Phase 2: Identify Root Cause - MULTIPLE BUGS FOUND
- [x] Bug 1: `self.engine` single reference overwritten (FIXED in ac0b564)
- [x] Bug 2: `active_tickets` not initialized (FIXED in 6f2a2c2)
- [x] Bug 3: `_start_track_logic` uses `self.active_track.id` when None (FIXED in f3585cb)
- [x] Bug 4: `_cb_start_track` overwrites `active_track` (PARTIALLY FIXED in b0a837d)

## Phase 3: Implement Fix
- [x] Task 3.1: Change `self.engine: Optional[ConductorEngine]` to `self.engines: Dict[str, ConductorEngine]`
- [x] Task 3.2: Update all `self.engine` references to track-specific lookup
- [x] Task 3.3: Fix `_start_track_logic` to use `track.id` instead of `self.active_track.id`
- [x] Task 3.4: Add `self.active_tickets = []` in `init_state()`
- [x] Task 3.5: Add explicit reload path in `_cb_start_track` when load fails
- [ ] Task 3.6: Verify `_cb_load_track` properly loads tracks created by `_cb_accept_tracks`

## Phase 4: Debug Remaining Issue
- [ ] Task 4.1: Investigate why reload path in `_cb_start_track` doesn't bring back Track A worker
- [ ] Task 4.2: Add debug logging to `_cb_load_track` to trace failure
- [ ] Task 4.3: Verify track state is saved with correct ID when created by `_cb_accept_tracks`
- [ ] Task 4.4: Run test and verify both workers appear

## Phase 5: Final Verification
- [ ] Task 5.1: Run all concurrent MMA tests
- [ ] Task 5.2: Run full test suite to check for regressions
- [ ] Task 5.3: Remove debug logging and commit final fixes

## Commits So Far
- `ac0b564` - fix(mma): Change self.engine to self.engines dict for concurrent track support
- `6f2a2c2` - fix(gui): Initialize active_tickets in AppController.init_state
- `f3585cb` - fix(mma): Use track.id instead of self.active_track.id in _start_track_logic
- `b0a837d` - fix(mma): Add explicit reload logic when _cb_load_track fails in _cb_start_track
- `cab733a` - debug: Add logging to _cb_start_track

## Current Blocker
After commits 1-4, Track B's worker appears but Track A's never does. The reload path (b0a837d) is triggered for Track A but the worker doesn't become visible. Need to trace why `_cb_load_track` succeeds for Track B but fails for Track A, or why the engine thread doesn't produce visible output.