@atlashub/smartstack-cli 3.8.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +2 -1
  4. package/templates/agents/action.md +1 -0
  5. package/templates/agents/ba-writer.md +211 -0
  6. package/templates/agents/explore-codebase.md +1 -0
  7. package/templates/agents/explore-docs.md +1 -0
  8. package/templates/agents/fix-grammar.md +1 -0
  9. package/templates/agents/snipper.md +1 -0
  10. package/templates/skills/admin/SKILL.md +6 -0
  11. package/templates/skills/ai-prompt/SKILL.md +32 -136
  12. package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
  13. package/templates/skills/apex/SKILL.md +120 -0
  14. package/templates/skills/apex/_shared.md +86 -0
  15. package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
  16. package/templates/skills/apex/references/smartstack-layers.md +173 -0
  17. package/templates/skills/apex/steps/step-00-init.md +156 -0
  18. package/templates/skills/apex/steps/step-01-analyze.md +169 -0
  19. package/templates/skills/apex/steps/step-02-plan.md +160 -0
  20. package/templates/skills/apex/steps/step-03-execute.md +166 -0
  21. package/templates/skills/apex/steps/step-04-validate.md +138 -0
  22. package/templates/skills/apex/steps/step-05-examine.md +124 -0
  23. package/templates/skills/apex/steps/step-06-resolve.md +105 -0
  24. package/templates/skills/apex/steps/step-07-tests.md +130 -0
  25. package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
  26. package/templates/skills/application/SKILL.md +10 -0
  27. package/templates/skills/application/references/application-roles-template.md +227 -0
  28. package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
  29. package/templates/skills/application/references/backend-entity-seeding.md +72 -0
  30. package/templates/skills/application/references/backend-verification.md +88 -0
  31. package/templates/skills/application/references/frontend-verification.md +111 -0
  32. package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
  33. package/templates/skills/application/references/provider-template.md +158 -0
  34. package/templates/skills/application/references/test-frontend.md +73 -0
  35. package/templates/skills/application/references/test-prerequisites.md +72 -0
  36. package/templates/skills/application/steps/step-01-navigation.md +7 -198
  37. package/templates/skills/application/steps/step-03-roles.md +45 -7
  38. package/templates/skills/application/steps/step-03b-provider.md +15 -132
  39. package/templates/skills/application/steps/step-04-backend.md +20 -350
  40. package/templates/skills/application/steps/step-05-frontend.md +12 -101
  41. package/templates/skills/application/steps/step-07-tests.md +12 -132
  42. package/templates/skills/business-analyse/SKILL.md +67 -6
  43. package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
  44. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
  45. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
  46. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
  47. package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
  48. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
  49. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
  50. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
  51. package/templates/skills/business-analyse/html/src/template.html +1 -0
  52. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
  53. package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
  54. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  55. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  56. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  57. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  58. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  59. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  60. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  61. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  62. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  63. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  64. package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
  65. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  66. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  67. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  68. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  69. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
  70. package/templates/skills/business-analyse/steps/step-00-init.md +186 -53
  71. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  72. package/templates/skills/business-analyse/steps/step-03a-data.md +42 -49
  73. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  74. package/templates/skills/business-analyse/steps/step-03c-compile.md +71 -2
  75. package/templates/skills/business-analyse/steps/step-03d-validate.md +277 -48
  76. package/templates/skills/business-analyse/steps/step-04-consolidation.md +175 -104
  77. package/templates/skills/business-analyse/steps/step-05a-handoff.md +66 -438
  78. package/templates/skills/business-analyse/steps/step-05b-deploy.md +35 -184
  79. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +526 -0
  80. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  81. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  82. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  83. package/templates/skills/check-version/SKILL.md +7 -0
  84. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  85. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  86. package/templates/skills/controller/steps/step-03-generate.md +166 -158
  87. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  88. package/templates/skills/controller/templates.md +11 -2
  89. package/templates/skills/debug/SKILL.md +7 -0
  90. package/templates/skills/explore/SKILL.md +6 -0
  91. package/templates/skills/feature-full/SKILL.md +39 -142
  92. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  93. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  94. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  95. package/templates/skills/gitflow/references/plan-template.md +69 -0
  96. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  97. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  98. package/templates/skills/gitflow/steps/step-init.md +18 -289
  99. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  100. package/templates/skills/gitflow/steps/step-start.md +16 -126
  101. package/templates/skills/mcp/SKILL.md +9 -213
  102. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  103. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  104. package/templates/skills/notification/SKILL.md +7 -0
  105. package/templates/skills/quick-search/SKILL.md +5 -0
  106. package/templates/skills/ralph-loop/SKILL.md +99 -381
  107. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  108. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  109. package/templates/skills/ralph-loop/references/core-seed-data.md +173 -21
  110. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  111. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  112. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  113. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  114. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  115. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  116. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  117. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  118. package/templates/skills/refactor/SKILL.md +12 -176
  119. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  120. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  121. package/templates/skills/review-code/SKILL.md +19 -257
  122. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  123. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  124. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  125. package/templates/skills/ui-components/SKILL.md +7 -0
  126. package/templates/skills/utils/SKILL.md +6 -0
  127. package/templates/skills/validate/SKILL.md +6 -0
  128. package/templates/skills/validate-feature/SKILL.md +8 -0
  129. package/templates/skills/workflow/SKILL.md +40 -118
  130. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -126,6 +126,280 @@ ba-writer.enrichSection({
126
126
  })
127
127
  ```
128
128
 
129
+ #### 9f. Module Specification Checklist (BLOCKING)
130
+
131
+ > **CRITICAL:** This checklist MUST be FULLY COMPLETED before marking module status = "specified".
132
+ > **Rationale:** Prevents incomplete modules from reaching handoff, reduces ralph-loop failures.
133
+
134
+ **Execute BEFORE updating module status to "specified":**
135
+
136
+ ```javascript
137
+ const checklist = {
138
+ // SECTION 1: DATA MODEL (BLOCKING)
139
+ entities: {
140
+ minimum: 2,
141
+ actual: specification.entities.length,
142
+ status: actual >= minimum ? "PASS" : "FAIL",
143
+ blocking: true,
144
+ details: "At least 2 entities required for a meaningful module"
145
+ },
146
+
147
+ entityAttributes: {
148
+ check: "All entities have ≥3 attributes",
149
+ status: validateAllEntities(e => e.attributes.length >= 3) ? "PASS" : "FAIL",
150
+ blocking: true,
151
+ details: "Entities with <3 attributes are likely incomplete"
152
+ },
153
+
154
+ entityRelationships: {
155
+ check: "All entities have relationships defined (or explicitly marked as standalone)",
156
+ status: validateEntityRelationships() ? "PASS" : "FAIL",
157
+ blocking: false, // WARNING only
158
+ details: "Standalone entities should be rare in business modules"
159
+ },
160
+
161
+ // SECTION 2: BUSINESS RULES (BLOCKING)
162
+ businessRules: {
163
+ minimum: 4,
164
+ actual: analysis.businessRules.length,
165
+ status: actual >= minimum ? "PASS" : "FAIL",
166
+ blocking: true,
167
+ details: "Minimum 4 BRs (mix of VAL/CALC/WF/SEC/DATA)"
168
+ },
169
+
170
+ businessRuleCategories: {
171
+ check: "BRs cover ≥2 categories (VAL, CALC, WF, SEC, DATA)",
172
+ status: countUniqueCategories(analysis.businessRules) >= 2 ? "PASS" : "FAIL",
173
+ blocking: true,
174
+ details: "Single-category modules are likely incomplete"
175
+ },
176
+
177
+ businessRulePrefixes: {
178
+ check: "All BR IDs use module prefix (e.g., BR-VAL-{PREFIX}-NNN)",
179
+ status: validateBRPrefixes() ? "PASS" : "FAIL",
180
+ blocking: true,
181
+ details: "Missing prefixes cause ID collisions in multi-module apps"
182
+ },
183
+
184
+ // SECTION 3: USE CASES & REQUIREMENTS (BLOCKING)
185
+ useCases: {
186
+ minimum: 6,
187
+ actual: specification.useCases.length,
188
+ status: actual >= minimum ? "PASS" : "FAIL",
189
+ blocking: true,
190
+ details: "Minimum 6 UCs (CRUD + 2 business-specific)"
191
+ },
192
+
193
+ useCasePrefixes: {
194
+ check: "All UC IDs use module prefix (UC-{PREFIX}-NNN)",
195
+ status: validateUCPrefixes() ? "PASS" : "FAIL",
196
+ blocking: true,
197
+ details: "Missing prefixes cause ID collisions"
198
+ },
199
+
200
+ functionalRequirements: {
201
+ minimum: 4,
202
+ actual: specification.functionalRequirements.length,
203
+ status: actual >= minimum ? "PASS" : "FAIL",
204
+ blocking: true,
205
+ details: "FRs must cover key functionality"
206
+ },
207
+
208
+ ucFrLinkage: {
209
+ check: "Every UC has ≥1 linked FR",
210
+ status: validateUCtoFRLinkage() ? "PASS" : "FAIL",
211
+ blocking: true,
212
+ details: "Orphan UCs indicate incomplete requirements"
213
+ },
214
+
215
+ frBrLinkage: {
216
+ check: "Every FR has ≥1 linked BR",
217
+ status: validateFRtoBRLinkage() ? "PASS" : "FAIL",
218
+ blocking: false, // WARNING only
219
+ details: "FRs without BRs may lack validation/calculation logic"
220
+ },
221
+
222
+ // SECTION 4: PERMISSIONS (BLOCKING)
223
+ permissions: {
224
+ minimum: 5,
225
+ actual: specification.permissionMatrix.permissions.length,
226
+ status: actual >= minimum ? "PASS" : "FAIL",
227
+ blocking: true,
228
+ details: "Minimum 5 permissions (CRUD + 1 business action)"
229
+ },
230
+
231
+ permissionFormat: {
232
+ check: "All permissions use full format: business.{app}.{module}.{resource}.{action}",
233
+ status: validatePermissionFormat() ? "PASS" : "FAIL",
234
+ blocking: true,
235
+ details: "Wrong format breaks RBAC system"
236
+ },
237
+
238
+ rolePermissions: {
239
+ check: "All application roles have ≥1 permission assigned",
240
+ status: validateRoleAssignments() ? "PASS" : "FAIL",
241
+ blocking: true,
242
+ details: "Roles without permissions are useless"
243
+ },
244
+
245
+ // SECTION 5: UI & NAVIGATION (BLOCKING)
246
+ sections: {
247
+ minimum: 2,
248
+ actual: specification.sections.length,
249
+ status: actual >= minimum ? "PASS" : "FAIL",
250
+ blocking: true,
251
+ details: "Modules need ≥2 sections (list + form minimum)"
252
+ },
253
+
254
+ wireframes: {
255
+ minimum: specification.sections.length, // 1 wireframe PER section
256
+ actual: specification.uiWireframes.length,
257
+ status: actual >= minimum ? "PASS" : "FAIL",
258
+ blocking: true,
259
+ details: "EVERY section MUST have a wireframe (ASCII/SVG)"
260
+ },
261
+
262
+ navigation: {
263
+ check: "Module has ≥1 navigation entry",
264
+ status: specification.navigation.entries.length >= 1 ? "PASS" : "FAIL",
265
+ blocking: true,
266
+ details: "Module must be accessible in menu"
267
+ },
268
+
269
+ // SECTION 6: I18N & MESSAGES (BLOCKING)
270
+ i18nKeys: {
271
+ minimum: 42, // Realistic minimum for a module
272
+ actual: specification.i18nKeys.length,
273
+ status: actual >= minimum ? "PASS" : "FAIL",
274
+ blocking: true,
275
+ details: "Keys needed: entities (×2), fields, messages, validation, navigation"
276
+ },
277
+
278
+ i18nLanguages: {
279
+ check: "All i18n keys have 4 languages (fr, en, nl, de)",
280
+ status: validateI18nCompleteness() ? "PASS" : "FAIL",
281
+ blocking: true,
282
+ details: "Missing translations break multi-language support"
283
+ },
284
+
285
+ messages: {
286
+ minimum: 4,
287
+ actual: specification.messages.length,
288
+ status: actual >= minimum ? "PASS" : "FAIL",
289
+ blocking: true,
290
+ details: "Minimum: 1 success, 1 error, 1 warning, 1 info"
291
+ },
292
+
293
+ // SECTION 7: SEED DATA (BLOCKING)
294
+ seedDataCore: {
295
+ check: "All 5 CORE seed data sections present",
296
+ requiredSections: [
297
+ "navigationModules",
298
+ "navigationTranslations",
299
+ "permissions",
300
+ "rolePermissions",
301
+ "permissionConstants"
302
+ ],
303
+ status: validateSeedDataCore() ? "PASS" : "FAIL",
304
+ blocking: true,
305
+ details: "Missing CORE seed data breaks module deployment"
306
+ },
307
+
308
+ seedDataBusiness: {
309
+ check: "Business seed data template defined (even if empty)",
310
+ status: specification.seedDataBusiness !== undefined ? "PASS" : "FAIL",
311
+ blocking: false, // WARNING only
312
+ details: "Business seed data helps with testing"
313
+ },
314
+
315
+ // SECTION 8: API ENDPOINTS (BLOCKING)
316
+ apiEndpoints: {
317
+ minimum: 5,
318
+ actual: specification.apiEndpoints.length,
319
+ status: actual >= minimum ? "PASS" : "FAIL",
320
+ blocking: true,
321
+ details: "Minimum 5 endpoints (CRUD + 1 business action)"
322
+ },
323
+
324
+ apiPermissions: {
325
+ check: "Every API endpoint has permission defined",
326
+ status: validateAPIPermissions() ? "PASS" : "FAIL",
327
+ blocking: true,
328
+ details: "Endpoints without permissions are security holes"
329
+ },
330
+
331
+ // SECTION 9: VALIDATIONS (BLOCKING)
332
+ validations: {
333
+ minimum: 1,
334
+ actual: specification.validations.length,
335
+ status: actual >= minimum ? "PASS" : "FAIL",
336
+ blocking: true,
337
+ details: "Modules need field validation rules"
338
+ },
339
+
340
+ // SECTION 10: GHERKIN SCENARIOS (WARNING)
341
+ gherkinScenarios: {
342
+ minimum: 2,
343
+ actual: specification.gherkinScenarios.scenarios.length,
344
+ status: actual >= minimum ? "PASS" : "FAIL",
345
+ blocking: false, // WARNING only
346
+ details: "Gherkin scenarios enable automated testing"
347
+ }
348
+ };
349
+
350
+ // BLOCKING CHECK: Count failures in BLOCKING items
351
+ const blockingFailures = Object.entries(checklist)
352
+ .filter(([key, check]) => check.blocking === true && check.status === "FAIL")
353
+ .map(([key, check]) => ({ section: key, ...check }));
354
+
355
+ IF blockingFailures.length > 0:
356
+ **BLOCKING ERROR:** Module specification incomplete
357
+
358
+ Display table:
359
+ | Section | Required | Actual | Status | Details |
360
+ |---------|----------|--------|--------|---------|
361
+ {for each blocking failure}
362
+
363
+ ACTIONS REQUIRED:
364
+ 1. Fix ALL blocking failures listed above
365
+ 2. Re-run step-03d validation
366
+ 3. DO NOT mark module as "specified" until ALL blocking checks pass
367
+
368
+ STOP - DO NOT PROCEED TO UPDATE STATUS
369
+ ELSE:
370
+ All blocking checks passed ✓
371
+ {count} warnings (non-blocking)
372
+ Proceed to mark module as "specified"
373
+ ```
374
+
375
+ **Display Checklist Summary:**
376
+
377
+ ```
378
+ ═══════════════════════════════════════════════════════════════
379
+ MODULE SPECIFICATION CHECKLIST - {currentModule}
380
+ ═══════════════════════════════════════════════════════════════
381
+
382
+ | Category | Checks | Passed | Failed | Warnings |
383
+ |----------|--------|--------|--------|----------|
384
+ | Data Model | 3 | {n} | {n} | {n} |
385
+ | Business Rules | 3 | {n} | {n} | {n} |
386
+ | Use Cases & FRs | 4 | {n} | {n} | {n} |
387
+ | Permissions | 3 | {n} | {n} | {n} |
388
+ | UI & Navigation | 3 | {n} | {n} | {n} |
389
+ | I18N & Messages | 3 | {n} | {n} | {n} |
390
+ | Seed Data | 2 | {n} | {n} | {n} |
391
+ | API Endpoints | 2 | {n} | {n} | {n} |
392
+ | Validations | 1 | {n} | {n} | {n} |
393
+ | Gherkin | 1 | {n} | {n} | {n} |
394
+
395
+ TOTAL: {total_checks} checks | {passed} ✓ | {failed} ✗ | {warnings} ⚠
396
+
397
+ STATUS: {failed === 0 ? "READY FOR SPECIFIED" : "INCOMPLETE - FIX REQUIRED"}
398
+ ═══════════════════════════════════════════════════════════════
399
+ ```
400
+
401
+ **IF ALL BLOCKING CHECKS PASS → Proceed to update module status to "specified"**
402
+
129
403
  ---
130
404
 
131
405
  ### 10. Module Summary with Roles & Permissions
@@ -228,56 +502,11 @@ ba-writer.updateModuleStatus({feature_id}, {currentModule.code}, "specified")
228
502
  ### 11-bis. Deploy Incremental Interactive HTML (MANDATORY)
229
503
 
230
504
  > **After each module is specified, deploy/update the interactive HTML document with all available data.**
231
- > This allows the client to review completed modules while the next module is being specified.
232
- > The HTML is incrementally enriched: after module 1, only module 1 specs appear; after module 2, both appear; etc.
233
-
234
- **Source:** `html/ba-interactive.html` (relative to skill root = `~/.claude/skills/business-analyse/html/`)
505
+ > The client can review completed modules while the next module is being specified.
235
506
 
236
- **Destination:** `docs/business/{app}/business-analyse/v{version}/ba-interactive.html`
237
-
238
- **Steps:**
239
-
240
- 1. **Read sources:**
241
- - Read the HTML template from skill directory
242
- - Read the master feature.json (application level — now updated with current module status)
243
- - Read EACH completed module's feature.json (including the one just specified)
244
-
245
- 2. **Build FEATURE_DATA object:**
246
-
247
- > **Use the EXACT SAME mapping defined in step-05b-deploy.md and references/html-data-mapping.md.**
248
- > The mapping is identical — the only difference is that `moduleSpecs` only includes completed modules.
249
- > Modules not yet specified will NOT appear in `moduleSpecs` (their entry in `modules[]` will show `status: "pending"`).
250
-
251
- Follow step-05 section 9d "Step 2: Build FEATURE_DATA object" for the complete mapping pseudocode:
252
- - `metadata`, `cadrage`, `modules[]`, `dependencies[]` → from master feature.json
253
- - `moduleSpecs[moduleCode]` → only for modules with status "specified" (completed so far)
254
- - `consolidation` → empty `{ interactions: [], e2eFlows: [] }` (not yet consolidated)
255
- - `handoff` → empty `{}` (not yet handed off)
256
-
257
- 3. **Replace placeholders in template:**
258
- - Serialize the FEATURE_DATA object as JSON (2-space indentation)
259
- - Replace `{{FEATURE_DATA}}` with the serialized JSON
260
- - Replace `{{APPLICATION_NAME}}` → `{application_name}`
261
- - Replace `{{APPLICATION_ID}}` → `{feature_id}`
262
- - Replace `{{VERSION}}` → `{version}`
263
- - Replace `{{CREATED_AT}}` → `{ISO timestamp}`
264
-
265
- 4. **Write and confirm:**
266
-
267
- ```
268
- ✓ Interactive HTML updated (incremental):
269
- Path: docs/business/{app}/business-analyse/v{version}/ba-interactive.html
270
- Modules included: {completedModules.length}/{totalModules} specified
271
- - {completedModule1}: {uc_count} UCs, {br_count} BRs, {entity_count} entities
272
- - {completedModule2}: ...
273
- Remaining: {pendingModules.join(', ')} (will be added after specification)
274
- → Client can open in browser to review completed modules now.
275
- ```
507
+ See [references/validate-incremental-html.md](../references/validate-incremental-html.md) for the complete deployment process (read sources, build FEATURE_DATA, replace placeholders, write HTML).
276
508
 
277
- > **WHY incremental?** The client doesn't have to wait until handoff to start reviewing.
278
- > While module 2 is being specified, the client can already give feedback on module 1.
279
- > Each incremental deployment OVERWRITES the previous HTML (latest state always).
280
- > The FINAL deployment at step-05 (handoff) will include consolidation and handoff data.
509
+ Uses the **same mapping** as step-05b-deploy.md only difference is `moduleSpecs` only includes completed modules.
281
510
 
282
511
  ---
283
512
 
@@ -113,6 +113,172 @@ Identify shared lookup/reference tables:
113
113
  }
114
114
  ```
115
115
 
116
+ **2e. Cross-Module Reference Validation (ENHANCED)**
117
+
118
+ > **CRITICAL:** Verify ALL cross-module entity references are resolvable.
119
+ > **Purpose:** Prevent broken FK references and runtime errors in ralph-loop.
120
+
121
+ **Process:**
122
+
123
+ 1. **Build Entity Registry:**
124
+ ```javascript
125
+ const entityRegistry = {};
126
+ for (const module of completedModules) {
127
+ entityRegistry[module.code] = {
128
+ entities: module.analysis.entities.map(e => ({
129
+ name: e.name,
130
+ attributes: e.attributes.map(a => a.name),
131
+ pk: e.attributes.find(a => a.name === "Id" || a.unique)?.name || "Id"
132
+ }))
133
+ };
134
+ }
135
+ ```
136
+
137
+ 2. **Extract Cross-Module References:**
138
+
139
+ For EACH module, scan all entity relationships:
140
+ ```javascript
141
+ for (const entity of module.analysis.entities) {
142
+ for (const rel of entity.relationships) {
143
+ // Detect cross-module reference
144
+ if (rel.target.includes(".")) {
145
+ // Format: "ModuleName.EntityName.FieldName" or "ModuleName.EntityName"
146
+ const [targetModule, targetEntity, targetField] = rel.target.split(".");
147
+
148
+ // Validate: target module exists
149
+ if (!entityRegistry[targetModule]) {
150
+ BLOCKING_ERROR(`Module ${module.code}: Entity ${entity.name} references non-existent module "${targetModule}"`);
151
+ }
152
+
153
+ // Validate: target entity exists in target module
154
+ const targetModuleEntities = entityRegistry[targetModule].entities;
155
+ const resolvedEntity = targetModuleEntities.find(e => e.name === targetEntity);
156
+ if (!resolvedEntity) {
157
+ BLOCKING_ERROR(`Module ${module.code}: Entity ${entity.name} references non-existent entity "${targetEntity}" in module "${targetModule}"`);
158
+ }
159
+
160
+ // Validate: target field exists (if specified)
161
+ if (targetField && !resolvedEntity.attributes.includes(targetField)) {
162
+ BLOCKING_ERROR(`Module ${module.code}: Entity ${entity.name} references non-existent field "${targetField}" on "${targetModule}.${targetEntity}"`);
163
+ }
164
+
165
+ // Record valid reference
166
+ crossModuleReferences.push({
167
+ sourceModule: module.code,
168
+ sourceEntity: entity.name,
169
+ sourceField: rel.sourceField || `${targetEntity}Id`,
170
+ targetModule,
171
+ targetEntity,
172
+ targetField: targetField || resolvedEntity.pk,
173
+ type: rel.type,
174
+ cardinality: rel.cardinality || "N:1",
175
+ status: "RESOLVED"
176
+ });
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ 3. **Validate Dependency Graph Alignment:**
183
+
184
+ ```javascript
185
+ // For each cross-module reference, verify dependency edge exists
186
+ for (const ref of crossModuleReferences) {
187
+ const dependencyExists = dependencyGraph.edges.find(edge =>
188
+ edge.from === ref.sourceModule && edge.to === ref.targetModule
189
+ );
190
+
191
+ if (!dependencyExists) {
192
+ WARNING(`Dependency missing: ${ref.sourceModule} → ${ref.targetModule}`);
193
+ WARNING(`Reason: ${ref.sourceEntity}.${ref.sourceField} references ${ref.targetModule}.${ref.targetEntity}`);
194
+
195
+ // Auto-fix: add missing dependency edge
196
+ dependencyGraph.edges.push({
197
+ from: ref.sourceModule,
198
+ to: ref.targetModule,
199
+ type: "FK",
200
+ reason: `${ref.sourceEntity}.${ref.sourceField} → ${ref.targetEntity}`
201
+ });
202
+
203
+ // Recalculate topological order
204
+ topologicalOrder = calculateTopologicalOrder(dependencyGraph);
205
+ }
206
+ }
207
+ ```
208
+
209
+ 4. **Display Cross-Module Reference Map:**
210
+
211
+ ```
212
+ ═══════════════════════════════════════════════════════════════
213
+ CROSS-MODULE REFERENCES VALIDATED
214
+ ═══════════════════════════════════════════════════════════════
215
+
216
+ | Source Module | Source Entity | Target | Type | Status |
217
+ |---------------|---------------|--------|------|--------|
218
+ | TimeTracking | TimeEntry | Projects.Project.Id | FK (N:1) | ✓ RESOLVED |
219
+ | LeaveManagement | LeaveRequest | Projects.Employee.Id | FK (N:1) | ✓ RESOLVED |
220
+ | AbsenceManagement | Absence | Projects.Employee.Id | FK (N:1) | ✓ RESOLVED |
221
+ | Reporting | ProjectReport | Projects.Project.Id | FK (N:1) | ✓ RESOLVED |
222
+
223
+ Total: {count} cross-module references
224
+ All references RESOLVED ✓
225
+ ═══════════════════════════════════════════════════════════════
226
+ ```
227
+
228
+ 5. **Detect Circular Dependencies:**
229
+
230
+ ```javascript
231
+ const cycles = detectCycles(dependencyGraph);
232
+
233
+ if (cycles.length > 0) {
234
+ BLOCKING_ERROR("Circular dependencies detected:");
235
+ for (const cycle of cycles) {
236
+ ERROR(` ${cycle.join(" → ")}`);
237
+ }
238
+
239
+ ACTIONS:
240
+ 1. Review module dependencies
241
+ 2. Break cycles by:
242
+ - Moving shared entities to a separate "Core" module
243
+ - Using event-driven communication instead of FK
244
+ - Removing unnecessary dependencies
245
+ 3. Re-run step-02 decomposition with fixed dependencies
246
+
247
+ STOP - DO NOT PROCEED TO HANDOFF
248
+ }
249
+ ```
250
+
251
+ 6. **Store Cross-Module Interaction Data:**
252
+
253
+ ```javascript
254
+ ba-writer.enrichSection({
255
+ featureId: {feature_id},
256
+ section: "consolidation",
257
+ data: {
258
+ crossModuleInteractions: crossModuleReferences.map(ref => ({
259
+ fromModule: ref.sourceModule,
260
+ toModule: ref.targetModule,
261
+ interactionType: "FK_REFERENCE",
262
+ description: `${ref.sourceEntity}.${ref.sourceField} → ${ref.targetModule}.${ref.targetEntity}.${ref.targetField}`,
263
+ entities: [ref.sourceEntity, ref.targetEntity],
264
+ cardinality: ref.cardinality,
265
+ status: ref.status
266
+ }))
267
+ }
268
+ });
269
+ ```
270
+
271
+ **Success Criteria:**
272
+ - ✓ All cross-module references resolved
273
+ - ✓ Dependency graph aligned with actual references
274
+ - ✓ No circular dependencies
275
+ - ✓ Topological order valid
276
+
277
+ **Failure Handling:**
278
+ - BLOCKING errors for unresolved references
279
+ - Auto-fix missing dependency edges (with warning)
280
+ - Manual intervention required for circular dependencies
281
+
116
282
  ### 3. Permission Coherence
117
283
 
118
284
  > **All modules MUST use the same application-level roles.**
@@ -212,112 +378,17 @@ Store results in consolidation.semanticChecks[]:
212
378
 
213
379
  ### 4-bis. Structural Schema Conformity Check (MANDATORY)
214
380
 
215
- > **Post-generation validation.** After semantic checks, verify that ALL module feature.json files conform to the JSON schema structure. This catches field name mismatches, missing sections, and wrong nesting.
216
-
217
- For EACH module feature.json, run these structural checks:
218
-
219
- **A. Required Sections Presence**
220
-
221
- | Section | Required | Check |
222
- |---------|----------|-------|
223
- | `metadata` | YES | Must have: app, module, language, featureDescription, featureType |
224
- | `discovery` | YES | Must exist (even if minimal) |
225
- | `analysis.entities[]` | YES | Must have ≥1 entity |
226
- | `analysis.businessRules[]` | YES | Must have ≥1 BR |
227
- | `analysis.objectives[]` | YES | Must have ≥1 objective |
228
- | `analysis.processFlow` | YES | Must have entryPoints, mainFlow, decisionPoints |
229
- | `analysis.dataLifecycle` | YES | Must have retention, archival, deletion, gdprRelevant |
230
- | `specification.useCases[]` | YES | Must have ≥1 UC |
231
- | `specification.functionalRequirements[]` | YES | Must have ≥1 FR |
232
- | `specification.permissionMatrix` | YES | Must be `{permissions[], roleAssignments[]}` (NOT flat array) |
233
- | `specification.sections[]` | YES | Must have ≥1 section with resources |
234
- | `specification.uiWireframes[]` | YES | Must have ≥1 wireframe with `layout` object |
235
- | `specification.lifeCycles[]` | IF entities have status | States must be objects (NOT strings) |
236
- | `specification.seedDataCore` | YES | Must have 5 arrays: navigationModules, navigationTranslations, permissions, rolePermissions, permissionConstants |
237
- | `specification.gherkinScenarios` | YES | Must be `{feature, scenarios[]}` (NOT flat array) |
238
- | `specification.navigation` | YES | Must have entries[] |
239
- | `specification.i18nKeys[]` | YES | Must have ≥1 key with fr, en, nl, de |
240
- | `validation` | YES | Must have completenessChecks, consistencyChecks, semanticChecks, decision |
241
- | `handoff` | Written by step-05 | Checked post-handoff |
242
-
243
- **B. Field Name Conformity**
244
-
245
- For each section, verify NO FORBIDDEN field names are used:
246
-
247
- | Section | FORBIDDEN fields | Correct fields |
248
- |---------|-----------------|----------------|
249
- | `entities[].attributes[]` | `type`, `values`, `rules` | `description`, `unique`, `validation` |
250
- | `businessRules[]` | `rule`, `condition` (singular), `action` | `name`, `statement`, `conditions[]` |
251
- | `useCases[]` | `actor`, `linkedBRs`, `linkedFRs` | `primaryActor`, `linkedRules` |
252
- | `functionalRequirements[]` | `name`, `description`, `linkedUCs`, `linkedBRs` | `statement`, `linkedUseCases`, `linkedRules` |
253
- | `permissionMatrix` | flat array with `resource`/`roles` | `{permissions[], roleAssignments[]}` |
254
- | `lifeCycles[].states[]` | string values like `"Active"` | objects with `{id, displayName, color, isTerminal}` |
255
- | `seedDataCore` | flat object, string values | 5 typed arrays |
256
- | `gherkinScenarios` | flat scenario array | `{feature, scenarios[]}` nested |
257
-
258
- **C. ID Pattern Conformity**
259
-
260
- | ID Type | Pattern | Example |
261
- |---------|---------|---------|
262
- | BR | `BR-(VAL\|CALC\|WF\|SEC\|DATA)-{PREFIX}-\d{3}` | BR-VAL-RM-001 |
263
- | UC | `UC-{PREFIX}-\d{3}` | UC-RM-001 |
264
- | FR | `FR-{PREFIX}-\d{3}` | FR-RM-001 |
265
- | Permissions | `business.{app}.{module}.{resource}.{action}` | business.freebike.repairs.create |
266
-
267
- Verify all IDs use the correct module prefix (2-4 uppercase letters).
268
-
269
- **D. Cross-Module ID Uniqueness**
270
-
271
- Verify no ID collision across modules:
272
- ```
273
- SET all_ids = {}
274
- FOR each module:
275
- FOR each BR, UC, FR id:
276
- IF id IN all_ids → ERROR: "Duplicate {id} in {module1} and {module2}"
277
- ADD id to all_ids
278
- ```
279
-
280
- **E. Wireframe Layout Completeness**
281
-
282
- For each `uiWireframes[]`:
283
- ```
284
- IF missing componentMapping[] → ERROR
285
- IF missing layout object → ERROR
286
- IF missing layout.regions[] → ERROR
287
- FOR each region in layout.regions[]:
288
- IF missing position → ERROR
289
- IF missing components[] → ERROR
290
- ```
291
-
292
- **F. SeedDataCore Translation Coverage**
381
+ > **Post-generation validation.** After semantic checks, verify ALL module feature.json files conform to JSON schema.
293
382
 
294
- ```
295
- FOR each navigationModules[].code:
296
- FOR each language in [fr, en, nl, de]:
297
- IF NOT EXISTS navigationTranslations[] with moduleCode AND language → ERROR
298
- ```
383
+ See [references/consolidation-structural-checks.md](../references/consolidation-structural-checks.md) for the full 6-category structural check:
384
+ - **A.** Required Sections Presence (18 sections)
385
+ - **B.** Field Name Conformity (forbidden vs correct fields)
386
+ - **C.** ID Pattern Conformity (BR, UC, FR, Permissions)
387
+ - **D.** Cross-Module ID Uniqueness
388
+ - **E.** Wireframe Layout Completeness
389
+ - **F.** SeedDataCore Translation Coverage
299
390
 
300
- **Result aggregation:**
301
- ```json
302
- {
303
- "structuralChecks": [
304
- { "check": "required-sections", "module": "...", "status": "PASS|ERROR", "details": "Missing: analysis.objectives" },
305
- { "check": "field-names", "module": "...", "status": "PASS|ERROR", "details": "businessRules[0] uses 'rule' instead of 'name'+'statement'" },
306
- { "check": "id-patterns", "module": "...", "status": "PASS|ERROR", "details": "BR-001 missing category segment" },
307
- { "check": "id-uniqueness", "module": "...", "status": "PASS|ERROR", "details": "UC-RM-003 duplicated in Vehicles and Repairs" },
308
- { "check": "wireframe-layout", "module": "...", "status": "PASS|ERROR", "details": "Wireframe repairs-list missing layout object" },
309
- { "check": "seeddata-translations", "module": "...", "status": "PASS|ERROR", "details": "Missing nl translation for NavigationModuleRepairs" }
310
- ]
311
- }
312
- ```
313
-
314
- **Blocking rule:**
315
- - 0 ERROR → PASS (merge structuralChecks into consolidation.semanticChecks[])
316
- - ≥1 ERROR → BLOCK. For each ERROR:
317
- 1. Attempt AUTO-FIX (rename fields, restructure)
318
- 2. Re-write the module feature.json with fixes
319
- 3. Re-check
320
- 4. If still ERROR → ask user
391
+ **Blocking rule:** 0 ERROR → PASS. ≥1 ERROR → BLOCK (attempt auto-fix, re-write, re-check).
321
392
 
322
393
  ### 5. End-to-End Flows
323
394