qfai 1.3.18 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/assets/init/.qfai/README.md +45 -49
  2. package/assets/init/.qfai/assistant/skills/qfai-atdd/SKILL.md +2 -2
  3. package/assets/init/.qfai/assistant/skills/qfai-implement/SKILL.md +2 -2
  4. package/assets/init/.qfai/assistant/skills/qfai-prototyping/SKILL.md +2 -2
  5. package/assets/init/.qfai/assistant/skills/qfai-sdd-planning/SKILL.md +40 -29
  6. package/assets/init/.qfai/assistant/skills/qfai-sdd-planning/templates/spec-pack/17_Plan.md +58 -0
  7. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/SKILL.md +71 -39
  8. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/01_Spec.md +28 -0
  9. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/02_Objective.md +23 -0
  10. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/03_Initiative.md +26 -0
  11. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/04_Capability.md +16 -0
  12. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/05_Business-flow.feature +11 -0
  13. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/06_User-stories.md +17 -0
  14. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/07_Acceptance-criteria.md +17 -0
  15. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/08_Business-rules.md +17 -0
  16. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/09_Examples.feature +21 -0
  17. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/10_Test-cases.md +17 -0
  18. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/11_Contracts.md +19 -0
  19. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/12_Glossary.md +17 -0
  20. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/13_Constraints.md +19 -0
  21. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/14_Decisions.md +15 -0
  22. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/15_Open-questions.md +19 -0
  23. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/16_Traceability-ledger.md +18 -0
  24. package/assets/init/.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/18_delta.md +35 -0
  25. package/assets/init/.qfai/assistant/skills/qfai-tdd-green/SKILL.md +2 -2
  26. package/assets/init/.qfai/assistant/skills/qfai-tdd-red/SKILL.md +2 -2
  27. package/assets/init/.qfai/assistant/skills/qfai-tdd-refactor/SKILL.md +2 -2
  28. package/assets/init/.qfai/assistant/skills/qfai-unit-test/SKILL.md +2 -2
  29. package/assets/init/.qfai/contracts/README.md +4 -3
  30. package/assets/init/.qfai/contracts/api/api-0001-sample.yaml +26 -0
  31. package/assets/init/.qfai/contracts/db/db-0001-sample.sql +13 -0
  32. package/assets/init/.qfai/contracts/ui/ui-0001-sample.yaml +15 -0
  33. package/assets/init/.qfai/discussions/README.md +5 -5
  34. package/assets/init/.qfai/require/README.md +3 -2
  35. package/assets/init/.qfai/specs/README.md +93 -379
  36. package/assets/init/.qfai/specs/spec-0001/01_Spec.md +24 -0
  37. package/assets/init/.qfai/specs/spec-0001/02_Objective.md +18 -0
  38. package/assets/init/.qfai/specs/spec-0001/03_Initiative.md +26 -0
  39. package/assets/init/.qfai/specs/spec-0001/04_Capability.md +13 -0
  40. package/assets/init/.qfai/specs/spec-0001/05_Business-flow.feature +12 -0
  41. package/assets/init/.qfai/specs/spec-0001/06_User-stories.md +8 -0
  42. package/assets/init/.qfai/specs/spec-0001/07_Acceptance-criteria.md +9 -0
  43. package/assets/init/.qfai/specs/spec-0001/08_Business-rules.md +9 -0
  44. package/assets/init/.qfai/specs/spec-0001/09_Examples.feature +20 -0
  45. package/assets/init/.qfai/specs/spec-0001/10_Test-cases.md +9 -0
  46. package/assets/init/.qfai/specs/spec-0001/11_Contracts.md +7 -0
  47. package/assets/init/.qfai/specs/spec-0001/12_Glossary.md +6 -0
  48. package/assets/init/.qfai/specs/spec-0001/13_Constraints.md +9 -0
  49. package/assets/init/.qfai/specs/spec-0001/14_Decisions.md +7 -0
  50. package/assets/init/.qfai/specs/spec-0001/15_Open-questions.md +13 -0
  51. package/assets/init/.qfai/specs/spec-0001/16_Traceability-ledger.md +7 -0
  52. package/assets/init/.qfai/specs/spec-0001/17_Plan.md +49 -0
  53. package/assets/init/.qfai/specs/spec-0001/18_delta.md +34 -0
  54. package/assets/init/.qfai/specs/spec-0001/case-catalogue.md +23 -0
  55. package/assets/init/.qfai/specs/spec-0001/delta.md +76 -0
  56. package/assets/init/.qfai/specs/spec-0001/plan.md +171 -0
  57. package/assets/init/.qfai/specs/spec-0001/scenario.feature +22 -0
  58. package/assets/init/.qfai/specs/spec-0001/spec.md +69 -0
  59. package/assets/init/.qfai/specs/spec-0001/traceability-matrix.md +28 -0
  60. package/assets/init/.qfai/templates/spec/implementation-brief.md +4 -1
  61. package/assets/init/root/features/spec-0001.feature +20 -0
  62. package/dist/cli/index.cjs +189 -56
  63. package/dist/cli/index.cjs.map +1 -1
  64. package/dist/cli/index.mjs +185 -52
  65. package/dist/cli/index.mjs.map +1 -1
  66. package/dist/index.cjs +183 -50
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.mjs +183 -50
  69. package/dist/index.mjs.map +1 -1
  70. package/package.json +1 -1
@@ -2,13 +2,13 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
- `.qfai/` is the **single workspace** for QFAI artifacts so that requirements, contracts, spec packs, and automation stay aligned and traceable.
5
+ `.qfai/` is the single workspace for QFAI artifacts so requirements, contracts, spec packs, and automation stay aligned.
6
6
 
7
- This folder is generated by `qfai init`. It is designed to be:
7
+ This folder is generated by `qfai init` and designed to be:
8
8
 
9
- - **predictable** (stable file layout),
10
- - **reviewable** (human-readable Markdown/YAML/SQL),
11
- - **machine-checkable** (validators enforce minimal structural rules).
9
+ - predictable (stable layout),
10
+ - reviewable (human-readable Markdown/YAML/SQL),
11
+ - machine-checkable (validators enforce minimal structural rules).
12
12
 
13
13
  ## Recommended QFAI sequence (project)
14
14
 
@@ -24,10 +24,7 @@ flowchart TD
24
24
  H --> I[/qfai-tdd-refactor/]
25
25
  ```
26
26
 
27
- > Formatting MUST follow the templates in each directory README.
28
- > Do not invent per-file formats.
29
- > Requirements decomposition starts from **Actors** and **Business Flows** in `require/`.
30
- > Keep `business-flows.md` as the top-level narrative backbone; derive REQ/SPEC/SCENARIO from BF steps.
27
+ > Formatting must follow the templates and checklists documented in each directory README.
31
28
 
32
29
  ## Directory map
33
30
 
@@ -36,25 +33,31 @@ flowchart TD
36
33
  ├── README.md
37
34
  ├── discussions/
38
35
  │ ├── README.md
39
- │ └── discuss-0001-<topic>.md # discussion log (decision/evidence)
36
+ │ └── discuss-0001-<topic>.md
40
37
  ├── assistant/
41
- │ ├── skills/ # canonical skills (SSOT)
42
- │ ├── skills.local/ # project-specific skill overrides
43
- │ ├── agents/ # sub-agent missions / guardrails
44
- │ ├── steering/ # project steering (inputs for skills, includes test-layers.md)
45
- │ └── instructions/ # tool/integration instructions (includes drift-protocol.md)
38
+ │ ├── skills/ # canonical skills (SSOT)
39
+ │ ├── skills.local/ # project-specific overrides
40
+ │ ├── agents/ # sub-agent missions
41
+ │ ├── steering/ # project steering inputs
42
+ │ └── instructions/ # workflow and guardrail docs
46
43
  ├── require/
47
44
  │ ├── README.md
48
- │ ├── glossary.md # terms (SSOT)
49
- │ ├── actors.md # actor catalog (SSOT)
50
- │ ├── business-flows.md # business flow catalog (SSOT)
51
- │ ├── require.md # requirements (REQ-*) + BF coverage map
45
+ │ ├── glossary.md
46
+ │ ├── actors.md
47
+ │ ├── business-flows.md
48
+ │ ├── require.md
52
49
  │ └── open-questions.md
53
50
  ├── contracts/
54
51
  │ ├── README.md
55
- │ ├── api/README.md # OpenAPI YAML style guide
56
- │ ├── db/README.md # SQL contracts style guide
57
- │ └── ui/README.md # UI contract YAML style guide
52
+ │ ├── api/
53
+ ├── README.md
54
+ └── api-0001-sample.yaml
55
+ │ ├── db/
56
+ │ │ ├── README.md
57
+ │ │ └── db-0001-sample.sql
58
+ │ └── ui/
59
+ │ ├── README.md
60
+ │ └── ui-0001-sample.yaml
58
61
  ├── specs/
59
62
  │ ├── README.md
60
63
  │ └── spec-0001/
@@ -63,15 +66,16 @@ flowchart TD
63
66
  │ ├── scenario.feature
64
67
  │ ├── case-catalogue.md
65
68
  │ ├── traceability-matrix.md
66
- │ └── plan.md
67
- ├── templates/
68
- │ └── spec/
69
- │ ├── delta.md
70
69
  │ ├── plan.md
71
- └── implementation-brief.md # deprecated alias template
70
+ ├── 01_Spec.md
71
+ │ ├── ...
72
+ │ ├── 17_Plan.md
73
+ │ └── 18_delta.md
74
+ ├── templates/
75
+ │ └── spec/ # compatibility templates (runtime SSOT files)
72
76
  └── evidence/
73
77
  ├── README.md
74
- └── <skill>-<run>.md # completion evidence (gitignored by default)
78
+ └── <skill>-<run>.md
75
79
  ```
76
80
 
77
81
  ## Rules (global)
@@ -81,44 +85,36 @@ flowchart TD
81
85
  Each directory `README.md` defines:
82
86
 
83
87
  - required files,
84
- - canonical **template**,
85
- - realistic **sample**,
88
+ - template expectations,
86
89
  - quality checklist,
87
90
  - anti-patterns.
88
91
 
89
- All custom skills must:
90
-
91
- 1. read the relevant directory README(s),
92
- 2. generate artifacts matching their templates,
93
- 3. run a self-check before declaring completion.
92
+ Custom skills should read relevant README files before writing artifacts.
94
93
 
95
94
  ### R2. Evidence is not versioned by default
96
95
 
97
- Evidence under `.qfai/evidence/` is **gitignored by default** (see repository `.gitignore` and/or project `.git/info/exclude`).
98
-
99
- - Evidence is still useful locally and in PR review (attach or paste snippets), but it should not pollute version control.
96
+ Evidence under `.qfai/evidence/` is gitignored by default.
97
+ It is useful for local review but should not pollute version control.
100
98
 
101
99
  ### R3. Keep artifacts atomic
102
100
 
103
- - Prefer many small, stable identifiers (REQ/BR/AC/CASE/SC) over long paragraphs that hide multiple rules.
104
- - If a statement contains multiple independent “must” clauses, split it.
101
+ - Prefer small stable identifiers (REQ/BR/AC/TC/EX/etc.) over long mixed paragraphs.
102
+ - If one line contains multiple independent constraints, split it.
105
103
 
106
- ### R4. Do not put templates in skills
104
+ ### R4. Runtime compatibility first, layered overlay second
107
105
 
108
- Templates/samples MUST live only in `.qfai/**/README.md`.
109
- Skills only **reference** them to avoid double maintenance.
106
+ - Runtime validators and downstream skills consume `spec.md`, `delta.md`, `scenario.feature`, `case-catalogue.md`, `traceability-matrix.md`, and `plan.md`.
107
+ - Layered files (`01_*` to `18_*`) are optional overlays and must stay synchronized when present.
110
108
 
111
109
  ## Skills (SSOT)
112
110
 
113
- QFAI also ships an **assistant skills** tree at `assistant/skills/`.
114
-
115
- `assistant/skills/**` is the canonical source of truth.
116
- Tool-specific wrappers (`.claude/skills`, `.github/skills`, `.codex/skills`) must point to this tree.
111
+ `assistant/skills/**` is the canonical source.
112
+ Tool-specific wrappers (`.claude/skills`, `.github/skills`, `.codex/skills`) should point to this tree.
117
113
 
118
114
  ## Where to look next
119
115
 
120
116
  - Requirements format: `require/README.md`
121
- - Contracts format: `contracts/README.md` and sub-READMEs
117
+ - Contracts format: `contracts/README.md` and child READMEs
122
118
  - Spec pack format: `specs/README.md`
123
- - Change classification (Primary/Tags): `assistant/instructions/change-classification.md`
119
+ - Change classification: `assistant/instructions/change-classification.md`
124
120
  - Evidence rules: `evidence/README.md`
@@ -152,8 +152,8 @@ Rules:
152
152
 
153
153
  - Do NOT declare completion based on unit/component tests.
154
154
  - `plan.md` is the primary How SSOT for execution phases.
155
- - If only legacy `implementation-brief.md` exists, continue with warning and create a migration task to `plan.md`.
156
- - If both `plan.md` and legacy `implementation-brief.md` are missing, STOP and run `/qfai-sdd-planning`.
155
+ - `implementation-brief.md` is deprecated and must not be used as How SSOT.
156
+ - If `plan.md` is missing, STOP and run `/qfai-sdd-planning` before proceeding.
157
157
  - Acceptance tests must be runnable and Coverage Ledger must be 100% implemented (blocked/skipped require DR + approval).
158
158
  - You MUST evaluate layer floors as volume signals (E2E=SC count, API=endpoints, Integration=max(endpoints×K, ΣCASE)).
159
159
  - E2E=0 or Integration=0 is forbidden unless a DR + user approval + reviewer PASS explicitly allows it.
@@ -157,8 +157,8 @@ Rules:
157
157
 
158
158
  - This is a legacy entrypoint. You MUST follow `.qfai/assistant/skills/qfai-tdd-green/SKILL.md`.
159
159
  - `plan.md` is the primary How SSOT for execution phases.
160
- - If only legacy `implementation-brief.md` exists, continue with warning and create a migration task to `plan.md`.
161
- - If both `plan.md` and legacy `implementation-brief.md` are missing, STOP and run `/qfai-sdd-planning`.
160
+ - `implementation-brief.md` is deprecated and must not be used as How SSOT.
161
+ - If `plan.md` is missing, STOP and run `/qfai-sdd-planning` before proceeding.
162
162
  - Do NOT write new tests here (use `/qfai-tdd-red` or `/qfai-unit-test`, and `/qfai-atdd` when needed).
163
163
  - You MUST produce the required evidence file: `.qfai/evidence/tdd-green-<spec-id>.md`.
164
164
  - If refactoring is required, run `/qfai-tdd-refactor` and record `.qfai/evidence/tdd-refactor-<spec-id>.md`.
@@ -159,8 +159,8 @@ Rules:
159
159
 
160
160
  - Do NOT implement acceptance tests or unit tests (that is `/qfai-atdd` and TDD phases).
161
161
  - If `plan.md` exists, you MUST follow it as implementation constraints.
162
- - If only legacy `implementation-brief.md` exists, continue with warning and create a migration task to `plan.md`.
163
- - If both `plan.md` and legacy `implementation-brief.md` are missing, exploratory prototyping is allowed, but you MUST run `/qfai-sdd-planning` before downstream execution phases.
162
+ - `implementation-brief.md` is deprecated and must not be used as How SSOT.
163
+ - If `plan.md` is missing, STOP and run `/qfai-sdd-planning` before proceeding.
164
164
  - You MUST produce the required evidence file: `.qfai/evidence/prototyping-<spec-id>.md`.
165
165
  - `.qfai/evidence/` is intentionally NOT tracked by Git (it ships with a local `.gitignore`).
166
166
  - Do NOT commit evidence files; summarize key outcomes in the PR description instead.
@@ -8,7 +8,7 @@ QFAI Skill Body (SSOT)
8
8
 
9
9
  name: qfai-sdd-planning
10
10
  title: QFAI SDD Planning (How SSOT)
11
- description: "Create plan.md and lock implementation constraints for downstream execution phases."
11
+ description: "Create plan.md and lock implementation constraints for downstream execution phases (optionally mirror to 17_Plan.md)."
12
12
  argument-hint: "<spec-id-or-name> [--auto]"
13
13
  allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
14
  roles: [Planner, Architect, QAEngineer, CodeReviewer]
@@ -35,7 +35,7 @@ When unsure, read inputs in this order:
35
35
  - P1: `.qfai/assistant/instructions/*`
36
36
  - P2: `.qfai/assistant/steering/*`
37
37
  - P3: `.qfai/specs/<spec-id>/delta.md`
38
- - P4: `.qfai/specs/<spec-id>/spec.md`, `scenario.feature`, contracts
38
+ - P4: `.qfai/specs/<spec-id>/spec.md`, `scenario.feature`, `01_Spec.md`, `06_User-stories.md`, `09_Examples.feature`, `16_Traceability-ledger.md`, contracts
39
39
 
40
40
  ## Sub-agent Delegation (MANDATORY)
41
41
 
@@ -142,15 +142,25 @@ Rules:
142
142
 
143
143
  ## Delta Rejected Guard (Mandatory)
144
144
 
145
- - Do NOT reintroduce options marked as rejected in delta.md.
145
+ - Do NOT reintroduce options marked as rejected in `delta.md`.
146
146
  - If planning must revisit a rejected option, add a `[RE-OPEN]` decision record with explicit approval evidence.
147
147
 
148
+ ## Workflow Convention (Mandatory)
149
+
150
+ - Planning owns `plan.md` as runtime How SSOT; `17_Plan.md` is an optional layered mirror.
151
+ - Finalize plan details after at least one user-story slice is grounded in refinement outputs.
152
+ - Keep planning aligned with lower-to-upper reference direction and `@layer-*` policy from `steering/test-layers.md`.
153
+
148
154
  ## CRITICAL CONSTRAINTS (Read First)
149
155
 
150
156
  - This phase MUST create or update:
151
157
  - `.qfai/specs/spec-XXXX/plan.md`
152
158
  - The plan is the How SSOT and must be concise, explicit, and implementation-binding.
153
- - Required headings must exist in fixed order:
159
+ - Use the runtime template as primary:
160
+ - `.qfai/templates/spec/plan.md`
161
+ - If layered mode is enabled, keep this optional mirror synchronized:
162
+ - `.qfai/specs/spec-XXXX/17_Plan.md`
163
+ - Required `plan.md` headings must exist in fixed order:
154
164
  1. `Metadata`
155
165
  2. `Context & Scope`
156
166
  3. `Goals / Non-goals`
@@ -160,11 +170,9 @@ Rules:
160
170
  7. `Risks & Mitigations`
161
171
  8. `Open Questions / Blockers`
162
172
  9. `Done Checklist`
163
- - `Open Questions / Blockers` should finish with blockers resolved by default.
164
- - Planning decisions should be appended to delta as `DR-HOW-*` entries when strategy changes.
165
- - You MUST run full validation:
166
- - `qfai validate --fail-on error`
167
- - CI validation must remain default/full. Do NOT switch CI gates to `--phase refinement`.
173
+ - `Open Questions / Blockers` should end with no unresolved blockers by default.
174
+ - Planning decisions should be appended to `delta.md` when strategy changes.
175
+ - Run full validation after planning updates.
168
176
  - Completion must be approved by a reviewer who did not author the plan.
169
177
 
170
178
  ## Completion Contract (Shared)
@@ -172,49 +180,51 @@ Rules:
172
180
  Before declaring completion, you MUST:
173
181
 
174
182
  - OQ / undefined resolution: remove ambiguity from implementation decisions.
175
- - Deliverable completeness: verify required headings and concrete constraints.
183
+ - Deliverable completeness: verify required sections and concrete constraints.
176
184
  - OQ / placeholder scan: remove unresolved placeholders (`TBD`, `TODO`, `???`, etc.) unless explicitly deferred.
177
- - Smoke check (if applicable): run the smallest command to prove artifacts are valid.
185
+ - Run checks proving `plan.md` is actionable and references grounded slices.
178
186
 
179
187
  ## Goal
180
188
 
181
- Transform refined SDD artifacts into a constrained implementation plan that downstream skills must follow.
189
+ Transform refined artifacts into a constrained `plan.md` that downstream execution phases must follow.
182
190
 
183
191
  ## Non-goals
184
192
 
185
- - Writing production code or tests.
186
- - Expanding into a full design document beyond required constraints.
193
+ - Writing production code or runnable tests.
194
+ - Re-authoring refinement-owned files unless an approved change request requires it.
187
195
 
188
196
  ## Mandatory Outputs
189
197
 
190
- - `.qfai/specs/spec-XXXX/plan.md`
198
+ - `.qfai/specs/spec-XXXX/plan.md` (required)
199
+ - `.qfai/specs/spec-XXXX/17_Plan.md` (optional layered mirror; keep in sync with `plan.md`)
191
200
  - Updated `.qfai/specs/spec-XXXX/delta.md` when planning decisions changed
201
+ - Updated `.qfai/specs/spec-XXXX/18_delta.md` when layered mirror is used
192
202
  - Evidence file: `.qfai/evidence/sdd-planning-<spec-id>.md`
193
203
 
194
204
  ## Plan Template (Minimum)
195
205
 
196
- - Use `.qfai/templates/spec/plan.md` as the single source of truth.
206
+ - Use `.qfai/templates/spec/plan.md` as the runtime source of truth.
207
+ - If layered mode is used, keep `.qfai/assistant/skills/qfai-sdd-planning/templates/spec-pack/17_Plan.md` synchronized as a mirror.
197
208
  - Do not duplicate the template content in this workflow file.
198
209
 
199
210
  ## Change Control During Execution
200
211
 
201
212
  If execution discovers a conflicting implementation path:
202
213
 
203
- 1. STOP implementation.
204
- 2. Create a Change Request with at least 3 options + recommendation.
214
+ 1. STOP execution planning.
215
+ 2. Create a Change Request with at least 3 options plus recommendation.
205
216
  3. Wait for explicit user approval.
206
217
  4. Re-run the owner skill to update upstream artifacts (do not patch upstream directly from downstream).
207
- 5. Re-run full validation after approved updates.
218
+ 5. Re-run full validation and reviewer gate after approved updates.
208
219
 
209
220
  ## Quality Gate
210
221
 
211
- Run:
212
-
213
- ```bash
214
- qfai validate --fail-on error
215
- ```
222
+ Run checks:
216
223
 
217
- This phase must pass default/full validation.
224
+ - Confirm `plan.md` exists and required sections are present in order.
225
+ - Confirm plan references at least one grounded user-story slice from refinement outputs.
226
+ - Confirm verification strategy aligns with `steering/test-layers.md`.
227
+ - Confirm strategy changes are reflected in `delta.md` (and `18_delta.md` if mirror is used).
218
228
 
219
229
  ## Evidence (MANDATORY)
220
230
 
@@ -235,16 +245,17 @@ Required sections:
235
245
  When declaring DONE, include:
236
246
 
237
247
  - Referenced inputs and spec-id
238
- - `DR-HOW-*` IDs added or updated
239
- - Full validation result
248
+ - `DELTA-*` IDs added or updated in `delta.md` (and `18_delta.md` when mirrored)
249
+ - Static planning gate result
240
250
  - Confirmation that downstream phases must follow the plan
241
251
 
242
252
  ## FINAL CHECKLIST (Check Last)
243
253
 
244
254
  - [ ] CRITICAL CONSTRAINTS were followed.
245
255
  - [ ] `plan.md` exists and matches required heading order.
246
- - [ ] Any planning strategy change is recorded in delta decisions.
256
+ - [ ] Any planning strategy change is recorded in `delta.md`.
257
+ - [ ] If `17_Plan.md` exists, it is synchronized with `plan.md`.
247
258
  - [ ] Blockers are resolved, or approved exceptions are recorded.
248
- - [ ] Full validation passed (`qfai validate --fail-on error`).
259
+ - [ ] Planning static gate checks are recorded in evidence.
249
260
  - [ ] Evidence file exists and is complete.
250
261
  - [ ] Reviewer approval is recorded.
@@ -0,0 +1,58 @@
1
+ # 17 Plan
2
+
3
+ ## Metadata
4
+
5
+ | Key | Value |
6
+ | ---------- | ------------- |
7
+ | Spec ID | SPEC-XXXX |
8
+ | Plan owner | <role/person> |
9
+ | Created | YYYY-MM-DD |
10
+ | Updated | YYYY-MM-DD |
11
+
12
+ ## Context and Scope
13
+
14
+ - Related objective:
15
+ - Related initiative:
16
+ - In scope for execution:
17
+ - Out of scope for execution:
18
+
19
+ ## Execution Strategy
20
+
21
+ - Reference completed user-story slices from `06` to `16`:
22
+ - Slice:
23
+ - Why this order:
24
+ - Drift Protocol checkpoints:
25
+ - Change request policy:
26
+
27
+ ## Milestones
28
+
29
+ | Milestone | Output | Exit criteria |
30
+ | --------- | -------- | ------------- |
31
+ | M1 | <output> | <criteria> |
32
+
33
+ ## Verification and Gates
34
+
35
+ - Layer policy source: `.qfai/assistant/steering/test-layers.md`
36
+ - Required checks:
37
+ - AC coverage by EX and TC
38
+ - ledger trace to objective intent
39
+ - critical risks covered by tests
40
+ - Gate record location: `.qfai/evidence/sdd-planning-<spec-id>.md`
41
+
42
+ ## Risks and Mitigations
43
+
44
+ | Risk | Impact | Mitigation | Owner |
45
+ | ------ | -------- | ------------ | ------- |
46
+ | <risk> | <impact> | <mitigation> | <owner> |
47
+
48
+ ## Open Questions
49
+
50
+ - [OQ-SPEC-0001-0001] <question>
51
+
52
+ ## Done Checklist
53
+
54
+ - [ ] Required sections are filled
55
+ - [ ] At least one grounded user-story slice is referenced
56
+ - [ ] Verification and gate conditions are explicit
57
+ - [ ] Major strategy decisions are reflected in `delta.md` (and `18_delta.md` when layered mirror is used)
58
+ - [ ] Reviewer approval is recorded
@@ -36,7 +36,7 @@ When unsure, read inputs in this order:
36
36
 
37
37
  - P1: `.qfai/assistant/instructions/*`
38
38
  - P2: `.qfai/assistant/steering/*`
39
- - P3: `.qfai/specs/<spec-id>/delta.md` (if present)
39
+ - P3: `.qfai/specs/<spec-id>/delta.md` (if present, runtime SSOT)
40
40
  - P4: other artifacts (require/specs/contracts/evidence)
41
41
 
42
42
  ## Sub-agent Delegation (MANDATORY)
@@ -144,23 +144,40 @@ Rules:
144
144
 
145
145
  ## Delta Rejected Guard (Mandatory)
146
146
 
147
- - Do NOT reintroduce options marked as rejected in delta.md.
147
+ - Do NOT reintroduce options marked as rejected in `delta.md`.
148
148
  - If a rejected option must be reconsidered, add a `[RE-OPEN]` decision record with explicit approval evidence.
149
149
 
150
+ ## Workflow Convention (Mandatory)
151
+
152
+ Apply this flow only while authoring spec packs:
153
+
154
+ - **Layer-first** for upper layers: `02_Objective.md`, `03_Initiative.md`, `04_Capability.md`, `05_Business-flow.feature`.
155
+ - **Slice-first** for lower layers: `06_User-stories.md` -> `07_Acceptance-criteria.md` -> `08_Business-rules.md` -> `09_Examples.feature` -> `10_Test-cases.md` -> `16_Traceability-ledger.md` (matching rows).
156
+ - `plan.md` is owned by planning and must be finalized after at least one user-story slice is grounded.
157
+
158
+ US slice completion gate:
159
+
160
+ - For each AC, examples count is at least one and test cases count is at least one.
161
+ - Ledger rows can be traced back to objective intent.
162
+ - `@layer-*` tags in examples align with `steering/test-layers.md`.
163
+
150
164
  ## CRITICAL CONSTRAINTS (Read First)
151
165
 
152
166
  - This phase defines Why/What/Examples/Rules. It MUST NOT lock implementation details.
153
167
  - `plan.md` MUST NOT be created in this phase.
154
- - `case-catalogue.md` MUST use category-based Markdown tables (not bullet lists).
155
- - `case-catalogue.md` rows MUST keep all legacy information (no-loss), including a dedicated `Case title` column.
168
+ - Use only skill-local templates:
169
+ - `.qfai/assistant/skills/qfai-sdd-refinement/templates/spec-pack/`
170
+ - Scenario specification in `09_Examples.feature` is strict:
171
+ - exactly one `Feature:`
172
+ - one or more tagged `Scenario:`
173
+ - each scenario includes `@EX-XXXX @AC-XXXX @layer-*`
174
+ - Respect reference direction rules from `.qfai/specs/README.md`:
175
+ - upper-to-lower references are forbidden
176
+ - lower-to-upper references are allowed
156
177
  - Ambiguity is forbidden:
157
- - Ask the user when a decision is not at least 95% certain.
158
- - If uncertainty remains, convert it to a documented Spike (timebox, success criteria, deliverable).
159
- - You MUST produce the required evidence file: `.qfai/evidence/sdd-refinement-<spec-id>.md`.
160
- - You MUST run the refinement gate:
161
- - `qfai validate --phase refinement --fail-on error`
162
- - The refinement gate is local-stage validation. CI pipelines MUST use default/full validation (`qfai validate --fail-on error`).
163
- - Waivers may only suppress `warning` / `info` findings; never use waivers to suppress `error` findings.
178
+ - ask the user when certainty is below the threshold
179
+ - unresolved decisions become explicit open questions or spikes
180
+ - You MUST produce the evidence file: `.qfai/evidence/sdd-refinement-<spec-id>.md`.
164
181
  - Completion must be approved by a reviewer who did not author the artifacts.
165
182
 
166
183
  ## Completion Contract (Shared)
@@ -170,27 +187,44 @@ Before declaring completion, you MUST:
170
187
  - OQ / undefined resolution: resolve ambiguities or explicitly defer with rationale and approval evidence.
171
188
  - Deliverable completeness: verify all required artifacts and sections are present.
172
189
  - OQ / placeholder scan: remove unresolved placeholders (`TBD`, `TODO`, `???`, `OPEN QUESTION`, etc.) unless explicitly deferred.
173
- - Smoke check (if applicable): run the smallest command that proves artifacts are machine-checkable.
190
+ - Run static checks that prove the pack can be reviewed without validator support.
174
191
 
175
192
  ## Goal
176
193
 
177
- Create or update an SDD spec pack that is clear, testable, and ready for planning.
194
+ Create or update an SDD spec pack in the layered format so planning can produce a constrained `plan.md`.
178
195
 
179
196
  ## Non-goals
180
197
 
181
- - Writing production code or tests.
198
+ - Writing production code or runnable tests.
182
199
  - Creating `plan.md` (belongs to planning).
183
200
  - Bypassing unresolved ambiguity.
184
201
 
185
202
  ## Mandatory Outputs
186
203
 
187
- - `.qfai/specs/spec-XXXX/spec.md`
188
- - `.qfai/specs/spec-XXXX/delta.md`
189
- - `.qfai/specs/spec-XXXX/scenario.feature`
190
- - `.qfai/specs/spec-XXXX/case-catalogue.md`
191
- - `.qfai/specs/spec-XXXX/traceability-matrix.md`
192
- - Updated contracts under `.qfai/contracts/**` (when required)
193
- - `.qfai/require/open-questions.md`
204
+ - `.qfai/specs/spec-XXXX/spec.md` (runtime compatibility)
205
+ - `.qfai/specs/spec-XXXX/delta.md` (runtime decision/guardrail SSOT)
206
+ - `.qfai/specs/spec-XXXX/scenario.feature` (runtime compatibility)
207
+ - `.qfai/specs/spec-XXXX/case-catalogue.md` (runtime compatibility)
208
+ - `.qfai/specs/spec-XXXX/traceability-matrix.md` (runtime compatibility)
209
+ - `.qfai/specs/spec-XXXX/01_Spec.md`
210
+ - `.qfai/specs/spec-XXXX/02_Objective.md`
211
+ - `.qfai/specs/spec-XXXX/03_Initiative.md`
212
+ - `.qfai/specs/spec-XXXX/04_Capability.md`
213
+ - `.qfai/specs/spec-XXXX/05_Business-flow.feature`
214
+ - `.qfai/specs/spec-XXXX/06_User-stories.md`
215
+ - `.qfai/specs/spec-XXXX/07_Acceptance-criteria.md`
216
+ - `.qfai/specs/spec-XXXX/08_Business-rules.md`
217
+ - `.qfai/specs/spec-XXXX/09_Examples.feature`
218
+ - `.qfai/specs/spec-XXXX/10_Test-cases.md`
219
+ - `.qfai/specs/spec-XXXX/11_Contracts.md`
220
+ - `.qfai/specs/spec-XXXX/12_Glossary.md`
221
+ - `.qfai/specs/spec-XXXX/13_Constraints.md`
222
+ - `.qfai/specs/spec-XXXX/14_Decisions.md`
223
+ - `.qfai/specs/spec-XXXX/15_Open-questions.md`
224
+ - `.qfai/specs/spec-XXXX/16_Traceability-ledger.md`
225
+ - `.qfai/specs/spec-XXXX/18_delta.md` (optional layered mirror; sync with `delta.md`)
226
+ - Updated contracts under `.qfai/contracts/**` when required
227
+ - `.qfai/require/open-questions.md` when unresolved items remain
194
228
  - Evidence file: `.qfai/evidence/sdd-refinement-<spec-id>.md`
195
229
 
196
230
  ## Required Process
@@ -201,24 +235,21 @@ Create or update an SDD spec pack that is clear, testable, and ready for plannin
201
235
  - Can-Decide
202
236
  - Spike
203
237
  3. Resolve questions in loop (ask one at a time when interactive).
204
- 4. Build/update contracts first when contracts are in scope.
205
- 5. Produce or refine spec pack artifacts.
206
- 6. Update delta decisions and rejected options.
207
- 7. Run refinement gate and record outputs.
238
+ 4. Draft upper layers in layer-first order.
239
+ 5. Execute at least one user-story slice in slice-first order.
240
+ 6. Update contracts index and contract files when references are needed.
241
+ 7. Append adoption/rejection rationale in `delta.md` and sync layered `18_delta.md` when used.
242
+ 8. Run static refinement checks and record outcomes in evidence.
208
243
 
209
244
  ## Refinement Quality Gate
210
245
 
211
- Run:
212
-
213
- ```bash
214
- qfai validate --phase refinement --fail-on error
215
- ```
216
-
217
- Interpretation:
246
+ Run static checks (no validator hard gate for this layout stage):
218
247
 
219
- - This gate validates upstream consistency.
220
- - How-specific checks and SC-to-Test enforcement are intentionally relaxed in this phase.
221
- - This gate is for local refinement iterations, not for CI.
248
+ - Confirm `01..16` and `18` files exist in the target spec pack.
249
+ - Confirm `09_Examples.feature` has exactly one `Feature:` block.
250
+ - Confirm each scenario in `09_Examples.feature` has `@EX`, `@AC`, and `@layer-*` tags.
251
+ - Confirm reference direction follows lower-to-upper only.
252
+ - Confirm at least one ledger row can be traced to objective intent.
222
253
 
223
254
  ## Evidence (MANDATORY)
224
255
 
@@ -240,16 +271,17 @@ Required sections:
240
271
  When declaring DONE, include:
241
272
 
242
273
  - Referenced inputs and spec-id
243
- - Decision record IDs touched
274
+ - Decision record IDs touched in `delta.md`
244
275
  - Confirmation that no rejected option was reintroduced (or list RE-OPEN IDs)
245
- - Refinement gate result
276
+ - Refinement static gate result
246
277
 
247
278
  ## FINAL CHECKLIST (Check Last)
248
279
 
249
280
  - [ ] CRITICAL CONSTRAINTS were followed.
250
281
  - [ ] `plan.md` was NOT created in this phase.
251
- - [ ] `case-catalogue.md` uses category-based tables with `Case title` and no information loss.
282
+ - [ ] Runtime compatibility files and layered `01..16`/`18` outputs exist.
283
+ - [ ] `09_Examples.feature` uses one `Feature:` and tagged `Scenario:` entries.
252
284
  - [ ] OQ ambiguity is resolved or deferred with explicit approval evidence.
253
- - [ ] Refinement gate passed (`qfai validate --phase refinement --fail-on error`).
285
+ - [ ] Refinement static gate checks are recorded in evidence.
254
286
  - [ ] Evidence file exists and is complete.
255
287
  - [ ] Reviewer approval is recorded.
@@ -0,0 +1,28 @@
1
+ # 01 Spec - Metadata and SSOT
2
+
3
+ ## Metadata
4
+
5
+ | Key | Value |
6
+ | ------- | ------------------------------ |
7
+ | Spec ID | SPEC-XXXX |
8
+ | Title | <title> |
9
+ | Status | Draft \| In Review \| Approved |
10
+ | Owner | <role/person> |
11
+ | Created | YYYY-MM-DD |
12
+ | Updated | YYYY-MM-DD |
13
+
14
+ ## Reading Order
15
+
16
+ Use the file order `01` to `18` for review.
17
+
18
+ ## SSOT Declarations
19
+
20
+ - Objective SSOT: `02_Objective.md`
21
+ - Traceability SSOT: `16_Traceability-ledger.md`
22
+ - Plan SSOT: `plan.md` (planning owned; `17_Plan.md` may mirror in layered mode)
23
+ - Contracts index is non-SSOT: `11_Contracts.md`
24
+
25
+ ## Reference Rule
26
+
27
+ - Upper-to-lower references are forbidden.
28
+ - Lower-to-upper references are allowed.
@@ -0,0 +1,23 @@
1
+ # 02 Objective
2
+
3
+ ## Intent
4
+
5
+ - Primary user value:
6
+ - Business value:
7
+
8
+ ## Success Metrics
9
+
10
+ | Metric | Target | Measurement |
11
+ | -------- | -------- | ---------------- |
12
+ | <metric> | <target> | <how to measure> |
13
+
14
+ ## Decision Policy
15
+
16
+ - Priority order for trade-offs:
17
+ - What to optimize first:
18
+ - What can be sacrificed:
19
+
20
+ ## Reference Rule
21
+
22
+ - This layer must not reference lower layers.
23
+ - Lower layers may reference this objective.
@@ -0,0 +1,26 @@
1
+ # 03 Initiative
2
+
3
+ ## Scope Boundary
4
+
5
+ ### In Scope
6
+
7
+ - <item>
8
+
9
+ ### Out of Scope
10
+
11
+ - <item>
12
+
13
+ ## Assumptions
14
+
15
+ - <assumption>
16
+
17
+ ## Risks
18
+
19
+ | Risk | Impact | Mitigation |
20
+ | ------ | -------- | ------------ |
21
+ | <risk> | <impact> | <mitigation> |
22
+
23
+ ## Reference Rule
24
+
25
+ - This layer must not reference lower layers.
26
+ - Lower layers may reference initiative constraints.