Session 43 - Testing & Verification

How to test the complete AI generation pipeline

Testing Session 43 Fixes

✅ Verification: Entity Extraction is Working!

Generated modules in /modules/business/:

Proof: Check member-management.manifest.ts:

{
  "id": "fitness-studio-platform-member-management",
  "name": "Member Management",
  "publicActions": [
    {
      "name": "create-member",  // ✅ Domain-specific!
      "inputs": [
        { "name": "firstName", ... },  // ✅ Contextual fields!
        { "name": "lastName", ... },
        { "name": "email", ... },
        { "name": "phone", ... }
      ]
    }
  ]
}

Current Issues (Minor)

1. Angular NG0203 Error (Browser Cache)

Error: effect() can only be used within an injection context

Root Cause: Browser is running OLD code (effects in ngOnInit()). New code has effects in constructor().

Fix: Hard refresh the browser

2. Canvas Showing Flat List

Expected: Hierarchy (platform-root → galaxy → worlds)
Actual: Flat list

Debug Steps:

  1. Open browser console
  2. Look for log: "🔄 Converting modules to canvas"
  3. Check if it says "Structured platform detected" or "Flat module list"
  4. If flat, check the types array - does it include 'platform-root'?

Possible Causes:

3. 404 on Module Lookup

Error: GET .../modules/generated-fitness-studio-platform-... 404

Root Cause: Frontend is querying with a different ID than what was generated.

Generated IDs (from backend):

Queried ID (from frontend):

Why: The autoSyncModulesToCanvas() or deployToUniverse() is creating modules with different IDs than the backend generated.


Immediate Actions Required

Step 1: Hard Refresh Browser

# In browser:
Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)

This will load the new Angular code with constructor() and fix the NG0203 error.

Step 2: Check Universe Structure in MongoDB

// In MongoDB Compass or shell:
db.universes.findOne({ _id: "universe_1768430861607_ba3vtksly" })

// Check structure field:
{
  structure: [
    {
      moduleId: "platform-root-complete-fitness-...",
      config: {
        type: "layout",  // ❌ Should be "platform-root"
        // ...
      },
      children: [...]
    }
  ]
}

If config.type is "layout": The buildGeneratedUniverseTree() is setting wrong type in config.

Step 3: Verify Module IDs Match

Check what IDs are in universe.structure:

db.universes.findOne({ _id: "universe_..." }).structure[0].children

Compare with generated module folders:

ls modules/business/ | grep fitness

They should match exactly.


Root Cause Analysis

Issue: config.type vs module.type

Looking at backend logs (line 29):

"config":{"name":"Complete Fitness","type":"layout","layoutType":"flex",...}

The config.type is "layout" but it should be "platform-root".

Where this is set: vibe-universe-generator.component.ts:2390 in buildGeneratedUniverseTree():

const structureNode: UniverseStructureNode = {
  moduleId: module.moduleRef || module.id,
  moduleRef: module.moduleRef,
  config: {
    name: module.name,
    type: module.type as CosmicModuleType,  // ✅ This should be correct
    // ...
  }
}

But UniversalModule.type is 'platform-root' while config.type ends up as 'layout'.

Bug Location: universe-module.service.ts:784 in modulesToStructureNodes():

config: {
  name: module.name,
  type: module.type as import('@libs-foundational/core-models').CosmicModuleType,
  route: module.route,
  layoutType: module.layout?.type || 'flex',  // ❌ This might be overwriting type
  // ...
}

Quick Fixes Needed

Fix 1: Ensure config.type Preserves Module Type

File: libs/libs-foundational/core-angular/src/lib/services/universe-module.service.ts:782-790

const structureNode: UniverseStructureNode = {
  moduleId: module.moduleRef || module.id,
  moduleRef: module.moduleRef,
  config: {
    name: module.name,
    type: module.type as CosmicModuleType,  // ✅ Correct
    route: module.route,
    layoutType: module.layout?.type || 'flex',  // Don't confuse with type
    template: module.layout?.template,
    styles: module.styles,
    ai: module.ai,
  } as StructureNodeConfig,
  children: module.children ? this.modulesToStructureNodes(...) : [],
};

Fix 2: Match Module IDs Between Generation and Sync

The autoSyncModulesToCanvas() creates IDs like:

id: `preview-${moduleSlug}-${Date.now()}-${i}`

But the backend generates:

id: `${platformSlug}-${entitySlug}-management`

These must match!


Summary

✅ Working

⚠️ Needs Fix

🔧 Action Items

  1. Hard refresh browser (fixes NG0203)
  2. Debug config.type in structure nodes
  3. Align module IDs between generation and sync
  4. Test full flow after fixes