-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
P3-post-betaLow priority - can wait until after beta (v2.0)Low priority - can wait until after beta (v2.0)architectureSystem architecture and design patternsSystem architecture and design patternsenhancementNew feature or requestNew feature or request
Description
Problem
lead_agent.py at 110KB is a monolith that violates Single Responsibility Principle. It handles orchestration, discovery, planning, and conversation management all in one file.
Current State
- File:
codeframe/agents/lead_agent.py(~110KB, ~3000+ lines) - Combines: Agent orchestration, Discovery workflow, Planning pipeline, Conversation/chat, PRD generation
Impact
- Hard to maintain and debug
- Changes to discovery can break planning
- Testing is complex due to tight coupling
- New developers struggle to understand flow
Required Decomposition
New Module Structure
codeframe/agents/
├── lead_agent.py # Thin orchestrator (reduced to ~500 lines)
├── coordinators/
│ ├── __init__.py
│ ├── discovery_coordinator.py # Socratic Q&A workflow
│ ├── planning_coordinator.py # Issue/task generation
│ └── agent_coordinator.py # Worker agent management
└── managers/
├── __init__.py
└── conversation_manager.py # Chat persistence
Responsibility Split
| Module | Responsibility |
|---|---|
| LeadAgent | High-level orchestration, state transitions |
| DiscoveryCoordinator | Socratic questions, answer processing |
| PlanningCoordinator | PRD → Issues → Tasks pipeline |
| AgentCoordinator | Worker spawning, task assignment |
| ConversationManager | Chat history, context persistence |
Acceptance Criteria
- LeadAgent reduced to <500 lines
- Each coordinator is independently testable
- No change to external API/behavior
- All existing tests pass
- Coverage maintained at >85%
Migration Strategy
- Extract DiscoveryCoordinator first (highest complexity)
- Extract PlanningCoordinator
- Extract AgentCoordinator
- Extract ConversationManager
- Thin LeadAgent to orchestrator only
Committee Report Reference
System Architect and Python Expert both flagged LeadAgent as "architectural smell". Quote: "Doing too much - orchestration, discovery, planning, conversation."
coderabbitai
Metadata
Metadata
Assignees
Labels
P3-post-betaLow priority - can wait until after beta (v2.0)Low priority - can wait until after beta (v2.0)architectureSystem architecture and design patternsSystem architecture and design patternsenhancementNew feature or requestNew feature or request