@atlashub/smartstack-cli 2.3.0 → 2.5.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 (33) hide show
  1. package/.documentation/cli-commands.html +1 -1
  2. package/.documentation/init.html +1 -1
  3. package/.documentation/installation.html +1 -1
  4. package/dist/index.js +1213 -815
  5. package/dist/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/templates/agents/ba-reader.md +114 -9
  8. package/templates/agents/ba-writer.md +108 -27
  9. package/templates/agents/mcp-healthcheck.md +1 -1
  10. package/templates/ralph/README.md +1 -1
  11. package/templates/ralph/ralph.config.yaml +1 -1
  12. package/templates/skills/_shared.md +60 -0
  13. package/templates/skills/application/steps/step-00-init.md +32 -8
  14. package/templates/skills/business-analyse/SKILL.md +65 -42
  15. package/templates/skills/business-analyse/_shared.md +161 -51
  16. package/templates/skills/business-analyse/questionnaire/00-application.md +166 -0
  17. package/templates/skills/business-analyse/questionnaire.md +63 -19
  18. package/templates/skills/business-analyse/react/application-viewer.md +242 -0
  19. package/templates/skills/business-analyse/react/components.md +60 -8
  20. package/templates/skills/business-analyse/react/schema.md +238 -7
  21. package/templates/skills/business-analyse/schemas/application-schema.json +389 -0
  22. package/templates/skills/business-analyse/schemas/feature-schema.json +74 -3
  23. package/templates/skills/business-analyse/steps/step-00-init.md +110 -44
  24. package/templates/skills/business-analyse/steps/step-01-cadrage.md +259 -0
  25. package/templates/skills/business-analyse/steps/step-02-decomposition.md +282 -0
  26. package/templates/skills/business-analyse/steps/step-03-specify.md +489 -0
  27. package/templates/skills/business-analyse/steps/step-04-consolidation.md +336 -0
  28. package/templates/skills/business-analyse/steps/step-05-handoff.md +1119 -0
  29. package/templates/skills/mcp/SKILL.md +2 -2
  30. package/templates/skills/business-analyse/steps/step-01-analyse.md +0 -523
  31. package/templates/skills/business-analyse/steps/step-02-specify.md +0 -899
  32. package/templates/skills/business-analyse/steps/step-03-validate.md +0 -1009
  33. package/templates/skills/business-analyse/steps/step-04-handoff.md +0 -1802
@@ -1,899 +0,0 @@
1
- # Step 02: Specification
2
-
3
- > **Version:** 3.0.0
4
- > **Name:** step-02-specify
5
- > **Next step:** steps/step-03-validate.md
6
- > **Purpose:** Enrich feature.json with detailed specification section (use cases, functional requirements, actors, permissions, wireframes, scenarios)
7
- > **Input:** feature.json (scope, analysis sections populated)
8
- > **Output:** feature.json.specification enriched + status: "specified"
9
-
10
- ---
11
-
12
- ## 1. Introduction
13
-
14
- This step transforms the analysis from **discovery** into detailed **specifications**. You will:
15
-
16
- 1. **Define actors and permissions** - Map stakeholder roles to system actors and RBAC permissions
17
- 2. **Create use cases** - Model user interactions with UC-XXX identifiers
18
- 3. **Define functional requirements** - Specify what the system must do (FR-XXX format)
19
- 4. **Design permission matrix** - Map actors × resources × operations
20
- 5. **Plan navigation & SeedData** - Design UI hierarchy and mandatory reference data
21
- 6. **Sketch UI wireframes** - Visual representation of key screens
22
- 7. **Write Gherkin scenarios** - Acceptance criteria in BDD format
23
- 8. **Define validations & messages** - Business rules for data quality
24
- 9. **Model data lifecycle** - Creation, updates, deletions, archiving patterns
25
-
26
- ---
27
-
28
- ## 2. Mode Support
29
-
30
- ### Standard Mode
31
- Execute all sections in full detail.
32
-
33
- ### Delta Mode
34
- IF use_case = refactoring:
35
- - Only add/modify use cases, functional requirements, and permissions for **affected features**
36
- - Keep existing UCs, FRs, and permissions intact (DO NOT regenerate complete matrix)
37
- - Mark affected sections with `delta: true` in specification
38
- - Preserve backwards compatibility
39
-
40
- ### Micro Mode
41
- IF use_case = micro:
42
- - Generate **minimal spec** for MVP
43
- - Use cases: 1-2 only (typically Create + Read, or List + Detail)
44
- - Functional requirements: standard CRUD only (no advanced features)
45
- - Permission matrix: default 4-role (Admin, Manager, User, Guest)
46
- - Gherkin scenarios: basic happy path + one error case
47
- - No navigation hierarchy complexity
48
- - Minimal SeedData (only essential lookups)
49
-
50
- ---
51
-
52
- ## 3. Section 1: Define Actors & Permissions
53
-
54
- ### 3.1 Map Stakeholder Roles to System Actors
55
-
56
- From `feature.json.discovery.stakeholders[]`, create an **actors** section in specification:
57
-
58
- ```json
59
- {
60
- "specification": {
61
- "actors": [
62
- {
63
- "id": "ACTOR-001",
64
- "role": "Admin",
65
- "description": "System administrator with full control",
66
- "canDelegate": true,
67
- "basePermissions": ["Read", "Create", "Update", "Delete"]
68
- },
69
- {
70
- "id": "ACTOR-002",
71
- "role": "Manager",
72
- "description": "Module manager with approval authority",
73
- "canDelegate": false,
74
- "basePermissions": ["Read", "Create", "Update"]
75
- },
76
- {
77
- "id": "ACTOR-003",
78
- "role": "User",
79
- "description": "Standard user for daily operations",
80
- "canDelegate": false,
81
- "basePermissions": ["Read", "Create"]
82
- },
83
- {
84
- "id": "ACTOR-004",
85
- "role": "Guest",
86
- "description": "External user with minimal access",
87
- "canDelegate": false,
88
- "basePermissions": ["Read"]
89
- }
90
- ]
91
- }
92
- }
93
- ```
94
-
95
- ### 3.2 Define Permission Categories
96
-
97
- For each actor, enumerate:
98
-
99
- | Category | Examples | Notes |
100
- |----------|----------|-------|
101
- | **Read** | View list, View detail, Search, Export | Includes all retrieval operations |
102
- | **Create** | Add new record, Bulk import | Creation with initial state |
103
- | **Update** | Edit fields, Change status, Reassign | Update including state transitions |
104
- | **Delete** | Hard delete, Soft delete/Archive | Deletion or data removal |
105
- | **Approve** | Approve changes, Reject submissions | Workflow decisions |
106
- | **Delegate** | Assign task to another user | Transfer responsibility |
107
- | **Execute** | Trigger workflow, Process batch | Special actions |
108
-
109
- ---
110
-
111
- ## 4. Section 2: Create Use Cases (UC-XXX)
112
-
113
- ### 4.1 Format & Structure
114
-
115
- For each major user interaction, create a use case:
116
-
117
- ```markdown
118
- ### UC-001: List [Resource] by [Criteria]
119
-
120
- | Field | Value |
121
- |-------|-------|
122
- | **ID** | UC-001 |
123
- | **Title** | List [Module] by [Criteria] |
124
- | **Actor(s)** | User, Manager |
125
- | **Trigger** | User navigates to [Module] menu |
126
- | **Precondition** | User is authenticated and has Read permission |
127
- | **Main Flow** | 1. System loads records from database filtered by [criteria] \| 2. Display paginated results with [fields] \| 3. User can sort/filter further |
128
- | **Alternative Flow** | No records: Show empty state with message; User cancels: Return to previous screen |
129
- | **Postcondition** | List displayed; User can select record for detail view |
130
- | **Linked Rules** | BR-001, BR-003 |
131
-
132
- ```
133
-
134
- ### 4.2 Use Case Categories
135
-
136
- Organize around resource operations:
137
-
138
- | UC Type | Examples | Count |
139
- |---------|----------|-------|
140
- | **List/Search** | List Orders, Search Customers, Find Products | 1 per resource |
141
- | **Create** | Create Order, Add Customer, Register Employee | 1 per resource |
142
- | **Read Detail** | View Order details, Customer profile | 1 per resource |
143
- | **Update** | Edit Order, Modify Customer address | 1 per resource |
144
- | **Delete/Archive** | Cancel Order, Archive Customer | 0-1 per resource |
145
- | **Bulk Operations** | Bulk Import Orders, Export Customers | 0-1 per resource |
146
- | **Workflow** | Approve Order, Escalate Ticket | 1 per workflow |
147
- | **Reports** | Order Summary, Customer Analysis | 0-1 per module |
148
-
149
- **Micro mode:** Limit to UC-001 (List) and UC-002 (Create), or UC-001 (List) and UC-002 (Detail).
150
-
151
- ### 4.3 Link to Business Rules
152
-
153
- Each UC's "Linked Rules" field references `analysis.businessRules[].id`:
154
-
155
- ```json
156
- {
157
- "useCases": [
158
- {
159
- "id": "UC-001",
160
- "linkedRules": ["BR-001", "BR-003"]
161
- }
162
- ]
163
- }
164
- ```
165
-
166
- ---
167
-
168
- ## 5. Section 3: Define Functional Requirements (FR-XXX)
169
-
170
- ### 5.1 Format & Priorities
171
-
172
- For each capability, create an FR:
173
-
174
- ```json
175
- {
176
- "functionalRequirements": [
177
- {
178
- "id": "FR-001",
179
- "title": "Display [Resource] List",
180
- "description": "System shall display paginated list of [resources] with sortable/filterable columns",
181
- "priority": "MUST",
182
- "actor": "User",
183
- "linkedRules": ["BR-001"],
184
- "acceptance": [
185
- "List loads within 2 seconds",
186
- "Pagination supports 10/25/50 items per page",
187
- "User can sort by any column",
188
- "User can filter by [field1], [field2]"
189
- ]
190
- },
191
- {
192
- "id": "FR-002",
193
- "title": "Create [Resource] with Validation",
194
- "description": "System shall accept new [resource] creation with mandatory field validation",
195
- "priority": "MUST",
196
- "actor": "User",
197
- "linkedRules": ["BR-002", "BR-003"],
198
- "acceptance": [
199
- "All mandatory fields enforced on form",
200
- "Validation messages appear inline",
201
- "Submit button disabled until valid",
202
- "Success message on creation"
203
- ]
204
- }
205
- ]
206
- }
207
- ```
208
-
209
- ### 5.2 Priority Mapping
210
-
211
- | Priority | MOSCOW | Impact | Scheduling |
212
- |----------|--------|--------|-----------|
213
- | **MUST** | M (Must have) | Critical to MVP | Sprint N |
214
- | **SHOULD** | S (Should have) | High value, deferrable | Sprint N+1 |
215
- | **COULD** | C (Could have) | Nice-to-have | Backlog |
216
- | **WONT** | W (Won't have this time) | Out of scope | Future |
217
-
218
- **Micro mode:** All FRs have priority MUST (focus only on essential CRUD).
219
-
220
- ### 5.3 FR Anatomy
221
-
222
- Each FR includes:
223
- - **id:** FR-NNN (sequential)
224
- - **title:** [Verb] [Object] [Qualifier]
225
- - **description:** What the system shall do
226
- - **priority:** MUST/SHOULD/COULD/WONT
227
- - **actor:** Which actor initiates
228
- - **linkedRules:** References to BR-XXX identifiers
229
- - **acceptance:** Testable acceptance criteria
230
-
231
- ---
232
-
233
- ## 6. Section 4: Permission Matrix & Data Model
234
-
235
- ### 6.1 RBAC Matrix (Actors × Resources × Operations)
236
-
237
- Create a permission matrix for each resource:
238
-
239
- ```json
240
- {
241
- "permissionMatrix": [
242
- {
243
- "resource": "Order",
244
- "operations": [
245
- {
246
- "op": "Read",
247
- "Admin": true,
248
- "Manager": true,
249
- "User": true,
250
- "Guest": false
251
- },
252
- {
253
- "op": "Create",
254
- "Admin": true,
255
- "Manager": true,
256
- "User": true,
257
- "Guest": false
258
- },
259
- {
260
- "op": "Update",
261
- "Admin": true,
262
- "Manager": true,
263
- "User": false,
264
- "Guest": false
265
- },
266
- {
267
- "op": "Delete",
268
- "Admin": true,
269
- "Manager": false,
270
- "User": false,
271
- "Guest": false
272
- }
273
- ]
274
- }
275
- ]
276
- }
277
- ```
278
-
279
- **Micro mode:** 4-role matrix only (Admin, Manager, User, Guest).
280
-
281
- ### 6.2 Data Model Entities
282
-
283
- Define main entities and relationships:
284
-
285
- ```json
286
- {
287
- "entities": [
288
- {
289
- "name": "Order",
290
- "pluralName": "Orders",
291
- "description": "Purchase order entity",
292
- "fields": [
293
- {
294
- "name": "id",
295
- "type": "int",
296
- "required": true,
297
- "key": "primary"
298
- },
299
- {
300
- "name": "orderNumber",
301
- "type": "string",
302
- "required": true,
303
- "unique": true,
304
- "length": 20
305
- },
306
- {
307
- "name": "orderDate",
308
- "type": "datetime",
309
- "required": true
310
- },
311
- {
312
- "name": "status",
313
- "type": "enum",
314
- "values": ["Draft", "Submitted", "Approved", "Shipped", "Delivered", "Cancelled"],
315
- "default": "Draft"
316
- }
317
- ]
318
- }
319
- ]
320
- }
321
- ```
322
-
323
- ### 6.3 Navigation Hierarchy & UI Structure
324
-
325
- **CRITICAL: Define 5 Mandatory SeedData Tables**
326
-
327
- The navigation structure implies these mandatory SeedData tables:
328
-
329
- ```json
330
- {
331
- "navigationHierarchy": [
332
- {
333
- "level": 1,
334
- "menuItem": "Module Name",
335
- "icon": "icon-module",
336
- "route": "/module",
337
- "children": [
338
- {
339
- "level": 2,
340
- "menuItem": "List [Resource]",
341
- "route": "/module/list",
342
- "seedDataRequired": [
343
- "Module_Status (SeedData)",
344
- "Module_Priority (SeedData)",
345
- "Module_Category (SeedData)",
346
- "Module_Type (SeedData)",
347
- "Module_Department (SeedData)"
348
- ]
349
- },
350
- {
351
- "level": 2,
352
- "menuItem": "Create [Resource]",
353
- "route": "/module/create"
354
- },
355
- {
356
- "level": 2,
357
- "menuItem": "Reports",
358
- "route": "/module/reports",
359
- "children": [
360
- {
361
- "level": 3,
362
- "menuItem": "Daily Summary",
363
- "route": "/module/reports/daily"
364
- }
365
- ]
366
- }
367
- ]
368
- }
369
- ]
370
- }
371
- ```
372
-
373
- **5 Mandatory SeedData Tables:**
374
-
375
- 1. **Module_Status** - Record statuses (Draft, Approved, Published, Archived)
376
- 2. **Module_Priority** - Priority levels (High, Medium, Low)
377
- 3. **Module_Category** - Classification categories
378
- 4. **Module_Type** - Resource subtypes or classifications
379
- 5. **Module_Department** - Organizational units for filtering/access control
380
-
381
- These tables are:
382
- - Created in migrations before module features
383
- - Seeded with initial values (5-10 rows each)
384
- - Used in dropdowns and status filters throughout the UI
385
- - Referenced in validation and permission checks
386
-
387
- **Micro mode:** Minimal: Status and Category only. Skip Priority, Type, Department.
388
-
389
- ### 6.4 SeedData Core (OBLIGATOIRE)
390
-
391
- > **CRITIQUE :** Sans ces SeedData, le module sera invisible dans la navigation et toutes les API retourneront 403.
392
-
393
- En plus des 5 tables metier ci-dessus, generer une section `specification.seedDataCore` derivee automatiquement de `specification.navigation` et `specification.permissionMatrix` :
394
-
395
- ```json
396
- {
397
- "seedDataCore": {
398
- "navigationModules": [
399
- {
400
- "code": "fleet",
401
- "label": "Fleet Management",
402
- "icon": "Truck",
403
- "route": "/business/freebike/fleet",
404
- "parentCode": "freebike",
405
- "sort": 1
406
- }
407
- ],
408
- "navigationTranslations": [
409
- { "moduleCode": "fleet", "language": "fr", "label": "Gestion de Flotte" },
410
- { "moduleCode": "fleet", "language": "en", "label": "Fleet Management" }
411
- ],
412
- "permissions": [
413
- { "path": "business.freebike.fleetmanagement.vehicles.read", "action": "read", "description": "Consulter vehicules" }
414
- ],
415
- "rolePermissions": [
416
- { "role": "FreeBike Admin", "permissionPath": "business.freebike.fleetmanagement.*" },
417
- { "role": "FreeBike Manager", "permissionPath": "business.freebike.fleetmanagement.vehicles.read" }
418
- ],
419
- "permissionConstants": [
420
- { "constantName": "VehiclesRead", "path": "business.freebike.fleetmanagement.vehicles.read" }
421
- ]
422
- }
423
- }
424
- ```
425
-
426
- **Regles de derivation :**
427
-
428
- 1. **navigationModules** : Prendre chaque entree de `specification.navigation.entries[]` avec level = module ou section
429
- 2. **navigationTranslations** : Prendre chaque entree de navigation et generer une traduction par langue definie dans `labels`
430
- 3. **permissions** : Copier EXACTEMENT `specification.permissionMatrix.permissions[]` (chemins complets)
431
- 4. **rolePermissions** : Pour chaque `roleAssignments[]`, expander les wildcards et raccourcis en chemins complets. Chaque `permissionPath` DOIT correspondre a un `permissions[].path` existant
432
- 5. **permissionConstants** : Pour chaque permission, generer un nom PascalCase (ex: `business.freebike.fleetmanagement.vehicles.read` → `VehiclesRead`)
433
-
434
- **Verification :** Chaque `rolePermissions[].permissionPath` doit exister dans `permissions[].path`. Si un raccourci est utilise (ex: `vehicles.read` au lieu du chemin complet), c'est une ERREUR.
435
-
436
- **Micro mode :** Generer avec les permissions CRUD minimales pour le role Admin uniquement.
437
-
438
- ---
439
-
440
- ## 7. Section 5: UI Wireframes
441
-
442
- ### 7.1 Key Screens
443
-
444
- For each major UC, sketch wireframe structure:
445
-
446
- ```markdown
447
- ### Wireframe WF-001: List [Resource]
448
-
449
- **Location:** `/module/list`
450
-
451
- **Layout:**
452
- ```
453
- ┌─────────────────────────────────────────┐
454
- │ Module > List [Resource] │
455
- ├─────────────────────────────────────────┤
456
- │ [Search] [Filter ▼] [Add New] │
457
- ├─────────────────────────────────────────┤
458
- │ ┌─────┬──────────┬────┬──────┐ │
459
- │ │ ID │ Name │... │ Action│ │
460
- │ ├─────┼──────────┼────┼──────┤ │
461
- │ │ 001 │ Item 1 │... │ Edit │ │
462
- │ │ 002 │ Item 2 │... │ [⋮] │ │
463
- │ └─────┴──────────┴────┴──────┘ │
464
- │ │
465
- │ Page 1 of 10 [◀] [1][2][3]... [▶] │
466
- └─────────────────────────────────────────┘
467
- ```
468
-
469
- **Components:**
470
- - Header with breadcrumb
471
- - Filter bar (by Status, Category, etc.)
472
- - Sortable data table with [fields]
473
- - Row actions: Edit, View, Delete (context menu)
474
- - Pagination controls
475
- - Empty state: "No [resources] found"
476
-
477
- **Responsive:** Full width on desktop, card view on mobile.
478
- ```
479
-
480
- ### 7.2 Form Validation UI
481
-
482
- For Create/Update screens:
483
-
484
- ```markdown
485
- ### Wireframe WF-002: Create [Resource]
486
-
487
- **Location:** `/module/create`
488
-
489
- **Form Fields:**
490
- ```
491
- Field Name (required) *
492
- ┌──────────────────────────┐
493
- │ [text input] │ ✓
494
- └──────────────────────────┘
495
- Help text: [guidance]
496
-
497
- Status (required) *
498
- ┌──────────────────────────┐
499
- │ [Draft ▼] │
500
- └──────────────────────────┘
501
-
502
- [Cancel] [Save]
503
- ```
504
-
505
- **Validations:**
506
- - Field Name: required, max 100 chars, no special characters (inline validation)
507
- - Status: required, dropdown only (no free text)
508
- - On submit: If invalid, highlight fields and show error messages above form
509
- - On success: Show success toast and navigate to detail view
510
- ```
511
-
512
- ---
513
-
514
- ## 8. Section 6: Gherkin Scenarios (BDD)
515
-
516
- ### 8.1 Feature Definition
517
-
518
- Write acceptance criteria in Gherkin format:
519
-
520
- ```gherkin
521
- Feature: Order Management - List Orders
522
- As a User
523
- I want to view a paginated list of orders
524
- So that I can find and manage orders efficiently
525
-
526
- Scenario: User views default order list
527
- Given I am logged in as a User
528
- And I have Read permission on Orders
529
- When I navigate to /orders
530
- Then I should see the order list
531
- And results should be sorted by OrderDate descending
532
- And page size should default to 25 items
533
- And I should see pagination controls
534
-
535
- Scenario: User filters orders by status
536
- Given I am on the order list page
537
- And there are orders with different statuses
538
- When I select "Approved" from Status filter
539
- And I click Apply
540
- Then only Approved orders should be displayed
541
- And the filter should remain active on the page
542
-
543
- Scenario: User searches for specific order
544
- Given I am on the order list page
545
- When I enter "ORD-001" in the search box
546
- And I press Enter
547
- Then only matching orders should be displayed
548
- And search term should appear in the search box
549
-
550
- Scenario: Empty state when no orders exist
551
- Given I am on the order list page
552
- And no orders exist in the system
553
- Then I should see "No orders found"
554
- And I should see "Create New Order" button
555
- And pagination should not be visible
556
- ```
557
-
558
- **Gherkin Rules:**
559
- - **Feature:** Module-level behavior
560
- - **Scenario:** Individual test case (happy path or alternative)
561
- - **Given:** Initial state/preconditions
562
- - **When:** User action
563
- - **Then:** Expected outcome
564
- - **And:** Additional steps in same context
565
-
566
- **Micro mode:** 2 scenarios max: happy path (List works) + one error case (empty state, validation failure).
567
-
568
- ### 8.2 Scenario Categories
569
-
570
- | Category | Count | Examples |
571
- |----------|-------|----------|
572
- | **Happy Path** | 1 per UC | Normal operation succeeds |
573
- | **Alternative Flows** | 1-2 per UC | Empty state, no permission, etc. |
574
- | **Validation** | 1 per form | Invalid input rejected with message |
575
- | **Edge Cases** | 0-1 per UC | Boundary values, special characters |
576
- | **Error Handling** | 1 per UC | Server error, network failure |
577
-
578
- ---
579
-
580
- ## 9. Section 7: Validations & Business Messages
581
-
582
- ### 9.1 Field Validations
583
-
584
- For each input field, specify validation rules:
585
-
586
- ```json
587
- {
588
- "validations": [
589
- {
590
- "fieldName": "OrderNumber",
591
- "rules": [
592
- {
593
- "type": "required",
594
- "message": "Order number is required"
595
- },
596
- {
597
- "type": "unique",
598
- "scope": "Order",
599
- "message": "This order number already exists"
600
- },
601
- {
602
- "type": "pattern",
603
- "pattern": "^ORD-\\d{6}$",
604
- "message": "Format must be ORD-XXXXXX (e.g., ORD-001234)"
605
- },
606
- {
607
- "type": "maxLength",
608
- "maxLength": 20,
609
- "message": "Order number cannot exceed 20 characters"
610
- }
611
- ]
612
- },
613
- {
614
- "fieldName": "OrderDate",
615
- "rules": [
616
- {
617
- "type": "required",
618
- "message": "Order date is required"
619
- },
620
- {
621
- "type": "notFuture",
622
- "message": "Order date cannot be in the future"
623
- }
624
- ]
625
- }
626
- ]
627
- }
628
- ```
629
-
630
- ### 9.2 Business Messages (OBLIGATOIRE - minimum 4 messages)
631
-
632
- > **OBLIGATOIRE :** Generer au minimum 4 messages metier dans `specification.messages[]` :
633
- > - 1 success (ex: RESOURCE_CREATED_SUCCESS)
634
- > - 1 error CRUD (ex: RESOURCE_CREATION_FAILED)
635
- > - 1 error validation (ex: RESOURCE_NOT_FOUND)
636
- > - 1 error permission (ex: PERMISSION_DENIED)
637
- >
638
- > Pour les modules complexes, ajouter des messages warning (ex: STOCK_LOW_WARNING, SYNC_FAILED_WARNING).
639
-
640
- Define user-facing messages for operations:
641
-
642
- ```json
643
- {
644
- "messages": [
645
- {
646
- "code": "ORDER_CREATED_SUCCESS",
647
- "type": "success",
648
- "title": "Order Created",
649
- "message": "Order {orderNumber} was created successfully.",
650
- "i18nKey": "orders.messages.createdSuccess"
651
- },
652
- {
653
- "code": "ORDER_CREATION_FAILED",
654
- "type": "error",
655
- "title": "Creation Failed",
656
- "message": "Unable to create order. Please check your input and try again.",
657
- "i18nKey": "orders.messages.creationFailed"
658
- },
659
- {
660
- "code": "ORDER_NOT_FOUND",
661
- "type": "error",
662
- "title": "Not Found",
663
- "message": "Order {id} does not exist.",
664
- "i18nKey": "orders.messages.notFound"
665
- },
666
- {
667
- "code": "PERMISSION_DENIED",
668
- "type": "error",
669
- "title": "Access Denied",
670
- "message": "You do not have permission to {action} this order.",
671
- "i18nKey": "common.messages.permissionDenied"
672
- }
673
- ]
674
- }
675
- ```
676
-
677
- ---
678
-
679
- ## 10. Section 8: Data Lifecycle & Cross-Module Patterns
680
-
681
- ### 10.1 Entity Lifecycle States (OBLIGATOIRE - minimum 1 entite)
682
-
683
- > **OBLIGATOIRE :** Pour chaque entite ayant un attribut `Status` ou `State` (enum), definir une state machine dans `specification.lifeCycles[]`.
684
- > Identifier les entites candidates en parcourant `analysis.entities[].attributes[]` pour trouver celles avec un champ de type enum representant un statut.
685
- > Minimum : 1 entite avec state machine. Pour un full-module, typiquement 2-4 entites.
686
-
687
- Define state transitions for key entities:
688
-
689
- ```json
690
- {
691
- "lifeCycles": [
692
- {
693
- "entity": "Order",
694
- "states": [
695
- {
696
- "id": "Draft",
697
- "displayName": "Draft",
698
- "description": "Order created but not yet submitted",
699
- "allowedTransitions": ["Submitted", "Cancelled"],
700
- "visibility": "Creator only"
701
- },
702
- {
703
- "id": "Submitted",
704
- "displayName": "Submitted for Review",
705
- "description": "Order awaiting approval",
706
- "allowedTransitions": ["Approved", "Rejected", "Cancelled"],
707
- "visibility": "Creator + Manager",
708
- "requiresApproval": true
709
- },
710
- {
711
- "id": "Approved",
712
- "displayName": "Approved",
713
- "description": "Order approved and ready for fulfillment",
714
- "allowedTransitions": ["Shipped", "Cancelled"],
715
- "visibility": "All",
716
- "triggerAction": "CreateFulfillmentTask"
717
- },
718
- {
719
- "id": "Shipped",
720
- "displayName": "Shipped",
721
- "description": "Order dispatched to customer",
722
- "allowedTransitions": ["Delivered", "Cancelled"],
723
- "visibility": "All"
724
- },
725
- {
726
- "id": "Delivered",
727
- "displayName": "Delivered",
728
- "description": "Order received by customer",
729
- "allowedTransitions": ["Archived"],
730
- "visibility": "All",
731
- "isTerminal": true
732
- },
733
- {
734
- "id": "Cancelled",
735
- "displayName": "Cancelled",
736
- "description": "Order cancelled",
737
- "allowedTransitions": [],
738
- "visibility": "All",
739
- "isTerminal": true
740
- }
741
- ]
742
- }
743
- ]
744
- }
745
- ```
746
-
747
- ### 10.2 Cross-Module Dependencies
748
-
749
- Document how this module interacts with others:
750
-
751
- ```json
752
- {
753
- "crossModuleDependencies": [
754
- {
755
- "module": "Orders",
756
- "dependsOn": "Customers",
757
- "relationship": "Foreign key: Order.CustomerId → Customer.Id",
758
- "synchronization": "Order.CustomerName auto-updates when Customer.Name changes",
759
- "validation": "CustomerId must exist in Customers table",
760
- "cascadeDelete": false
761
- },
762
- {
763
- "module": "Orders",
764
- "dependsOn": "Inventory",
765
- "relationship": "Order creates InventoryMovement records",
766
- "synchronization": "When Order status = Shipped, Inventory.OnHand decreases",
767
- "validation": "Order cannot be approved if inventory insufficient",
768
- "cascadeDelete": false
769
- }
770
- ]
771
- }
772
- ```
773
-
774
- ### 10.3 Audit & Archival
775
-
776
- Document data retention and auditing:
777
-
778
- ```json
779
- {
780
- "auditingPolicy": {
781
- "enabled": true,
782
- "trackFields": ["OrderNumber", "Status", "OrderDate", "TotalAmount"],
783
- "retentionDays": 2555,
784
- "archivalRule": "Orders older than 7 years are archived to cold storage"
785
- },
786
- "archivalPolicy": {
787
- "enabled": true,
788
- "archiveAfterDays": 2555,
789
- "archiveLocation": "Archive_Orders table",
790
- "restoreCapability": true
791
- }
792
- }
793
- ```
794
-
795
- ---
796
-
797
- ## 11. Execution Workflow
798
-
799
- ### 11.1 Information Gathering
800
-
801
- 1. **Load feature.json** via `ba-reader`:
802
- - feature.json.scope.* - User goals and constraints
803
- - feature.json.analysis.* - Business rules, stakeholder roles
804
-
805
- 2. **Clarify with user:**
806
- - Confirm actor roles and permission levels
807
- - Validate use case scope (too many? combine?)
808
- - Confirm resource state transitions
809
- - Verify SeedData needs
810
-
811
- ### 11.2 Specification Generation
812
-
813
- 1. **Define actors** - Map to system roles with base permissions
814
- 2. **Create use cases** - UC-001, UC-002, ... in order of importance
815
- 3. **Define FRs** - FR-001, FR-002, ... linked to BRs
816
- 4. **Build permission matrix** - Actor × Resource × Operation
817
- 5. **Design UI structure** - 5 mandatory SeedData tables, navigation hierarchy
818
- 6. **Sketch wireframes** - Key screens (List, Create, Detail)
819
- 7. **Write Gherkin** - BDD scenarios for each UC
820
- 8. **Define validations** - Field rules and business messages
821
- 9. **Model lifecycle** - State machines, cross-module sync
822
- 10. **Document dependencies** - External modules, cascading operations
823
-
824
- ### 11.3 Data Model Validation
825
-
826
- Ensure:
827
- - No duplicate entity definitions
828
- - All FK relationships defined
829
- - All required fields marked
830
- - Enum values match business rules
831
-
832
- ---
833
-
834
- ## 12. Output & Status Update
835
-
836
- ### 12.1 Write Specification Section
837
-
838
- Use `ba-writer.updateSpecification()` to write:
839
-
840
- > **INTERDIT :** Ne JAMAIS generer de fichier `specification.json` separe. Toute la specification DOIT rester dans `feature.json.specification`. Un fichier specification.json separe cree une double source de verite et sera ecrase/ignore.
841
-
842
- ```json
843
- {
844
- "specification": {
845
- "actors": [...],
846
- "useCases": [...],
847
- "functionalRequirements": [...],
848
- "permissionMatrix": [...],
849
- "entities": [...],
850
- "navigationHierarchy": [...],
851
- "wireframes": [...],
852
- "gherkinScenarios": [...],
853
- "validations": [...],
854
- "messages": [...],
855
- "lifeCycles": [...],
856
- "seedDataCore": {...},
857
- "crossModuleDependencies": [...],
858
- "auditingPolicy": {...},
859
- "archivalPolicy": {...}
860
- }
861
- }
862
- ```
863
-
864
- ### 12.2 Update Status
865
-
866
- Use `ba-writer.updateStatus("specified")` to mark specification complete.
867
-
868
- ### 12.3 User Confirmation
869
-
870
- Summarize for user:
871
-
872
- ```
873
- ✓ Specification complete
874
-
875
- Actors defined: 4 (Admin, Manager, User, Guest)
876
- Use cases created: 8 (UC-001 → UC-008)
877
- Requirements: 12 FRs linked to business rules
878
- Permission matrix: 3 resources × 4 actors
879
- SeedData tables: 5 mandatory (Status, Priority, Category, Type, Department)
880
- SeedData Core: 5 files (Navigation, Translations, Permissions, RolePermissions, Constants)
881
- Messages: 6 business messages (success, error, warning)
882
- UI screens: 6 wireframes (List, Create, Detail, Reports, etc.)
883
- Gherkin scenarios: 18 scenarios across all UCs
884
- Validations: 24 field validation rules
885
- Entity lifecycle: 3 entities with state machines
886
-
887
- Next step: Validation (step-03-validate.md)
888
- ```
889
-
890
- ---
891
-
892
- ## OUTPUT
893
-
894
- This step enriches **feature.json** with:
895
- - **specification** section containing actors, use cases, functional requirements, permission matrix, entities, navigation hierarchy, wireframes, Gherkin scenarios, validations, and data lifecycle
896
- - **Status:** "specified"
897
-
898
- **Delta mode:** Only affected UCs/FRs/permissions modified; existing ones preserved.
899
- **Micro mode:** Minimal specification with 1-2 UCs, 4-role permissions, basic CRUD FRs, essential SeedData only.