olympus-ai 4.5.13 → 4.5.14

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 (49) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/cli/index.js +63 -27
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/hooks/olympus-hooks.cjs +257 -257
  5. package/dist/installer/hooks.d.ts +47 -14
  6. package/dist/installer/hooks.d.ts.map +1 -1
  7. package/dist/installer/hooks.js +45 -77
  8. package/dist/installer/hooks.js.map +1 -1
  9. package/dist/installer/index.d.ts +8 -7
  10. package/dist/installer/index.d.ts.map +1 -1
  11. package/dist/installer/index.js +49 -46
  12. package/dist/installer/index.js.map +1 -1
  13. package/package.json +1 -1
  14. package/resources/config/risk-keywords.json +5 -5
  15. package/resources/rules/common/ascii-diagram-standards.md +115 -115
  16. package/resources/rules/common/content-validation.md +131 -131
  17. package/resources/rules/common/error-handling.md +430 -430
  18. package/resources/rules/common/markdown-formatting.md +170 -170
  19. package/resources/rules/common/overconfidence-prevention.md +100 -100
  20. package/resources/rules/common/pathway-behaviors.json +60 -60
  21. package/resources/rules/common/pathway-behaviors.md +100 -100
  22. package/resources/rules/common/process-overview.md +157 -157
  23. package/resources/rules/common/terminal-formatting.md +161 -161
  24. package/resources/rules/common/terminology.md +189 -189
  25. package/resources/rules/common/welcome-message.md +118 -118
  26. package/resources/rules/common/workflow-changes.md +285 -285
  27. package/resources/rules/construction/bolt-planning.md +153 -153
  28. package/resources/rules/construction/bolt-review.md +143 -143
  29. package/resources/rules/construction/build-and-test.md +527 -527
  30. package/resources/rules/construction/code-generation.md +414 -414
  31. package/resources/rules/construction/documentation.md +201 -201
  32. package/resources/rules/construction/functional-design.md +135 -135
  33. package/resources/rules/construction/infrastructure-design.md +110 -110
  34. package/resources/rules/construction/nfr-design.md +106 -106
  35. package/resources/rules/construction/nfr-requirements.md +118 -118
  36. package/resources/rules/construction/test-generation.md +112 -112
  37. package/resources/rules/core-workflow.md +196 -196
  38. package/resources/rules/inception/application-design.md +195 -195
  39. package/resources/rules/inception/bolt-planning.md +588 -588
  40. package/resources/rules/inception/reverse-engineering.md +354 -354
  41. package/resources/rules/inception/units-generation.md +505 -505
  42. package/resources/rules/inception/user-stories.md +527 -527
  43. package/resources/rules/inception/workspace-detection.md +82 -82
  44. package/resources/rules/operations/operations.md +19 -19
  45. package/resources/skills/brief/templates/ai-dlc-intent-brief-template.md +149 -149
  46. package/resources/skills/getting-started/SKILL.md +79 -79
  47. package/resources/templates/construction/bolt-spec-template.md +270 -270
  48. package/resources/templates/inception/unit-brief-template.md +188 -188
  49. package/resources/templates/inception/units-template.md +99 -99
@@ -1,505 +1,505 @@
1
- # Units Generation - Detailed Steps
2
-
3
- ## Overview
4
-
5
- This stage decomposes the system into manageable units of work through two integrated parts:
6
- - **Part 1 - Planning**: Perform domain analysis, apply decomposition criteria, create decomposition plan with questions, collect answers, analyze for ambiguities, get approval
7
- - **Part 2 - Generation**: Execute approved plan to generate unit artifacts following canonical templates
8
-
9
- **Goal**: Decompose the intent into independently deployable units of work based on domain boundaries and architectural concerns. Each unit should represent a cohesive bounded context with clear interfaces. Requirements and stories are then *assigned* to units for traceability — but units are defined by domain boundaries, not by story grouping. Story grouping into execution sessions is Bolt Planning's job.
10
-
11
- **DEFINITION**: A unit of work is an independently deployable domain boundary derived from the intent. For microservices, each unit becomes a separate service. For monoliths, each unit is a logically independent module with explicit interfaces. Units are NOT defined as "groupings of stories" — that is what bolts do. Units decompose the *system architecture*; bolts decompose the *execution plan*.
12
-
13
- **Terminology**: Use "Service" for independently deployable components, "Module" for logical groupings within a service, "Unit of Work" for planning context.
14
-
15
- ---
16
-
17
- ## Input (Required Artifacts)
18
-
19
- The following artifacts MUST be available before Units Generation begins. The agent must read each artifact to extract requirement IDs, story IDs, and design decisions.
20
-
21
- | Artifact | Path | Required | Purpose |
22
- |----------|------|----------|---------|
23
- | Requirements | `inception/requirements/requirements.md` | YES | FR-N requirement IDs, priorities, and descriptions |
24
- | Execution Plan | `inception/plans/execution-plan.md` | YES | Workflow routing and stage decisions |
25
-
26
- **Hard block**: If `requirements.md` is missing or contains no FR-N requirement IDs, Units Generation cannot proceed. Abort and direct the user to complete Requirements Analysis first.
27
-
28
- > **Note**: Stories do not exist yet at this point -- they are created in the User Stories stage after units are defined. If prior application design artifacts exist (from brownfield analysis or earlier workflows), they may inform domain analysis but are not a prerequisite.
29
-
30
- ---
31
-
32
- ## Output
33
-
34
- This stage produces the following artifacts in `aidlc-docs/{workflowId}/inception/units/`:
35
-
36
- | Artifact | Path | Condition | Description |
37
- |----------|------|-----------|-------------|
38
- | Unit overview | `inception/units/unit-of-work.md` | ALWAYS | Unit definitions, requirement mapping, dependency graph |
39
- | Dependency matrix | `inception/units/unit-of-work-dependency.md` | When 2+ units | Cross-unit dependency analysis |
40
- | Story map | `inception/units/unit-of-work-story-map.md` | After User Stories stage | Cross-unit story reference (created during User Stories stage, not during Units Generation) |
41
- | Per-unit briefs | `inception/units/{UNIT-NNN-slug}/unit-brief.md` | When 2+ units | Detailed per-unit brief for Bolt Planning |
42
-
43
- ### Canonical Templates
44
-
45
- Agents MUST read and follow these template files exactly when creating artifacts:
46
-
47
- - **Units overview**: `resources/templates/inception/units-template.md`
48
- - **Unit briefs**: `resources/templates/inception/unit-brief-template.md`
49
-
50
- > **CRITICAL**: Do NOT invent your own artifact format. Read the template files and follow their structure. The templates define all required frontmatter fields, required body sections, and expected content.
51
-
52
- ---
53
-
54
- ## Unit Naming Convention (MANDATORY)
55
-
56
- All units of work MUST follow a consistent naming scheme:
57
-
58
- - **Documentation headings**: Use `## U-NNN: Name` format
59
- - Example: `## U-001: Foundation`, `## U-002: API Layer`, `## U-003: Frontend`
60
- - Number is zero-padded to three digits (U-001, U-002, ... U-010, U-011)
61
- - **Construction folder names**: Use `UNIT-NNN-name` kebab-case format
62
- - Example: `UNIT-001-foundation/`, `UNIT-002-api-layer/`, `UNIT-003-frontend/`
63
- - This format is automatically enforced by the TypeScript engine via `slugifyUnitName()`
64
- - **AI-generated artifacts** (unit-of-work.md, unit-of-work-dependency.md, unit-of-work-story-map.md) MUST use `## U-NNN: Name` headings — not plain unit names
65
-
66
- This convention ensures that construction artifacts are traceable to their inception units and that folder paths are consistent across all workflows.
67
-
68
- ---
69
-
70
- ## Skip Pathway: Mandatory Unit Registration
71
-
72
- When Workflow Planning (Step 3.3) determines that the full Units Generation stage should be **skipped**, a lightweight **Unit Registration** step MUST still execute. This ensures all units have `U-NNN` IDs and a unit registry exists — even when the full Q&A decomposition process is unnecessary.
73
-
74
- The Unit Registration is defined in `workflow-planning.md` (Step 3.5) and executes as part of the Workflow Planning stage itself. It produces:
75
- - `unit-of-work.md` (MANDATORY) — minimal unit definitions (ID, name, description, key deliverables)
76
- - `unit-of-work-dependency.md` (CONDITIONAL) — only when units have actual blocking dependencies
77
- - `unit-of-work-story-map.md` (CONDITIONAL) — only when stories exist and aren't already mapped to units elsewhere
78
-
79
- All artifacts are placed in `aidlc-docs/{workflow-id}/inception/units/` and follow the **Unit Naming Convention** defined above.
80
-
81
- When the full Units Generation stage executes (PART 1 + PART 2 below), these lightweight artifacts are not needed — the full process produces comprehensive versions instead.
82
-
83
- ---
84
-
85
- ## Agent Delegation Strategy
86
-
87
- **MANDATORY**: Delegate unit artifact generation (Part 2) to `olympian`. Do NOT generate unit decomposition artifacts directly.
88
-
89
- **Execution mode**: Foreground sequential — single coherent decomposition task per workflow.
90
-
91
- **Delegation scope**:
92
- - **Orchestrator retains**: Part 1 (Planning) — Steps 1-14. The orchestrator performs domain analysis, applies decomposition criteria, creates the decomposition plan, manages Q&A, resolves ambiguities, and obtains user approval.
93
- - **Delegated to `olympian`**: Part 2 (Generation) — Steps 15-18. The agent executes the approved plan to produce unit-of-work.md, unit-of-work-dependency.md, unit-of-work-story-map.md, and per-unit briefs.
94
-
95
- **If an agent task fails**: Follow the Agent Task Failure Recovery procedure in `error-handling.md` — retry the delegation, never silently do the work yourself.
96
-
97
- **After agent completes**: The orchestrator reviews the generated artifacts, presents the completion message (Step 19), and manages the approval gate (Steps 20-22).
98
-
99
- **Optional quality gate — `momus` review**:
100
- Unit boundaries define the scope of all subsequent design and code generation work. After `olympian` generates the unit artifacts (Part 2), the orchestrator may optionally invoke `momus` to critically evaluate the decomposition before presenting it to the user. This is recommended when multiple units are defined or when unit boundaries involve complex dependencies. Momus evaluates against: unit independence, story coverage completeness, dependency validity, and absence of circular dependencies.
101
-
102
- ---
103
-
104
- # PART 1: PLANNING
105
-
106
- ## Step 1: Read Input Artifacts
107
-
108
- - [ ] Read `inception/requirements/requirements.md` — extract all FR-N IDs, descriptions, and priorities
109
- - [ ] Read `inception/application-design/` artifacts (if exist from brownfield analysis) — extract component/service definitions to inform domain analysis
110
- - [ ] Verify `requirements.md` contains at least one FR-N requirement (hard block if missing)
111
-
112
- ## Step 2: Domain Analysis
113
-
114
- This step subsumes the former Application Design stage. Identify components, services, and their dependencies as part of bounded context analysis.
115
-
116
- Before generating questions or decomposing units, perform domain analysis on the input artifacts. This analysis informs the decomposition approach and ensures questions target real ambiguities rather than generic categories.
117
-
118
- - [ ] **Identify bounded contexts**: Group related requirements by domain area (e.g., user management, billing, notifications). Look for natural seams where the language or concerns shift.
119
- - [ ] **Identify aggregates and key entities**: From requirements and stories, list the core domain entities and which context they belong to. Note entities that appear in multiple contexts (shared kernel candidates).
120
- - [ ] **Identify services and operations**: Map each FR to the operations it implies (CRUD, workflows, integrations, transformations). Group operations by the entity or context they primarily serve.
121
- - [ ] **Identify integration points**: Determine where potential units would need to communicate — shared data, event flows, API calls, or file exchanges. These become the interfaces between units.
122
- - [ ] **Document the analysis**: Record the domain analysis findings in the unit-of-work plan (Step 6) so the rationale is preserved.
123
-
124
- ## Step 3: Apply Decomposition Criteria
125
-
126
- For each potential unit identified through domain analysis, verify these criteria BEFORE committing to the decomposition. A unit that fails any criterion must be restructured before proceeding.
127
-
128
- - [ ] **Single Responsibility**: Does this unit do one thing well? It should handle one bounded domain area. A unit spanning multiple unrelated domains must be split.
129
- - [ ] **Independence**: Can this unit be built and tested separately from other units? It should not require runtime access to another unit's unbuilt code.
130
- - [ ] **Deployability**: Can this unit be deployed independently? (For monoliths: can it be a logically separate module with clear boundaries?)
131
- - [ ] **Clear Interface**: Are inputs and outputs well-defined? Any cross-unit interaction must be expressible through an explicit interface (API contract, event schema, shared type definition).
132
- - [ ] **Cohesion**: Do the requirements and stories assigned to this unit belong together? High cohesion means the unit's parts are closely related; low cohesion signals a need to split or reorganize.
133
-
134
- ## Step 4: Requirement-to-Unit Mapping (Draft)
135
-
136
- Based on the domain analysis and decomposition criteria, create a draft mapping of every FR from `requirements.md` to a proposed unit.
137
-
138
- **CRITICAL**: Each FR must be assigned to exactly one unit. This mapping is the contract for what each unit must deliver.
139
-
140
- ```text
141
- | Requirement | Description | Priority | Proposed Unit |
142
- |-------------|-------------|----------|---------------|
143
- | FR-1 | ... | Must | U-001: {name} |
144
- | FR-2 | ... | Should | U-001: {name} |
145
- | FR-3 | ... | Must | U-002: {name} |
146
- ```
147
-
148
- - [ ] Every FR in `requirements.md` appears in the mapping
149
- - [ ] No FR is assigned to more than one unit
150
- - [ ] No FR is unassigned (unassigned FRs = hard block)
151
- - [ ] Must-priority FRs are distributed to ensure no single unit is overloaded
152
-
153
- This draft mapping will be refined based on Q&A answers but serves as the baseline decomposition.
154
-
155
- ## Step 5: Generate Context-Appropriate Questions
156
-
157
- **DIRECTIVE**: Analyze the requirements and any available application design artifacts to generate ONLY questions relevant to THIS specific decomposition problem. Use the categories below as inspiration, NOT as a mandatory checklist. Skip entire categories if not applicable.
158
-
159
- - EMBED questions using [Answer]: tag format
160
- - Focus on ambiguities and missing information specific to this context
161
- - Generate questions only where user input is needed for decision-making
162
- - Reference the domain analysis findings when framing questions
163
-
164
- **Example question categories** (adapt as needed):
165
- - **Domain Boundaries** - Only if bounded context boundaries are ambiguous or overlapping
166
- - **Dependencies** - Only if multiple units likely and integration approach is ambiguous
167
- - **Team Alignment** - Only if team structure or ownership is unclear
168
- - **Technical Considerations** - Only if scalability/deployment requirements differ across units
169
- - **Business Domain** - Only if domain boundaries or bounded contexts are unclear
170
- - **Code Organization (Greenfield multi-unit only)** - Ask deployment model and directory structure preferences
171
- - **Decomposition Validation** - Questions to validate the draft requirement-to-unit mapping with the user
172
-
173
- ## Step 6: Store Unit of Work Plan
174
-
175
- - Save as `aidlc-docs/inception/plans/unit-of-work-plan.md`
176
- - Include the domain analysis findings (Step 2)
177
- - Include the draft requirement-to-unit mapping (Step 4)
178
- - Include all [Answer]: tags for user input
179
- - Ensure plan covers all aspects of system decomposition
180
-
181
- ## Step 7: Include Mandatory Unit Artifacts in Plan
182
-
183
- **ALWAYS** include these mandatory artifacts in the unit plan (when executing the full stage — if the stage is skipped, the Skip Pathway above handles these):
184
- - [ ] Generate `aidlc-docs/inception/units/unit-of-work.md` with unit definitions and responsibilities — following `resources/templates/inception/units-template.md`
185
- - [ ] Generate `aidlc-docs/inception/units/unit-of-work-dependency.md` with dependency matrix (when 2+ units)
186
- - [ ] ~~Generate `aidlc-docs/inception/units/unit-of-work-story-map.md`~~ — Created during User Stories stage, not here. Do NOT generate this artifact during Units Generation.
187
- - [ ] Generate per-unit briefs in `aidlc-docs/inception/units/{unit-slug}/unit-brief.md` (when 2+ units) — following `resources/templates/inception/unit-brief-template.md`
188
- - [ ] **Greenfield only**: Document code organization strategy in `unit-of-work.md` (see code-generation.md for structure patterns)
189
- - [ ] Validate unit boundaries and dependencies
190
- - [ ] Ensure all requirements are assigned to units (100% coverage)
191
- - [ ] Prepare unit briefs with placeholder story sections (populated during User Stories stage)
192
- - [ ] Create `stories/` subdirectory in each unit folder as a placeholder for per-unit stories created in the User Stories stage
193
-
194
- ## Step 8: Request User Input
195
-
196
- - Ask user to fill [Answer]: tags directly in the plan document
197
- - Emphasize importance of decomposition decisions
198
- - Provide clear instructions on completing the [Answer]: tags
199
-
200
- ## Step 9: Collect Answers
201
-
202
- - Wait for user to provide answers to all questions using [Answer]: tags in the document
203
- - Do not proceed until ALL [Answer]: tags are completed
204
- - Review the document to ensure no [Answer]: tags are left blank
205
-
206
- ## Step 10: ANALYZE ANSWERS (MANDATORY)
207
-
208
- Before proceeding, you MUST carefully review all user answers for:
209
- - **Vague or ambiguous responses**: "mix of", "somewhere between", "not sure", "depends"
210
- - **Undefined criteria or terms**: References to concepts without clear definitions
211
- - **Contradictory answers**: Responses that conflict with each other
212
- - **Missing generation details**: Answers that lack specific guidance
213
- - **Answers that combine options**: Responses that merge different approaches without clear decision rules
214
- - **Conflicts with draft mapping**: Answers that invalidate the proposed requirement-to-unit mapping
215
-
216
- ## Step 11: MANDATORY Follow-up Questions
217
-
218
- If the analysis in step 10 reveals ANY ambiguous answers, you MUST:
219
- - Add specific follow-up questions to the plan document using [Answer]: tags
220
- - DO NOT proceed to approval until all ambiguities are resolved
221
- - Examples of required follow-ups:
222
- - "You mentioned 'mix of A and B' - what specific criteria should determine when to use A vs B?"
223
- - "You said 'somewhere between A and B' - can you define the exact middle ground approach?"
224
- - "You indicated 'not sure' - what additional information would help you decide?"
225
- - "You mentioned 'depends on complexity' - how do you define complexity levels?"
226
-
227
- ## Step 12: Finalize Requirement-to-Unit Mapping
228
-
229
- After Q&A is complete, finalize the requirement-to-unit mapping based on user answers:
230
-
231
- - [ ] Update the draft mapping with any changes from user feedback
232
- - [ ] Verify 100% FR coverage — every FR in `requirements.md` is assigned to exactly one unit
233
- - [ ] Verify 100% must-priority coverage — every Must FR is assigned
234
- - [ ] Resolve any mapping conflicts surfaced during Q&A
235
-
236
- **Hard block**: If any FR remains unassigned after Q&A, do not proceed to approval. Either assign it to an existing unit or create a new unit.
237
-
238
- ## Step 13: Request Approval
239
-
240
- - Ask: "**Unit of work plan complete. Review the plan in aidlc-docs/inception/plans/unit-of-work-plan.md. Ready to proceed to generation?**"
241
- - DO NOT PROCEED until user confirms
242
-
243
- ## Step 14: MANDATORY: Update Progress
244
-
245
- - Log prompt and response in audit.md with timestamp (ISO 8601)
246
- - Include complete approval prompt text
247
- - **MANDATORY**: Update BOTH state files:
248
- 1. Mark Units Planning complete in `aidlc-docs/{workflow-id}/aidlc-state.md`
249
- 2. Update `aidlc-docs/{workflow-id}/checkpoint.json` current status
250
- - **Do NOT proceed without completing state updates**
251
-
252
- ---
253
-
254
- # PART 2: GENERATION
255
-
256
- ## Step 15: Load Unit of Work Plan
257
-
258
- - [ ] Read the complete plan from `aidlc-docs/inception/plans/unit-of-work-plan.md`
259
- - [ ] Read the canonical templates:
260
- - `resources/templates/inception/units-template.md`
261
- - `resources/templates/inception/unit-brief-template.md`
262
- - [ ] Identify the next uncompleted step (first [ ] checkbox)
263
- - [ ] Load the context and requirements for that step
264
-
265
- ## Step 16: Execute Current Step
266
-
267
- - [ ] Perform exactly what the current step describes
268
- - [ ] Generate unit artifacts as specified in the plan, following the canonical templates
269
- - [ ] Follow the approved decomposition approach from Planning
270
- - [ ] Use the criteria and boundaries specified in the plan
271
- - [ ] Ensure the Requirement-to-Unit Mapping table is included in `unit-of-work.md`
272
-
273
- ## Step 17: MANDATORY: Update Progress
274
-
275
- - [ ] Mark the completed step as [x] in the unit of work plan
276
- - [ ] **MANDATORY**: Update `aidlc-docs/{workflow-id}/aidlc-state.md` current status
277
- - [ ] **MANDATORY**: Update `aidlc-docs/{workflow-id}/checkpoint.json` current status
278
- - [ ] Save all generated artifacts
279
- - **Do NOT proceed without completing state updates**
280
-
281
- ## Step 18: Generate Unit Briefs
282
-
283
- **Condition**: Generate unit briefs when the decomposition produces **2 or more units**. If only 1 unit exists, skip to Step 18b.
284
-
285
- For each unit defined in `unit-of-work.md`, create a per-unit brief file following the canonical template at `resources/templates/inception/unit-brief-template.md`.
286
-
287
- **Path**: `aidlc-docs/{workflowId}/inception/units/{unit-slug}/unit-brief.md`
288
-
289
- Where `{unit-slug}` follows the naming convention (e.g., `UNIT-001-foundation`).
290
-
291
- The agent MUST read the template file and produce a brief with ALL required sections:
292
- - Frontmatter (unit, unit_slug, intent, complexity, status, created, updated)
293
- - Purpose (one paragraph)
294
- - Scope (In Scope AND Out of Scope)
295
- - Assigned Requirements (table with FR IDs, descriptions, priorities)
296
- - Domain Concepts (Key Entities and Key Operations tables)
297
- - Story Summary and Stories Assigned
298
- - Dependencies (Depends On, Depended On By, External Dependencies)
299
- - Technical Context (Integration Points, Data Storage)
300
- - Constraints
301
- - Success Criteria (Functional, Non-Functional, Quality)
302
- - Bolt Suggestions
303
- - Notes
304
-
305
- **Rules**:
306
- - Unit briefs supplement, not replace, `unit-of-work.md` — the overview document remains the single index of all units
307
- - Assigned Requirements must trace back to FRs in `requirements.md` and match the Requirement-to-Unit Mapping
308
- - Dependencies must be consistent with `unit-of-work-dependency.md`
309
- - Stories Assigned table should contain placeholder content (stories are created in the User Stories stage after units are defined)
310
- - Keep domain-level detail appropriate — detailed functional design happens in the Construction phase
311
-
312
- ## Step 18b: Continue or Complete Generation
313
-
314
- - [ ] If more plan steps remain, return to Step 15
315
- - [ ] If all steps complete, verify units are ready for independence validation
316
- - [ ] If unit briefs were generated (Step 18), verify consistency across all briefs
317
- - [ ] Verify Requirement-to-Unit Mapping has 100% coverage
318
-
319
- ---
320
-
321
- # INDEPENDENCE VALIDATION (HARD GATE)
322
-
323
- ## Step 18c: Unit Independence Validation
324
-
325
- **This is a HARD GATE. No unit may proceed to Bolt Planning if it fails any independence criterion.**
326
-
327
- Before marking Units Generation complete, verify EACH unit satisfies ALL five independence criteria:
328
-
329
- | Criterion | Description | Failure Action |
330
- |-----------|-------------|----------------|
331
- | Single responsibility | The unit handles one bounded domain area. A unit spanning multiple unrelated domains must be split. | Split the unit |
332
- | Clear interfaces | Any cross-unit interaction is expressed through an explicit interface (API contract, event schema, shared type definition). Units must not access each other's internal implementation. | Define explicit interfaces |
333
- | No circular dependencies | The dependency matrix in `unit-of-work-dependency.md` must be a DAG (directed acyclic graph). Circular dependencies are a hard block. | Restructure dependencies |
334
- | Independent buildability | Each unit can be developed and tested by a separate team without requiring runtime access to another unit's unbuilt code. | Decouple the unit |
335
- | Explicit cross-unit deps | Every dependency a unit has on another unit must be documented in `unit-of-work-dependency.md`. Undocumented implicit dependencies are not allowed. | Document or remove dependency |
336
-
337
- Validation results:
338
-
339
- ```text
340
- | Unit | Single Resp | Clear Interfaces | No Circular Deps | Independent Build | Explicit Deps | PASS? |
341
- |------|-------------|------------------|-------------------|-------------------|---------------|-------|
342
- | U-001 | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No |
343
- | U-002 | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No |
344
- ```
345
-
346
- - If ANY unit fails ANY criterion: revise the decomposition and re-validate. Do NOT proceed.
347
- - If ALL units pass ALL criteria: proceed to the completion message.
348
-
349
- ---
350
-
351
- ## Step 19: Present Completion Message
352
-
353
- ```markdown
354
- # Units Generation Complete
355
-
356
- [AI-generated summary of units and decomposition approach]
357
-
358
- ## Units Created
359
- - U-001: {name} — {n} requirements, complexity: {S/M/L/XL}
360
- - U-002: {name} — {n} requirements, complexity: {S/M/L/XL}
361
-
362
- ## Dependency Graph
363
- [U-001: {name}] --> [U-002: {name}] --> [U-003: {name}]
364
-
365
- ## Requirement Coverage
366
- - FR assigned: {n}/{total} (must be 100%)
367
- - Must-priority covered: {n}/{n}
368
-
369
- ## Independence Validation
370
- All units passed 5/5 independence criteria.
371
-
372
- ## Artifacts Created
373
- - inception/units/unit-of-work.md
374
- - inception/units/unit-of-work-dependency.md
375
- - inception/units/UNIT-001-{slug}/unit-brief.md
376
- - inception/units/UNIT-002-{slug}/unit-brief.md
377
-
378
- ---
379
-
380
- **REVIEW REQUIRED**
381
-
382
- > Please examine the units generation artifacts at:
383
- > `aidlc-docs/{workflow-id}/inception/units/`
384
-
385
- **You may:**
386
- - **Request Changes** — Ask for modifications to the units generation if required
387
- - **Approve & Continue** — Approve units and proceed to **User Stories**
388
- ```
389
-
390
- ## Step 20: Wait for Explicit Approval
391
-
392
- - Do not proceed until the user explicitly approves the units generation
393
- - Approval must be clear and unambiguous
394
- - If user requests changes, update the units and repeat the approval process (including independence validation)
395
-
396
- ## Step 21: Record Approval Response
397
-
398
- - Log the user's approval response with timestamp in `aidlc-docs/audit.md`
399
- - Include the exact user response text
400
- - Mark the approval status clearly
401
-
402
- ## Step 22: MANDATORY: Update State Tracking
403
-
404
- - **MANDATORY**: Update BOTH state files in the SAME interaction:
405
- 1. Mark Units Generation stage complete in `aidlc-docs/{workflow-id}/aidlc-state.md`
406
- 2. Update `aidlc-docs/{workflow-id}/checkpoint.json` — set units-generation status to "completed" with completed_at timestamp
407
- - **Do NOT proceed to the next stage without completing this step**
408
-
409
- ---
410
-
411
- ## Completion Summary Format
412
-
413
- After approval, present the final summary in this structured format:
414
-
415
- ```text
416
- ## Units Generation Complete
417
-
418
- ### Units Created
419
- - U-001: {name} — {n} requirements, complexity: {S/M/L/XL}
420
- - U-002: {name} — {n} requirements, complexity: {S/M/L/XL}
421
-
422
- ### Dependency Graph
423
- [U-001] --> [U-002] --> [U-003]
424
-
425
- ### Requirement Coverage
426
- - FR assigned: {n}/{total} (100%)
427
- - Must-priority covered: {n}/{n}
428
-
429
- ### Artifacts Created
430
- inception/units/unit-of-work.md
431
- inception/units/unit-of-work-dependency.md
432
- inception/units/UNIT-001-{slug}/unit-brief.md
433
- inception/units/UNIT-002-{slug}/unit-brief.md
434
- ```
435
-
436
- ---
437
-
438
- ## Test Contract
439
-
440
- ```yaml
441
- input: Requirements (FR-N IDs), application design (if available from brownfield analysis)
442
- output: unit-of-work.md, unit-of-work-dependency.md, per-unit briefs (unit-of-work-story-map.md created during User Stories stage)
443
- constraints:
444
- requirement_coverage: 100% (every FR assigned to a unit)
445
- must_requirement_coverage: 100%
446
- unit_independence: all 5 criteria must pass
447
- no_circular_dependencies: true
448
- unit_brief_threshold: 2+ units (always generate briefs when 2 or more units exist)
449
- checkpoints: 0 (part of inception review gate)
450
- ```
451
-
452
- ---
453
-
454
- ## Critical Rules
455
-
456
- ### Requirement Mapping Rules
457
- - **REQUIREMENT MAPPING IS MANDATORY**: Every FR from `requirements.md` must be assigned to exactly one unit. Unassigned FRs are a hard block — generation cannot proceed.
458
- - **Must-priority 100% coverage**: Every FR with `Must` priority must be assigned. No exceptions.
459
- - **No duplicate assignment**: Each FR belongs to exactly one unit. If a requirement spans multiple units, decompose the requirement or assign to the unit with primary ownership.
460
-
461
- ### Template Rules
462
- - **TEMPLATES ARE MANDATORY**: Agents MUST read and follow the canonical templates at `resources/templates/inception/units-template.md` and `resources/templates/inception/unit-brief-template.md`. Do NOT invent custom formats.
463
- - **All required sections**: Every section defined in the template must appear in the generated artifact. Missing sections are a rejection.
464
-
465
- ### Unit Brief Rules
466
- - **UNIT BRIEFS ALWAYS FOR 2+ UNITS**: Generate per-unit briefs whenever 2 or more units exist. This is NOT conditional on complexity — if there are 2+ units, briefs are mandatory.
467
- - **Brief completeness**: Each brief must contain ALL sections defined in the template (Purpose, Scope, Assigned Requirements, Domain Concepts, Story Summary, Dependencies, Technical Context, Constraints, Success Criteria, Bolt Suggestions, Notes).
468
-
469
- ### Process Rules
470
- - **DECOMPOSITION BEFORE Q&A**: Domain analysis (Step 2) and decomposition criteria (Step 3) must be applied before generating questions (Step 5). Questions should be informed by the analysis, not generic.
471
- - **INDEPENDENCE IS A HARD GATE**: A unit that fails any independence criterion in Step 18c cannot proceed. This is not advisory — it is a blocking validation.
472
- - Generate ONLY context-relevant questions
473
- - Use [Answer]: tag format for all questions
474
- - Analyze all answers for ambiguities before proceeding
475
- - Resolve ALL ambiguities with follow-up questions
476
- - Get explicit user approval before generation
477
-
478
- ### Generation Phase Rules
479
- - **NO HARDCODED LOGIC**: Only execute what's written in the unit of work plan
480
- - **FOLLOW PLAN EXACTLY**: Do not deviate from the step sequence
481
- - **UPDATE CHECKBOXES**: Mark [x] immediately after completing each step
482
- - **USE APPROVED APPROACH**: Follow the decomposition methodology from Planning
483
- - **VERIFY COMPLETION**: Ensure all unit artifacts are complete before proceeding
484
-
485
- ---
486
-
487
- ## Completion Criteria
488
-
489
- - All planning questions answered and ambiguities resolved
490
- - User approval obtained for the plan
491
- - All steps in unit of work plan marked [x]
492
- - All unit artifacts generated according to plan and canonical templates:
493
- - `unit-of-work.md` with unit definitions and Requirement-to-Unit Mapping
494
- - `unit-of-work-dependency.md` with dependency matrix (when 2+ units)
495
- - Per-unit briefs with placeholder story sections (when 2+ units)
496
- - 100% requirement coverage (every FR assigned to a unit)
497
- - 100% must-priority coverage
498
- - All units pass independence validation (5/5 criteria)
499
- - Units verified and ready for User Stories stage
500
-
501
- ---
502
-
503
- ## Next Stage: User Stories
504
-
505
- After units are approved, the workflow proceeds to **User Stories** — a separate inception stage that creates per-unit user stories in each unit's `stories/` directory (e.g., `inception/units/{UNIT-NNN-slug}/stories/S-001-{slug}.md`). Stories are scoped to their parent unit and reference the unit ID. Personas remain project-wide at `inception/user-stories/personas.md`. After stories are created, the workflow proceeds to **Bolt Planning**, which decomposes each unit's stories into bolt spec files.
1
+ # Units Generation - Detailed Steps
2
+
3
+ ## Overview
4
+
5
+ This stage decomposes the system into manageable units of work through two integrated parts:
6
+ - **Part 1 - Planning**: Perform domain analysis, apply decomposition criteria, create decomposition plan with questions, collect answers, analyze for ambiguities, get approval
7
+ - **Part 2 - Generation**: Execute approved plan to generate unit artifacts following canonical templates
8
+
9
+ **Goal**: Decompose the intent into independently deployable units of work based on domain boundaries and architectural concerns. Each unit should represent a cohesive bounded context with clear interfaces. Requirements and stories are then *assigned* to units for traceability — but units are defined by domain boundaries, not by story grouping. Story grouping into execution sessions is Bolt Planning's job.
10
+
11
+ **DEFINITION**: A unit of work is an independently deployable domain boundary derived from the intent. For microservices, each unit becomes a separate service. For monoliths, each unit is a logically independent module with explicit interfaces. Units are NOT defined as "groupings of stories" — that is what bolts do. Units decompose the *system architecture*; bolts decompose the *execution plan*.
12
+
13
+ **Terminology**: Use "Service" for independently deployable components, "Module" for logical groupings within a service, "Unit of Work" for planning context.
14
+
15
+ ---
16
+
17
+ ## Input (Required Artifacts)
18
+
19
+ The following artifacts MUST be available before Units Generation begins. The agent must read each artifact to extract requirement IDs, story IDs, and design decisions.
20
+
21
+ | Artifact | Path | Required | Purpose |
22
+ |----------|------|----------|---------|
23
+ | Requirements | `inception/requirements/requirements.md` | YES | FR-N requirement IDs, priorities, and descriptions |
24
+ | Execution Plan | `inception/plans/execution-plan.md` | YES | Workflow routing and stage decisions |
25
+
26
+ **Hard block**: If `requirements.md` is missing or contains no FR-N requirement IDs, Units Generation cannot proceed. Abort and direct the user to complete Requirements Analysis first.
27
+
28
+ > **Note**: Stories do not exist yet at this point -- they are created in the User Stories stage after units are defined. If prior application design artifacts exist (from brownfield analysis or earlier workflows), they may inform domain analysis but are not a prerequisite.
29
+
30
+ ---
31
+
32
+ ## Output
33
+
34
+ This stage produces the following artifacts in `aidlc-docs/{workflowId}/inception/units/`:
35
+
36
+ | Artifact | Path | Condition | Description |
37
+ |----------|------|-----------|-------------|
38
+ | Unit overview | `inception/units/unit-of-work.md` | ALWAYS | Unit definitions, requirement mapping, dependency graph |
39
+ | Dependency matrix | `inception/units/unit-of-work-dependency.md` | When 2+ units | Cross-unit dependency analysis |
40
+ | Story map | `inception/units/unit-of-work-story-map.md` | After User Stories stage | Cross-unit story reference (created during User Stories stage, not during Units Generation) |
41
+ | Per-unit briefs | `inception/units/{UNIT-NNN-slug}/unit-brief.md` | When 2+ units | Detailed per-unit brief for Bolt Planning |
42
+
43
+ ### Canonical Templates
44
+
45
+ Agents MUST read and follow these template files exactly when creating artifacts:
46
+
47
+ - **Units overview**: `resources/templates/inception/units-template.md`
48
+ - **Unit briefs**: `resources/templates/inception/unit-brief-template.md`
49
+
50
+ > **CRITICAL**: Do NOT invent your own artifact format. Read the template files and follow their structure. The templates define all required frontmatter fields, required body sections, and expected content.
51
+
52
+ ---
53
+
54
+ ## Unit Naming Convention (MANDATORY)
55
+
56
+ All units of work MUST follow a consistent naming scheme:
57
+
58
+ - **Documentation headings**: Use `## U-NNN: Name` format
59
+ - Example: `## U-001: Foundation`, `## U-002: API Layer`, `## U-003: Frontend`
60
+ - Number is zero-padded to three digits (U-001, U-002, ... U-010, U-011)
61
+ - **Construction folder names**: Use `UNIT-NNN-name` kebab-case format
62
+ - Example: `UNIT-001-foundation/`, `UNIT-002-api-layer/`, `UNIT-003-frontend/`
63
+ - This format is automatically enforced by the TypeScript engine via `slugifyUnitName()`
64
+ - **AI-generated artifacts** (unit-of-work.md, unit-of-work-dependency.md, unit-of-work-story-map.md) MUST use `## U-NNN: Name` headings — not plain unit names
65
+
66
+ This convention ensures that construction artifacts are traceable to their inception units and that folder paths are consistent across all workflows.
67
+
68
+ ---
69
+
70
+ ## Skip Pathway: Mandatory Unit Registration
71
+
72
+ When Workflow Planning (Step 3.3) determines that the full Units Generation stage should be **skipped**, a lightweight **Unit Registration** step MUST still execute. This ensures all units have `U-NNN` IDs and a unit registry exists — even when the full Q&A decomposition process is unnecessary.
73
+
74
+ The Unit Registration is defined in `workflow-planning.md` (Step 3.5) and executes as part of the Workflow Planning stage itself. It produces:
75
+ - `unit-of-work.md` (MANDATORY) — minimal unit definitions (ID, name, description, key deliverables)
76
+ - `unit-of-work-dependency.md` (CONDITIONAL) — only when units have actual blocking dependencies
77
+ - `unit-of-work-story-map.md` (CONDITIONAL) — only when stories exist and aren't already mapped to units elsewhere
78
+
79
+ All artifacts are placed in `aidlc-docs/{workflow-id}/inception/units/` and follow the **Unit Naming Convention** defined above.
80
+
81
+ When the full Units Generation stage executes (PART 1 + PART 2 below), these lightweight artifacts are not needed — the full process produces comprehensive versions instead.
82
+
83
+ ---
84
+
85
+ ## Agent Delegation Strategy
86
+
87
+ **MANDATORY**: Delegate unit artifact generation (Part 2) to `olympian`. Do NOT generate unit decomposition artifacts directly.
88
+
89
+ **Execution mode**: Foreground sequential — single coherent decomposition task per workflow.
90
+
91
+ **Delegation scope**:
92
+ - **Orchestrator retains**: Part 1 (Planning) — Steps 1-14. The orchestrator performs domain analysis, applies decomposition criteria, creates the decomposition plan, manages Q&A, resolves ambiguities, and obtains user approval.
93
+ - **Delegated to `olympian`**: Part 2 (Generation) — Steps 15-18. The agent executes the approved plan to produce unit-of-work.md, unit-of-work-dependency.md, unit-of-work-story-map.md, and per-unit briefs.
94
+
95
+ **If an agent task fails**: Follow the Agent Task Failure Recovery procedure in `error-handling.md` — retry the delegation, never silently do the work yourself.
96
+
97
+ **After agent completes**: The orchestrator reviews the generated artifacts, presents the completion message (Step 19), and manages the approval gate (Steps 20-22).
98
+
99
+ **Optional quality gate — `momus` review**:
100
+ Unit boundaries define the scope of all subsequent design and code generation work. After `olympian` generates the unit artifacts (Part 2), the orchestrator may optionally invoke `momus` to critically evaluate the decomposition before presenting it to the user. This is recommended when multiple units are defined or when unit boundaries involve complex dependencies. Momus evaluates against: unit independence, story coverage completeness, dependency validity, and absence of circular dependencies.
101
+
102
+ ---
103
+
104
+ # PART 1: PLANNING
105
+
106
+ ## Step 1: Read Input Artifacts
107
+
108
+ - [ ] Read `inception/requirements/requirements.md` — extract all FR-N IDs, descriptions, and priorities
109
+ - [ ] Read `inception/application-design/` artifacts (if exist from brownfield analysis) — extract component/service definitions to inform domain analysis
110
+ - [ ] Verify `requirements.md` contains at least one FR-N requirement (hard block if missing)
111
+
112
+ ## Step 2: Domain Analysis
113
+
114
+ This step subsumes the former Application Design stage. Identify components, services, and their dependencies as part of bounded context analysis.
115
+
116
+ Before generating questions or decomposing units, perform domain analysis on the input artifacts. This analysis informs the decomposition approach and ensures questions target real ambiguities rather than generic categories.
117
+
118
+ - [ ] **Identify bounded contexts**: Group related requirements by domain area (e.g., user management, billing, notifications). Look for natural seams where the language or concerns shift.
119
+ - [ ] **Identify aggregates and key entities**: From requirements and stories, list the core domain entities and which context they belong to. Note entities that appear in multiple contexts (shared kernel candidates).
120
+ - [ ] **Identify services and operations**: Map each FR to the operations it implies (CRUD, workflows, integrations, transformations). Group operations by the entity or context they primarily serve.
121
+ - [ ] **Identify integration points**: Determine where potential units would need to communicate — shared data, event flows, API calls, or file exchanges. These become the interfaces between units.
122
+ - [ ] **Document the analysis**: Record the domain analysis findings in the unit-of-work plan (Step 6) so the rationale is preserved.
123
+
124
+ ## Step 3: Apply Decomposition Criteria
125
+
126
+ For each potential unit identified through domain analysis, verify these criteria BEFORE committing to the decomposition. A unit that fails any criterion must be restructured before proceeding.
127
+
128
+ - [ ] **Single Responsibility**: Does this unit do one thing well? It should handle one bounded domain area. A unit spanning multiple unrelated domains must be split.
129
+ - [ ] **Independence**: Can this unit be built and tested separately from other units? It should not require runtime access to another unit's unbuilt code.
130
+ - [ ] **Deployability**: Can this unit be deployed independently? (For monoliths: can it be a logically separate module with clear boundaries?)
131
+ - [ ] **Clear Interface**: Are inputs and outputs well-defined? Any cross-unit interaction must be expressible through an explicit interface (API contract, event schema, shared type definition).
132
+ - [ ] **Cohesion**: Do the requirements and stories assigned to this unit belong together? High cohesion means the unit's parts are closely related; low cohesion signals a need to split or reorganize.
133
+
134
+ ## Step 4: Requirement-to-Unit Mapping (Draft)
135
+
136
+ Based on the domain analysis and decomposition criteria, create a draft mapping of every FR from `requirements.md` to a proposed unit.
137
+
138
+ **CRITICAL**: Each FR must be assigned to exactly one unit. This mapping is the contract for what each unit must deliver.
139
+
140
+ ```text
141
+ | Requirement | Description | Priority | Proposed Unit |
142
+ |-------------|-------------|----------|---------------|
143
+ | FR-1 | ... | Must | U-001: {name} |
144
+ | FR-2 | ... | Should | U-001: {name} |
145
+ | FR-3 | ... | Must | U-002: {name} |
146
+ ```
147
+
148
+ - [ ] Every FR in `requirements.md` appears in the mapping
149
+ - [ ] No FR is assigned to more than one unit
150
+ - [ ] No FR is unassigned (unassigned FRs = hard block)
151
+ - [ ] Must-priority FRs are distributed to ensure no single unit is overloaded
152
+
153
+ This draft mapping will be refined based on Q&A answers but serves as the baseline decomposition.
154
+
155
+ ## Step 5: Generate Context-Appropriate Questions
156
+
157
+ **DIRECTIVE**: Analyze the requirements and any available application design artifacts to generate ONLY questions relevant to THIS specific decomposition problem. Use the categories below as inspiration, NOT as a mandatory checklist. Skip entire categories if not applicable.
158
+
159
+ - EMBED questions using [Answer]: tag format
160
+ - Focus on ambiguities and missing information specific to this context
161
+ - Generate questions only where user input is needed for decision-making
162
+ - Reference the domain analysis findings when framing questions
163
+
164
+ **Example question categories** (adapt as needed):
165
+ - **Domain Boundaries** - Only if bounded context boundaries are ambiguous or overlapping
166
+ - **Dependencies** - Only if multiple units likely and integration approach is ambiguous
167
+ - **Team Alignment** - Only if team structure or ownership is unclear
168
+ - **Technical Considerations** - Only if scalability/deployment requirements differ across units
169
+ - **Business Domain** - Only if domain boundaries or bounded contexts are unclear
170
+ - **Code Organization (Greenfield multi-unit only)** - Ask deployment model and directory structure preferences
171
+ - **Decomposition Validation** - Questions to validate the draft requirement-to-unit mapping with the user
172
+
173
+ ## Step 6: Store Unit of Work Plan
174
+
175
+ - Save as `aidlc-docs/inception/plans/unit-of-work-plan.md`
176
+ - Include the domain analysis findings (Step 2)
177
+ - Include the draft requirement-to-unit mapping (Step 4)
178
+ - Include all [Answer]: tags for user input
179
+ - Ensure plan covers all aspects of system decomposition
180
+
181
+ ## Step 7: Include Mandatory Unit Artifacts in Plan
182
+
183
+ **ALWAYS** include these mandatory artifacts in the unit plan (when executing the full stage — if the stage is skipped, the Skip Pathway above handles these):
184
+ - [ ] Generate `aidlc-docs/inception/units/unit-of-work.md` with unit definitions and responsibilities — following `resources/templates/inception/units-template.md`
185
+ - [ ] Generate `aidlc-docs/inception/units/unit-of-work-dependency.md` with dependency matrix (when 2+ units)
186
+ - [ ] ~~Generate `aidlc-docs/inception/units/unit-of-work-story-map.md`~~ — Created during User Stories stage, not here. Do NOT generate this artifact during Units Generation.
187
+ - [ ] Generate per-unit briefs in `aidlc-docs/inception/units/{unit-slug}/unit-brief.md` (when 2+ units) — following `resources/templates/inception/unit-brief-template.md`
188
+ - [ ] **Greenfield only**: Document code organization strategy in `unit-of-work.md` (see code-generation.md for structure patterns)
189
+ - [ ] Validate unit boundaries and dependencies
190
+ - [ ] Ensure all requirements are assigned to units (100% coverage)
191
+ - [ ] Prepare unit briefs with placeholder story sections (populated during User Stories stage)
192
+ - [ ] Create `stories/` subdirectory in each unit folder as a placeholder for per-unit stories created in the User Stories stage
193
+
194
+ ## Step 8: Request User Input
195
+
196
+ - Ask user to fill [Answer]: tags directly in the plan document
197
+ - Emphasize importance of decomposition decisions
198
+ - Provide clear instructions on completing the [Answer]: tags
199
+
200
+ ## Step 9: Collect Answers
201
+
202
+ - Wait for user to provide answers to all questions using [Answer]: tags in the document
203
+ - Do not proceed until ALL [Answer]: tags are completed
204
+ - Review the document to ensure no [Answer]: tags are left blank
205
+
206
+ ## Step 10: ANALYZE ANSWERS (MANDATORY)
207
+
208
+ Before proceeding, you MUST carefully review all user answers for:
209
+ - **Vague or ambiguous responses**: "mix of", "somewhere between", "not sure", "depends"
210
+ - **Undefined criteria or terms**: References to concepts without clear definitions
211
+ - **Contradictory answers**: Responses that conflict with each other
212
+ - **Missing generation details**: Answers that lack specific guidance
213
+ - **Answers that combine options**: Responses that merge different approaches without clear decision rules
214
+ - **Conflicts with draft mapping**: Answers that invalidate the proposed requirement-to-unit mapping
215
+
216
+ ## Step 11: MANDATORY Follow-up Questions
217
+
218
+ If the analysis in step 10 reveals ANY ambiguous answers, you MUST:
219
+ - Add specific follow-up questions to the plan document using [Answer]: tags
220
+ - DO NOT proceed to approval until all ambiguities are resolved
221
+ - Examples of required follow-ups:
222
+ - "You mentioned 'mix of A and B' - what specific criteria should determine when to use A vs B?"
223
+ - "You said 'somewhere between A and B' - can you define the exact middle ground approach?"
224
+ - "You indicated 'not sure' - what additional information would help you decide?"
225
+ - "You mentioned 'depends on complexity' - how do you define complexity levels?"
226
+
227
+ ## Step 12: Finalize Requirement-to-Unit Mapping
228
+
229
+ After Q&A is complete, finalize the requirement-to-unit mapping based on user answers:
230
+
231
+ - [ ] Update the draft mapping with any changes from user feedback
232
+ - [ ] Verify 100% FR coverage — every FR in `requirements.md` is assigned to exactly one unit
233
+ - [ ] Verify 100% must-priority coverage — every Must FR is assigned
234
+ - [ ] Resolve any mapping conflicts surfaced during Q&A
235
+
236
+ **Hard block**: If any FR remains unassigned after Q&A, do not proceed to approval. Either assign it to an existing unit or create a new unit.
237
+
238
+ ## Step 13: Request Approval
239
+
240
+ - Ask: "**Unit of work plan complete. Review the plan in aidlc-docs/inception/plans/unit-of-work-plan.md. Ready to proceed to generation?**"
241
+ - DO NOT PROCEED until user confirms
242
+
243
+ ## Step 14: MANDATORY: Update Progress
244
+
245
+ - Log prompt and response in audit.md with timestamp (ISO 8601)
246
+ - Include complete approval prompt text
247
+ - **MANDATORY**: Update BOTH state files:
248
+ 1. Mark Units Planning complete in `aidlc-docs/{workflow-id}/aidlc-state.md`
249
+ 2. Update `aidlc-docs/{workflow-id}/checkpoint.json` current status
250
+ - **Do NOT proceed without completing state updates**
251
+
252
+ ---
253
+
254
+ # PART 2: GENERATION
255
+
256
+ ## Step 15: Load Unit of Work Plan
257
+
258
+ - [ ] Read the complete plan from `aidlc-docs/inception/plans/unit-of-work-plan.md`
259
+ - [ ] Read the canonical templates:
260
+ - `resources/templates/inception/units-template.md`
261
+ - `resources/templates/inception/unit-brief-template.md`
262
+ - [ ] Identify the next uncompleted step (first [ ] checkbox)
263
+ - [ ] Load the context and requirements for that step
264
+
265
+ ## Step 16: Execute Current Step
266
+
267
+ - [ ] Perform exactly what the current step describes
268
+ - [ ] Generate unit artifacts as specified in the plan, following the canonical templates
269
+ - [ ] Follow the approved decomposition approach from Planning
270
+ - [ ] Use the criteria and boundaries specified in the plan
271
+ - [ ] Ensure the Requirement-to-Unit Mapping table is included in `unit-of-work.md`
272
+
273
+ ## Step 17: MANDATORY: Update Progress
274
+
275
+ - [ ] Mark the completed step as [x] in the unit of work plan
276
+ - [ ] **MANDATORY**: Update `aidlc-docs/{workflow-id}/aidlc-state.md` current status
277
+ - [ ] **MANDATORY**: Update `aidlc-docs/{workflow-id}/checkpoint.json` current status
278
+ - [ ] Save all generated artifacts
279
+ - **Do NOT proceed without completing state updates**
280
+
281
+ ## Step 18: Generate Unit Briefs
282
+
283
+ **Condition**: Generate unit briefs when the decomposition produces **2 or more units**. If only 1 unit exists, skip to Step 18b.
284
+
285
+ For each unit defined in `unit-of-work.md`, create a per-unit brief file following the canonical template at `resources/templates/inception/unit-brief-template.md`.
286
+
287
+ **Path**: `aidlc-docs/{workflowId}/inception/units/{unit-slug}/unit-brief.md`
288
+
289
+ Where `{unit-slug}` follows the naming convention (e.g., `UNIT-001-foundation`).
290
+
291
+ The agent MUST read the template file and produce a brief with ALL required sections:
292
+ - Frontmatter (unit, unit_slug, intent, complexity, status, created, updated)
293
+ - Purpose (one paragraph)
294
+ - Scope (In Scope AND Out of Scope)
295
+ - Assigned Requirements (table with FR IDs, descriptions, priorities)
296
+ - Domain Concepts (Key Entities and Key Operations tables)
297
+ - Story Summary and Stories Assigned
298
+ - Dependencies (Depends On, Depended On By, External Dependencies)
299
+ - Technical Context (Integration Points, Data Storage)
300
+ - Constraints
301
+ - Success Criteria (Functional, Non-Functional, Quality)
302
+ - Bolt Suggestions
303
+ - Notes
304
+
305
+ **Rules**:
306
+ - Unit briefs supplement, not replace, `unit-of-work.md` — the overview document remains the single index of all units
307
+ - Assigned Requirements must trace back to FRs in `requirements.md` and match the Requirement-to-Unit Mapping
308
+ - Dependencies must be consistent with `unit-of-work-dependency.md`
309
+ - Stories Assigned table should contain placeholder content (stories are created in the User Stories stage after units are defined)
310
+ - Keep domain-level detail appropriate — detailed functional design happens in the Construction phase
311
+
312
+ ## Step 18b: Continue or Complete Generation
313
+
314
+ - [ ] If more plan steps remain, return to Step 15
315
+ - [ ] If all steps complete, verify units are ready for independence validation
316
+ - [ ] If unit briefs were generated (Step 18), verify consistency across all briefs
317
+ - [ ] Verify Requirement-to-Unit Mapping has 100% coverage
318
+
319
+ ---
320
+
321
+ # INDEPENDENCE VALIDATION (HARD GATE)
322
+
323
+ ## Step 18c: Unit Independence Validation
324
+
325
+ **This is a HARD GATE. No unit may proceed to Bolt Planning if it fails any independence criterion.**
326
+
327
+ Before marking Units Generation complete, verify EACH unit satisfies ALL five independence criteria:
328
+
329
+ | Criterion | Description | Failure Action |
330
+ |-----------|-------------|----------------|
331
+ | Single responsibility | The unit handles one bounded domain area. A unit spanning multiple unrelated domains must be split. | Split the unit |
332
+ | Clear interfaces | Any cross-unit interaction is expressed through an explicit interface (API contract, event schema, shared type definition). Units must not access each other's internal implementation. | Define explicit interfaces |
333
+ | No circular dependencies | The dependency matrix in `unit-of-work-dependency.md` must be a DAG (directed acyclic graph). Circular dependencies are a hard block. | Restructure dependencies |
334
+ | Independent buildability | Each unit can be developed and tested by a separate team without requiring runtime access to another unit's unbuilt code. | Decouple the unit |
335
+ | Explicit cross-unit deps | Every dependency a unit has on another unit must be documented in `unit-of-work-dependency.md`. Undocumented implicit dependencies are not allowed. | Document or remove dependency |
336
+
337
+ Validation results:
338
+
339
+ ```text
340
+ | Unit | Single Resp | Clear Interfaces | No Circular Deps | Independent Build | Explicit Deps | PASS? |
341
+ |------|-------------|------------------|-------------------|-------------------|---------------|-------|
342
+ | U-001 | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No |
343
+ | U-002 | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No | Yes/No |
344
+ ```
345
+
346
+ - If ANY unit fails ANY criterion: revise the decomposition and re-validate. Do NOT proceed.
347
+ - If ALL units pass ALL criteria: proceed to the completion message.
348
+
349
+ ---
350
+
351
+ ## Step 19: Present Completion Message
352
+
353
+ ```markdown
354
+ # Units Generation Complete
355
+
356
+ [AI-generated summary of units and decomposition approach]
357
+
358
+ ## Units Created
359
+ - U-001: {name} — {n} requirements, complexity: {S/M/L/XL}
360
+ - U-002: {name} — {n} requirements, complexity: {S/M/L/XL}
361
+
362
+ ## Dependency Graph
363
+ [U-001: {name}] --> [U-002: {name}] --> [U-003: {name}]
364
+
365
+ ## Requirement Coverage
366
+ - FR assigned: {n}/{total} (must be 100%)
367
+ - Must-priority covered: {n}/{n}
368
+
369
+ ## Independence Validation
370
+ All units passed 5/5 independence criteria.
371
+
372
+ ## Artifacts Created
373
+ - inception/units/unit-of-work.md
374
+ - inception/units/unit-of-work-dependency.md
375
+ - inception/units/UNIT-001-{slug}/unit-brief.md
376
+ - inception/units/UNIT-002-{slug}/unit-brief.md
377
+
378
+ ---
379
+
380
+ **REVIEW REQUIRED**
381
+
382
+ > Please examine the units generation artifacts at:
383
+ > `aidlc-docs/{workflow-id}/inception/units/`
384
+
385
+ **You may:**
386
+ - **Request Changes** — Ask for modifications to the units generation if required
387
+ - **Approve & Continue** — Approve units and proceed to **User Stories**
388
+ ```
389
+
390
+ ## Step 20: Wait for Explicit Approval
391
+
392
+ - Do not proceed until the user explicitly approves the units generation
393
+ - Approval must be clear and unambiguous
394
+ - If user requests changes, update the units and repeat the approval process (including independence validation)
395
+
396
+ ## Step 21: Record Approval Response
397
+
398
+ - Log the user's approval response with timestamp in `aidlc-docs/audit.md`
399
+ - Include the exact user response text
400
+ - Mark the approval status clearly
401
+
402
+ ## Step 22: MANDATORY: Update State Tracking
403
+
404
+ - **MANDATORY**: Update BOTH state files in the SAME interaction:
405
+ 1. Mark Units Generation stage complete in `aidlc-docs/{workflow-id}/aidlc-state.md`
406
+ 2. Update `aidlc-docs/{workflow-id}/checkpoint.json` — set units-generation status to "completed" with completed_at timestamp
407
+ - **Do NOT proceed to the next stage without completing this step**
408
+
409
+ ---
410
+
411
+ ## Completion Summary Format
412
+
413
+ After approval, present the final summary in this structured format:
414
+
415
+ ```text
416
+ ## Units Generation Complete
417
+
418
+ ### Units Created
419
+ - U-001: {name} — {n} requirements, complexity: {S/M/L/XL}
420
+ - U-002: {name} — {n} requirements, complexity: {S/M/L/XL}
421
+
422
+ ### Dependency Graph
423
+ [U-001] --> [U-002] --> [U-003]
424
+
425
+ ### Requirement Coverage
426
+ - FR assigned: {n}/{total} (100%)
427
+ - Must-priority covered: {n}/{n}
428
+
429
+ ### Artifacts Created
430
+ inception/units/unit-of-work.md
431
+ inception/units/unit-of-work-dependency.md
432
+ inception/units/UNIT-001-{slug}/unit-brief.md
433
+ inception/units/UNIT-002-{slug}/unit-brief.md
434
+ ```
435
+
436
+ ---
437
+
438
+ ## Test Contract
439
+
440
+ ```yaml
441
+ input: Requirements (FR-N IDs), application design (if available from brownfield analysis)
442
+ output: unit-of-work.md, unit-of-work-dependency.md, per-unit briefs (unit-of-work-story-map.md created during User Stories stage)
443
+ constraints:
444
+ requirement_coverage: 100% (every FR assigned to a unit)
445
+ must_requirement_coverage: 100%
446
+ unit_independence: all 5 criteria must pass
447
+ no_circular_dependencies: true
448
+ unit_brief_threshold: 2+ units (always generate briefs when 2 or more units exist)
449
+ checkpoints: 0 (part of inception review gate)
450
+ ```
451
+
452
+ ---
453
+
454
+ ## Critical Rules
455
+
456
+ ### Requirement Mapping Rules
457
+ - **REQUIREMENT MAPPING IS MANDATORY**: Every FR from `requirements.md` must be assigned to exactly one unit. Unassigned FRs are a hard block — generation cannot proceed.
458
+ - **Must-priority 100% coverage**: Every FR with `Must` priority must be assigned. No exceptions.
459
+ - **No duplicate assignment**: Each FR belongs to exactly one unit. If a requirement spans multiple units, decompose the requirement or assign to the unit with primary ownership.
460
+
461
+ ### Template Rules
462
+ - **TEMPLATES ARE MANDATORY**: Agents MUST read and follow the canonical templates at `resources/templates/inception/units-template.md` and `resources/templates/inception/unit-brief-template.md`. Do NOT invent custom formats.
463
+ - **All required sections**: Every section defined in the template must appear in the generated artifact. Missing sections are a rejection.
464
+
465
+ ### Unit Brief Rules
466
+ - **UNIT BRIEFS ALWAYS FOR 2+ UNITS**: Generate per-unit briefs whenever 2 or more units exist. This is NOT conditional on complexity — if there are 2+ units, briefs are mandatory.
467
+ - **Brief completeness**: Each brief must contain ALL sections defined in the template (Purpose, Scope, Assigned Requirements, Domain Concepts, Story Summary, Dependencies, Technical Context, Constraints, Success Criteria, Bolt Suggestions, Notes).
468
+
469
+ ### Process Rules
470
+ - **DECOMPOSITION BEFORE Q&A**: Domain analysis (Step 2) and decomposition criteria (Step 3) must be applied before generating questions (Step 5). Questions should be informed by the analysis, not generic.
471
+ - **INDEPENDENCE IS A HARD GATE**: A unit that fails any independence criterion in Step 18c cannot proceed. This is not advisory — it is a blocking validation.
472
+ - Generate ONLY context-relevant questions
473
+ - Use [Answer]: tag format for all questions
474
+ - Analyze all answers for ambiguities before proceeding
475
+ - Resolve ALL ambiguities with follow-up questions
476
+ - Get explicit user approval before generation
477
+
478
+ ### Generation Phase Rules
479
+ - **NO HARDCODED LOGIC**: Only execute what's written in the unit of work plan
480
+ - **FOLLOW PLAN EXACTLY**: Do not deviate from the step sequence
481
+ - **UPDATE CHECKBOXES**: Mark [x] immediately after completing each step
482
+ - **USE APPROVED APPROACH**: Follow the decomposition methodology from Planning
483
+ - **VERIFY COMPLETION**: Ensure all unit artifacts are complete before proceeding
484
+
485
+ ---
486
+
487
+ ## Completion Criteria
488
+
489
+ - All planning questions answered and ambiguities resolved
490
+ - User approval obtained for the plan
491
+ - All steps in unit of work plan marked [x]
492
+ - All unit artifacts generated according to plan and canonical templates:
493
+ - `unit-of-work.md` with unit definitions and Requirement-to-Unit Mapping
494
+ - `unit-of-work-dependency.md` with dependency matrix (when 2+ units)
495
+ - Per-unit briefs with placeholder story sections (when 2+ units)
496
+ - 100% requirement coverage (every FR assigned to a unit)
497
+ - 100% must-priority coverage
498
+ - All units pass independence validation (5/5 criteria)
499
+ - Units verified and ready for User Stories stage
500
+
501
+ ---
502
+
503
+ ## Next Stage: User Stories
504
+
505
+ After units are approved, the workflow proceeds to **User Stories** — a separate inception stage that creates per-unit user stories in each unit's `stories/` directory (e.g., `inception/units/{UNIT-NNN-slug}/stories/S-001-{slug}.md`). Stories are scoped to their parent unit and reference the unit ID. Personas remain project-wide at `inception/user-stories/personas.md`. After stories are created, the workflow proceeds to **Bolt Planning**, which decomposes each unit's stories into bolt spec files.