# Implementation Plan: MMA Core Engine Implementation

## Phase 1: Track 1 - The Memory Foundations (AST Parser) [checkpoint: ac31e41]
- [x] Task: Dependency Setup (8fb75cc)
    - [x] Add `tree-sitter` and `tree-sitter-python` to `pyproject.toml` / `requirements.txt` (8fb75cc)
- [x] Task: Core Parser Class (7a609ca)
    - [x] Create `ASTParser` in `file_cache.py` (7a609ca)
- [x] Task: Skeleton View Extraction (7a609ca)
    - [x] Write query to extract `function_definition` and `class_definition` (7a609ca)
    - [x] Replace bodies with `pass`, keep type hints and signatures (7a609ca)
- [x] Task: Curated View Extraction (7a609ca)
    - [x] Keep class structures, module docstrings (7a609ca)
    - [x] Preserve `@core_logic` or `# [HOT]` function bodies, hide others (7a609ca)

## Phase 2: Track 2 - State Machine & Data Structures [checkpoint: a518a30]
- [x] Task: The Dataclasses (f9b5a50)
    - [x] Create `models.py` defining `Ticket` and `Track` (f9b5a50)
- [x] Task: Worker Context Definition (ee71929)
    - [x] Define `WorkerContext` holding `Ticket` ID, model config, and ephemeral messages (ee71929)
- [x] Task: State Mutator Methods (e925b21)
    - [x] Implement `ticket.mark_blocked()`, `ticket.mark_complete()`, `track.get_executable_tickets()` (e925b21)

## Phase 3: Track 3 - The Linear Orchestrator & Execution Clutch [checkpoint: e6c8d73]
- [x] Task: The Engine Core (7a30168)
    - [x] Create `multi_agent_conductor.py` containing `ConductorEngine` and `run_worker_lifecycle` (7a30168)
- [x] Task: Context Injection (9d6d174)
    - [x] Format context strings using `file_cache.py` target AST views (9d6d174)
- [x] Task: The HITL Execution Clutch (1afd9c8)
    - [x] Before executing `write_file`/`shell_runner.py` tools in step-mode, prompt user for confirmation (1afd9c8)
    - [x] Provide functionality to mutate the history JSON before resuming execution (1afd9c8)

## Phase 4: Track 4 - Tier 4 QA Interception [checkpoint: 61d17ad]
- [x] Task: The Interceptor Loop (bc654c2)
    - [x] Catch `subprocess.run()` execution errors inside `shell_runner.py` (bc654c2)
- [x] Task: Tier 4 Instantiation (8e4e326)
    - [x] Make a secondary API call to `default_cheap` model passing `stderr` and snippet (8e4e326)
- [x] Task: Payload Formatting (fb3da4d)
    - [x] Inject the 20-word fix summary into the Tier 3 worker history (fb3da4d)

## Phase 5: Track 5 - UI Decoupling & Tier 1/2 Routing (The Final Boss) [checkpoint: 3982fda]
- [x] Task: The Event Bus (695cb4a)
    - [x] Implement an `asyncio.Queue` linking GUI actions to the backend engine (695cb4a)
- [x] Task: Tier 1 & 2 System Prompts (a28d71b)
    - [x] Create structured system prompts for Epic routing and Ticket creation (a28d71b)
- [x] Task: The Dispatcher Loop (1dacd36)
    - [x] Read Tier 2 JSON flat-lists, construct Tickets, execute Stub resolution paths (1dacd36)
- [x] Task: UI Component Update (68861c0)
    - [x] Refactor `gui_2.py` to push `UserRequestEvent` instead of blocking on API generation (68861c0)

## Phase 6: Live & Headless Verification
- [x] Task: Headless Engine Verification
    - [x] Run a comprehensive headless test scenario (e.g., using a mock or dedicated test script).
    - [x] Verify Ticket execution, "Context Amnesia" (statelessness), and Tier 4 error interception.
- [x] Task: Live GUI Integration Verification
    - [x] Launch `gui_2.py` and verify Event Bus responsiveness.
    - [x] Confirm UI updates and async event handling during multi-model generation.
- [x] Task: Comprehensive Regression Suite
    - [x] Run all tests in `tests/` related to MMA, Conductor, and Async Events.
    - [x] Verify that no regressions were introduced in existing functionality.

## Phase 7: MMA Observability & UX
- [x] Task: MMA Dashboard Implementation
    - [x] Create a new dockable panel in `gui_2.py` for "MMA Dashboard".
    - [x] Display active `Track` and `Ticket` queue status.
- [x] Task: Execution Clutch UI
    - [x] Implement Step Mode toggle and Pause Points logic in the GUI.
    - [x] Add `[Approve]`, `[Edit Payload]`, and `[Abort]` buttons for tool execution.
- [x] Task: Memory Mutator Modal
    - [x] Create a modal for editing raw JSON conversation history of paused workers.
- [x] Task: Tiered Metrics & Log Links
    - [x] Add visual indicators for the active model Tier.
    - [x] Provide clickable links to sub-agent logs.

## Phase 8: Visual Verification & Interaction Tests
- [x] Task: Visual Verification Script
    - [x] Create `tests/visual_mma_verification.py` to drive the GUI into various MMA states.
    - [x] Verify MMA Dashboard visibility and progress bar.
    - [x] Verify Ticket Queue rendering with correct status colors.
- [x] Task: HITL Interaction Verification
    - [x] Drive a simulated HITL pause through the verification script.
    - [x] Manually verify the "MMA Step Approval" modal appearance.
    - [x] Manually verify "Edit Payload" (Memory Mutator) functionality.
- [~] Task: Final Polish & Fixes
    - [ ] Fix any visual glitches or layout issues discovered during manual testing.
    - [ ] Fix any visual glitches or layout issues discovered during manual testing.