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
@@ -0,0 +1,93 @@
1
+ # Approved Change Request reset (the only sanctioned backward transition)
2
+
3
+ `tdd/test-list.md` has a forward-only lifecycle
4
+ (`todo -> red -> green -> refactor -> done`) and skips `done` rows on
5
+ re-execution. An approved upstream change can invalidate rows that already
6
+ reached `green`, `refactor` or `done`, and the Change Request template
7
+ (`.qfai/assistant/skills/qfai-sdd/templates/change-request.md`) instructs the
8
+ approved actions to "reset the `tdd/test-list.md` rows this change
9
+ invalidates". Without a stated exception that instruction is unperformable:
10
+ the skill would either violate the forward-only rule or leave a `done` row
11
+ holding an implementation result the approved change already invalidated.
12
+
13
+ ## The mandatory preflight
14
+
15
+ The reset cannot be reached from the normal loop: `Required Process` starts by
16
+ selecting the first `todo` row, and the skill exits with "nothing to do" when
17
+ every row is `done` — exactly the state an approved reset is meant to reopen.
18
+ So the sweep is a **preflight**, not an opportunistic step:
19
+
20
+ 1. On every run, before the ledger is read for any other purpose, enumerate
21
+ `.qfai/decisions/CR-*.md` and keep those in scope for the target spec.
22
+ 2. Apply every reset the approved ones authorise (conditions below).
23
+ 3. Only then judge the ledger. A run whose preflight reset rows must not report
24
+ "nothing to do", because the all-`done` state it would report is stale.
25
+
26
+ A run with no in-scope approved CR does nothing here and proceeds unchanged.
27
+
28
+ ## The exception
29
+
30
+ A `.qfai/decisions/CR-*.md` whose "Approved actions" name a downstream ledger
31
+ sweep may reset the rows that change invalidates back to `todo`. Those rows are
32
+ then re-executed rather than skipped.
33
+
34
+ This is an operator-approved act, not a skill decision. It is legal only when
35
+ all of the following hold:
36
+
37
+ - the CR's `Status` is `approved`, with `Approved by` and `Approved at`
38
+ populated;
39
+ - the CR's "Approved actions" section **enumerates the rows** — the `TDD-ID`s,
40
+ or a verifiable selection rule — so the reset scope is what the operator
41
+ approved and not what the skill later decided was invalidated. A row outside
42
+ that enumeration is not approved; widening the scope needs a new CR;
43
+ - each reset row records that CR's ID in its `DR-ID` column — that column
44
+ carries both `DR-*` and `CR-*` references as a comma-separated list, and the
45
+ ID is **retained** as the row re-runs through `red` / `green` / `refactor` /
46
+ `done`, since clearing it on the next transition erases the only record of the
47
+ approved reopen; and
48
+ - the reset is recorded in the CR's `Resolution` section (which rows, by
49
+ `TDD-ID`).
50
+
51
+ ## A retained `CR-*` is not an exception's `DR-*`
52
+
53
+ A reset row that later hits an anomaly still owes a Decision Record. The
54
+ retained `CR-*` records the approved reopen, not the anomaly, so it does not
55
+ satisfy the `exception` requirement on its own: add the `DR-*` alongside it
56
+ (`DR-NNNN, CR-YYYYMMDD-NNNN`). `TDDLIST_EXCEPTION_MISSING_DR` fires on an
57
+ `exception` row whose `DR-ID` cell is empty **or holds `CR-*` references only**.
58
+
59
+ ## What stays prohibited
60
+
61
+ - Any backward transition not covered by an approved CR, including the named
62
+ `green -> red` case. The error text is unchanged:
63
+ `"Backward transition prohibited: green -> red"`.
64
+ - Resetting rows before approval. A CR at `Status: open` authorises nothing.
65
+ - Resetting rows the CR's "Approved actions" did not name.
66
+
67
+ ## When an in-scope CR counts as resolved
68
+
69
+ The spec completion gate covers only the `.qfai/decisions/CR-*.md` **in scope for
70
+ this spec**: `Impact scope` names this spec or a shared policy it depends on, or
71
+ this spec's artifacts reference it. A CR confined to another spec never blocks
72
+ this one.
73
+
74
+ An in-scope CR is **resolved** only when every one of these holds. A CR failing
75
+ any single one — a half-filled record included — is **unresolved** and blocks
76
+ completion:
77
+
78
+ - `Status` is `approved`, `rejected` or `superseded` (never `open`);
79
+ - `Approved by` / `Approved at` are populated, plus `Approved option` when
80
+ `Status` is `approved` and `Superseded by` when it is `superseded`;
81
+ - `Resolution` records what was actually done; and
82
+ - when `Status` is `approved`, `Applied at` is populated — approval alone does
83
+ not release the gate. It is set only after the owner-skill rerun in "Approved
84
+ actions" completed and upstream artifacts are updated, which is when
85
+ `constitution/drift-protocol.md` resumes downstream work.
86
+
87
+ ## Ordering against the drift protocol
88
+
89
+ `.qfai/assistant/constitution/drift-protocol.md` resumes downstream work only
90
+ after the owner skill has been rerun and the upstream artifacts are updated.
91
+ The ledger sweep is downstream work, so it follows the owner-skill rerun; the
92
+ CR's `Applied at` is set once both are done. An `approved` CR without
93
+ `Applied at` is still unresolved and blocks spec completion.
@@ -0,0 +1,210 @@
1
+ # Checkpoint Verification
2
+
3
+ "Checkpoint verification" is the whole-repository regression check run at a checkpoint boundary. It
4
+ is what item 12 of the 12-point gate refers to and the only thing it refers to.
5
+
6
+ ## Checkpoint boundary
7
+
8
+ A checkpoint boundary is reached in exactly two places:
9
+
10
+ - **Per item** — after all routed blocking reviewers have returned PASS for the item and before it
11
+ transitions `refactor` -> `done`. Every item has exactly one.
12
+ - **Per spec** — after the last item in `test-list.md` reaches `done` or a valid `exception`, before
13
+ declaring spec-level completion.
14
+
15
+ No other point is a checkpoint boundary. There is no "every N items" rule.
16
+
17
+ ## Verification command set (per item)
18
+
19
+ Run all of the following from the repository root, in order. Substitute the project's own runner for
20
+ the placeholders; record the literal commands actually executed in evidence.
21
+
22
+ 1. The item's own test — the ledger's `Test file`, run **file-scoped, with no test-name option**:
23
+
24
+ ```bash
25
+ <test runner> <Test file>
26
+ ```
27
+
28
+ **Why the name option is not prescribed here.** Narrowing the run to the ledger's `Selector` is
29
+ the obvious move and an earlier form of this step required it. Do not, unless you have checked
30
+ that your runner matches the selector **literally**. Vitest's and Jest's `-t` take a _regular
31
+ expression_, and a `Selector` written in the common `TC-NNNN-NNNN (TDD-NNNN): title` shape
32
+ contains `(` and `)` — which the matcher reads as a capture group, not as characters. The pattern
33
+ then matches nothing, the runner reports `Tests 1 skipped (1)`, and it **exits 0**: a checkpoint
34
+ that establishes nothing while reporting success. Nothing downstream distinguishes it from a real
35
+ pass, because the exit code is what the surrounding procedure reads.
36
+
37
+ The file-scoped form cannot fail that way. It over-runs when several rows share one file, which is
38
+ the safe direction — it can only execute more than the row, never less.
39
+
40
+ **If you do narrow**, escape the selector for your runner's matcher, record the literal command,
41
+ and check that the run actually selected something: `passed >= 1` for a GREEN, `failed >= 1` for a
42
+ RED. A skipped count is not a pass.
43
+
44
+ **The unit of selection is not always a file.** Package-selecting runners (`go test`) take a
45
+ package, not a path. `go help test` documents the usage as
46
+ `go test [build/test flags] [packages] [build/test flags & test binary flags]`, and it compiles
47
+ the package's sources together with the matching `*_test.go` files. Handing it a lone file
48
+ switches it into file mode and drops the rest of the package from the build, so the item's test
49
+ normally fails on undefined symbols. Derive the package from the `Test file`'s directory:
50
+
51
+ ```bash
52
+ go test ./<dir of Test file>
53
+ ```
54
+
55
+ Record the literal command actually run either way. If a project's runner selects by something
56
+ else again, derive that unit from `Test file` in the same manner and say so in the evidence.
57
+
58
+ 2. The full test suite — `<test runner>` with no file filter and no test-name option.
59
+ 3. The project's static gates, when the repository defines them — formatter check, linter, and type
60
+ check.
61
+ 4. `npx qfai validate --profile tdd --fail-on error --spec <spec-id>` — qfai is a project
62
+ dependency, not a global command; a bare `qfai …` is `command not found` (exit 127) on a normal
63
+ local install, which would fail every checkpoint. `--spec` scopes the run to the spec this
64
+ checkpoint is for: this skill processes one spec at a time, so an unscoped run makes a sibling
65
+ spec's in-flight failure fail this checkpoint. It also writes
66
+ `<report>/validate.spec-<id>.json` instead of the shared `validate.json`, so the checkpoint
67
+ artifact cannot be overwritten by another spec's run.
68
+ **`--spec` scopes the spec-owned rules only, and this checkpoint still fails on the rest.**
69
+ `QFAI-TEST-001` names a test file, the `QFAI-TRACE-*` findings **that have no spec
70
+ owner** are filed against `.qfai/specs/` itself, and the contract validators run
71
+ regardless of scope —
72
+ `QFAI-CONTRACT-*` and `QFAI-DB-002` are filed against `.qfai/contracts/**`, which
73
+ no spec owns. None of the three has a spec owner, so a sibling spec's `it.todo`, a
74
+ `CAP-*` it has not created yet, or a malformed contract it is mid-way through
75
+ editing, exits 1 here. **Not the whole `QFAI-TRACE-*` family**: the per-artifact
76
+ ones are filed against the spec's own `03_Acceptance-Criteria.md` /
77
+ `04_Business-Rules.md` / `05_Examples.md` / `06_Test-Cases.md` and its ledger, so a
78
+ sibling's are dropped by the scope filter and never reach this checkpoint —
79
+ treating them as still-blocking reports a failure this run cannot see. Record the finding, its owning spec and why it
80
+ is not this checkpoint's work; do **not** drop `--fail-on error`, weaken the profile, or
81
+ report the checkpoint as passed.
82
+
83
+ ## Verification command set (per spec)
84
+
85
+ The spec-level boundary has no "item just completed" — a re-run in a later session has none, and
86
+ under parallel slices the ledger order does not identify one either. So step 1 is dropped: the
87
+ spec-level set is steps 2, 3 and 4 only. Everything step 1 would have proved is already covered by
88
+ the full suite.
89
+
90
+ ## Pass criteria
91
+
92
+ Checkpoint verification PASSES only when **every** command in the applicable set exits 0, and step 4
93
+ reports zero `QFAI-TEST-001` findings. Any non-zero exit is a FAIL: for a per-item checkpoint the
94
+ item stays at `refactor`, the failure is fixed, and the whole set is re-run. A partial run is not a
95
+ pass.
96
+
97
+ ### The one substitution: a measured delta for step 4
98
+
99
+ Step 4 alone MAY be judged on a **measured delta** instead of on exit 0, and only when all five of the
100
+ following hold. This exists for the case where the profile already reports findings that no row in the
101
+ slice can discharge — a validate run cannot exit 0 against a standing error, so without this the gate
102
+ would hold every row of every slice hostage to work outside it.
103
+
104
+ 1. The baseline — the counts **and** the finding IDs — was captured before the slice's first code
105
+ change and recorded in the slice's evidence **before any row started**. A baseline written after the
106
+ fact is not a baseline.
107
+ 2. Step 4 reports zero `QFAI-TEST-001` findings. This clause is never substituted.
108
+ 3. The aggregate does not worsen, on **both** measures the baseline records: no severity count
109
+ **attributable to this slice** is higher than the baseline's, **and no finding ID appears that the
110
+ baseline did not hold**. The count alone is not the test — resolving one finding while introducing
111
+ a different one leaves every count unchanged, and clauses 4 and 5 below only ever read baseline
112
+ findings, so a new ID would reach none of them. A finding this slice introduced is a regression
113
+ whatever its severity.
114
+
115
+ **Attributable** is read the way clause 5 already reads a finding: by the spec and row each finding
116
+ names, which the validator prints on every line. A count that rose because a sibling spec gained
117
+ findings, or because a validator's own defect widened what it reports, is not this slice worsening
118
+ the aggregate — and the raw total made those indistinguishable from a real regression, which is
119
+ what stalled four rows behind a warning count they did not cause.
120
+
121
+ **Record both.** The attributed delta is what the clause is judged on; the raw total is recorded
122
+ beside it, unjudged, so a cross-spec regression this slice really did cause is still visible rather
123
+ than attributed away. A boundary that records only the attributed figure has not satisfied this
124
+ clause.
125
+
126
+ 4. **No row's `TC-*` re-enters the unreferenced-TC list.** Stated as re-entry rather than as departure,
127
+ because departure is undischargeable for a sibling: when one `TC-*` is split across several rows,
128
+ the first row to discharge it removes it from the list and every sibling then satisfies a departure
129
+ clause vacuously. Re-entry is checkable for every row, and it pairs with the row-level obligation the
130
+ validator already enforces — that a row's `Selector` resolves in its own `Test file`.
131
+ 5. **Every finding the baseline holds open is unattributable to the row being closed** — it names an
132
+ obligation that row does not carry. Read per row, not per spec: a finding naming another row's
133
+ obligation in the same spec, or an obligation owned by an upstream phase, does not block this row.
134
+ What it does forbid is the case it exists for — closing a row while a baseline finding names **that
135
+ row's own** obligation.
136
+
137
+ Clause 5 is the load-bearing one. It is also the one to state carefully in the evidence: name each
138
+ baseline finding, name whose obligation it is, and say why that is not the row's. A slice that cannot
139
+ answer that per row has not earned the substitution.
140
+
141
+ The substitution applies to step 4 and nothing else. Every other command in the set still has to exit 0.
142
+
143
+ **A fix invalidates the reviewer PASS that preceded it.** The per-item boundary sits after
144
+ `completion-reviewer` and `implementation-reviewer` returned PASS (Phase: Refactor, steps 4-5), so
145
+ those verdicts were given against the pre-fix test and production code. Whenever the fix changes
146
+ either, re-submit to every routed blocking reviewer the change could affect — always the ones whose
147
+ scope it touches — and obtain a fresh PASS **before** re-running the command set. Re-running the
148
+ commands alone would let an item reach `done` carrying code no reviewer ever saw, which the
149
+ skill's own stale-evidence rule forbids. A fix that changes nothing a reviewer judged — re-running
150
+ after a flaky external service, say — needs no re-review; record which case applied.
151
+
152
+ ## Spec-level boundary on an already-complete ledger
153
+
154
+ A ledger is **terminal** when every row is `done` or a valid `exception` — the same condition the
155
+ spec completion conditions use. The last row reaching `exception` ends the loop exactly as `done`
156
+ does, so both must reach this boundary.
157
+
158
+ The per-spec boundary is owed once per terminal ledger state, not once per session. Two cases leave
159
+ it unrecorded:
160
+
161
+ - the run was interrupted between the last row reaching its terminal status and the spec-level
162
+ verification;
163
+ - `/qfai-implement` is re-run against a ledger that is already terminal.
164
+
165
+ In both, an unconditional "nothing to do" exit would skip the boundary permanently, and no later
166
+ re-run could repair it — a re-run finds no `todo` rows to process either. So before that exit: read
167
+ the spec's evidence file for spec-level `Checkpoint verification command` /
168
+ `Checkpoint verification result` entries covering the current ledger state. Run the **per spec**
169
+ command set above and record them when they are absent, or when they predate the last ledger
170
+ change. Only then report "nothing to do".
171
+
172
+ **Which file, for a boundary that has no `Layer`.** The per-item rule below picks the file from the
173
+ row's `Layer`, and this result belongs to no row. The spec-level boundary is written to
174
+ `.qfai/evidence/implement-<spec-id>.md` whenever that file exists, and to
175
+ `.qfai/evidence/atdd-<spec-id>.md` when it does not — the terminal-ledger case of a spec whose every
176
+ row is `E2E` / `API`, where the implement file was never created. Read and write are the same rule,
177
+ so a re-run finds what the previous run wrote instead of judging the boundary unrecorded, and the
178
+ one-file-per-spec contract holds: a spec never has this boundary in both files.
179
+
180
+ ## Evidence
181
+
182
+ Record a **per-item** result in the evidence file the row's `Layer` owns (the spec-level boundary
183
+ above has no row, and its own rule is stated there) —
184
+ `.qfai/evidence/implement-<spec-id>.md`, or `.qfai/evidence/atdd-<spec-id>.md` for an `E2E` / `API`
185
+ row — using the per-item evidence fields `Checkpoint verification command`,
186
+ `Checkpoint verification result` and `Checkpoint verification seal`. The seal is the audit hash over
187
+ the first two together with the `Revision` this run was made against, taken the moment the run ends
188
+ and recomputed at gate item 12: these fields are appended after every reviewer has hashed, so they
189
+ sit in no audit subject, and the revision that would otherwise cover them excludes
190
+ `.qfai/evidence/**`. Without it a recorded FAIL could be edited to PASS on a `done` row and no hash
191
+ anywhere would move.
192
+
193
+ **The spec-level boundary records a seal of its own, and the spec completion conditions recompute
194
+ it.** That boundary has no row, so gate item 12 never runs for it: the seal defined here was
195
+ per-item only, and the full-suite result on a terminal ledger could still be edited from FAIL to
196
+ PASS afterwards with no revision, no `Audited evidence hash` and no pack seal moving. Take it the
197
+ same way — the audit hash over the spec-level `Checkpoint verification command` and
198
+ `Checkpoint verification result` together with the `Revision` that run was made against — record it
199
+ beside them as `Checkpoint verification seal`, and recompute it before spec-level completion is
200
+ declared. A mismatch means the record was edited after the run, and completion is not declared.
201
+
202
+ **Both seals — per item and per spec — are recorded when the run ends and recomputed at the gate**,
203
+ and `evidence-revision.md` says once, for every seal in this contract, what that catches and what
204
+ it does not: drift between those two moments, which is what happens; not an author rewriting the
205
+ pair and the seal together, which nothing recorded in the repository can catch.
206
+
207
+ These are per-item fields of the same contract gate item 10
208
+ resolves, so writing them to the implement file for a row anchored at the ATDD one splits that row
209
+ across two files and leaves the one the gate reads incomplete. As with RED/GREEN evidence,
210
+ a status without its command is invalid, and evidence from a previous checkpoint MUST NOT be reused.
@@ -0,0 +1,73 @@
1
+ # Cross-spec Code Ownership
2
+
3
+ What to do when implementing one spec correctly requires changing something
4
+ another spec's `done` rows certify.
5
+
6
+ ## Why this needs a rule at all
7
+
8
+ `/qfai-implement` constrains execution to **one spec** and scopes every artifact
9
+ it writes — the ledger, the evidence file — to that spec. The codebase is not
10
+ partitioned at all, qfai defines no module → owning-spec index, and the Refactor
11
+ phase **mandates** duplication removal one line before this rule applies.
12
+
13
+ So the collision is the normal case, not an edge one. And both available
14
+ outcomes used to violate a shipped rule:
15
+
16
+ - change the file, and spec A's `done` rows now certify behaviour that was
17
+ re-tested by nobody — `done` has no outbound edge, so those rows cannot be
18
+ reopened;
19
+ - do not change it, and the Refactor phase's own instruction is unmet, and
20
+ spec B ships a duplicate.
21
+
22
+ Neither left any trace under `.qfai/**`. `drift-protocol.md`'s upstream list
23
+ contains no code or test artifacts, so the STOP → Change Request → owner-rerun
24
+ route never fired for them.
25
+
26
+ ## The rule
27
+
28
+ **A file another spec's ledger names in `Test file` is that spec's to certify.**
29
+ Editing it does not require permission — it requires a record and a re-review.
30
+
31
+ 1. **Detect.** Before editing a production file in Refactor, search every
32
+ `tdd/test-list.md` for it. A hit means the edit is cross-spec.
33
+ 2. **Record.** Add a `## Cross-spec obligations` entry to this spec's evidence
34
+ file (fields below).
35
+ 3. **Re-review.** Run `completion-reviewer` against the affected specs'
36
+ obligations as well as this one's. The reviewer is the party that can say
37
+ whether the other spec's assertions still hold.
38
+ 4. **Do not close over it.** An open entry is a completion prohibition
39
+ (`qfai-implement/SKILL.md#completion-prohibition-conditions`).
40
+
41
+ ## The evidence entry
42
+
43
+ Per affected spec, in the evidence file the row's `Layer` owns (`.qfai/evidence/implement-<spec-id>.md`, or `.qfai/evidence/atdd-<spec-id>.md` for an `E2E` / `API` row):
44
+
45
+ | Field | Meaning |
46
+ | -------------------- | ------------------------------------------------------------- |
47
+ | `TDD-ID` | the row in **this** spec whose work forced the change |
48
+ | `Blocked spec` | the spec whose `done` rows the file belongs to |
49
+ | `Blocked TDD-IDs` | the rows in that spec that name the file |
50
+ | `File` | the exact path changed |
51
+ | `Change required` | what had to change, in one sentence |
52
+ | `Obligation at risk` | what that spec asserted about the file that is now unverified |
53
+ | `Resolution` | `re-reviewed` (the reviewer confirmed it holds) or `CR-*` |
54
+
55
+ `Obligation at risk` is the load-bearing field. "Changed a shared helper" is not
56
+ a record; "spec-0004 TDD-0012 asserts this helper rejects an empty batch, and
57
+ that path is now routed through the new guard" is.
58
+
59
+ ## When re-review is not enough
60
+
61
+ If the other spec's obligation genuinely no longer holds — the behaviour it
62
+ asserted has changed, not merely moved — that is upstream drift, and
63
+ `constitution/drift-protocol.md#when-drift-is-detected` governs from step 1.
64
+ Record the CR id in `Resolution`. Re-review cannot ratify a behaviour change the
65
+ other spec never agreed to; only its owner can.
66
+
67
+ ## What this does not do
68
+
69
+ It does not partition the codebase, and it does not give `done` an outbound
70
+ edge. Both are larger changes. What it does is make the collision **visible and
71
+ blocking** instead of silent — the two outcomes above are still the two
72
+ outcomes, but neither can now be taken without a record that names the
73
+ obligation it puts at risk.