qfai 2.1.0 → 2.1.2

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 (184) hide show
  1. package/README.md +327 -55
  2. package/assets/defaults/agent-routing/qfai-triage.yml +9 -0
  3. package/assets/defaults/workflows/change-tooling.yml +0 -4
  4. package/assets/defaults/workflows/run-owned-cleanup.yml +12 -0
  5. package/assets/init/.claude/settings.json +27 -9
  6. package/assets/init/.codex/hooks.json +20 -8
  7. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +5 -0
  8. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +14 -1
  9. package/assets/init/.qfai/assistant/agent/product-experience-architect.md +4 -0
  10. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +7 -0
  11. package/assets/init/.qfai/assistant/agent/qa-gatekeeper.md +29 -0
  12. package/assets/init/.qfai/assistant/agent/requirements-analyst.md +8 -0
  13. package/assets/init/.qfai/assistant/rule/communication.md +18 -8
  14. package/assets/init/.qfai/assistant/rule/constitution.md +5 -4
  15. package/assets/init/.qfai/assistant/rule/drift-protocol.md +72 -5
  16. package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +72 -0
  17. package/assets/init/.qfai/assistant/rule/references/context-summary.md +30 -0
  18. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +42 -0
  19. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +23 -0
  20. package/assets/init/.qfai/assistant/rule/references/host-backstops.md +60 -0
  21. package/assets/init/.qfai/assistant/rule/references/placeholder-scan.md +25 -0
  22. package/assets/init/.qfai/assistant/rule/references/reviewer-findings.md +41 -0
  23. package/assets/init/.qfai/assistant/rule/references/reviewer-remit.md +35 -0
  24. package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +48 -0
  25. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +39 -162
  26. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +14 -145
  27. package/assets/init/.qfai/assistant/rule/stage-cost.md +1 -1
  28. package/assets/init/.qfai/assistant/rule/test-layers.md +42 -0
  29. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +6 -1
  30. package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +11 -45
  31. package/assets/init/.qfai/assistant/skill/qfai-configure/references/principles.md +25 -0
  32. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +1 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +12 -9
  34. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +2 -4
  35. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/platform_baselines.md +11 -0
  36. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/review_audit_playbook.md +11 -0
  37. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux_best_practices.md +13 -42
  38. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +0 -16
  39. package/assets/init/.qfai/assistant/skill/qfai-grill/SKILL.md +1 -1
  40. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +16 -88
  41. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +58 -0
  42. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +42 -0
  43. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +17 -4
  44. package/assets/init/.qfai/assistant/skill/qfai-implement/references/credential-reuse.md +9 -0
  45. package/assets/init/.qfai/assistant/skill/qfai-implement/references/cross-spec-ownership.md +41 -0
  46. package/assets/init/.qfai/assistant/skill/qfai-implement/references/oracle-strength.md +6 -1
  47. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +9 -1
  48. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +47 -1
  49. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +4 -3
  50. package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +4 -4
  51. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +16 -10
  52. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +10 -260
  53. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +273 -0
  54. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +5 -4
  55. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/design-md-spec.md +14 -5
  56. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +10 -0
  57. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +1 -1
  58. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +3 -4
  59. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +12 -5
  60. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +33 -4
  61. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +34 -36
  62. package/assets/init/.qfai/assistant/skill/qfai-run/references/evidence-delivery.md +322 -0
  63. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +67 -24
  64. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +246 -5
  65. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +29 -5
  66. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +43 -0
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +5 -4
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +10 -1
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +22 -9
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-anti-patterns.md +41 -6
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +11 -5
  72. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-brand-catalog.md +17 -2
  73. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/requirements-decomposition.md +10 -2
  74. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +34 -9
  75. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +4 -4
  76. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +2 -2
  77. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +177 -7
  78. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +29 -5
  79. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +130 -1
  80. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-design-contract-normalization.md +4 -30
  81. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +39 -2
  82. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/db-contract.sample.sql +2 -2
  83. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/ui-contract.sample.yaml +52 -5
  84. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/03_contract/cli/cli-NNNN-title.md +2 -2
  85. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/03_contract/tech.md +1 -1
  86. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +7 -0
  87. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +30 -20
  88. package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +6 -5
  89. package/assets/init/.qfai/assistant/skill/qfai-verify/references/context-load.md +9 -6
  90. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +92 -13
  91. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +37 -31
  92. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/config.toml +2 -4
  93. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/mcp-config.json +9 -5
  94. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/.mcp.json +1 -2
  95. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/config.toml +3 -3
  96. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/mcp-config.json +11 -8
  97. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/config.toml +1 -1
  98. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/mcp-config.json +7 -3
  99. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +17 -7
  100. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +126 -13
  101. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +3 -2
  102. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +1 -0
  103. package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +2 -0
  104. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +12 -4
  105. package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +1 -1
  106. package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +7 -4
  107. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +11 -1
  108. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +2 -0
  109. package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +2 -2
  110. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +3 -3
  111. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +2 -2
  112. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +4 -3
  113. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +6 -3
  114. package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +4 -3
  115. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +3 -3
  116. package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +9 -6
  117. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +1 -1
  118. package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +4 -3
  119. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +42 -6
  120. package/assets/init/.qfai/assistant/step/implement-test-fix/STEP.md +2 -0
  121. package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +22 -2
  122. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +18 -14
  123. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +4 -3
  124. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +4 -0
  125. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +1 -3
  126. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +11 -0
  127. package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +4 -0
  128. package/assets/init/.qfai/assistant/step/sdd-gate/STEP.md +4 -0
  129. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +10 -0
  130. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +37 -11
  131. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +5 -4
  132. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +33 -23
  133. package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +5 -3
  134. package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +2 -0
  135. package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +4 -0
  136. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +13 -4
  137. package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +8 -5
  138. package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +86 -0
  139. package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +2 -0
  140. package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +6 -3
  141. package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +9 -5
  142. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +39 -6
  143. package/assets/init/.qfai/assistant/step/verify-external/STEP.md +5 -2
  144. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +10 -2
  145. package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +1 -0
  146. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +7 -5
  147. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +136 -28
  148. package/assets/init/.qfai/waivers.yml +1 -1
  149. package/assets/init/root/.agents/rules/ai-readable-markdown.md +98 -0
  150. package/assets/init/root/.agents/rules/api-budget.md +191 -13
  151. package/assets/init/root/.agents/rules/documentation-clarity.md +192 -35
  152. package/assets/init/root/.agents/rules/grilling.md +4 -4
  153. package/assets/init/root/.agents/rules/interface-clarity.md +5 -5
  154. package/assets/init/root/.agents/rules/minimal-implementation.md +11 -3
  155. package/assets/init/root/.agents/rules/reminders.json +27 -14
  156. package/assets/init/root/.agents/rules/session-feedback.md +136 -0
  157. package/assets/init/root/.agents/rules/temporary-files.md +47 -5
  158. package/assets/init/root/.agents/rules/untrusted-content.md +3 -3
  159. package/assets/init/root/.agents/rules/user-questions.md +74 -36
  160. package/assets/init/root/.gitattributes +9 -0
  161. package/assets/init/root/.github/workflows/qfai-docs.yml +44 -12
  162. package/assets/init/root/.github/workflows/qfai-tests.yml +58 -15
  163. package/assets/init/root/.github/workflows/qfai-validate.yml +49 -42
  164. package/assets/init/root/AGENTS.md +23 -21
  165. package/assets/mdschema/story/03_contract/tech.mdschema.yml +7 -3
  166. package/assets/sandbox-templates/default-deny.yaml +9 -5
  167. package/assets/schemas/workflow/extraction.schema.json +85 -5
  168. package/assets/schemas/workflow/plan.schema.json +9 -2
  169. package/assets/scripts/check-mdschema.mjs +172 -5
  170. package/assets/uix-rev/comparison-review.md +1 -1
  171. package/assets/uix-rev/contracts-review.md +1 -2
  172. package/dist/cli/index.cjs +6499 -7688
  173. package/dist/cli/index.cjs.map +1 -1
  174. package/dist/cli/index.mjs +6449 -7641
  175. package/dist/cli/index.mjs.map +1 -1
  176. package/dist/index.cjs +5548 -7823
  177. package/dist/index.cjs.map +1 -1
  178. package/dist/index.d.cts +40 -666
  179. package/dist/index.d.ts +40 -666
  180. package/dist/index.mjs +5397 -7648
  181. package/dist/index.mjs.map +1 -1
  182. package/docs/MIGRATION-2.0.0.md +1 -1
  183. package/package.json +5 -7
  184. package/assets/init/root/CLAUDE.md +0 -45
@@ -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.
@@ -44,9 +45,12 @@ commands entry named after the colon:
44
45
  7. build/package (if relevant): `Build`
45
46
  8. pack/verify (if distributed): `Pack / distribution`
46
47
 
47
- Run listed commands and record outputs. Where the environment cannot run a
48
- command, ask the user to run it and provide the output. Never assume PASS
49
- without evidence.
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
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.
50
54
 
51
55
  ## Fix loop
52
56
 
@@ -60,6 +64,10 @@ one code review reads the repair, as `qfai-verify`'s `## Review` section says.
60
64
 
61
65
  - If failing, produce an actionable fix list (not vague). Stop and escalate
62
66
  when a gate fails without one.
67
+ - Before attributing a failure to the change, run the gate on the base commit,
68
+ as `common-gate-run`'s `## A failure that predates the change` says. A
69
+ failure that is the same there is reported with its baseline and is not
70
+ repaired.
63
71
  - Identify whether the failure is a spec mismatch, a test issue or an
64
72
  implementation defect, and fix the root cause. Do not silence a test without
65
73
  a reason.
@@ -78,68 +86,168 @@ one code review reads the repair, as `qfai-verify`'s `## Review` section says.
78
86
  Report the scope, every gate command with its result, the open risks and the
79
87
  next actions.
80
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
+
81
165
  ## Verdict
82
166
 
83
167
  Write `.qfai/report/verify.json` at the end of the run. It is the
84
168
  machine-readable verdict downstream gates read, and the evidence markdown does
85
- not replace it. `status` is `"PASS"` only when every gate in scope passed.
86
- `scope` is the one `verify-qfai-gate` ran, never a stage this run did not
87
- 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
88
180
  never be written are in
89
181
  `.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md`.
90
182
 
91
- ## The stage result
183
+ ## Stage report
92
184
 
93
185
  Inside an `npx qfai workflow` run, the stage runs every required gate over the
94
186
  run's change and reports each result.
95
187
 
96
- - The stage writes this run's `.qfai/report/verify.json` and names it in
97
- `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.
98
191
  - A `verify.json` written by another run, scoped to another flow or kept in a
99
192
  shared location is never named as this stage's report.
100
- - The stage's own `gateResults` are information only: the run decides no gate
101
- from them.
102
- - `outcome` and `testObservation` are reported apart.
103
- - A required gate that did not run is reported `unrun`, never as a pass.
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.
104
197
 
105
- `verify.json` itself is unchanged inside a run: its fields and values are
106
- `.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md`'s,
107
- 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`.
108
201
 
109
202
  ## Findings verify did not cause
110
203
 
111
204
  Inside a run, verify edits no artifact another owner holds. A finding it did
112
- not cause returns `needs_repair`, with the finding listed in `debts` under its
113
- `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.
114
208
 
115
- | Finding | `resolvingOwner` |
209
+ | Finding | Owner |
116
210
  | ------------------------- | ---------------- |
117
211
  | A story or contract gap | `qfai-sdd` |
118
212
  | An acceptance-test defect | `qfai-implement` |
119
213
  | An implementation defect | `qfai-implement` |
120
214
 
121
- These three are the only repairs verify routes.
215
+ These three are the only repairs verify hands off to an owner.
122
216
 
123
217
  ## A missing environment
124
218
 
125
- - A gate whose environment is missing returns the stage `blocked`, with the
126
- blocker `stage-blocked` and `operator` as the one who clears it.
127
- - 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.
224
+
225
+ ## A failure the run did not cause
226
+
227
+ A gate that fails the same way on the base commit, or could not run, is
228
+ recorded in the report and in `gates` of `verify.json`, with its `baseline` or
229
+ its `reason`. The top-level `status` stays `"FAIL"`, so the run stops before
230
+ `verify-commit`. The final report lists each such gate apart from the failures
231
+ the run caused, so the user can decide whether to commit.
128
232
 
129
233
  ## Gate
130
234
 
131
235
  The step is done when:
132
236
 
133
237
  - every gate in scope ran and is recorded, or is recorded UNRUN with the
134
- reason;
238
+ reason, or is recorded DELEGATED with its CI check;
135
239
  - every gate passes, or each failure has an actionable fix list and an owner;
136
240
  - `verify.json` exists, its `status` matches the gate results and its `scope`
137
- matches the validate profile that ran.
241
+ matches the required validate profile. A delegated validation check must cover
242
+ that same profile and scan; a whole-repository scope still requires a full
243
+ scan. Pending delegation never claims it ran.
138
244
 
139
245
  For this skill, the smallest applicable smoke check of
140
246
  `.qfai/assistant/rule/shared-skill-operating-baseline.md#completion-contract-shared`
141
247
  is the whole gate set of the scope, run to completion, with every outcome in
142
248
  `verify.json` and the report.
143
249
 
144
- A PASS needs zero errors in the declared profile, and, where the project has
145
- them, a clean distributed-surface guard and a clean branch version pin.
250
+ A PASS needs zero errors in the declared profile. A successful custom Validate
251
+ wrapper does not waive validation errors or replace a full scan. Where the
252
+ project has them, the distributed-surface guard and branch version pin must also
253
+ pass.
@@ -2,7 +2,7 @@ version: 1
2
2
  waivers: []
3
3
  # Write `rule:` exactly as the finding's `code` appears in
4
4
  # `.qfai/report/validate.json` and in the CLI output — `QFAI-DT-006`,
5
- # `QFAI-CFG-LINK-002`, `W-ASSISTANT-LAYOUT`. Do not strip the `QFAI-` prefix;
5
+ # `QFAI-CFG-LINK-002`, `QFAI-ASSISTANT-001`. Do not strip the `QFAI-` prefix;
6
6
  # the stripped form is kept working only for older waiver files.
7
7
  #
8
8
  # Waivers apply to `warning` and `info` findings only. A waiver aimed at an
@@ -0,0 +1,98 @@
1
+ # AI-Readable Markdown
2
+
3
+ How a Markdown file that an AI agent reads as instructions is sized and split.
4
+
5
+ An agent follows fewer instructions as its context grows, and it follows those
6
+ in the middle of a long file worst. A loaded file also stays loaded: every line
7
+ is paid for again on every turn. So the aim is a small, relevant context for
8
+ each task, not merely short files.
9
+
10
+ ## Scope
11
+
12
+ | Target | Applies |
13
+ | ----------------------------------------------------------------- | ------------------------------------------------- |
14
+ | Skills, references, templates, rules, agent cards and entry files | Always |
15
+ | Any other Markdown file an agent reads to decide what to do | Always |
16
+ | Markdown written for people only, such as a changelog | Outside this rule |
17
+ | How the text in a file is written | Outside this rule; see `documentation-clarity.md` |
18
+
19
+ ## 1. Size limits
20
+
21
+ - Every Markdown file an agent reads stays at or under **500 lines**.
22
+ - A `SKILL.md` body stays at or under **20,000 characters**.
23
+
24
+ The body excludes YAML frontmatter; a character is one Unicode code point.
25
+
26
+ A file near a limit is a signal to move a section out, not to pack more onto
27
+ each line.
28
+
29
+ ## 2. Budget what a task loads
30
+
31
+ Splitting helps only when the pieces are loaded on demand. A piece that is
32
+ always read together with another saves nothing: the task still loads both, and
33
+ now pays for the pointer as well.
34
+
35
+ So the budget is what a task loads, not the size of one file. It is the entry
36
+ file, plus every file the task reads because a pointer sent it there. Two files
37
+ that are always read together are one file.
38
+
39
+ ## 3. Every pointer says when
40
+
41
+ Every pointer to another file says when to read it, when not to, and what it
42
+ holds.
43
+
44
+ > Read `references/api-errors.md` when the API returns a status other than 200.
45
+ > It lists each error code and what to do about it. Not needed after a
46
+ > successful call.
47
+
48
+ A generic "see `references/`" does not count. An agent that cannot tell whether
49
+ it needs a file either skips it or reads every file, and both defeat the split.
50
+
51
+ ## 4. One level deep
52
+
53
+ The entry file names every reference directly. A reference does not point to
54
+ another reference.
55
+
56
+ An agent tends to preview a file it reached through another one, rather than
57
+ read it whole, and misses what the preview did not show. Where two references
58
+ need each other, point the entry file at both, or merge them.
59
+
60
+ ## 5. A long reference opens with its contents
61
+
62
+ A reference file over 100 lines opens with a `## Contents` section: a list of
63
+ its `##` headings, in order.
64
+
65
+ A preview, a truncated read and a context that was compacted all keep the head
66
+ of a file. The list lets the agent see what the rest holds from there.
67
+
68
+ ## 6. What stays in the entry file
69
+
70
+ An obligation whose trigger the agent cannot judge for itself stays in the entry
71
+ file.
72
+
73
+ Move a section out only when the task itself shows the agent it needs it: it is
74
+ writing that file, it hit that error, it reached that step. A rule that applies
75
+ before the agent can know it applies — a trap, a stop condition, an input that
76
+ must never be assumed — is read in the entry file or not at all.
77
+
78
+ ## 7. One home per rule
79
+
80
+ Each rule is written in one place, and every other file references it.
81
+
82
+ Two copies diverge over time. When they contradict each other, an agent picks one of
83
+ them, and nothing says which.
84
+
85
+ ## Held by
86
+
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
+
90
+ ## Related
91
+
92
+ - Writing standard for the text itself: `documentation-clarity.md`
93
+
94
+ ## Scope of this file
95
+
96
+ This is the master copy for every AI coding agent in this repository.
97
+ Tool-specific instruction files point here instead of restating it. Edit this
98
+ file when the rule changes.
@@ -31,7 +31,7 @@ In this order, and stop at the first that answers.
31
31
 
32
32
  Most questions can be answered on more than one of these, which is why the order
33
33
  matters. Reaching for the convenient command rather than the cheap one is how an
34
- allowance goes: several of the forge's own subcommands take the GraphQL path
34
+ allowance runs out: several of the forge's own subcommands take the GraphQL path
35
35
  where an equivalent REST path exists.
36
36
 
37
37
  ## 2. One call for the set, not one per member
@@ -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
 
@@ -78,10 +257,9 @@ The cheap path holds only if it is the default. A repository that gives the
78
257
  recurring questions one command gets that; one where each agent reassembles the
79
258
  calls gets the habits above again.
80
259
 
81
- The QFAI repository's own command is `scripts/gh-budget.mjs`: the CI state of
82
- every branch from one call, and a job log saved once. A project with no
83
- equivalent composes its calls by hand under the rules above, and a project that
84
- writes one names it here.
260
+ A useful command answers two questions: the CI state of every branch from one
261
+ call, and a job log saved once. A project with no equivalent composes its calls
262
+ by hand under the rules above, and a project that writes one names it here.
85
263
 
86
264
  ## The reminder
87
265