qfai 1.9.2 → 1.10.1

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 (136) hide show
  1. package/README.md +67 -6
  2. package/assets/init/.qfai/assistant/README.md +27 -0
  3. package/assets/init/.qfai/assistant/agents/acceptance-test-engineer.md +1 -0
  4. package/assets/init/.qfai/assistant/agents/backend-engineer.md +1 -0
  5. package/assets/init/.qfai/assistant/agents/completion-reviewer.md +29 -2
  6. package/assets/init/.qfai/assistant/agents/delivery-planner.md +17 -0
  7. package/assets/init/.qfai/assistant/agents/frontend-engineer.md +1 -0
  8. package/assets/init/.qfai/assistant/agents/implementation-reviewer.md +17 -0
  9. package/assets/init/.qfai/assistant/agents/orchestrator.md +2 -2
  10. package/assets/init/.qfai/assistant/agents/qa-gatekeeper.md +183 -5
  11. package/assets/init/.qfai/assistant/agents/test-design-analyst.md +22 -3
  12. package/assets/init/.qfai/assistant/catalog/cli-ux-guidelines.md +2 -2
  13. package/assets/init/.qfai/assistant/catalog/spec_required_files.json +2 -1
  14. package/assets/init/.qfai/assistant/catalog/test-layers-ci-lanes.md +60 -0
  15. package/assets/init/.qfai/assistant/catalog/test-layers.md +430 -13
  16. package/assets/init/.qfai/assistant/catalog/worklog-entry.schema.md +165 -0
  17. package/assets/init/.qfai/assistant/constitution/communication.md +1 -1
  18. package/assets/init/.qfai/assistant/constitution/constitution.md +1 -1
  19. package/assets/init/.qfai/assistant/constitution/drift-protocol.md +359 -10
  20. package/assets/init/.qfai/assistant/constitution/quality.md +35 -5
  21. package/assets/init/.qfai/assistant/constitution/requirements-decomposition.md +37 -0
  22. package/assets/init/.qfai/assistant/constitution/shared-skill-delegation-baseline.md +419 -8
  23. package/assets/init/.qfai/assistant/constitution/shared-skill-operating-baseline.md +122 -5
  24. package/assets/init/.qfai/assistant/constitution/workflow.md +53 -7
  25. package/assets/init/.qfai/assistant/manifest/agent-catalog.yml +439 -946
  26. package/assets/init/.qfai/assistant/manifest/agent-routing.yml +116 -4
  27. package/assets/init/.qfai/assistant/manifest/review-profiles.yml +9 -0
  28. package/assets/init/.qfai/assistant/process/migrations/v1.4.27-atdd-alignment.md +1 -1
  29. package/assets/init/.qfai/assistant/skills/qfai-atdd/SKILL.md +150 -53
  30. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/credential-reuse.md +146 -0
  31. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/red-provenance.md +456 -0
  32. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/review-fix-rounds.md +128 -0
  33. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/scaffolding.md +29 -0
  34. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/shared-test-artifacts.md +96 -0
  35. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/stale-manifest.md +34 -0
  36. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/test-case-depth-checklist.md +52 -5
  37. package/assets/init/.qfai/assistant/skills/qfai-configure/SKILL.md +16 -8
  38. package/assets/init/.qfai/assistant/skills/qfai-discussion/SKILL.md +8 -4
  39. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/design-md-brand-catalog.md +2 -2
  40. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/discussion-completion-matrix.md +17 -7
  41. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/rcp_footer.md +10 -4
  42. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/review-cycle-playbook.md +5 -1
  43. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui-bearing-playbook.md +4 -4
  44. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/review_audit_playbook.md +1 -1
  45. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/trend_scan_playbook.md +1 -1
  46. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux_best_practices.md +17 -7
  47. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/01_Context.md +1 -1
  48. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/02_Inception-Deck.md +1 -1
  49. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/03_Story-Workshop.md +11 -3
  50. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/05_Scope.md +5 -2
  51. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/07_NFR.md +1 -1
  52. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/09_Constraints.md +7 -4
  53. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/10_Policy.md +1 -1
  54. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/11_OQ-Register.md +1 -1
  55. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/12_OQ-Resolution-Log.md +1 -1
  56. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/14_Review-Request.md +14 -7
  57. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/99_delta.md +1 -1
  58. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/Rxx_reviewer.md +16 -7
  59. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/review_request.md +9 -6
  60. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/summary.json +2 -0
  61. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/40_screen_contracts.md +3 -2
  62. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/50_review_input_bundle.md +4 -2
  63. package/assets/init/.qfai/assistant/skills/qfai-implement/SKILL.md +252 -130
  64. package/assets/init/.qfai/assistant/skills/qfai-implement/references/change-request-reset.md +93 -0
  65. package/assets/init/.qfai/assistant/skills/qfai-implement/references/checkpoint-verification.md +210 -0
  66. package/assets/init/.qfai/assistant/skills/qfai-implement/references/cross-spec-ownership.md +73 -0
  67. package/assets/init/.qfai/assistant/skills/qfai-implement/references/evidence-revision.md +291 -0
  68. package/assets/init/.qfai/assistant/skills/qfai-implement/references/execution-ledger.md +389 -0
  69. package/assets/init/.qfai/assistant/skills/qfai-implement/references/final-checklist.md +28 -0
  70. package/assets/init/.qfai/assistant/skills/qfai-implement/references/finding-classification.md +49 -0
  71. package/assets/init/.qfai/assistant/skills/qfai-implement/references/ledger-preconditions.md +55 -0
  72. package/assets/init/.qfai/assistant/skills/qfai-implement/references/oracle-strength.md +81 -0
  73. package/assets/init/.qfai/assistant/skills/qfai-implement/references/parallelization-policy.md +235 -0
  74. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-admissibility.md +91 -0
  75. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-not-observable.md +112 -0
  76. package/assets/init/.qfai/assistant/skills/qfai-implement/references/relevant-test-suite.md +87 -0
  77. package/assets/init/.qfai/assistant/skills/qfai-implement/references/review-artifact-layout.md +44 -0
  78. package/assets/init/.qfai/assistant/skills/qfai-implement/references/round-evidence.md +118 -0
  79. package/assets/init/.qfai/assistant/skills/qfai-implement/references/selector-granularity.md +24 -0
  80. package/assets/init/.qfai/assistant/skills/qfai-implement/references/upstream-artifact-ordering.md +33 -0
  81. package/assets/init/.qfai/assistant/skills/qfai-implement/references/volume-policy.md +149 -0
  82. package/assets/init/.qfai/assistant/skills/qfai-prototyping/SKILL.md +35 -18
  83. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/evidence-requirements.md +1 -1
  84. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/generator-prompt.md +106 -7
  85. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/handoff.md +40 -11
  86. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/iteration-loop.md +48 -1
  87. package/assets/init/.qfai/assistant/skills/qfai-prototyping/templates/DESIGN.md.sample +6 -0
  88. package/assets/init/.qfai/assistant/skills/qfai-sdd/SKILL.md +87 -22
  89. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/contract-artifact-rules.md +148 -0
  90. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/rcp_footer.md +10 -4
  91. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/review-cycle-playbook.md +5 -1
  92. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-execution-playbook.md +4 -2
  93. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-phase-checklists.md +18 -0
  94. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-quality-gate.md +44 -3
  95. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-triage.md +60 -7
  96. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/spec-traceability-rules.md +171 -6
  97. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/change-request.md +125 -0
  98. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/contracts/db-contract.sample.sql +6 -0
  99. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/evidence/sdd-spec.md +92 -0
  100. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/01_Objective.md +27 -0
  101. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/02_Initiative.md +30 -0
  102. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/05_Contracts.md +16 -6
  103. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/06_Glossary.md +19 -0
  104. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/07_Constraints.md +25 -0
  105. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/08_Decisions.md +22 -2
  106. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/11_Slice-Policy.md +37 -10
  107. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/02_User-stories.md +20 -0
  108. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/03_Acceptance-Criteria.md +19 -0
  109. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/04_Business-Rules.md +32 -3
  110. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/06_Test-Cases.md +56 -0
  111. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/07_Decisions.md +29 -2
  112. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/10_Plan.md +41 -0
  113. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/16_Traceability-ledger.md +58 -0
  114. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/tdd/test-list.md +56 -0
  115. package/assets/init/.qfai/assistant/skills/qfai-verify/SKILL.md +57 -102
  116. package/assets/init/.qfai/assistant/skills/qfai-verify/references/articles.md +24 -0
  117. package/assets/init/.qfai/assistant/skills/qfai-verify/references/context-load.md +22 -0
  118. package/assets/init/.qfai/assistant/skills/qfai-verify/references/verify-output-contract.md +48 -0
  119. package/assets/init/.qfai/assistant/skills/qfai-verify/templates/verify-evidence.md +48 -0
  120. package/assets/init/.qfai/assistant/skills/web-research/SKILL.md +25 -7
  121. package/assets/init/.qfai/waivers.yml +11 -5
  122. package/assets/init/root/.github/workflows/qfai-tests.yml +318 -0
  123. package/assets/init/root/.github/workflows/qfai-validate.yml +327 -24
  124. package/assets/init/root/DESIGN.md +6 -0
  125. package/assets/init/root/qfai.config.yaml +15 -12
  126. package/dist/cli/index.cjs +20646 -13620
  127. package/dist/cli/index.cjs.map +1 -1
  128. package/dist/cli/index.mjs +22101 -15061
  129. package/dist/cli/index.mjs.map +1 -1
  130. package/dist/index.cjs +13954 -8829
  131. package/dist/index.cjs.map +1 -1
  132. package/dist/index.d.cts +423 -14
  133. package/dist/index.d.ts +423 -14
  134. package/dist/index.mjs +9330 -4224
  135. package/dist/index.mjs.map +1 -1
  136. package/package.json +22 -19
@@ -15,8 +15,8 @@
15
15
  | DB-001 | order_drafts | CON-DB-0001 | `.qfai/contracts/db/db-0001-<slug>.sql` | draft persistence |
16
16
  -->
17
17
 
18
- | Short ID | Entity | Declared ID | File | Purpose |
19
- | -------- | ------ | ----------- | ---- | ------- |
18
+ | Short ID | Entity | Declared ID | File | Depends On | Purpose |
19
+ | -------- | ------ | ----------- | ---- | ---------- | ------- |
20
20
 
21
21
  ### API Contracts
22
22
 
@@ -26,8 +26,8 @@
26
26
  | API-001 | /api/orders | CON-API-0001 | `.qfai/contracts/api/api-0001-<slug>.yaml` | create draft |
27
27
  -->
28
28
 
29
- | Short ID | Router | Declared ID | File | Purpose |
30
- | -------- | ------ | ----------- | ---- | ------- |
29
+ | Short ID | Router | Declared ID | File | Depends On | Purpose |
30
+ | -------- | ------ | ----------- | ---- | ---------- | ------- |
31
31
 
32
32
  ### UI Contracts
33
33
 
@@ -37,11 +37,21 @@
37
37
  | UI-001 | order-create | CON-UI-0001 | `.qfai/contracts/ui/ui-0001-<slug>.yaml` | draft input form |
38
38
  -->
39
39
 
40
- | Short ID | Screen | Declared ID | File | Purpose |
41
- | -------- | ------ | ----------- | ---- | ------- |
40
+ | Short ID | Screen | Declared ID | File | Depends On | Purpose |
41
+ | -------- | ------ | ----------- | ---- | ---------- | ------- |
42
42
 
43
43
  ## Mapping Rules
44
44
 
45
+ - `Depends On` lists the contracts that must be applied **before** this one, as
46
+ `CON-*` ids, or `-` when none. It mirrors the `-- Depends on:` line in a
47
+ `.sql` contract and the `x-qfai-depends-on` key in a `.yaml` one.
48
+ - A runtime reference is not an apply-order dependency. `QFAI-CONTRACT-011`
49
+ forces a multi-table schema into N files, so this column is the only place the
50
+ resulting composition is stated; without it every consumer reconstructs the
51
+ apply graph by reading the DDL, and getting it wrong is silent.
52
+ - `QFAI-CONTRACT-014` errors on a declared dependency that names no existing
53
+ contract.
54
+
45
55
  - If no contracts are needed, keep each table and state `0 items` explicitly.
46
56
  - `<slug>` must be kebab-case from entity/router/screen.
47
57
 
@@ -0,0 +1,19 @@
1
+ # 06 Glossary
2
+
3
+ Cross-spec vocabulary. One definition per term, defined once, here.
4
+
5
+ ## Terms
6
+
7
+ | Term | Definition | Not to be confused with |
8
+ | -------- | ------------------------------------ | --------------------------- |
9
+ | `<Term>` | `<precise definition, one sentence>` | `<the near-miss it is not>` |
10
+
11
+ ## Authoring rules
12
+
13
+ - A term earns an entry when two specs would otherwise define it differently,
14
+ or when a reader outside the team would guess wrong.
15
+ - `Not to be confused with` is where the value is. A definition that no one
16
+ would have misread did not need this file.
17
+ - Use the term consistently in every spec once it is defined here. Introducing a
18
+ synonym is a glossary change, not a wording choice.
19
+ - Domain vocabulary only — do not restate framework or language terms.
@@ -0,0 +1,25 @@
1
+ # 07 Constraints
2
+
3
+ Cross-spec constraints every spec inherits: what the solution may not do,
4
+ regardless of which capability is being built.
5
+
6
+ ## Constraints
7
+
8
+ | ID | Constraint | Kind | Source |
9
+ | ------ | ------------------------- | ---------------------------------------------------------- | -------------------------- |
10
+ | CST-01 | `<what is not permitted>` | `regulatory` / `contractual` / `technical` / `operational` | `<who or what imposes it>` |
11
+
12
+ ## Non-functional floors
13
+
14
+ | ID | Dimension | Floor | How it is verified |
15
+ | ------ | --------------------------------------------- | ------------------ | ------------------ |
16
+ | NFR-01 | `availability` / `latency` / `security` / ... | `<measurable bar>` | `<gate or probe>` |
17
+
18
+ ## Authoring rules
19
+
20
+ - A constraint without a `Source` is a preference. Name who imposes it, so a
21
+ future change knows whom to ask.
22
+ - A floor without a verification method is unenforceable — state the gate or the
23
+ probe that would catch a breach.
24
+ - Constraints bind every spec. Something true of one capability only belongs in
25
+ that spec's `01_Spec.md`, not here.
@@ -1,9 +1,29 @@
1
1
  # 08 Decisions
2
2
 
3
+ Cross-spec Decision Records. A `DR-*` cited from any spec's `tdd/test-list.md`
4
+ `DR-ID` column resolves against this file as well as the spec's own
5
+ `07_Decisions.md`, so a policy-level decision is cited, never re-declared.
6
+
7
+ ## ID scheme
8
+
9
+ - **Policy-level**: `DR-NNNN` — declared here, cited from any spec.
10
+ - A spec-only decision uses `DR-NNNN-MMMM` and belongs in that spec's
11
+ `07_Decisions.md`. Declaring the same ID in both files gives it two owners.
12
+
3
13
  ## Decisions
4
14
 
5
- - 0 items in shared decisions.
15
+ <!-- One `### DR-NNNN` block per decision. Copy the sample below. -->
16
+
17
+ ### DR-NNNN: one-line title
18
+
19
+ - Status: proposed | accepted | superseded | rejected
20
+ - Context: what forced the decision — the constraint, conflict or anomaly
21
+ - Decision: what was decided, in the imperative
22
+ - Consequences: what this costs and what it forecloses
23
+ - Related: the specs, capabilities or contracts this decision binds, or `-`
6
24
 
7
25
  ## Empty State
8
26
 
9
- - Add ADR entries only when a cross-spec shared decision is required.
27
+ - 0 items in shared decisions. Add an entry only when a decision genuinely
28
+ crosses specs; a spec-local one belongs in that spec's `07_Decisions.md`.
29
+ Delete the sample block above once the first real decision is recorded.
@@ -67,22 +67,49 @@ approval before any spec edits begin.
67
67
 
68
68
  ## APPEND vs CREATE algorithm
69
69
 
70
- For each incoming REQ/NFR, apply in order (append-first):
70
+ Steps 1-3, 5 and 6 select the operation; the **first** one that matches wins.
71
+ Step 4 is **not** an alternative branch — it is a recording obligation that
72
+ always runs afterwards, on whichever spec the selected operation targets. Do not
73
+ stop at step 2.
71
74
 
72
75
  1. Resolve the REQ's capability from `_policies/03_Capabilities.md`.
73
- 2. If a single active spec already owns that capability and its
74
- `acCount <= 30 && tcCount <= 50` → **UPDATE:APPEND**.
76
+ 2. If a single active spec already owns that capability → **UPDATE:APPEND**.
77
+ Item counts do not change this answer. Continue to step 4: an oversized
78
+ owner still needs its `Rationale` entry and its capability-ownership review.
75
79
  3. If multiple active specs share the capability → **MERGE**.
76
- 4. If a single active spec owns the capability but exceeds the AC/TC
77
- thresholds → **SPLIT**.
80
+ 4. **Always evaluate, whatever step 2/3/5 decided.** If any spec the selected
81
+ operation targets exceeds the AC/TC thresholds (`acCount > 30` or
82
+ `tcCount > 50`), that is a **size signal, not an operation**. A MERGE row
83
+ targets several specs, so check them all. Record every breach in the Triage
84
+ row's `Rationale` and start a **capability-ownership review**:
85
+ - the spec genuinely owns more than one `CAP-NNNN` → **SPLIT** (approval
86
+ required, see below);
87
+ - the spec owns exactly one capability → **the operation selected in steps
88
+ 1-3/5 is unchanged** — MERGE stays MERGE with its approval, APPEND stays
89
+ APPEND. This step never rewrites the operation; it only records the
90
+ reasoned non-split, because there is nothing to split into.
91
+
92
+ > A count-driven SPLIT of a single-capability spec is **illegal**.
93
+ > `validateSpecSplitByCapability` hard-enforces one `CAP-NNNN` per spec
94
+ > with sequential directory names, so it raises `QFAI-SPLIT-102` and
95
+ > `QFAI-SPLIT-104` at `error` severity. The SPLIT trigger is capability
96
+ > ownership (line 64 of this file, and `sdd-triage.md`), never a count.
97
+
98
+ > An **obligation-conserving re-granulation** — the same obligations
99
+ > expressed as finer cells, zero added and zero removed — never triggers
100
+ > SPLIT, whatever it does to `acCount` / `tcCount`. To claim it, state in
101
+ > the `Rationale` which obligations existed before, which exist after, and
102
+ > that the sets are equal.
103
+
78
104
  5. If no active spec owns the capability **but at least one active
79
105
  spec's title / scope / capability shares any subject token with the
80
106
  REQ** → **UPDATE:APPEND on the closest spec** (subject-overlap
81
- fallback). Upgrade to **SPLIT** if that spec exceeds the AC/TC
82
- thresholds. Subject tokens follow `src/core/sddTriage.ts::tokenize`
83
- normalization (STOP_TOKEN drop, length ≥ 2, Unicode `\p{L}\p{N}`),
84
- so "the new flag"-style subjects collapse to zero tokens and skip to
85
- step 6 — author REQ subjects with meaningful nouns.
107
+ fallback). A threshold breach on that spec is again a size signal
108
+ recorded in `Rationale`, not an upgrade to SPLIT. Subject tokens follow
109
+ `src/core/sddTriage.ts::tokenize` normalization (STOP_TOKEN drop,
110
+ length ≥ 2, Unicode `\p{L}\p{N}`), so "the new flag"-style subjects
111
+ collapse to zero tokens and skip to step 6 — author REQ subjects with
112
+ meaningful nouns.
86
113
  6. Only when **no active spec shares any token** with the REQ AND the
87
114
  underlying capability is genuinely new → **CREATE**. Add the new
88
115
  `CAP-NNNN` to `_policies/03_Capabilities.md` _first_, then cite it
@@ -7,6 +7,26 @@
7
7
  ## US-0001: <title>
8
8
 
9
9
  - Parent: CAP-XXXX
10
+ - Source: discussion-YYYYMMDDhhmmssSSS#DUS-XXX <!-- originating pack + story ID, or `-` if none -->
10
11
  - Goal: <goal>
11
12
  - Non-goals: <non-goal>
12
13
  - Notes: <notes>
14
+
15
+ > `Source` carries provenance back to the discussion pack. Write it as
16
+ > `<pack-id>#<discussion-id>`: the pack directory name under `.qfai/discussion/`, then the
17
+ > discussion-layer ID inside that pack, joined by `#`. Both halves are required. Every pack
18
+ > numbers its stories from `DUS-001`, so a bare `DUS-001` cannot say which pack it came from
19
+ > — and a spec that a second pack later `UPDATE:APPEND`s would carry two different stories
20
+ > under the same `Source` value. The pair resolves to exactly one entry:
21
+ > `.qfai/discussion/<pack-id>/03_Story-Workshop.md`, story `<discussion-id>`.
22
+ >
23
+ > Use the discussion-layer ID verbatim (`DUS-001`, `DAC-001-01`, ...) — never rewrite it into
24
+ > prose, and never renumber it into the spec-local `US-0001` form. Discussion IDs are
25
+ > `D`-prefixed precisely so they cannot be mistaken for spec IDs, and the `_policies`
26
+ > lower-layer-ID rule does not apply to them (it covers spec-local 4-digit IDs only).
27
+ >
28
+ > **Packs written before the `D` prefix** carry unprefixed IDs (`US-001`, `AC-001-01`).
29
+ > Copy those verbatim too: `discussion-YYYYMMDDhhmmssSSS#US-001`. Do NOT invent a `DUS-`
30
+ > form for them — that ID does not exist in the pack, so the `Source` would resolve to
31
+ > nothing. The pack half already disambiguates it from the spec-local `US-0001`, and the
32
+ > pack is immutable: rewriting its IDs to match this template is not a migration.
@@ -9,14 +9,33 @@
9
9
 
10
10
  ```gherkin
11
11
  # AC-0001
12
+ # Source: discussion-YYYYMMDDhhmmssSSS#DAC-001-01
12
13
  Scenario: <scenario title>
13
14
  Given <precondition>
14
15
  When <action>
15
16
  Then <expected outcome>
16
17
  ```
17
18
 
19
+ > The `# Source:` comment is required on every AC and lives in this block, not in the optional
20
+ > catalog below — a spec that skips the catalog would otherwise have nowhere to record
21
+ > provenance, losing the only machine-checkable trace back to the discussion pack.
22
+ >
23
+ > Write it as `<pack-id>#<discussion-id>`: the pack directory name under `.qfai/discussion/`,
24
+ > then the discussion criterion ID inside it, joined by `#`. Both halves are required —
25
+ > every pack numbers its criteria from `DAC-001-01`, so a bare `DAC-001-01` cannot say which
26
+ > pack it came from, and two packs updating the same spec would collide. Use `-` when the AC
27
+ > has no discussion ancestor. Keep the discussion ID verbatim; do not paraphrase it into prose.
28
+ >
29
+ > Packs written before the `D` prefix carry unprefixed IDs (`AC-001-01`). Copy those verbatim
30
+ > as well — `discussion-YYYYMMDDhhmmssSSS#AC-001-01` — rather than inventing a `DAC-` form
31
+ > the pack does not contain.
32
+
18
33
  ## AC Catalog (optional)
19
34
 
20
35
  | AC-ID | Title | Notes | Priority |
21
36
  | ------- | ------- | ------- | -------- |
22
37
  | AC-0001 | <title> | <notes> | P1 |
38
+
39
+ > This catalog is a human-facing index. It deliberately carries no `Source` column: provenance
40
+ > has exactly one home, the `# Source:` comment in the required Gherkin block above, so the two
41
+ > can never disagree.
@@ -5,8 +5,37 @@
5
5
  - Decompose AC into explicit business rules.
6
6
  - Every BR must reference one or more AC IDs.
7
7
 
8
+ ## Granularity (required)
9
+
10
+ - **One BR expresses one independently falsifiable rule.** If you can delete
11
+ half of the `Rule` cell and what remains is still a complete, testable rule,
12
+ it is two BRs.
13
+ - A BR that needs the words "and also", "additionally", or an enumerated list
14
+ of unrelated conditions to be stated is almost always several BRs.
15
+ - Splitting late is expensive: `05_Examples.md` pins `EX` to `BR` 1:1, so a
16
+ coarse BR propagates downward by construction and is usually discovered only
17
+ after it has been projected into one oversized test module.
18
+ - `QFAI-DENSITY-005` (`warning`) flags a `Rule` cell that is a size outlier
19
+ against the other rules in the same file. It is a signal, not a gate.
20
+ - See `.qfai/assistant/constitution/requirements-decomposition.md#item-granularity-acbrextc`.
21
+
22
+ ## Reference Column Conventions
23
+
24
+ - `AC-Refs`, `NFR-Refs` and `Contract-Refs` are typed reference columns. Each
25
+ holds a comma-separated list of IDs and nothing else — no prose, no
26
+ parentheses, no trailing commentary.
27
+ - `Contract-Refs` holds the contract IDs this rule is bound by. The supported
28
+ kinds are exactly `CON-API-*`, `CON-DB-*` and `CON-UI-*` — for example
29
+ `CON-API-0001`, `CON-DB-0002`, `CON-UI-0003`. Any other kind is silently
30
+ untracked: `specPackIds.ts` and `contractReferences.ts` only recognise these
31
+ three, so an invented kind such as `CON-EVT-*` is neither declarable nor
32
+ traceable. Use `-` when the rule binds no contract. Do not put contract IDs
33
+ in `Notes`.
34
+ - `Notes` is free prose. IDs written there are **not** traced by any tool and
35
+ must not be the only place an obligation is recorded.
36
+
8
37
  ## Rule Table (required)
9
38
 
10
- | BR-ID | Title | AC-Refs | Rule | Notes | NFR-Refs |
11
- | ------- | ------- | ------- | ------ | ------- | -------- |
12
- | BR-0001 | <title> | AC-0001 | <rule> | <notes> | <nfr> |
39
+ | BR-ID | Title | AC-Refs | Rule | Contract-Refs | Notes | NFR-Refs |
40
+ | ------- | ------- | ------- | ------ | ------------- | ------- | -------- |
41
+ | BR-0001 | <title> | AC-0001 | <rule> | CON-API-0001 | <notes> | <nfr> |
@@ -6,6 +6,39 @@
6
6
  - Include both `AC-Refs` and `EX-Ref` whenever possible.
7
7
  - Ensure test cases cover not only normal paths but also error paths, boundary values, and edge cases.
8
8
 
9
+ Derive each row's `Level` with
10
+ `.qfai/assistant/catalog/test-layers.md#layer-derivation-procedure-normative`.
11
+ One oracle per TC; a multi-valued `Level` is illegal.
12
+
13
+ ## Level vocabulary
14
+
15
+ `Level` holds exactly **one** layer code from the crosswalk in
16
+ `.qfai/assistant/catalog/test-layers.md#layer-vocabulary-crosswalk-normative`:
17
+
18
+ - `L1` — Unit
19
+ - `L2` — Component
20
+ - `L3` — Integration
21
+
22
+ (Deliberately a list, not a table: `collectTestCaseIds` and the TDD coverage
23
+ report both read `parseFirstMarkdownTable`, so the **Test Case Table below must
24
+ be the first markdown table in this file**. A table here would be parsed as the
25
+ TC table, find no `TC-ID` column, and silently disable `TDDLIST_TC_NOT_COVERED`
26
+ for the whole spec.)
27
+
28
+ `L1` and `L2` are TDD coverage targets — each needs a `tdd/test-list.md` row.
29
+ `L3` is not. An obligation that spans two layers is two TC rows.
30
+
31
+ **`L4` and `L5` are not `TC-*` values.** An oracle that lands at the service
32
+ boundary (L4) or on a full-system journey (L5) is a misfiled obligation —
33
+ record it as `CON-API-*` or `US-*`, not as a `TC-*` row. If one is declared
34
+ anyway, the ATDD gate routes it to `<testsDir>/api/**` or `<testsDir>/e2e/**`
35
+ by its declared `Level`; that routing is a safety net, not a licence to file
36
+ L4/L5 as `TC-*`.
37
+
38
+ `<testsDir>` is `paths.testsDir` from `qfai.config.yaml` (default `tests`); the
39
+ traceability scan follows the configured value, so write the paths relative to
40
+ it rather than hard-coding a literal `tests/` prefix.
41
+
9
42
  ## Test Case Table (required)
10
43
 
11
44
  | TC-ID | Level | AC-Refs | EX-Ref | Type | Steps | Expected | Notes |
@@ -14,6 +47,29 @@
14
47
  | TC-0002 | L2 | AC-0001 | — | error | <steps> | <expected> | <notes> |
15
48
  | TC-0003 | L2 | AC-0001 | — | boundary | <steps> | <expected> | <notes> |
16
49
 
50
+ ### Level column values
51
+
52
+ The layer this test case verifies; exactly one code per cell. All five codes are
53
+ defined in `.qfai/assistant/catalog/test-layers.md`, which is the single source;
54
+ the summaries below are a reading aid, not a second definition.
55
+
56
+ - `L1` — Unit. The oracle observes inputs and return values only.
57
+ - `L2` — Component. The oracle observes collaboration with a port through a
58
+ fixture adapter, with no real infrastructure.
59
+ - `L3` — Integration. The oracle observes real infrastructure state
60
+ (DB / queue / filesystem). Tests live in `<testsDir>/integration/**`.
61
+ - `L4` — API. The oracle observes service-boundary values (status, body, auth,
62
+ error contracts). Tests live in `<testsDir>/api/**`.
63
+ - `L5` — E2E. The oracle observes a full-system journey. Tests live in
64
+ `<testsDir>/e2e/**`.
65
+
66
+ Which codes require a `tdd/test-list.md` row is decided by
67
+ `isCoverageTargetLevel`. It recognises both spellings of every layer — the code
68
+ form (`L1`-`L5`) and the word form (`unit`, `integration`, `e2e`, …) — so `L1`
69
+ and `L2` are coverage targets that need a ledger row and `L3`-`L5` are not. A
70
+ value it recognises in neither spelling is conservatively treated as a target,
71
+ and `TDDLIST_UNKNOWN_LEVEL` reports it rather than letting it pass silently.
72
+
17
73
  ### Type column values
18
74
 
19
75
  - `normal` — Happy path / expected successful behavior.
@@ -1,9 +1,36 @@
1
1
  # 07 Decisions
2
2
 
3
+ Decision Records for this spec. A `DR-*` cited from the `DR-ID` column of
4
+ `tdd/test-list.md` — which every `exception` row is required to carry — resolves
5
+ against this file, so an entry here is what makes that citation checkable.
6
+
7
+ ## ID scheme
8
+
9
+ - **Spec-scoped**: `DR-NNNN-MMMM`. Use this form for a decision that binds only
10
+ this spec. Setting `NNNN` to the spec's own number is the recommended
11
+ convention and keeps the id self-locating, but validation checks the shape,
12
+ not the match — do not read a passing run as confirmation of the pairing.
13
+ - **Policy-level**: `DR-NNNN`, declared in `_policies/08_Decisions.md` instead.
14
+ Cite it from here rather than re-declaring it; an ID declared twice has two
15
+ owners.
16
+
17
+ `npx qfai validate` accepts both shapes. A `DR-ID` cell matching neither raises
18
+ `TDDLIST_EXCEPTION_INVALID_DR`; one that resolves to no entry in either file
19
+ raises `TDDLIST_EXCEPTION_UNRESOLVED_DR`.
20
+
3
21
  ## Decisions
4
22
 
5
- - 0 decisions in this spec.
23
+ <!-- One `### DR-NNNN-MMMM` block per decision. Copy the sample below. -->
24
+
25
+ ### DR-NNNN-MMMM: one-line title
26
+
27
+ - Status: proposed | accepted | superseded | rejected
28
+ - Context: what forced the decision — the constraint, conflict or anomaly
29
+ - Decision: what was decided, in the imperative
30
+ - Consequences: what this costs and what it forecloses
31
+ - Related: the `AC-*` / `BR-*` / `TC-*` / `TDD-*` / `CR-*` this decision binds, or `-`
6
32
 
7
33
  ## Empty State
8
34
 
9
- - Add ADR entries when a local spec decision is finalized.
35
+ - 0 decisions in this spec. Delete the sample block above once the first real
36
+ decision is recorded.
@@ -0,0 +1,41 @@
1
+ # 10 Plan
2
+
3
+ **How-only.** This file states approach. It is validated as such:
4
+ `QFAI-PLAN-002` rejects status/progress headings, `QFAI-PLAN-003` rejects
5
+ update-history headings, and `QFAI-PLAN-004` rejects RC / Go-NoGo headings —
6
+ all at severity `error`. The four sections below are the allowed shape; keep
7
+ them and the gates are satisfied by construction.
8
+
9
+ Progress belongs in `tdd/test-list.md`, history in `09_delta.md`, and release
10
+ judgement nowhere in the spec pack.
11
+
12
+ ## Implementation approach
13
+
14
+ - `<the shape of the change: which modules, which seams, in what order>`
15
+ - `<the alternative considered and why this one>`
16
+
17
+ ## Test approach
18
+
19
+ - `<what is proven at which layer — see catalog/test-layers.md>`
20
+ - `<the boundary cases that must have their own case, not a shared one>`
21
+
22
+ ## NFR approach
23
+
24
+ - `<how the floors in _policies/07_Constraints.md are met by this spec>`
25
+ - `<the measurement that would show a breach>`
26
+
27
+ ## Risk mitigation
28
+
29
+ | Risk | Likelihood / impact | Mitigation | Trigger to act |
30
+ | ----------------------- | ------------------- | ------------------- | --------------------- |
31
+ | `<what could go wrong>` | `<low/med/high>` | `<what reduces it>` | `<the observed sign>` |
32
+
33
+ ## Authoring rules
34
+
35
+ - Do not add a "Status", "Progress", "TODO", "Remaining", "Done" or "WIP"
36
+ heading. The ledger owns that, and duplicating it creates a second answer that
37
+ drifts.
38
+ - Do not add a changelog or revision-history heading — `09_delta.md` is that
39
+ record.
40
+ - A risk with no `Trigger to act` is a worry, not a mitigation: name the
41
+ observation that says the mitigation is now needed.
@@ -0,0 +1,58 @@
1
+ # 16 Traceability Ledger
2
+
3
+ ## Purpose
4
+
5
+ Link each `BR-*` / `AC-*` in this spec to the implementation file that realizes it and the test file
6
+ that proves it. `npx qfai validate` reads this file to enforce **implementation integrity**: when a
7
+ spec's `03_Acceptance-Criteria.md` or `04_Business-Rules.md` changes on a branch, every
8
+ implementation file linked from a changed spec must also have changed in that branch, otherwise
9
+ `QFAI-TRACE-001` (severity `error`) fires.
10
+
11
+ This file is **optional**. A spec without it is not invalid — validation emits `QFAI-TRACE-002` at
12
+ severity `warning` and skips the integrity check, so `--fail-on error` still passes. Add it to any
13
+ spec whose BR/AC you want held to implementation drift.
14
+
15
+ ## Ledger Table (required when this file exists)
16
+
17
+ The **first** Markdown table in this file is the one the validator reads, and the only one: any
18
+ further table in this document is prose, never a ledger row, even if its first cell looks like a
19
+ `BR`/`AC` ID. Its header must have at least three columns and one of them must be named
20
+ `Implementation File`. Each data row's first cell must be a `BR-NNNN` or `AC-NNNN` ID, and the
21
+ second cell must be a repository-root-relative path to the implementation file.
22
+
23
+ | BR/AC | Implementation File | Test File | Notes |
24
+ | ------- | ------------------------- | ------------------------------------- | ------- |
25
+ | AC-0001 | src/<module>/<file>.<ext> | tests/integration/<spec>/<file>.<ext> | <notes> |
26
+ | BR-0001 | src/<module>/<file>.<ext> | tests/unit/<spec>/<file>.<ext> | <notes> |
27
+
28
+ ### Column rules
29
+
30
+ - `BR/AC` — a single `BR-NNNN` or `AC-NNNN` ID defined in this spec. Rows whose first cell does not
31
+ match that shape are ignored by the validator; use them for grouping headings if you like.
32
+ - `Implementation File` — one repository-root-relative path, no globs, no `./` prefix. This is the
33
+ path compared against `git diff --name-only <baseBranch>..HEAD`.
34
+ - `Test File` — the test that proves the row. Not machine-checked here; TC-level coverage is
35
+ enforced separately from `06_Test-Cases.md` and `tdd/test-list.md`.
36
+ - Extra trailing columns are allowed and ignored.
37
+
38
+ ### One obligation per row
39
+
40
+ Write one row per `BR`/`AC` ↔ implementation-file pair. If one `AC-*` is realized by three files,
41
+ write three rows with the same `AC` ID. A row naming several files in one cell will not match.
42
+
43
+ ## Authoring and maintenance
44
+
45
+ - Authored and refreshed by `/qfai-sdd` alongside `03_Acceptance-Criteria.md` and
46
+ `04_Business-Rules.md`. It is upstream SSOT — downstream skills must not edit it directly (see
47
+ `.qfai/assistant/constitution/drift-protocol.md`).
48
+ - Whenever a `BR`/`AC` is added, removed, or renumbered, update this ledger in the same change.
49
+ - If a linked implementation file is renamed or moved, update the path here in the same commit, or
50
+ `QFAI-TRACE-001` will report the old path as unmodified.
51
+
52
+ ## Not the same as the spec-pack ledger
53
+
54
+ Legacy 18-file **spec-pack** layouts also carry a `16_Traceability-ledger.md`, but with a different
55
+ schema (`trace_id, obj_id, init_id, cap_id, flow_id, us_id, ac_id, ex_ids, tc_ids`) checked by
56
+ `QFAI-LEDGER-001` / `E_LEDGER_MISSING_COLUMN`. That check runs **only** on `spec-pack` layouts; this
57
+ template is for the layered layout and is read only by the implementation-integrity check. Do not
58
+ merge the two schemas into one table.
@@ -0,0 +1,56 @@
1
+ # TDD Execution Ledger
2
+
3
+ Execution ledger for the TDD micro-cycle of this spec. `/qfai-implement` reads
4
+ this file, selects the first row with `Status = todo`, and drives the
5
+ Red/Green/Refactor cycle one row at a time.
6
+
7
+ ## Producer
8
+
9
+ Rows are derived from `06_Test-Cases.md`: **one row per coverage-target TC**.
10
+ `/qfai-sdd` seeds them at Phase 2b. An empty table below is valid — it means
11
+ the spec has no coverage-target TC yet, not that the ledger is missing.
12
+
13
+ `US-*` and `CON-API-*` are **not** rows here. They are ATDD obligations,
14
+ traced by `QFAI:` annotations in the test tree per
15
+ `.qfai/assistant/catalog/test-layers.md`, and `/qfai-atdd` does not write to
16
+ this ledger.
17
+
18
+ Reseeding is a **delta**, never a regeneration: an unchanged TC's row keeps its
19
+ `TDD-ID`, `Status`, `Test file`, `Selector`, `DR-ID` and `Evidence`, and TCs
20
+ with no row yet are appended at `Status = todo`. Rewriting a row that has
21
+ already progressed would destroy the RED/GREEN evidence that proves its cycle.
22
+
23
+ The delta runs in both directions. A TC whose obligation changed has its row
24
+ returned to `todo` under the upstream-reset rule (driving `CR-*` / `DR-*` in
25
+ `DR-ID`, prior `Evidence` kept); a TC deleted upstream, or no longer a
26
+ coverage target, has its row retired the same way. Leaving a stale `done` row
27
+ hides re-implementation work, and leaving a `todo` row for a deleted TC feeds
28
+ `/qfai-implement` an obligation that no longer exists.
29
+
30
+ ## Ledger
31
+
32
+ The **first** markdown table in this file is the ledger — `validateTddList`
33
+ reads it with `parseFirstMarkdownTable`. Keep it first; a table above it is
34
+ parsed as the ledger instead and raises eight
35
+ `TDDLIST_REQUIRED_COLUMN_MISSING` errors.
36
+
37
+ | TDD-ID | TC-Refs | Layer | Test file | Selector | Status | DR-ID | Evidence |
38
+ | ------ | ------- | ----- | --------- | -------- | ------ | ----- | -------- |
39
+
40
+ ## Schema
41
+
42
+ Required columns, in the order used above:
43
+
44
+ | Column | Description |
45
+ | --------- | ------------------------------------------------------------ |
46
+ | TDD-ID | `TDD-NNNN`, unique within this spec |
47
+ | TC-Refs | Test cases from `06_Test-Cases.md` this row implements |
48
+ | Layer | `Unit`, `Component`, `Integration`, `API` or `E2E` |
49
+ | Test file | Project-root-relative path to the test module |
50
+ | Selector | Test selector/description for targeted execution |
51
+ | Status | `todo` / `red` / `green` / `refactor` / `done` / `exception` |
52
+ | DR-ID | Decision Record ID for exception rows (`-` otherwise) |
53
+ | Evidence | RED/GREEN command+result pairs proving the TDD cycle |
54
+
55
+ See `.qfai/assistant/skills/qfai-sdd/references/spec-traceability-rules.md`
56
+ for the full rules.