qfai 1.9.2 → 1.10.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 (123) hide show
  1. package/README.md +48 -2
  2. package/assets/init/.qfai/assistant/agents/acceptance-test-engineer.md +1 -0
  3. package/assets/init/.qfai/assistant/agents/backend-engineer.md +1 -0
  4. package/assets/init/.qfai/assistant/agents/completion-reviewer.md +13 -2
  5. package/assets/init/.qfai/assistant/agents/delivery-planner.md +9 -0
  6. package/assets/init/.qfai/assistant/agents/frontend-engineer.md +1 -0
  7. package/assets/init/.qfai/assistant/agents/implementation-reviewer.md +6 -0
  8. package/assets/init/.qfai/assistant/agents/orchestrator.md +2 -2
  9. package/assets/init/.qfai/assistant/agents/qa-gatekeeper.md +96 -3
  10. package/assets/init/.qfai/assistant/agents/test-design-analyst.md +20 -3
  11. package/assets/init/.qfai/assistant/catalog/cli-ux-guidelines.md +2 -2
  12. package/assets/init/.qfai/assistant/catalog/spec_required_files.json +2 -1
  13. package/assets/init/.qfai/assistant/catalog/test-layers.md +355 -14
  14. package/assets/init/.qfai/assistant/catalog/worklog-entry.schema.md +165 -0
  15. package/assets/init/.qfai/assistant/constitution/communication.md +1 -1
  16. package/assets/init/.qfai/assistant/constitution/drift-protocol.md +304 -10
  17. package/assets/init/.qfai/assistant/constitution/quality.md +35 -5
  18. package/assets/init/.qfai/assistant/constitution/requirements-decomposition.md +37 -0
  19. package/assets/init/.qfai/assistant/constitution/shared-skill-delegation-baseline.md +244 -8
  20. package/assets/init/.qfai/assistant/constitution/shared-skill-operating-baseline.md +122 -5
  21. package/assets/init/.qfai/assistant/constitution/workflow.md +53 -7
  22. package/assets/init/.qfai/assistant/manifest/agent-catalog.yml +316 -945
  23. package/assets/init/.qfai/assistant/manifest/agent-routing.yml +50 -4
  24. package/assets/init/.qfai/assistant/manifest/review-profiles.yml +9 -0
  25. package/assets/init/.qfai/assistant/process/migrations/v1.4.27-atdd-alignment.md +1 -1
  26. package/assets/init/.qfai/assistant/skills/qfai-atdd/SKILL.md +61 -21
  27. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/test-case-depth-checklist.md +23 -4
  28. package/assets/init/.qfai/assistant/skills/qfai-configure/SKILL.md +15 -7
  29. package/assets/init/.qfai/assistant/skills/qfai-discussion/SKILL.md +8 -4
  30. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/design-md-brand-catalog.md +2 -2
  31. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/discussion-completion-matrix.md +17 -7
  32. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/rcp_footer.md +10 -4
  33. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/review-cycle-playbook.md +1 -1
  34. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui-bearing-playbook.md +4 -4
  35. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/review_audit_playbook.md +1 -1
  36. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/trend_scan_playbook.md +1 -1
  37. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux_best_practices.md +17 -7
  38. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/01_Context.md +1 -1
  39. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/02_Inception-Deck.md +1 -1
  40. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/03_Story-Workshop.md +11 -3
  41. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/05_Scope.md +5 -2
  42. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/07_NFR.md +1 -1
  43. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/09_Constraints.md +7 -4
  44. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/10_Policy.md +1 -1
  45. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/11_OQ-Register.md +1 -1
  46. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/12_OQ-Resolution-Log.md +1 -1
  47. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/14_Review-Request.md +14 -7
  48. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/99_delta.md +1 -1
  49. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/Rxx_reviewer.md +16 -7
  50. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/review_request.md +9 -6
  51. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/40_screen_contracts.md +3 -2
  52. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/50_review_input_bundle.md +4 -2
  53. package/assets/init/.qfai/assistant/skills/qfai-implement/SKILL.md +250 -128
  54. package/assets/init/.qfai/assistant/skills/qfai-implement/references/change-request-reset.md +93 -0
  55. package/assets/init/.qfai/assistant/skills/qfai-implement/references/checkpoint-verification.md +106 -0
  56. package/assets/init/.qfai/assistant/skills/qfai-implement/references/cross-spec-ownership.md +73 -0
  57. package/assets/init/.qfai/assistant/skills/qfai-implement/references/evidence-revision.md +77 -0
  58. package/assets/init/.qfai/assistant/skills/qfai-implement/references/execution-ledger.md +303 -0
  59. package/assets/init/.qfai/assistant/skills/qfai-implement/references/final-checklist.md +19 -0
  60. package/assets/init/.qfai/assistant/skills/qfai-implement/references/finding-classification.md +49 -0
  61. package/assets/init/.qfai/assistant/skills/qfai-implement/references/ledger-preconditions.md +55 -0
  62. package/assets/init/.qfai/assistant/skills/qfai-implement/references/oracle-strength.md +81 -0
  63. package/assets/init/.qfai/assistant/skills/qfai-implement/references/parallelization-policy.md +235 -0
  64. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-admissibility.md +91 -0
  65. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-not-observable.md +70 -0
  66. package/assets/init/.qfai/assistant/skills/qfai-implement/references/relevant-test-suite.md +87 -0
  67. package/assets/init/.qfai/assistant/skills/qfai-implement/references/review-artifact-layout.md +31 -0
  68. package/assets/init/.qfai/assistant/skills/qfai-implement/references/round-evidence.md +102 -0
  69. package/assets/init/.qfai/assistant/skills/qfai-implement/references/selector-granularity.md +24 -0
  70. package/assets/init/.qfai/assistant/skills/qfai-implement/references/volume-policy.md +149 -0
  71. package/assets/init/.qfai/assistant/skills/qfai-prototyping/SKILL.md +35 -18
  72. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/evidence-requirements.md +1 -1
  73. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/generator-prompt.md +106 -7
  74. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/handoff.md +40 -11
  75. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/iteration-loop.md +48 -1
  76. package/assets/init/.qfai/assistant/skills/qfai-prototyping/templates/DESIGN.md.sample +6 -0
  77. package/assets/init/.qfai/assistant/skills/qfai-sdd/SKILL.md +82 -22
  78. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/contract-artifact-rules.md +148 -0
  79. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/rcp_footer.md +10 -4
  80. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/review-cycle-playbook.md +1 -1
  81. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-execution-playbook.md +4 -2
  82. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-phase-checklists.md +18 -0
  83. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-quality-gate.md +44 -3
  84. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-triage.md +60 -7
  85. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/spec-traceability-rules.md +157 -5
  86. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/change-request.md +125 -0
  87. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/contracts/db-contract.sample.sql +6 -0
  88. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/evidence/sdd-spec.md +92 -0
  89. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/01_Objective.md +27 -0
  90. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/02_Initiative.md +30 -0
  91. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/05_Contracts.md +16 -6
  92. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/06_Glossary.md +19 -0
  93. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/07_Constraints.md +25 -0
  94. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/08_Decisions.md +22 -2
  95. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/11_Slice-Policy.md +37 -10
  96. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/02_User-stories.md +20 -0
  97. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/03_Acceptance-Criteria.md +19 -0
  98. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/04_Business-Rules.md +32 -3
  99. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/06_Test-Cases.md +56 -0
  100. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/07_Decisions.md +29 -2
  101. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/10_Plan.md +41 -0
  102. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/16_Traceability-ledger.md +58 -0
  103. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/tdd/test-list.md +56 -0
  104. package/assets/init/.qfai/assistant/skills/qfai-verify/SKILL.md +57 -102
  105. package/assets/init/.qfai/assistant/skills/qfai-verify/references/articles.md +24 -0
  106. package/assets/init/.qfai/assistant/skills/qfai-verify/references/context-load.md +22 -0
  107. package/assets/init/.qfai/assistant/skills/qfai-verify/references/verify-output-contract.md +48 -0
  108. package/assets/init/.qfai/assistant/skills/qfai-verify/templates/verify-evidence.md +48 -0
  109. package/assets/init/.qfai/assistant/skills/web-research/SKILL.md +25 -7
  110. package/assets/init/.qfai/waivers.yml +11 -5
  111. package/assets/init/root/DESIGN.md +6 -0
  112. package/assets/init/root/qfai.config.yaml +15 -12
  113. package/dist/cli/index.cjs +11023 -7139
  114. package/dist/cli/index.cjs.map +1 -1
  115. package/dist/cli/index.mjs +10963 -7080
  116. package/dist/cli/index.mjs.map +1 -1
  117. package/dist/index.cjs +8782 -5257
  118. package/dist/index.cjs.map +1 -1
  119. package/dist/index.d.cts +280 -8
  120. package/dist/index.d.ts +280 -8
  121. package/dist/index.mjs +11776 -8264
  122. package/dist/index.mjs.map +1 -1
  123. package/package.json +18 -19
@@ -0,0 +1,125 @@
1
+ # Change Request
2
+
3
+ <!--
4
+ Canonical path: `.qfai/decisions/CR-YYYYMMDD-NNNN-<slug>.md`
5
+ ID pattern: `CR-\d{8}-\d{4}`
6
+ A Change Request is the mandatory precondition for any upstream SSOT edit
7
+ (`constitution/drift-protocol.md`). `qfai-implement` blocks spec completion
8
+ while an unresolved CR exists, so `Status` must be a real, checkable field.
9
+ -->
10
+
11
+ - ID: `CR-YYYYMMDD-NNNN`
12
+ - Title: `<one-line summary>`
13
+ - Raised by: `<skill or agent>`
14
+ - Raised at: `YYYY-MM-DDThh:mm:ssZ`
15
+ - Class: `intent` <!-- intent | defect; see constitution/drift-protocol.md#drift-classes -->
16
+ - Status: `open` <!-- open | approved | rejected | superseded -->
17
+ - Approved by: `-` <!-- required whenever Status leaves `open` (approved / rejected / superseded) -->
18
+ - Approved at: `-` <!-- YYYY-MM-DDThh:mm:ssZ -->
19
+ - Approved option: `-` <!-- the option number below that was chosen; stays `-` when Class is defect -->
20
+ - Applied at: `-` <!-- YYYY-MM-DDThh:mm:ssZ; set only after the owner-skill rerun below completed and upstream artifacts are updated -->
21
+ - Superseded by: `-` <!-- CR-ID, required when Status is superseded -->
22
+
23
+ <!--
24
+ `Status: approved` records the operator's decision; `Applied at` records that
25
+ the approved actions were carried out. `qfai-implement` treats an approved CR
26
+ as unresolved until `Applied at` and `Resolution` are both filled, because
27
+ `constitution/drift-protocol.md` resumes downstream work only after the
28
+ upstream artifacts have been updated.
29
+ -->
30
+
31
+ ## Context
32
+
33
+ <!--
34
+ Class `intent`: the upstream SSOT statement and the downstream fact that
35
+ contradicts it. Cite both by path and ID.
36
+ Class `defect`: what the artifact declares, and how it breaks that declaration
37
+ on its own terms. A defect conflicts with nothing external — say what it
38
+ contradicts in itself.
39
+ -->
40
+
41
+ ## Reproduction
42
+
43
+ <!--
44
+ REQUIRED when Class is `defect`; delete this section when Class is `intent`.
45
+ The command and its verbatim output, or the two artifact excerpts that
46
+ contradict each other, with paths and line numbers. A defect claim without a
47
+ reproduction is an intent-drift CR that skipped its options
48
+ (`constitution/drift-protocol.md#drift-classes`).
49
+ -->
50
+
51
+ ## Proposed change
52
+
53
+ <!--
54
+ What must change in the upstream artifact. When Class is `defect` this is the
55
+ single correct fix, and it is what the operator approves.
56
+ -->
57
+
58
+ ## Options (at least 3) and recommendation
59
+
60
+ <!--
61
+ Class `intent` only — delete this section when Class is `defect`. A change with
62
+ exactly one correct answer has no option set; manufacturing a second and third
63
+ so the table is full asks the operator to ratify a comparison its author knew
64
+ was fabricated.
65
+ -->
66
+
67
+ | # | Option | Cost | Risk | Recommended |
68
+ | --- | ---------- | -------- | -------- | ----------- |
69
+ | 1 | `<option>` | `<cost>` | `<risk>` | |
70
+ | 2 | `<option>` | `<cost>` | `<risk>` | ✅ |
71
+ | 3 | `<option>` | `<cost>` | `<risk>` | |
72
+
73
+ ## Blocked downstream items
74
+
75
+ <!--
76
+ The set STOP covers for THIS Change Request
77
+ (`constitution/drift-protocol.md#when-drift-is-detected`, step 1). Enumerate it
78
+ — an item not listed here is not blocked by this CR and continues. The halt is
79
+ not repository-wide, and this section is what makes that checkable.
80
+
81
+ Also state what this CR does NOT block when it would otherwise be assumed, and
82
+ name any other open CR whose blocked set overlaps: the effective halt is the
83
+ union of the open CRs' blocked sets.
84
+ -->
85
+
86
+ | Item | Kind | Why it depends on the artifact |
87
+ | -------------------------- | ---------------------------------- | ------------------------------ |
88
+ | `<spec-NNNN / TDD-NNNN />` | `spec` / `ledger-row` / `contract` | `<TC-Refs names …>` |
89
+
90
+ - Not blocked by this CR: `<items a reader would expect to be blocked, and why they are not>`
91
+ - Overlapping open CRs: `<CR-ID, …>` or `none`
92
+
93
+ ## Impact scope
94
+
95
+ - Specs: `<spec-NNNN, ...>`
96
+ - Plans: `<paths>`
97
+ - Tests: `<paths / TDD-IDs>`
98
+ - Contracts: `<CON-*>`
99
+ - Schema: `<paths>`
100
+
101
+ ## Decision needed from user
102
+
103
+ <!-- The exact question to put to the user. -->
104
+
105
+ ## Approved actions (owner skill rerun plan)
106
+
107
+ 1. `<owner skill>` rerun scope: `<what>`
108
+ 2. Downstream ledger sweep: reset these `tdd/test-list.md` rows, recording this
109
+ CR's ID in their `DR-ID` column. **Enumerate them here, before approval** —
110
+ list the `TDD-ID`s (or a verifiable selection rule such as "every row whose
111
+ `TC-Refs` names TC-0007"), because what the operator approves is this list.
112
+ A reset of any row not covered by it is not operator-approved, and
113
+ `Resolution` must match this list.
114
+ - `<TDD-NNNN>`, `<TDD-NNNN>`, …
115
+ This is the only sanctioned backward status transition — see
116
+ `.qfai/assistant/skills/qfai-implement/SKILL.md`, "Approved Change Request
117
+ reset".
118
+
119
+ ## Resolution
120
+
121
+ <!--
122
+ Filled in when Status leaves `open`. Record what was actually done: the owner
123
+ skill that was rerun and the upstream artifacts it updated, and the ledger rows
124
+ reset (by TDD-ID). Set `Applied at` in the header once this section is true.
125
+ -->
@@ -1,5 +1,11 @@
1
1
  -- QFAI-CONTRACT-ID: CON-DB-0001
2
2
  -- Purpose: Sample order draft persistence contract
3
+ -- Depends on: -
4
+ -- Apply-order dependencies as a comma-separated list of CON-DB-* ids, or `-`
5
+ -- when there are none. List only what must be applied BEFORE this file.
6
+ -- A reference resolved at run time (a deferred FK, a view a later query
7
+ -- reads) is NOT an apply-order dependency: the apply graph is acyclic by
8
+ -- construction, the runtime graph need not be.
3
9
 
4
10
  CREATE TABLE order_drafts (
5
11
  id TEXT PRIMARY KEY,
@@ -0,0 +1,92 @@
1
+ # Evidence: /qfai-sdd (<spec-id>)
2
+
3
+ > Canonical layout for `.qfai/evidence/sdd-<spec-id>.md`, a Mandatory Output of
4
+ > `/qfai-sdd`. Keep every `##` heading below, in this order, even when a section
5
+ > is empty — write `- none` rather than deleting the heading. The completion
6
+ > reviewer grades this file's shape against this template.
7
+
8
+ ## Objective
9
+
10
+ - Spec target: <spec-id>
11
+ - Objective: <what this SDD cycle set out to change for this spec>
12
+
13
+ ## Inputs reviewed
14
+
15
+ - <path or pack id>
16
+ - <path or pack id>
17
+
18
+ ## Preflight summary path
19
+
20
+ - `.qfai/report/preflight_summary.md`
21
+
22
+ ## Triage decisions
23
+
24
+ > One row per incoming REQ/NFR handled for this spec, mirroring the Triage table
25
+ > persisted in `09_delta.md` (per-spec) or `_policies/10_delta.md` (cross-spec).
26
+ > Operation: `CREATE` | `UPDATE` | `DELETE` | `SPLIT` | `MERGE` | `SUPERSEDE`.
27
+ > Sub-op (UPDATE only): `APPEND` | `MODIFY` | `REMOVE`.
28
+ > Approved By is required for CREATE / DELETE / SPLIT / MERGE / SUPERSEDE /
29
+ > UPDATE:REMOVE; use `-` when approval is not required.
30
+
31
+ | Source | Subject | Operation | Sub-op | Approved By | Rationale |
32
+ | -------- | ----------- | --------- | ------ | ----------- | --------- |
33
+ | REQ-XXXX | <one-liner> | UPDATE | APPEND | - | <why> |
34
+
35
+ ## Open questions
36
+
37
+ - OQ-XXXX: <question> — Disposition: open | resolved | deferred
38
+ - <or> none
39
+
40
+ ## Decisions made
41
+
42
+ - DEC-XXXX / DELTA-XXXX: <decision> — <rationale>
43
+ - <or> none
44
+
45
+ ## Work performed
46
+
47
+ - <artifact created or updated, with path>
48
+ - <artifact created or updated, with path>
49
+
50
+ ## Commands executed
51
+
52
+ ```
53
+ npx qfai validate --profile sdd --fail-on error --format github
54
+ ```
55
+
56
+ > No redirect. `npx qfai validate` writes `<paths.outDir>/validate.log` itself on
57
+ > every run, always pointing at that run's `run-*/` directory, so a `| tee` is
58
+ > both unnecessary and not portable to PowerShell. Same command as `SKILL.md`
59
+ > step 8 and `references/sdd-quality-gate.md`.
60
+
61
+ ## Validate evidence paths
62
+
63
+ - `.qfai/report/validate.log`
64
+ - `.qfai/report/run-<timestamp>/` (run id: <run-id>, status: pass | fail)
65
+ - `.qfai/report/specs-coverage/<spec-id>.md`
66
+
67
+ ## Work Orders Summary
68
+
69
+ > Fixed 6-column schema from
70
+ > `.qfai/assistant/constitution/shared-skill-delegation-baseline.md#work-orders-summary`.
71
+ > Do not add, remove or rename columns.
72
+ > `Status` accepts exactly `PASS` or `REVISE` — no other value (no `PENDING`,
73
+ > no `N/A`, no `FAIL`). A work order that has not been reviewed yet is `REVISE`.
74
+
75
+ | Step | Role (sub-agent) | Task title | Input (refs) | Output (refs) | Status (PASS/REVISE) |
76
+ | ---- | ---------------- | ---------- | ------------ | ------------- | -------------------- |
77
+ | 1 | <role> | <task> | <refs> | <refs> | PASS |
78
+
79
+ ## Gaps / Open risks
80
+
81
+ - <residual risk, or the OQ that carries it>
82
+ - <or> none
83
+
84
+ ## Final status
85
+
86
+ - Final status: PASS | REVISE
87
+ - Rationale: <one line>
88
+
89
+ > `Final status` accepts exactly `PASS` or `REVISE`, matching the reviewer
90
+ > vocabulary in `shared-skill-delegation-baseline.md#verdict-vocabulary`. A
91
+ > `REVISE` here maps to `status: "FAIL"` when a review pack's `summary.json` is
92
+ > written; they are the same outcome. Do not invent a third verdict.
@@ -0,0 +1,27 @@
1
+ # 01 Objective
2
+
3
+ The product-level "why" the whole spec pack serves. One objective per project;
4
+ every `CAP-*` in `03_Capabilities.md` traces up to it.
5
+
6
+ ## Objective
7
+
8
+ - <one sentence: the outcome this product exists to produce>
9
+
10
+ ## Success criteria
11
+
12
+ | ID | Criterion | How it is measured |
13
+ | ------ | ---------------------- | ------------------------- |
14
+ | OBJ-01 | `<observable outcome>` | `<metric or observation>` |
15
+
16
+ ## Out of scope
17
+
18
+ - `<what this objective explicitly does not cover>`
19
+
20
+ ## Authoring rules
21
+
22
+ - Outcome only. No solution, no architecture, no delivery sequencing — those
23
+ live in `02_Initiative.md` and `10_Plan.md` respectively.
24
+ - Do not name `US` / `AC` / `BR` / `EX` / `TC` IDs here: `_policies/**` must not
25
+ define or own lower-layer items (`references/spec-traceability-rules.md`).
26
+ - An empty success-criteria table is a finding, not a default. An objective no
27
+ one can measure cannot adjudicate a capability.
@@ -0,0 +1,30 @@
1
+ # 02 Initiative
2
+
3
+ The initiative is the bounded effort undertaken to reach `01_Objective.md`. It
4
+ answers "what are we doing about it", one layer above capabilities.
5
+
6
+ ## Initiative
7
+
8
+ - <one sentence: the bounded effort, not the product>
9
+
10
+ ## Scope
11
+
12
+ | In scope | Out of scope | Why |
13
+ | -------- | -------------------------- | ------------------------- |
14
+ | `<area>` | `<adjacent area excluded>` | `<reason for the border>` |
15
+
16
+ ## Assumptions
17
+
18
+ - `<assumption this initiative rests on, and what falsifies it>`
19
+
20
+ ## Dependencies
21
+
22
+ - `<external system, team, or decision this initiative waits on>`
23
+
24
+ ## Authoring rules
25
+
26
+ - The scope table's `Out of scope` column is load-bearing: a border with no
27
+ stated reason is a border no one can defend when it is challenged.
28
+ - Record a stated assumption here rather than an open question when the work
29
+ proceeds on it. Genuine questions belong in `09_Open-questions.md`.
30
+ - No lower-layer IDs (`references/spec-traceability-rules.md`).
@@ -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.