S202 Handoff Prompt
Context for the next agent — validate generation, polish Studio, local dev mode
S202 Handoff Prompt — Validation & Polish
What Was Built (S199-S201)
The platform code generation pipeline is feature-complete. Three sessions built it:
| Session | Focus | Key Commits |
|---|---|---|
| S199 | Backend infrastructure | 6-phase pipeline, SSE streaming, GitLab API, auto-correction |
| S200 | Frontend wiring + deploy | Studio GitLab mode, deploy pipeline, chat integration, parallel gen |
| S201 | Production hardening | MongoDB SSE persistence, auth guards, cost display, rollback, summary |
Current State
- Branch:
session-201.4 - Commits: S201.5 (backend stability, +917 lines), S201.6 (Phase 5 hardening, +739 lines)
- All backends compile (missing packages installed in S201.5)
- vitto-studio library compiles clean (verified with
tsc --noEmit)
What Needs Validation
Priority 1: End-to-End Generation Test
Run a real generation and verify:
- Category assignment — Modules get meaningful categories (layout, analytics, auth) not all "structural"
- Check
inferModuleCategory()inmodule-generation.types.ts
- Check
- GitLab repo creation — Personal namespace fallback works on 403
- Scaffold templates compile — Form:
crud.onSubmit(), List:crud.items(), Detail: proper routing - Path aliases — Format
@module/{category}/{slug}ingenerated.paths.json - package.json — Each module gets one with
@module/{category}/{slug}name - Parallel execution — Logs show "PARALLEL: Executing batch of N modules"
- Post-gen summary — Chat shows rich markdown with module list, quality score, MR link
- Cost display — Pipeline visualizer shows per-node and total cost
- SSE reconnection — Refresh page mid-generation, events replay
Priority 2: Studio Visualization
Vitto Studio should show generated modules in its file tree:
VfsSyncService.setRepoContext()must be called from route paramsrefreshAllModulesFromRepo()must get data from GitLab- The
StudioGenerationListenerServiceshould handle SSE events to update the tree
Priority 3: Remaining Phase 5 Items
- 5.2 Local dev mode —
SAVE_GENERATED_LOCALLY=true+ NX project scaffolding + file watcher - 5.3 NX module registration —
yarn paths:mergeauto-run after local generation
New Infrastructure (from S201)
| Feature | How It Works |
|---|---|
| SSE persistence | generation_events collection, 24h TTL, dual-write (ReplaySubject + MongoDB) |
| Auth guards | JwtAuthGuard + SpaceOwnershipGuard on Studio/Deploy/ModuleGen controllers |
| SSE stream auth | @Public() on SSE endpoints (EventSource can't send headers), session ID is the token |
| Cost display | Client-side computation in pipeline-state.service.ts using MODEL_COST_RATES |
| Rollback | lastGenerationCommitSha signal in studio-generation-listener.service.ts, button in git-status-bar |
| Chat summary | module-gen.completed handler in vitto-chat-engine.service.ts, captures MR URL from earlier event |
Critical Conventions (Cumulative S200-S201)
- Module aliases:
@module/{category}/{slug}— NEVER without category - Scaffold templates:
crud.onSubmit()notform.submit(),crud.items()nottoggleSelectAll() session.result.executeResult.modulesMUST be array, never count- GitLab
initializeRepofalls back to personal namespace on 403 - Every module needs
package.jsonwith@module/{category}/{slug}name - SSE endpoints:
@Public()(EventSource limitation), session ID as implicit auth - Cost: client-side from token counts, MODEL_COST_RATES in
pipeline.types.ts - Dual-write for SSE: ReplaySubject (live) + MongoDB (restart recovery)
- Guards: controller-level
@UseGuards(), new endpoints get protection by default
Key Files
Backend (Vitto API — port 3003)
- Generation executor:
APIs/backend-vitto-api/.../phases/module-gen-phase.executor.ts - Parallel batching:
APIs/backend-vitto-api/.../phases/execute.phase.ts - SSE events schema:
APIs/backend-vitto-api/.../session/generation-event.schema.ts - Session manager:
APIs/backend-vitto-api/.../session/module-gen-session.manager.ts - Auth guard:
APIs/backend-vitto-api/.../studio/guards/space-ownership.guard.ts - GitLab service:
APIs/backend-vitto-api/.../studio/universe-git.service.ts
Frontend (Angular)
- Chat engine:
libs/libs-ai/vitto-chat/.../vitto-chat-engine.service.ts - Pipeline state:
libs/libs-structural/vitto-studio/.../services/pipeline-state.service.ts - Pipeline types:
libs/libs-structural/vitto-studio/.../types/pipeline.types.ts - Git service:
libs/libs-structural/vitto-studio/.../services/studio-git.service.ts - Gen listener:
libs/libs-structural/vitto-studio/.../services/studio-generation-listener.service.ts - VFS sync:
libs/libs-structural/vitto-studio/.../services/vfs-sync.service.ts
What NOT to Do
- Do NOT manually edit generated module files — fix the generator instead
- Do NOT edit tsconfig.base.json for @module/* paths — use
generated.paths.json+yarn paths:merge - Do NOT hardcode ports — use env vars from
.env.local - Do NOT pass
--portto backend serve commands (WebSocket 400 errors) - Do NOT use Promises in Angular — RxJS Observables only
- Do NOT remove
@Public()from SSE endpoints — browsers can't send auth headers to EventSource - Do NOT use @module/{slug} without category — always
@module/{category}/{slug}
Commit Convention
[S202.N] type: description