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:

  1. Extract all at once (big bang)
  2. Extract one-by-one following dep graph (chosen)
  3. Refactor in-place without new files
  4. 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


🔗 Related


Auto-generated by MCP Smart Consolidation