qfai 2.1.0 → 2.1.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 (124) hide show
  1. package/README.md +272 -20
  2. package/assets/defaults/workflows/change-tooling.yml +0 -4
  3. package/assets/init/.claude/settings.json +8 -8
  4. package/assets/init/.codex/hooks.json +6 -6
  5. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +14 -1
  6. package/assets/init/.qfai/assistant/agent/qa-gatekeeper.md +29 -0
  7. package/assets/init/.qfai/assistant/rule/constitution.md +5 -4
  8. package/assets/init/.qfai/assistant/rule/drift-protocol.md +14 -3
  9. package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +70 -0
  10. package/assets/init/.qfai/assistant/rule/references/context-summary.md +30 -0
  11. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +42 -0
  12. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +23 -0
  13. package/assets/init/.qfai/assistant/rule/references/host-backstops.md +60 -0
  14. package/assets/init/.qfai/assistant/rule/references/placeholder-scan.md +25 -0
  15. package/assets/init/.qfai/assistant/rule/references/reviewer-findings.md +41 -0
  16. package/assets/init/.qfai/assistant/rule/references/reviewer-remit.md +35 -0
  17. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +26 -139
  18. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +6 -137
  19. package/assets/init/.qfai/assistant/rule/stage-cost.md +1 -1
  20. package/assets/init/.qfai/assistant/rule/test-layers.md +42 -0
  21. package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +8 -42
  22. package/assets/init/.qfai/assistant/skill/qfai-configure/references/principles.md +25 -0
  23. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +1 -1
  24. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +9 -2
  25. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/platform_baselines.md +11 -0
  26. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/review_audit_playbook.md +11 -0
  27. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux_best_practices.md +12 -36
  28. package/assets/init/.qfai/assistant/skill/qfai-grill/SKILL.md +1 -1
  29. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +16 -88
  30. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +58 -0
  31. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +42 -0
  32. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +8 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-implement/references/credential-reuse.md +9 -0
  34. package/assets/init/.qfai/assistant/skill/qfai-implement/references/cross-spec-ownership.md +41 -0
  35. package/assets/init/.qfai/assistant/skill/qfai-implement/references/oracle-strength.md +6 -1
  36. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +1 -1
  37. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +1 -3
  38. package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +1 -1
  39. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +4 -4
  40. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +19 -5
  41. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +1 -1
  42. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/design-md-spec.md +14 -5
  43. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +10 -0
  44. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +1 -1
  45. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +3 -4
  46. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +10 -2
  47. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +16 -3
  48. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +6 -21
  49. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +30 -10
  50. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +34 -0
  51. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +28 -5
  52. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +29 -0
  53. package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +1 -1
  54. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +10 -1
  55. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +21 -9
  56. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-anti-patterns.md +19 -2
  57. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +11 -5
  58. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-brand-catalog.md +17 -2
  59. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/requirements-decomposition.md +2 -2
  60. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +5 -5
  61. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +4 -4
  62. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +2 -2
  63. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +47 -5
  64. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +15 -3
  65. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +16 -1
  66. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-design-contract-normalization.md +1 -2
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +2 -2
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/db-contract.sample.sql +2 -2
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/03_contract/cli/cli-NNNN-title.md +2 -2
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/03_contract/tech.md +1 -1
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +4 -0
  72. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +1 -1
  73. package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +1 -1
  74. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +22 -8
  75. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +2 -10
  76. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +17 -3
  77. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +30 -7
  78. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +11 -1
  79. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +7 -0
  80. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +3 -3
  81. package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +3 -1
  82. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +3 -1
  83. package/assets/init/.qfai/assistant/step/implement-test-fix/STEP.md +2 -0
  84. package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +2 -0
  85. package/assets/init/.qfai/assistant/step/sdd-gate/STEP.md +4 -0
  86. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +7 -3
  87. package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +8 -5
  88. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +6 -1
  89. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +20 -3
  90. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +1 -1
  91. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +23 -6
  92. package/assets/init/.qfai/waivers.yml +1 -1
  93. package/assets/init/root/.agents/rules/ai-readable-markdown.md +98 -0
  94. package/assets/init/root/.agents/rules/api-budget.md +4 -5
  95. package/assets/init/root/.agents/rules/documentation-clarity.md +30 -2
  96. package/assets/init/root/.agents/rules/grilling.md +4 -4
  97. package/assets/init/root/.agents/rules/interface-clarity.md +5 -5
  98. package/assets/init/root/.agents/rules/minimal-implementation.md +8 -0
  99. package/assets/init/root/.agents/rules/reminders.json +2 -2
  100. package/assets/init/root/.agents/rules/temporary-files.md +14 -5
  101. package/assets/init/root/.agents/rules/untrusted-content.md +3 -3
  102. package/assets/init/root/.agents/rules/user-questions.md +34 -7
  103. package/assets/init/root/.gitattributes +9 -0
  104. package/assets/init/root/.github/workflows/qfai-docs.yml +43 -11
  105. package/assets/init/root/.github/workflows/qfai-tests.yml +58 -15
  106. package/assets/init/root/.github/workflows/qfai-validate.yml +49 -42
  107. package/assets/init/root/AGENTS.md +1 -0
  108. package/assets/init/root/CLAUDE.md +1 -0
  109. package/assets/mdschema/story/03_contract/tech.mdschema.yml +7 -3
  110. package/assets/sandbox-templates/default-deny.yaml +0 -2
  111. package/assets/schemas/workflow/plan.schema.json +9 -2
  112. package/assets/scripts/check-mdschema.mjs +172 -5
  113. package/dist/cli/index.cjs +3979 -3055
  114. package/dist/cli/index.cjs.map +1 -1
  115. package/dist/cli/index.mjs +3167 -2243
  116. package/dist/cli/index.mjs.map +1 -1
  117. package/dist/index.cjs +3024 -2500
  118. package/dist/index.cjs.map +1 -1
  119. package/dist/index.d.cts +23 -9
  120. package/dist/index.d.ts +23 -9
  121. package/dist/index.mjs +2881 -2358
  122. package/dist/index.mjs.map +1 -1
  123. package/docs/MIGRATION-2.0.0.md +1 -1
  124. package/package.json +3 -3
@@ -49,14 +49,18 @@ Both classes use the same approval and owner-rerun path.
49
49
 
50
50
  When the user cannot be asked, write no row to either table: report the proposed change as the decision still
51
51
  needed and keep the affected items stopped. A WIP Change request: row is the in-force authorization that the drift gate reads.
52
- TODO is not authorization. A DONE row authorizes only on the branch that appended it or moved it from WIP. A DONE
53
- row the base already holds records a change already applied, so a later edit to the same path needs a row of its own.
52
+ TODO is not authorization. A DONE row authorizes only on the branch that appended it or moved it from WIP. A row
53
+ the base already holds at DONE records a change already applied and authorizes nothing at any Status, so setting it back to WIP
54
+ reopens nothing and a later edit to the same path needs a row of its own.
54
55
 
55
56
  4. Rerun the owner skill against the affected artifact. The owner names the approved decision row, the input revision, and whether it is confirming existing content or changing it.
56
57
  A contract with a contract ID, such as `API-0002`, is selected by its full ID; a contract without one is selected by its repository-relative path.
57
58
  The owner updates the specification and its tests together, then validates the relevant flow.
58
59
  5. Recheck every dependent BF, AC, and EX test obligation and every affected contract reference. Rewrite tests where their former expectation is invalid. Report any uncovered obligation. No execution ledger, TC row, or status reset substitutes for this check.
59
- 6. Complete the decision row by changing Status from WIP to DONE only after the owner artifact and dependent checks are complete. Cite the DEC ID in the stage report. A second open request on the same artifact waits for the first outcome and is restated if its premise changed.
60
+ 6. Complete the decision row by changing Status from WIP to DONE only after the owner artifact and dependent checks are complete.
61
+ A row has one Status, so DONE claims every action its Approach lists. While one of them is deferred, keep the row at WIP.
62
+ Cite the DEC ID in the stage report.
63
+ A second open request on the same artifact waits for the first outcome and is restated if its premise changed.
60
64
 
61
65
  The decision table has no separate Applied at field and no standalone CR file. Approval alone does not certify a change as applied.
62
66
 
@@ -70,6 +74,13 @@ Open requests have independent affected sets. Their union is the set of work pau
70
74
 
71
75
  A defect is demonstrable from the deliverable or an existing obligation: incorrect behavior, missing input validation, data loss, or a failing required quality gate. It is blocking with the concrete artifact and evidence as provenance.
72
76
 
77
+ No repository gate scans for a security or data-integrity defect. Review is that
78
+ class's detector: `.qfai/assistant/agent/implementation-reviewer.md` checks each
79
+ change for missing validation on an input the code already treats as trusted,
80
+ credential or personal-data exposure, and an injection or traversal path opened
81
+ by the change. A finding the reviewer demonstrates traces to `defect:security`
82
+ and blocks like the other blocking classes.
83
+
73
84
  New scope adds product behavior or a quality bar the approved story tree and contracts do not require. A reviewer records it as advisory and sends it to the SDD owner. It becomes binding only after the owner records the decision and updates the relevant BF, AC, EX, BR, or contract. An advisory does not create a test assertion by itself.
74
85
 
75
86
  ### Provenance and routing
@@ -0,0 +1,70 @@
1
+ # Asset Authoring
2
+
3
+ Read when you write or change a shipped asset.
4
+
5
+ ## Asset Authoring Shape (Mandatory)
6
+
7
+ A `SKILL.md` states the contract and points at the file that carries the detail. It is not where the detail lives.
8
+
9
+ - **Keep in `SKILL.md`**: what the skill is for, its non-goals, its hard constraints, the phase/step order, and the gate conditions. Enough for an agent to know what it must do and when it is done.
10
+ - **Move out**: command sets, table schemas, field-by-field contracts, worked procedures, checklists and rationale. These go under the owning tree's own directory:
11
+ - `references/` — normative detail the body cites (`references/<topic>.md`)
12
+ - `templates/` — artifacts the file produces, as fillable skeletons
13
+ - `examples/` — worked instances that illustrate, and bind, nothing
14
+ - **One topic per file.** Do not replace an oversized `SKILL.md` with an oversized `references/everything.md`; that is the same problem one directory down. Split by topic and keep each file readable on its own — a reader who followed one pointer should not have to scan past three unrelated subjects to reach the one they came for.
15
+ - **Every pointer resolves.** A line that moves detail out must name the file (and anchor, when the file covers more than one topic) so the reader is never left guessing where the rule went.
16
+
17
+ A hard line ceiling backs this up: **800 lines per assistant asset file**, for every `.qfai/assistant/**/*.{md,yml,yaml}` file, counted as `content.split(/\r?\n/).length` — blank lines included. `npx qfai doctor` measures it and reports every file over the ceiling as `assets.lineBudget`. The ceiling is a backstop, not the rule: a file approaching it is a signal to move a section out, not
18
+ to raise the number.
19
+
20
+ It was raised from 500 once, and on measurement rather than on the "this file is long" claim the number exists to refuse: three skill bodies had converged on that ceiling, and the changes in flight against one of them added 161 lines to a body already at 498 — eleven of them crossing the ceiling on their own. The detail those bodies carry is required to sit in the body rather than behind
21
+ a pointer, so splitting could not absorb it. Converging on the limit was itself the signal — a body at the ceiling stops shedding topics and starts packing them into longer lines, and a line count cannot see that. Raise it again only against evidence of that kind.
22
+
23
+ **A width ceiling makes the count honest: 400 characters per line.** A count of lines bounds reading cost only while a line is a roughly constant unit of reading, and packing broke that — one line in the shipped tree ran 9,104 characters against a median of 118, and cost the budget one unit. The two are read together, because each permits what the other refuses: width alone allows a thin
24
+ file of a thousand short lines, and the count alone allows a packed one.
25
+
26
+ Two shapes are not measured, and for the same reason — the author cannot make them narrower:
27
+
28
+ | not measured | why |
29
+ | -------------- | --------------------------------------------------------- |
30
+ | a table row | markdown gives it no continuation, so it cannot wrap |
31
+ | a fenced block | its content is a command, a diagram or a sample, verbatim |
32
+
33
+ A table is found by its delimiter row, not by a leading pipe: that pipe is optional, so a table written without one is still a table, and a paragraph that opens with one is still a paragraph. Rows a blank line has cut off from their delimiter are prose, because that is how they render.
34
+
35
+ Some shipped files predate the ceiling and carry a recorded width of their own. It is the width each arrives with, so `npx qfai doctor` does not report a fresh tree for content you received rather than wrote. That record belongs to the package and shrinks there; it is not a per-project allowance, and it never loosens the ceiling on an asset you write. **Everything you author is held
36
+ at 400.**
37
+
38
+ The exemption from the line ceiling does not carry here. Its reason is about a file's length, not about how wide one line may be.
39
+
40
+ No shipped prose asset has a line-ceiling exemption. Agent definitions are
41
+ individual cards under `assistant/agent/`, so their count does not lengthen
42
+ one roster file.
43
+
44
+ ### The owning tree is the one the file sits in
45
+
46
+ The ceiling applies to **every** shipped assistant prose asset, including
47
+ rules and cards. A rule at the ceiling moves topic detail to
48
+ `rule/references/<topic>.md`; a skill uses its own `references/` directory.
49
+ The tree that owns the file owns its detail.
50
+
51
+ For a prose asset, raising the ceiling or claiming an exemption is not the remedy. An exemption claims no split is possible, and a Markdown file whose tree has a `references/` home available cannot make that claim.
52
+
53
+ ### Machine-readable assets split in their own format, or say why they cannot
54
+
55
+ The ceiling is measured over YAML assets too — package routing and review-profile defaults and the shipped contract templates. The split above is not open to them: a validator parses those files as structured data, or a skill copies one whole into a project, so an entry moved into a Markdown sibling under `references/` leaves the parsed document and stops meaning anything. Prose about the
56
+ file may move there; the file's own items may not.
57
+
58
+ So for a machine-readable asset at the ceiling the remedy is, in order:
59
+
60
+ 1. **Split it in its own format** — a sibling of the same kind that the loader or schema already reads, so every item stays parsed.
61
+ 2. **Record an exemption** where the document has to stay whole — a file generated from another asset, one the schema admits only as a single document — naming what makes the split impossible. "This file is long" is not that reason, and a prose asset may not use this step.
62
+
63
+ ## Citation Path Form (Mandatory)
64
+
65
+ A pointer only resolves if the reader knows what base to resolve it against. There is one base, and it is the project root.
66
+
67
+ - **Cite a shared rule by its full path from the project root.** Write the path from the project root, with `#anchor` appended when one applies: `.qfai/assistant/rule/drift-protocol.md`. Not the bare filename, not a relative climb. That form resolves from every directory in the tree,
68
+ and the only one that still resolves when read with the cwd at the project root — which is where an agent's cwd is.
69
+ - **The same holds when a rule cites another one**, including a sibling in its own directory. A bare name works there only by accident of where the citing file sits; it stops working the moment the text is quoted elsewhere.
70
+ - **Within a skill's own directory, keep pointers relative to that directory**: `references/<topic>.md`, `templates/<name>.md`. Those name the skill's own parts, not a shared document, and the surrounding text already establishes which skill is meant.
@@ -0,0 +1,30 @@
1
+ # Context Summary
2
+
3
+ Read when a context summary is written.
4
+
5
+ ## Context Summary Contract
6
+
7
+ When context is summarized, preserve the requests, decisions and stage state
8
+ needed to continue.
9
+
10
+ Every summary that replaces earlier context keeps these six:
11
+
12
+ 1. Difficulties that came up, and how each was resolved.
13
+ 2. Options raised, tried or set aside, and why.
14
+ 3. Everything asked for, decided, agreed, ruled out or established as a constraint — in the exact words.
15
+ 4. Where things stand: what is covered, settled or complete.
16
+ 5. What is still open, promised or expected next.
17
+ 6. Details that are hard to reconstruct: names, numbers, dates, exact wording, references.
18
+
19
+ It also keeps the stage state. None of it can be recovered from the code, and a summary that keeps the six and drops it still misleads the next window.
20
+
21
+ | Stage state | What goes wrong when it is dropped |
22
+ | ----------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
23
+ | The execution ledger and the row in progress | Finished rows are worked again, or a row in `red` is taken for untouched |
24
+ | Every open question, with its ID and status | A question stays open with nobody tracking it, or is answered twice |
25
+ | The clarification budget spent in this invocation, and the questions it was spent on | The next window asks what the user already answered, or asks past the cap |
26
+ | Every assumption recorded under `--auto` or after the budget ran out, with its label | A labelled assumption is read back as a decision someone took |
27
+ | Whether the stage's review has run, and each finding's fix or answer | The review runs a second time, or an answered finding is raised again (`.qfai/assistant/rule/review-convergence.md`) |
28
+ | A grilling session's decision tree, its current frontier, and the answers already settled | An answered question is asked again, or a question is put before the one it depends on (`.agents/rules/grilling.md`) |
29
+
30
+ Keep what the user said close to their own words. Your own reasoning may be condensed to what it concluded, as long as nothing listed above is dropped. Be complete on these items even when that makes the summary longer.
@@ -0,0 +1,42 @@
1
+ # Gate Failure Autorepair
2
+
3
+ Read when a gate fails.
4
+
5
+ ## Gate Failure Autorepair Protocol
6
+
7
+ Follow this protocol when any of the validate, doctor, test, lint, typecheck, build, capture, or report gates fail. A reviewer's `REVISE` is not a gate failure and is not rerun: the author fixes or answers each finding once, as `.qfai/assistant/rule/review-convergence.md` sets out.
8
+
9
+ - inspect exit code, logs, `validate.json`, and cited files before reporting — in `validate.json`, read `counts` for the verdict and `issues[].code` for each finding; the array is `issues`, not `findings`;
10
+ - classify each finding as skill-owned artifact, upstream spec/contract, code/test defect, environment/tooling, or user decision;
11
+ - fix skill-owned artifacts and code/test defects autonomously when the fix is local and non-destructive;
12
+ - **upstream spec/contract findings: never repair.** STOP and follow `.qfai/assistant/rule/drift-protocol.md` (Change Request + owner-skill rerun) — **even when the fix looks local and non-destructive, and even when it is one token and obviously correct**. "Local and non-destructive" is a permission for the two classes above it; it is not a test that upstream artifacts can pass.
13
+ Ownership, not size, decides;
14
+ - environment/tooling findings: repair the environment when it is yours to repair (install a missing dev dependency, regenerate a lockfile, create a scratch directory). Stop for anything needing credentials, network access you do not have, or a change to CI configuration or the host machine;
15
+ - user decision findings: never decide by default. Record the question, state the option you would take and why, and stop — a decision taken silently to keep a gate green is the same failure as repairing upstream, one layer up;
16
+ - rerun the same failing gate after each fix batch, **and once with no intervening change** when the failure looks nondeterministic — see `#nondeterministic-gates` below. The confirmation rerun is bounded at one: after it the finding is classified, not re-rolled;
17
+ - do not weaken profiles, lower `--fail-on`, waive errors, invent evidence, or skip required reviewers;
18
+ - stop for destructive changes, **any upstream spec/contract finding**, ambiguous product/spec decisions, missing permissions/tools, or repeated no-progress failures — the stop list is closed over the classification above, so every class the agent is told to use has a defined next action;
19
+
20
+ When stopping, report: cause, attempted fixes, remaining blocker, user action, retry gate, and **the work counts — how many items are complete, how many are blocked, and by which finding**.
21
+
22
+ The counts are not decoration. Restating the ownership rule does not change the incentive that breaks it: an agent facing "repair five upstream defects or report most of the batch as blocked" reaches for the repair because the alternative reads as failure. `26 items: 21 complete, 5 blocked on DB-0007` is a report of work done, and it is what makes STOP a credible answer rather than a
23
+ surrender. Blocked is a status, not a verdict on the run.
24
+
25
+ ### Nondeterministic gates
26
+
27
+ A gate whose answer varies on identical inputs is a finding in its own right, not a run to discard. The protocol classifies it as `environment/tooling`; what follows is what that class obliges.
28
+
29
+ **When a gate fails and a rerun with no intervening change passes**, all of the following are REQUIRED. A clean rerun on its own is not evidence for that gate.
30
+
31
+ - **Record it as an `environment/tooling` finding.** Not as a pass, and not as a code/test defect — nothing was fixed between the two runs.
32
+ - **Disclose every run.** Report the results of all runs of that gate, in order, with their commands. Reporting only the run that passed is [selective reporting](#selective-reporting-is-invented-evidence) and is forbidden: the evidence rules are satisfied by a clean run's command and output, so nothing else stops it.
33
+ - **Re-run the failing selectors in isolation** and report that result too. A selector that passes alone and fails in the suite is the signature of shared state, not of a defect in that test.
34
+ - **Name the suspected cause**, concretely: a contended port, a shared database or schema, an `os.tmpdir()` path, an un-namespaced cache or queue, ordering between workers. "Flaky" is not a cause.
35
+
36
+ Do not fix the flake by rerunning until green, and do not fix it by weakening the test. Either the shared resource is isolated per worker or the run is serialised — both are real changes with a real cost, which is the point.
37
+
38
+ A gate reported this way has **not passed**. It is a blocker with a named cause, and it goes in the stop report like any other.
39
+
40
+ #### Selective reporting is invented evidence
41
+
42
+ Reporting the clean run and omitting the red ones satisfies every existing evidence rule — a real command, a real result, freshly obtained — and still misrepresents what happened. Which of N runs is reported is itself part of the evidence, so omitting runs of the same gate is on the same footing as inventing one.
@@ -0,0 +1,23 @@
1
+ # Griller Recommendations
2
+
3
+ Read when a griller's recommendation is used.
4
+
5
+ ## A griller's recommendations, and what they disqualify
6
+
7
+ A grilling session puts a recommended answer beside each question (`.agents/rules/grilling.md`). Who settled the decision decides what happens next.
8
+
9
+ | The decision was settled | What follows |
10
+ | ----------------------------------------------------- | --------------------------------------------------------------------------------- |
11
+ | By the user, from the recommendation among the inputs | The decision is theirs. The griller may review the artifact |
12
+ | Agent to agent, not critical | The decision stands. The griller that recommended it does not review the artifact |
13
+ | Agent to agent, critical, with no user adjudication | The artifact is wrong, and no reviewer can clear it |
14
+
15
+ **The second row is how a delegated session is meant to end** (`.agents/rules/grilling.md`), not a finding. The reviewer checks that the decision is in the final report and is not critical. A reviewer that doubts its merit raises that as an ordinary finding against the artifact, under its own remit, as it would for any other content.
16
+
17
+ **The third row is not a routing problem.** A critical decision is the user's in every session, and a run that could not ask records it as an open question rather than adopting it. An agent-adopted critical decision is therefore an artifact carrying something nobody with the standing decided, and handing it to a different reviewer would launder it.
18
+ The reviewer must return `REVISE` and name the decision: it is reopened and put to the user, or recorded open where no question can be asked.
19
+
20
+ The first row needs a reason, because the intuitive one is wrong. A sub-agent starting with a reset context cannot defer to something it does not remember, so deference is not the risk. **Correlation** is: a fresh instance of the same agent, on the same model, over the same evidence, re-derives the preference that produced the recommendation and finds it good on the merits. Resetting the
21
+ context removes the memory, not the disposition — which is why role name alone never establishes independence either. Where the user chose, that disposition is one input among several and the decision is not the griller's to re-derive.
22
+
23
+ **The stage's final report is the record.** It lists every decision the agents adopted and the agent that recommended it, so a reviewer with a reset context reads the third row off the report rather than off recollection.
@@ -0,0 +1,60 @@
1
+ # Host Backstops
2
+
3
+ Read when a host limit on agents is involved.
4
+
5
+ ## Host backstops above the declared shape
6
+
7
+ The dispatch limits in this baseline and in each skill's own policy are read by
8
+ the agent doing the dispatch. A run that has lost its way is the one least likely
9
+ to apply them, so nothing here bounds a run that spawns more workers than it
10
+ declared, nests delegation deeper than the stage intended, or keeps spending.
11
+
12
+ Some hosts refuse delegation outside their limits. Each control below states
13
+ what it covers.
14
+ QFAI sets none of them, so the host defaults stand.
15
+
16
+ **A backstop sits above the declared shape, never at it.** Leave room for other
17
+ permitted agents sharing the host limit. The policy decides the ordinary case.
18
+
19
+ Claude Code 2.1.217 or later:
20
+
21
+ | Control | Default | What it bounds |
22
+ | ------------------------------------------------------------------------------------ | ---------------------------- | ---------------------------------------------------------- |
23
+ | `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` | 3 (1 in 2.1.217 and 2.1.218) | How deep delegation nests. `1` turns nesting off |
24
+ | `CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS` | 20 | When new Agent tool spawns are refused |
25
+ | `--max-budget-usd` in print mode; `maxBudgetUsd` / `max_budget_usd` in the Agent SDK | none | What one run may spend, in US dollars, sub-agents included |
26
+
27
+ The spawn limit has exceptions for ultracode, `/subtask` forks, and resuming an
28
+ exited agent.
29
+
30
+ Codex:
31
+
32
+ | Control | Default | What it bounds |
33
+ | ----------------------------------------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------- |
34
+ | `agents.max_concurrent_threads_per_session` in `config.toml` (alias `agents.max_threads`) | chosen by Codex when unset | How many spawned-agent threads are open at once, the primary excluded |
35
+
36
+ No equivalent was confirmed for nesting depth or for a spend cap.
37
+
38
+ GitHub Copilot CLI:
39
+
40
+ | Control | Documented default | What it bounds |
41
+ | ---------------------------------- | ------------------------------------ | ---------------------------------------- |
42
+ | `subagents.maxDepth` setting | 6 in the limits table | How deep sub-agents nest |
43
+ | `COPILOT_SUBAGENT_MAX_DEPTH` | 4 in the environment-variable table | How deep sub-agents nest |
44
+ | `subagents.maxConcurrency` setting | set by the Copilot plan, 2 to 32 | How many sub-agents run at once |
45
+ | `COPILOT_SUBAGENT_MAX_CONCURRENT` | 32 in the environment-variable table | How many sub-agents run at once |
46
+ | `--max-ai-credits` | unset | AI credits per response, as a soft limit |
47
+
48
+ The two settings take effect only on usage-based billing plans.
49
+
50
+ The depth defaults disagree across the CLI documentation. Which control takes
51
+ precedence was not confirmed.
52
+
53
+ VS Code Local harness (`runSubagent`):
54
+
55
+ | Control | Default | What it bounds |
56
+ | ---------------------------------------------- | ------- | --------------------------------------------------------------------- |
57
+ | `chat.subagents.allowInvocationsFromSubagents` | `false` | Whether a sub-agent may start sub-agents. Nesting stops at depth five |
58
+
59
+ No equivalent was confirmed for concurrent sub-agents or for a spend cap. None
60
+ was confirmed for any of the three in the Copilot cloud agent.
@@ -0,0 +1,25 @@
1
+ # Placeholder Scan
2
+
3
+ Read when the placeholder scan reports a hit.
4
+
5
+ ## What the placeholder scan does not flag
6
+
7
+ **`OQ` and `OPEN QUESTION` are exempt only as tracking structure.** Exempt: the `Open Questions` heading, a register
8
+ table header, and a question row containing the fields required by its register. Story-tree `open-questions.md` uses
9
+ `ID | Content | Approach | Status`; an empty register contains the heading and table header without a question row.
10
+ Discussion registers use their own template fields. A register row's Status is structure too: `TODO` in the Status cell of a
11
+ `decisions.md` or `open-questions.md` row is the row's state, not a placeholder. Article II and `.qfai/assistant/rule/workflow.md` both end an
12
+ unverifiable fact by recording an Open Question, so the tracked record they prescribe must never be reported as an
13
+ unresolved placeholder. Everywhere else the two strings are still scanned: a bare `OQ` or `OPEN QUESTION` left as a
14
+ value in generated spec prose or a contract field, or a row missing a required field, is a hit like any other token.
15
+
16
+ **A documented `TBD` is a compliant record.** `.qfai/assistant/rule/constitution.md` Article II and `.qfai/assistant/rule/thinking.md` require writing `TBD` together with a note of what evidence is missing, and `.qfai/assistant/rule/thinking.md` requires raising the matching Open Question for the same fact. Both halves together are the finished form, not an
17
+ unfinished one; do not report it and do not delete it — deleting it destroys the record of the missing evidence, which is the whole point of the marker. A `TBD` missing either half — no note, or no Open Question — is a hit.
18
+
19
+ ## What a surviving hit obligates
20
+
21
+ A hit is **reported, not silently cleared**, and **cleared by a re-scan, not by assertion**. Fix what you can, then run the scan again over the same artifacts: _resolved_ is the verdict for a hit the re-run no longer reports, and that re-run is its evidence. It is not available for a hit still present at that file and line — a token still readable there is unresolved whatever the report
22
+ calls it. List every hit the re-scan still finds alongside the completion claim — file, line, token — and state for each one whether it is deferred with rationale or recorded as an Open Question. A completion claim that omits a surviving hit is invalid evidence under the rules above. Completion is blocked while a surviving hit is neither of the two.
23
+
24
+ **Severity floor on the verdict.** _Deferred with rationale_ and _recorded as an Open Question_ are NOT available for a hit that stands in for a concrete security defect, data loss or corruption, or a correctness defect that would break a released contract. Such a hit is cleared only by a named fix or by dropping the item from scope; recording it and declaring completion anyway is
25
+ prohibited, exactly as `.qfai/assistant/rule/shared-skill-delegation-baseline.md` withholds that same exit for that same class. While neither of the two remaining verdicts applies, completion stays blocked.
@@ -0,0 +1,41 @@
1
+ # Reviewer Findings
2
+
3
+ Read when a reviewer finding is written or judged.
4
+
5
+ ## Finding provenance
6
+
7
+ - Every finding must declare a severity (`blocking` or `advisory`) and a `Traces to:` value.
8
+ - `Traces to:` names what the finding enforces. Legal values:
9
+ - an upstream obligation — a `BF-*`, `AC-*`, `EX-*`, `BR-*` or contract ID, or a named shared rule **that governs the product's behaviour**;
10
+ - `defect:correctness`, `defect:security`, or `defect:code-quality` — a defect demonstrable from the changed artifacts themselves, cited with the evidence that demonstrates it (see `.qfai/assistant/rule/drift-protocol.md#defect-or-new-scope-decide-this-first`). A reviewer who can show the deliverable is wrong on its own terms does not need an `AC-*` to say so;
11
+ - `record:<CODE>` — a defect in the run's own record rather than in the product: an evidence section, a round block, an anchor, or provenance prose. `<CODE>` names the record rule;
12
+ - `none` — reviewer-originated scope, i.e. a new product obligation upstream never asked for.
13
+ - `record:*` and `none` MUST be recorded as `advisory`; neither can be `blocking` or gate `DONE`. A `record:*` finding never re-runs the row: the orchestrator files it in the record-defect queue the reviewing stage's own completion contract names, and that contract is what drains it (`.qfai/assistant/rule/drift-protocol.md#the-record-defect-queue`). **The class needs a drain:
14
+ only a stage whose completion conditions require that queue drained may use it — today `/qfai-implement` alone, so `/qfai-sdd`, `/qfai-configure`, `/qfai-verify`, `/qfai-discussion` and `/web-research` reviewers must not, and there the finding keeps the class it would otherwise have had.** An entry closes only on a repaired record;
15
+ `record:unchecked` is never a substitute for the repair — a record rule worth a round is worth a validator code.
16
+ - **Integrity is not record class.** Evidence copied from another round or a sibling row, an anchor resolving to a run other than the one it names, and a reviewer that authored what it reviews all claim work that was not done or independence that is missing. A `PASS` built on them is refused,
17
+ so they stay `blocking` as `defect:code-quality` and are never filed as `record:*` — which covers an honestly produced record that is merely wrong.
18
+ - A `none` advisory takes the Change Request / Open Question path (`.qfai/assistant/rule/drift-protocol.md#reviewer-originated-obligations`); a `record:*` advisory takes the queue above. Neither goes to the implementer.
19
+ - Only `blocking` findings force `REVISE`, and only a finding citing a behaviour-governing obligation or a defect class may be one. **The trace class bounds which findings may block; the severity is declared, and it settles whether one does.** Read as "an obligation trace is blocking", the same item was a discussion-blocking defect to one reviewer and carried advice to the next.
20
+ - An obligation-traced finding is recorded `advisory` where a named section places the work outside the reviewed stage. The discussion review's implementation precision is that section
21
+ (`.qfai/assistant/rule/review-convergence.md#discussion-review-precision`): the obligation is agreed, and what the advice is about is how a later stage implements it, so the finding is carried to that stage rather than demanded here. Nothing else lowers a behaviour-governing finding to `advisory`.
22
+
23
+ ## What a reviewer may demand more of (MUST)
24
+
25
+ A finding that asks for more work — another item, more detail, a wider set — is admissible only on
26
+ the concrete artifacts.
27
+
28
+ | Admissible on | Inadmissible on |
29
+ | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
30
+ | business flows, user stories, acceptance criteria, examples, test cases | business rules, non-functional requirements, policies and decisions, architecture |
31
+
32
+ Two demands stay admissible on any artifact:
33
+
34
+ - that an abstract item already recorded carry its mandatory pair, such as a quality floor naming
35
+ its verification method;
36
+ - that a safety-floor item be met: security, accessibility, data-loss handling, or validation at a
37
+ trust boundary (`.agents/rules/minimal-implementation.md` § 2).
38
+
39
+ This bounds what a reviewer may require, never what a reviewer may report. A demand the table does
40
+ not admit, such as one for another business rule, is recorded as `advisory` and cannot force
41
+ `REVISE`.
@@ -0,0 +1,35 @@
1
+ # Reviewer Remit
2
+
3
+ Read when a reviewer is briefed.
4
+
5
+ ## Reviewer remit (in scope per stage)
6
+
7
+ A finding outside the reviewing stage's remit is recorded and deferred, never blocking:
8
+
9
+ | Stage | In scope | Out of scope (record and defer) |
10
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
11
+ | `/qfai-discussion` | Requirement clarity, scope boundary, decision traceability | Spec structure, runtime behavior |
12
+ | `/qfai-sdd` | Spec / contract consistency, testability, traceability edges, each document in its template's shape | Runtime enforcement correctness, code quality |
13
+ | `/qfai-implement` | Code quality, spec alignment of the item, RED/GREEN evidence, silent failure and type design across the whole of every file the change touches, and security across the same files and along every input the change adds or alters to where it is used | Upstream spec content, contract design, and a finding on code in a touched file that the change did not add or alter |
14
+ | `/qfai-prototyping` | The prototype against its UI contracts and the root `DESIGN.md`, loop evidence, the handoff | Spec and contract content, downstream implementation code |
15
+ | `/qfai-migration-v1-to-v2` | Migration plan and report fidelity, ID mapping, every deletion listed in the reports, each written document in its template's shape | New story content and downstream implementation quality |
16
+ | `/qfai-configure` | Config / manifest validity and the surfaces the run generated | Spec content, implementation structure |
17
+ | `/qfai-verify` | Gate execution, evidence completeness, report / artifact fidelity | Authoring quality of the artifacts it verifies |
18
+ | `/web-research` | Source authority and freshness, citation accuracy, claim support | Spec content, implementation structure |
19
+ | `/qfai-grilling` | Decisions asked rather than assumed, facts naming where they were read, the session's end condition | The merit of what the user decided, and the artifacts the invoking stage writes from it |
20
+ | `/qfai-grill` | The same, reported to the user rather than to a stage | The merit of what the user decided; there is no artifact to review |
21
+ | `/qfai-maintain` | That the diff changes no behaviour, and the checks run over it | Whether the new wording is the better one |
22
+ | `/qfai-triage` | That no tracked file changed, the recorded outcome, each follow-up, and the sources an answer cites | The work a follow-up request describes |
23
+ | `/qfai-run` | The artifacts the session writes, in the specification or code review the plan names after a stage | Whether the route the decision rules chose was the right one |
24
+
25
+ Article VII excess in the reviewing stage's own artifacts is in scope;
26
+ quality of downstream implementation code is deferred at upstream stages.
27
+
28
+ Apply this route only where the installed Article VII governs the artifact.
29
+ A retained constitution does not gain newer authority from refreshed cards.
30
+ Report an unsupported Article VII route as advisory and follow the installed constitution.
31
+
32
+ A step's remit is its owner's row. A `common-*` step's work is reviewed under
33
+ the row of the skill whose stage ran it.
34
+
35
+ **Fallback for any stage not listed.** A stage that references this baseline without a row above has, as its remit, the artifacts that stage itself produces; everything upstream of them is out of scope, recorded and deferred. Add the row when a new stage starts routing blocking reviewers, so the in/out split is not re-derived per run.