Architecture: How should the scaffold fallback generator produce code when...
Documentation for Sessions
🏗️ Architecture: How should the scaffold fallback generator produce code when...
Date: 2026-03-10
Time: 18:57:22 UTC
Session: gspace1-199.2
Agent: angular
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
How should the scaffold fallback generator produce code when the LLM times out or returns malformed output?
Task: S199: Fix module code generation quality
🎯 Decision Made
Chosen:
Align scaffold templates with implement.prompt.md golden rules: models extend BaseEntity, services extend BaseCrudApiService, components use useCrudList/useCrudDetail/useCrudForm composables, all routes include authGuard, domain events generated per entity, .vitto/instructions.json generated per module.
Options Considered:
- Fix only the LLM prompt (already correct, doesn't help when LLM times out)
- Add more retries to LLM calls (wastes tokens, doesn't fix quality)
- Remove scaffold entirely and fail loudly (bad UX, users see nothing)
- Align scaffold with prompt rules (chosen — guaranteed quality floor)
💭 Reasoning
ROOT CAUSE: The scaffold generator (generateScaffoldFiles, ~430 lines) was written in Session 108 before the composable infrastructure existed. It produced code from a different era: manual signals, raw UniverseDataService, no BaseEntity, no authGuard, no events. When the LLM timed out (which happens ~20% of the time on multi-module generation), users got broken modules that violated every rule in implement.prompt.md. The fix is not to make the LLM more reliable (that's a separate problem) but to make the fallback indistinguishable from correct LLM output. The scaffold IS the safety net — it must be production-quality. Also added detail + form component generation (scaffold only generated list components, but routes referenced detail/form → guaranteed 404). Also added .vitto/instructions.json with editable areas and available actions — this is the foundation for contextual chat editing.
📁 Files Involved
APIs/backend-vitto-api/src/app/module-generation/phases/module-gen-phase.executor.tsAPIs/backend-ai-api/src/app/workflow/generators/module-code-generator.service.tsAPIs/backend-vitto-api/src/prompts/module-gen/implement.prompt.md
🔗 Related
- Decision ID:
dev_1773169042348_7jlpzoc - Session: 199
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation