# Implementation Plan: Data-Oriented Python Optimization Pass

## Phase 1: Guidelines and Instrumentation
- [x] Task: Update `conductor/product-guidelines.md` with Data-Oriented Python heuristics and the "less Python does the better" philosophy. (fbaef6c)
- [x] Task: Review existing profiling instrumentation in `src/performance_monitor.py` or diagnostic hooks. (ae2b79a)
- [x] Task: Expand profiling instrumentation to capture more detailed execution times for non-GUI data structures/processes if necessary. (23c1e21)
- [x] Task: Conductor - User Manual Verification 'Phase 1: Guidelines and Instrumentation' (Protocol in workflow.md) (56e9627)

## Phase 2: Audit and Profiling (`src/` and `simulation/`)
- [x] Task: Run profiling scenarios (especially utilizing simulations) to generate baseline metrics. (83afc90)
- [x] Task: Audit `src/` (e.g., `dag_engine.py`, `multi_agent_conductor.py`, `aggregate.py`) against the new guidelines, cross-referencing with profiling data to identify bottlenecks. (7dc91dd)
- [x] Task: Audit `simulation/` files against the new guidelines to ensure the test harness is performant and non-blocking. (05db5bd)
- [x] Task: Compile a list of identified bottleneck targets to refactor. (1294619)
- [x] Task: Conductor - User Manual Verification 'Phase 2: Audit and Profiling (`src/` and `simulation/`)' (Protocol in workflow.md) (7a72987)

## Phase 3: Targeted Optimization and Refactoring
- [x] Task: Write/update tests for the first identified bottleneck to establish a performance or structural baseline (Red Phase). (2e68f1e)
- [x] Task: Refactor the first identified bottleneck to align with data-oriented guidelines (Green Phase). (2e68f1e)
- [x] Task: Write/update tests for remaining identified bottlenecks. (56e9627)
- [x] Task: Refactor remaining identified bottlenecks. (d0aff71)
- [x] Task: Conductor - User Manual Verification 'Phase 3: Targeted Optimization and Refactoring' (Protocol in workflow.md) (f628e0b)

## Phase 4: Final Evaluation and Documentation
- [x] Task: Re-run all profiling scenarios to compare against the baseline metrics. (90807d3)
- [x] Task: Analyze remaining bottlenecks that did not reach performance thresholds and document them as candidates for C/C++ bindings (Last Resort). (7a72987)
- [x] Task: Generate a final summary report of the optimizations applied and the C extension evaluation. (7a72987)
- [x] Task: Conductor - User Manual Verification 'Phase 4: Final Evaluation and Documentation' (Protocol in workflow.md) (299d9e5)

## Phase 5: Entropy Audit & Reduction
Goal: Identify and consolidate duplicate functionality, redundant code paths, and inconsistencies from multi-agent development.

- [x] ~~Task: Identify duplicate getter/setter patterns~~ - FALSE POSITIVE, these are proper Python @property patterns.
- [x] Task: Fix duplicate line bug in `app_controller.py` `rag_emb_provider.setter` - two identical lines. (f6feab9)
- [x] Task: Audit `src/` for duplicate functionality - find code that does the same thing in multiple places. (No significant duplicates found - proper @property patterns and intentional layering) (7a72987)
- [x] Task: Audit ticket/event handling patterns - ensure consistent state transitions across the codebase. (Found: direct status assignments instead of method calls in abort paths, mark_manual_block is dead code) (7a72987)
- [x] Task: Audit UI rendering patterns - find duplicate or overlapping rendering logic. (No significant duplication found - _gui_func is single sequential dispatch) (7a72987)
- [x] Task: Document findings and create refactoring plan for any identified issues.
  - **Duplicate code audit**: No significant duplication found. Proper @property patterns and intentional layering confirmed across aggregate.py, summarize.py, summary_cache.py.
  - **Ticket/event handling issues**:
    1. Direct `ticket.status = "killed"` assignments in abort paths (lines 445, 575 in multi_agent_conductor.py) instead of using a proper method
    2. `mark_manual_block()` is dead code - defined in models.py but never called anywhere in src/
  - **UI rendering**: No duplication found. _gui_func is single sequential dispatch to distinct panel methods.
  - **Refactoring plan**: Consider adding a `mark_killed()` method to Ticket class for consistency, and add a deprecation note for `mark_manual_block()`. (7a72987)
- [x] Task: Conductor - User Manual Verification 'Phase 5: Entropy Audit & Reduction' (Protocol in workflow.md) (923ffe8)