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,588 +1,588 @@
1
- # Bolt Planning - Inception Stage
2
-
3
- ## Overview
4
-
5
- Bolt Planning is the final inception stage. It decomposes each unit of work into **bolts** — scoped execution packages that a code-generation agent can implement in a focused session. The goal is to produce human-reviewable bolt specs alongside requirements, stories, and unit definitions so that construction starts with pre-planned, dependency-ordered bolts rather than ad-hoc decomposition.
6
-
7
- **When this stage runs**: After Units Generation completes and all unit stories are defined.
8
-
9
- **When this stage is skipped**: Single shallow unit with `depth_score <= 4` AND pathway is not `bugfix`. Set `inception_stages["bolt-planning"].status = "skipped"` with an appropriate skip reason.
10
-
11
- ---
12
-
13
- ## Input (Required Artifacts)
14
-
15
- Before bolt planning can begin, ALL of the following must exist and be loaded:
16
-
17
- | Artifact | Location | Purpose |
18
- |----------|----------|---------|
19
- | **Unit definitions** | `inception/units/unit-of-work.md` | Unit IDs, titles, acceptance criteria |
20
- | **Unit briefs** | `inception/units/{unit-slug}/unit-brief.md` | Detailed scope per unit |
21
- | **Story-to-unit map** | `inception/units/unit-of-work-story-map.md` | Which stories belong to which unit |
22
- | **Stories** | `inception/units/{UNIT-NNN-slug}/stories/` (per-unit) or `inception/user-stories/stories.md` (fallback) | Per-unit story files with IDs and priorities |
23
- | **Requirements** | `inception/requirements/requirements.md` | FR-N requirement IDs and priorities |
24
-
25
- All paths are relative to `aidlc-docs/{workflowId}/`.
26
-
27
- > **CRITICAL**: Do NOT begin bolt planning if any required artifact is missing. Surface the gap to the user and halt.
28
-
29
- ---
30
-
31
- ## Output (What This Stage Produces)
32
-
33
- ```
34
- aidlc-docs/{workflowId}/construction/{UNIT-NNN-slug}/bolts/
35
- BOLT-001-{slug}/spec.md
36
- BOLT-002-{slug}/spec.md
37
- BOLT-003-{slug}/spec.md
38
- ```
39
-
40
- > **WARNING**: DO NOT CREATE:
41
- > - `bolt-plan.md` (summary doc) -- the individual `spec.md` files ARE the plan
42
- > - `README.md` files in bolt directories
43
- > - Flat files like `BOLT-001.md` (must be in a directory as `spec.md`)
44
- > - Flat `construction/bolts/` paths (bolts MUST be nested under their parent unit)
45
-
46
- ---
47
-
48
- ## Test Contract
49
-
50
- ```yaml
51
- input: Units with assigned stories from inception
52
- output: Bolt spec.md files nested under construction/{unit}/bolts/{bolt}/
53
- constraints:
54
- max_per_unit: 8
55
- max_total: 50
56
- coverage_threshold: 95%
57
- must_requirements: 100%
58
- checkpoints: 0 (part of inception review gate)
59
- ```
60
-
61
- ---
62
-
63
- ## Bolt Naming Convention (MANDATORY)
64
-
65
- Bolt IDs use **global sequential numbering across ALL units** -- numbering does NOT reset per unit.
66
-
67
- Format: `BOLT-NNN-slug`
68
-
69
- - `NNN` is zero-padded to three digits: `001`, `002`, `003`, ...
70
- - `slug` is a short kebab-case description of the bolt's scope (lowercase, alphanumeric + hyphens only)
71
- - Numbers are assigned in creation order across all units
72
- - The regex pattern enforced by the TypeScript validator is: `^BOLT-\d{3}-[a-z0-9-]+$`
73
-
74
- Examples:
75
-
76
- ```
77
- BOLT-001-data-model (Unit 1, bolt 1)
78
- BOLT-002-repository-layer (Unit 1, bolt 2)
79
- BOLT-003-api-endpoints (Unit 1, bolt 3)
80
- BOLT-004-dashboard-ui (Unit 2, bolt 1 -- numbering continues globally)
81
- ```
82
-
83
- > **CRITICAL**: Never reset numbering per unit. Bolt 4 in unit 2 is `BOLT-004`, not `BOLT-001`.
84
-
85
- ---
86
-
87
- ## Directory Structure
88
-
89
- Bolt specs are nested under their parent unit:
90
-
91
- ```
92
- aidlc-docs/{workflowId}/construction/{UNIT-NNN-slug}/bolts/
93
- BOLT-001-{slug}/spec.md
94
- BOLT-002-{slug}/spec.md
95
- BOLT-003-{slug}/spec.md
96
- ```
97
-
98
- Full path examples:
99
-
100
- ```
101
- aidlc-docs/{workflowId}/construction/UNIT-001-foundation/bolts/BOLT-001-data-model/spec.md
102
- aidlc-docs/{workflowId}/construction/UNIT-001-foundation/bolts/BOLT-002-repository-layer/spec.md
103
- aidlc-docs/{workflowId}/construction/UNIT-002-frontend/bolts/BOLT-003-dashboard-ui/spec.md
104
- ```
105
-
106
- ---
107
-
108
- ## Process (Strict Sequential Steps)
109
-
110
- ### Step 1: Load and Validate Inputs
111
-
112
- For each unit defined in `inception/units/unit-of-work.md`:
113
-
114
- 1. Read the unit definition (ID, title, success criteria and requirements, estimated effort)
115
- 2. Read the unit brief at `inception/units/{unit-slug}/unit-brief.md`
116
- 3. Read the assigned stories from `inception/units/unit-of-work-story-map.md`
117
- 4. Resolve each story's full definition from `inception/units/{unit-slug}/stories/` (per-unit story files) or fall back to `inception/user-stories/stories.md`
118
- 5. Resolve each story's requirement references from `inception/requirements/requirements.md`
119
- 6. Confirm every story has an ID (`S-NNN`), a priority (`Must`, `Should`, `Could`), and at least one requirement reference (`FR-N`)
120
-
121
- > **HARD BLOCK**: If any unit has zero assigned stories, halt and surface the issue. Every unit must have at least one story assigned.
122
-
123
- ### Step 2: Assess Story Complexity (4-Factor Analysis)
124
-
125
- For **each story** in every unit, assess complexity using all four factors:
126
-
127
- | Factor | Question | Low (1) | Medium (2) | High (3) |
128
- |--------|----------|---------|------------|----------|
129
- | **Complexity** | How intricate is the logic? | CRUD, known patterns | Business rules, validation | Novel algorithms, state machines |
130
- | **Uncertainty** | How clear are requirements? | Fully specified | Some ambiguity | Many unknowns |
131
- | **Dependencies** | What external things needed? | Self-contained | Internal APIs/units | External systems, third-party |
132
- | **Testing** | What validation needed? | Unit tests only | Integration tests | E2E + manual testing |
133
-
134
- Record the 4-factor scores for each story. These scores drive grouping decisions in Step 3.
135
-
136
- > **WARNING**: Any story with Uncertainty = High (3) MUST be flagged. Consider creating a **spike bolt** to reduce uncertainty before the implementation bolt.
137
-
138
- ### Step 3: Group Stories into Bolts
139
-
140
- For each unit, group its stories into cohesive bolts using these **explicit rules** (in priority order):
141
-
142
- 1. **Cohesion**: Stories operating on the same domain entity or bounded context belong in the same bolt
143
- 2. **Dependencies**: If Story A requires Story B's output, they go in the same bolt OR Story B's bolt must be sequenced before Story A's bolt
144
- 3. **Balance**: Mix high-complexity and low-complexity stories within a bolt to avoid creating "monster bolts"
145
- 4. **Limit**: Target 5-6 stories per bolt. Hard maximum is 8 stories per bolt (enforced by TypeScript validator: `MAX_BOLTS_PER_UNIT = 8` bolts per unit)
146
- 5. **Risk**: Any story with Uncertainty = High (3) goes into a dedicated spike bolt that is sequenced FIRST
147
-
148
- **Grouping by architectural layer** (typical ordering within a unit):
149
-
150
- | Layer | Scope | Typical Bolt Slug |
151
- |-------|-------|-------------------|
152
- | Data models and schema migrations | Entity definitions, DB schema | `data-model` |
153
- | Repository / data access layer | CRUD operations, queries | `repo-layer` |
154
- | Business logic / service layer | Domain rules, validation | `service-layer` |
155
- | API endpoints | Controllers, routes, DTOs | `api-endpoints` |
156
- | UI components | Screens, forms, interactions | `ui-components` |
157
- | Infrastructure | Auth, logging, config, middleware | `infrastructure` |
158
-
159
- > **HARD CONSTRAINT**: Maximum **8 bolts per unit**, **50 bolts total** across all units. If a unit's scope exceeds 8 bolts, halt and flag it for re-scoping before proceeding.
160
-
161
- ### Step 4: Assign Express Mode
162
-
163
- For each bolt, determine whether express mode applies:
164
-
165
- - `express_mode: true` if `depth_target <= 4` OR the parent workflow pathway is `bugfix`
166
- - Express bolts skip the elaboration stage during construction and go directly to code generation
167
- - All bolts within a given depth/pathway context receive the same express mode value
168
-
169
- The express mode determination is handled programmatically by `isExpressBoltEligible()` in `express-bolt-factory.ts`.
170
-
171
- ### Step 5: Analyze Dependencies (3-Level Analysis)
172
-
173
- Dependency analysis operates at three distinct levels. All three MUST be performed.
174
-
175
- #### 5a. Story Dependencies (within a bolt)
176
-
177
- Within each bolt, identify ordering constraints between stories:
178
-
179
- - If Story A's implementation depends on Story B's artifacts, Story B must appear first in the bolt's story list
180
- - Document internal story ordering in the bolt's Scope section
181
-
182
- #### 5b. Bolt Dependencies (within a unit)
183
-
184
- For each unit, identify which bolts must complete before others can begin:
185
-
186
- - Populate `requires_bolts`: array of bolt IDs this bolt depends on
187
- - Populate `enables_bolts`: array of bolt IDs that depend on this bolt (reverse, informational)
188
- - Typical ordering: data model -> repository -> service -> API -> UI
189
-
190
- Output format for each bolt's dependency analysis:
191
-
192
- ```markdown
193
- #### Bolt Dependencies (within unit)
194
- - **BOLT-001-data-model** (Required): Planned
195
- - **BOLT-002-repo-layer** (Required): Planned
196
- #### Enables (bolts waiting on this)
197
- - BOLT-004-api-endpoints
198
- ```
199
-
200
- #### 5c. Unit Dependencies (cross-unit)
201
-
202
- Identify whether any bolt requires work from a different unit:
203
-
204
- - Populate `requires_units` with unit IDs (e.g., `["UNIT-001-foundation"]`)
205
- - Cross-unit dependencies MUST be explicit and minimal -- prefer loose coupling
206
- - Flag any unit that depends on 3 or more other units for mandatory review
207
-
208
- Output format:
209
-
210
- ```markdown
211
- #### Unit Dependencies (cross-unit)
212
- - **UNIT-001-foundation** (Required): Database schemas must exist
213
- ```
214
-
215
- #### Dependency Warnings
216
-
217
- After completing all three levels, output a warnings section:
218
-
219
- ```markdown
220
- ### Dependency Warnings
221
- - BOLT-003-api-endpoints depends on 3 bolts (high fan-in -- consider splitting)
222
- - UNIT-002-frontend has cross-unit dependency on UNIT-001-foundation (verify interface contract exists)
223
- - No circular dependencies detected
224
- ```
225
-
226
- #### Validate No Circular Dependencies
227
-
228
- Before proceeding to spec creation:
229
-
230
- - **Within a unit**: Ensure the `requires_bolts` graph is a DAG (no cycles). The TypeScript validator `BoltSpecValidator.validateNoCycles()` enforces this.
231
- - **Across units**: Ensure no two units mutually depend on each other via `requires_units`
232
- - If circular dependencies are found, **halt and re-scope bolts to break the cycle before continuing**
233
-
234
- ### Step 6: Generate Bolt Sequence Visualization
235
-
236
- Before creating specs, produce an ASCII dependency graph showing bolt execution order:
237
-
238
- ```
239
- [BOLT-001-data-model] --> [BOLT-002-repo-layer] --> [BOLT-003-service-layer]
240
- |
241
- v
242
- [BOLT-004-api-endpoints] --> [BOLT-005-ui-components]
243
- ```
244
-
245
- For multi-unit workflows, show unit boundaries:
246
-
247
- ```
248
- UNIT-001-foundation:
249
- [BOLT-001-data-model] --> [BOLT-002-repo-layer] --> [BOLT-003-api]
250
-
251
- UNIT-002-frontend:
252
- [BOLT-004-dashboard] --> [BOLT-005-settings]
253
- |
254
- +-- requires UNIT-001-foundation
255
- ```
256
-
257
- Present this visualization to the user before proceeding to spec file creation.
258
-
259
- ### Step 7: Create Bolt Spec Files
260
-
261
- For each bolt, create the directory and write the spec file:
262
-
263
- ```
264
- aidlc-docs/{workflowId}/construction/{parent_unit_id}/bolts/{bolt_id}/spec.md
265
- ```
266
-
267
- Populate ALL frontmatter fields and ALL required body sections. Do NOT leave template placeholders -- fill every field from the unit artifacts.
268
-
269
- See the **Bolt Spec Format** section below for the complete template.
270
-
271
- ### Step 8: Validate Frontmatter (Per-Bolt Checklist)
272
-
273
- For EACH bolt spec created, verify the following checklist. Every item MUST pass:
274
-
275
- - [ ] `id` -- present, matches `BOLT-NNN-slug` format (`^BOLT-\d{3}-[a-z0-9-]+$`)
276
- - [ ] `title` -- present, non-empty string
277
- - [ ] `parent_unit_id` -- present, matches an existing unit ID
278
- - [ ] `sequence` -- positive integer (>= 1)
279
- - [ ] `status` -- set to `planned`
280
- - [ ] `created` -- ISO 8601 timestamp
281
- - [ ] `intent` -- set to the workflow ID
282
- - [ ] `depth_target` -- number on 1-11 scale
283
- - [ ] `express_mode` -- boolean, correctly derived from depth_target/pathway
284
- - [ ] `estimated_effort_hours` -- positive number
285
- - [ ] `requirements` -- array with at least one FR-N ID
286
- - [ ] `stories` -- array of story IDs (in both frontmatter AND body)
287
- - [ ] `docs_impact` -- array of valid values (see Frontmatter Field Reference)
288
- - [ ] `requires_bolts` -- array present (can be empty `[]`)
289
- - [ ] `enables_bolts` -- array present (can be empty `[]`)
290
- - [ ] `requires_units` -- array present (can be empty `[]`)
291
- - [ ] `blocked` -- boolean, set to `false` on creation
292
- - [ ] `complexity` -- block with all 4 fields (`avg_complexity`, `avg_uncertainty`, `max_dependencies`, `testing_scope`)
293
-
294
- > **CRITICAL**: A bolt that fails ANY frontmatter check is invalid. Fix it before proceeding.
295
-
296
- ### Step 9: Validate Coverage
297
-
298
- After all bolts for each unit are written, validate story and requirement coverage:
299
-
300
- #### Story Coverage
301
-
302
- | Coverage | Result |
303
- |----------|--------|
304
- | >= 95% of unit stories assigned to bolts | **Pass** -- proceed |
305
- | 80-94% covered | **Warning** -- user MUST explicitly acknowledge the gap before continuing |
306
- | < 80% covered | **Hard block** -- revise bolt decomposition, do NOT continue |
307
-
308
- Coverage formula: `(stories assigned to at least one bolt) / (total stories in unit) * 100`
309
-
310
- #### Requirement Coverage
311
-
312
- Every `Must`-priority requirement in `requirements.md` that is referenced by any story in the unit MUST be referenced by at least one bolt's `requirements` field. Any uncovered `Must` requirement is a **hard block** regardless of percentage score.
313
-
314
- #### Content Validation Checklist
315
-
316
- After coverage passes, verify these content-level constraints:
317
-
318
- - [ ] All stories assigned to bolts (100% target, 95% minimum)
319
- - [ ] All `Must`-priority requirements covered (100%, no exceptions)
320
- - [ ] Dependencies respected (bolt-to-bolt AND unit-to-unit)
321
- - [ ] Each bolt has clear Expected Outputs
322
- - [ ] No bolt exceeds 8 stories (target 5-6)
323
- - [ ] No circular dependencies (within-unit or cross-unit)
324
- - [ ] Cross-unit dependencies are explicit and minimal
325
- - [ ] Every bolt has at least one acceptance criterion
326
- - [ ] Every bolt has at least one target file
327
-
328
- ### Step 10: Validate Unit Independence
329
-
330
- After all bolts for all units are planned, verify unit-level independence:
331
-
332
- - **Single responsibility**: Each unit handles one bounded domain area
333
- - **Clear interfaces**: Cross-unit interactions go through explicit interfaces (APIs, events, contracts)
334
- - **No circular unit dependencies**: The `requires_units` graph across all bolts must be a DAG
335
- - **Independent buildability**: Each unit can be developed and tested by a separate agent without requiring internal access to other units' implementation details
336
- - **Minimal cross-unit deps**: Flag any unit that depends on 3 or more other units for mandatory review
337
-
338
- If validation fails, surface the specific issue and require resolution before marking bolt-planning complete.
339
-
340
- ### Step 11: Register Bolts in Checkpoint
341
-
342
- After all validations pass, register bolts in the workflow checkpoint:
343
-
344
- - Call `registerBoltsInCheckpoint(bolts, checkpoint)` for each unit's bolts
345
- - This creates `ConstructionBoltProgress` entries with `status: 'planned'` and all four stage progress records initialized to `not_started`
346
- - Update `inception_stages["bolt-planning"].status = "completed"`
347
-
348
- ---
349
-
350
- ## Bolt Spec Format
351
-
352
- The canonical bolt spec template is defined at:
353
-
354
- **Template file**: `resources/templates/construction/bolt-spec-template.md`
355
-
356
- When creating bolt specs, agents MUST read this template file and follow its structure exactly. The template defines:
357
-
358
- - All required frontmatter fields (including runtime state fields: `started`, `completed`, `current_stage`, `stages_completed`)
359
- - All required body sections (Scope, Stories Included, Acceptance Criteria, Expected Outputs, Target Files, Stages, Dependencies, Success Criteria, Traceability)
360
- - Status values and stage status symbols
361
- - A concrete example of a bolt spec
362
-
363
- > **CRITICAL**: Do NOT invent your own spec format. Read and follow the template.
364
-
365
- ### Frontmatter Field Reference
366
-
367
- | Field | Type | Required | Description |
368
- |-------|------|----------|-------------|
369
- | `id` | string | YES | Globally unique bolt ID. Must match `BOLT-NNN-slug` pattern. |
370
- | `title` | string | YES | Short human-readable title. |
371
- | `parent_unit_id` | string | YES | ID of the parent construction unit (e.g., `UNIT-001-foundation`). |
372
- | `sequence` | integer | YES | Execution order within the unit (1-based, positive). |
373
- | `status` | string | YES | Always `planned` on creation. Lifecycle: `planned` -> `in_progress` -> `built` -> `in_review` -> `done` or `failed`. |
374
- | `created` | string | YES | ISO 8601 timestamp of spec creation. |
375
- | `intent` | string | YES | Parent workflow ID (matches `{workflowId}`). |
376
- | `depth_target` | number | YES | Reasoning depth (1-11 scale). Express mode threshold: <= 4. |
377
- | `express_mode` | boolean | YES | `true` if eligible for express execution (skips elaboration). Derived from `depth_target <= 4 OR pathway == 'bugfix'`. |
378
- | `estimated_effort_hours` | number | YES | Rough hours estimate for human review. |
379
- | `requirements` | string[] | YES | Requirement IDs from `requirements.md` this bolt satisfies (e.g., `["FR-1", "FR-3"]`). **Minimum 1 required.** |
380
- | `stories` | string[] | YES | Story IDs from `stories.md` this bolt addresses (e.g., `["S-001"]`). |
381
- | `docs_impact` | string[] | YES | Documentation types this bolt impacts. Valid values: `none`, `readme`, `user-guide`, `config-reference`, `cli-reference`, `migration-guide`, `architecture`, `code-comments`. |
382
- | `requires_bolts` | string[] | YES | Bolt IDs that must complete before this bolt begins (within-unit). Empty array `[]` if none. |
383
- | `enables_bolts` | string[] | YES | Bolt IDs that depend on this bolt completing (reverse deps, informational). Empty array `[]` if none. |
384
- | `requires_units` | string[] | YES | Unit IDs that must be fully built before this bolt begins (cross-unit). Empty array `[]` if none. |
385
- | `blocked` | boolean | YES | Always `false` on creation. Set to `true` by executor when a dependency is incomplete. |
386
- | `started` | string/null | YES | ISO 8601 timestamp when execution began. `null` on creation. |
387
- | `completed` | string/null | YES | ISO 8601 timestamp when all stages finished. `null` on creation. |
388
- | `current_stage` | string/null | YES | Currently executing stage. `null` on creation. |
389
- | `stages_completed` | array | YES | Array of completed stage records. Empty `[]` on creation. |
390
- | `complexity` | object | YES | 4-factor complexity assessment block (see below). |
391
-
392
- #### Complexity Block Fields
393
-
394
- | Field | Type | Range | Description |
395
- |-------|------|-------|-------------|
396
- | `avg_complexity` | number | 1-3 | Average complexity score across stories. 1=Low (CRUD), 2=Medium (business rules), 3=High (novel algorithms). |
397
- | `avg_uncertainty` | number | 1-3 | Average uncertainty score. 1=Fully specified, 2=Some ambiguity, 3=Many unknowns. |
398
- | `max_dependencies` | number | 1-3 | Highest dependency score among stories. 1=Self-contained, 2=Internal APIs, 3=External systems. |
399
- | `testing_scope` | number | 1-3 | Required testing depth. 1=Unit tests, 2=Integration tests, 3=E2E + manual. |
400
-
401
- ### Required Body Sections
402
-
403
- Every bolt spec MUST contain ALL of the following sections. No section may be omitted.
404
-
405
- ```markdown
406
- # {Bolt Title}
407
-
408
- ## Scope
409
-
410
- {What this bolt implements. A focused description of the functionality delivered
411
- by this bolt alone. Include internal story ordering if relevant.}
412
-
413
- ## Stories Included
414
-
415
- - [ ] **S-001**: User can register -- Priority: Must
416
- - [ ] **S-002**: User can login -- Priority: Must
417
-
418
- ## Acceptance Criteria
419
-
420
- - [ ] {Measurable, verifiable criterion 1}
421
- - [ ] {Measurable, verifiable criterion 2}
422
-
423
- ## Expected Outputs
424
-
425
- - User entity and migration
426
- - Registration API endpoint
427
- - Unit tests for registration flow
428
-
429
- ## Target Files
430
-
431
- - `src/models/user.ts` -- create: User entity definition
432
- - `src/services/auth.ts` -- create: Authentication service
433
- - `src/routes/auth.ts` -- create: Auth API routes
434
-
435
- ## Dependencies
436
-
437
- ### Bolt Dependencies (within unit)
438
- - **BOLT-001-data-model** (Required): Planned
439
-
440
- ### Unit Dependencies (cross-unit)
441
- - None
442
-
443
- ### Enables (bolts waiting on this)
444
- - BOLT-003-api-endpoints
445
-
446
- ## Stages
447
-
448
- - [ ] **1. elaboration**: Pending
449
- - [ ] **2. code_generation**: Pending
450
- - [ ] **3. build_and_test**: Pending
451
- - [ ] **4. review**: Pending
452
-
453
- ## Success Criteria
454
-
455
- - [ ] All stories implemented
456
- - [ ] All acceptance criteria met
457
- - [ ] Tests passing
458
- - [ ] Code reviewed and approved
459
-
460
- ## Traceability
461
-
462
- - **Requirements**: FR-1, FR-2
463
- - **Stories**: S-001, S-002
464
- ```
465
-
466
- > **CRITICAL**: The body must use checkbox syntax (`- [ ]`) for Stories Included, Acceptance Criteria, Stages, and Success Criteria. These checkboxes are tracked during construction execution.
467
-
468
- ---
469
-
470
- ## Critical Rules
471
-
472
- > **WARNING**: Violation of any rule in this section produces an invalid bolt plan. The agent MUST NOT proceed past validation if any rule is broken.
473
-
474
- ### Naming and Structure
475
-
476
- - **GLOBAL BOLT NUMBERING**: `BOLT-NNN` numbers are assigned globally across all units. Never reset per unit.
477
- - **NESTED PATHS ONLY**: Bolt specs always live at `construction/{unit-id}/bolts/{bolt-id}/spec.md`. No flat `construction/bolts/` paths.
478
- - **NO BOLT-PLAN.MD**: Do not create a `bolt-plan.md` summary document. The individual `spec.md` files ARE the plan.
479
- - **NO README FILES**: Do not create `README.md` in bolt directories.
480
-
481
- ### Frontmatter Integrity
482
-
483
- - **ALL FIELDS MANDATORY**: Every frontmatter field listed in the Field Reference must be present with a valid value. No template placeholders.
484
- - **DEPENDENCY FIELDS ARE MANDATORY**: Every spec must include `requires_bolts`, `enables_bolts`, `requires_units`, and `blocked` in frontmatter -- even if the values are empty arrays and `false`.
485
- - **REQUIREMENT REFERENCE IS MANDATORY**: Every bolt must reference at least one `FR-N` requirement ID. A bolt with an empty `requirements` array is invalid.
486
- - **STATUS ALWAYS PLANNED**: On creation, `status` must be `planned`. Never set to `in_progress` or any other value during bolt planning.
487
- - **COMPLEXITY BLOCK MANDATORY**: Every bolt must include the 4-field `complexity` block derived from Step 2 analysis.
488
-
489
- ### Coverage and Completeness
490
-
491
- - **95% STORY COVERAGE MINIMUM**: At least 95% of unit stories must be assigned to bolts. Below 80% is a hard block.
492
- - **100% MUST-REQUIREMENT COVERAGE**: Every `Must`-priority requirement must appear in at least one bolt. No exceptions.
493
- - **NO ORPHAN STORIES**: Every story in the unit should appear in exactly one bolt. Duplicate assignment across bolts is acceptable only when justified (shared infrastructure stories).
494
-
495
- ### Dependency Safety
496
-
497
- - **NO SELF-REFERENCES**: A bolt cannot list itself in `requires_bolts`.
498
- - **NO PARENT UNIT REFERENCES**: A bolt cannot list its own parent unit in `requires_units`.
499
- - **NO CIRCULAR DEPENDENCIES**: The dependency graph must be a DAG at both bolt and unit levels. Enforced by `BoltSpecValidator.validateNoCycles()`.
500
- - **CROSS-UNIT MINIMIZATION**: Flag any unit with 3+ cross-unit dependencies for mandatory review.
501
-
502
- ### Size Constraints
503
-
504
- - **MAX 8 BOLTS PER UNIT**: Enforced by `BoltSpecValidator` (`MAX_BOLTS_PER_UNIT = 8`). Target 5-6.
505
- - **MAX 50 BOLTS TOTAL**: Enforced by `BoltSpecValidator` (`MAX_BOLTS_TOTAL = 50`).
506
- - **TARGET 5-6 STORIES PER BOLT**: Hard maximum 8 stories. If a bolt exceeds 6 stories, provide written justification.
507
-
508
- ---
509
-
510
- ## Agent Delegation Strategy
511
-
512
- **MANDATORY**: Delegate bolt spec file generation to `olympian`. Do NOT generate multi-bolt, multi-unit spec files directly from the orchestrator.
513
-
514
- **Execution mode**: Foreground sequential -- one coherent bolt planning pass per workflow.
515
-
516
- **Delegation scope**:
517
-
518
- | Steps | Owner | Rationale |
519
- |-------|-------|-----------|
520
- | 1-3 (Load inputs, assess complexity, decompose into bolts) | **Orchestrator** | Requires reading multiple artifacts and making decomposition decisions |
521
- | 4-7 (Express mode, dependency analysis, visualization, spec creation) | **Delegated to `olympian`** | Writes spec.md files to disk, performs dependency analysis |
522
- | 8-11 (Frontmatter validation, coverage, unit independence, checkpoint) | **Orchestrator** | Final validation gates and checkpoint registration |
523
-
524
- **After agent completes**: The orchestrator validates coverage and unit independence (Steps 8-11), then presents the completion summary and approval gate.
525
-
526
- **Optional quality gate -- `momus` review**: When multiple units exist (3+) or cross-unit dependencies are present, invoke `momus` to critically evaluate the bolt decomposition before presenting to the user.
527
-
528
- ---
529
-
530
- ## Completion Summary Format
531
-
532
- After all validation passes, present the following summary to the user:
533
-
534
- ```markdown
535
- ## Bolt Plan Complete: {unit-name}
536
-
537
- ### Bolts Created
538
- - [ ] **BOLT-001-data-model** (express: false): S-001, S-002
539
- - [ ] **BOLT-002-repo-layer** (express: false): S-003, S-004
540
-
541
- ### Dependency Graph
542
- BOLT-001-data-model --> BOLT-002-repo-layer --> BOLT-003-api
543
-
544
- ### Directories Created
545
- `construction/UNIT-001-foundation/bolts/BOLT-001-data-model/spec.md`
546
- `construction/UNIT-001-foundation/bolts/BOLT-002-repo-layer/spec.md`
547
-
548
- ### Coverage
549
- - Stories covered: 6/6 (100%)
550
- - Requirements covered: FR-1, FR-2, FR-3 (3/3)
551
- - Must-requirements covered: 3/3 (100%)
552
-
553
- ### Complexity Summary
554
- - Average complexity across all bolts: 2.1
555
- - Highest uncertainty bolt: BOLT-003-api (avg_uncertainty: 2)
556
- - Spike bolts: 0
557
-
558
- ### Total
559
- - {n} bolts created
560
- - {n} stories covered
561
- - {n} cross-unit dependencies
562
- - {n} express bolts
563
- ```
564
-
565
- ---
566
-
567
- ## Completion Criteria
568
-
569
- ALL of the following must be true before bolt planning is marked complete:
570
-
571
- - [ ] All bolt specs created at `construction/{UNIT-NNN-slug}/bolts/{BOLT-NNN-slug}/spec.md`
572
- - [ ] No `bolt-plan.md` summary document created (specs ARE the plan)
573
- - [ ] All required body sections present in every spec (Scope, Stories Included, Acceptance Criteria, Expected Outputs, Target Files, Stages, Dependencies, Success Criteria, Traceability)
574
- - [ ] All frontmatter fields populated with valid values (no template placeholders)
575
- - [ ] Frontmatter validation checklist (Step 8) passes for every bolt
576
- - [ ] `status: planned` set on every bolt
577
- - [ ] `created` timestamp set on every bolt
578
- - [ ] `intent` set to workflow ID on every bolt
579
- - [ ] `complexity` block with all 4 fields present on every bolt
580
- - [ ] All `requires_bolts`, `enables_bolts`, `requires_units`, and `blocked` fields set
581
- - [ ] Story coverage >= 95% for all units (or gap explicitly acknowledged for 80-94%)
582
- - [ ] All `Must`-priority requirements referenced by at least one bolt (100%, no exceptions)
583
- - [ ] No circular dependencies within or across units
584
- - [ ] Unit independence validated
585
- - [ ] Bolts registered in checkpoint via `registerBoltsInCheckpoint()`
586
- - [ ] `inception_stages["bolt-planning"].status` set to `"completed"`
587
- - [ ] Completion summary presented to user
588
- - [ ] User has approved the bolt plan before proceeding to construction
1
+ # Bolt Planning - Inception Stage
2
+
3
+ ## Overview
4
+
5
+ Bolt Planning is the final inception stage. It decomposes each unit of work into **bolts** — scoped execution packages that a code-generation agent can implement in a focused session. The goal is to produce human-reviewable bolt specs alongside requirements, stories, and unit definitions so that construction starts with pre-planned, dependency-ordered bolts rather than ad-hoc decomposition.
6
+
7
+ **When this stage runs**: After Units Generation completes and all unit stories are defined.
8
+
9
+ **When this stage is skipped**: Single shallow unit with `depth_score <= 4` AND pathway is not `bugfix`. Set `inception_stages["bolt-planning"].status = "skipped"` with an appropriate skip reason.
10
+
11
+ ---
12
+
13
+ ## Input (Required Artifacts)
14
+
15
+ Before bolt planning can begin, ALL of the following must exist and be loaded:
16
+
17
+ | Artifact | Location | Purpose |
18
+ |----------|----------|---------|
19
+ | **Unit definitions** | `inception/units/unit-of-work.md` | Unit IDs, titles, acceptance criteria |
20
+ | **Unit briefs** | `inception/units/{unit-slug}/unit-brief.md` | Detailed scope per unit |
21
+ | **Story-to-unit map** | `inception/units/unit-of-work-story-map.md` | Which stories belong to which unit |
22
+ | **Stories** | `inception/units/{UNIT-NNN-slug}/stories/` (per-unit) or `inception/user-stories/stories.md` (fallback) | Per-unit story files with IDs and priorities |
23
+ | **Requirements** | `inception/requirements/requirements.md` | FR-N requirement IDs and priorities |
24
+
25
+ All paths are relative to `aidlc-docs/{workflowId}/`.
26
+
27
+ > **CRITICAL**: Do NOT begin bolt planning if any required artifact is missing. Surface the gap to the user and halt.
28
+
29
+ ---
30
+
31
+ ## Output (What This Stage Produces)
32
+
33
+ ```
34
+ aidlc-docs/{workflowId}/construction/{UNIT-NNN-slug}/bolts/
35
+ BOLT-001-{slug}/spec.md
36
+ BOLT-002-{slug}/spec.md
37
+ BOLT-003-{slug}/spec.md
38
+ ```
39
+
40
+ > **WARNING**: DO NOT CREATE:
41
+ > - `bolt-plan.md` (summary doc) -- the individual `spec.md` files ARE the plan
42
+ > - `README.md` files in bolt directories
43
+ > - Flat files like `BOLT-001.md` (must be in a directory as `spec.md`)
44
+ > - Flat `construction/bolts/` paths (bolts MUST be nested under their parent unit)
45
+
46
+ ---
47
+
48
+ ## Test Contract
49
+
50
+ ```yaml
51
+ input: Units with assigned stories from inception
52
+ output: Bolt spec.md files nested under construction/{unit}/bolts/{bolt}/
53
+ constraints:
54
+ max_per_unit: 8
55
+ max_total: 50
56
+ coverage_threshold: 95%
57
+ must_requirements: 100%
58
+ checkpoints: 0 (part of inception review gate)
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Bolt Naming Convention (MANDATORY)
64
+
65
+ Bolt IDs use **global sequential numbering across ALL units** -- numbering does NOT reset per unit.
66
+
67
+ Format: `BOLT-NNN-slug`
68
+
69
+ - `NNN` is zero-padded to three digits: `001`, `002`, `003`, ...
70
+ - `slug` is a short kebab-case description of the bolt's scope (lowercase, alphanumeric + hyphens only)
71
+ - Numbers are assigned in creation order across all units
72
+ - The regex pattern enforced by the TypeScript validator is: `^BOLT-\d{3}-[a-z0-9-]+$`
73
+
74
+ Examples:
75
+
76
+ ```
77
+ BOLT-001-data-model (Unit 1, bolt 1)
78
+ BOLT-002-repository-layer (Unit 1, bolt 2)
79
+ BOLT-003-api-endpoints (Unit 1, bolt 3)
80
+ BOLT-004-dashboard-ui (Unit 2, bolt 1 -- numbering continues globally)
81
+ ```
82
+
83
+ > **CRITICAL**: Never reset numbering per unit. Bolt 4 in unit 2 is `BOLT-004`, not `BOLT-001`.
84
+
85
+ ---
86
+
87
+ ## Directory Structure
88
+
89
+ Bolt specs are nested under their parent unit:
90
+
91
+ ```
92
+ aidlc-docs/{workflowId}/construction/{UNIT-NNN-slug}/bolts/
93
+ BOLT-001-{slug}/spec.md
94
+ BOLT-002-{slug}/spec.md
95
+ BOLT-003-{slug}/spec.md
96
+ ```
97
+
98
+ Full path examples:
99
+
100
+ ```
101
+ aidlc-docs/{workflowId}/construction/UNIT-001-foundation/bolts/BOLT-001-data-model/spec.md
102
+ aidlc-docs/{workflowId}/construction/UNIT-001-foundation/bolts/BOLT-002-repository-layer/spec.md
103
+ aidlc-docs/{workflowId}/construction/UNIT-002-frontend/bolts/BOLT-003-dashboard-ui/spec.md
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Process (Strict Sequential Steps)
109
+
110
+ ### Step 1: Load and Validate Inputs
111
+
112
+ For each unit defined in `inception/units/unit-of-work.md`:
113
+
114
+ 1. Read the unit definition (ID, title, success criteria and requirements, estimated effort)
115
+ 2. Read the unit brief at `inception/units/{unit-slug}/unit-brief.md`
116
+ 3. Read the assigned stories from `inception/units/unit-of-work-story-map.md`
117
+ 4. Resolve each story's full definition from `inception/units/{unit-slug}/stories/` (per-unit story files) or fall back to `inception/user-stories/stories.md`
118
+ 5. Resolve each story's requirement references from `inception/requirements/requirements.md`
119
+ 6. Confirm every story has an ID (`S-NNN`), a priority (`Must`, `Should`, `Could`), and at least one requirement reference (`FR-N`)
120
+
121
+ > **HARD BLOCK**: If any unit has zero assigned stories, halt and surface the issue. Every unit must have at least one story assigned.
122
+
123
+ ### Step 2: Assess Story Complexity (4-Factor Analysis)
124
+
125
+ For **each story** in every unit, assess complexity using all four factors:
126
+
127
+ | Factor | Question | Low (1) | Medium (2) | High (3) |
128
+ |--------|----------|---------|------------|----------|
129
+ | **Complexity** | How intricate is the logic? | CRUD, known patterns | Business rules, validation | Novel algorithms, state machines |
130
+ | **Uncertainty** | How clear are requirements? | Fully specified | Some ambiguity | Many unknowns |
131
+ | **Dependencies** | What external things needed? | Self-contained | Internal APIs/units | External systems, third-party |
132
+ | **Testing** | What validation needed? | Unit tests only | Integration tests | E2E + manual testing |
133
+
134
+ Record the 4-factor scores for each story. These scores drive grouping decisions in Step 3.
135
+
136
+ > **WARNING**: Any story with Uncertainty = High (3) MUST be flagged. Consider creating a **spike bolt** to reduce uncertainty before the implementation bolt.
137
+
138
+ ### Step 3: Group Stories into Bolts
139
+
140
+ For each unit, group its stories into cohesive bolts using these **explicit rules** (in priority order):
141
+
142
+ 1. **Cohesion**: Stories operating on the same domain entity or bounded context belong in the same bolt
143
+ 2. **Dependencies**: If Story A requires Story B's output, they go in the same bolt OR Story B's bolt must be sequenced before Story A's bolt
144
+ 3. **Balance**: Mix high-complexity and low-complexity stories within a bolt to avoid creating "monster bolts"
145
+ 4. **Limit**: Target 5-6 stories per bolt. Hard maximum is 8 stories per bolt (enforced by TypeScript validator: `MAX_BOLTS_PER_UNIT = 8` bolts per unit)
146
+ 5. **Risk**: Any story with Uncertainty = High (3) goes into a dedicated spike bolt that is sequenced FIRST
147
+
148
+ **Grouping by architectural layer** (typical ordering within a unit):
149
+
150
+ | Layer | Scope | Typical Bolt Slug |
151
+ |-------|-------|-------------------|
152
+ | Data models and schema migrations | Entity definitions, DB schema | `data-model` |
153
+ | Repository / data access layer | CRUD operations, queries | `repo-layer` |
154
+ | Business logic / service layer | Domain rules, validation | `service-layer` |
155
+ | API endpoints | Controllers, routes, DTOs | `api-endpoints` |
156
+ | UI components | Screens, forms, interactions | `ui-components` |
157
+ | Infrastructure | Auth, logging, config, middleware | `infrastructure` |
158
+
159
+ > **HARD CONSTRAINT**: Maximum **8 bolts per unit**, **50 bolts total** across all units. If a unit's scope exceeds 8 bolts, halt and flag it for re-scoping before proceeding.
160
+
161
+ ### Step 4: Assign Express Mode
162
+
163
+ For each bolt, determine whether express mode applies:
164
+
165
+ - `express_mode: true` if `depth_target <= 4` OR the parent workflow pathway is `bugfix`
166
+ - Express bolts skip the elaboration stage during construction and go directly to code generation
167
+ - All bolts within a given depth/pathway context receive the same express mode value
168
+
169
+ The express mode determination is handled programmatically by `isExpressBoltEligible()` in `express-bolt-factory.ts`.
170
+
171
+ ### Step 5: Analyze Dependencies (3-Level Analysis)
172
+
173
+ Dependency analysis operates at three distinct levels. All three MUST be performed.
174
+
175
+ #### 5a. Story Dependencies (within a bolt)
176
+
177
+ Within each bolt, identify ordering constraints between stories:
178
+
179
+ - If Story A's implementation depends on Story B's artifacts, Story B must appear first in the bolt's story list
180
+ - Document internal story ordering in the bolt's Scope section
181
+
182
+ #### 5b. Bolt Dependencies (within a unit)
183
+
184
+ For each unit, identify which bolts must complete before others can begin:
185
+
186
+ - Populate `requires_bolts`: array of bolt IDs this bolt depends on
187
+ - Populate `enables_bolts`: array of bolt IDs that depend on this bolt (reverse, informational)
188
+ - Typical ordering: data model -> repository -> service -> API -> UI
189
+
190
+ Output format for each bolt's dependency analysis:
191
+
192
+ ```markdown
193
+ #### Bolt Dependencies (within unit)
194
+ - **BOLT-001-data-model** (Required): Planned
195
+ - **BOLT-002-repo-layer** (Required): Planned
196
+ #### Enables (bolts waiting on this)
197
+ - BOLT-004-api-endpoints
198
+ ```
199
+
200
+ #### 5c. Unit Dependencies (cross-unit)
201
+
202
+ Identify whether any bolt requires work from a different unit:
203
+
204
+ - Populate `requires_units` with unit IDs (e.g., `["UNIT-001-foundation"]`)
205
+ - Cross-unit dependencies MUST be explicit and minimal -- prefer loose coupling
206
+ - Flag any unit that depends on 3 or more other units for mandatory review
207
+
208
+ Output format:
209
+
210
+ ```markdown
211
+ #### Unit Dependencies (cross-unit)
212
+ - **UNIT-001-foundation** (Required): Database schemas must exist
213
+ ```
214
+
215
+ #### Dependency Warnings
216
+
217
+ After completing all three levels, output a warnings section:
218
+
219
+ ```markdown
220
+ ### Dependency Warnings
221
+ - BOLT-003-api-endpoints depends on 3 bolts (high fan-in -- consider splitting)
222
+ - UNIT-002-frontend has cross-unit dependency on UNIT-001-foundation (verify interface contract exists)
223
+ - No circular dependencies detected
224
+ ```
225
+
226
+ #### Validate No Circular Dependencies
227
+
228
+ Before proceeding to spec creation:
229
+
230
+ - **Within a unit**: Ensure the `requires_bolts` graph is a DAG (no cycles). The TypeScript validator `BoltSpecValidator.validateNoCycles()` enforces this.
231
+ - **Across units**: Ensure no two units mutually depend on each other via `requires_units`
232
+ - If circular dependencies are found, **halt and re-scope bolts to break the cycle before continuing**
233
+
234
+ ### Step 6: Generate Bolt Sequence Visualization
235
+
236
+ Before creating specs, produce an ASCII dependency graph showing bolt execution order:
237
+
238
+ ```
239
+ [BOLT-001-data-model] --> [BOLT-002-repo-layer] --> [BOLT-003-service-layer]
240
+ |
241
+ v
242
+ [BOLT-004-api-endpoints] --> [BOLT-005-ui-components]
243
+ ```
244
+
245
+ For multi-unit workflows, show unit boundaries:
246
+
247
+ ```
248
+ UNIT-001-foundation:
249
+ [BOLT-001-data-model] --> [BOLT-002-repo-layer] --> [BOLT-003-api]
250
+
251
+ UNIT-002-frontend:
252
+ [BOLT-004-dashboard] --> [BOLT-005-settings]
253
+ |
254
+ +-- requires UNIT-001-foundation
255
+ ```
256
+
257
+ Present this visualization to the user before proceeding to spec file creation.
258
+
259
+ ### Step 7: Create Bolt Spec Files
260
+
261
+ For each bolt, create the directory and write the spec file:
262
+
263
+ ```
264
+ aidlc-docs/{workflowId}/construction/{parent_unit_id}/bolts/{bolt_id}/spec.md
265
+ ```
266
+
267
+ Populate ALL frontmatter fields and ALL required body sections. Do NOT leave template placeholders -- fill every field from the unit artifacts.
268
+
269
+ See the **Bolt Spec Format** section below for the complete template.
270
+
271
+ ### Step 8: Validate Frontmatter (Per-Bolt Checklist)
272
+
273
+ For EACH bolt spec created, verify the following checklist. Every item MUST pass:
274
+
275
+ - [ ] `id` -- present, matches `BOLT-NNN-slug` format (`^BOLT-\d{3}-[a-z0-9-]+$`)
276
+ - [ ] `title` -- present, non-empty string
277
+ - [ ] `parent_unit_id` -- present, matches an existing unit ID
278
+ - [ ] `sequence` -- positive integer (>= 1)
279
+ - [ ] `status` -- set to `planned`
280
+ - [ ] `created` -- ISO 8601 timestamp
281
+ - [ ] `intent` -- set to the workflow ID
282
+ - [ ] `depth_target` -- number on 1-11 scale
283
+ - [ ] `express_mode` -- boolean, correctly derived from depth_target/pathway
284
+ - [ ] `estimated_effort_hours` -- positive number
285
+ - [ ] `requirements` -- array with at least one FR-N ID
286
+ - [ ] `stories` -- array of story IDs (in both frontmatter AND body)
287
+ - [ ] `docs_impact` -- array of valid values (see Frontmatter Field Reference)
288
+ - [ ] `requires_bolts` -- array present (can be empty `[]`)
289
+ - [ ] `enables_bolts` -- array present (can be empty `[]`)
290
+ - [ ] `requires_units` -- array present (can be empty `[]`)
291
+ - [ ] `blocked` -- boolean, set to `false` on creation
292
+ - [ ] `complexity` -- block with all 4 fields (`avg_complexity`, `avg_uncertainty`, `max_dependencies`, `testing_scope`)
293
+
294
+ > **CRITICAL**: A bolt that fails ANY frontmatter check is invalid. Fix it before proceeding.
295
+
296
+ ### Step 9: Validate Coverage
297
+
298
+ After all bolts for each unit are written, validate story and requirement coverage:
299
+
300
+ #### Story Coverage
301
+
302
+ | Coverage | Result |
303
+ |----------|--------|
304
+ | >= 95% of unit stories assigned to bolts | **Pass** -- proceed |
305
+ | 80-94% covered | **Warning** -- user MUST explicitly acknowledge the gap before continuing |
306
+ | < 80% covered | **Hard block** -- revise bolt decomposition, do NOT continue |
307
+
308
+ Coverage formula: `(stories assigned to at least one bolt) / (total stories in unit) * 100`
309
+
310
+ #### Requirement Coverage
311
+
312
+ Every `Must`-priority requirement in `requirements.md` that is referenced by any story in the unit MUST be referenced by at least one bolt's `requirements` field. Any uncovered `Must` requirement is a **hard block** regardless of percentage score.
313
+
314
+ #### Content Validation Checklist
315
+
316
+ After coverage passes, verify these content-level constraints:
317
+
318
+ - [ ] All stories assigned to bolts (100% target, 95% minimum)
319
+ - [ ] All `Must`-priority requirements covered (100%, no exceptions)
320
+ - [ ] Dependencies respected (bolt-to-bolt AND unit-to-unit)
321
+ - [ ] Each bolt has clear Expected Outputs
322
+ - [ ] No bolt exceeds 8 stories (target 5-6)
323
+ - [ ] No circular dependencies (within-unit or cross-unit)
324
+ - [ ] Cross-unit dependencies are explicit and minimal
325
+ - [ ] Every bolt has at least one acceptance criterion
326
+ - [ ] Every bolt has at least one target file
327
+
328
+ ### Step 10: Validate Unit Independence
329
+
330
+ After all bolts for all units are planned, verify unit-level independence:
331
+
332
+ - **Single responsibility**: Each unit handles one bounded domain area
333
+ - **Clear interfaces**: Cross-unit interactions go through explicit interfaces (APIs, events, contracts)
334
+ - **No circular unit dependencies**: The `requires_units` graph across all bolts must be a DAG
335
+ - **Independent buildability**: Each unit can be developed and tested by a separate agent without requiring internal access to other units' implementation details
336
+ - **Minimal cross-unit deps**: Flag any unit that depends on 3 or more other units for mandatory review
337
+
338
+ If validation fails, surface the specific issue and require resolution before marking bolt-planning complete.
339
+
340
+ ### Step 11: Register Bolts in Checkpoint
341
+
342
+ After all validations pass, register bolts in the workflow checkpoint:
343
+
344
+ - Call `registerBoltsInCheckpoint(bolts, checkpoint)` for each unit's bolts
345
+ - This creates `ConstructionBoltProgress` entries with `status: 'planned'` and all four stage progress records initialized to `not_started`
346
+ - Update `inception_stages["bolt-planning"].status = "completed"`
347
+
348
+ ---
349
+
350
+ ## Bolt Spec Format
351
+
352
+ The canonical bolt spec template is defined at:
353
+
354
+ **Template file**: `resources/templates/construction/bolt-spec-template.md`
355
+
356
+ When creating bolt specs, agents MUST read this template file and follow its structure exactly. The template defines:
357
+
358
+ - All required frontmatter fields (including runtime state fields: `started`, `completed`, `current_stage`, `stages_completed`)
359
+ - All required body sections (Scope, Stories Included, Acceptance Criteria, Expected Outputs, Target Files, Stages, Dependencies, Success Criteria, Traceability)
360
+ - Status values and stage status symbols
361
+ - A concrete example of a bolt spec
362
+
363
+ > **CRITICAL**: Do NOT invent your own spec format. Read and follow the template.
364
+
365
+ ### Frontmatter Field Reference
366
+
367
+ | Field | Type | Required | Description |
368
+ |-------|------|----------|-------------|
369
+ | `id` | string | YES | Globally unique bolt ID. Must match `BOLT-NNN-slug` pattern. |
370
+ | `title` | string | YES | Short human-readable title. |
371
+ | `parent_unit_id` | string | YES | ID of the parent construction unit (e.g., `UNIT-001-foundation`). |
372
+ | `sequence` | integer | YES | Execution order within the unit (1-based, positive). |
373
+ | `status` | string | YES | Always `planned` on creation. Lifecycle: `planned` -> `in_progress` -> `built` -> `in_review` -> `done` or `failed`. |
374
+ | `created` | string | YES | ISO 8601 timestamp of spec creation. |
375
+ | `intent` | string | YES | Parent workflow ID (matches `{workflowId}`). |
376
+ | `depth_target` | number | YES | Reasoning depth (1-11 scale). Express mode threshold: <= 4. |
377
+ | `express_mode` | boolean | YES | `true` if eligible for express execution (skips elaboration). Derived from `depth_target <= 4 OR pathway == 'bugfix'`. |
378
+ | `estimated_effort_hours` | number | YES | Rough hours estimate for human review. |
379
+ | `requirements` | string[] | YES | Requirement IDs from `requirements.md` this bolt satisfies (e.g., `["FR-1", "FR-3"]`). **Minimum 1 required.** |
380
+ | `stories` | string[] | YES | Story IDs from `stories.md` this bolt addresses (e.g., `["S-001"]`). |
381
+ | `docs_impact` | string[] | YES | Documentation types this bolt impacts. Valid values: `none`, `readme`, `user-guide`, `config-reference`, `cli-reference`, `migration-guide`, `architecture`, `code-comments`. |
382
+ | `requires_bolts` | string[] | YES | Bolt IDs that must complete before this bolt begins (within-unit). Empty array `[]` if none. |
383
+ | `enables_bolts` | string[] | YES | Bolt IDs that depend on this bolt completing (reverse deps, informational). Empty array `[]` if none. |
384
+ | `requires_units` | string[] | YES | Unit IDs that must be fully built before this bolt begins (cross-unit). Empty array `[]` if none. |
385
+ | `blocked` | boolean | YES | Always `false` on creation. Set to `true` by executor when a dependency is incomplete. |
386
+ | `started` | string/null | YES | ISO 8601 timestamp when execution began. `null` on creation. |
387
+ | `completed` | string/null | YES | ISO 8601 timestamp when all stages finished. `null` on creation. |
388
+ | `current_stage` | string/null | YES | Currently executing stage. `null` on creation. |
389
+ | `stages_completed` | array | YES | Array of completed stage records. Empty `[]` on creation. |
390
+ | `complexity` | object | YES | 4-factor complexity assessment block (see below). |
391
+
392
+ #### Complexity Block Fields
393
+
394
+ | Field | Type | Range | Description |
395
+ |-------|------|-------|-------------|
396
+ | `avg_complexity` | number | 1-3 | Average complexity score across stories. 1=Low (CRUD), 2=Medium (business rules), 3=High (novel algorithms). |
397
+ | `avg_uncertainty` | number | 1-3 | Average uncertainty score. 1=Fully specified, 2=Some ambiguity, 3=Many unknowns. |
398
+ | `max_dependencies` | number | 1-3 | Highest dependency score among stories. 1=Self-contained, 2=Internal APIs, 3=External systems. |
399
+ | `testing_scope` | number | 1-3 | Required testing depth. 1=Unit tests, 2=Integration tests, 3=E2E + manual. |
400
+
401
+ ### Required Body Sections
402
+
403
+ Every bolt spec MUST contain ALL of the following sections. No section may be omitted.
404
+
405
+ ```markdown
406
+ # {Bolt Title}
407
+
408
+ ## Scope
409
+
410
+ {What this bolt implements. A focused description of the functionality delivered
411
+ by this bolt alone. Include internal story ordering if relevant.}
412
+
413
+ ## Stories Included
414
+
415
+ - [ ] **S-001**: User can register -- Priority: Must
416
+ - [ ] **S-002**: User can login -- Priority: Must
417
+
418
+ ## Acceptance Criteria
419
+
420
+ - [ ] {Measurable, verifiable criterion 1}
421
+ - [ ] {Measurable, verifiable criterion 2}
422
+
423
+ ## Expected Outputs
424
+
425
+ - User entity and migration
426
+ - Registration API endpoint
427
+ - Unit tests for registration flow
428
+
429
+ ## Target Files
430
+
431
+ - `src/models/user.ts` -- create: User entity definition
432
+ - `src/services/auth.ts` -- create: Authentication service
433
+ - `src/routes/auth.ts` -- create: Auth API routes
434
+
435
+ ## Dependencies
436
+
437
+ ### Bolt Dependencies (within unit)
438
+ - **BOLT-001-data-model** (Required): Planned
439
+
440
+ ### Unit Dependencies (cross-unit)
441
+ - None
442
+
443
+ ### Enables (bolts waiting on this)
444
+ - BOLT-003-api-endpoints
445
+
446
+ ## Stages
447
+
448
+ - [ ] **1. elaboration**: Pending
449
+ - [ ] **2. code_generation**: Pending
450
+ - [ ] **3. build_and_test**: Pending
451
+ - [ ] **4. review**: Pending
452
+
453
+ ## Success Criteria
454
+
455
+ - [ ] All stories implemented
456
+ - [ ] All acceptance criteria met
457
+ - [ ] Tests passing
458
+ - [ ] Code reviewed and approved
459
+
460
+ ## Traceability
461
+
462
+ - **Requirements**: FR-1, FR-2
463
+ - **Stories**: S-001, S-002
464
+ ```
465
+
466
+ > **CRITICAL**: The body must use checkbox syntax (`- [ ]`) for Stories Included, Acceptance Criteria, Stages, and Success Criteria. These checkboxes are tracked during construction execution.
467
+
468
+ ---
469
+
470
+ ## Critical Rules
471
+
472
+ > **WARNING**: Violation of any rule in this section produces an invalid bolt plan. The agent MUST NOT proceed past validation if any rule is broken.
473
+
474
+ ### Naming and Structure
475
+
476
+ - **GLOBAL BOLT NUMBERING**: `BOLT-NNN` numbers are assigned globally across all units. Never reset per unit.
477
+ - **NESTED PATHS ONLY**: Bolt specs always live at `construction/{unit-id}/bolts/{bolt-id}/spec.md`. No flat `construction/bolts/` paths.
478
+ - **NO BOLT-PLAN.MD**: Do not create a `bolt-plan.md` summary document. The individual `spec.md` files ARE the plan.
479
+ - **NO README FILES**: Do not create `README.md` in bolt directories.
480
+
481
+ ### Frontmatter Integrity
482
+
483
+ - **ALL FIELDS MANDATORY**: Every frontmatter field listed in the Field Reference must be present with a valid value. No template placeholders.
484
+ - **DEPENDENCY FIELDS ARE MANDATORY**: Every spec must include `requires_bolts`, `enables_bolts`, `requires_units`, and `blocked` in frontmatter -- even if the values are empty arrays and `false`.
485
+ - **REQUIREMENT REFERENCE IS MANDATORY**: Every bolt must reference at least one `FR-N` requirement ID. A bolt with an empty `requirements` array is invalid.
486
+ - **STATUS ALWAYS PLANNED**: On creation, `status` must be `planned`. Never set to `in_progress` or any other value during bolt planning.
487
+ - **COMPLEXITY BLOCK MANDATORY**: Every bolt must include the 4-field `complexity` block derived from Step 2 analysis.
488
+
489
+ ### Coverage and Completeness
490
+
491
+ - **95% STORY COVERAGE MINIMUM**: At least 95% of unit stories must be assigned to bolts. Below 80% is a hard block.
492
+ - **100% MUST-REQUIREMENT COVERAGE**: Every `Must`-priority requirement must appear in at least one bolt. No exceptions.
493
+ - **NO ORPHAN STORIES**: Every story in the unit should appear in exactly one bolt. Duplicate assignment across bolts is acceptable only when justified (shared infrastructure stories).
494
+
495
+ ### Dependency Safety
496
+
497
+ - **NO SELF-REFERENCES**: A bolt cannot list itself in `requires_bolts`.
498
+ - **NO PARENT UNIT REFERENCES**: A bolt cannot list its own parent unit in `requires_units`.
499
+ - **NO CIRCULAR DEPENDENCIES**: The dependency graph must be a DAG at both bolt and unit levels. Enforced by `BoltSpecValidator.validateNoCycles()`.
500
+ - **CROSS-UNIT MINIMIZATION**: Flag any unit with 3+ cross-unit dependencies for mandatory review.
501
+
502
+ ### Size Constraints
503
+
504
+ - **MAX 8 BOLTS PER UNIT**: Enforced by `BoltSpecValidator` (`MAX_BOLTS_PER_UNIT = 8`). Target 5-6.
505
+ - **MAX 50 BOLTS TOTAL**: Enforced by `BoltSpecValidator` (`MAX_BOLTS_TOTAL = 50`).
506
+ - **TARGET 5-6 STORIES PER BOLT**: Hard maximum 8 stories. If a bolt exceeds 6 stories, provide written justification.
507
+
508
+ ---
509
+
510
+ ## Agent Delegation Strategy
511
+
512
+ **MANDATORY**: Delegate bolt spec file generation to `olympian`. Do NOT generate multi-bolt, multi-unit spec files directly from the orchestrator.
513
+
514
+ **Execution mode**: Foreground sequential -- one coherent bolt planning pass per workflow.
515
+
516
+ **Delegation scope**:
517
+
518
+ | Steps | Owner | Rationale |
519
+ |-------|-------|-----------|
520
+ | 1-3 (Load inputs, assess complexity, decompose into bolts) | **Orchestrator** | Requires reading multiple artifacts and making decomposition decisions |
521
+ | 4-7 (Express mode, dependency analysis, visualization, spec creation) | **Delegated to `olympian`** | Writes spec.md files to disk, performs dependency analysis |
522
+ | 8-11 (Frontmatter validation, coverage, unit independence, checkpoint) | **Orchestrator** | Final validation gates and checkpoint registration |
523
+
524
+ **After agent completes**: The orchestrator validates coverage and unit independence (Steps 8-11), then presents the completion summary and approval gate.
525
+
526
+ **Optional quality gate -- `momus` review**: When multiple units exist (3+) or cross-unit dependencies are present, invoke `momus` to critically evaluate the bolt decomposition before presenting to the user.
527
+
528
+ ---
529
+
530
+ ## Completion Summary Format
531
+
532
+ After all validation passes, present the following summary to the user:
533
+
534
+ ```markdown
535
+ ## Bolt Plan Complete: {unit-name}
536
+
537
+ ### Bolts Created
538
+ - [ ] **BOLT-001-data-model** (express: false): S-001, S-002
539
+ - [ ] **BOLT-002-repo-layer** (express: false): S-003, S-004
540
+
541
+ ### Dependency Graph
542
+ BOLT-001-data-model --> BOLT-002-repo-layer --> BOLT-003-api
543
+
544
+ ### Directories Created
545
+ `construction/UNIT-001-foundation/bolts/BOLT-001-data-model/spec.md`
546
+ `construction/UNIT-001-foundation/bolts/BOLT-002-repo-layer/spec.md`
547
+
548
+ ### Coverage
549
+ - Stories covered: 6/6 (100%)
550
+ - Requirements covered: FR-1, FR-2, FR-3 (3/3)
551
+ - Must-requirements covered: 3/3 (100%)
552
+
553
+ ### Complexity Summary
554
+ - Average complexity across all bolts: 2.1
555
+ - Highest uncertainty bolt: BOLT-003-api (avg_uncertainty: 2)
556
+ - Spike bolts: 0
557
+
558
+ ### Total
559
+ - {n} bolts created
560
+ - {n} stories covered
561
+ - {n} cross-unit dependencies
562
+ - {n} express bolts
563
+ ```
564
+
565
+ ---
566
+
567
+ ## Completion Criteria
568
+
569
+ ALL of the following must be true before bolt planning is marked complete:
570
+
571
+ - [ ] All bolt specs created at `construction/{UNIT-NNN-slug}/bolts/{BOLT-NNN-slug}/spec.md`
572
+ - [ ] No `bolt-plan.md` summary document created (specs ARE the plan)
573
+ - [ ] All required body sections present in every spec (Scope, Stories Included, Acceptance Criteria, Expected Outputs, Target Files, Stages, Dependencies, Success Criteria, Traceability)
574
+ - [ ] All frontmatter fields populated with valid values (no template placeholders)
575
+ - [ ] Frontmatter validation checklist (Step 8) passes for every bolt
576
+ - [ ] `status: planned` set on every bolt
577
+ - [ ] `created` timestamp set on every bolt
578
+ - [ ] `intent` set to workflow ID on every bolt
579
+ - [ ] `complexity` block with all 4 fields present on every bolt
580
+ - [ ] All `requires_bolts`, `enables_bolts`, `requires_units`, and `blocked` fields set
581
+ - [ ] Story coverage >= 95% for all units (or gap explicitly acknowledged for 80-94%)
582
+ - [ ] All `Must`-priority requirements referenced by at least one bolt (100%, no exceptions)
583
+ - [ ] No circular dependencies within or across units
584
+ - [ ] Unit independence validated
585
+ - [ ] Bolts registered in checkpoint via `registerBoltsInCheckpoint()`
586
+ - [ ] `inception_stages["bolt-planning"].status` set to `"completed"`
587
+ - [ ] Completion summary presented to user
588
+ - [ ] User has approved the bolt plan before proceeding to construction