@atlashub/smartstack-cli 2.1.0 → 2.2.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 (35) hide show
  1. package/dist/index.js +18 -10
  2. package/dist/index.js.map +1 -1
  3. package/package.json +1 -1
  4. package/templates/agents/ba-reader.md +250 -0
  5. package/templates/agents/ba-writer.md +210 -0
  6. package/templates/agents/docs-context-reader.md +51 -33
  7. package/templates/skills/_shared.md +2 -0
  8. package/templates/skills/business-analyse/SKILL.md +120 -108
  9. package/templates/skills/business-analyse/_shared.md +136 -146
  10. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +478 -0
  11. package/templates/skills/business-analyse/questionnaire/01-context.md +3 -15
  12. package/templates/skills/business-analyse/questionnaire/08-performance.md +7 -21
  13. package/templates/skills/business-analyse/questionnaire/09-constraints.md +0 -13
  14. package/templates/skills/business-analyse/questionnaire/10-documentation.md +0 -13
  15. package/templates/skills/business-analyse/questionnaire.md +72 -76
  16. package/templates/skills/business-analyse/react/components.md +317 -154
  17. package/templates/skills/business-analyse/react/i18n-template.md +167 -106
  18. package/templates/skills/business-analyse/react/schema.md +325 -106
  19. package/templates/skills/business-analyse/schemas/feature-schema.json +690 -0
  20. package/templates/skills/business-analyse/steps/step-00-init.md +395 -285
  21. package/templates/skills/business-analyse/steps/step-01-analyse.md +505 -0
  22. package/templates/skills/business-analyse/steps/step-02-specify.md +833 -0
  23. package/templates/skills/business-analyse/steps/step-03-validate.md +862 -0
  24. package/templates/skills/business-analyse/steps/step-04-handoff.md +1593 -0
  25. package/templates/skills/business-analyse/templates/tpl-handoff.md +39 -63
  26. package/templates/skills/business-analyse/steps/step-01-discover.md +0 -737
  27. package/templates/skills/business-analyse/steps/step-02-analyse.md +0 -299
  28. package/templates/skills/business-analyse/steps/step-03-specify.md +0 -472
  29. package/templates/skills/business-analyse/steps/step-04-validate.md +0 -335
  30. package/templates/skills/business-analyse/steps/step-05-handoff.md +0 -741
  31. package/templates/skills/business-analyse/steps/step-06-doc-html.md +0 -320
  32. package/templates/skills/business-analyse/templates/00-context.md +0 -105
  33. package/templates/skills/business-analyse/templates/tpl-brd.md +0 -97
  34. package/templates/skills/business-analyse/templates/tpl-discovery.md +0 -78
  35. package/templates/skills/business-analyse/tracking/change-template.md +0 -30
@@ -0,0 +1,833 @@
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
+ ---
390
+
391
+ ## 7. Section 5: UI Wireframes
392
+
393
+ ### 7.1 Key Screens
394
+
395
+ For each major UC, sketch wireframe structure:
396
+
397
+ ```markdown
398
+ ### Wireframe WF-001: List [Resource]
399
+
400
+ **Location:** `/module/list`
401
+
402
+ **Layout:**
403
+ ```
404
+ ┌─────────────────────────────────────────┐
405
+ │ Module > List [Resource] │
406
+ ├─────────────────────────────────────────┤
407
+ │ [Search] [Filter ▼] [Add New] │
408
+ ├─────────────────────────────────────────┤
409
+ │ ┌─────┬──────────┬────┬──────┐ │
410
+ │ │ ID │ Name │... │ Action│ │
411
+ │ ├─────┼──────────┼────┼──────┤ │
412
+ │ │ 001 │ Item 1 │... │ Edit │ │
413
+ │ │ 002 │ Item 2 │... │ [⋮] │ │
414
+ │ └─────┴──────────┴────┴──────┘ │
415
+ │ │
416
+ │ Page 1 of 10 [◀] [1][2][3]... [▶] │
417
+ └─────────────────────────────────────────┘
418
+ ```
419
+
420
+ **Components:**
421
+ - Header with breadcrumb
422
+ - Filter bar (by Status, Category, etc.)
423
+ - Sortable data table with [fields]
424
+ - Row actions: Edit, View, Delete (context menu)
425
+ - Pagination controls
426
+ - Empty state: "No [resources] found"
427
+
428
+ **Responsive:** Full width on desktop, card view on mobile.
429
+ ```
430
+
431
+ ### 7.2 Form Validation UI
432
+
433
+ For Create/Update screens:
434
+
435
+ ```markdown
436
+ ### Wireframe WF-002: Create [Resource]
437
+
438
+ **Location:** `/module/create`
439
+
440
+ **Form Fields:**
441
+ ```
442
+ Field Name (required) *
443
+ ┌──────────────────────────┐
444
+ │ [text input] │ ✓
445
+ └──────────────────────────┘
446
+ Help text: [guidance]
447
+
448
+ Status (required) *
449
+ ┌──────────────────────────┐
450
+ │ [Draft ▼] │
451
+ └──────────────────────────┘
452
+
453
+ [Cancel] [Save]
454
+ ```
455
+
456
+ **Validations:**
457
+ - Field Name: required, max 100 chars, no special characters (inline validation)
458
+ - Status: required, dropdown only (no free text)
459
+ - On submit: If invalid, highlight fields and show error messages above form
460
+ - On success: Show success toast and navigate to detail view
461
+ ```
462
+
463
+ ---
464
+
465
+ ## 8. Section 6: Gherkin Scenarios (BDD)
466
+
467
+ ### 8.1 Feature Definition
468
+
469
+ Write acceptance criteria in Gherkin format:
470
+
471
+ ```gherkin
472
+ Feature: Order Management - List Orders
473
+ As a User
474
+ I want to view a paginated list of orders
475
+ So that I can find and manage orders efficiently
476
+
477
+ Scenario: User views default order list
478
+ Given I am logged in as a User
479
+ And I have Read permission on Orders
480
+ When I navigate to /orders
481
+ Then I should see the order list
482
+ And results should be sorted by OrderDate descending
483
+ And page size should default to 25 items
484
+ And I should see pagination controls
485
+
486
+ Scenario: User filters orders by status
487
+ Given I am on the order list page
488
+ And there are orders with different statuses
489
+ When I select "Approved" from Status filter
490
+ And I click Apply
491
+ Then only Approved orders should be displayed
492
+ And the filter should remain active on the page
493
+
494
+ Scenario: User searches for specific order
495
+ Given I am on the order list page
496
+ When I enter "ORD-001" in the search box
497
+ And I press Enter
498
+ Then only matching orders should be displayed
499
+ And search term should appear in the search box
500
+
501
+ Scenario: Empty state when no orders exist
502
+ Given I am on the order list page
503
+ And no orders exist in the system
504
+ Then I should see "No orders found"
505
+ And I should see "Create New Order" button
506
+ And pagination should not be visible
507
+ ```
508
+
509
+ **Gherkin Rules:**
510
+ - **Feature:** Module-level behavior
511
+ - **Scenario:** Individual test case (happy path or alternative)
512
+ - **Given:** Initial state/preconditions
513
+ - **When:** User action
514
+ - **Then:** Expected outcome
515
+ - **And:** Additional steps in same context
516
+
517
+ **Micro mode:** 2 scenarios max: happy path (List works) + one error case (empty state, validation failure).
518
+
519
+ ### 8.2 Scenario Categories
520
+
521
+ | Category | Count | Examples |
522
+ |----------|-------|----------|
523
+ | **Happy Path** | 1 per UC | Normal operation succeeds |
524
+ | **Alternative Flows** | 1-2 per UC | Empty state, no permission, etc. |
525
+ | **Validation** | 1 per form | Invalid input rejected with message |
526
+ | **Edge Cases** | 0-1 per UC | Boundary values, special characters |
527
+ | **Error Handling** | 1 per UC | Server error, network failure |
528
+
529
+ ---
530
+
531
+ ## 9. Section 7: Validations & Business Messages
532
+
533
+ ### 9.1 Field Validations
534
+
535
+ For each input field, specify validation rules:
536
+
537
+ ```json
538
+ {
539
+ "validations": [
540
+ {
541
+ "fieldName": "OrderNumber",
542
+ "rules": [
543
+ {
544
+ "type": "required",
545
+ "message": "Order number is required"
546
+ },
547
+ {
548
+ "type": "unique",
549
+ "scope": "Order",
550
+ "message": "This order number already exists"
551
+ },
552
+ {
553
+ "type": "pattern",
554
+ "pattern": "^ORD-\\d{6}$",
555
+ "message": "Format must be ORD-XXXXXX (e.g., ORD-001234)"
556
+ },
557
+ {
558
+ "type": "maxLength",
559
+ "maxLength": 20,
560
+ "message": "Order number cannot exceed 20 characters"
561
+ }
562
+ ]
563
+ },
564
+ {
565
+ "fieldName": "OrderDate",
566
+ "rules": [
567
+ {
568
+ "type": "required",
569
+ "message": "Order date is required"
570
+ },
571
+ {
572
+ "type": "notFuture",
573
+ "message": "Order date cannot be in the future"
574
+ }
575
+ ]
576
+ }
577
+ ]
578
+ }
579
+ ```
580
+
581
+ ### 9.2 Business Messages
582
+
583
+ Define user-facing messages for operations:
584
+
585
+ ```json
586
+ {
587
+ "messages": [
588
+ {
589
+ "code": "ORDER_CREATED_SUCCESS",
590
+ "type": "success",
591
+ "title": "Order Created",
592
+ "message": "Order {orderNumber} was created successfully.",
593
+ "i18nKey": "orders.messages.createdSuccess"
594
+ },
595
+ {
596
+ "code": "ORDER_CREATION_FAILED",
597
+ "type": "error",
598
+ "title": "Creation Failed",
599
+ "message": "Unable to create order. Please check your input and try again.",
600
+ "i18nKey": "orders.messages.creationFailed"
601
+ },
602
+ {
603
+ "code": "ORDER_NOT_FOUND",
604
+ "type": "error",
605
+ "title": "Not Found",
606
+ "message": "Order {id} does not exist.",
607
+ "i18nKey": "orders.messages.notFound"
608
+ },
609
+ {
610
+ "code": "PERMISSION_DENIED",
611
+ "type": "error",
612
+ "title": "Access Denied",
613
+ "message": "You do not have permission to {action} this order.",
614
+ "i18nKey": "common.messages.permissionDenied"
615
+ }
616
+ ]
617
+ }
618
+ ```
619
+
620
+ ---
621
+
622
+ ## 10. Section 8: Data Lifecycle & Cross-Module Patterns
623
+
624
+ ### 10.1 Entity Lifecycle States
625
+
626
+ Define state transitions for key entities:
627
+
628
+ ```json
629
+ {
630
+ "lifeCycles": [
631
+ {
632
+ "entity": "Order",
633
+ "states": [
634
+ {
635
+ "id": "Draft",
636
+ "displayName": "Draft",
637
+ "description": "Order created but not yet submitted",
638
+ "allowedTransitions": ["Submitted", "Cancelled"],
639
+ "visibility": "Creator only"
640
+ },
641
+ {
642
+ "id": "Submitted",
643
+ "displayName": "Submitted for Review",
644
+ "description": "Order awaiting approval",
645
+ "allowedTransitions": ["Approved", "Rejected", "Cancelled"],
646
+ "visibility": "Creator + Manager",
647
+ "requiresApproval": true
648
+ },
649
+ {
650
+ "id": "Approved",
651
+ "displayName": "Approved",
652
+ "description": "Order approved and ready for fulfillment",
653
+ "allowedTransitions": ["Shipped", "Cancelled"],
654
+ "visibility": "All",
655
+ "triggerAction": "CreateFulfillmentTask"
656
+ },
657
+ {
658
+ "id": "Shipped",
659
+ "displayName": "Shipped",
660
+ "description": "Order dispatched to customer",
661
+ "allowedTransitions": ["Delivered", "Cancelled"],
662
+ "visibility": "All"
663
+ },
664
+ {
665
+ "id": "Delivered",
666
+ "displayName": "Delivered",
667
+ "description": "Order received by customer",
668
+ "allowedTransitions": ["Archived"],
669
+ "visibility": "All",
670
+ "isTerminal": true
671
+ },
672
+ {
673
+ "id": "Cancelled",
674
+ "displayName": "Cancelled",
675
+ "description": "Order cancelled",
676
+ "allowedTransitions": [],
677
+ "visibility": "All",
678
+ "isTerminal": true
679
+ }
680
+ ]
681
+ }
682
+ ]
683
+ }
684
+ ```
685
+
686
+ ### 10.2 Cross-Module Dependencies
687
+
688
+ Document how this module interacts with others:
689
+
690
+ ```json
691
+ {
692
+ "crossModuleDependencies": [
693
+ {
694
+ "module": "Orders",
695
+ "dependsOn": "Customers",
696
+ "relationship": "Foreign key: Order.CustomerId → Customer.Id",
697
+ "synchronization": "Order.CustomerName auto-updates when Customer.Name changes",
698
+ "validation": "CustomerId must exist in Customers table",
699
+ "cascadeDelete": false
700
+ },
701
+ {
702
+ "module": "Orders",
703
+ "dependsOn": "Inventory",
704
+ "relationship": "Order creates InventoryMovement records",
705
+ "synchronization": "When Order status = Shipped, Inventory.OnHand decreases",
706
+ "validation": "Order cannot be approved if inventory insufficient",
707
+ "cascadeDelete": false
708
+ }
709
+ ]
710
+ }
711
+ ```
712
+
713
+ ### 10.3 Audit & Archival
714
+
715
+ Document data retention and auditing:
716
+
717
+ ```json
718
+ {
719
+ "auditingPolicy": {
720
+ "enabled": true,
721
+ "trackFields": ["OrderNumber", "Status", "OrderDate", "TotalAmount"],
722
+ "retentionDays": 2555,
723
+ "archivalRule": "Orders older than 7 years are archived to cold storage"
724
+ },
725
+ "archivalPolicy": {
726
+ "enabled": true,
727
+ "archiveAfterDays": 2555,
728
+ "archiveLocation": "Archive_Orders table",
729
+ "restoreCapability": true
730
+ }
731
+ }
732
+ ```
733
+
734
+ ---
735
+
736
+ ## 11. Execution Workflow
737
+
738
+ ### 11.1 Information Gathering
739
+
740
+ 1. **Load feature.json** via `ba-reader`:
741
+ - feature.json.scope.* - User goals and constraints
742
+ - feature.json.analysis.* - Business rules, stakeholder roles
743
+
744
+ 2. **Clarify with user:**
745
+ - Confirm actor roles and permission levels
746
+ - Validate use case scope (too many? combine?)
747
+ - Confirm resource state transitions
748
+ - Verify SeedData needs
749
+
750
+ ### 11.2 Specification Generation
751
+
752
+ 1. **Define actors** - Map to system roles with base permissions
753
+ 2. **Create use cases** - UC-001, UC-002, ... in order of importance
754
+ 3. **Define FRs** - FR-001, FR-002, ... linked to BRs
755
+ 4. **Build permission matrix** - Actor × Resource × Operation
756
+ 5. **Design UI structure** - 5 mandatory SeedData tables, navigation hierarchy
757
+ 6. **Sketch wireframes** - Key screens (List, Create, Detail)
758
+ 7. **Write Gherkin** - BDD scenarios for each UC
759
+ 8. **Define validations** - Field rules and business messages
760
+ 9. **Model lifecycle** - State machines, cross-module sync
761
+ 10. **Document dependencies** - External modules, cascading operations
762
+
763
+ ### 11.3 Data Model Validation
764
+
765
+ Ensure:
766
+ - No duplicate entity definitions
767
+ - All FK relationships defined
768
+ - All required fields marked
769
+ - Enum values match business rules
770
+
771
+ ---
772
+
773
+ ## 12. Output & Status Update
774
+
775
+ ### 12.1 Write Specification Section
776
+
777
+ Use `ba-writer.updateSpecification()` to write:
778
+
779
+ ```json
780
+ {
781
+ "specification": {
782
+ "actors": [...],
783
+ "useCases": [...],
784
+ "functionalRequirements": [...],
785
+ "permissionMatrix": [...],
786
+ "entities": [...],
787
+ "navigationHierarchy": [...],
788
+ "wireframes": [...],
789
+ "gherkinScenarios": [...],
790
+ "validations": [...],
791
+ "messages": [...],
792
+ "lifeCycles": [...],
793
+ "crossModuleDependencies": [...],
794
+ "auditingPolicy": {...},
795
+ "archivalPolicy": {...}
796
+ }
797
+ }
798
+ ```
799
+
800
+ ### 12.2 Update Status
801
+
802
+ Use `ba-writer.updateStatus("specified")` to mark specification complete.
803
+
804
+ ### 12.3 User Confirmation
805
+
806
+ Summarize for user:
807
+
808
+ ```
809
+ ✓ Specification complete
810
+
811
+ Actors defined: 4 (Admin, Manager, User, Guest)
812
+ Use cases created: 8 (UC-001 → UC-008)
813
+ Requirements: 12 FRs linked to business rules
814
+ Permission matrix: 3 resources × 4 actors
815
+ SeedData tables: 5 mandatory (Status, Priority, Category, Type, Department)
816
+ UI screens: 6 wireframes (List, Create, Detail, Reports, etc.)
817
+ Gherkin scenarios: 18 scenarios across all UCs
818
+ Validations: 24 field validation rules
819
+ Entity lifecycle: 3 entities with state machines
820
+
821
+ Next step: Validation (step-03-validate.md)
822
+ ```
823
+
824
+ ---
825
+
826
+ ## OUTPUT
827
+
828
+ This step enriches **feature.json** with:
829
+ - **specification** section containing actors, use cases, functional requirements, permission matrix, entities, navigation hierarchy, wireframes, Gherkin scenarios, validations, and data lifecycle
830
+ - **Status:** "specified"
831
+
832
+ **Delta mode:** Only affected UCs/FRs/permissions modified; existing ones preserved.
833
+ **Micro mode:** Minimal specification with 1-2 UCs, 4-role permissions, basic CRUD FRs, essential SeedData only.