@atlashub/smartstack-cli 4.73.0 → 4.75.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 (95) hide show
  1. package/dist/index.js +111 -36
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +14 -3
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/agents/ba-reader.md +17 -15
  7. package/templates/agents/ba-writer.md +49 -51
  8. package/templates/project/Dockerfile.backend.template +2 -2
  9. package/templates/project/docker-compose.yml.template +20 -0
  10. package/templates/skills/apex/_shared.md +1 -1
  11. package/templates/skills/apex/references/checks/backend-checks.sh +21 -7
  12. package/templates/skills/apex/references/checks/infrastructure-checks.sh +47 -10
  13. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +3 -0
  14. package/templates/skills/apex/references/post-checks.md +5 -2
  15. package/templates/skills/apex/references/smartstack-frontend.md +53 -7
  16. package/templates/skills/apex/steps/step-00-init.md +74 -0
  17. package/templates/skills/apex/steps/step-03-execute.md +16 -4
  18. package/templates/skills/apex/steps/step-03b-layer1-seed.md +39 -6
  19. package/templates/skills/apex/steps/step-03c-layer2-backend.md +50 -5
  20. package/templates/skills/apex/steps/step-03d-layer3-frontend.md +102 -2
  21. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +3 -0
  22. package/templates/skills/business-analyse/SKILL.md +14 -0
  23. package/templates/skills/business-analyse/_shared.md +27 -0
  24. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +34 -26
  25. package/templates/skills/business-analyse/questionnaire/01-context.md +13 -9
  26. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +20 -27
  27. package/templates/skills/business-analyse/questionnaire.md +86 -9
  28. package/templates/skills/business-analyse/references/03-json-schemas.md +213 -0
  29. package/templates/skills/business-analyse/references/03-post-check-validation.md +144 -0
  30. package/templates/skills/business-analyse/references/03-smartstack-entity-guards.md +32 -0
  31. package/templates/skills/business-analyse/references/04-cross-module-validation.md +95 -0
  32. package/templates/skills/business-analyse/references/04-file-allocation.md +162 -0
  33. package/templates/skills/business-analyse/references/04-naming-audit-checks.md +174 -0
  34. package/templates/skills/business-analyse/references/04-semantic-validation-matrix.md +118 -0
  35. package/templates/skills/business-analyse/references/domain-research-playbook.md +234 -0
  36. package/templates/skills/business-analyse/references/entity-sourcing-presentation.md +166 -0
  37. package/templates/skills/business-analyse/references/init-resume-logic.md +70 -0
  38. package/templates/skills/business-analyse/references/module-completeness-challenge.md +174 -0
  39. package/templates/skills/business-analyse/references/multi-app-detection.md +149 -0
  40. package/templates/skills/business-analyse/references/portal-classification.md +52 -0
  41. package/templates/skills/business-analyse/references/validation-checklist.md +30 -1
  42. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +37 -4
  43. package/templates/skills/business-analyse/steps/step-00-init.md +22 -190
  44. package/templates/skills/business-analyse/steps/step-01-cadrage.md +365 -269
  45. package/templates/skills/business-analyse/steps/step-02-structure.md +98 -20
  46. package/templates/skills/business-analyse/steps/step-03-specify.md +652 -229
  47. package/templates/skills/business-analyse/steps/step-04-consolidate.md +308 -287
  48. package/templates/skills/business-analyse-design/SKILL.md +10 -0
  49. package/templates/skills/business-analyse-design/references/screens-post-check.md +221 -0
  50. package/templates/skills/business-analyse-design/references/screens-type-mapping.md +138 -0
  51. package/templates/skills/business-analyse-design/references/smartcomponents-templates.md +225 -0
  52. package/templates/skills/{business-analyse → business-analyse-design}/references/spec-auto-inference.md +117 -117
  53. package/templates/skills/business-analyse-design/steps/step-01-screens.md +36 -162
  54. package/templates/skills/business-analyse-design/steps/step-02-wireframes.md +8 -7
  55. package/templates/skills/business-analyse-design/steps/step-03-navigation.md +89 -42
  56. package/templates/skills/business-analyse-develop/references/compact-loop.md +9 -0
  57. package/templates/skills/business-analyse-develop/references/handoff-quality-gate.md +132 -0
  58. package/templates/skills/business-analyse-develop/references/prd-v3-transformation.md +326 -0
  59. package/templates/skills/business-analyse-develop/references/report-reconciliation.md +140 -0
  60. package/templates/skills/business-analyse-develop/references/report-template.md +142 -0
  61. package/templates/skills/business-analyse-develop/steps/step-01-task.md +5 -177
  62. package/templates/skills/business-analyse-develop/steps/step-02-execute.md +17 -4
  63. package/templates/skills/business-analyse-develop/steps/step-03-commit.md +6 -2
  64. package/templates/skills/business-analyse-develop/steps/step-04-check.md +6 -0
  65. package/templates/skills/business-analyse-develop/steps/step-05-report.md +3 -269
  66. package/templates/skills/business-analyse-handoff/SKILL.md +10 -0
  67. package/templates/skills/business-analyse-handoff/references/agent-handoff-transform-prompt.md +208 -0
  68. package/templates/skills/business-analyse-handoff/references/context-isolation-pattern.md +47 -0
  69. package/templates/skills/business-analyse-handoff/references/handoff-file-inventory.md +49 -0
  70. package/templates/skills/business-analyse-handoff/references/handoff-global-validation.md +142 -0
  71. package/templates/skills/business-analyse-handoff/references/prd-validation-checks.md +125 -0
  72. package/templates/skills/business-analyse-handoff/references/project-index-update.md +98 -0
  73. package/templates/skills/business-analyse-handoff/steps/step-01-transform.md +9 -160
  74. package/templates/skills/business-analyse-handoff/steps/step-02-export.md +10 -99
  75. package/templates/skills/business-analyse-html/SKILL.md +10 -0
  76. package/templates/skills/business-analyse-html/html/ba-interactive.html +306 -81
  77. package/templates/skills/business-analyse-html/html/src/scripts/01-data-init.js +15 -2
  78. package/templates/skills/business-analyse-html/html/src/scripts/02-navigation.js +6 -46
  79. package/templates/skills/business-analyse-html/html/src/scripts/06-render-mockups.js +88 -33
  80. package/templates/skills/business-analyse-html/html/src/scripts/12-render-diagrams.js +116 -0
  81. package/templates/skills/business-analyse-html/html/src/styles/10-diagrams.css +73 -0
  82. package/templates/skills/business-analyse-html/html/src/template.html +2 -0
  83. package/templates/skills/business-analyse-html/references/02-embedded-artifacts-building.md +144 -0
  84. package/templates/skills/business-analyse-html/references/02-feature-data-building.md +141 -0
  85. package/templates/skills/business-analyse-html/references/02-mapping-tables.md +442 -0
  86. package/templates/skills/business-analyse-html/references/02-normalization-helpers.md +139 -0
  87. package/templates/skills/business-analyse-html/references/02-screen-format-detection.md +283 -0
  88. package/templates/skills/business-analyse-html/references/02-self-check-validation.md +199 -0
  89. package/templates/skills/business-analyse-html/references/data-build.md +22 -1
  90. package/templates/skills/business-analyse-html/references/data-mapping.md +40 -5
  91. package/templates/skills/business-analyse-html/steps/step-02-build-data.md +12 -555
  92. package/templates/skills/business-analyse-review/SKILL.md +10 -0
  93. package/templates/skills/business-analyse-status/SKILL.md +8 -0
  94. package/templates/skills/dev-start/SKILL.md +143 -307
  95. package/templates/skills/efcore/SKILL.md +13 -0
@@ -36,19 +36,112 @@ function resolveModuleDir(appCode, moduleCode) {
36
36
  - Step 02 (structure) completed
37
37
  - Applications, modules, sections, dependencies identified
38
38
 
39
+ ## Scope Verification (BLOCKING — before any module processing)
40
+
41
+ Re-read `.business-analyse/config.json` and verify scope has not drifted:
42
+
43
+ ```javascript
44
+ const config = readJSON('.business-analyse/config.json').currentFeature;
45
+ const expectedApps = config.candidateApplications?.length || 1;
46
+ const confirmedModules = /* read from step-02 output: application index.json modules[] */;
47
+
48
+ // BLOCKING if scope drifted
49
+ if (config.workflowMode === "project") {
50
+ const appIndexFiles = GLOB(`${config.docsDir}/*/index.json`);
51
+ if (appIndexFiles.length > expectedApps) {
52
+ BLOCKING_ERROR(`Scope drift: expected ${expectedApps} applications but found ${appIndexFiles.length}`);
53
+ }
54
+ }
55
+
56
+ // Log confirmed scope for traceability
57
+ Display(`Scope locked: ${expectedApps} app(s), ${confirmedModules.length} module(s)`);
58
+ ```
59
+
60
+ ## INTERDICTIONS ABSOLUES (step-03)
61
+
62
+ +==============================================================================+
63
+ | INTERDICTIONS — Violation = analyse invalide |
64
+ +==============================================================================+
65
+ | |
66
+ | 1. JAMAIS lancer ba-writer pour un module AVANT validation client |
67
+ | des entites, regles, use cases ET permissions de ce module. |
68
+ | |
69
+ | 2. JAMAIS lancer des ba-writer en PARALLELE pour des modules differents. |
70
+ | Chaque module est traite SEQUENTIELLEMENT avec interaction client. |
71
+ | |
72
+ | 3. JAMAIS persister des entites, regles, volumetries, filtres |
73
+ | ou notifications sans VALIDATION CLIENT (confirmation du lot propose). |
74
+ | L'auto-deduction avec confirmation groupee est une validation valide. |
75
+ | |
76
+ | 4. JAMAIS sauter la VALIDATION CLIENT meme si le domaine semble "evident". |
77
+ | Auto-deduction + confirmation groupee = OK. Pas de confirmation = KO. |
78
+ | |
79
+ | 5. SUBAGENT DISCIPLINE : |
80
+ | - MAX 1 ba-writer par module (ecriture finale apres validation) |
81
+ | - Total ba-writer pour step-03 = nombre_de_modules (pas plus) |
82
+ | - INTERDICTION de spawner des ba-writer pour des modules NON encore |
83
+ | valides par le client |
84
+ | |
85
+ +==============================================================================+
86
+
39
87
  ## Sequential Execution
40
88
 
41
89
  **No team mode.** Each module receives 100% of LLM attention for maximum specification quality.
42
90
 
43
- Process modules in topological order (dependencies first):
91
+ Process **application by application**, modules in dependency order within each app:
92
+
44
93
  ```
45
- For module in topologicalSort(modules):
94
+ IF workflow_mode = "project" (multi-app):
95
+ // Group by application first, then topological sort within each app
96
+ // Cross-app dependencies: if Module A (App1) depends on Module B (App2),
97
+ // App2 must be processed before App1. Adjust application order accordingly.
98
+
99
+ applicationOrder = resolveApplicationOrder(modules, dependencies)
100
+ // e.g., [Rh, Crm, GestionDeProjet, Facturation, Portal]
101
+
102
+ For EACH application in applicationOrder:
103
+ Display application banner:
104
+ ═══════════════════════════════════════════════════════
105
+ APPLICATION {appIndex}/{appTotal} : {appName}
106
+ ═══════════════════════════════════════════════════════
107
+
108
+ appModules = modules.filter(m => m.applicationCode === app.code)
109
+ sortedAppModules = topologicalSort(appModules)
110
+
111
+ For EACH module in sortedAppModules:
112
+ specify(module) // Full cycle: A-bis → A-ter → B → C-pre → C → D → E → F → H
113
+
114
+ ELSE (single-app):
115
+ For module in topologicalSort(modules):
46
116
  specify(module)
47
117
  ```
48
118
 
49
- ## Per-Module Specification Loop
119
+ ## Per-Module Specification Loop — STRICT MODE
120
+
121
+ ### VALIDATION MINIMALE (per module — ba-009 fix)
122
+
123
+ Chaque module metier (hors Portal et config) requiert AU MINIMUM 2 AskUserQuestion :
124
+ 1. Entites (B-ter) : "Voici les entites pour {module}. Corrections ?"
125
+ 2. Regles + UCs + Permissions (C-bis + E-ter groupes) : "Voici les regles, UCs et permissions pour {module}. Corrections ?"
126
+
127
+ Exceptions :
128
+ - Modules **Portal** (read-only, 0 entites propres) : 1 validation groupee suffit.
129
+ - Modules **config/lookup** (< 2 entites) : 1 validation groupee suffit.
130
+
131
+ **INTERDICTION** de tout bundler en 1 seule question "Module complet, validez-vous ?" pour les modules metier.
132
+
133
+ For each module (in topological order), execute the complete cycle below.
134
+
135
+ ### Banniere de progression
136
+
137
+ Afficher au debut de chaque module :
138
+ ```
139
+ ═══════════════════════════════════════════════════════════════
140
+ MODULE {index}/{total} : {moduleName} ({applicationName})
141
+ ═══════════════════════════════════════════════════════════════
142
+ ```
50
143
 
51
- For each module, execute these sub-steps:
144
+ Execute these sub-steps for the current module:
52
145
 
53
146
  ### A. Context Loading
54
147
 
@@ -57,20 +150,26 @@ Load via ba-reader:
57
150
  - Application `cadrage.json` for stakeholder context (including `_preAnalysis.domain_research`)
58
151
  - Completed modules' summaries (compact, <100 lines each)
59
152
 
60
- ### A-bis. Entity Pattern Research (WebSearch per module)
153
+ ### A-bis. Module Domain Research (MANDATORY for modules with >= 2 entities)
61
154
 
62
- > **Before defining entities, validate design against industry best practices.**
155
+ > **MANDATORY BLOCKING** pour les modules metier (>= 2 entites).
156
+ > SKIP ONLY: Portal (0 entites propres), config (1 entite reference pure).
63
157
  > Uses domain_research from step-01 as baseline, then does targeted searches for this specific module.
158
+ > → **Load** `references/domain-research-playbook.md` Level 2 for per-module search strategy.
159
+ > Si WebSearch indisponible: s'appuyer sur `references/module-completeness-challenge.md` comme fallback.
64
160
 
65
161
  ```
66
- IF cadrage._preAnalysis.domain_research exists:
67
- Load as baseline (already researched in step-01)
162
+ IF module is Portal OR (module has exactly 1 config/lookup entity):
163
+ SKIP WebSearch (use step-01 domain_research only)
68
164
  ELSE:
69
- Run a quick WebSearch: "{module_domain} entity data model best practices"
165
+ SHOULD WebSearch: "{module_domain} entity data model best practices"
166
+ (e.g., "invoice entity design ERP", "timesheet data model best practices")
167
+
168
+ IF cadrage._preAnalysis.domain_research exists:
169
+ → Load as baseline complement
70
170
 
71
- FOR each main entity in this module (max 2-3 searches):
171
+ OPTIONAL: FOR complex entities (max 1-2 additional searches):
72
172
  Query: "{entity_name} entity design pattern {domain}"
73
- (e.g., "invoice entity design ERP", "timesheet data model best practices")
74
173
 
75
174
  EXTRACT (ULTRATHINK — internal only):
76
175
  - Standard attributes for this entity type
@@ -89,163 +188,304 @@ FOR each main entity in this module (max 2-3 searches):
89
188
  > If web research suggests putting firstName on Employee, the B-bis guard still blocks it
90
189
  > because SmartStack uses auth_Users for personal data.
91
190
 
191
+ **TRACK 2 — Section & View Completeness (MANDATORY):**
192
+
193
+ ```
194
+ WebSearch: "{module_domain} management system features views screens UX"
195
+ (e.g., "absence management system features views screens",
196
+ "invoice management application features views UX")
197
+
198
+ EXTRACT (ULTRATHINK — internal only):
199
+ - Standard views/sections for this module type
200
+ - Contextual filtered views (open requests, rejected, my X, history)
201
+ - Dashboard/reporting expectations
202
+ - Standard UX patterns (approval queue, batch actions, etc.)
203
+
204
+ CROSS-CHECK against anticipatedSections from step-02:
205
+ - List sections found in research but NOT in anticipatedSections
206
+ - For each missing section: prepare proposal for A-ter validation
207
+ ```
208
+
209
+ ### A-ter. Section Completeness Validation (MANDATORY)
210
+
211
+ > **Ensure this module has all the sections a user would expect.**
212
+ > Workflow modules without contextual views (open-requests, rejected, history) are incomplete.
213
+ > → **Load** `references/module-completeness-challenge.md` for section archetypes per pattern.
214
+
215
+ Compare module's `anticipatedSections` against:
216
+ 1. Domain research (Track 2 above)
217
+ 2. Module archetype from `module-completeness-challenge.md`
218
+ 3. Section archetypes per module pattern (workflow vs data-centric)
219
+
220
+ Display comparison table:
221
+ ```
222
+ ### Sections pour {moduleName}
223
+
224
+ | Section actuelle | Section standard (recherche/archetype) | Statut |
225
+ |-----------------|---------------------------------------|--------|
226
+ | list | list | ✓ OK |
227
+ | detail | detail | ✓ OK |
228
+ | approve | approve | ✓ OK |
229
+ | calendar | calendar | ✓ OK |
230
+ | — | open-requests | ✗ MANQUANTE — vue filtree des demandes en attente |
231
+ | — | rejected | ✗ MANQUANTE — vue filtree des demandes rejetees |
232
+ | — | history | ✗ MANQUANTE — historique des absences passees |
233
+ | — | my-balance | ✗ MANQUANTE — solde personnel de l'employe |
234
+ ```
235
+
236
+ AskUserQuestion (multiSelect: true):
237
+ ```
238
+ question: "{language == 'fr'
239
+ ? 'Voici les sections standards trouvees pour un module {moduleType}. Quelles sections manquantes souhaitez-vous ajouter ?'
240
+ : 'Here are the standard sections found for a {moduleType} module. Which missing sections would you like to add?'}"
241
+ header: "Sections {moduleName}"
242
+ multiSelect: true
243
+ options:
244
+ - For each missing section: label: "{section_code}", description: "{description}"
245
+ - label: "{language == 'fr' ? 'Aucune' : 'None'}"
246
+ description: "{language == 'fr' ? 'Garder les sections actuelles' : 'Keep current sections'}"
247
+ ```
248
+
249
+ Update `anticipatedSections` with accepted additions. For each added section:
250
+ - Determine `sectionType` (functional for filtered views, embedded for dashboards)
251
+ - Determine `permissionMode` (read-only for history/reporting, custom for approval queues)
252
+ - Add appropriate resources
253
+
92
254
  ### B. Entities
93
255
 
94
256
  For each entity identified in step 02:
95
257
 
96
- ```json
97
- {
98
- "name": "Employee",
99
- "description": "Représente un employé de l'entreprise",
100
- "personRoleConfig": { "variant": "mandatory", "userFields": ["firstName", "lastName", "email"] },
101
- "attributes": [
102
- { "name": "code", "type": "string", "required": true, "description": "Identifiant unique auto-généré" },
103
- { "name": "userId", "type": "string", "required": true, "description": "FK vers auth_Users (ASP.NET Identity — type string, NOT guid)" },
104
- { "name": "departmentId", "type": "guid", "required": true, "description": "Département d'affectation" },
105
- { "name": "hireDate", "type": "date", "required": true, "description": "Date d'embauche" },
106
- { "name": "position", "type": "string", "description": "Poste occupé" },
107
- { "name": "status", "type": "enum", "options": ["Active", "Inactive", "OnLeave", "Terminated"], "defaultValue": "Active", "description": "Statut de l'employé" }
108
- ],
109
- "versionedAttributes": [
110
- { "entity": "Salary", "attributes": ["grossAmount", "netAmount", "effectiveDate", "currency"], "reason": "Historique salarial versionné" }
111
- ],
112
- "estimatedVolume": { "monthly": 50, "total2y": 1200 },
113
- "searchableFields": ["code", "position", "status"],
114
- "defaultFilters": ["status"],
115
- "relationships": [
116
- { "target": "Department", "type": "ManyToOne", "description": "Appartient à un département" },
117
- { "target": "Contract", "type": "OneToMany", "description": "Possède plusieurs contrats" },
118
- { "target": "Salary", "type": "OneToMany", "description": "Historique de salaires versionnés" }
119
- ]
120
- }
121
- ```
258
+ > → **Load** `references/03-json-schemas.md` section "Entity Schema Format" for the canonical JSON format.
122
259
 
123
260
  ### B-bis. SmartStack Entity Convention Guards (MANDATORY)
124
261
 
125
- Before finalizing each entity, apply these rules:
262
+ > **Load** `references/03-smartstack-entity-guards.md` for all convention rules before finalizing each entity.
263
+
264
+ ### B-ter. Client Validation — Entities (OBLIGATOIRE)
265
+
266
+ **Mode : Auto-déduction + Confirmation groupée**
267
+
268
+ > L'IA propose les entités basées sur le cadrage + recherche domaine (A-bis).
269
+ > Le client valide PAR LOT au lieu de répondre aux questions individuellement.
270
+ > Les questions détaillées (Q3.1-Q3.5) ne sont posées QUE si le cadrage est ambigu.
271
+
272
+ 1. **Construire la proposition d'entités** à partir de :
273
+ - `cadrage.json` (coverageMatrix, stakeholders, globalScope)
274
+ - Recherche domaine (A-bis : standard attributes, versioning patterns)
275
+ - Modules déjà spécifiés (dépendances, entités partagées)
276
+
277
+ 2. **Présenter la proposition COMPLÈTE** (markdown PUIS AskUserQuestion) :
278
+ ```
279
+ ### Entités proposées pour {moduleName}
280
+
281
+ | Entité | Attributs clés | Relations | Volume estimé |
282
+ |--------|---------------|-----------|---------------|
283
+ | {entity} | {top 5 attrs with flags} | {relations} | {monthly/total} |
284
+ ```
285
+ AskUserQuestion : "Voici les entités que je propose pour {moduleName}. Corrections ?"
286
+
287
+ 3. SI le client corrige → intégrer et re-présenter
288
+ 4. SI le client valide → continuer vers C
126
289
 
127
- **B-bis-1. Person Extension Pattern** (ref: `entity-architecture-decision.md` section 0)
128
- IF the entity matches a person role (Employee, Customer, Manager, Consultant, etc.):
129
- - **DO NOT** add firstName, lastName, email, phoneNumber as direct attributes
130
- - **DO** add `userId` (type: `string`, FK to auth_Users — ASP.NET Identity uses string IDs)
131
- - **DO** add `personRoleConfig` metadata with variant (mandatory/optional)
132
- - Personal fields come from User, not from the domain entity
290
+ 5. **SI le cadrage est ambigu** sur un point spécifique → poser la question ciblée :
291
+ - Q3.1 si les entités ne sont pas claires
292
+ - Q3.5 si la stratégie de code est ambiguë
133
293
 
134
- **B-bis-2. Versioned Sensitive Data**
135
- IF the entity has attributes that change over time with audit requirements (salary, rate, grade):
136
- - **DO NOT** put them directly on the entity as single fields
137
- - **DO** extract into a versioned satellite table (e.g., Employee → Salary with effectiveDate)
138
- - Mark with `"versionedAttributes"` in entity spec
294
+ 6. APRES validation entites, AVANT passage aux regles (C) — poser en 2 batches max :
139
295
 
140
- **B-bis-3. SmartStack Socle Entities (NEVER redefine)**
141
- - Users/Identity `auth_Users` (managed by SmartStack Identity)
142
- - Tenants `tenant_Tenants` (managed by SmartStack Core)
143
- - Departments → `ref_Departments` or `rh_Departments` (check if exists in target DB)
296
+ **Batch recherche/filtres** (Q3.19 + Q3.20) :
297
+ - Q3.19 : "Par quels criteres cherchez-vous un {entite} ? (nom, date, statut, code...)"
298
+ - Q3.20 : "Quels filtres rapides sont indispensables dans la liste ?"
144
299
 
145
- **B-bis-4. Foreign Key Conventions**
146
- - All FK attributes MUST end with `Id` suffix (e.g., `departmentId`, `userId`)
147
- - FK to Identity users MUST use type `string` (ASP.NET Identity convention, NOT guid)
148
- - FK to domain entities MUST use type `guid`
300
+ **RACCOURCI module 3+ :** Proposer "Meme logique de recherche/filtres que {module_precedent} ?"
301
+ Si le client confirme, copier searchableFields et defaultFilters du module precedent.
302
+ Sinon, poser les questions normalement.
303
+
304
+ **SKIP si:** module Portal (pas d'entites propres) ou module config (filtres evidents : name, code).
305
+
306
+ INTERDICTION de passer à C (Business Rules) tant que le client n'a pas validé les entités ET les champs recherche/filtres.
149
307
 
150
308
  ### C. Business Rules
151
309
 
152
310
  For each entity/process, identify rules. **Each rule MUST specify `sectionCode`** matching a code from `anticipatedSections[]`:
153
311
 
154
- ```json
155
- {
156
- "id": "BR-VAL-EMPLOYEES-001",
157
- "name": "Validation date embauche",
158
- "category": "validation",
159
- "sectionCode": "list",
160
- "statement": "La date d'embauche ne peut pas être dans le futur",
161
- "example": "Date embauche = 2027-01-01 → erreur car > date du jour",
162
- "entities": ["Employee"],
163
- "severity": "blocking"
164
- }
165
- ```
312
+ > → **Load** `references/03-json-schemas.md` section "Business Rules Schema Format" for the canonical JSON format and all validation requirements.
166
313
 
167
- Categories: `validation`, `calculation`, `workflow`, `security`, `data`, `notification`
314
+ ### C-pre. Business Rules Domain Research (MANDATORY for workflow modules)
168
315
 
169
- > **OBLIGATOIRE** : Chaque attribut `enum` DOIT avoir un `defaultValue`. Chaque attribut numérique borné DOIT avoir `validation.min/max`. Les types userId (FK vers Identity) DOIVENT utiliser le type `string` (convention ASP.NET Identity).
316
+ > **Domain-specific business rules are what separate a 2/10 analysis from a 9/10 analysis.**
317
+ > Generic rules (date coherence, required fields) are the MINIMUM. Domain rules are the VALUE.
318
+ > → **Load** `references/module-completeness-challenge.md` for domain-specific rule examples.
170
319
 
171
- > **OBLIGATOIRE** : Chaque attribut marqué "calculé" dans entities.json DOIT avoir une règle `category: "calculation"` correspondante avec le champ `formula`.
320
+ ```
321
+ IF module has workflow states OR approval patterns:
322
+ WebSearch: "{module_domain} business rules constraints validation best practices"
323
+ (e.g., "absence leave management business rules HR constraints",
324
+ "invoice billing business rules validation constraints",
325
+ "CRM opportunity management business rules")
172
326
 
173
- Exemple de règle de calcul :
174
- ```json
175
- {
176
- "id": "BR-CALC-INV-003",
177
- "category": "calculation",
178
- "statement": "Le reste à payer = total - montant payé",
179
- "formula": "remainingAmount = total - paidAmount",
180
- "entities": ["Invoice"]
181
- }
327
+ EXTRACT (ULTRATHINK internal only):
328
+ - Domain-specific validation rules (NOT just date coherence / required fields)
329
+ - Calculation rules with formulas
330
+ - Workflow constraints (capacity limits, notice periods, deadlines)
331
+ - Edge cases (half-day, probation, carry-over, expiry, partial payments)
332
+ - Regulatory constraints (legal leave types, mandatory approvals, numbering)
333
+ - Separation of duties rules (cannot approve own request)
334
+
335
+ CROSS-CHECK proposed rules (from B-ter entity analysis):
336
+ For each rule found in research but NOT already proposed:
337
+ → Add to proposal with source: "domain-research"
338
+ → Category: detected category (VAL, CALC, WF, SEC, DATA)
339
+ → Mark with domainSpecific: true
340
+
341
+ Example enrichments for Absences module:
342
+ Current generic rules: date coherence, no overlap, balance check, workflow transitions
343
+ Research-based additions:
344
+ - BR-VAL-ABS-004: "Half-day absence (morning/afternoon)" [domainSpecific]
345
+ - BR-VAL-ABS-005: "Minimum 48h notice for planned absences" [domainSpecific]
346
+ - BR-VAL-ABS-006: "Max 30% of team can be absent simultaneously" [domainSpecific]
347
+ - BR-VAL-ABS-007: "Restricted leave types during probation period" [domainSpecific]
348
+ - BR-DATA-ABS-001: "Carry-over days expire after March 31" [domainSpecific]
349
+ - BR-VAL-ABS-008: "Medical certificate required for absences > 3 days" [domainSpecific]
350
+ - BR-SEC-ABS-001: "Manager cannot approve their own absences" [domainSpecific]
351
+
352
+ ELSE (non-workflow module):
353
+ → Use entity patterns from A-bis for validation rules
354
+ → Load archetype rules from module-completeness-challenge.md
182
355
  ```
183
356
 
357
+ ### C-bis. Client Validation — Business Rules (OBLIGATOIRE)
358
+
359
+ **Mode : Auto-déduction + Confirmation groupée**
360
+
361
+ 1. **Construire les règles métier** à partir de :
362
+ - Entités validées en B-ter (attributs, types, contraintes)
363
+ - Patterns domaine (A-bis) : validations standards, calculs attendus
364
+ - Cadrage : errorFlows, processus décrits
365
+
366
+ **ENRICHISSEMENT OBLIGATOIRE pour chaque règle :**
367
+
368
+ Pour chaque BR proposée, inclure ces champs :
369
+ - `severity` : TOUJOURS spécifier (blocking/warning/info)
370
+ - `sectionCode` : TOUJOURS spécifier (section où la règle s'applique)
371
+ - `examples[]` : OBLIGATOIRE — au moins 1 exemple structuré `{input, expected}`
372
+ Ex: `{ input: "debut=15/03 fin=12/03", expected: "Erreur : date de fin avant date de debut" }`
373
+ - `conditions[]` : OBLIGATOIRE pour les règles conditionnelles (IF/THEN) — structuré `{entity, field, operator, value}`
374
+ Ex: `[{ entity: "Absence", field: "type", operator: "==", value: "Maladie" }, { entity: "Absence", field: "duration", operator: ">", value: 3 }]`
375
+ - `consequences[]` : OBLIGATOIRE pour les règles avec effets de bord
376
+ Ex: `[{ type: "notification", target: "RH Manager", description: "Certificat médical requis" }]`
377
+ - `formula` : OBLIGATOIRE pour les BR-CALC
378
+ - `domainSpecific: true` si la règle vient de la recherche domaine (C-pre)
379
+
380
+ **Minimums par module métier (hors Portal/config) :**
381
+ - >= 4 règles avec `examples[]` structurés `{input, expected}`
382
+ - >= 2 règles avec `conditions[]` structurés
383
+ - >= 1 règle avec `consequences[]`
384
+
385
+ 2. **Présenter le LOT complet** (markdown PUIS AskUserQuestion) :
386
+ ```
387
+ ### Règles métier proposées pour {moduleName}
388
+
389
+ | ID | Catégorie | Règle | Sévérité |
390
+ |----|-----------|-------|----------|
391
+ | BR-VAL-... | validation | {statement} | blocking |
392
+ | BR-CALC-... | calculation | {statement} (formula: {formula}) | blocking |
393
+ ```
394
+ AskUserQuestion : "Voici les {N} règles métier pour {moduleName}. Manques/corrections ?"
395
+
396
+ 3. SI le cadrage est ambigu → poser les questions ciblées :
397
+ - Q3.7 si les validations ne sont pas claires
398
+ - Q3.8 si les relations inter-champs sont complexes
399
+ - Q3.9 si les données sensibles ne sont pas identifiées
400
+
401
+ INTERDICTION de passer à D (Use Cases) tant que le client n'a pas validé les règles.
402
+
184
403
  ### D. Use Cases
185
404
 
186
- For each stakeholder action. **Each use case MUST specify `sectionCode`** matching a code from `anticipatedSections[]` — this links the UC to the screen/page where it happens:
405
+ > **Note (v3) :** Les questions parcours/decisions/erreurs (ex-Q2.16-Q2.18) sont desormais capturees ICI
406
+ > lors de la specification des use cases, et non plus en step-01 cadrage. Cela evite la duplication
407
+ > et produit des donnees directement exploitables par module.
187
408
 
188
- > **CANONICAL FORMAT (MANDATORY):** The usecases.json file MUST use these exact keys:
189
- > - Root key: `"useCases"` (camelCase, NOT "usecases")
190
- > - Actor field: `"primaryActor"` (NOT "actor")
191
- > - Steps field: `"mainScenario"` (string[], NOT "steps" with objects)
192
- > - Alternatives: `"alternativeScenarios"` (object[] with `{name, steps}`, NOT "alternative" as flat string)
193
- > - This matches specification-schema.json. Deviation causes normalization overhead in 4+ downstream skills.
409
+ **D-pre. Capture du parcours utilisateur (1 question par module si pertinent)**
194
410
 
195
- ```json
196
- {
197
- "useCases": [
198
- {
199
- "id": "UC-EMPLOYEES-001",
200
- "name": "Créer un employé",
201
- "sectionCode": "list",
202
- "primaryActor": "Responsable RH",
203
- "preconditions": ["L'utilisateur a la permission HumanResources.Employees.Create"],
204
- "mainScenario": [
205
- "L'utilisateur ouvre la page de création",
206
- "Il remplit les champs obligatoires (nom, département, date embauche)",
207
- "Il valide le formulaire",
208
- "Le système vérifie les règles métier (BR-VAL-EMPLOYEES-001)",
209
- "Le système crée l'employé et affiche la fiche"
210
- ],
211
- "alternativeScenarios": [
212
- {
213
- "name": "Données invalides",
214
- "steps": ["Le système affiche les erreurs de validation", "L'utilisateur corrige et re-soumet"]
215
- }
216
- ],
217
- "businessRules": ["BR-VAL-EMPLOYEES-001"],
218
- "result": "L'employé est créé avec le statut 'Actif'"
219
- }
220
- ]
221
- }
411
+ > Avant de construire les UCs, comprendre le parcours type pour CE module.
412
+ > SKIP si le module est un module config/lookup ou Portal (pas de parcours propre).
413
+
414
+ ```
415
+ IF module is NOT config/lookup AND NOT Portal:
416
+ AskUserQuestion (1 question):
417
+ "{language == 'fr'
418
+ ? 'Pour le module {moduleName} : décrivez le parcours typique. L\'utilisateur arrive, que fait-il ? Quand quelque chose ne se passe pas comme prévu, que se passe-t-il ?'
419
+ : 'For the {moduleName} module: describe the typical journey. The user arrives, what do they do? When something doesn't go as planned, what happens?'}"
420
+
421
+ Record answer as:
422
+ - mainScenario steps feed UC mainScenario
423
+ - decision points → feed UC alternativeScenarios
424
+ - error cases feed UC errorScenarios + BR-WF rules
222
425
  ```
223
426
 
427
+ For each stakeholder action. **Each use case MUST specify `sectionCode`** matching a code from `anticipatedSections[]` — this links the UC to the screen/page where it happens:
428
+
429
+ > → **Load** `references/03-json-schemas.md` section "Use Cases Schema Format" for the canonical JSON format.
430
+
224
431
  ### E. Permissions
225
432
 
226
433
  Define the permission matrix:
227
434
 
228
- ```json
229
- {
230
- "roles": ["RH Admin", "Manager", "Employee"],
231
- "matrix": [
232
- { "role": "RH Admin", "permissions": ["Read", "Create", "Update", "Delete", "Export"] },
233
- { "role": "Manager", "permissions": ["Read", "Export"] },
234
- { "role": "Employee", "permissions": ["Read"] }
235
- ],
236
- "permissionPaths": [
237
- "HumanResources.Employees.Read",
238
- "HumanResources.Employees.Create",
239
- "HumanResources.Employees.Update",
240
- "HumanResources.Employees.Delete",
241
- "HumanResources.Employees.Export"
242
- ]
243
- }
244
- ```
435
+ > → **Load** `references/03-json-schemas.md` section "Permissions Schema Format" for the canonical JSON format.
436
+
437
+ ### E-bis. Notifications et Dashboards (OBLIGATOIRE)
438
+
439
+ > **Regle : 2 questions max par AskUserQuestion.**
440
+
441
+ **Batch E-bis-1** Notifications :
442
+ - Q3.21 : "Quels evenements doivent declencher une notification dans {moduleName} ?"
443
+ - Q3.22 : "Qui doit etre notifie ? Par quel canal ? (in-app, email)" (conditionnel si Q3.21 = oui)
444
+
445
+ **Batch E-bis-2** — Dashboards (SI pertinent pour ce module) :
446
+ - Q3.14 : "Des tableaux de bord ou indicateurs sont-ils requis ?"
447
+ - Q3.15 : "Si oui, quels KPIs afficher ?" (conditionnel si Q3.14 = oui)
448
+
449
+ ### E-ter. Client Validation — Use Cases & Permissions (OBLIGATOIRE)
450
+
451
+ **Mode : Auto-déduction + Confirmation groupée**
245
452
 
246
- **Auto-detection rules:**
247
- - If the cadrage mentions "export", "Excel", "CSV", or "télécharger" → automatically add `.export` permission and an export use case (UC-{PREFIX}-EXPORT)
248
- - If the cadrage mentions "import", "importer", "upload" → automatically add `.import` permission and an import use case (UC-{PREFIX}-IMPORT)
453
+ 1. **Construire UCs et permissions** à partir des entités + règles validées :
454
+ - CRUD UCs dérivés des entités (Create, Read, Update, Delete)
455
+ - Export UC si cadrage mentionne export/Excel/CSV
456
+ - Import UC si cadrage mentionne import/upload
457
+ - Workflow UCs si entité a des états (enum status)
458
+
459
+ **ENRICHISSEMENT OBLIGATOIRE pour chaque Use Case :**
460
+
461
+ Pour chaque UC proposé, inclure ces champs :
462
+ - `postconditions[]` : OBLIGATOIRE — effets après le UC
463
+ Ex: `["Absence.status = Approved", "AbsenceBalance.taken += duration", "Notification envoyee a l'employe"]`
464
+ - `errorScenarios[]` : OBLIGATOIRE pour les UCs workflow (>= 1 par UC workflow)
465
+ Ex: `{ name: "Solde insuffisant", steps: ["Systeme affiche le solde restant", "Systeme bloque la soumission", "Employe peut modifier les dates"] }`
466
+ - `mainScenario[]` : MINIMUM 5 steps pour les UCs workflow (3 suffisent pour list/read)
467
+ - `alternativeScenarios[]` : MINIMUM 1 pour les UCs avec branchements
468
+
469
+ **Minimums par module métier :**
470
+ - >= 3 UCs avec `errorScenarios[]` non vides
471
+ - >= 4 UCs avec `postconditions[]` non vides
472
+ - Moyenne mainScenario >= 4 steps
473
+
474
+ 2. **Présenter les deux lots en 1 seule interaction** (markdown PUIS AskUserQuestion) :
475
+ ```
476
+ ### Use Cases proposés pour {moduleName}
477
+ | ID | Nom | Acteur | Règles liées |
478
+ ...
479
+
480
+ ### Permissions proposées
481
+ | Rôle | Permissions |
482
+ ...
483
+ ```
484
+ AskUserQuestion : "Voici les UCs et permissions pour {moduleName}. Corrections ?"
485
+
486
+ 3. SI le cadrage est ambigu → poser les questions ciblées du lot E-bis (notifications, dashboards)
487
+
488
+ INTERDICTION de passer à F (Seed Data) / H (Write) tant que le client n'a pas validé use cases ET permissions.
249
489
 
250
490
  ### F. Seed Data pour tables de référence
251
491
 
@@ -265,13 +505,273 @@ Define the permission matrix:
265
505
  }
266
506
  ```
267
507
 
508
+ ### F-bis. LifeCycle State Machine (MANDATORY for workflow entities)
509
+
510
+ > Les lifeCycles sont déjà dans le schema (`specification-schema.json` l.317-383).
511
+ > Ils doivent être générés pour CHAQUE entité ayant un attribut status de type enum.
512
+ > Ces données alimentent les diagrammes d'état Mermaid ET le code généré.
513
+
514
+ Pour CHAQUE entité avec attribut `type: "enum"` contenant "status" dans ses `options[]` :
515
+
516
+ 1. Extraire les états depuis `options[]` de l'attribut enum
517
+ 2. Identifier les transitions depuis les règles BR-WF-*
518
+ 3. Lier chaque transition à :
519
+ - `permission` : depuis permissions.json
520
+ - `guards[]` : BR-VAL-* qui doivent passer avant la transition
521
+ - `effects[]` : BR-NOTIF-* et BR-CALC-* déclenchées par la transition
522
+
523
+ Générer le `lifeCycle` complet :
524
+ ```json
525
+ {
526
+ "entity": "Absence",
527
+ "field": "status",
528
+ "initialState": "Draft",
529
+ "states": [
530
+ { "id": "Draft", "displayName": "Brouillon", "color": "gray", "allowedTransitions": ["Submitted"], "isTerminal": false },
531
+ { "id": "Submitted", "displayName": "Soumis", "color": "blue", "allowedTransitions": ["Approved", "Rejected"], "isTerminal": false },
532
+ { "id": "Approved", "displayName": "Approuvé", "color": "green", "allowedTransitions": [], "isTerminal": true },
533
+ { "id": "Rejected", "displayName": "Refusé", "color": "red", "allowedTransitions": [], "isTerminal": true }
534
+ ],
535
+ "transitions": [
536
+ { "from": "Draft", "to": "Submitted", "action": "submit", "permission": "Rh.Absences.Create",
537
+ "guards": ["BR-VAL-ABS-001", "BR-VAL-ABS-002", "BR-VAL-ABS-003"],
538
+ "effects": [{ "type": "notification", "target": "RH Manager", "template": "absence-submitted" }] },
539
+ { "from": "Submitted", "to": "Approved", "action": "approve", "permission": "Rh.Absences.Approve",
540
+ "guards": [],
541
+ "effects": [
542
+ { "type": "field-update", "target": "AbsenceBalance.taken", "template": "+= duration" },
543
+ { "type": "notification", "target": "employee", "template": "absence-approved" }
544
+ ] }
545
+ ]
546
+ }
547
+ ```
548
+
549
+ Présenter le lifecycle au client dans le lot E-ter (avec UCs et permissions).
550
+
551
+ **Écriture :** Stocker dans `usecases.json` sous la clé `lifeCycles[]` (déjà dans le schema).
552
+
553
+ ### F-ter. Gherkin Auto-Generation from Enriched UCs (MANDATORY)
554
+
555
+ > **Les Gherkin doivent être DERIVES des UCs enrichis, pas inventés séparément.**
556
+ > Chaque `mainScenario` → 1 Gherkin happy path.
557
+ > Chaque `errorScenario` → 1 Gherkin error path.
558
+ > Chaque `alternativeScenario` → 1 Gherkin alternative path.
559
+ > Les `examples[]{input, expected}` des BRs alimentent les `Examples:` tables Gherkin.
560
+
561
+ **Process :**
562
+
563
+ ```
564
+ For EACH UC in module:
565
+ // 1. Happy path from mainScenario + postconditions
566
+ Generate Gherkin:
567
+ Feature: {UC.name}
568
+ Scenario: {UC.name} - happy path
569
+ Given {UC.preconditions[] joined as Given/And}
570
+ When {UC.mainScenario[] mapped to When/And steps}
571
+ Then {UC.postconditions[] mapped to Then/And assertions}
572
+
573
+ // 2. Error paths from errorScenarios
574
+ For EACH errorScenario in UC.errorScenarios:
575
+ Scenario: {UC.name} - {errorScenario.name}
576
+ Given {UC.preconditions[] + error setup conditions}
577
+ When {trigger action from mainScenario step 1}
578
+ Then {errorScenario.steps[] mapped to Then/And}
579
+
580
+ // 3. Alternative paths from alternativeScenarios
581
+ For EACH alt in UC.alternativeScenarios:
582
+ Scenario: {UC.name} - {alt.name}
583
+ Given {modified preconditions}
584
+ When {alt trigger}
585
+ Then {alt.steps[] mapped to Then/And}
586
+
587
+ // 4. Data-driven examples from linked BR examples
588
+ IF UC.linkedRules references BRs with structured examples[]:
589
+ Scenario Outline: {UC.name} - validation rules
590
+ Given a {entity} with <field> = <value>
591
+ When the user submits the form
592
+ Then the system shows <expected>
593
+ Examples:
594
+ | field | value | expected |
595
+ {for each BR example: | {input} | {expected} |}
596
+ ```
597
+
598
+ **Exemple concret (Absence - Soumission) :**
599
+
600
+ ```gherkin
601
+ Feature: Soumettre une demande d'absence (UC-ABS-001)
602
+
603
+ Scenario: Soumission reussie
604
+ Given un employe avec la permission Rh.Absences.Create
605
+ And un solde de CP >= duree demandee
606
+ When il selectionne le type CP, dates 15/03 au 19/03
607
+ And le systeme calcule la duree en jours ouvres (5j)
608
+ And le systeme verifie les dates, chevauchements et solde
609
+ And il soumet la demande
610
+ Then Absence.status = Submitted
611
+ And AbsenceBalance.taken reste inchange (pas encore approuve)
612
+ And notification envoyee au RH Manager
613
+
614
+ Scenario: Soumission echouee - solde insuffisant
615
+ Given un employe avec 2 jours de CP restants
616
+ When il soumet une absence de 5 jours de type CP
617
+ Then le systeme affiche le solde restant (2 jours)
618
+ And la soumission est bloquee
619
+
620
+ Scenario: Soumission echouee - chevauchement
621
+ Given un employe avec une absence approuvee du 15/03 au 19/03
622
+ When il soumet une absence du 17/03 au 21/03
623
+ Then le systeme affiche l'absence existante en conflit
624
+ And la soumission est bloquee
625
+
626
+ Scenario Outline: Validation des dates
627
+ Given un employe connecte
628
+ When il saisit debut=<debut> fin=<fin>
629
+ Then le systeme affiche <resultat>
630
+ Examples:
631
+ | debut | fin | resultat |
632
+ | 15/03 | 12/03 | Erreur : date de fin avant date de debut |
633
+ | 15/03 | 15/03 | OK (1 jour) |
634
+ | 15/03 | 19/03 | OK (5 jours ouvres) |
635
+ ```
636
+
637
+ **Minimums :** >= 3 scnarios Gherkin par module mtier (1 happy + 2 error/alt minimum).
638
+
639
+ **criture :** Stocker dans `usecases.json` sous la cl `gherkinScenarios[]`.
640
+
641
+ ### F-quater. Field-Level Validations Auto-Generation (MANDATORY)
642
+
643
+ > **Gnrer les validations field-level depuis les attributs d'entits + rgles mtier.**
644
+ > Ces validations alimentent directement les validators frontend (FluentValidation backend + form validation frontend).
645
+
646
+ ```
647
+ For EACH entity in module:
648
+ For EACH attribute in entity.attributes:
649
+
650
+ validations = []
651
+
652
+ // From attribute metadata
653
+ IF attribute.required: validations.push({ rule: "required", errorMessageKey: "{module}.{entity}.{attr}.required" })
654
+ IF attribute.type === "string" AND attribute.maxLength: validations.push({ rule: "maxLength", params: { max: attribute.maxLength }, errorMessageKey: "..." })
655
+ IF attribute.type === "string" AND attribute.unique: validations.push({ rule: "unique", errorMessageKey: "..." })
656
+ IF attribute.type === "email": validations.push({ rule: "email", errorMessageKey: "..." })
657
+ IF attribute.type === "decimal" AND (context is amount/price): validations.push({ rule: "min", params: { min: 0 }, errorMessageKey: "..." })
658
+ IF attribute.type === "int": validations.push({ rule: "integer", errorMessageKey: "..." })
659
+ IF attribute.type === "date": validations.push({ rule: "date", errorMessageKey: "..." })
660
+
661
+ // From linked business rules (BR-VAL-*)
662
+ IF exists BR-VAL referencing this attribute:
663
+ For EACH matching BR:
664
+ validations.push({ rule: "custom", brRef: BR.id, description: BR.statement, errorMessageKey: "..." })
665
+
666
+ Store: { entity: entity.name, field: attribute.name, rules: validations }
667
+ ```
668
+
669
+ **Exemple concret (Absence) :**
670
+
671
+ ```json
672
+ [
673
+ { "entity": "Absence", "field": "startDate", "rules": [
674
+ { "rule": "required", "errorMessageKey": "absences.absence.startDate.required" },
675
+ { "rule": "date", "errorMessageKey": "absences.absence.startDate.date" },
676
+ { "rule": "custom", "brRef": "BR-VAL-ABS-001", "description": "startDate <= endDate", "errorMessageKey": "absences.absence.startDate.beforeEnd" }
677
+ ]},
678
+ { "entity": "Absence", "field": "endDate", "rules": [
679
+ { "rule": "required", "errorMessageKey": "absences.absence.endDate.required" },
680
+ { "rule": "date", "errorMessageKey": "absences.absence.endDate.date" }
681
+ ]},
682
+ { "entity": "Absence", "field": "reason", "rules": [
683
+ { "rule": "maxLength", "params": { "max": 500 }, "errorMessageKey": "absences.absence.reason.maxLength" }
684
+ ]}
685
+ ]
686
+ ```
687
+
688
+ **criture :** Stocker dans `usecases.json` sous la cl `validations[]` (dj dans le schema specification-schema.json).
689
+
268
690
  ### G. Interface Specs — Delegated to /business-analyse-design
269
691
 
270
692
  > **Screen specifications are NOT produced in this step.**
271
693
  > Interface design (SmartTable columns, SmartForm fields, wireframes, navigation) is handled by Phase 2: `/business-analyse-design`.
272
694
  > This separation allows iterating on UI design without replaying the full analysis cycle.
273
695
 
274
- ### H. Write & Advance
696
+ ### G-bis. API Endpoint Schema Enrichment (MANDATORY)
697
+
698
+ > **Gnrer les request/response schemas pour chaque API endpoint depuis les entits.**
699
+ > Les apiEndpoints[] existent dj dans le schema mais manquent les DTOs.
700
+ > Ce sont ces DTOs qui permettent au develop de gnrer le bon code du premier coup.
701
+
702
+ ```
703
+ For EACH apiEndpoint in module:
704
+ // Derive requestSchema from entity attributes
705
+ IF method in ["POST", "PUT", "PATCH"]:
706
+ requestSchema = {}
707
+ For EACH attribute in entity.attributes:
708
+ IF attribute is NOT computed AND attribute is NOT auto-generated:
709
+ requestSchema[attribute.name] = {
710
+ type: attribute.type,
711
+ required: attribute.required || false,
712
+ description: attribute.description
713
+ }
714
+
715
+ // Derive responseSchema from entity attributes + computed fields
716
+ responseSchema = { id: "guid" }
717
+ For EACH attribute in entity.attributes:
718
+ responseSchema[attribute.name] = {
719
+ type: attribute.type,
720
+ computed: attribute.computed || false
721
+ }
722
+ // Add navigation properties for relationships
723
+ For EACH relationship in entity.relationships:
724
+ IF relationship.type === "ManyToOne":
725
+ responseSchema[relationship.target + "Name"] = { type: "string", computed: true }
726
+
727
+ // Derive errorCodes from linked BRs
728
+ errorCodes = []
729
+ For EACH linkedRule in UC.linkedRules:
730
+ IF rule.severity === "blocking":
731
+ errorCodes.push({ code: 400, reason: rule.id, description: rule.statement })
732
+ errorCodes.push({ code: 403, reason: "Forbidden", description: "Missing permission: " + endpoint.permission })
733
+ errorCodes.push({ code: 404, reason: "NotFound", description: entity.name + " not found" })
734
+ ```
735
+
736
+ **Exemple concret (POST /api/rh/absences) :**
737
+
738
+ ```json
739
+ {
740
+ "method": "POST",
741
+ "path": "/api/rh/absences",
742
+ "permission": "Rh.Absences.Create",
743
+ "linkedUC": "UC-ABS-001",
744
+ "requestSchema": {
745
+ "employeeId": { "type": "guid", "required": true },
746
+ "absenceTypeId": { "type": "guid", "required": true },
747
+ "startDate": { "type": "date", "required": true },
748
+ "endDate": { "type": "date", "required": true },
749
+ "reason": { "type": "string", "required": false }
750
+ },
751
+ "responseSchema": {
752
+ "id": { "type": "guid" },
753
+ "code": { "type": "string" },
754
+ "status": { "type": "enum", "computed": false },
755
+ "duration": { "type": "decimal", "computed": true },
756
+ "employeeName": { "type": "string", "computed": true }
757
+ },
758
+ "errorCodes": [
759
+ { "code": 400, "reason": "BR-VAL-ABS-001", "description": "Date de debut apres date de fin" },
760
+ { "code": 400, "reason": "BR-VAL-ABS-002", "description": "Chevauchement avec absence existante" },
761
+ { "code": 400, "reason": "BR-VAL-ABS-003", "description": "Solde insuffisant" },
762
+ { "code": 403, "reason": "Forbidden", "description": "Permission Rh.Absences.Create requise" },
763
+ { "code": 404, "reason": "NotFound", "description": "Employee not found" }
764
+ ]
765
+ }
766
+ ```
767
+
768
+ **criture :** Stocker dans `usecases.json` sous la cl `apiEndpoints[]` (enrichi).
769
+
770
+ ### H. Write & Advance (SEULEMENT apres validation complete)
771
+
772
+ > **GATE:** ba-writer ne peut etre lance QUE si le client a valide :
773
+ > entites (B-ter) + regles (C-bis) + use cases/permissions (E-ter).
774
+ > Si un lot n'est pas valide → RETOUR au lot concerne.
275
775
 
276
776
  After completing all sub-steps for a module:
277
777
 
@@ -295,6 +795,15 @@ After completing all sub-steps for a module:
295
795
 
296
796
  3. Advance to next module in topological order
297
797
 
798
+ ### H-bis. Module Transition Summary
799
+
800
+ Afficher un resume compact du module termine :
801
+ ```
802
+ ✓ {moduleName} — {entityCount} entites, {ruleCount} regles, {ucCount} UCs, {permCount} permissions
803
+ ```
804
+
805
+ Passer au module suivant. INTERDICTION de lancer des ba-writer en parallele pour des modules differents.
806
+
298
807
  ### I. Module Completion Check
299
808
 
300
809
  After all modules are specified:
@@ -303,102 +812,16 @@ After all modules are specified:
303
812
  - Remind user: "Run /business-analyse-design to design interfaces for these modules"
304
813
  - Transition to step 04
305
814
 
306
- ## POST-CHECK (EXECUTABLE BLOCKING)
815
+ ### I-bis. Cross-Module Questions (apres tous les modules)
307
816
 
308
- Before advancing to step 04, run these validations for EACH module:
817
+ SI des dependances cross-module existent (identifiees en step-02) :
818
+ → Charger questionnaire/05-cross-module.md et poser les questions pertinentes via AskUserQuestion.
819
+ → Integrer les reponses dans les modules concernes via ba-writer.
309
820
 
310
- ```javascript
311
- const errors = [];
312
- const warnings = [];
313
-
314
- for (const mod of modules) {
315
- // mod.dir = resolveModuleDir(applicationCode, mod.code)
316
- // e.g., docs/projet-rh/v1.0/human-resources/employees/
317
- const ent = READ(mod.dir + '/entities.json')?.entities || [];
318
- const ucs = READ(mod.dir + '/usecases.json')?.useCases || [];
319
- const brs = READ(mod.dir + '/rules.json')?.rules || [];
320
- const perms = READ(mod.dir + '/permissions.json');
321
- const sections = mod.anticipatedSections || [];
322
- const sectionCodes = new Set(sections.map(s => s.code));
323
-
324
- // Mandatory checks (BLOCKING)
325
- if (ent.length === 0) errors.push(mod.code + ": 0 entities");
326
- if (ucs.length === 0) errors.push(mod.code + ": 0 use cases");
327
- if (brs.length === 0) errors.push(mod.code + ": 0 business rules");
328
- if (!perms?.permissionPaths?.length) errors.push(mod.code + ": no permissions");
329
-
330
- // sectionCode validation
331
- for (const uc of ucs) {
332
- if (!uc.sectionCode) errors.push(mod.code + ": UC '" + uc.id + "' missing sectionCode");
333
- else if (!sectionCodes.has(uc.sectionCode)) errors.push(mod.code + ": UC '" + uc.id + "' sectionCode '" + uc.sectionCode + "' not in anticipatedSections");
334
- }
335
- for (const br of brs) {
336
- if (!br.sectionCode) errors.push(mod.code + ": BR '" + br.id + "' missing sectionCode");
337
- else if (!sectionCodes.has(br.sectionCode)) errors.push(mod.code + ": BR '" + br.id + "' sectionCode '" + br.sectionCode + "' not in anticipatedSections");
338
- }
339
-
340
- // Entity attribute checks
341
- for (const e of ent) {
342
- for (const a of (e.attributes || [])) {
343
- if (!a.type) warnings.push(mod.code + ": entity " + e.name + " attr '" + a.name + "' missing type");
344
- if (a.type === 'enum' && !a.defaultValue) errors.push(mod.code + ": enum attr '" + a.name + "' missing defaultValue");
345
- // FK naming convention: must end with "Id"
346
- if ((a.type === 'guid' || a.type === 'string') && a.foreignKey && !a.name.endsWith('Id'))
347
- warnings.push(mod.code + ": entity " + e.name + " FK attr '" + a.name + "' should end with 'Id'");
348
- }
349
- // Person Extension Pattern check
350
- const personFields = ['firstName', 'lastName', 'email', 'phoneNumber', 'phone'];
351
- const foundPersonFields = (e.attributes || []).filter(a => personFields.includes(a.name));
352
- if (foundPersonFields.length >= 3 && !e.personRoleConfig) {
353
- errors.push(mod.code + ": entity '" + e.name + "' has " + foundPersonFields.length +
354
- " person fields (" + foundPersonFields.map(f => f.name).join(", ") +
355
- ") but no personRoleConfig — use Person Extension Pattern (entity-architecture-decision.md section 0). " +
356
- "Person fields (firstName, lastName, email) belong on auth_Users, not on the domain entity.");
357
- }
358
- }
359
-
360
- // Canonical usecases key check
361
- const rawUCFile = READ(mod.dir + '/usecases.json');
362
- if (rawUCFile && !rawUCFile.useCases && rawUCFile.usecases) {
363
- errors.push(mod.code + ": usecases.json uses 'usecases' key instead of canonical 'useCases' — fix before proceeding");
364
- }
365
- // Check steps serialization format
366
- for (const uc of ucs) {
367
- if (uc.steps && Array.isArray(uc.steps) && uc.steps.length > 0 && typeof uc.steps[0] === 'object') {
368
- errors.push(mod.code + ": UC '" + uc.id + "' uses steps[] with objects — must use mainScenario[] with strings");
369
- }
370
- if (uc.actor && !uc.primaryActor) {
371
- warnings.push(mod.code + ": UC '" + uc.id + "' uses 'actor' instead of canonical 'primaryActor'");
372
- }
373
- }
374
-
375
- // Cross-reference checks
376
- for (const uc of ucs) {
377
- for (const brRef of (uc.businessRules || [])) {
378
- if (!brs.find(br => br.id === brRef)) warnings.push(mod.code + ": UC '" + uc.id + "' references non-existent BR '" + brRef + "'");
379
- }
380
- }
381
-
382
- // Section permission checks
383
- for (const section of sections) {
384
- if (section.sectionType === 'view') {
385
- const viewPerms = (perms?.permissionPaths || []).filter(p => p.includes('.' + section.code + '.'));
386
- if (viewPerms.length > 0) errors.push(mod.code + ": view section '" + section.code + "' has " + viewPerms.length + " permissions (should inherit)");
387
- }
388
- }
389
- }
821
+ ## POST-CHECK (EXECUTABLE — BLOCKING)
390
822
 
391
- if (errors.length > 0) {
392
- Display("POST-CHECK FAILED (" + errors.length + " errors):");
393
- errors.forEach(e => Display(" ✗ " + e));
394
- BLOCKING_ERROR("Fix all errors before advancing to step 04");
395
- }
396
- if (warnings.length > 0) {
397
- Display("POST-CHECK warnings (" + warnings.length + "):");
398
- warnings.forEach(w => Display(" ⚠ " + w));
399
- }
400
- Display("POST-CHECK PASS: " + modules.length + " modules validated");
401
- ```
823
+ > → **Load** `references/03-post-check-validation.md` and execute ALL checks.
824
+ > Any BLOCKING check failure must be resolved before proceeding to step 04.
402
825
 
403
826
  ## Transition
404
827