feat(style): Add anti-OOP conventions and OOP refactoring tracker

- Add section 10 (Anti-OOP Conventions) to python.md with hard rules,
  class justification requirements, and Strangler Fig refactoring pattern
- Create conductor/refactor_oop.md tracker with 4 phases for class elimination
- Add ruff PLR rules (PLR0912, PLR6301, PLR0206) to pyproject.toml for
  OOP anti-patterns

Addresses AI agent scope misinterpretation issues by enforcing flat
function-call graphs over deep class hierarchies.
This commit is contained in:
2026-05-11 23:41:41 -04:00
parent 4ef18ab5d2
commit b9c1b63f8d
3 changed files with 121 additions and 5 deletions
+55
View File
@@ -0,0 +1,55 @@
# OOP Refactoring Tracker
Tracks elimination of class-based OOP from the codebase to reduce AI agent scope misinterpretation.
## Status: IN PROGRESS
## Phase 1: Leaf Classes (No internal dependents)
These classes have no dependencies on other classes being refactored. Start here.
- [ ] `src/tool_bias.py` - ToolBiasEngine → module functions + dict
- [ ] `src/session_logger.py` - SessionLogger → module-level functions
- [ ] `src/summarize.py` - SummaryCache class → plain dict + functions
## Phase 2: Internal Classes (Depend on Phase 1)
These classes use Phase 1 classes. Refactor Phase 1 first.
- [ ] `src/project_manager.py` - ProjectManager class
- [ ] `src/aggregate.py` - Aggregator class
## Phase 3: Core Classes (High risk - many callers)
These have many dependents. Handle last with extra testing.
- [ ] `src/ai_client.py` - AI client classes (AIProvider, etc.)
- [ ] `src/mcp_client.py` - MCPClient, ToolRegistry
- [ ] `src/models.py` - Data classes → dataclass/NamedTuple
## Phase 4: GUI Classes (Highest risk)
Classes used in GUI callbacks. Require live testing.
- [ ] `src/gui_2.py` - Main GUI class, panel classes
## Anti-Regression Protocol
Before refactoring ANY class:
1. **Write test** that validates current behavior
2. **Commit baseline** with `test(baseline): add baseline for <class>`
3. **Extract method** into module-level function
4. **Update all callers** to use function directly
5. **Run test** - must pass identically
6. **Commit extraction** with `refactor(oop): extract <method> from <Class>`
7. **Delete class** only when ALL methods extracted
## Progress Log
### 2026-05-11
- Initial tracker created
- Anti-OOP conventions added to `conductor/code_styleguides/python.md`
- Ruff PLR rules added to `pyproject.toml`
## Notes
- Use Strangler Fig pattern: keep class working until last caller migrated
- Prefer `dict`/`NamedTuple` over classes for data containers
- Classes with only data: convert to `dataclass(frozen=True)` or `NamedTuple`