@atlashub/smartstack-cli 3.9.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 (22) hide show
  1. package/package.json +1 -1
  2. package/templates/agents/ba-writer.md +178 -0
  3. package/templates/skills/application/references/application-roles-template.md +227 -0
  4. package/templates/skills/application/references/provider-template.md +30 -6
  5. package/templates/skills/application/steps/step-03-roles.md +45 -7
  6. package/templates/skills/application/steps/step-03b-provider.md +13 -6
  7. package/templates/skills/business-analyse/SKILL.md +56 -4
  8. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
  9. package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
  10. package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
  11. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
  12. package/templates/skills/business-analyse/steps/step-00-init.md +166 -0
  13. package/templates/skills/business-analyse/steps/step-03a-data.md +36 -0
  14. package/templates/skills/business-analyse/steps/step-03c-compile.md +71 -2
  15. package/templates/skills/business-analyse/steps/step-03d-validate.md +274 -0
  16. package/templates/skills/business-analyse/steps/step-04-consolidation.md +166 -0
  17. package/templates/skills/business-analyse/steps/step-05a-handoff.md +44 -0
  18. package/templates/skills/business-analyse/steps/step-05b-deploy.md +21 -2
  19. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +526 -0
  20. package/templates/skills/controller/steps/step-03-generate.md +184 -24
  21. package/templates/skills/controller/templates.md +11 -2
  22. package/templates/skills/ralph-loop/references/core-seed-data.md +173 -21
@@ -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.**
@@ -57,6 +57,50 @@ Include:
57
57
 
58
58
  ---
59
59
 
60
+ ### 1b. Cache Warming for Handoff & Deploy
61
+
62
+ > **Performance Optimization:** Pre-load handoff templates and references to reduce redundant reads during handoff generation.
63
+ > This step runs ONCE at start of step-05a, files retained through step-05b.
64
+
65
+ ```
66
+ // Pre-load handoff & deploy references (Bucket 5)
67
+ const handoffRefs = [
68
+ "~/.claude/skills/business-analyse/references/handoff-file-templates.md",
69
+ "~/.claude/skills/business-analyse/references/handoff-mappings.md",
70
+ "~/.claude/skills/business-analyse/references/deploy-data-build.md",
71
+ "~/.claude/skills/business-analyse/references/deploy-modes.md",
72
+ "~/.claude/skills/business-analyse/references/html-data-mapping.md"
73
+ ];
74
+
75
+ for (const file of handoffRefs) {
76
+ read(file); // Pre-load into cache
77
+ }
78
+
79
+ // Pre-load HTML template (large file, loaded once)
80
+ read("~/.claude/skills/business-analyse/html/ba-interactive.html");
81
+
82
+ Display: "✓ Cache warmed: handoff templates (139KB, 6 files)"
83
+ Display: " Expected token savings: ~3,000 tokens (handoff refs read 2× → 1×)"
84
+ Display: " Retention: through step-05b (deploy)"
85
+ ```
86
+
87
+ **Rationale:**
88
+
89
+ - Handoff templates are read 2× during step-05a + step-05b (without caching)
90
+ - HTML template (85KB) is read once but benefits from explicit pre-load (faster deploy)
91
+ - Token savings: ~3,000 tokens for handoff process
92
+ - Cache retained until session end (needed for both handoff and deploy steps)
93
+
94
+ **Why NOT loaded at step-00:**
95
+ - Large files (139KB total), especially ba-interactive.html (85KB)
96
+ - Only used at END of workflow (steps 05a, 05b)
97
+ - Low re-use (1-2× each)
98
+ - Loading at step-05a is more efficient (just-in-time caching)
99
+
100
+ See [references/cache-warming-strategy.md](../references/cache-warming-strategy.md) § Bucket 5 for details.
101
+
102
+ ---
103
+
60
104
  ### 2. Implementation Strategy Choice (Multi-Module)
61
105
 
62
106
  **IF** more than 1 module defined in feature.json:
@@ -2,7 +2,7 @@
2
2
  name: step-05b-deploy
3
3
  description: Generate prd.json, deploy artifacts, interactive HTML
4
4
  model: sonnet
5
- next_step: null
5
+ next_step: steps/step-05c-ralph-readiness.md
6
6
  ---
7
7
 
8
8
  > **Context files:** _shared.md
@@ -339,7 +339,12 @@ Effort: {total_days} days ({total_hours} hours)
339
339
  1. Ouvrir ba-interactive.html dans le navigateur
340
340
  2. Partager avec les stakeholders pour validation
341
341
  3. Si retours --> relancer /business-analyse pour une nouvelle itération
342
- 4. Une fois validé, lancer le développement:
342
+ 4. Validation de la compatibilité ralph-loop (recommandé):
343
+
344
+ Continuez à step-05c-ralph-readiness.md pour valider
345
+ la complétude et l'intégrité avant développement
346
+
347
+ 5. Une fois validé, lancer le développement:
343
348
 
344
349
  /ralph-loop -r
345
350
 
@@ -348,6 +353,20 @@ Effort: {total_days} days ({total_hours} hours)
348
353
 
349
354
  ---
350
355
 
356
+ ## NEXT STEP
357
+
358
+ **RECOMMENDED:** Load `steps/step-05c-ralph-readiness.md` to run validation gate before /ralph-loop.
359
+
360
+ This validation ensures:
361
+ - All module handoffs are complete
362
+ - PRD files are structurally valid
363
+ - Cross-module references are resolvable
364
+ - No blocking issues before development
365
+
366
+ User can skip validation and proceed directly to /ralph-loop, but validation is strongly recommended to catch issues early.
367
+
368
+ ---
369
+
351
370
  ## MODE SUPPORT & TROUBLESHOOTING
352
371
 
353
372
  See [references/deploy-modes.md](../references/deploy-modes.md) for: