# Implementation Plan: AI Interaction Call Graph (ai_interaction_call_graph_20260507)

## Phase 1: Trace Mapping
- [x] Task: Use `py_find_usages` to trace `ai_client.send` callers and callees.
- [x] Task: Map the asynchronous hand-off from `AppController` to the AI worker threads.
- [x] Task: Trace the recursion depth of the tool-call loop (`MAX_TOOL_ROUNDS`).

## Phase 2: Documentation & Synthesis
- [x] Task: Create a high-fidelity Mermaid sequence diagram of the entire loop.
- [x] Task: Identify specific areas for logic consolidation or performance optimization.

## Phase 3: Automated Path Derivation Tooling
- [x] Task: Develop `derive_code_path` MCP tool using tree-sitter.
- [~] Task: Implement cross-file call-chain tracing and data hand-off detection.
- [ ] Task: Verify tool output against the manual AI Loop trace.

## Phase 4: Comprehensive Pipeline Mapping
- [x] Task: Map the **Context Aggregation Pipeline** using the new tool.
- [x] Task: Map the **GUI Event & State Synchronization** pipeline.
- [x] Task: Map the **Simulation Lifecycle** and turn-loop.
- [x] Task: Consolidate all intensive traces into a final Phase 5 Architectural Audit.
- [x] Task: Conductor - User Manual Verification 'Final Audit' (Protocol in workflow.md)
