2026 03 09 S197 Vitto Generation Pipeline Design
Documentation for Plans
S197 Design: Vitto End-to-End Generation Pipeline
Overview
Fix the agent loop stalling that prevents module generation, deep-port gmodules1's proven generation patterns into Vitto, integrate generation with the existing 51-feature Vitto UI ecosystem, and enable full conversational generation with interactive/autonomous modes.
Stream A: Backend — Generation Foundation
A1. Agent Loop Stall Fix
Root cause: System prompt from context-assembly.service.ts concatenates 10+ sections with zero token budget enforcement. When total exceeds context window, tool definitions get dropped. LLM responds with text only, stopReason !== 'tool_use', loop exits at iteration 1.
Changes:
- Token budget enforcement in
context-assembly.service.ts— cap system prompt at 60K tokens - Tiered section priority — trim lowest-priority sections first when budget exceeded:
- Proactive hints (lowest)
- Page context
- Learning intelligence
- Awareness events
- Conversation history (truncate progressively)
- Core persona + tool descriptions (never trim)
- Diagnostic logging in
agent-loop.service.ts:- Log tools array size before API call
- Log system prompt token estimate
- Log raw Anthropic API response stopReason + tool_use blocks
- Tool presence assertion — if tools array is empty after filtering, log error and include fallback essential tools
- Files:
context-assembly.service.ts,agent-loop.service.ts,claude.provider.ts
A2. Template Registry (from gmodules1)
New service: TemplateRegistryService in module-generation/templates/
5 template types: crud, dashboard, analytics, integration, basic
Pre-generated files per template (CRUD example):
models/{{entity}}.model.ts # Entity interface extending BaseEntity
models/index.ts # Barrel export
services/{{entity}}.repository.ts # API service extending BaseCrudApiService<T>
services/index.ts # Barrel export
components/{{entity}}-list/ # List component with useCrudList() composable
components/{{entity}}-detail/ # Detail component with useCrudDetail() composable
components/{{entity}}-form/ # Form component with useCrudForm() composable
Template variables: {{entity}}, {{Entity}}, {{entities}}, {{Entities}}, {{ENTITY}}, {{PascalCaseName}}, {{moduleName}}
Token reduction: ~45% — LLM enhances pre-generated files instead of writing from scratch.
getTemplatePromptContext() provides template-aware context to phase prompts.
A3. Composable Functions Registry
Port gmodules1 composables that generated code will use:
useCrudList()— configuresGgsCrudListShellComponent(table/card mode, filters, pagination, bulk actions)useCrudForm()— configures form with field definitions (layout, validation, conditional visibility)useCrudDetail()— configures detail view (sections, related entities, actions)
These composables are what make output "editable" — they configure existing shell components that the embeddable-bridge renders. Changes are config adjustments, not rewrites.
A4. Prompt Enhancement
Enrich Vitto's 5 phase prompts (system-analyze.prompt.md, system-decompose.prompt.md, system-plan.prompt.md, implement-visual.prompt.md, implement.prompt.md) with:
- 20+ critical failure rules from gmodules1 (FA icon tuples, entity lookups, route ordering, barrel exports, mock data matching, etc.)
- Template-aware instructions — "enhance the pre-generated template, don't rewrite from scratch"
- Composable usage rules — "use useCrudList() not raw table components"
- Embeddable-bridge compatibility — ensure generated components work in the studio editor
- Token budget per prompt — enforce 800 chars brief, 2000 chars prompt (already in S196, verify enforcement)
A5. Context Caching + Checkpoint/Resume
ProjectContextCacheService:
- Cache workspace structure, dependencies, existing modules (30min TTL)
- Invalidate on file changes
- Provide sibling module context to prevent duplication
Phase checkpoint system:
- Save state between phases (files generated so far, entity model, decisions made)
- Allow resume from failure point
- Support user-initiated pause in interactive mode
Validation rules per phase (from gmodules1):
- Spec:
specification_complete,entity_model_defined,routes_specified - Implement:
components_complete,inline_templates_only,signals_used,inject_used - Finalize:
path_alias_added,module_registered,mock_registered,build_passes,lint_passes
Stream B: Frontend — UI + Integration
B1. Pipeline Visualizer Panel (vitto-studio)
New dock panel in @libs-structural/vitto-studio: PipelineVisualizerPanelComponent
Layout: DAG graph (left 60%) + active phase detail (right 40%)
DAG graph:
- Nodes = phases/skills from playbook orchestration
- Edges = dependencies (sequential vertical, parallel branches side-by-side)
- Node states: pending (dim), running (pulsing border + glow), complete (green check), failed (red X), skipped (gray)
- Each node shows: skill name, mastery level badge, inline progress bar with file count
Detail panel (when node selected):
- Real-time progress bar with percentage
- Token usage (used / budget)
- Files generated (list with status icons)
- Mastery score for this skill
- Elapsed time + ETA
- Live log stream (last 5 lines of agent output)
Bottom bar: Overall pipeline stats — total progress %, total tokens, total time
Editor mode (when not generating): drag to reorder steps, add/remove skills, configure timeouts, toggle parallel/sequential. Saves to playbook orchestration field.
SSE integration: Wires into existing StudioGenerationListenerService events + new events:
pipeline.status— full state snapshot (reconnection)phase.file.list— files generated in current phasephase.token.usage— token consumption per phasephase.mastery.update— mastery score change
B2. Enhanced Properties Panel (vitto-studio)
Extend existing PropertiesPanelComponent:
- Pipeline node selected → show active phase detail (progress, tokens, files, mastery, log)
- Entity/module selected → show entity designer inline
- Use existing
CanvasSelectionService
B3. Generation Toolbar Indicator (vitto-studio)
Enhance studio-toolbar generation indicator:
- Show phase name + progress percentage during generation
- Click → auto-focus pipeline panel in dock layout
B4. Workflow-Generation Integration
Extend WorkflowBuilderPageComponent to support generation pipelines:
New step types:
AnalyzeStep— runs analyze phasePlanStep— runs plan phaseGenerateStep— runs execute phase (configurable: backend, frontend, or both)VerifyStep— runs verify phaseCheckpointStep— user approval gate (pause workflow, wait for input)
Workflow templates: Pre-built "CRUD Module Generation" workflow from playbook orchestration config.
Bidirectional conversion: Playbook orchestration.steps[] ↔ workflow definition. Import a playbook as a workflow, or save a custom workflow as a playbook orchestration.
Parallel branches: Workflow canvas parallel branches = parallel generation phases.
B5. Skills as Workflow Steps
Skills from Skill Studio usable as workflow Action steps:
- Playbook skills (generate-backend, generate-frontend, etc.) become reusable Action nodes
- Skill Composer DAG composition maps to workflow step dependencies
- Skill mastery updates on completion within workflow execution
B6. Templates UI Enhancement
Extend ContentTemplatesComponent at /vitto/templates:
- Add "Code Generation" template category alongside content templates
- Port gmodules1's 5 template types as browsable/editable templates
- Users create custom templates → Vitto uses in future generations
- Template preview with variable highlighting
B7. Queue + Observatory Integration
Queue Dashboard: Generation tasks appear as queue items (pending, active, completed, failed) Observatory Agent Monitor: Generation progress visible in real-time Cost Dashboard: Token costs per generation tracked Failure Chains: Failed generations analyzed for patterns Specialization Matrix: Generation skill mastery displayed
Stream C: Conversational Generation
C1. Interaction Mode Selection
At generation start, Vitto asks:
"I can walk you through this step by step so you can guide the decisions, or I can build it autonomously and show you the result. Which do you prefer?"
Interactive → SUGGEST autonomy level:
- Pauses at decision points
- Asks clarifying questions
- Lets user modify mid-generation
Autonomous → AUTONOMOUS autonomy level:
- Builds end-to-end
- Reports result
- User reviews via file review panel
Mode stored in user dossier workPatterns.preferredWorkflow.
C2. Interactive Checkpoints
In interactive mode, Vitto pauses at:
- Pre-generation: Entity relationships confirmation
- After analyze: Component structure preview
- After plan: Architecture approval
- During execute: Per-component style choices
- Post-generation: Final review + tweaks
Each checkpoint saves phase state. User can modify, then Vitto resumes from that point.
C3. Post-Generation Conversational Editing
After generation, user modifies via chat:
- "Make the list view use cards instead of a table" → modify composable config
- "Add a date filter field" → update entity model + list filter config
- "The form should have 2 columns" → adjust form layout composable
Works because generated code uses composable functions — changes are config, not rewrites. Each modification logged as a learning outcome.
C4. Enhanced Chat Plugins
Studio Plugin (extend existing createStudioPlugin()):
/generate [description]— enhanced with interaction mode prompt/modify [what to change]— NEW: modify last generated module conversationally/pipeline— NEW: show pipeline status in chat/review— NEW: start file review from chat/teach [pattern]— wire to mastery: save user preference to dossier
Mastery Plugin (wire existing empty enrichMessage()):
enrichMessage()injects active job mastery context (skill scores, pitfalls, patterns)/mastery→ navigate to mastery dashboard/dossier→ navigate to dossier view/new-job→ open PlaybookCreator with pre-filled description
C5. PlaybookCreator "Let Vitto Help"
Wire onLetVittoHelp() in PlaybookCreatorComponent:
- Send
naturalDescriptionto Vitto API - Vitto generates: jobType slug, displayName, category, description, skills list with instructions, initial strategy, graduation criteria
- Pre-fill all form fields with generated values
- User reviews and adjusts before saving
C6. Learning Loop
Every generation produces learning data:
- Outcome logging via
studio-learning.service(success/failure + metrics) - User modifications logged as "correction" events in dossier
- Mastery updates via SSE in real-time during generation
- Strategy self-optimization after 3+ failures (already in S196
JobMasteryService) - Knowledge Graph nodes created for generated entities/relationships
- Thought Trace shows reasoning during each phase
Architecture Diagram
User Chat Message
↓
Interaction Mode Check (autonomy.service.ts)
↓
┌── Interactive ──────────────────────────┐
│ Checkpoint gates between phases │
│ User approves/modifies at each step │
│ Post-gen conversational editing │
└─────────────────────────────────────────┘
↓
Agent Loop (agent-loop.service.ts) [FIXED: token budget + tool assertion]
↓
Tool: start_module_generation
↓
Template Registry → Pre-generate boilerplate (45% token reduction)
↓
Phase Pipeline (workflow steps):
ANALYZE → PLAN → EXECUTE (parallel: backend + frontend) → VERIFY
↓ (each phase)
├── Prompt: enhanced with gmodules1 rules + mastery context
├── Template: pre-generated files with composable functions
├── Validation: per-phase rules (build, lint, type-check)
├── SSE events: progress, files, tokens, mastery
└── Checkpoint: save state, optional user gate
↓
Generated Files → AiFileWriterService → File Review → Git Commit
↓
Learning Pipeline:
├── Outcome → studio-learning.service
├── Corrections → user-dossier.service
├── Mastery → job-mastery.service
├── Strategy → self-optimization (after 3+ failures)
└── Knowledge Graph → entity relationships
Files to Create
Backend (backend-vitto-api)
module-generation/templates/template-registry.service.tsmodule-generation/templates/template-types.tsmodule-generation/templates/crud/(template files)module-generation/templates/dashboard/module-generation/templates/analytics/module-generation/templates/integration/module-generation/templates/basic/module-generation/context/project-context-cache.service.tsmodule-generation/checkpoint/phase-checkpoint.service.tsmodule-generation/checkpoint/checkpoint.schema.tsmodule-generation/validation/phase-validation.service.tsmodule-generation/composables/composable-registry.service.ts
Frontend (vitto-studio)
components/pipeline-visualizer/pipeline-visualizer.component.tscomponents/pipeline-visualizer/pipeline-visualizer.component.htmlcomponents/pipeline-visualizer/pipeline-visualizer.component.scsscomponents/pipeline-visualizer/pipeline-node.component.tspanels/pipeline-visualizer-panel.component.tsservices/pipeline-state.service.ts
Frontend (vitto-hub — workflow extension)
- Extend
workflow-builder-pagewith generation step types - Add step type definitions for Analyze, Plan, Generate, Verify, Checkpoint
Frontend (vitto-intelligence)
- Wire
PlaybookCreatorComponent.onLetVittoHelp()
Frontend (vitto-chat)
- Wire
mastery.plugin.tsenrichMessage() - Add
/modify,/pipeline,/reviewcommands to studio plugin
Files to Modify
Backend
engine/agent-loop.service.ts— diagnostic logging, tool assertionengine/context-assembly.service.ts— token budget enforcement, tiered trimmingengine/claude.provider.ts— log tools sent to APIprompts/module-gen/*.prompt.md— add gmodules1 rules + template instructionsmodule-generation/phases/module-gen-phase.executor.ts— emit new SSE events, checkpoint supportmodule-generation/context/generation-context.service.ts— integrate template registry + context cache
Frontend
vitto-studio/services/studio-generation-listener.service.ts— handle new SSE eventsvitto-studio/components/studio-toolbar/— generation progress indicatorvitto-studio/config/studio-dock-panels.config.ts— register pipeline panelvitto-studio/plugins/studio.plugin.ts— add /modify, /pipeline, /review commandsvitto-chat/plugins/mastery.plugin.ts— wire enrichMessage() + command handlersvitto-intelligence/components/playbook-creator/— wire onLetVittoHelp()vitto-hub/components/workflow-builder-page/— add generation step types
Testing Strategy
Backend Tests
- Agent loop: verify tools are sent to API, verify budget enforcement, verify loop continues on tool_use
- Template registry: verify template generation, variable interpolation, all 5 types
- Context cache: verify caching, TTL, invalidation
- Checkpoint: verify save/resume, state integrity
- Validation: verify per-phase rules
Frontend Tests
- Pipeline visualizer: DAG rendering, node state transitions, SSE event handling
- Workflow steps: generation step types create/execute correctly
- Chat plugins: slash commands trigger correct actions, enrichMessage injects context
- PlaybookCreator: Vitto Help generates and pre-fills form
Integration Tests
- End-to-end: chat message → agent loop → tool call → generation → file review → git commit
- Interactive mode: checkpoint gates pause/resume correctly
- Conversational editing: post-generation modification updates files