qfai 2.2.0 → 2.2.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 (117) hide show
  1. package/README.md +46 -6
  2. package/assets/defaults/workflows/bump-dependency.yml +4 -1
  3. package/assets/defaults/workflows/decide-design.yml +5 -1
  4. package/assets/defaults/workflows/rename-concept.yml +30 -0
  5. package/assets/defaults/workflows/resolve-conflicts.yml +14 -0
  6. package/assets/defaults/workflows/retire-feature.yml +26 -0
  7. package/assets/defaults/workflows/run-release.yml +12 -0
  8. package/assets/init/.claude/settings.json +11 -11
  9. package/assets/init/.codex/hooks.json +9 -9
  10. package/assets/init/.qfai/assistant/agent/backend-engineer.md +1 -1
  11. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +1 -1
  12. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +5 -0
  13. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +8 -3
  14. package/assets/init/.qfai/assistant/rule/constitution.md +5 -3
  15. package/assets/init/.qfai/assistant/rule/drift-protocol.md +18 -0
  16. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +1 -1
  17. package/assets/init/.qfai/assistant/rule/review-convergence.md +9 -3
  18. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +11 -2
  19. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +6 -4
  20. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +2 -1
  21. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +5 -2
  22. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +15 -2
  23. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +17 -0
  24. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/trend_scan_playbook.md +3 -1
  25. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/01_Context.md +4 -1
  26. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/04_Sources.md +5 -1
  27. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +4 -1
  28. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +2 -2
  29. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +10 -0
  30. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +35 -0
  31. package/assets/init/.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md +445 -0
  32. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +2 -2
  33. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +10 -9
  34. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +33 -2
  35. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +77 -2
  36. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +12 -3
  37. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +3 -1
  38. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +31 -5
  39. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +17 -17
  40. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +194 -129
  41. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +29 -14
  42. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +46 -22
  43. package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +2 -0
  44. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +7 -4
  45. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -1
  46. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -1
  47. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +2 -2
  48. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +1 -1
  49. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +1 -0
  50. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +1 -1
  51. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +83 -6
  52. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +1 -1
  53. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +23 -5
  54. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +1 -1
  55. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions/page-NNNN.md +6 -0
  56. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +9 -0
  57. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/open-questions.md +13 -0
  58. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +15 -9
  59. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +1 -1
  60. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +11 -8
  61. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +15 -2
  62. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +48 -11
  63. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +11 -3
  64. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +12 -0
  65. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +18 -2
  66. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +4 -0
  67. package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +3 -0
  68. package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +4 -0
  69. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +31 -7
  70. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +12 -3
  71. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +35 -6
  72. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +25 -5
  73. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +26 -0
  74. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +28 -5
  75. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +20 -5
  76. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +70 -6
  77. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +39 -6
  78. package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +12 -3
  79. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +56 -6
  80. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +5 -0
  81. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +8 -0
  82. package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +9 -4
  83. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +22 -1
  84. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +48 -12
  85. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +7 -2
  86. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +6 -0
  87. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +76 -3
  88. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +35 -10
  89. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +65 -7
  90. package/assets/init/root/.agents/rules/api-budget.md +8 -3
  91. package/assets/init/root/.agents/rules/graph-exploration.md +18 -4
  92. package/assets/init/root/.agents/rules/reminders.json +20 -28
  93. package/assets/init/root/.agents/rules/user-questions.md +21 -11
  94. package/assets/init/root/.gitattributes +2 -0
  95. package/assets/init/root/AGENTS.md +1 -1
  96. package/assets/mdschema/manifest.yml +3 -0
  97. package/assets/mdschema/story/03_contract/tech.mdschema.yml +1 -1
  98. package/assets/mdschema/story/decisions/page-NNNN.mdschema.yml +32 -0
  99. package/assets/mdschema/story/decisions.mdschema.yml +12 -0
  100. package/assets/schemas/workflow/extraction.schema.json +94 -2
  101. package/assets/schemas/workflow/plan.schema.json +34 -1
  102. package/assets/scripts/check-mdschema.mjs +434 -45
  103. package/dist/cli/index.cjs +4930 -2264
  104. package/dist/cli/index.cjs.map +1 -1
  105. package/dist/cli/index.mjs +4690 -2016
  106. package/dist/cli/index.mjs.map +1 -1
  107. package/dist/graph/cli.cjs.map +1 -1
  108. package/dist/graph/cli.mjs.map +1 -1
  109. package/dist/graph/hook.cjs.map +1 -1
  110. package/dist/graph/hook.mjs.map +1 -1
  111. package/dist/index.cjs +3338 -1830
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +59 -3
  114. package/dist/index.d.ts +59 -3
  115. package/dist/index.mjs +3154 -1649
  116. package/dist/index.mjs.map +1 -1
  117. package/package.json +1 -1
@@ -44,8 +44,9 @@ Each decision record carries the four labelled Approach items stated at the top
44
44
 
45
45
  ## One session
46
46
 
47
- The stage holds one session per run. The row goes in the stage report, under
48
- `## Grilling Session`, and is written before the first authored file:
47
+ The stage holds one session per run, except a reopened node, below. The row
48
+ goes in the stage report, under `## Grilling Session`, and is written before
49
+ the first authored file:
49
50
 
50
51
  ```text
51
52
  | Ended | Ended at | Authoring began | Frontier | Lookups | Decisions | Escalated |
@@ -63,3 +64,15 @@ Record these in the stage evidence, not as a fictional human option answer.
63
64
  `Ended at` and `Authoring began` are actual timestamps, with authoring later.
64
65
  A missing hard-required consumed input authorizes no authoring ending.
65
66
  Allowing authoring is not a completion or validation receipt.
67
+
68
+ ## A reopened node
69
+
70
+ A critical decision found while authoring reopens the session for that node
71
+ only, for one round to the user. Append one row for that round under the same
72
+ header, with its own `Ended`, `Ended at` and `Authoring began`, before authoring
73
+ resumes. The earlier rows stay as written. A stopped round is reported, not written.
74
+
75
+ The round runs until no node it opened is left open, or until what is still
76
+ open is recorded as labelled assumptions or `11_OQ-Register.md` entries. Under
77
+ a no-question mode the row's `Ended` is `no-question`, and the decision is
78
+ registered in `11_OQ-Register.md`.
@@ -40,8 +40,25 @@ them; it is the procedure that applies them.
40
40
  reviewer. A side is reviewed when it is on the default branch or a review of
41
41
  this route or its pull request covered its commits. A resolution that adds
42
42
  content neither side had is not conflict-only. The stage report names the
43
- merge and why no reviewer ran. A parent skill invoked by name uses the
44
- reviewers its own `## Review` section names, such as `qfai-discussion`'s.
43
+ merge and why no reviewer ran. In the `resolve-conflicts` route, a
44
+ resolution that touches a story-tree file, a contract, or `decisions.md` or
45
+ `open-questions.md` is not exempt: it gets the code review, and
46
+ `architecture-reviewer` too for a contract. A parent skill invoked by name
47
+ uses the reviewers its own `## Review` section names, such as `qfai-discussion`'s.
48
+
49
+ In a route, a code review whose target replaces at most five lines, a
50
+ replaced line counting once, and no line added or removed, each changing
51
+ only a literal value such as a version, a number, a name or a flag in a
52
+ configuration or build file, gets no reviewer. A change to code, tests, a
53
+ story-tree or contract file, a screen or a file's structure is not
54
+ literal-only, and neither is a change that touches permissions, secrets,
55
+ credentials or tokens; a URL, host, registry, image or action reference; a
56
+ dependency or tool version resolved from the network; a workflow trigger; a
57
+ setting that turns a check, lint rule, type check, gate or test on or off;
58
+ any text inside a shell command, script or recipe; or a package's own
59
+ version, or any value a release, tag or publish job reads. The stage report
60
+ and the final report both name the skip, the changed lines and why no
61
+ reviewer ran.
45
62
 
46
63
  - **The review target.** The specification review: every path and ID the
47
64
  stage it follows wrote or changed, and the source it was written from. The
@@ -58,17 +75,30 @@ them; it is the procedure that applies them.
58
75
  focus. Put the answers an earlier stage recorded on the same artifact into
59
76
  this review's request before dispatching reviewers, under
60
77
  `.qfai/assistant/rule/review-convergence.md#answered-demands-must`.
61
- 2. **Dispatch.** Send each reviewer a work order in the shared template. An
62
- agent that authored, edited or recommended a decision in the reviewed
63
- artifact is not its independent reviewer. The session report names its
64
- authors, editors and decision recommenders, and the independent reviewers.
78
+ For the code review, name each test the run recorded `red: ci-deferred`:
79
+ the reviewer reads it against the code before the fix and confirms that
80
+ its assertion fails there
81
+ (`.qfai/assistant/skill/qfai-implement/references/red-admissibility.md#ci-only-test-gate`).
82
+ 2. **Dispatch.** The orchestrator sends each reviewer a work order in the
83
+ shared template, never a stage worker. An agent that authored, edited or
84
+ recommended a decision in the reviewed artifact is not its independent
85
+ reviewer. The session report names its authors, editors and decision
86
+ recommenders, and the independent reviewers.
65
87
  Each reviewer returns a verdict, `PASS` or `REVISE`, and its
66
88
  findings, in the shared reviewer response template.
67
89
  3. **Address every finding** once: fix it in its owning source with the
68
90
  smallest edit that resolves it, or record a reasoned answer beside it, and
69
91
  rerun the tests a fix touches. An upstream finding is not repaired here:
70
- stop under `.qfai/assistant/rule/drift-protocol.md`. No reviewer is rerun.
71
- 4. **Complete** once every reviewer has responded and every finding is fixed or
92
+ stop under `.qfai/assistant/rule/drift-protocol.md`.
93
+ 4. **Re-review a behaviour fix** once. A fix that changes behaviour (code, a
94
+ test's assertions or a contract statement, not wording alone) goes back to
95
+ the reviewer whose finding it fixed: each reviewer whose findings had a
96
+ behaviour fix re-reviews the combined diff of those fixes, once, and reads
97
+ nothing else. Fix or answer each finding of that re-review as step 3 says, with no further
98
+ re-review. A fix that changes wording only gets no re-review. No other
99
+ reviewer is rerun.
100
+ 5. **Complete** once every reviewer has responded, each behaviour fix has had
101
+ its one re-review, and every finding is fixed or
72
102
  answered. A finding the author cannot fix goes in the stage's final report;
73
103
  a critical decision goes to the user
74
104
  (`.qfai/assistant/rule/review-convergence.md#one-review`).
@@ -76,12 +106,19 @@ them; it is the procedure that applies them.
76
106
  ## Writes
77
107
 
78
108
  - In the stage report: each reviewer's verdict, the findings, and how each was
79
- fixed or answered.
109
+ fixed or answered, and for each behaviour fix its re-review's verdict and
110
+ findings.
111
+ - For a code review skipped as a small literal-only change: the skip, the
112
+ changed lines and why no reviewer ran, in the stage report and in the final
113
+ report.
80
114
 
81
115
  ## Gate
82
116
 
83
- Every routed reviewer responded once, every finding is fixed or answered, and
117
+ Every routed reviewer responded once, each behaviour fix had its one focused
118
+ re-review, every finding is fixed or answered, and
84
119
  the stage report names each verdict and each answer, or says why the review
85
- dispatched no reviewer. A finding the author
120
+ dispatched no reviewer. For a code review skipped as a small literal-only
121
+ change, the stage report names the skip, the changed lines and why, and records
122
+ the skip for the final report. A finding the author
86
123
  cannot fix is in the stage's final report, and a critical decision has gone to
87
124
  the user.
@@ -50,7 +50,9 @@ is in place.
50
50
  a `visual.*` token tree for one. The design direction belongs in this session
51
51
  because `discussion-pack` records it after the pack is authored, and a
52
52
  user-owned visual choice asked there is asked after the thing it governs is
53
- written.
53
+ written. Skip the design-DNA questions when the classification declares
54
+ `design_direction: inherit`, under the conditions of
55
+ `.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md#inheriting-the-current-designmd`.
54
56
  4. The research findings are inputs to the session's tree, not a later fill-in:
55
57
  a decision settled before the research that bears on it is settled against
56
58
  evidence nobody had, and the method reads a fact rather than asking about it.
@@ -134,6 +136,11 @@ off that row. Without it a skipped session and a completed one present the same
134
136
  pack — nine files, every topic covered, every open question registered — so
135
137
  the reviewer would have to block every run or accept a claim it cannot check.
136
138
 
139
+ The agent that holds the session writes the row, `Ended at` included. Where
140
+ another agent authors the pack, write the row before delegating, and pass the
141
+ row to the pack author, who copies it unchanged into the stage report it
142
+ writes and does not reconstruct it.
143
+
137
144
  A `stopped` session writes no row: the ending is reported, and no later step
138
145
  runs.
139
146
 
@@ -141,8 +148,9 @@ runs.
141
148
 
142
149
  The reviewer confirms:
143
150
 
144
- - the stage report's `## Grilling Session` row shows the session ended before
145
- authoring began, with `Ended` one of `confirmed`, `user-closed`,
151
+ - every row of the stage report's `## Grilling Session` table has its
152
+ `Ended at` before its own `Authoring began` (for a reopened row, when
153
+ authoring resumed), with `Ended` one of `confirmed`, `user-closed`,
146
154
  `no-question`, or `adopted` with the recorded explicit-delegation conditions
147
155
  verified;
148
156
  - every decision the session settled is recorded where
@@ -23,6 +23,18 @@ human authority in the stage evidence; the ending label alone is insufficient.
23
23
  Without that row, or with
24
24
  `Ended: stopped`, write nothing and stop.
25
25
 
26
+ ## A critical decision found while authoring
27
+
28
+ A decision found while registering that is critical under
29
+ `.agents/rules/grilling.md#critical-decisions` reopens the session for that
30
+ node only. Stop writing, ask the user one round on that node, record the round
31
+ as `.qfai/assistant/step/common-grilling-record/STEP.md#a-reopened-node` says,
32
+ then resume. The rest of the session's record stays as it is.
33
+ Recording the decision as an assumption is allowed only under a no-question
34
+ mode, labelled beside its open question.
35
+ A stop in that round ends the run as `stopped` does: no row is written,
36
+ writing stops, and the report names the pack files already written and the open node.
37
+
26
38
  ## Reads
27
39
 
28
40
  - `.qfai/assistant/skill/qfai-discussion/references/oq-and-deferred-rules.md`
@@ -25,6 +25,18 @@ or with `Ended: stopped`, write no pack file and stop. A pack drafted
25
25
  mid-session records a design that was still being decided, and the draft is
26
26
  what the rest of the run then defends.
27
27
 
28
+ ## A critical decision found while authoring
29
+
30
+ A decision found while authoring that is critical under
31
+ `.agents/rules/grilling.md#critical-decisions` reopens the session for that
32
+ node only. Stop writing the pack, ask the user one round on that node, record
33
+ the round as `.qfai/assistant/step/common-grilling-record/STEP.md#a-reopened-node`
34
+ says, then resume. The rest of the session's record stays as it is.
35
+ Recording the decision as an assumption is allowed only under a no-question
36
+ mode, labelled beside its open question.
37
+ A stop in that round ends the run as `stopped` does: no row is written,
38
+ writing stops, and the report names the pack files already written and the open node.
39
+
28
40
  ## Passes when
29
41
 
30
42
  Read first: the pack under work and the interview's answers. The step passes
@@ -79,7 +91,10 @@ and the `uiux/` sidecars. Root DESIGN.md is not a discussion output.
79
91
  choice is made in the session, not here; this step writes it down. Required
80
92
  when any classified surface — primary or secondary — is `web`, `mobile`,
81
93
  `desktop` or `mixed`; skip for cli-only and non-ui targets. The answers, not
82
- a rendered brand file, are the handoff.
94
+ a rendered brand file, are the handoff. A pack whose classification declares
95
+ `design_direction: inherit` records no direction and skips the registries
96
+ and the 40/50 sidecars, under the conditions of
97
+ `.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md#inheriting-the-current-designmd`.
83
98
  8. Generate `prototyping.yaml` only for a visual prototyping surface; a cli-only pack emits none.
84
99
  Write it where the pack targets `web`, `mobile`, `desktop` or `mixed` and an
85
100
  explicit prototyping recommendation is useful. `/qfai-prototyping` rejects
@@ -108,7 +123,8 @@ Decide whether the target is UI-bearing with
108
123
  `/qfai-sdd`'s `common-design-md` step turns into root `DESIGN.md` front matter and
109
124
  its `# Brand Philosophy` body, so an entry left blank leaves a brand field
110
125
  with nothing behind it. A registry `reference` resolves to a URL, repository
111
- path, or `SRC-ID`.
126
+ path, or `SRC-ID`. A pack declaring `design_direction: inherit` owes neither
127
+ registry nor the Trend Scan (see step 7).
112
128
 
113
129
  Discussion is planner-first: carry the screen explorations unranked and do not
114
130
  finalize the design system here. The brand direction is the exception — which
@@ -52,6 +52,10 @@ including `cli`:
52
52
  - `uiux/40_screen_contracts.md`
53
53
  - `uiux/50_review_input_bundle.md`
54
54
 
55
+ A pack whose classification declares `design_direction: inherit` may leave out
56
+ the last two, and writes no Trend Scan or competitor references; the playbook
57
+ above says when the declaration is allowed.
58
+
55
59
  ## Procedure
56
60
 
57
61
  1. Write `40_screen_contracts.md` with every screen contract in the template's
@@ -24,6 +24,9 @@ step writes the assertions those bodies owe.
24
24
  contracts, under `paths.contractsDir`.
25
25
  - The worker session setup `implement-credentials` wrote, when a test needs an
26
26
  authenticated actor.
27
+ - When a test depends on business time, shares a database or server with
28
+ other workers, or feeds a required CI check:
29
+ `.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md`.
27
30
 
28
31
  ## Writes
29
32
 
@@ -31,6 +31,10 @@ in scope needs an authenticated actor.
31
31
  Follow `.qfai/assistant/skill/qfai-implement/references/credential-reuse.md`.
32
32
  It holds the seven session-reuse rules, the rule for a caller-injected
33
33
  environment and a worked example. Keep actors and sessions isolated by worker.
34
+ For a Playwright or Vitest suite, the optional recipes in
35
+ `.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md` put
36
+ the rules into code, with the business data, shared-state, credential
37
+ directory and CI aggregate patterns around them.
34
38
 
35
39
  ## Passes when
36
40
 
@@ -46,20 +46,44 @@ the section "Keeping QFAI itself up to date" of `node_modules/qfai/README.md`:
46
46
  `init --force`, the retired files the release notes list, then `doctor` and
47
47
  `validate`. `init --force` replaces the skills and steps in use, so read the
48
48
  next step from disk after it runs. What `doctor` and `validate` report is part
49
- of the update: a new required key in `qfai.config.yaml`, and an edit to a spec
50
- contract, which needs its change request in `decisions.md` under
51
- `paths.specsDir`, as `.qfai/assistant/rule/drift-protocol.md` describes, before
52
- the contract file changes.
49
+ of the update: this step writes a new required key in `qfai.config.yaml`, and a
50
+ finding that names a spec contract moves the work as the next section says.
51
+
52
+ ## When a finding names a contract
53
+
54
+ When `validate`, or another check the update runs, reports a finding that
55
+ names a spec contract to change, leave the contract unchanged. Finish every
56
+ other part of the update first, so the contract finding is the only open item.
57
+ Then get the change approved as `.qfai/assistant/rule/drift-protocol.md`
58
+ describes:
59
+
60
+ 1. Put the finding, the contract it names and the fix it states to the
61
+ operator as a critical decision: return `awaiting_input` and change nothing
62
+ more. The attempt holding the answer carries on.
63
+ 2. On approval, append one `Change request:` row to `decisions.md` under
64
+ `paths.specsDir`. Its Content names the contract's path, and its Approach
65
+ records the finding, the fix, who approved it and when. The row starts at
66
+ WIP.
67
+ 3. Report `branch: { outcome: contract-finding }` citing that row's DEC ID.
68
+ The work moves to `apply-settled`, whose `spec` stage edits the contract
69
+ under its change request. Its settled triage applies the cited row.
70
+
71
+ On a decline, append the row at REJECTED, leave the contract as it is and
72
+ report the finding as unresolved, with no branch. When the operator cannot be
73
+ asked, write no row and report the change as the decision still needed.
53
74
 
54
75
  ## What it writes
55
76
 
56
77
  - The actual changed paths for the manifest, lockfile and any adapted call,
57
78
  listed in the stage report. When the dependency is `qfai` itself, they also
58
- include a new key in `qfai.config.yaml` and a spec-contract edit with its
59
- change request.
79
+ include a new key in `qfai.config.yaml`.
80
+ - On a contract finding the operator answered, the change request row in
81
+ `decisions.md`, and its DEC ID in the stage report.
60
82
  - A record of the versions, the breaking changes read and how each was met, in the stage report.
61
83
 
62
84
  ## Gate
63
85
 
64
86
  The step is done when the target version is installed, the runtime check and
65
- every breaking change are recorded as met, and the relevant suite passes.
87
+ every breaking change are recorded as met, and the relevant suite passes, or
88
+ when every other part of the update is met and recorded and the only finding
89
+ left is the contract one, which it reports as `contract-finding`.
@@ -71,8 +71,15 @@ test that should have caught it, before any production code changes:
71
71
  `implement-tdd`, which appends the EX and annotates the test.
72
72
  2. Run that test alone and observe its assertion fail for the reported
73
73
  behaviour (Red). A load error, a missing dependency or a broken fixture is
74
- not a Red.
75
- 3. Record the test path, the command and the failure in the stage report.
74
+ not a Red. Where the Test entry of the Standard commands is
75
+ `CI only: <check name>`, or the user's instruction for this run delegates
76
+ that gate to a named CI check, do not run it: record `red: ci-deferred`,
77
+ quoting that instruction, as
78
+ `.qfai/assistant/skill/qfai-implement/references/red-admissibility.md#ci-only-test-gate`
79
+ states, and the route's code review reads the test against the code
80
+ before the fix.
81
+ 3. Record the test path, the command and the failure in the stage report. For
82
+ a `ci-deferred` Red, record the test path, its selector and the check name.
76
83
 
77
84
  A verdict that moves the work to another route leaves no new test behind:
78
85
  remove the test written here.
@@ -125,5 +132,7 @@ Inside a workflow run, the result carries:
125
132
 
126
133
  The step is done when one verdict is recorded with the observation that
127
134
  supports it, and no tracked file changed but the failing test. That
128
- observation is the reproduction: on a `fix` route the test's observed Red, and
135
+ observation is the reproduction: on a `fix` route the test's observed Red, or
136
+ its `ci-deferred` Red where the Test entry is `CI only: <check name>` or the
137
+ user's instruction for this run delegates that gate to a named CI check, and
129
138
  for `needs-info` the attempts that could not reproduce it.
@@ -13,7 +13,8 @@ routing-profile: default
13
13
 
14
14
  Write instructions a person can follow within the project's existing policy.
15
15
  Do not invent a business flow, code, tests, specifications or contracts to
16
- support this document.
16
+ support this document. The one exception is a script the document itself names
17
+ for the operator to run: edit it as `## Named scripts` says.
17
18
 
18
19
  ## Reads
19
20
 
@@ -22,6 +23,8 @@ support this document.
22
23
  - The existing policy and procedures governing the actions: preserve their
23
24
  authority limits and required checks.
24
25
  - For every document edit, read `.agents/rules/documentation-clarity.md`.
26
+ - For a named script the change requires, read the script and the tests or
27
+ checks that cover it.
25
28
 
26
29
  ## Before writing
27
30
 
@@ -32,19 +35,39 @@ confer ownership of those surfaces.
32
35
  If required facts or values are missing, stop the dependent work and report
33
36
  what is needed to resume. Never invent values, commands or permission.
34
37
 
38
+ ## Named scripts
39
+
40
+ Edit a script only when the document names it for the operator to run and the
41
+ procedure change requires the edit, and only as far as the change requires.
42
+ Keep that script's existing tests and checks passing, and add coverage for the
43
+ change where the repository has tests for the script. Any other code, a new
44
+ script, or a script change the procedure does not need belongs to another
45
+ stage: stop before writing and name it. Editing a script does not run it.
46
+
35
47
  ## Procedure
36
48
 
37
49
  1. Identify the inputs, actions, commands, required values, order, failure
38
50
  conditions and recovery steps the request needs.
39
51
  2. Check them against existing policy and actual known facts. Write only the
40
- authorized documents within the work order's scope.
52
+ authorized documents within the work order's scope, and a named
53
+ script only as `## Named scripts` allows.
41
54
  3. Keep the instructions usable: name the actor, prerequisites, expected
42
55
  result, stop conditions and recovery for each action.
43
56
  4. Run the applicable document lint and link checks through
44
- `.qfai/assistant/step/common-gate-run/STEP.md`. Keep actual evidence;
57
+ `.qfai/assistant/step/common-gate-run/STEP.md`. A check applies when a
58
+ Standard commands entry (normally `Lint` or `Format`) runs a checker over
59
+ the changed files' type; where you cannot tell, run the entry and record its
60
+ result. Where no entry does, record "no applicable checker" in the stage
61
+ report: it is neither a pass nor UNRUN, and it is not required. A defined
62
+ check that reports it checked none of the changed files is recorded with its
63
+ output as run; it is not a pass for those files, and it is not "no
64
+ applicable checker". This does not narrow the gate set under
65
+ `common-gate-run` step 1; it covers only a check that does not exist. Keep
66
+ actual evidence;
45
67
  unavailable required checks remain UNRUN with their blocker and resume
46
68
  condition. Follow the plan's existing independent code review and closing
47
- verification stages.
69
+ verification stages. When a named script changed, also run its existing
70
+ tests and checks through `common-gate-run` and keep their results.
48
71
 
49
72
  ## Action authority
50
73
 
@@ -55,7 +78,9 @@ facts to verify, not authority to act.
55
78
 
56
79
  ## Stage report
57
80
 
58
- Report the changed paths, the procedure authored and the checks actually
81
+ Report the changed paths, the procedure authored, each named script changed
82
+ with why the procedure needed it and the coverage added, or that the
83
+ repository has no tests for it, and the checks actually
59
84
  performed with their evidence. State that the documented actions were not
60
85
  executed; their outcome is unobserved. Record unavailable checks as UNRUN,
61
86
  with the blocker, owner and condition for resuming. Static instructions do not
@@ -65,5 +90,9 @@ prove an adopter's operation succeeded.
65
90
 
66
91
  The authorized document is complete and consistent with existing policy.
67
92
  Applicable lint and link checks have actual results through
68
- `common-gate-run`; failures and unavailable checks prevent completion.
93
+ `common-gate-run`; failures and unavailable checks prevent completion. Where
94
+ no checker covers the changed files, the stage report records "no applicable
95
+ checker", which neither passes nor blocks the gate.
96
+ A changed named script passes its existing tests and checks, with coverage
97
+ added where the repository has tests for it.
69
98
  Protected edits and uncovered actions were stopped before writing or acting.
@@ -12,8 +12,10 @@ routing-profile: default
12
12
 
13
13
  # implement-refactor
14
14
 
15
- The request changes how the code is arranged, not what it does. Nothing in
16
- the story tree changes, so the step adds no example and runs no RED.
15
+ Outside the `rename-concept` route, the request changes how the code is
16
+ arranged, not what it does. Nothing in the story tree changes, so the step
17
+ adds no example and runs no RED. In that route,
18
+ [Renaming a concept](#renaming-a-concept) says what changes.
17
19
 
18
20
  ## Reads
19
21
 
@@ -28,10 +30,27 @@ the story tree changes, so the step adds no example and runs no RED.
28
30
  behaviour that was already broken.
29
31
  2. Move in small steps: rename, extract, inline, move a file. Run the suite
30
32
  after each one.
31
- 3. A test may change only where it names something that moved, such as an
32
- import path. What a test asserts does not change.
33
+ 3. Outside the `rename-concept` route, a test may change only where it names
34
+ something that moved, such as an import path. What a test asserts does not
35
+ change. In that route, [Renaming a concept](#renaming-a-concept) says how a
36
+ test changes.
33
37
  4. Delete code nothing calls and nothing declares.
34
38
 
39
+ ## Renaming a concept
40
+
41
+ In the `rename-concept` route, the user asked to rename a concept across the
42
+ project, and the specification stage before this step already renamed it in
43
+ the glossary, business-flow documents, stories, examples and contract rules,
44
+ keeping every ID. This step renames
45
+ it to match everywhere else: code identifiers, file names, user-visible text,
46
+ configuration and documents, in the small steps of the procedure. A test
47
+ changes only where it names the concept: an identifier, an import, a test
48
+ title or an expected string that carries the old name takes the new name, and
49
+ nothing else in it changes. No test is added or deleted, and no example
50
+ annotation changes. A name the specification did not rename keeps its old
51
+ name. When the rename would change anything beyond the name, stop as
52
+ [When behaviour has to change](#when-behaviour-has-to-change) says.
53
+
35
54
  ## When behaviour has to change
36
55
 
37
56
  When finishing the move would change what the code does, stop before
@@ -51,4 +70,5 @@ changing it and report a branch:
51
70
  ## Gate
52
71
 
53
72
  The step is done when the suite passed before and after every move, no
54
- assertion changed.
73
+ assertion changed except to carry a renamed concept's new name in the
74
+ `rename-concept` route.
@@ -39,6 +39,32 @@ This step carries it out.
39
39
  story or contract through its own route.
40
40
  5. Run the relevant suite. It passes.
41
41
 
42
+ ## Retiring a feature
43
+
44
+ In the `retire-feature` route, the user asked to remove a feature, or a concept
45
+ across the project's surfaces, and the specification stage before this step
46
+ already removed or rewrote the stories, examples and contract rules that stated
47
+ it. That rewritten specification is the recorded decision. When a contract rule
48
+ still cites an example that stage removed, the step changes nothing: it returns
49
+ `needs_repair` naming the rule, with `qfai-sdd` as its owner.
50
+
51
+ The step removes the feature from code, configuration and documents as the
52
+ procedure says, and rewords what still names it to match the specification.
53
+ In this route, step 2 of the procedure is narrowed:
54
+
55
+ - A test is deleted only when every example its example annotations name was
56
+ removed in the specification stage's diff. The stage report lists each
57
+ deleted test with the example IDs it was deleted for.
58
+ - A test that annotates any example the specification keeps stays. The step
59
+ changes its assertions to what the rewritten specification states, and
60
+ moves its example annotation to the rewritten example.
61
+ Before it moves an annotation, it reads the test's body and confirms that it
62
+ asserts the rewritten example's observable outcome.
63
+ - A test that refers to the feature but annotates no removed example is not
64
+ deleted. The stage report lists it.
65
+
66
+ No test is added, neither for the removal nor for the new wording.
67
+
42
68
  ## What it writes
43
69
 
44
70
  - The deleted and changed files, listed in the stage report.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: implement-scaffold
3
3
  owner: qfai-implement
4
- purpose: "Write, with `npx qfai atdd scaffold`, the E2E test of each business flow and the integration test of each acceptance criterion the flow lacks, each with an empty body."
4
+ purpose: "Write, with `npx qfai atdd scaffold` or, in a project with purpose-named test files, by hand, the E2E test of each business flow and the integration test of each acceptance criterion the flow lacks, each with an empty body."
5
5
  requires: [common-gate-run]
6
6
  roles: [test-design-analyst]
7
7
  routing-profile: default
@@ -28,6 +28,8 @@ the system's shape has settled.
28
28
  ## Writes
29
29
 
30
30
  - The empty acceptance tests `npx qfai atdd scaffold` writes.
31
+ - In a project that names its test files by purpose, the empty tests and
32
+ annotation lines this step adds to those files instead.
31
33
 
32
34
  ## Procedure
33
35
 
@@ -35,10 +37,10 @@ the system's shape has settled.
35
37
  `common-gate-run` says, and list the BF and AC items no test annotates.
36
38
  Drop from that list each item a `Test exception:` row at DONE names: it is
37
39
  owed no test.
38
- 2. When the flow is still on that list, run
39
- `npx qfai atdd scaffold --flow BF-NNNN`. It writes
40
+ 2. Unless § Purpose-named test files applies, when the flow is still on that
41
+ list, run `npx qfai atdd scaffold --flow BF-NNNN`. It writes
40
42
  `<testsDir>/e2e/<BF-ID>.test.<ext>`.
41
- 3. For each story with an acceptance criterion still on that list, run
43
+ 3. Under the same condition, for each story with an acceptance criterion still on that list, run
42
44
  `npx qfai atdd scaffold --story US-NNNN-NNNN`. It writes one test per
43
45
  criterion under `<testsDir>/integration/<US-ID>/`, so delete each test it
44
46
  reports as created for a criterion the list dropped.
@@ -47,11 +49,32 @@ the system's shape has settled.
47
49
 
48
50
  The command never overwrites an existing test. A destination the configured
49
51
  globs would not collect is a refusal: fix the globs or the layout, not the
50
- command's output.
52
+ command's output. So is a JS/TS project where no `package.json` above the
53
+ tests names vitest or a `node --test` script: declare the runner there.
51
54
 
52
55
  Unit and component tests are not scaffolded. `implement-tdd` writes them test
53
56
  first, one example at a time.
54
57
 
58
+ ## Purpose-named test files
59
+
60
+ Where the flow's existing acceptance tests are purpose-named files, each
61
+ carrying its `QFAI:` annotations, run no `npx qfai atdd scaffold` for the
62
+ flow. Write each listed item's test, with an empty body, into an existing or a
63
+ new purpose-named file instead. Where they are not, run the scaffold as
64
+ § Procedure items 2 and 3 say.
65
+
66
+ - A `QFAI:AC-NNNN-NNNN-NN` test goes in a file under `<testsDir>/integration/`
67
+ or `<testsDir>/api/`, and a `QFAI:BF-NNNN` test in one under
68
+ `<testsDir>/e2e/`, as `.qfai/assistant/rule/test-layers.md` routes them. The file must be one
69
+ the configured globs select.
70
+ - An AC or BF annotation counts anywhere in such a file. Put it on the comment
71
+ line directly before the test it marks, so the pass can name that test.
72
+ - Change no existing test in the file: add no assertion, and move or remove no
73
+ annotation already there.
74
+
75
+ The step then passes as Passes when states. Procedure items 1 and 4 still
76
+ apply.
77
+
55
78
  ## Passes when
56
79
 
57
80
  Read first: the BF and AC items of the flow that no `Test exception:` row
@@ -158,7 +158,9 @@ the smallest useful seam and a falsifiable assertion.
158
158
 
159
159
  Where `implement-diagnose` already wrote the failing test for the example, do
160
160
  not write another: annotate that test with the EX ID and run it to confirm it
161
- still fails.
161
+ still fails. Where the Test entry is `CI only: <check name>`, or the user's
162
+ instruction for this run delegates that gate to a named CI check, keep that
163
+ test's `ci-deferred` Red and do not run it.
162
164
 
163
165
  While implementing, run only the selected test. The full suite, Lint,
164
166
  Typecheck, Build and `npx qfai validate` run once, in the verify stage.
@@ -188,7 +190,12 @@ ordinary success. Existing approved alternative RED routes remain available.
188
190
  not an admissible RED. Record command, selector and failure. Follow
189
191
  `.qfai/assistant/skill/qfai-implement/references/red-admissibility.md` and
190
192
  `.qfai/assistant/skill/qfai-implement/references/red-not-observable.md`
191
- when existing behavior prevents an ordinary RED.
193
+ when existing behavior prevents an ordinary RED. Where the Test entry is
194
+ `CI only: <check name>`, or the user's instruction for this run delegates
195
+ that gate to a named CI check, run nothing locally: record Red, Green and
196
+ Refactor `ci-deferred`, quoting that instruction, as
197
+ `.qfai/assistant/skill/qfai-implement/references/red-admissibility.md#ci-only-test-gate`
198
+ states.
192
199
  2. **Green:** Write the minimum production code that makes this test pass.
193
200
  Do not generalize to an untested case. Minimal is measured against the
194
201
  example's obligation, not the test's inputs: a value hard-coded to match
@@ -201,8 +208,12 @@ ordinary success. Existing approved alternative RED routes remain available.
201
208
 
202
209
  For UI-affecting work, follow
203
210
  `.qfai/assistant/skill/qfai-implement/references/ui-affecting.md`; source code
204
- alone does not prove the user-visible result. The route's code review reads
205
- the recorded Red and Green results. Classify its findings as
211
+ alone does not prove the user-visible result. A component test carries only
212
+ `QFAI:EX` annotations: a UI acceptance criterion's `QFAI:AC` annotation goes in
213
+ an integration or API test, and a flow's `QFAI:BF` annotation in an E2E test, as
214
+ `.qfai/assistant/rule/test-layers.md#annotation-routing` states. The route's
215
+ code review reads the recorded Red and Green results, and reads each
216
+ `ci-deferred` test against the code before the fix. Classify its findings as
206
217
  `.qfai/assistant/skill/qfai-implement/references/finding-classification.md`
207
218
  says. A record correction follows `.qfai/assistant/rule/drift-protocol.md`.
208
219
 
@@ -230,11 +241,15 @@ the obligation, test path and selector,
230
241
  RED, GREEN, and Refactor commands and observed results, and open findings.
231
242
  For each focused phase, include the selected-case execution receipt above;
232
243
  command, exit and aggregate counts alone do not establish behavior execution.
244
+ For a `ci-deferred` phase, the test path, its selector and the check name take
245
+ the place of the command, the observed result and the receipt.
233
246
  Evidence without a command and result pair does not prove a gate.
234
247
  A failing or unrun gate cannot be reported as PASS.
235
248
 
236
249
  ## Gate
237
250
 
238
251
  The step is done for an example when its RED, GREEN and Refactor results are
239
- observed and recorded. It is done for the flow when every example the
252
+ observed and recorded, or recorded `ci-deferred` where the Test entry is
253
+ `CI only: <check name>` or the user's instruction for this run delegates that
254
+ gate to a named CI check. It is done for the flow when every example the
240
255
  selection listed is done.