qfai 2.1.2 → 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 (162) hide show
  1. package/README.md +46 -6
  2. package/assets/defaults/agent-routing/qfai-implement.yml +9 -0
  3. package/assets/defaults/agent-routing/qfai-triage.yml +9 -0
  4. package/assets/defaults/workflows/answer-in-session.yml +8 -0
  5. package/assets/defaults/workflows/bump-dependency.yml +4 -1
  6. package/assets/defaults/workflows/decide-design.yml +5 -1
  7. package/assets/defaults/workflows/quarantine-flaky.yml +3 -0
  8. package/assets/defaults/workflows/rename-concept.yml +30 -0
  9. package/assets/defaults/workflows/repair-consistency.yml +1 -0
  10. package/assets/defaults/workflows/resolve-conflicts.yml +14 -0
  11. package/assets/defaults/workflows/retire-feature.yml +26 -0
  12. package/assets/defaults/workflows/run-operation.yml +11 -0
  13. package/assets/defaults/workflows/run-release.yml +12 -0
  14. package/assets/defaults/workflows/write-procedure.yml +18 -0
  15. package/assets/graph/codegraph-native.mjs +174 -0
  16. package/assets/graph/graphify-native.py +72 -0
  17. package/assets/init/.claude/settings.json +11 -29
  18. package/assets/init/.codex/hooks.json +9 -21
  19. package/assets/init/.qfai/assistant/agent/backend-engineer.md +1 -1
  20. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +1 -1
  21. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +5 -0
  22. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +8 -3
  23. package/assets/init/.qfai/assistant/rule/constitution.md +36 -18
  24. package/assets/init/.qfai/assistant/rule/drift-protocol.md +80 -1
  25. package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +27 -0
  26. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +1 -1
  27. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +21 -9
  28. package/assets/init/.qfai/assistant/rule/review-convergence.md +34 -15
  29. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +12 -2
  30. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +14 -7
  31. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +2 -1
  32. package/assets/init/.qfai/assistant/rule/workflow.md +2 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +11 -2
  34. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +32 -10
  35. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +17 -0
  36. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/trend_scan_playbook.md +3 -1
  37. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/01_Context.md +4 -1
  38. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/04_Sources.md +5 -1
  39. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +4 -1
  40. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +30 -20
  41. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +4 -3
  42. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +8 -2
  43. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +9 -2
  44. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +10 -0
  45. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +35 -0
  46. package/assets/init/.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md +445 -0
  47. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +3 -3
  48. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +10 -9
  49. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +33 -2
  50. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +77 -2
  51. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +12 -3
  52. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +3 -1
  53. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +31 -5
  54. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +48 -46
  55. package/assets/init/.qfai/assistant/skill/qfai-run/references/codex-cloud-install.md +80 -0
  56. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +202 -126
  57. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +38 -15
  58. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +48 -22
  59. package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +134 -0
  60. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +7 -4
  61. package/assets/init/.qfai/assistant/skill/qfai-run/scripts/codex-cloud-install.mjs +117 -0
  62. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -1
  63. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -1
  64. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +20 -7
  65. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +2 -2
  66. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +2 -2
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +5 -1
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +2 -2
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +111 -7
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +1 -1
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +58 -8
  72. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +1 -1
  73. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions/page-NNNN.md +6 -0
  74. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +18 -0
  75. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/open-questions.md +13 -0
  76. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +10 -7
  77. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +22 -16
  78. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +1 -1
  79. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +33 -16
  80. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +37 -8
  81. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +25 -4
  82. package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +1 -0
  83. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +68 -15
  84. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +25 -10
  85. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +17 -1
  86. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +23 -3
  87. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +9 -1
  88. package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +3 -0
  89. package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +4 -0
  90. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +33 -3
  91. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +12 -3
  92. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +98 -0
  93. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +21 -4
  94. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +25 -5
  95. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +3 -3
  96. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +26 -0
  97. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +28 -5
  98. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +33 -2
  99. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +20 -5
  100. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +70 -6
  101. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +39 -6
  102. package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +12 -3
  103. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +56 -6
  104. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +13 -0
  105. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +8 -0
  106. package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +9 -4
  107. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +22 -1
  108. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +52 -14
  109. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +2 -2
  110. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +7 -2
  111. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +6 -0
  112. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +123 -0
  113. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +35 -10
  114. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +8 -1
  115. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +40 -0
  116. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +77 -7
  117. package/assets/init/root/.agents/rules/api-budget.md +8 -3
  118. package/assets/init/root/.agents/rules/document-schema.md +17 -0
  119. package/assets/init/root/.agents/rules/documentation-clarity.md +1 -1
  120. package/assets/init/root/.agents/rules/graph-exploration.md +164 -0
  121. package/assets/init/root/.agents/rules/grilling.md +100 -43
  122. package/assets/init/root/.agents/rules/reminders.json +20 -32
  123. package/assets/init/root/.agents/rules/session-feedback.md +6 -11
  124. package/assets/init/root/.agents/rules/untrusted-content.md +2 -2
  125. package/assets/init/root/.agents/rules/user-questions.md +24 -14
  126. package/assets/init/root/.gitattributes +2 -0
  127. package/assets/init/root/.github/workflows/qfai-docs.yml +2 -2
  128. package/assets/init/root/.github/workflows/qfai-tests.yml +88 -35
  129. package/assets/init/root/.github/workflows/qfai-validate.yml +2 -2
  130. package/assets/init/root/AGENTS.md +1 -0
  131. package/assets/mdschema/manifest.yml +3 -0
  132. package/assets/mdschema/story/03_contract/tech.mdschema.yml +1 -1
  133. package/assets/mdschema/story/decisions/page-NNNN.mdschema.yml +32 -0
  134. package/assets/mdschema/story/decisions.mdschema.yml +12 -0
  135. package/assets/schemas/workflow/extraction.schema.json +98 -2
  136. package/assets/schemas/workflow/plan.schema.json +34 -1
  137. package/assets/scripts/check-mdschema.mjs +497 -39
  138. package/dist/cli/index.cjs +7667 -3515
  139. package/dist/cli/index.cjs.map +1 -1
  140. package/dist/cli/index.mjs +8872 -4702
  141. package/dist/cli/index.mjs.map +1 -1
  142. package/dist/graph/cli.cjs +1568 -0
  143. package/dist/graph/cli.cjs.map +1 -0
  144. package/dist/graph/cli.d.cts +9 -0
  145. package/dist/graph/cli.d.ts +9 -0
  146. package/dist/graph/cli.mjs +1541 -0
  147. package/dist/graph/cli.mjs.map +1 -0
  148. package/dist/graph/hook.cjs +817 -0
  149. package/dist/graph/hook.cjs.map +1 -0
  150. package/dist/graph/hook.d.cts +9 -0
  151. package/dist/graph/hook.d.ts +9 -0
  152. package/dist/graph/hook.mjs +792 -0
  153. package/dist/graph/hook.mjs.map +1 -0
  154. package/dist/index.cjs +6436 -3012
  155. package/dist/index.cjs.map +1 -1
  156. package/dist/index.d.cts +185 -1
  157. package/dist/index.d.ts +185 -1
  158. package/dist/index.mjs +6620 -3197
  159. package/dist/index.mjs.map +1 -1
  160. package/dist/process-C21nTvkT.d.cts +12 -0
  161. package/dist/process-C21nTvkT.d.ts +12 -0
  162. package/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: implement-procedure
3
+ owner: qfai-implement
4
+ purpose: Write an authorized operational procedure within existing policy.
5
+ requires: [common-gate-run]
6
+ roles: [doc-steward]
7
+ routing-profile: default
8
+ ---
9
+
10
+ # implement-procedure
11
+
12
+ ## What this is for
13
+
14
+ Write instructions a person can follow within the project's existing policy.
15
+ Do not invent a business flow, code, tests, specifications or contracts to
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.
18
+
19
+ ## Reads
20
+
21
+ - The request and work order: resolve the authorized write scope and target
22
+ documents before editing.
23
+ - The existing policy and procedures governing the actions: preserve their
24
+ authority limits and required checks.
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.
28
+
29
+ ## Before writing
30
+
31
+ If the needed edit belongs to policy, a story, a contract or QFAI assistant
32
+ instructions, stop before writing and name its owning stage. Markdown does not
33
+ confer ownership of those surfaces.
34
+
35
+ If required facts or values are missing, stop the dependent work and report
36
+ what is needed to resume. Never invent values, commands or permission.
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
+
47
+ ## Procedure
48
+
49
+ 1. Identify the inputs, actions, commands, required values, order, failure
50
+ conditions and recovery steps the request needs.
51
+ 2. Check them against existing policy and actual known facts. Write only the
52
+ authorized documents within the work order's scope, and a named
53
+ script only as `## Named scripts` allows.
54
+ 3. Keep the instructions usable: name the actor, prerequisites, expected
55
+ result, stop conditions and recovery for each action.
56
+ 4. Run the applicable document lint and link checks through
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;
67
+ unavailable required checks remain UNRUN with their blocker and resume
68
+ condition. Follow the plan's existing independent code review and closing
69
+ verification stages. When a named script changed, also run its existing
70
+ tests and checks through `common-gate-run` and keep their results.
71
+
72
+ ## Action authority
73
+
74
+ Authoring does not authorize execution. Do not perform publication, deletion,
75
+ login or permission expansion while writing their instructions. Those actions
76
+ need separate authority and their own applicable route. Required values are
77
+ facts to verify, not authority to act.
78
+
79
+ ## Stage report
80
+
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
84
+ performed with their evidence. State that the documented actions were not
85
+ executed; their outcome is unobserved. Record unavailable checks as UNRUN,
86
+ with the blocker, owner and condition for resuming. Static instructions do not
87
+ prove an adopter's operation succeeded.
88
+
89
+ ## Gate
90
+
91
+ The authorized document is complete and consistent with existing policy.
92
+ Applicable lint and link checks have actual results through
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.
98
+ Protected edits and uncovered actions were stopped before writing or acting.
@@ -24,15 +24,29 @@ it.
24
24
 
25
25
  ## Procedure
26
26
 
27
- 1. Show the flakiness: run the test a recorded number of times at one
28
- revision and count the failures. A test that fails every time is not
29
- flaky; stop and report it as failing.
27
+ 1. Show the flakiness: run the test at one revision at least five times,
28
+ record the number of runs and count the failures. A test that fails every
29
+ run is not flaky: see
30
+ [A test that fails every run](#a-test-that-fails-every-run).
30
31
  2. Quarantine it with the project's own mechanism. Add one only where the
31
32
  project has none.
32
33
  3. Keep it running where it blocks nothing, such as a non-gating job, where
33
34
  the project can.
34
35
  4. Change neither what it asserts nor the code it tests. Delete nothing.
35
36
 
37
+ ## A test that fails every run
38
+
39
+ When all of at least five recorded runs fail, nothing is quarantined, no marker
40
+ is written and no non-gating job is added: a skip would hide a failure that is
41
+ real, and a failure rate the runs do not show cannot be invented. With fewer
42
+ runs, or with one passing run, the test is not shown to fail every run, so run
43
+ it again or quarantine it as flaky. Record the runs, their count and the
44
+ failure's signature in the stage report, then report the outcome
45
+ `failing-consistently` with an extraction of the report as a test that fails
46
+ every run, so the decision rules route it again. The stage ends there: the
47
+ stages after it do not run, and the next route's diagnosis and test repair take
48
+ over.
49
+
36
50
  ## What it writes
37
51
 
38
52
  - The changed file path for the quarantine entry or marker, listed in the
@@ -43,4 +57,7 @@ it.
43
57
  ## Gate
44
58
 
45
59
  The step is done when the flakiness is shown by a recorded failure rate, the
46
- test no longer gates, and its quarantine entry states what lifts it.
60
+ test no longer gates, and its quarantine entry states what lifts it. It is also
61
+ done when a test that failed all of at least five recorded runs is reported as
62
+ `failing-consistently`, with the runs in the stage report and nothing
63
+ quarantined.
@@ -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.
@@ -31,9 +31,9 @@ else.
31
31
  3. Re-run the same test. The same test turning GREEN again confirms the fix.
32
32
  4. The fix and the re-run are reported in the stage report.
33
33
 
34
- The route's code review judges the fix. A UI-affecting fix, as
35
- `.qfai/assistant/skill/qfai-implement/references/ui-affecting.md` defines it,
36
- adds the product-surface-reviewer to that review. The full suite and the
34
+ The route's code review judges the fix. A fix that changes a screen, as
35
+ `common-review-cycle`'s reviewer set defines it, adds `product-surface-reviewer`
36
+ to that review. The full suite and the
37
37
  project gates run once, in the verify stage.
38
38
 
39
39
  The example stays annotated by the same test. No `Change request:` row is
@@ -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
@@ -22,9 +22,37 @@ be checked against something more than one lucky run.
22
22
  the failure appears.
23
23
  - The commands of `common-gate-run`, and the test tools the project already
24
24
  carries.
25
+ - Existing Red evidence with its command, signature and revision, and the
26
+ evidence that establishes its cause.
25
27
 
26
28
  ## Procedure
27
29
 
30
+ ### Applicability on entry
31
+
32
+ This step always checks the evidence on entry. Pressure is unnecessary only
33
+ when a prior executed Red reproduces the same failure signature and a verified
34
+ ordinary cause explains it without clock, operation order, parallelism, load,
35
+ timing or race dependence. A verified ordinary cause is one demonstrated with
36
+ fixed inputs and a directly constructed failing state: the test sets up that
37
+ state itself instead of waiting for it, and fails on it. One recorded Red
38
+ cannot show a failure on every run, so cite the recorded Red results, or state
39
+ why the failing state is deterministic. The original report of an intermittent
40
+ failure, a single observed failure or a Red that fails only sometimes is not
41
+ that proof. A fixed seed or controlled schedule that exposes a race is not an
42
+ ordinary cause.
43
+ Uncertainty requires the real harness below. Missing or unexecuted Red,
44
+ another signature or an unknown cause cannot justify omitting pressure.
45
+ Stale or pending CI, unavailable tools, waits and limited time do not supply
46
+ missing proof. A cause found later cannot justify claiming that an earlier
47
+ harness was unnecessary or not performed.
48
+
49
+ When the entry evidence qualifies, build no harness and run no pressure. In
50
+ the stage report, cite the inspected Red and cause evidence, record why load
51
+ or soak is unnecessary, and state that the stress run was not performed. The
52
+ gate checks this applicability reason and its proof; report no stress PASS.
53
+
54
+ ### When a harness is required
55
+
28
56
  1. Pick the cheapest pressure that reaches the failure:
29
57
  - a deterministic schedule: a fixed seed, an injected clock, or a
30
58
  controlled order of the operations that interleave;
@@ -49,5 +77,8 @@ be checked against something more than one lucky run.
49
77
 
50
78
  ## Gate
51
79
 
52
- The step is done when the harness reproduces the reported failure at a
53
- recorded rate, and no production code changed.
80
+ When a harness is required, the step is done when it reproduces the reported
81
+ failure at a recorded rate, and no production code changed.
82
+ For the ordinary-cause case, the entry proof and applicability reason are
83
+ recorded, and no production code changed. No unperformed stress run counts
84
+ as passed.
@@ -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.
@@ -17,7 +17,8 @@ agent does: wording, a typo, a code comment, prose in a document.
17
17
  ## Non-goals
18
18
 
19
19
  - A behaviour change of any size. That is another route's work.
20
- - A story-tree file, a contract, or a row of `decisions.md` or `open-questions.md`.
20
+ - A story-tree file, a contract, or a row of `decisions.md` or `open-questions.md`,
21
+ except as [Resolving conflicts](#resolving-conflicts) allows.
21
22
  - A file outside the write scope the request or the work order gives.
22
23
 
23
24
  ## Never a maintenance edit
@@ -28,7 +29,7 @@ as [A semantic effect](#a-semantic-effect) says:
28
29
  - dependency updates;
29
30
  - workflow and CI files;
30
31
  - authorization conditions and environment settings;
31
- - SQL and generated files;
32
+ - SQL, generated files and lockfiles;
32
33
  - a command a README states as the way to do something;
33
34
  - QFAI's own skills, steps and rules.
34
35
 
@@ -38,6 +39,61 @@ A procedure's actions, required values, commands and order govern what a person
38
39
  does. Changing any of them has a semantic effect, even when only Markdown
39
40
  changes.
40
41
 
42
+ ## Resolving conflicts
43
+
44
+ In the `resolve-conflicts` route, the step merges the named base into the
45
+ branch and keeps every record's meaning. `verify-commit` concludes the merge.
46
+
47
+ 1. Fetch the base (`git fetch`), then on a clean tree, before the merge,
48
+ renumber every `decisions.md` row the branch added, from the lowest one
49
+ whose ID the fetched base now declares upward, lowest first, by the
50
+ `npx qfai sdd renumber-decision` procedure in
51
+ `.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md` (two branches
52
+ taking the same ID), and commit after each run. The union merge of
53
+ `decisions.md` duplicates a colliding ID without a conflict, so this runs
54
+ first. When a merge has already stopped with conflicts, run
55
+ `git merge --abort`, renumber, and merge again.
56
+ 2. Start or resume the merge with `git merge --no-commit <base>`.
57
+ 3. Resolve each conflict. The base's item keeps its ID; never rename it. An
58
+ item the branch added whose ID collides takes the next free ID of its scope,
59
+ with every citation of it. Every other edit only keeps what one side already
60
+ had: what each side added to a conflicting block.
61
+
62
+ Stop before the edit, as [A semantic effect](#a-semantic-effect) says, on any
63
+ of these:
64
+
65
+ - Content neither side had is a semantic effect.
66
+ - When both sides changed the same record, keeping both is a semantic effect:
67
+ stop.
68
+ - An ID that two records already share on one history before this merge,
69
+ carried in by an earlier merge, is a semantic effect: stop.
70
+ - A conflict in code, or in a file listed under
71
+ [Never a maintenance edit](#never-a-maintenance-edit), such as a generated
72
+ file or a lockfile, stops: its owner route resolves or regenerates it.
73
+ - A conflict in a pin or digest file, or in a file with an owner marker or a
74
+ CODEOWNERS entry, stops.
75
+ - After the merge, check each union-merged register, such as `decisions.md`,
76
+ for an ID declared twice. A duplicate is a semantic effect: stop.
77
+
78
+ ### Several branches
79
+
80
+ When the user names several branches to take one base into, each branch is its
81
+ own run of this route, one branch at a time, with every rule above.
82
+
83
+ - Take the base in by merge, never by rebase. Never force-push a branch.
84
+ - On a stop, abort that branch's merge with `git merge --abort`, or keep each
85
+ branch in its own worktree, report the branch at its commit before the merge,
86
+ and go on with the next branch.
87
+ - The verify block repairs no failure on such a branch: a failing gate undoes
88
+ the merge and holds the branch.
89
+ - The route pushes nothing. A push the user's instruction names is planned
90
+ after the run as an order. A branch with a failed or UNRUN gate is not
91
+ pushed. A gate DELEGATED to CI may be pushed under the user's push
92
+ instruction once every gate that runs locally has passed, and the branch is
93
+ not merged until that CI check is green.
94
+ - Report each branch's result: merged locally, pushed, stopped on the named
95
+ file and hunk, or held by the named gate.
96
+
41
97
  ## Reads
42
98
 
43
99
  - The write scope the request or the work order gives.
@@ -51,7 +107,8 @@ itself.
51
107
 
52
108
  1. Read the write scope. Edit nothing outside it.
53
109
  2. Before editing, judge whether each planned edit has a semantic effect: a
54
- changed command, value, identifier, condition or rule. If one has, stop before
110
+ changed command, value, identifier, condition or rule, except a renumber
111
+ [Resolving conflicts](#resolving-conflicts) allows. If one has, stop before
55
112
  editing as [A semantic effect](#a-semantic-effect) says. Do not make the edit.
56
113
  3. Make the edit.
57
114
  4. Run the applicable lint and link checks over the changed files through
@@ -68,12 +125,12 @@ so the run is `blocked`, naming the finding and the owner skill to invoke by nam
68
125
  The session report records:
69
126
 
70
127
  - the semantic effect, affected paths and the review or command that found it;
71
- - that nothing was edited and the `edit-text` run binds no flow;
128
+ - that nothing was edited and this run binds no flow;
72
129
  - the owner skill to invoke by name: `qfai-implement` for code or configuration,
73
130
  or `qfai-sdd` for a story or contract;
74
131
  - the authorized owner route needed before work can resume.
75
132
 
76
- Do not treat a stage of the `edit-text` plan as the owner of this repair.
133
+ Do not treat a stage of this route's plan as the owner of this repair.
77
134
 
78
135
  ## Passes when
79
136
 
@@ -92,10 +149,17 @@ edit changes none. Any other entry under
92
149
  - The no-behaviour-change judgement, with its reason.
93
150
  - The independent review's verdict and who gave it.
94
151
  - The lint and link checks run, and their results.
152
+ - In the `resolve-conflicts` route: the base, each renumber as old → new, and
153
+ the combined diff of each resolved path, taken with `git diff` before it is
154
+ staged, and `git diff` of every path the renumbers touched. Every added line
155
+ is inside one side's text, except the ID changes that list names.
95
156
 
96
157
  ## Gate
97
158
 
98
159
  The diff stays inside the write scope, the no-behaviour-change judgement names
99
160
  its reason, and every check run over the changed files exited 0. The review that
100
161
  follows (`implementation-reviewer`) confirms the diff changes no behaviour; the
101
- reviewer is never the agent that made the edit.
162
+ reviewer is never the agent that made the edit. In the `resolve-conflicts`
163
+ route, that review runs as `common-review-cycle` says: a resolution that
164
+ touches no story-tree file, contract or register row gets no reviewer. The
165
+ combined diff passes the added-line check before `verify-commit` commits.
@@ -18,6 +18,8 @@ settles, by talking, the questions that do not need a prototype to answer.
18
18
  - The specs in the story tree, the UI contracts in scope (see [Scope](#scope))
19
19
  and root `DESIGN.md`.
20
20
  - `.qfai/prototype/grilling.md`, where an earlier run left one.
21
+ - `.qfai/prototype/final/index.html` and `final/handoff.json`, when the request
22
+ scopes the run (see [Run scope](#run-scope)).
21
23
 
22
24
  ## Writes
23
25
 
@@ -48,8 +50,34 @@ Inside an `npx qfai workflow` run the work order narrows that set:
48
50
 
49
51
  A standalone invocation still resolves every UI-bearing UI contract.
50
52
 
51
- The scope floor is unchanged: which UI contracts the loop covers is decided by
52
- their declared IDs and screens, and no session narrows it.
53
+ The scope floor is unchanged, and no session narrows it: its single home is
54
+ `.qfai/assistant/rule/constitution.md` Article VII § Prototyping exception
55
+ (scope floor).
56
+
57
+ ### Run scope
58
+
59
+ A run can rebuild part of a prototype the user already confirmed. The record's
60
+ optional `## Run scope` section names what the run changes, one entry per
61
+ line: a screen as `<ui-contract-id>/<screen>`, or a shared component by its
62
+ repository path or by the `item` that `final/handoff.json` `procurement`
63
+ names for it. Take the entries from the request, settle them in the session,
64
+ and write them afresh each run: a `## Run scope` an earlier run left does not
65
+ carry over.
66
+
67
+ The run covers the whole product, and the session report says so, when:
68
+
69
+ - the record has no `## Run scope`, or an empty one;
70
+ - `.qfai/prototype/final/index.html` is missing, or `final/handoff.json` is
71
+ missing or lacks `finalArtifact` or `procurement`, as the restyle short
72
+ form does;
73
+ - the run is a `restyle` loop.
74
+
75
+ Write no `## Run scope` in any of these cases.
76
+
77
+ Check the earlier `final/` against every declared screen outside the scope: it
78
+ needs a route in `final/index.html` and a `procurement` row. Add each screen
79
+ that lacks either to the scope; when the scope would then hold every screen,
80
+ run the whole product instead.
53
81
 
54
82
  ## What is grilled, and what is prototyped
55
83
 
@@ -97,8 +125,9 @@ user's behalf — with more evidence than before, and still not the user's answe
97
125
  that re-opens a frozen requirement produces an answer that drifts from it.
98
126
  What is left is what the session is for.
99
127
  3. Run the session. **It is delegated** (`.agents/rules/grilling.md` § Two
100
- kinds of session): a griller interviews the agents that generate and review
101
- the prototype, and each decision that is not critical takes its
128
+ kinds of session). The orchestrator starts the griller, never a stage
129
+ worker. The griller interviews the agents that generate and review the
130
+ prototype, and each decision that is not critical takes its
102
131
  recommendation. `DESIGN.md` is frozen from the discussion stage's answers, so
103
132
  a question of taste or purpose it already answers is adopted from it. One it
104
133
  leaves open is product intent, which is critical, and goes to the user.
@@ -119,7 +148,8 @@ and name it.
119
148
  **The session's answers are written down, and the loop reads them.** They go to
120
149
  `.qfai/prototype/grilling.md`, under `## Session` for the decisions
121
150
  — an adopted one names the agent that recommended it and why it was taken —
122
- and `## Escalated` for a critical decision the user has yet to settle. The
151
+ and `## Escalated` for a critical decision the user has yet to settle, plus
152
+ `## Run scope` when the run is scoped (see [Run scope](#run-scope)). The
123
153
  generator and the reviewer both take that file as an input — named in
124
154
  `prototyping-loop`'s `## Evaluator Inputs (Mandatory)` and in the generator's
125
155
  contract set — because a decision the loop cannot read is one it will
@@ -169,4 +199,7 @@ this gate's subject — those are what the loop exists to make answerable, and
169
199
  they are open by design until the user has something to react to.
170
200
 
171
201
  Otherwise the step passes when `.qfai/prototype/grilling.md` exists
172
- with both sections and every row carries a `Scope`.
202
+ with both sections and every row carries a `Scope`. Every `## Run scope`
203
+ entry names a declared screen, or a component (by existing path or
204
+ `procurement` item) that at least one screen in `final/index.html` renders.
205
+ Any other entry stops the run before the first iteration, naming it.
@@ -18,22 +18,30 @@ Runs only after the user confirmed the prototype in `prototyping-loop`.
18
18
  - `.qfai/assistant/skill/qfai-prototyping/references/handoff.md` — the handoff
19
19
  fields.
20
20
  - `.qfai/prototype/grilling.md`, for the completion report.
21
+ - `.qfai/prototype/progress.md`, for `iterationKind` and any `runScope`.
22
+ - In a scoped run, the `final/index.html` and `final/handoff.json` an earlier
23
+ run confirmed, which the merge keeps outside the scope.
21
24
 
22
25
  ## Writes
23
26
 
24
27
  - `.qfai/prototype/final/index.html` — a copy, not a symlink, of the confirmed
25
- iteration.
28
+ iteration, or in a scoped run its in-scope parts merged in, except in a
29
+ `restyle` loop.
26
30
  - `.qfai/prototype/final/handoff.json`, a CLI-HANDOFF record.
27
31
 
28
32
  ## Procedure
29
33
 
30
34
  1. Copy the confirmed iteration to `.qfai/prototype/final/index.html`.
35
+ In a `restyle` loop, copy nothing: the iteration is the live app. In a
36
+ scoped run, replace only the in-scope parts and keep the rest, as the
37
+ handoff reference's Scoped handoff says.
31
38
  2. Write `.qfai/prototype/final/handoff.json` per the handoff reference.
32
39
  3. Write the completion report.
33
40
 
34
41
  ## Gate
35
42
 
36
- The step passes when both files exist. Only `npx qfai validate --profile
43
+ The step passes when both files exist,
44
+ or, in a `restyle` loop, when `handoff.json` exists. Only `npx qfai validate --profile
37
45
  saas-package` checks the handoff record; nothing certifies the prototype.
38
46
 
39
47
  The completion report names:
@@ -41,6 +49,7 @@ The completion report names:
41
49
  - every blocking finding, layout anti-pattern and `DESIGN.md` violation the
42
50
  latest review still lists;
43
51
  - every decision a session adopted, from the `## Session` rows of
44
- `.qfai/prototype/grilling.md`, with why each was taken.
52
+ `.qfai/prototype/grilling.md`, with why each was taken;
53
+ - in a scoped run, the scope the user confirmed.
45
54
 
46
55
  It does not wait for an answer.