qfai 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +56 -36
  2. package/assets/defaults/agent-routing/qfai-implement.yml +9 -0
  3. package/assets/defaults/agent-routing/qfai-triage.yml +18 -0
  4. package/assets/defaults/workflows/answer-in-session.yml +8 -0
  5. package/assets/defaults/workflows/quarantine-flaky.yml +3 -0
  6. package/assets/defaults/workflows/repair-consistency.yml +1 -0
  7. package/assets/defaults/workflows/run-operation.yml +11 -0
  8. package/assets/defaults/workflows/run-owned-cleanup.yml +12 -0
  9. package/assets/defaults/workflows/write-procedure.yml +18 -0
  10. package/assets/graph/codegraph-native.mjs +174 -0
  11. package/assets/graph/graphify-native.py +72 -0
  12. package/assets/init/.claude/settings.json +9 -9
  13. package/assets/init/.codex/hooks.json +8 -8
  14. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +5 -0
  15. package/assets/init/.qfai/assistant/agent/product-experience-architect.md +4 -0
  16. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +7 -0
  17. package/assets/init/.qfai/assistant/agent/requirements-analyst.md +8 -0
  18. package/assets/init/.qfai/assistant/rule/communication.md +18 -8
  19. package/assets/init/.qfai/assistant/rule/constitution.md +31 -15
  20. package/assets/init/.qfai/assistant/rule/drift-protocol.md +119 -2
  21. package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +6 -4
  22. package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +27 -0
  23. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +21 -9
  24. package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +48 -0
  25. package/assets/init/.qfai/assistant/rule/review-convergence.md +25 -12
  26. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +16 -25
  27. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +16 -11
  28. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +6 -1
  29. package/assets/init/.qfai/assistant/rule/workflow.md +2 -1
  30. package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +3 -3
  31. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +6 -0
  32. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +20 -15
  33. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +2 -4
  34. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux_best_practices.md +1 -6
  35. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +0 -16
  36. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +30 -20
  37. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +4 -3
  38. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +8 -2
  39. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +16 -3
  40. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +9 -1
  41. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +46 -0
  42. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +5 -2
  43. package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +3 -3
  44. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +12 -6
  45. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +1 -265
  46. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +273 -0
  47. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +4 -3
  48. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +2 -3
  49. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +17 -1
  50. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +52 -37
  51. package/assets/init/.qfai/assistant/skill/qfai-run/references/codex-cloud-install.md +80 -0
  52. package/assets/init/.qfai/assistant/skill/qfai-run/references/evidence-delivery.md +322 -0
  53. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +83 -49
  54. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +226 -11
  55. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +6 -3
  56. package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +132 -0
  57. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +14 -0
  58. package/assets/init/.qfai/assistant/skill/qfai-run/scripts/codex-cloud-install.mjs +117 -0
  59. package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +4 -3
  60. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -0
  61. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-anti-patterns.md +23 -5
  62. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +20 -7
  63. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/requirements-decomposition.md +8 -0
  64. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +29 -4
  65. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +1 -1
  66. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +4 -1
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +1 -1
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +159 -4
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +14 -2
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +146 -0
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-design-contract-normalization.md +4 -29
  72. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +38 -1
  73. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/ui-contract.sample.yaml +52 -5
  74. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +12 -0
  75. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +34 -21
  76. package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +5 -4
  77. package/assets/init/.qfai/assistant/skill/qfai-verify/references/context-load.md +9 -6
  78. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +80 -15
  79. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +35 -21
  80. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/config.toml +2 -4
  81. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/mcp-config.json +9 -5
  82. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/.mcp.json +1 -2
  83. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/config.toml +3 -3
  84. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/mcp-config.json +11 -8
  85. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/config.toml +1 -1
  86. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/mcp-config.json +7 -3
  87. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +33 -20
  88. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +124 -8
  89. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +10 -2
  90. package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +1 -0
  91. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +26 -9
  92. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +15 -8
  93. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +5 -1
  94. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +6 -1
  95. package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +2 -0
  96. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +6 -4
  97. package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +1 -1
  98. package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +7 -4
  99. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +11 -2
  100. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +2 -0
  101. package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +2 -2
  102. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +69 -0
  103. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +24 -7
  104. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +2 -2
  105. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +7 -6
  106. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +6 -3
  107. package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +4 -3
  108. package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +6 -5
  109. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +34 -3
  110. package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +4 -3
  111. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +39 -5
  112. package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +22 -2
  113. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +18 -14
  114. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +4 -3
  115. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +4 -0
  116. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +9 -3
  117. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +11 -0
  118. package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +2 -0
  119. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +10 -0
  120. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +34 -10
  121. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +7 -6
  122. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +33 -23
  123. package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +5 -3
  124. package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +2 -0
  125. package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +4 -0
  126. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +13 -4
  127. package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +8 -5
  128. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +50 -0
  129. package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +86 -0
  130. package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +2 -0
  131. package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +6 -3
  132. package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +1 -0
  133. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +37 -9
  134. package/assets/init/.qfai/assistant/step/verify-external/STEP.md +5 -2
  135. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +14 -16
  136. package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +1 -0
  137. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +46 -4
  138. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +133 -30
  139. package/assets/init/root/.agents/rules/ai-readable-markdown.md +2 -2
  140. package/assets/init/root/.agents/rules/api-budget.md +187 -8
  141. package/assets/init/root/.agents/rules/document-schema.md +17 -0
  142. package/assets/init/root/.agents/rules/documentation-clarity.md +163 -34
  143. package/assets/init/root/.agents/rules/graph-exploration.md +150 -0
  144. package/assets/init/root/.agents/rules/grilling.md +100 -43
  145. package/assets/init/root/.agents/rules/minimal-implementation.md +3 -3
  146. package/assets/init/root/.agents/rules/reminders.json +27 -18
  147. package/assets/init/root/.agents/rules/session-feedback.md +131 -0
  148. package/assets/init/root/.agents/rules/temporary-files.md +33 -0
  149. package/assets/init/root/.agents/rules/untrusted-content.md +2 -2
  150. package/assets/init/root/.agents/rules/user-questions.md +51 -40
  151. package/assets/init/root/.github/workflows/qfai-docs.yml +3 -3
  152. package/assets/init/root/.github/workflows/qfai-tests.yml +88 -35
  153. package/assets/init/root/.github/workflows/qfai-validate.yml +2 -2
  154. package/assets/init/root/AGENTS.md +24 -22
  155. package/assets/sandbox-templates/default-deny.yaml +9 -3
  156. package/assets/schemas/workflow/extraction.schema.json +89 -5
  157. package/assets/scripts/check-mdschema.mjs +77 -8
  158. package/assets/uix-rev/comparison-review.md +1 -1
  159. package/assets/uix-rev/contracts-review.md +1 -2
  160. package/dist/cli/index.cjs +9444 -10071
  161. package/dist/cli/index.cjs.map +1 -1
  162. package/dist/cli/index.mjs +9421 -10041
  163. package/dist/cli/index.mjs.map +1 -1
  164. package/dist/graph/cli.cjs +1568 -0
  165. package/dist/graph/cli.cjs.map +1 -0
  166. package/dist/graph/cli.d.cts +9 -0
  167. package/dist/graph/cli.d.ts +9 -0
  168. package/dist/graph/cli.mjs +1541 -0
  169. package/dist/graph/cli.mjs.map +1 -0
  170. package/dist/graph/hook.cjs +817 -0
  171. package/dist/graph/hook.cjs.map +1 -0
  172. package/dist/graph/hook.d.cts +9 -0
  173. package/dist/graph/hook.d.ts +9 -0
  174. package/dist/graph/hook.mjs +792 -0
  175. package/dist/graph/hook.mjs.map +1 -0
  176. package/dist/index.cjs +7634 -8517
  177. package/dist/index.cjs.map +1 -1
  178. package/dist/index.d.cts +146 -658
  179. package/dist/index.d.ts +146 -658
  180. package/dist/index.mjs +7462 -8318
  181. package/dist/index.mjs.map +1 -1
  182. package/dist/process-C21nTvkT.d.cts +12 -0
  183. package/dist/process-C21nTvkT.d.ts +12 -0
  184. package/package.json +4 -6
  185. package/assets/init/root/CLAUDE.md +0 -46
@@ -17,6 +17,7 @@ Drafts what a user reads about a release. It releases nothing.
17
17
  - The changes merged since the last release, from the history.
18
18
  - The format the project's earlier release notes use.
19
19
  - The version the user named, if any.
20
+ - `.agents/rules/documentation-clarity.md`, when writing the prose this step produces.
20
21
 
21
22
  ## Writes
22
23
 
@@ -22,16 +22,51 @@ 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
 
28
30
  - In the stage report: the number of runs and why, then
29
31
  every run in order, each with its command, result and revision.
30
32
  - Where the runs lift a quarantine: the removal of the quarantine marker and
31
- record the quarantine added, and nothing else.
33
+ record the quarantine added, and nothing else. Name the removed paths in the
34
+ stage report.
32
35
 
33
36
  ## Procedure
34
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
+
35
70
  1. Fix the number of runs before the first one, and record it with its reason.
36
71
  Where nothing names a number, take at least three divided by the failure
37
72
  rate the diagnosis measured, so a failure that rate predicts would show.
@@ -41,13 +76,20 @@ run.
41
76
  reporting, as
42
77
  `.qfai/assistant/rule/references/gate-failure-autorepair.md#nondeterministic-gates`
43
78
  says.
44
- 4. One failure ends the step. Inside a run, return `needs_repair` with the
45
- failure in `debts`, owned by the skill that owns the failing test's layer or
46
- the code it exercises. The count starts again only after a new fix.
79
+ 4. One failure ends the step. Inside a run, return `needs_repair`. Record
80
+ the failed run and its evidence in the stage report, with the skill that
81
+ owns the failing test's layer or code as the repair owner. The count starts
82
+ again only after a new fix.
47
83
  5. When every run passed, lift the quarantine where there is one.
48
84
 
49
85
  ## Gate
50
86
 
87
+ When repeated runs are required:
88
+
51
89
  - The number of runs was fixed and recorded before the first run.
52
90
  - Every run is recorded, and all of them passed on the same revision.
53
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.
@@ -25,7 +25,8 @@ Create and update `.qfai/report/verify.json`.
25
25
 
26
26
  ## Procedure
27
27
 
28
- 1. Run the repository gates (below).
28
+ 1. Determine the applicable repository gates through `common-gate-run` before
29
+ resolving their commands, then run those gates (below).
29
30
  2. Run the fix loop until every gate in scope passes, or stop as it says.
30
31
  3. Report the result.
31
32
  4. Write the verdict.
@@ -46,8 +47,10 @@ commands entry named after the colon:
46
47
 
47
48
  Run listed commands and record outputs. A gate whose Standard commands entry
48
49
  is `CI only: <check name>` is not run here: record it `DELEGATED` with that
49
- check name. Where the environment cannot run any other command, ask the user to
50
- run it and provide the output. Never assume PASS without evidence.
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
52
+ UNRUN results. Where the environment cannot run any other command, ask the user
53
+ to run it and provide the output. Never assume PASS without evidence.
51
54
 
52
55
  ## Fix loop
53
56
 
@@ -83,55 +86,141 @@ one code review reads the repair, as `qfai-verify`'s `## Review` section says.
83
86
  Report the scope, every gate command with its result, the open risks and the
84
87
  next actions.
85
88
 
89
+ For CI results, keep the full receipt in the stage report as
90
+ `.qfai/assistant/step/common-gate-run/STEP.md#ci-evidence` requires. A branch
91
+ overview and a confirmed closed cleanup SKIP do not replace actual verification.
92
+
93
+ For a `DELEGATED` gate, record `check` and `ci` (`green`, `red` or `pending`).
94
+ In the stage report, bind evidence to the target and current head: run ID or URL,
95
+ check, actual outcome and counts, blocker and resume condition. If no run exists,
96
+ record that fact. A result for another head does not pass this head; a missing
97
+ or mismatched result remains pending. Keep earlier failures visible.
98
+
99
+ Name pending checks in `summary` and the stage report. A covered verification
100
+ commit may use the existing DELEGATED allowance in `verify-commit`; it does not
101
+ complete verification. With explicit CI-only delegation covering transport,
102
+ actual changes addressing a failed check through the existing planned fix may
103
+ be committed while HEAD still names the failing commit. Every nondelegated gate
104
+ must pass. Retain the prior head, check, run and observed result as FAIL, and
105
+ report the actual fix and new head after committing. Never relabel the prior
106
+ failure pending or transport the same unchanged red candidate. The new candidate
107
+ remains unverified until its own results are observed; report a missing run as
108
+ missing. Formal completion or merge requires actual passing results for every
109
+ required check on the current target and head. Pending, red, missing or
110
+ mismatched evidence stops completion. Repair follows the existing
111
+ fix procedure under its own covered authority.
112
+
113
+ ### Acceptance evidence and follow-up
114
+
115
+ When implementation, verification or handoff scope includes acceptance scaffolds
116
+ or unfinished BF/AC acceptance bodies, include these five fields in the human
117
+ report. A lint-only scope without these bodies needs no acceptance report.
118
+
119
+ | Field | Report |
120
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121
+ | Annotation proof | BF/AC annotation IDs, their test files and the inspection or validation result that established them. |
122
+ | Acceptance bodies | Empty, implemented and unclassified body counts, with each counting unit and file references. Keep BF test bodies and AC test bodies separate; test bodies are not unique obligations. Use UNKNOWN, not zero, for a count inspection did not establish. |
123
+ | Asserted behavior and runs | The actual assertion that observes each implemented body's BF or AC, and its actual run results with evidence references. An annotation alone does not establish the assertion or its execution. |
124
+ | Observed outcomes | PASS, FAIL, skipped, UNRUN and pending observations, with their logs or evidence references. Only an actual run supplies an execution result. A passing empty body establishes no behavioral proof. |
125
+ | Remaining work | Identified unfinished BF/AC bodies and files, the actual owner or UNASSIGNED, completion criteria and the next route. Use `write-acceptance-tests` to write the remaining bodies under its existing acceptance-writing rules. |
126
+
127
+ Do not derive completed ACs by subtracting empty bodies from the suite's pass
128
+ total. An assertion for another EX does not complete an empty AC body. Zero
129
+ validation errors do not prove BF/AC behavior. Guidance fixtures prove the
130
+ reporting guidance they inspect, not an adopter's actual behavior.
131
+
132
+ For example, an illustrative inspection can identify two AC test bodies, one
133
+ empty and one with recorded assertion and run evidence, plus one unclassified
134
+ BF test body. Report those body counts with their separate units and files;
135
+ the remaining bodies still need owners and completion criteria. If inspection
136
+ has not established the count, write UNKNOWN. If no owner has been assigned,
137
+ write UNASSIGNED; do not invent an assignment or a successful run.
138
+
139
+ Legitimate empty bodies keep their existing exemption. An actual required-check
140
+ FAIL remains FAIL, and the acceptance-writing completion gate is unchanged.
141
+ When using the existing optional `verify.json` summary, keep one or two short
142
+ sentences naming remaining work, its owner or UNASSIGNED, and the detailed
143
+ report reference. Put the table in the human report, without new JSON fields,
144
+ statuses, scopes, gates or routes.
145
+
146
+ ### Full collection evidence
147
+
148
+ During the existing normal verify run, record the full intended collection
149
+ and actual collection and execution. Reconcile omitted cases against
150
+ comparable case membership at the same revision, command/filter, runner and
151
+ environment, or explain intentional differences. Preserve the Standard Test
152
+ command's quoted arguments: shell expansion can change collection depth.
153
+ Equal aggregate counts do not prove equal membership. Keep unknown expected
154
+ counts unknown; unexplained omissions prevent a full-scope completion claim.
155
+
156
+ A focused target pass, file/container success or static annotation linkage
157
+ proves no full collection. For a focused case's source identity, actual body
158
+ execution, terminal state and raw evidence, read
159
+ `.qfai/assistant/skill/qfai-implement/references/red-admissibility.md#selected-case-execution`.
160
+ Keep its result distinct from full-scope evidence. No extra full run is
161
+ required during each focused cycle. Record these facts in the existing human
162
+ report; add no permanent inventory, ledger, JSON field, gate status, runtime
163
+ parser or runner.
164
+
86
165
  ## Verdict
87
166
 
88
167
  Write `.qfai/report/verify.json` at the end of the run. It is the
89
168
  machine-readable verdict downstream gates read, and the evidence markdown does
90
- not replace it. `status` is `"PASS"` only when every gate in scope passed.
91
- `scope` is the one `verify-qfai-gate` ran, never a stage this run did not
92
- cover. Fields, the closed `scope` enum, a conforming example and what must
169
+ not replace it. `status` is `"PASS"` only when every gate in scope passed or is
170
+ `DELEGATED` to a CI check that is not red for the candidate being evaluated.
171
+ A red check for that candidate or a non-delegated UNRUN gate makes `status`
172
+ `"FAIL"`. Preserve the previous candidate's FAIL evidence when an explicitly
173
+ covered transport commit carries actual repairs into a new candidate. Its own
174
+ pending delegated checks permit only that transport, never formal completion;
175
+ they do not replace the earlier failed result. Keep revision and run evidence
176
+ in the stage report, without adding verdict fields or states.
177
+ `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
179
+ cover. Delegation does not claim that its validation profile has already run. Fields, the closed `scope` enum, a conforming example and what must
93
180
  never be written are in
94
181
  `.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md`.
95
182
 
96
- ## The stage result
183
+ ## Stage report
97
184
 
98
185
  Inside an `npx qfai workflow` run, the stage runs every required gate over the
99
186
  run's change and reports each result.
100
187
 
101
- - The stage writes this run's `.qfai/report/verify.json` and names it in
102
- `artifactRefs`.
188
+ - The stage writes this run's `.qfai/report/verify.json` and names its scope and
189
+ the revision checked in the stage report, with the commands and evidence for
190
+ each gate.
103
191
  - A `verify.json` written by another run, scoped to another flow or kept in a
104
192
  shared location is never named as this stage's report.
105
- - The stage's own `gateResults` are information only: the run decides no gate
106
- from them.
107
- - `outcome` and `testObservation` are reported apart.
108
- - A required gate that did not run is reported `unrun`, never as a pass.
109
- - A gate the project runs in CI only is reported `delegated`, with its check
110
- name.
193
+ - Report the stage's completion or stop separately from actual test and gate
194
+ 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
196
+ observed CI status.
111
197
 
112
- `verify.json` itself is unchanged inside a run: its fields and values are
113
- `.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md`'s,
114
- and the run's values stay in the stage result.
198
+ Keep these details in the stage report and session handoff. `verify.json`
199
+ keeps only the fields and values in
200
+ `.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md`.
115
201
 
116
202
  ## Findings verify did not cause
117
203
 
118
204
  Inside a run, verify edits no artifact another owner holds. A finding it did
119
- not cause returns `needs_repair`, with the finding listed in `debts` under its
120
- `resolvingOwner`, so the run sends the repair there.
205
+ not cause returns `needs_repair`. The stage report and handoff name the
206
+ finding, its evidence and affected paths, the repair owner and the repair
207
+ needed before verification can resume.
121
208
 
122
- | Finding | `resolvingOwner` |
209
+ | Finding | Owner |
123
210
  | ------------------------- | ---------------- |
124
211
  | A story or contract gap | `qfai-sdd` |
125
212
  | An acceptance-test defect | `qfai-implement` |
126
213
  | An implementation defect | `qfai-implement` |
127
214
 
128
- These three are the only repairs verify routes.
215
+ These three are the only repairs verify hands off to an owner.
129
216
 
130
217
  ## A missing environment
131
218
 
132
- - A gate whose environment is missing returns the stage `blocked`, with the
133
- blocker `stage-blocked` and `operator` as the one who clears it.
134
- - No debt is listed for it, and no repair is routed.
219
+ - A gate whose environment is missing leaves the stage `blocked`. Record
220
+ the missing environment in the stage report, with the operator as its owner
221
+ and the capability needed to resume.
222
+ - This is an environment stop, not a product repair. The gate remains UNRUN
223
+ with its reason.
135
224
 
136
225
  ## A failure the run did not cause
137
226
 
@@ -141,6 +230,18 @@ its `reason`. The top-level `status` stays `"FAIL"`, so the run stops before
141
230
  `verify-commit`. The final report lists each such gate apart from the failures
142
231
  the run caused, so the user can decide whether to commit.
143
232
 
233
+ For a gate with baseline `same`, `reason` names the failing test identifiers
234
+ and the environment they fail in. The identifiers are the ones observed failing
235
+ in the base commit's run, executed as `common-gate-run`'s
236
+ `## A failure that predates the change` says, never assumed. The stage report
237
+ adds how to confirm it: the base commit's result, and the result of the same
238
+ gate in CI when a check covers it, with the run or check named. A CI result that
239
+ was not observed is written as unknown, never as a pass. The report ends by
240
+ asking the user whether to commit with those gates open, as
241
+ `.agents/rules/user-questions.md` says; nothing is committed before the answer.
242
+ Under a no-question mode, or with no question tool, the report lists those gates
243
+ as open and stops without committing.
244
+
144
245
  ## Gate
145
246
 
146
247
  The step is done when:
@@ -149,14 +250,16 @@ The step is done when:
149
250
  reason, or is recorded DELEGATED with its CI check;
150
251
  - every gate passes, or each failure has an actionable fix list and an owner;
151
252
  - `verify.json` exists, its `status` matches the gate results and its `scope`
152
- matches the validate profile that ran.
253
+ matches the required validate profile. A delegated validation check must cover
254
+ that same profile and scan; a whole-repository scope still requires a full
255
+ scan. Pending delegation never claims it ran.
153
256
 
154
257
  For this skill, the smallest applicable smoke check of
155
258
  `.qfai/assistant/rule/shared-skill-operating-baseline.md#completion-contract-shared`
156
259
  is the whole gate set of the scope, run to completion, with every outcome in
157
260
  `verify.json` and the report.
158
261
 
159
- A PASS needs zero errors in the declared profile, or errors only within the
160
- project's recorded backlog as `verify-qfai-gate` reports it, and, where the
161
- project has them, a clean distributed-surface guard and a clean branch version
162
- pin.
262
+ A PASS needs zero errors in the declared profile. A successful custom Validate
263
+ wrapper does not waive validation errors or replace a full scan. Where the
264
+ project has them, the distributed-surface guard and branch version pin must also
265
+ pass.
@@ -84,8 +84,8 @@ them, and nothing says which.
84
84
 
85
85
  ## Held by
86
86
 
87
- Review, and any check a project adds for itself. `npx qfai doctor` reports an
88
- assistant asset over 800 lines, which is a second check above the limit in § 1.
87
+ Review, and any check a project adds for itself. `npx qfai doctor` reports a
88
+ Markdown assistant asset over the line limit in § 1.
89
89
 
90
90
  ## Related
91
91
 
@@ -43,6 +43,154 @@ asking it once costs what asking about a single item costs.
43
43
  Three branches polled separately spend three times what the answer needs, and
44
44
  the multiplier grows with the work rather than staying put.
45
45
 
46
+ ### A first snapshot of two pull requests
47
+
48
+ When git and a REST listing cannot answer the combined CI and review question,
49
+ use aliases and a common fragment. Supply the repository owner, name and two
50
+ pull-request numbers as variables. This query reads the first pages only.
51
+
52
+ ```graphql
53
+ query PullRequestSnapshot($owner: String!, $name: String!, $firstPR: Int!, $secondPR: Int!) {
54
+ repository(owner: $owner, name: $name) {
55
+ first: pullRequest(number: $firstPR) {
56
+ ...PullRequestState
57
+ }
58
+ second: pullRequest(number: $secondPR) {
59
+ ...PullRequestState
60
+ }
61
+ }
62
+ }
63
+
64
+ fragment PullRequestState on PullRequest {
65
+ id
66
+ number
67
+ headRefOid
68
+ state
69
+ mergeable
70
+ commits(last: 1) {
71
+ nodes {
72
+ commit {
73
+ id
74
+ oid
75
+ statusCheckRollup {
76
+ id
77
+ state
78
+ contexts(first: 50, after: null) {
79
+ nodes {
80
+ __typename
81
+ ... on CheckRun {
82
+ id
83
+ name
84
+ status
85
+ conclusion
86
+ detailsUrl
87
+ completedAt
88
+ }
89
+ ... on StatusContext {
90
+ id
91
+ context
92
+ state
93
+ targetUrl
94
+ }
95
+ }
96
+ pageInfo {
97
+ hasNextPage
98
+ endCursor
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ pageInfo {
105
+ hasPreviousPage
106
+ startCursor
107
+ }
108
+ }
109
+ reviewThreads(first: 50, after: null) {
110
+ nodes {
111
+ id
112
+ isResolved
113
+ isOutdated
114
+ comments(first: 20, after: null) {
115
+ nodes {
116
+ id
117
+ body
118
+ author {
119
+ login
120
+ }
121
+ createdAt
122
+ updatedAt
123
+ url
124
+ }
125
+ pageInfo {
126
+ hasNextPage
127
+ endCursor
128
+ }
129
+ }
130
+ }
131
+ pageInfo {
132
+ hasNextPage
133
+ endCursor
134
+ }
135
+ }
136
+ reviews(first: 50, after: null) {
137
+ nodes {
138
+ id
139
+ state
140
+ body
141
+ author {
142
+ login
143
+ }
144
+ submittedAt
145
+ commit {
146
+ oid
147
+ }
148
+ url
149
+ }
150
+ pageInfo {
151
+ hasNextPage
152
+ endCursor
153
+ }
154
+ }
155
+ comments(first: 50, after: null) {
156
+ nodes {
157
+ id
158
+ body
159
+ author {
160
+ login
161
+ }
162
+ createdAt
163
+ updatedAt
164
+ url
165
+ }
166
+ pageInfo {
167
+ hasNextPage
168
+ endCursor
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ - Keep a separate cursor for each PR's contexts, threads, reviews and comments,
175
+ and for each thread's comments. While `hasNextPage` is true, fetch that
176
+ connection with its own `endCursor` as `after`, retaining earlier pages.
177
+ Batch independent next-page requests with distinct aliases and variables;
178
+ never reuse one connection's cursor for another.
179
+ - `commits(last: 1)` selects the head evidence, not the full commit history.
180
+ Its commit `oid` must equal that PR's `headRefOid`. Earlier commits indicated
181
+ by `hasPreviousPage` need not be fetched for this head check.
182
+ - Require every page of the status and review connections before claiming
183
+ coverage. API errors, null PRs or required evidence, missing heads, or an OID
184
+ mismatch leave the snapshot incomplete. A null rollup does not prove CI passed.
185
+ If the head changes during pagination, discard that head's coverage and
186
+ collect a new snapshot. Apply the project's completion and merge rules only
187
+ to complete evidence for the current head.
188
+
189
+ GitHub's [pull-request fields](https://docs.github.com/en/graphql/reference/pulls),
190
+ [commit status fields](https://docs.github.com/en/graphql/reference/commits) and
191
+ [pagination guide](https://docs.github.com/en/graphql/guides/using-pagination-in-the-graphql-api)
192
+ define the query's fields and cursors.
193
+
46
194
  ## 3. Save a payload once and read it locally
47
195
 
48
196
  A log, a diff or a listing that will be searched more than once is written to
@@ -60,17 +208,48 @@ already said.
60
208
  Where the subject's duration is unknown, ask once, wait, and widen the gap as
61
209
  the wait grows.
62
210
 
211
+ ### One watcher for the task
212
+
213
+ The root agent names one API watcher for recurring hosted-state checks. The
214
+ root and all its descendants together have at most one such watcher. Other
215
+ workers read its saved payloads and request fresh snapshots from it. Save the
216
+ capture time, covered PRs and heads, pagination state and response headers with
217
+ each payload so workers can judge whether it answers their question.
218
+
219
+ Coordinate targets and timing with other known tasks using the same account;
220
+ reuse their watcher where it can cover the combined set. This does not reserve
221
+ the account or guarantee exclusive access against unknown sessions. It limits
222
+ API polling, not workers doing local work or making necessary non-polling calls.
223
+
224
+ These are operating instructions. The reminder does not elect a watcher or
225
+ enforce the limit.
226
+
63
227
  ## 5. `rate_limit` is not the budget
64
228
 
65
- A dedicated rate-limit endpoint can report a stale or wrong figure. One has
66
- answered `0` calls used against a token that a real endpoint reported, minutes
67
- later, as most of the way through its allowance. An agent that trusts the
68
- endpoint reads reassurance and keeps spending.
229
+ Read the budget from the response to a call that was going to be made anyway,
230
+ never a dedicated `rate_limit` probe. Record that response's resource, remaining count
231
+ and reset time. On GitHub these are `x-ratelimit-resource`,
232
+ `x-ratelimit-remaining` and `x-ratelimit-reset`; also retain `Retry-After` when
233
+ present. REST and GraphQL have separate primary allowances. Missing headers
234
+ leave the budget unknown; a saved count is not a reservation for the next call.
235
+
236
+ ### Recover from an actual refusal
237
+
238
+ When a real response refuses a request because of a rate limit, stop calls to
239
+ the affected resource and tell the watcher and known account-sharing tasks.
240
+ A successful HTTP status with a rate-limit error in the body is also a refusal.
241
+ For a secondary limit, pause affected requests across REST and GraphQL for the
242
+ same account. Changing tokens or API surfaces is not recovery.
243
+ Wait for `Retry-After` and any applicable reset time. For a secondary limit
244
+ with neither delay nor an exhausted primary allowance, wait at least one minute.
69
245
 
70
- The instrument is the response to a call that was going to be made anyway.
71
- Every response carries the remaining count, the reset time and the name of the
72
- allowance it was drawn from — and that last one is what says which allowance a
73
- refusal came from, where REST and GraphQL are counted separately.
246
+ After the wait, make one real request already needed for the work. Resume that
247
+ resource only when the request succeeds and its own headers show available
248
+ budget. If it is refused again or the headers are missing, keep it stopped;
249
+ do not run a retry loop or a `rate_limit` probe. Continue work that needs no
250
+ call to that resource. GitHub's
251
+ [rate-limit guidance](https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api)
252
+ describes the refusal signals and wait headers.
74
253
 
75
254
  ## The command, where there is one
76
255
 
@@ -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