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
@@ -22,6 +22,8 @@ run.
22
22
  - The number of runs the quarantine record or the work order names, where one
23
23
  does.
24
24
  - The Test command, through `common-gate-run`.
25
+ - The diagnosis and its executed same-signature Red, and the matching Green (same test and command)
26
+ for the current exact revision.
25
27
 
26
28
  ## Writes
27
29
 
@@ -33,6 +35,38 @@ run.
33
35
 
34
36
  ## Procedure
35
37
 
38
+ ### Applicability on entry
39
+
40
+ This step always checks the diagnosis and test evidence. Only a
41
+ `fix-intermittent` diagnosis of a verified ordinary cause, with a prior
42
+ executed Red of the same failure signature and a matching executed Green for
43
+ the current exact revision, can make repetitions unnecessary. A matching
44
+ Green is the same test, run with the same command as that Red, passing at the
45
+ current exact revision; a different test, a wider suite or another command
46
+ does not match. A verified ordinary cause is one the diagnosis demonstrates
47
+ with fixed inputs and a directly constructed failing state: the test sets
48
+ that state up itself and fails on it before the fix, instead of waiting for
49
+ it or reaching it by chance. One recorded Red cannot show a failure on every
50
+ run, so cite the recorded Red results, or state why the failing state is
51
+ deterministic. The cause must have no clock, operation order,
52
+ parallelism, load, timing or race dependence or uncertainty. A fixed seed or
53
+ deterministic schedule exposing a race does not qualify. Quarantine never
54
+ uses this case: lifting one always requires the actual consecutive runs
55
+ below.
56
+
57
+ Missing or unexecuted Red, another signature, a Green that is not the same
58
+ test and command, stale Green, pending CI, an unknown cause or unresolved
59
+ timing or load uncertainty require the real runs.
60
+ Unavailable tools, waits or limited time do not make repetitions unnecessary.
61
+ When the evidence qualifies, cite the inspected diagnosis, prior Red and
62
+ current Green, including their commands, results and revisions, in the stage
63
+ report, with the applicability reason and why load or soak is unnecessary.
64
+ State that repeat runs were not performed. The gate
65
+ checks this proof and reason; report no repeat-run PASS. A later cause never
66
+ changes the earlier record of what ran.
67
+
68
+ ### When repeated runs are required
69
+
36
70
  1. Fix the number of runs before the first one, and record it with its reason.
37
71
  Where nothing names a number, take at least three divided by the failure
38
72
  rate the diagnosis measured, so a failure that rate predicts would show.
@@ -50,6 +84,12 @@ run.
50
84
 
51
85
  ## Gate
52
86
 
87
+ When repeated runs are required:
88
+
53
89
  - The number of runs was fixed and recorded before the first run.
54
90
  - Every run is recorded, and all of them passed on the same revision.
55
91
  - A lifted quarantine removed only its marker and its record.
92
+
93
+ For the ordinary `fix-intermittent` case, the inspected diagnosis, prior Red,
94
+ current exact-revision Green and applicability reason are recorded. No
95
+ unperformed repetitions count as passed, and no quarantine is lifted.
@@ -45,10 +45,19 @@ commands entry named after the colon:
45
45
  7. build/package (if relevant): `Build`
46
46
  8. pack/verify (if distributed): `Pack / distribution`
47
47
 
48
- Run listed commands and record outputs. A gate whose Standard commands entry
49
- is `CI only: <check name>` is not run here: record it `DELEGATED` with that
50
- check name. This requires an actual CI check covering the same gate and scope;
51
- local environment failure alone creates no delegation. Retain observed FAIL or
48
+ Run listed commands and record outputs. A gate that looks unrelated to the
49
+ change is still run and its result recorded; `verify.json` has no status for a
50
+ gate that does not apply to the change. A conditional gate whose condition is
51
+ false is left out of `gates` with its reason, as `common-gate-run` step 1
52
+ says. A gate is not run here, and is recorded `DELEGATED` with its check name,
53
+ when its Standard commands entry is `CI only: <check name>`, or when the
54
+ user's instruction for this run delegates that gate to a named CI check. A delegation by
55
+ instruction holds for this run only and is recorded as `## Report` says. A
56
+ standing instruction in the project's agent instructions counts for each run it
57
+ is in force; quote it. Either delegation requires an actual CI check covering
58
+ the same gate and scope;
59
+ local environment failure alone creates no delegation, and the agent never
60
+ delegates a gate on its own judgment. Retain observed FAIL or
52
61
  UNRUN results. Where the environment cannot run any other command, ask the user
53
62
  to run it and provide the output. Never assume PASS without evidence.
54
63
 
@@ -80,6 +89,9 @@ one code review reads the repair, as `qfai-verify`'s `## Review` section says.
80
89
  `/qfai-sdd` or `/qfai-implement`.
81
90
  - A fix made after the code review is listed in the final report with its
82
91
  diff. No review runs again.
92
+ - In a `resolve-conflicts` run for one of several branches, the fix loop
93
+ repairs nothing: a failing gate undoes the merge (`git merge --abort`, or
94
+ `git reset --merge ORIG_HEAD` after the commit), and the branch is held.
83
95
 
84
96
  ## Report
85
97
 
@@ -96,9 +108,17 @@ check, actual outcome and counts, blocker and resume condition. If no run exists
96
108
  record that fact. A result for another head does not pass this head; a missing
97
109
  or mismatched result remains pending. Keep earlier failures visible.
98
110
 
111
+ For a gate delegated by instruction, the stage report quotes the user's
112
+ instruction word for word and says where it came from: this request, an answer
113
+ to a question, or the project's agent instructions. It names the gate, the
114
+ check and its state with the quote. `verify.json` carries only `check` and
115
+ `ci`, and its `summary` says "delegated by user instruction". If no instruction
116
+ can be quoted, the gate is not delegated.
117
+
99
118
  Name pending checks in `summary` and the stage report. A covered verification
100
119
  commit may use the existing DELEGATED allowance in `verify-commit`; it does not
101
- complete verification. With explicit CI-only delegation covering transport,
120
+ complete verification. With explicit delegation (CI-only or by instruction)
121
+ covering transport,
102
122
  actual changes addressing a failed check through the existing planned fix may
103
123
  be committed while HEAD still names the failing commit. Every nondelegated gate
104
124
  must pass. Retain the prior head, check, run and observed result as FAIL, and
@@ -162,6 +182,29 @@ required during each focused cycle. Record these facts in the existing human
162
182
  report; add no permanent inventory, ledger, JSON field, gate status, runtime
163
183
  parser or runner.
164
184
 
185
+ ### Run report
186
+
187
+ When the report cites test runner results, record these items in the human
188
+ report for each layer the gates ran:
189
+
190
+ | Item | Record |
191
+ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
192
+ | Revision and run | What the CI receipt in `.qfai/assistant/step/common-gate-run/STEP.md#ci-evidence` lists, and the deployed source when a test reaches a deployment, with any difference from that commit. |
193
+ | Counts per layer | For each layer, such as unit, integration or API, E2E and device: the runner, the command, and the collected, passed, failed and skipped counts, with the report file each count came from. |
194
+ | Skips | Each skipped case with its reason, and whether the skip is intended for this run, such as a case that runs only on the default branch. |
195
+ | Fresh or cached | Whether each layer ran in this run or was restored from a cache. A result restored from a cache names the run that produced it and is not reported as a fresh execution. |
196
+ | Retries | A retried case counts once, with its final outcome and the number of attempts. |
197
+ | Support cases | Setup, teardown and fixture cases, counted apart from the cases that check behavior. |
198
+ | UNKNOWN and UNRUN | A count no report establishes is UNKNOWN. A layer that did not run, whose report is missing, or that collected no cases is UNRUN with its reason, such as a test that needs a physical device. Neither is a pass. |
199
+
200
+ These items say what ran, not what is covered. An annotation, an assertion and a
201
+ passing case do not prove every clause of a requirement. Where the report states
202
+ the semantic coverage of a requirement, state it apart from the run report, and
203
+ do not mark a requirement covered because its annotated test passed.
204
+
205
+ A layer recorded UNRUN here is UNRUN for the gate that covers it, under
206
+ `## Verdict` and `## A missing environment`; this recipe changes no gate status.
207
+
165
208
  ## Verdict
166
209
 
167
210
  Write `.qfai/report/verify.json` at the end of the run. It is the
@@ -175,11 +218,26 @@ pending delegated checks permit only that transport, never formal completion;
175
218
  they do not replace the earlier failed result. Keep revision and run evidence
176
219
  in the stage report, without adding verdict fields or states.
177
220
  `scope` is the gate set `verify-qfai-gate` covered through execution or an
178
- explicitly declared matching CI-only check, never a stage this run did not
221
+ matching delegated (CI-only or by instruction) check, never a stage this run did not
179
222
  cover. Delegation does not claim that its validation profile has already run. Fields, the closed `scope` enum, a conforming example and what must
180
223
  never be written are in
181
224
  `.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md`.
182
225
 
226
+ ## After CI
227
+
228
+ Compare a CI result against the verification commit made from the tree the
229
+ verdict covers: the commit `verify-commit` names. When a delegated check's
230
+ result is observed for that commit, update `.qfai/report/verify.json`:
231
+
232
+ - set that gate's `ci` to the observed state;
233
+ - the gate stays `DELEGATED` and is never rewritten `PASS`;
234
+ - set `status` again from every gate by the `## Verdict` rule, so a red check
235
+ makes it `"FAIL"` and a later green rerun on the same commit clears that `FAIL`.
236
+
237
+ Name the run, check and commit in the stage report. A result for another
238
+ commit changes nothing. Formal completion still needs every required check
239
+ green on the current head.
240
+
183
241
  ## Stage report
184
242
 
185
243
  Inside an `npx qfai workflow` run, the stage runs every required gate over the
@@ -192,7 +250,7 @@ run's change and reports each result.
192
250
  shared location is never named as this stage's report.
193
251
  - Report the stage's completion or stop separately from actual test and gate
194
252
  observations. A required gate that did not run is UNRUN, never a pass.
195
- - A gate the project runs in CI only is DELEGATED, with its check name and
253
+ - A gate delegated (CI-only or by instruction) is DELEGATED, with its check name and
196
254
  observed CI status.
197
255
 
198
256
  Keep these details in the stage report and session handoff. `verify.json`
@@ -230,6 +288,18 @@ its `reason`. The top-level `status` stays `"FAIL"`, so the run stops before
230
288
  `verify-commit`. The final report lists each such gate apart from the failures
231
289
  the run caused, so the user can decide whether to commit.
232
290
 
291
+ For a gate with baseline `same`, `reason` names the failing test identifiers
292
+ and the environment they fail in. The identifiers are the ones observed failing
293
+ in the base commit's run, executed as `common-gate-run`'s
294
+ `## A failure that predates the change` says, never assumed. The stage report
295
+ adds how to confirm it: the base commit's result, and the result of the same
296
+ gate in CI when a check covers it, with the run or check named. A CI result that
297
+ was not observed is written as unknown, never as a pass. The report ends by
298
+ asking the user whether to commit with those gates open, as
299
+ `.agents/rules/user-questions.md` says; nothing is committed before the answer.
300
+ Under a no-question mode, or with no question tool, the report lists those gates
301
+ as open and stops without committing.
302
+
233
303
  ## Gate
234
304
 
235
305
  The step is done when:
@@ -264,14 +264,19 @@ by hand under the rules above, and a project that writes one names it here.
264
264
  ## The reminder
265
265
 
266
266
  `.claude/settings.json` and `.codex/hooks.json` put this rule in front of the
267
- agent before a shell command, through a `PreToolUse` hook matching `Bash`.
267
+ agent before a shell command, through a `PreToolUse` hook matching `Bash` and,
268
+ in Claude Code, `PowerShell`.
268
269
 
269
270
  `documentation-clarity.md` keeps its own hook off the shell, and that decision
270
271
  stands: a matcher on the tool name alone fires on every compound command, and a
271
272
  reminder about writing would arrive in front of work that has nothing to do with
272
273
  it. This hook takes the same matcher and then reads the command, printing only
273
- where the command mentions the forge's CLI or its API host. The filter is in the
274
- program rather than in the matcher, which is the whole of the difference.
274
+ where the command runs a network client: `gh`, `curl`, `wget`,
275
+ `Invoke-WebRequest`, `Invoke-RestMethod`, `iwr` or `irm`, or names the forge's
276
+ API host, as a script's own request does. The filter is in the program rather
277
+ than in the matcher, which is the whole of the difference. It
278
+ prints on the first such command of a session and not again; input that names
279
+ no session prints it every time.
275
280
 
276
281
  It reminds and never blocks. Claude Code runs `node` directly, with no shell and
277
282
  no network. Codex runs the same filter as one command line, the same under
@@ -61,6 +61,23 @@ Both run the checker the installed package carries, against its schemas, with
61
61
  the `@jackchuka/mdschema` version the package depends on. Neither can be
62
62
  switched off in `qfai.config.yaml`.
63
63
 
64
+ To run the lane's two checks before you push, install the checkers into
65
+ `tmp/qfai-docs-tools` with the `npm install` line of the step
66
+ "Install the document-shape and diagram checkers" in `qfai-docs.yml` that
67
+ matches your project: the line for a project with its own `node_modules/qfai`,
68
+ or the line for one without it. That line pins the versions the lane uses. Then
69
+ run the two commands the lane runs:
70
+
71
+ ```bash
72
+ node node_modules/qfai/assets/scripts/check-mdschema.mjs --tools tmp/qfai-docs-tools --scope all --summary
73
+ node node_modules/qfai/assets/scripts/check-mermaid.mjs --tools tmp/qfai-docs-tools
74
+ ```
75
+
76
+ A project with no `node_modules/qfai` of its own runs the script from
77
+ `tmp/qfai-docs-tools/node_modules/qfai/assets/scripts/` instead, as the lane
78
+ does. `npx qfai validate` already reports the shape violations; the Mermaid
79
+ check is the one only this install provides.
80
+
64
81
  ## 8. What a schema cannot say
65
82
 
66
83
  A schema reads structure. A cell's value, the content of a fenced block, and
@@ -255,7 +255,7 @@ rule still applies.
255
255
  The `gh` command line is out of scope. A shell-argument condition also matches
256
256
  compound commands that have nothing to do with GitHub, which would put the
257
257
  reminder in front of unrelated work. The standard reaches the agent through
258
- `CLAUDE.md` and `AGENTS.md` either way.
258
+ `AGENTS.md` either way.
259
259
 
260
260
  ## Scope of this file
261
261
 
@@ -0,0 +1,164 @@
1
+ # Graph exploration
2
+
3
+ Use the project graph CLIs for exploratory searches once they are ready. Run
4
+ `qfai init` to prepare or repair the project-local runtimes, CLI and denial
5
+ hooks. This integration registers and launches no graph MCP server.
6
+
7
+ ## While the graph tools are not ready
8
+
9
+ When `qfai init` or the graph CLI reports an engine as not ready, use ordinary
10
+ search for the questions that engine answers. Do the same when search
11
+ protection is reported as unsupported for your host. Say in your report that
12
+ the graph was not used and why. When a supported hook denies the search, use
13
+ the fallback command in "Direct search and result limits" below. Retry once
14
+ the cause is fixed; for a failed download, run the command `qfai init` names to
15
+ see the cause.
16
+
17
+ ## Choose the first engine
18
+
19
+ | Question | First engine |
20
+ | ----------------------------------------------------------- | ------------ |
21
+ | Symbols, callers, imports, dependencies or change impact | CodeGraph |
22
+ | Requirements, specifications, decisions or design rationale | Graphify |
23
+
24
+ Run the managed command for the selected engine:
25
+
26
+ ```sh
27
+ node .qfai/tools/graph-cli.mjs code "your code question"
28
+ node .qfai/tools/graph-cli.mjs documents "your document question"
29
+ ```
30
+
31
+ The CLI checks native freshness, prepares required analysis where possible and
32
+ retries its query. Each command exits after returning evidence or an actionable
33
+ failure; it uses no daemon or IPC.
34
+
35
+ Read an exact known source path directly. A known-file read grants no general
36
+ search exception. Use a second engine only for a specific unresolved question
37
+ that crosses from code to documents or documents to code. A complete answer
38
+ needs no second engine, watcher or continuous synchronization.
39
+
40
+ ## Processing and readiness
41
+
42
+ Installed tools do not establish current analysis or search protection.
43
+ Inspect code, document and host readiness separately. Configure document
44
+ processing explicitly before extraction. Ambient API credentials choose no
45
+ provider and authorize no external transmission or paid processing.
46
+
47
+ Local processing is the default. An external destination requires explicit
48
+ human approval of that destination and document scope. A completed, compatible,
49
+ current document graph may be queried without a model. Code-only Graphify
50
+ analysis does not establish document readiness.
51
+
52
+ ### Configure local document analysis
53
+
54
+ Create `.qfai/graph-processing.json` with the local server and model you chose:
55
+
56
+ ```json
57
+ {
58
+ "backend": "ollama",
59
+ "model": "your-installed-model",
60
+ "endpoint": "http://127.0.0.1:11434/v1",
61
+ "scope": ["docs"]
62
+ }
63
+ ```
64
+
65
+ Replace `model` with a model you already installed. Set `scope` to the existing
66
+ project files or directories you want to analyze. Paths are relative to this
67
+ worktree. Start your selected local server, then retry the documents CLI
68
+ command. The CLI prepares missing analysis with these settings. QFAI
69
+ does not install or choose a model for you.
70
+ The quality of document answers depends on the model you select, and QFAI
71
+ does not evaluate it. Check important answers against their cited sources.
72
+
73
+ The supported backend names are `ollama` and `openai`. An `openai` backend can
74
+ also use a compatible local endpoint. Keep credentials out of this file. When
75
+ the selected server requires a key, set `credentialEnv` to the name of an
76
+ environment variable containing it. An external endpoint still requires human
77
+ authorization of the exact destination and scope before processing.
78
+
79
+ ### Authorize external document analysis
80
+
81
+ Set the selected `backend`, `model`, `endpoint` and exact `scope` in the same
82
+ file. The ordinary graph CLI does not approve external transmission. Run a
83
+ Node script such as this yourself in an interactive terminal:
84
+
85
+ ```js
86
+ import { prepareDocumentAnalysis } from "qfai";
87
+ import { createInterface } from "node:readline/promises";
88
+ import { stdin, stdout } from "node:process";
89
+
90
+ if (!stdin.isTTY || !stdout.isTTY) {
91
+ throw new Error("Use an interactive terminal to review document transmission.");
92
+ }
93
+ const prompt = createInterface({ input: stdin, output: stdout });
94
+ try {
95
+ const result = await prepareDocumentAnalysis(process.cwd(), undefined, async (request) => {
96
+ stdout.write(JSON.stringify(request, null, 2) + "\n");
97
+ return (await prompt.question("Allow this document transmission? Type yes: ")).trim() === "yes";
98
+ });
99
+ console.log(result);
100
+ } finally {
101
+ prompt.close();
102
+ }
103
+ ```
104
+
105
+ Review the displayed worktree, destination, backend, model and document scope
106
+ before answering. The AI must not supply this approval or pipe a response.
107
+ An omitted or refusing authorization callback starts no external processing.
108
+ After preparation succeeds, retry the documents CLI. A changed scope requiring
109
+ new external processing needs this review again. Search fallback grants no
110
+ document-transmission permission.
111
+
112
+ Exclude secret files from both engines and generated storage. Keep credentials
113
+ out of tracked integration settings, logs and reusable analysis.
114
+
115
+ ## Direct search and result limits
116
+
117
+ Supported pre-tool hooks deny direct exploratory search and display the
118
+ appropriate graph CLI command and a pending attempt UUID. Build, test, lint and
119
+ graph-engine internals remain permitted. Hooks only classify, deny and save
120
+ bounded pending state; they perform no graph query, preparation, network
121
+ request or model call. The graph CLI never runs raw search itself.
122
+
123
+ When the AI judges that the graph cannot answer, run the fallback command with
124
+ the pending UUID displayed by the denied action:
125
+
126
+ ```sh
127
+ node .qfai/tools/graph-cli.mjs fallback --attempt-id "UUID-from-denial" --question "unresolved question" --reason "why the graph cannot answer"
128
+ ```
129
+
130
+ The CLI derives immutable target, operation, worktree, session and domain from
131
+ the pending attempt. It attempts the relevant graph itself, prepares required
132
+ analysis where possible and requeries before saving permission. Partial,
133
+ not-ready or failed results can still leave an unresolved question. State the
134
+ actual limitation; the CLI does not verify the reason's semantic truth.
135
+
136
+ Permission lasts exactly 60 seconds and matches only the observed target and
137
+ operation in the same worktree and session, strictly before expiry. No human
138
+ search approval is needed. Manual scope overrides and missing, invalid,
139
+ expired or mismatched state grant nothing. State-management failures grant
140
+ nothing. Correct the reported cause and retry the denied action when a new
141
+ pending attempt is required. Search fallback authorizes no external document
142
+ transmission.
143
+
144
+ Configuration alone proves no blocking. Trust and runtime behavior are checked
145
+ per host, version and event set. Hidden scripts, aliases and continuing shell
146
+ input remain outside the proven boundary unless separately demonstrated.
147
+
148
+ Report unparsed, unsupported, unreadable and incomplete scope separately from
149
+ no matches. Label inferred relationships and retain source locations. Incomplete
150
+ coverage does not establish absence or semantic correctness.
151
+
152
+ ## Local reuse
153
+
154
+ Keep generated runtimes, databases, graphs, manifests and caches outside Git.
155
+ Reuse only compatible, completed local analysis from the same repository and
156
+ machine. Restore independent writable copies and check native freshness before
157
+ querying. Worktrees share no live writable analysis, process, socket or lock.
158
+ Restoration is proven only on Windows x64, for CodeGraph on Node.js 24.16.0
159
+ and for Graphify on Python 3.12.13. Other platforms, architectures and
160
+ runtime versions are unverified and use local generation instead.
161
+
162
+ Each worktree serializes CLI queries and preparation with its own local lock.
163
+ Contention reports retry; an abandoned lock reports manual recovery. Do not
164
+ delete another operation's lock automatically.