---
name: step-04-verify
description: Post-check verification of generated HTML
model: opus
---

# Step 4: Verify Generated HTML

## YOUR TASK

Run 16 blocking validations on the generated HTML file and display the completion summary.

---

## EXECUTION SEQUENCE

### 1. Blocking Validations

**Check 1 — File size > 100KB:**
```
if [ $(stat --format=%s ba-interactive.html) -lt 100000 ]; then
  BLOCKING_ERROR("ba-interactive.html not pre-populated — file too small")
fi
```

**Check 2 — moduleSpecs present in HTML:**
```
if ! grep -q '"moduleSpecs"' ba-interactive.html; then
  BLOCKING_ERROR("moduleSpecs not found — FEATURE_DATA not serialized")
fi
```

**Check 3 — cadrage.scope uses HTML keys (inscope/outofscope, NOT inScope):**
```
if grep -q '"inScope"' ba-interactive.html; then
  BLOCKING_ERROR("cadrage.scope still has JSON keys — conversion failed")
fi
```

**Check 4 — Wireframe field names correct (format/content, NOT mockupFormat/mockup):**
```
if grep -q '"mockupFormat"' ba-interactive.html; then
  BLOCKING_ERROR("Wireframes use 'mockupFormat' — must be 'format'")
fi
```

**Check 5 — All modules have specs AND wireframes:**
```
FOR each module in FEATURE_DATA.modules:
  IF FEATURE_DATA.moduleSpecs[module.code] undefined:
    BLOCKING_ERROR("Module {module.code} not in moduleSpecs")
  IF EMBEDDED_ARTIFACTS.wireframes[module.code] undefined:
    BLOCKING_ERROR("Module {module.code} not in wireframes")
```

**Check 6 — Per-module data completeness (source vs HTML):**
```
FOR each module in FEATURE_DATA.modules:
  Read source: {docs_dir}/{appKebab}/{moduleKebab}/usecases.json
  sourceUCCount = count of useCases OR usecases in source file
  htmlUCCount = count in FEATURE_DATA.moduleSpecs[module.code].useCases
  IF sourceUCCount > 0 AND htmlUCCount === 0:
    BLOCKING_ERROR("Module {module.code}: 0 useCases in HTML but {sourceUCCount} in source")

  Read source: {docs_dir}/{appKebab}/{moduleKebab}/rules.json
  sourceBRCount = count of rules OR businessRules in source file
  htmlBRCount = count in FEATURE_DATA.moduleSpecs[module.code].businessRules
  IF sourceBRCount > 0 AND htmlBRCount === 0:
    BLOCKING_ERROR("Module {module.code}: 0 businessRules in HTML but {sourceBRCount} in source")
```

**Check 7 — Screens/mockups populated (prevents ASCII-only regression):**
```
FOR each module in FEATURE_DATA.modules:
  Read source: {docs_dir}/{appKebab}/{moduleKebab}/screens.json
  sourceScreenCount = count of "screens" array OR "sections" array in source file
  htmlScreenResources = sum of resources[].length across moduleSpecs[module.code].screens[]
  IF sourceScreenCount > 0 AND htmlScreenResources === 0:
    BLOCKING_ERROR("Module {module.code}: 0 screen resources but source has {sourceScreenCount}")
```

**Check 8 — No serialization bugs ([object Object]):**
```
Search ba-interactive.html for the literal string "[object Object]"
IF found:
  BLOCKING_ERROR("Serialization bug: [object Object] found in HTML — steps[] or other arrays contain objects instead of strings")
  Identify which module/field contains the bug and fix the mapping
```

**Check 9 — No runtime crash (CRITICAL — validates page won't be blank):**
```
Open ba-interactive.html and search for the FEATURE_DATA JSON block.
Verify these MANDATORY top-level fields exist:
  - "modules": [...]          (array, can be empty)
  - "dependencies": [...]     (array, can be empty)
  - "cadrage": {...}          (object with stakeholders[], scope{})
  - "moduleSpecs": {...}      (object, one key per module)
  - "consolidation": {...}    (object)

IF "dependencies" is missing from FEATURE_DATA:
  Add: "dependencies": [] to the FEATURE_DATA object in the HTML
  (This is the #1 cause of blank HTML pages — TypeError on data.dependencies.length crashes all JS)

IF "modules" is missing:
  BLOCKING_ERROR("FEATURE_DATA.modules missing — page will crash")
```

> **IF any check fails (1-9):** fix the issue and re-run the failing step before completing.

### 2. Content Quality Validations (NEW)

**Check 10 — Language coherence:**
```
Read FEATURE_DATA.metadata.language (or config.json language field)
IF language is set (e.g., "fr"):
  FOR each module in FEATURE_DATA.modules:
    const spec = FEATURE_DATA.moduleSpecs[module.code]

    // Check UC names
    FOR each uc in spec.useCases:
      IF language == "fr" AND uc.name matches /^(Create|Update|Delete|View|List|Manage|Submit|Approve|Reject|Export)\b/:
        WARNING("Module {module.code}: UC '{uc.name}' appears English (expected French)")

    // Check BR statements
    FOR each br in spec.businessRules:
      IF language == "fr" AND br.statement matches /\b(must|should|cannot|when|if the|is required)\b/i:
        WARNING("Module {module.code}: BR '{br.name}' statement appears English (expected French)")

  Count total warnings. IF > 20% of items are in wrong language:
    WARNING("⚠ Significant language mismatch: {count} items in wrong language")
```

**Check 11 — Business rules have examples:**
```
FOR each module in FEATURE_DATA.modules:
  const brs = FEATURE_DATA.moduleSpecs[module.code].businessRules || []
  IF brs.length === 0: SKIP
  const withExamples = brs.filter(br => br.example && br.example.trim() !== '')
  const rate = withExamples.length / brs.length
  IF rate < 0.5:
    WARNING("Module {module.code}: only {withExamples.length}/{brs.length} BRs have examples ({rate*100}%)")
```

**Check 12 — Entity attributes have type field:**
```
FOR each module in FEATURE_DATA.modules:
  const entities = FEATURE_DATA.moduleSpecs[module.code].entities || []
  FOR each entity in entities:
    const attrs = entity.attributes || []
    const withType = attrs.filter(a => a.type && a.type.trim() !== '' && a.type !== 'string')
    IF attrs.length > 3 AND withType.length === 0:
      WARNING("Module {module.code}: entity '{entity.name}' — all {attrs.length} attributes default to 'string' (types may be missing)")
```

**Check 13 — Permissions populated per module:**
```
FOR each module in FEATURE_DATA.modules:
  const perms = FEATURE_DATA.moduleSpecs[module.code].permissions || []
  IF perms.length === 0:
    WARNING("Module {module.code}: 0 permissions — permission grid will be empty")
```

**Check 14 — Mockups not empty (screens with actual resources):**
```
FOR each module in FEATURE_DATA.modules:
  const screens = FEATURE_DATA.moduleSpecs[module.code].screens || []
  const wireframes = EMBEDDED_ARTIFACTS.wireframes?.[module.code] || []
  IF screens.length === 0 AND wireframes.length === 0:
    WARNING("Module {module.code}: no screens and no wireframes — Mockups tab will show 'Aucune maquette'")
  ELSE IF screens.length > 0:
    const totalResources = screens.reduce((sum, s) => sum + (s.resources || []).length, 0)
    IF totalResources === 0:
      WARNING("Module {module.code}: has screens[] but 0 resources — mockups will appear empty despite data existing")
```

**Check 15 — MCD diagram present (multi-module projects):**
```
const diagrams = FEATURE_DATA.consolidation?.mermaidDiagrams || {}
IF FEATURE_DATA.modules.length > 1:
  IF !diagrams.erd:
    WARNING("No ERD diagram — data model section will have no visual")
  IF !diagrams.mcd:
    WARNING("No MCD diagram — conceptual model not generated")
```

**Check 16 — Use Case diagrams present:**
```
const ucDiagrams = diagrams.useCases || {}
const totalUCs = Object.values(FEATURE_DATA.moduleSpecs).reduce((sum, s) => sum + (s.useCases?.length || 0), 0)
IF Object.keys(ucDiagrams).length === 0 AND totalUCs > 0:
  WARNING("No use case diagrams generated — UC tabs will have no UML visual")
```

> **Checks 10-16 produce WARNINGs (non-blocking).** Display all warnings in the completion summary so the user is aware of potential quality issues.

---

### 3. Display Completion Summary

```
══════════════════════════════════════════════════════════════
  [OK] HTML DEPLOY COMPLETE — {application_name}
══════════════════════════════════════════════════════════════

Modules: {count} ({names})

[DIR] Artifact generated:
  ba-interactive.html — Interactive document
     Path: {output_path}
     Pre-populated: {module_count} modules, {total_uc} use cases,
       {total_br} business rules, {total_wireframes} wireframes

[NEXT] Review & Validation:
  1. Open ba-interactive.html in browser
  2. Review all modules, use cases, business rules
  3. Validate wireframes and permissions
  4. If approved: /business-analyse-handoff then /business-analyse-develop to begin development
  5. If corrections needed: export ba-review.json from the HTML, then run /business-analyse-review

Quality Warnings: {warning_count}
{FOR each warning: display warning message}

══════════════════════════════════════════════════════════════
```
