Architecture: How to implement Session 161: Super Vitto engine refactor + ...
Documentation for Sessions
🏗️ Architecture: How to implement Session 161: Super Vitto engine refactor + ...
Date: 2026-03-01
Time: 20:46:48 UTC
Session: gspace1-161.2
Agent: backend
Confidence: 91%
Status: ✅ Documented
📋 Decision Context
Question:
How to implement Session 161: Super Vitto engine refactor + Brain UI?
Task: Session 161: Super Vitto implementation plan
🎯 Decision Made
Chosen:
8-step plan: Extract 5 services from 2153-line vitto-engine.service.ts (ContextAssembly, MemoryPersistence, VittoDebug, SlashCommand, ChannelProcessing) + add debug endpoints + build Brain UI page with system prompt preview and debug viewer. Extraction order follows dependency graph (leaves first). Circular dep for /briefing solved with callback pattern.
Options Considered:
- Extract all at once (big bang)
- Extract one-by-one following dep graph (chosen)
- Refactor in-place without new files
- Defer to Phase 2 after more tests
💭 Reasoning
The 2153-line god object with 23 constructor deps is unmaintainable. Extracting by responsibility (context, memory, commands, channel I/O, debug) follows SRP. Leaf-first extraction order (ContextAssembly → MemoryPersistence → Debug → SlashCommand → ChannelProcessing) minimizes risk — each step compiles independently. The /briefing circular is solved with setAgentLoopHandler callback, avoiding forwardRef. Original plan's 200-line target was unrealistic — 850 is honest (60% reduction, all public API preserved). Brain UI in vitto-hub follows existing observatory pattern. Phases 4-5 deferred to Session 162 to avoid scope creep.
📁 Files Involved
APIs/backend-vitto-api/src/app/engine/vitto-engine.service.tsAPIs/backend-vitto-api/src/app/engine/engine.module.tsAPIs/backend-vitto-api/src/app/engine/vitto.controller.tslibs/libs-ai/vitto-hub/src/lib/routes/vitto-hub.routes.tslibs/libs-ai/vitto-hub/src/lib/services/vitto-api.service.ts
🔗 Related
- Decision ID:
dev_1772398008311_5kcy3cl - Session: 161
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation