qfai 1.4.23 → 1.4.25

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 (31) hide show
  1. package/README.md +10 -4
  2. package/assets/init/.qfai/assistant/agents/coverage-planner.md +14 -5
  3. package/assets/init/.qfai/assistant/agents/qa-gatekeeper.md +11 -1
  4. package/assets/init/.qfai/assistant/agents/test-case-owner.md +12 -4
  5. package/assets/init/.qfai/assistant/agents/test-volume-estimator.md +15 -11
  6. package/assets/init/.qfai/assistant/skills/qfai-discuss/SKILL.md +29 -6
  7. package/assets/init/.qfai/assistant/skills/qfai-discuss/templates/02_Hearing.md +11 -0
  8. package/assets/init/.qfai/assistant/skills/qfai-discuss/templates/03_Config-Hearing.md +8 -0
  9. package/assets/init/.qfai/assistant/skills/qfai-discuss/templates/08_Review-Request.md +3 -0
  10. package/assets/init/.qfai/assistant/skills/qfai-discuss/templates/review/review_request.md +3 -0
  11. package/assets/init/.qfai/assistant/skills/qfai-prototyping/SKILL.md +3 -0
  12. package/assets/init/.qfai/assistant/skills/qfai-require/templates/review/review_request.md +3 -0
  13. package/assets/init/.qfai/assistant/skills/qfai-sdd/SKILL.md +75 -11
  14. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_shared/05_Contracts.md +33 -9
  15. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_shared/08_Decisions.md +9 -0
  16. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_shared/09_Open-questions.md +11 -0
  17. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_shared/10_delta.md +9 -0
  18. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/07_Decisions.md +6 -4
  19. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/08_Open-questions.md +8 -6
  20. package/assets/init/.qfai/assistant/steering/review-gate.rules.yml +14 -0
  21. package/assets/init/.qfai/assistant/templates/rcp_footer.md +17 -0
  22. package/assets/init/.qfai/specs/README.md +7 -5
  23. package/dist/cli/index.cjs +301 -10
  24. package/dist/cli/index.cjs.map +1 -1
  25. package/dist/cli/index.mjs +301 -10
  26. package/dist/cli/index.mjs.map +1 -1
  27. package/dist/index.cjs +224 -6
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.mjs +224 -6
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +1 -1
package/README.md CHANGED
@@ -210,7 +210,7 @@ flowchart LR
210
210
  - Contracts SSOT: `.qfai/contracts/**`
211
211
  - Report outputs (`.qfai/report/**`) are derived artifacts and not SSOT.
212
212
 
213
- ## Minimal tutorial (v1.4.23)
213
+ ## Minimal tutorial (v1.4.25)
214
214
 
215
215
  1. `npx qfai init`
216
216
  2. Run `/qfai-discuss` to structure scope and open questions.
@@ -237,8 +237,8 @@ Release gate behavior:
237
237
 
238
238
  ## Continuous integration
239
239
 
240
- QFAI v1.4.23 generates `.github/**` only for Copilot integration wrappers
241
- (`.github/prompts`, `.github/agents`).
240
+ QFAI v1.4.25 generates integration wrappers under `.agents/**`, `.claude/**`,
241
+ `.github/**`, and `.codex/**`.
242
242
  It does not generate GitHub Actions workflows.
243
243
  Configure CI in your own platform and run:
244
244
 
@@ -272,6 +272,11 @@ Typical customizations.
272
272
 
273
273
  ```text
274
274
  .
275
+ ├── .agents
276
+ │ ├── README.md
277
+ │ └── skills
278
+ │ └── qfai-configure
279
+ │ └── SKILL.md
275
280
  ├── .qfai
276
281
  │ ├── assistant
277
282
  │ │ ├── agents
@@ -374,6 +379,7 @@ Typical customizations.
374
379
 
375
380
  Integration wrappers are also generated for immediate use:
376
381
 
382
+ - Agents/Codex VS Code: `.agents/skills/**`
377
383
  - Claude Code: `.claude/commands/**`, `.claude/agents/**`
378
384
  - GitHub Copilot: `.github/prompts/**`, `.github/agents/**`
379
385
  - Codex: `.codex/skills/**`
@@ -381,7 +387,7 @@ Integration wrappers are also generated for immediate use:
381
387
  ## Agent integrations
382
388
 
383
389
  `npx qfai init` installs canonical skills under `.qfai/assistant/skills/**` (SSOT)
384
- and generates thin wrapper assets for Copilot / Claude Code / Codex.
390
+ and generates thin wrapper assets for Agents/Codex VS Code / Copilot / Claude Code / Codex.
385
391
  If wrapper assets drift from canonical skills, rerun `npx qfai init --force` to resync.
386
392
 
387
393
  ## Contributing (for QFAI maintainers)
@@ -3,21 +3,27 @@
3
3
  ## Mission
4
4
 
5
5
  - Define and maintain coverage ledgers to prevent silent gaps.
6
+ - Convert coverage findings into actionable, perspective-based EX/TC planning.
6
7
 
7
8
  ## Inputs you must read
8
9
 
9
10
  - .qfai/assistant/instructions/\*
10
11
  - .qfai/assistant/steering/\*
11
- - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
- - .qfai/specs/spec-\*/scenario.feature
13
- - .qfai/specs/spec-\*/spec.md
12
+ - .qfai/specs/spec-\*/09_delta.md (Decision Records; check rejected)
13
+ - .qfai/specs/spec-\*/04_Business-Rules.md
14
+ - .qfai/specs/spec-\*/05_Examples.md
15
+ - .qfai/specs/spec-\*/06_Test-Cases.md
16
+ - .qfai/report/validate.log
17
+ - .qfai/report/specs-coverage/spec-\*.md
14
18
  - Existing coverage ledgers and test files
15
19
 
16
20
  ## Deliverables (MANDATORY)
17
21
 
18
22
  - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
23
+ - Hard-gap list (`QFAI-COV-201/202/203/204/205/206`) with source-layer fixes
24
+ - Density-smell list (for example `QFAI-COV-207`) with perspective-based improvement ideas
19
25
  - Scope ledger (what must be tested) with exclusions rationale
20
- - Coverage ledger mapped to scenarios and layers
26
+ - Coverage ledger mapped to BR/EX/TC layers
21
27
  - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
22
28
 
23
29
  ## Stop conditions (Blockers)
@@ -25,7 +31,7 @@
25
31
  - Rejected option would be reintroduced without RE-OPEN DR
26
32
  - Hidden exclusions or silent gaps detected
27
33
  - Evidence is missing or incomplete
28
- - Scenario mapping is ambiguous
34
+ - BR/EX/TC mapping is ambiguous
29
35
 
30
36
  ## Sign-off checklist (Check Last)
31
37
 
@@ -38,7 +44,10 @@
38
44
 
39
45
  - Decision Records (DR-IDs) / rejected check
40
46
  - Findings
47
+ - Hard gaps (`QFAI-COV-201..206`)
48
+ - Density smells (`QFAI-COV-207` and similar)
41
49
  - Coverage ledger
50
+ - Perspective-based EX/TC proposal (boundary, negative, permission, state)
42
51
  - Exclusions rationale
43
52
  - Evidence summary
44
53
  - Open Questions / Risks
@@ -9,8 +9,13 @@
9
9
 
10
10
  - .qfai/assistant/instructions/\*
11
11
  - .qfai/assistant/steering/\*
12
- - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/09_delta.md (Decision Records; check rejected)
13
+ - .qfai/specs/spec-\*/04_Business-Rules.md
14
+ - .qfai/specs/spec-\*/05_Examples.md
15
+ - .qfai/specs/spec-\*/06_Test-Cases.md
13
16
  - QA evidence summaries under `.qfai/evidence/` (gitignored)
17
+ - .qfai/report/validate.log
18
+ - .qfai/report/specs-coverage/spec-\*.md
14
19
  - Coverage ledgers and traceability reports
15
20
  - Gate command outputs
16
21
 
@@ -19,6 +24,8 @@
19
24
  - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
20
25
  - DONE declaration check (inputs + DR-IDs + rejected guard)
21
26
  - Gate status (PASS/FAIL) with rationale
27
+ - Hard gate result summary (`QFAI-COV-201..206`)
28
+ - Density-smell review notes (`QFAI-COV-207` and related warnings)
22
29
  - Explicit gap list and required fixes
23
30
  - Evidence presence check summary
24
31
 
@@ -27,6 +34,7 @@
27
34
  - Rejected option would be reintroduced without RE-OPEN DR
28
35
  - Evidence is missing or incomplete
29
36
  - Coverage ledger is missing or inconsistent
37
+ - Validate gate is missing/failing (`qfai validate --fail-on error --format github`)
30
38
  - Runtime or quality gates are not executed
31
39
 
32
40
  ## Sign-off checklist (Check Last)
@@ -41,6 +49,8 @@
41
49
  - Decision Records (DR-IDs) / rejected check
42
50
  - Gate decision (PASS/FAIL)
43
51
  - Findings
52
+ - Hard gate status (`QFAI-COV-201..206`)
53
+ - Density-smell review (`QFAI-COV-207`)
44
54
  - Required fixes
45
55
  - Evidence summary
46
56
  - Open Questions / Risks
@@ -8,15 +8,21 @@
8
8
 
9
9
  - .qfai/assistant/instructions/\*
10
10
  - .qfai/assistant/steering/\*
11
- - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
- - .qfai/specs/spec-\*/spec.md
13
- - .qfai/specs/spec-\*/scenario.feature
11
+ - .qfai/specs/spec-\*/09_delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/03_Acceptance-Criteria.md
13
+ - .qfai/specs/spec-\*/04_Business-Rules.md
14
+ - .qfai/specs/spec-\*/05_Examples.md
15
+ - .qfai/specs/spec-\*/06_Test-Cases.md
16
+ - .qfai/report/validate.log
17
+ - .qfai/report/specs-coverage/spec-\*.md
14
18
  - Existing test cases and mappings
15
19
 
16
20
  ## Deliverables (MANDATORY)
17
21
 
18
22
  - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
23
+ - Minimal TC set proposal satisfying AC->TC and EX->TC coverage
19
24
  - Test case inventory mapped to requirements/contracts
25
+ - Missing boundary/negative case recommendations (perspective-based)
20
26
  - Exclusions rationale for any missing coverage
21
27
  - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
22
28
 
@@ -25,7 +31,7 @@
25
31
  - Rejected option would be reintroduced without RE-OPEN DR
26
32
  - Traceability gaps without explicit rationale
27
33
  - Evidence is missing or incomplete
28
- - Test cases cannot be mapped to requirements
34
+ - Test cases cannot be mapped to AC/EX requirements
29
35
 
30
36
  ## Sign-off checklist (Check Last)
31
37
 
@@ -39,6 +45,8 @@
39
45
  - Decision Records (DR-IDs) / rejected check
40
46
  - Findings
41
47
  - Test case mapping
48
+ - Coverage gate status (`QFAI-COV-201..206`)
49
+ - Perspective gaps (boundary, negative, permission, state)
42
50
  - Exclusions rationale
43
51
  - Evidence summary
44
52
  - Open Questions / Risks
@@ -2,44 +2,48 @@
2
2
 
3
3
  ## Mission
4
4
 
5
- - Compute ATDD floors (E2E/API/Integration) and detect underestimation.
5
+ - Estimate test volume as a risk signal and detect thin areas.
6
6
 
7
7
  ## Inputs you must read
8
8
 
9
9
  - .qfai/assistant/instructions/\*
10
10
  - .qfai/assistant/steering/\*
11
- - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
- - .qfai/specs/spec-\*/scenario.feature
13
- - .qfai/specs/spec-\*/case-catalogue.md
14
- - .qfai/specs/spec-\*/traceability-matrix.md
11
+ - .qfai/specs/spec-\*/09_delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/04_Business-Rules.md
13
+ - .qfai/specs/spec-\*/05_Examples.md
14
+ - .qfai/specs/spec-\*/06_Test-Cases.md
15
+ - .qfai/report/specs-coverage/spec-\*.md
16
+ - .qfai/report/validate.log
15
17
  - .qfai/contracts/\*\*
16
18
 
17
19
  ## Deliverables (MANDATORY)
18
20
 
19
21
  - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
20
- - Floor estimate table (Layer / Raw count / Multiplier / Floor / Evidence / Notes)
21
- - K rationale (3..5) with complexity signals
22
+ - Risk-signal table (Layer / Raw count / Signal / Evidence / Notes)
23
+ - Density-smell findings (for example multi-BR EX rows) and impact summary
24
+ - Improvement proposals by perspective (boundary/negative/permission/state)
22
25
  - BLOCKED list when data is missing
23
26
  - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
24
27
 
25
28
  ## Stop conditions (Blockers)
26
29
 
27
30
  - Rejected option would be reintroduced without RE-OPEN DR
28
- - Endpoint count cannot be derived and no fallback is available
31
+ - BR/EX/TC source counts cannot be derived and no fallback is available
29
32
  - Evidence is missing or incomplete
30
33
 
31
34
  ## Sign-off checklist (Check Last)
32
35
 
33
36
  - [ ] Deliverables are complete
34
37
  - [ ] Evidence is present (gitignored)
35
- - [ ] Floors are justified with evidence
38
+ - [ ] Risk signals are justified with evidence
36
39
  - [ ] BLOCKED items are explicit
37
40
 
38
41
  ## Output format (structured)
39
42
 
40
43
  - Decision Records (DR-IDs) / rejected check
41
- - Floor table
42
- - K rationale
44
+ - Risk-signal table
45
+ - Density-smell findings
46
+ - Perspective-based improvement proposals
43
47
  - BLOCKED list (if any)
44
48
  - Evidence summary
45
49
  - Open Questions / Risks
@@ -88,6 +88,8 @@ Every major artifact in this stage MUST include this table schema:
88
88
  - RCP wording must be sourced from `.qfai/assistant/templates/rcp_footer.md`.
89
89
  - Discuss artifacts are logs/rationale and must not duplicate spec SSOT.
90
90
  - If diagrams are written, Mermaid syntax must be in ` ```mermaid ` fences only.
91
+ - Do not enforce fixed EX/BR or TC/EX ratios in this phase.
92
+ - Example Mapping is mandatory and must be captured as `Example Seeds` sections.
91
93
 
92
94
  ## Goal
93
95
 
@@ -118,12 +120,32 @@ Produce a fixed discuss pack with explicit decisions and OQ states so downstream
118
120
 
119
121
  1. Run the core interview for product concept, scope, and policy.
120
122
  2. Run config hearing for steering, constraints, and test-layer readiness.
121
- 3. Run deep dive for risks, boundary conditions, and alternatives.
122
- 4. Update `05_OQ-Register.md` with all identified OQs.
123
- 5. Run OQ resolution hearing repeatedly until open count is zero.
124
- 6. Move deferred items to `07_Deferred.md` with mandatory metadata.
125
- 7. Update `06_OQ-Resolution-Log.md`, `08_Review-Request.md`, and `09_delta.md`.
126
- 8. Request review and record Reviewer result.
123
+ 3. Run Example Mapping pass for each BR/AC candidate and capture `Example Seeds` in:
124
+ - `02_Hearing.md` (requirements-oriented seeds)
125
+ - `03_Config-Hearing.md` (constraints/policy-oriented seeds)
126
+ 4. Run deep dive for risks, boundary conditions, and alternatives.
127
+ 5. Update `05_OQ-Register.md` with all identified OQs.
128
+ 6. Run OQ resolution hearing repeatedly until open count is zero.
129
+ 7. Move deferred items to `07_Deferred.md` with mandatory metadata.
130
+ 8. Update `06_OQ-Resolution-Log.md`, `08_Review-Request.md`, and `09_delta.md`.
131
+ 9. Request review and record Reviewer result.
132
+
133
+ ## Example Mapping Perspectives (Mandatory)
134
+
135
+ For each BR/AC candidate, enumerate concrete example seeds with these perspectives:
136
+
137
+ 1. Happy path
138
+ 2. Negative path
139
+ 3. Edge / boundary
140
+ 4. Permission / role
141
+ 5. State transition (if stateful)
142
+ 6. Idempotency / retry (if external I/O exists)
143
+
144
+ Rules:
145
+
146
+ - Use perspective coverage as the gate, not raw case counts.
147
+ - Mark intentionally skipped perspectives with reason and follow-up.
148
+ - Feed unresolved seeds into OQ items with owner and decision point.
127
149
 
128
150
  ## OQ Data Model (Mandatory)
129
151
 
@@ -188,6 +210,7 @@ Before declaring completion, you MUST:
188
210
  - verify all mandatory output files exist and are populated;
189
211
  - ensure `Disposition: open` count is zero;
190
212
  - ensure every deferred item has full metadata;
213
+ - ensure `Example Seeds` sections are present and perspective coverage is explicit;
191
214
  - avoid duplicating finalized spec content in discuss outputs.
192
215
 
193
216
  ## Evidence (MANDATORY)
@@ -16,3 +16,14 @@
16
16
  - In scope:
17
17
  - Out of scope:
18
18
  - Key constraints:
19
+
20
+ ## Example Seeds (Requirements)
21
+
22
+ | BR/AC Candidate | Perspective | Seed (concrete) | Notes |
23
+ | ----------------- | ------------------- | --------------- | ----- |
24
+ | BR-0001 / AC-0001 | Happy | TBD | TBD |
25
+ | BR-0001 / AC-0001 | Negative | TBD | TBD |
26
+ | BR-0001 / AC-0001 | Edge / Boundary | TBD | TBD |
27
+ | BR-0001 / AC-0001 | Permission / Role | TBD | TBD |
28
+ | BR-0001 / AC-0001 | State transition | TBD | TBD |
29
+ | BR-0001 / AC-0001 | Idempotency / Retry | TBD | TBD |
@@ -18,3 +18,11 @@
18
18
  ## Open Gaps to Resolve in Discuss
19
19
 
20
20
  - OQ candidate:
21
+
22
+ ## Example Seeds (Constraints / Policy)
23
+
24
+ | BR/AC Candidate | Perspective | Constraint-aware seed | Policy / gate note |
25
+ | ----------------- | ------------------- | --------------------- | ------------------ |
26
+ | BR-0001 / AC-0001 | Permission / Role | TBD | TBD |
27
+ | BR-0001 / AC-0001 | State transition | TBD | TBD |
28
+ | BR-0001 / AC-0001 | Idempotency / Retry | TBD | TBD |
@@ -23,3 +23,6 @@
23
23
  - OQ state integrity (`open` must be zero at completion)
24
24
  - Deferred metadata completeness and risk handling
25
25
  - Traceability of decisions and rationale
26
+ - Validate evidence availability (`.qfai/report/validate.log`)
27
+ - Hard gate status (`QFAI-COV-201/202/203/204/205/206` should be zero)
28
+ - Coverage report observations from `.qfai/report/specs-coverage/spec-*.md` (perspective gaps over raw count requests)
@@ -19,6 +19,9 @@
19
19
  - Operational and security risks
20
20
  - Mermaid diagrams use ` ```mermaid ` fences only (no ` ```text ` or language-less fences)
21
21
  - Business Flow artifacts include required `flowchart` or `sequenceDiagram` where applicable
22
+ - Validate hard gate evidence exists (`.qfai/report/validate.log`).
23
+ - Coverage hard gates are clear (`QFAI-COV-201/202/203/204/205/206` = 0).
24
+ - `specs-coverage/spec-*.md` was reviewed and density-smell findings (for example `QFAI-COV-207`) are called out as perspective gaps.
22
25
 
23
26
  ## Required Reviewers
24
27
 
@@ -161,6 +161,8 @@ Rules:
161
161
  - If `plan.md` exists, you MUST follow it as implementation constraints.
162
162
  - `implementation-brief.md` is deprecated and must not be used as How SSOT.
163
163
  - If `plan.md` is missing, STOP and run `/qfai-sdd` before proceeding.
164
+ - If `_shared/05_Contracts.md` (or equivalent contracts index) references any contract ID whose declared file does not exist under `.qfai/contracts/**`, STOP and rerun `/qfai-sdd`.
165
+ - `/qfai-prototyping` MUST NOT create new contract files; contracts are strict inputs in this stage.
164
166
  - You MUST produce the required evidence file: `.qfai/evidence/prototyping-<spec-id>.md`.
165
167
  - `.qfai/evidence/` is intentionally NOT tracked by Git (it ships with a local `.gitignore`).
166
168
  - Do NOT commit evidence files; summarize key outcomes in the PR description instead.
@@ -225,6 +227,7 @@ Build a minimal runnable vertical slice from contracts so the app boots and user
225
227
  - ✅ You MAY add minimal “smoke scripts” (e.g., `scripts/smoke.ts`) if they help manual verification.
226
228
  - ❌ Do NOT implement acceptance tests here (that is `/qfai-atdd`).
227
229
  - ❌ Do NOT implement unit/component tests here (that is TDD phases).
230
+ - ❌ Do NOT create new files under `.qfai/contracts/**` in this stage.
228
231
  - ❌ Do NOT change `.qfai/**/README.md` content. They are templates and remain SSOT.
229
232
 
230
233
  ## Mission (what “prototype” means)
@@ -19,6 +19,9 @@
19
19
  - Operational and security risks
20
20
  - Mermaid diagrams use ` ```mermaid ` fences only (no ` ```text ` or language-less fences)
21
21
  - Business Flow artifacts include required `flowchart` or `sequenceDiagram` where applicable
22
+ - Validate hard gate evidence exists (`.qfai/report/validate.log`).
23
+ - Coverage hard gates are clear (`QFAI-COV-201/202/203/204/205/206` = 0).
24
+ - `specs-coverage/spec-*.md` was reviewed and density-smell findings (for example `QFAI-COV-207`) are called out as perspective gaps.
22
25
 
23
26
  ## Required Reviewers
24
27
 
@@ -98,6 +98,12 @@ Every major artifact in this stage MUST include a `## Work Orders Summary` secti
98
98
  - Reviewer checks (minimum):
99
99
  - Required roles were delegated (no orchestrator self-authoring).
100
100
  - DoD satisfied (coverage ledger, gates, evidence, DR-IDs).
101
+ - Validate gate evidence exists and is fresh:
102
+ - `qfai validate --fail-on error --format github` completed with `error=0`.
103
+ - `.qfai/report/validate.log` and `.qfai/report/specs-coverage/spec-*.md` are present.
104
+ - Layer coverage hard gates are all clear:
105
+ - `QFAI-COV-201/202/203/204/205/206` are `0`.
106
+ - `QFAI-COV-207` warnings are reviewed as density-smell signals.
101
107
  - **Drift Protocol enforced**:
102
108
  - No upstream artifact edits were made without an explicit user-approved Change Request.
103
109
  - If upstream changes exist, the correct owner skill was re-run after approval; downstream did not patch upstream directly.
@@ -171,7 +177,7 @@ Rules:
171
177
 
172
178
  ## Workflow Convention (Mandatory)
173
179
 
174
- - **This skill proceeds in this exact order: Outline -> Slice -> Plan finalize -> Delta update.**
180
+ - **This skill proceeds in this exact order: Contracts-first -> Outline -> Slice -> Plan finalize -> Delta update.**
175
181
  - **Upper-to-lower references are forbidden. Lower-to-upper references are allowed.**
176
182
  - **Connections between layers MUST be represented by IDs and required edges (`US->AC->BR->EX->TC`).**
177
183
  - **Plan finalize MUST happen after at least one user-story slice is grounded.**
@@ -184,6 +190,17 @@ Rules:
184
190
  - `.qfai/assistant/skills/qfai-sdd/templates/specs/`
185
191
  - `.qfai/assistant/skills/qfai-sdd/templates/contracts/`
186
192
  - Always write `.qfai/report/preflight_summary.md` before generating shared/spec artifacts.
193
+ - Contracts are contract-first mandatory outputs in this skill:
194
+ - create/update `.qfai/contracts/(api|db|ui)/**` before shared/spec slices
195
+ - `_shared/05_Contracts.md` must include a Contract Index with short IDs (`DB-001`, `API-001`, `UI-001`)
196
+ - every indexed short ID must map to a declared file with `QFAI-CONTRACT-ID`:
197
+ - `DB-001 -> CON-DB-0001 -> db-0001-<slug>.sql`
198
+ - `API-001 -> CON-API-0001 -> api-0001-<slug>.yaml`
199
+ - `UI-001 -> CON-UI-0001 -> ui-0001-<slug>.yaml`
200
+ - `<slug>` comes from entity/router/screen and must be sanitized to kebab-case
201
+ - allocate new contract IDs by scanning existing declarations and using next sequential NNNN per kind
202
+ - never duplicate existing declared IDs; update in-place when the contract already exists
203
+ - contract stubs must be syntactically valid (OpenAPI YAML / UI YAML / executable SQL skeleton)
187
204
  - `/qfai-sdd` must stop when require-pack is missing/incomplete or has blocking OQ (guide to `/qfai-require` or `/qfai-discuss` first).
188
205
  - Review roster is fixed by `.qfai/assistant/steering/review-roster.yml` and must be executed in full.
189
206
  - RCP wording must be sourced from `.qfai/assistant/templates/rcp_footer.md`.
@@ -192,6 +209,9 @@ Rules:
192
209
  - If diagrams are written in discuss/require/spec/evidence artifacts, Mermaid syntax must be inside ` ```mermaid ` fences only.
193
210
  - `05_Examples.md` must include `EX-ID` and `BR-Ref` mappings.
194
211
  - `06_Test-Cases.md` must include `TC-ID`, `EX-Ref`, and `AC-Refs`.
212
+ - Do not complete this stage until:
213
+ - `qfai validate --fail-on error --format github | tee .qfai/report/validate.log` exits successfully.
214
+ - `.qfai/report/specs-coverage/spec-*.md` has been read for density review.
195
215
  - Reference direction rules from `.qfai/specs/README.md` must be enforced:
196
216
  - upper-to-lower references are forbidden
197
217
  - lower-to-upper references are allowed
@@ -205,6 +225,22 @@ Rules:
205
225
  - ask the user when certainty is below threshold
206
226
  - unresolved decisions become explicit Open Questions
207
227
 
228
+ ### Phase 0 - Contracts-first (mandatory)
229
+
230
+ Create/update:
231
+
232
+ - `.qfai/contracts/api/**`
233
+ - `.qfai/contracts/db/**`
234
+ - `.qfai/contracts/ui/**`
235
+ - `_shared/05_Contracts.md` Contract Index table (DB/API/UI short IDs)
236
+
237
+ Rules:
238
+
239
+ - This phase MUST complete before Outline/Slice.
240
+ - If `_shared/05_Contracts.md` lists an ID, the corresponding declared contract file MUST exist.
241
+ - If a contract is empty, create a valid minimal stub and include `QFAI-CONTRACT-ID`.
242
+ - `none` is allowed only when there is no contract impact and rationale is written.
243
+
208
244
  ### Phase 1 - Outline (layer-first)
209
245
 
210
246
  Create/update:
@@ -216,11 +252,15 @@ Create/update:
216
252
  - `_shared/05_Contracts.md`
217
253
  - `_shared/06_Glossary.md`
218
254
  - `_shared/07_Constraints.md`
255
+ - `_shared/08_Decisions.md`
256
+ - `_shared/09_Open-questions.md`
257
+ - `_shared/10_delta.md`
219
258
 
220
259
  Rules:
221
260
 
222
261
  - Temporary `TBD` is allowed, but each `TBD` must be mirrored into `_shared/09_Open-questions.md`.
223
262
  - `_shared/04_Business-Flow.md` must include Mermaid and keep diagram syntax inside ` ```mermaid ` fences.
263
+ - `_shared/08_Decisions.md` and `_shared/10_delta.md` must exist even when empty, and must explicitly state `0 items`.
224
264
 
225
265
  ### Phase 2 - Slice (slice-first)
226
266
 
@@ -232,6 +272,8 @@ Create/update:
232
272
  - `spec-XXXX/04_Business-Rules.md`
233
273
  - `spec-XXXX/05_Examples.md`
234
274
  - `spec-XXXX/06_Test-Cases.md`
275
+ - `spec-XXXX/07_Decisions.md`
276
+ - `spec-XXXX/08_Open-questions.md`
235
277
 
236
278
  Slice gate (must pass before Phase 3):
237
279
 
@@ -239,6 +281,7 @@ Slice gate (must pass before Phase 3):
239
281
  - For each AC, BR and SC must exist.
240
282
  - For each TC, EX reference must exist.
241
283
  - `SC` tags must align with the target `spec-XXXX` namespace.
284
+ - `07_Decisions.md` and `08_Open-questions.md` must exist even when empty and include explicit `0 items` statements.
242
285
 
243
286
  ### Phase 3 - Plan finalize
244
287
 
@@ -271,6 +314,11 @@ Before declaring completion, you MUST:
271
314
  - Deliverable completeness: verify all required artifacts and sections are present.
272
315
  - OQ / placeholder scan: remove unresolved placeholders (`TBD`, `TODO`, `???`, `OPEN QUESTION`, etc.) unless explicitly deferred.
273
316
  - Run static checks proving the pack is reviewable.
317
+ - Run validate gate and keep evidence:
318
+ - `qfai validate --fail-on error --format github | tee .qfai/report/validate.log`
319
+ - `.qfai/report/specs-coverage/spec-*.md`
320
+ - If validate fails, fix spec-layer sources and rerun validate until `error=0`.
321
+ - Do not patch upstream intent from downstream artifacts (Drift Protocol applies).
274
322
 
275
323
  ## Goal
276
324
 
@@ -291,15 +339,20 @@ Create or update layered SDD artifacts in one run so downstream execution phases
291
339
  - `.qfai/specs/_shared/05_Contracts.md`
292
340
  - `.qfai/specs/_shared/06_Glossary.md`
293
341
  - `.qfai/specs/_shared/07_Constraints.md`
342
+ - `.qfai/specs/_shared/08_Decisions.md`
343
+ - `.qfai/specs/_shared/09_Open-questions.md`
344
+ - `.qfai/specs/_shared/10_delta.md`
294
345
  - `.qfai/specs/spec-XXXX/01_Spec.md`
295
346
  - `.qfai/specs/spec-XXXX/02_User-stories.md`
296
347
  - `.qfai/specs/spec-XXXX/03_Acceptance-Criteria.md`
297
348
  - `.qfai/specs/spec-XXXX/04_Business-Rules.md`
298
349
  - `.qfai/specs/spec-XXXX/05_Examples.md`
299
350
  - `.qfai/specs/spec-XXXX/06_Test-Cases.md`
351
+ - `.qfai/specs/spec-XXXX/07_Decisions.md`
352
+ - `.qfai/specs/spec-XXXX/08_Open-questions.md`
300
353
  - `.qfai/specs/spec-XXXX/10_Plan.md`
301
354
  - `.qfai/specs/spec-XXXX/09_delta.md` (or `*_delta.md`)
302
- - Updated contracts under `.qfai/contracts/**` when required
355
+ - Updated contracts under `.qfai/contracts/**` (mandatory in this workflow)
303
356
  - `.qfai/report/preflight_summary.md`
304
357
  - Evidence file: `.qfai/evidence/sdd-<spec-id>.md`
305
358
 
@@ -309,11 +362,15 @@ Create or update layered SDD artifacts in one run so downstream execution phases
309
362
  2. If readiness checks fail, stop and show blockers with `/qfai-require` and `/qfai-discuss`.
310
363
  3. Analyze repository context, existing artifacts, constraints, and open decisions.
311
364
  4. Write `.qfai/report/preflight_summary.md` from `templates/report/preflight_summary.md`.
312
- 5. Execute Phase 1 (Outline) in layer-first order.
313
- 6. Execute Phase 2 (Slice) for at least one user-story slice and pass slice gate.
314
- 7. Execute Phase 3 (Plan finalize) and make `10_Plan.md` actionable as How-only.
315
- 8. Execute Phase 4 (Delta update) and record adoption/rejection rationale.
316
- 9. Run static checks and record outcomes in evidence.
365
+ 5. Execute Phase 0 (Contracts-first) and ensure `_shared/05_Contracts.md` index and `.qfai/contracts/**` are aligned.
366
+ 6. Execute Phase 1 (Outline) in layer-first order.
367
+ 7. Execute Phase 2 (Slice) for at least one user-story slice and pass slice gate.
368
+ 8. Execute Phase 3 (Plan finalize) and make `10_Plan.md` actionable as How-only.
369
+ 9. Execute Phase 4 (Delta update) and record adoption/rejection rationale.
370
+ 10. Run `qfai validate --fail-on error --format github | tee .qfai/report/validate.log`.
371
+ 11. Run Density Review Pass using `.qfai/report/specs-coverage/spec-*.md` and `QFAI-COV-207` warnings.
372
+ 12. If any validate error exists, fix the source layer table(s) and repeat steps 10-11 until `error=0`.
373
+ 13. Record static checks, validate evidence, and density review outcomes in evidence.
317
374
 
318
375
  ## Unified SDD Quality Gate
319
376
 
@@ -327,6 +384,8 @@ Run static checks:
327
384
  - Confirm reference direction follows lower-to-upper only.
328
385
  - Confirm required edges `US -> AC -> BR -> EX -> TC`.
329
386
  - Confirm BR/Examples/Test-cases contain non-empty IDs and coverage mapping.
387
+ - Confirm `QFAI-COV-201/202/203/204/205/206` are zero.
388
+ - Confirm `.qfai/report/specs-coverage/spec-*.md` was reviewed and `QFAI-COV-207` warnings were triaged.
330
389
  - Confirm `10_Plan.md` exists and contains implementation/test strategy as How-only.
331
390
  - Confirm `specs/plan.md` does not exist.
332
391
  - Confirm `09_delta.md` (or `*_delta.md`) includes rejected guardrails (`DO NOT`, `Temptation`) when rejections exist.
@@ -344,6 +403,7 @@ Required sections:
344
403
  - Decisions made (with rationale)
345
404
  - Work performed (what changed, where)
346
405
  - Commands executed + key outputs
406
+ - Validate evidence paths (`.qfai/report/validate.log`, `.qfai/report/specs-coverage/spec-*.md`)
347
407
  - Gaps / Open risks
348
408
  - Final status (PASS/FAIL) + who confirmed
349
409
 
@@ -352,7 +412,7 @@ Required sections:
352
412
  When declaring DONE, include:
353
413
 
354
414
  - Referenced inputs and spec-id
355
- - Confirmation of phase order: Outline -> Slice -> Plan finalize -> Delta update
415
+ - Confirmation of phase order: Contracts-first -> Outline -> Slice -> Plan finalize -> Delta update
356
416
  - Decision record IDs touched in `09_delta.md` (or `*_delta.md`)
357
417
  - Confirmation that no rejected option was reintroduced (or list RE-OPEN IDs)
358
418
  - Unified SDD quality gate result
@@ -361,7 +421,8 @@ When declaring DONE, include:
361
421
 
362
422
  - [ ] CRITICAL CONSTRAINTS were followed.
363
423
  - [ ] `.qfai/report/preflight_summary.md` was generated before spec authoring.
364
- - [ ] Outline -> Slice -> Plan finalize -> Delta update order was preserved.
424
+ - [ ] Contracts-first -> Outline -> Slice -> Plan finalize -> Delta update order was preserved.
425
+ - [ ] `_shared/05_Contracts.md` index and `.qfai/contracts/**` declared files are aligned.
365
426
  - [ ] Upper-to-lower references were not introduced.
366
427
  - [ ] At least one user-story slice passed gate before plan finalization.
367
428
  - [ ] Required `_shared` + `spec-XXXX` outputs exist and are internally consistent.
@@ -370,6 +431,9 @@ When declaring DONE, include:
370
431
  - [ ] `10_Plan.md` is finalized with implementation/test strategy (How-only).
371
432
  - [ ] `specs/plan.md` was not created.
372
433
  - [ ] `09_delta.md` (or `*_delta.md`) contains adoption/rejection rationale.
434
+ - [ ] `qfai validate --fail-on error --format github` ran and produced `error=0`.
435
+ - [ ] `QFAI-COV-201/202/203/204/205/206` are all zero.
436
+ - [ ] `.qfai/report/specs-coverage/spec-*.md` was reviewed for density-smell signals (`QFAI-COV-207`).
373
437
  - [ ] Unresolved items are tracked in shared/spec Open Questions files.
374
438
  - [ ] Quality gate checks are recorded in evidence.
375
439
  - [ ] Evidence file exists and is complete.
@@ -392,7 +456,7 @@ When this skill is complete, provide a final user-facing completion message and
392
456
  Action: build contract-aligned skeleton implementation before deeper coding.
393
457
  - Test-first path: `/qfai-atdd`.
394
458
  Action: implement acceptance tests from the finalized spec pack.
395
- - Want to add contracts:
396
- Action: create files under `.qfai/contracts/(api|db|ui)/` from `templates/contracts/*` and declare `QFAI-CONTRACT-ID`.
459
+ - Contracts status:
460
+ Action: confirm contracts were created/updated under `.qfai/contracts/**` and referenced by `_shared/05_Contracts.md`.
397
461
  - Spec pack needs correction: rerun `/qfai-sdd`.
398
462
  Action: fix layered `_shared + spec-XXXX` consistency and decision records, then regenerate evidence.
@@ -2,25 +2,49 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
- - Describe API/UI/DB contract boundaries in shared language.
6
- - Model relationships with Mermaid when expressing entities or ownership.
5
+ - Keep contracts as SSOT under `.qfai/contracts/**` with deterministic IDs.
6
+ - Use this file as a readable index with short IDs for planning and review.
7
+
8
+ ## Contract Index
9
+
10
+ ### DB Contracts
11
+
12
+ | Short ID | Entity | Declared ID | File | Purpose |
13
+ | -------- | ------------ | ----------- | --------------------------------------- | ----------------- |
14
+ | DB-001 | order_drafts | CON-DB-0001 | `.qfai/contracts/db/db-0001-<slug>.sql` | draft persistence |
15
+
16
+ ### API Contracts
17
+
18
+ | Short ID | Router | Declared ID | File | Purpose |
19
+ | -------- | ----------- | ------------ | ------------------------------------------ | ------------ |
20
+ | API-001 | /api/orders | CON-API-0001 | `.qfai/contracts/api/api-0001-<slug>.yaml` | create draft |
21
+
22
+ ### UI Contracts
23
+
24
+ | Short ID | Screen | Declared ID | File | Purpose |
25
+ | -------- | ------------ | ----------- | ---------------------------------------- | ---------------- |
26
+ | UI-001 | order-create | CON-UI-0001 | `.qfai/contracts/ui/ui-0001-<slug>.yaml` | draft input form |
27
+
28
+ ## Mapping Rules
29
+
30
+ - `DB-001` maps to `CON-DB-0001`, file `db-0001-<slug>.sql`.
31
+ - `API-001` maps to `CON-API-0001`, file `api-0001-<slug>.yaml`.
32
+ - `UI-001` maps to `CON-UI-0001`, file `ui-0001-<slug>.yaml`.
33
+ - `<slug>` must be kebab-case from entity/router/screen.
34
+ - If no contracts are needed, keep each table and state `0 items` explicitly.
7
35
 
8
36
  ## Diagram (Mermaid required for ER/relationship)
9
37
 
10
38
  ```mermaid
11
39
  erDiagram
12
- USER ||--o{ ORDER : places
40
+ USER ||--o{ ORDER_DRAFT : creates
13
41
  USER {
14
42
  string id
15
43
  string email
16
44
  }
17
- ORDER {
45
+ ORDER_DRAFT {
18
46
  string id
19
47
  string user_id
48
+ string status
20
49
  }
21
50
  ```
22
-
23
- ## Notes
24
-
25
- - Keep detailed SSOT in `.qfai/contracts/**`.
26
- - Use this file as the shared contract index and relationship map.