Deprecated Generation Code Cleanup

Documentation for Plans

Deprecated Generation Code Cleanup — Post-S204

Background

S204 discovered that the platform generation pipeline had TWO parallel systems:

  1. backend-ai-api WorkflowService with full-configuration workflow type — a template-selection system that matched business descriptions to predefined templates. It NEVER decomposed requirements into actual modules (always produced 0 modules).
  2. backend-vitto-api ModuleGenerationService with a real 6-phase pipeline (PRE-FLIGHT, ENHANCE, ANALYZE, DECOMPOSE, PLAN, EXECUTE, DEPLOY) — the correct, working system.

S204 fixed routing so all entry points now delegate to the Vitto pipeline:

This session should remove the dead code left behind by that rerouting.


Files to Read First

Read these files in order before making any changes:

  1. apps/backend-ai-api/src/app/workflow/workflow.types.ts — WorkflowType union, WORKFLOW_TEMPLATES constant
  2. apps/backend-ai-api/src/app/workflow/workflow.service.ts — execute() method, full-configuration handler
  3. apps/backend-ai-api/src/app/workflow/workflow.controller.ts — POST/GET /workflow/start endpoints + module/generate endpoints
  4. libs/libs-ai/ai-generation-hub/src/lib/services/generation-hub.service.ts — main frontend orchestration service (~1200 lines)
  5. libs/libs-structural/vibe-universe/src/lib/components/vibe-universe-generator/vibe-universe-generator.component.ts — calls startGeneration()
  6. libs/libs-ai/ai-outcome-tracker/src/lib/types/module-outcome.types.ts — GenerationSource type

Cleanup Tasks

Task 1: Remove Dead Workflow Types from backend-ai-api

File: apps/backend-ai-api/src/app/workflow/workflow.types.ts

The WorkflowType union (line 12-18) defines 6 types. After S204, only single-module generation via PhaseExecutorService is active. The following types are dead:

Type Status Reason
full-configuration DEAD S204 bypassed it; never decomposed modules
system-generation DEAD Placeholder from Session 71, never wired to frontend
tenant-setup DEAD Never implemented beyond template definition
module-configuration DEAD Never called from frontend
page-layout DEAD Never called from frontend
widget-configuration DEAD Never called from frontend

Action:

Verification: npx tsc --noEmit on backend-ai-api after changes.

Task 2: Audit WorkflowService.execute() and Controller Endpoints

File: apps/backend-ai-api/src/app/workflow/workflow.service.ts

The execute() method handles the broken full-configuration flow. Check:

File: apps/backend-ai-api/src/app/workflow/workflow.controller.ts

Endpoints to evaluate:

Endpoint Status Notes
POST /workflow/start (line 48) Likely DEAD Routes to WorkflowService.execute() which uses broken flow
GET /workflow/start (line 66) Likely DEAD Same broken flow via SSE
POST /:id/continue (line 108) Likely DEAD Continues a broken workflow
GET /:id/status (line 120) Likely DEAD Status of broken workflows
POST /workflow/module/generate (line 152) KEEP Uses PhaseExecutorService (phase-executor/) for single-module gen
GET /workflow/module/generate (line 194) KEEP SSE version of above
GET /workflow/module/templates (line 262) KEEP Lists template types
GET /workflow/templates (line 319) Likely DEAD Lists broken workflow templates
GET /workflow/modules/:id/context (line 419) KEEP Retrieves generated module context
GET /workflow/modules/:id/files (line 436) KEEP Retrieves generated files
GET /workflow/modules/recent (line 453) KEEP Lists recent modules

Action:

Verification: Search for workflow/start in all frontend code to confirm no callers remain.

Task 3: Remove Dead Methods from GenerationHubService

File: libs/libs-ai/ai-generation-hub/src/lib/services/generation-hub.service.ts

After S204.5 rerouted startGeneration() to call startVittoGeneration() directly, the following private methods are dead (no callers):

Dead methods (confirmed by grep, all private):

Method Line LOC (approx) Reason Dead
startStreamingWorkflow() 422 ~230 Was the broken SSE flow to backend-ai-api
mergeToolResult() 668 ~20 Only called from startStreamingWorkflow
transformToGeneratedModule() 691 ~30 Only called from startStreamingWorkflow
transformManifestToGeneratedModule() 720 ~60 Only called from startStreamingWorkflow
inferEmbeddableType() 783 ~12 Only called from transformManifestToGeneratedModule
generateModuleName() 795 ~20 Only called from transformToGeneratedModule
extractEntities() 816 ~20 Only called from transformToGeneratedModule
parseEntitiesFromDescription() 840 ~140 Only called from extractEntities
moduleIdToEntityName() 980 ~10 Only called from extractEntities/transform methods
generateFieldsForEntity() 990 ~15 Only called from extractEntities/transform methods
extractActions() 1005 ~25 Only called from transformToGeneratedModule
extractEmbeddables() 1031 ~140 Only called from transformToGeneratedModule
initializeProgress() 1171 ~20 Was the old progress init; replaced by initializeVittoProgress()
getPhasesForMode() 1190 ~20 Only called from initializeProgress

Action:

Estimated removal: ~700 lines of dead code.

Verification: npx tsc --noEmit on ai-generation-hub and any app that imports it.

Task 4: Audit vibe-universe-generator Component

File: libs/libs-structural/vibe-universe/src/lib/components/vibe-universe-generator/vibe-universe-generator.component.ts

This component calls startGeneration() (confirmed at lines 1289, 1305, 2911, 2988). Since startGeneration() now delegates to startVittoGeneration(), the component should work correctly without changes.

Action:

Task 5: Audit ToolOrchestrationService References

File: libs/libs-foundational/core-angular/src/lib/services/tool-orchestration.service.ts

This service coordinates navigation between platform building tools (vibe-universe, modular-universe, module-workbench, etc.). It references ai-generation-hub as a tool conceptually but does NOT import or call GenerationHubService directly.

Action:

Task 6: Update GenerationSource Type

File: libs/libs-ai/ai-outcome-tracker/src/lib/types/module-outcome.types.ts

Current type (line 13):

export type GenerationSource = 'ai-panel' | 'module-workbench' | 'cursor-agent' | 'visual-builder';

This type tracks where a module was generated from. It does NOT include 'ai-generation-hub' as previously suggested. However, with the Vitto pipeline now being the canonical path:

Action:

Task 7: Remove Unused WorkflowService Dependencies

File: apps/backend-ai-api/src/app/workflow/workflow.service.ts

After removing the broken flow, check if these injected services are still needed:

For each, search for imports across the entire workflow directory. If only WorkflowService uses them, they can be removed from the module providers too.


Verification Checklist

After all changes:

  1. TypeScript compilation:

    npx tsc --noEmit -p apps/backend-ai-api/tsconfig.app.json
    npx tsc --noEmit -p libs/libs-ai/ai-generation-hub/tsconfig.lib.json
    npx tsc --noEmit -p libs/libs-ai/ai-outcome-tracker/tsconfig.lib.json
    
  2. Search for dangling references:

    # Search for removed method names
    grep -r "startStreamingWorkflow\|mapModeToWorkflowType\|full-configuration" --include="*.ts" libs/ apps/
    
    # Search for removed workflow start endpoint
    grep -r "workflow/start" --include="*.ts" libs/ apps/
    
  3. Confirm Vitto path still works:

    • GenerationHubService.startGeneration() should still compile and route to startVittoGeneration()
    • GenerationHubService.startVittoGeneration() should still call VITTO_API_BASE/generate
    • vibe-universe-generator component should still call startGeneration() without errors
  4. Backend module wiring:

    • Check WorkflowModule providers array — remove services that are no longer injected anywhere
    • Verify the module still exports PhaseExecutorService and its dependencies

Anti-Patterns to Avoid

DO NOT WHY
Remove the entire ai-generation-hub library It is used in live routes; startVittoGeneration() is the active path
Remove PhaseExecutorService or phase-executor/ directory Handles single-module generation from frontend (/module/generate)
Remove workflow.controller.ts entirely Still hosts active /module/generate and /modules/* endpoints
Change ModuleGenerationService in backend-vitto-api That is the canonical pipeline — leave it alone
Remove SSE event type interfaces from workflow.types.ts They may be imported by phase-executor or frontend code
Remove WorkflowModule from backend-ai-api Still needed for module generation endpoints
Batch-remove without checking imports first Some "dead" methods may have been re-used elsewhere since S204

Estimated Impact

Metric Before After
Dead workflow types 6 0
Dead methods in GenerationHubService 14 (~700 lines) 0
Dead controller endpoints ~4 0
Dead WorkflowService.execute() flow ~500+ lines 0
Total dead code removed ~1,200+ lines 0

Commit Convention

Follow SAGP v1.2:

[S{N}.1] refactor: remove dead workflow types from backend-ai-api
[S{N}.2] refactor: remove dead methods from GenerationHubService
[S{N}.3] refactor: remove dead controller endpoints from WorkflowController
[S{N}.4] feat: add 'vitto-pipeline' to GenerationSource type
[S{N}.5] refactor: remove unused WorkflowService dependencies

Where {N} is the session number assigned to this cleanup work.