@feigi/fleet-ctl 3.23.36 → 3.23.38

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 (205) hide show
  1. package/package.json +1 -1
  2. package/scripts/cell-readout.mjs +38 -11
  3. package/scripts/main-checkout.mjs +1 -1
  4. package/scripts/member-write-guard.mjs +1 -1
  5. package/scripts/repo-root.mjs +1 -1
  6. package/skills/run-team/references/reaping.md +1 -1
  7. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  8. package/scripts/agent-test.test.mjs +0 -1640
  9. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  10. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  11. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  12. package/scripts/apply-ruleset.test.mjs +0 -421
  13. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  14. package/scripts/arg.test.mjs +0 -1354
  15. package/scripts/board-cli.test.mjs +0 -710
  16. package/scripts/board-identity.test.mjs +0 -429
  17. package/scripts/board-liveness-banner.test.mjs +0 -119
  18. package/scripts/board-prev-shape.test.mjs +0 -228
  19. package/scripts/board-tryparse-null.test.mjs +0 -119
  20. package/scripts/board.test.mjs +0 -3121
  21. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  22. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  23. package/scripts/candidates.test.mjs +0 -2312
  24. package/scripts/caveat-unification-prose.test.mjs +0 -98
  25. package/scripts/cell-readout.test.mjs +0 -615
  26. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  27. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  28. package/scripts/ci-state-prose.test.mjs +0 -113
  29. package/scripts/ci-state.test.mjs +0 -1933
  30. package/scripts/ci-vacuous-green.test.mjs +0 -368
  31. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  32. package/scripts/claim-lifecycle.test.mjs +0 -187
  33. package/scripts/claim-ticket.test.mjs +0 -1122
  34. package/scripts/closing-keyword-prose.test.mjs +0 -193
  35. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  36. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  37. package/scripts/compute-board.test.mjs +0 -1214
  38. package/scripts/compute-spend.test.mjs +0 -517
  39. package/scripts/consumer-technology-prose.test.mjs +0 -126
  40. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  41. package/scripts/cwd-isolation-pins.mjs +0 -83
  42. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  43. package/scripts/delete-merged-branch.test.mjs +0 -576
  44. package/scripts/derive-testcmd.test.mjs +0 -595
  45. package/scripts/diff-stats.test.mjs +0 -404
  46. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  47. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  48. package/scripts/dispositions-check.test.mjs +0 -936
  49. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  50. package/scripts/drop-merged-label.test.mjs +0 -479
  51. package/scripts/exec-stub.mjs +0 -93
  52. package/scripts/exec-stub.test.mjs +0 -69
  53. package/scripts/expected-jobs-prose.test.mjs +0 -80
  54. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  55. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  56. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  57. package/scripts/finisher-died-prose.test.mjs +0 -31
  58. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  59. package/scripts/finisher-halt-prose.test.mjs +0 -106
  60. package/scripts/finisher-name-prose.test.mjs +0 -134
  61. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  62. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  63. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  64. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  65. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  66. package/scripts/fleet-bootstrap.test.mjs +0 -75
  67. package/scripts/fleet-heartbeat.test.mjs +0 -450
  68. package/scripts/fleet-provenance.test.mjs +0 -138
  69. package/scripts/fleet-run.test.mjs +0 -90
  70. package/scripts/fleet-state.test.mjs +0 -460
  71. package/scripts/fleet-tick-prose.test.mjs +0 -300
  72. package/scripts/fleet-tick.test.mjs +0 -2444
  73. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  74. package/scripts/frontmatter-check.test.mjs +0 -436
  75. package/scripts/git-env.test.mjs +0 -149
  76. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  77. package/scripts/gone-walk.test.mjs +0 -213
  78. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  79. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  80. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  81. package/scripts/implementer-model-tier.test.mjs +0 -235
  82. package/scripts/inflight-citation-prose.test.mjs +0 -144
  83. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  84. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  85. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  86. package/scripts/inflight.test.mjs +0 -2882
  87. package/scripts/injection-control-prose.test.mjs +0 -404
  88. package/scripts/install-root-audit.test.mjs +0 -464
  89. package/scripts/instrument-check-prose.test.mjs +0 -235
  90. package/scripts/instruments.test.mjs +0 -787
  91. package/scripts/is-cli.test.mjs +0 -99
  92. package/scripts/issue-tracker-prose.test.mjs +0 -71
  93. package/scripts/json.test.mjs +0 -364
  94. package/scripts/ledger-dispatch.test.mjs +0 -927
  95. package/scripts/ledger-grammar.test.mjs +0 -227
  96. package/scripts/ledger-read-require-file.test.mjs +0 -197
  97. package/scripts/ledger-rotate.test.mjs +0 -142
  98. package/scripts/ledger.test.mjs +0 -3436
  99. package/scripts/line-distance-prose.test.mjs +0 -245
  100. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  101. package/scripts/locale-pin-prose.test.mjs +0 -189
  102. package/scripts/main-checkout.test.mjs +0 -332
  103. package/scripts/member-outcome-prose.test.mjs +0 -167
  104. package/scripts/member-outcomes-header.test.mjs +0 -129
  105. package/scripts/member-outcomes-prose.test.mjs +0 -63
  106. package/scripts/member-outcomes.test.mjs +0 -638
  107. package/scripts/member-prompt-prose.test.mjs +0 -165
  108. package/scripts/member-record.test.mjs +0 -541
  109. package/scripts/member-write-guard.test.mjs +0 -214
  110. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  111. package/scripts/merge-gate.test.mjs +0 -613
  112. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  113. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  114. package/scripts/net-watchdog-prose.test.mjs +0 -79
  115. package/scripts/net.test.mjs +0 -211
  116. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  117. package/scripts/no-undo-audit.test.mjs +0 -3961
  118. package/scripts/no-wave.test.mjs +0 -138
  119. package/scripts/node-floor-sweep.test.mjs +0 -611
  120. package/scripts/pointer-target-prose.test.mjs +0 -186
  121. package/scripts/pr-cost.test.mjs +0 -521
  122. package/scripts/pr-overlap.test.mjs +0 -692
  123. package/scripts/printf-die-sweep.test.mjs +0 -384
  124. package/scripts/prompt-renderer.mjs +0 -40
  125. package/scripts/prompt-renderer.test.mjs +0 -68
  126. package/scripts/prose-pin.mjs +0 -807
  127. package/scripts/prose-pin.test.mjs +0 -1034
  128. package/scripts/prove-merge.test.mjs +0 -995
  129. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  130. package/scripts/quiet-payload-prose.test.mjs +0 -222
  131. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  132. package/scripts/reap.test.mjs +0 -4432
  133. package/scripts/reaping-prose.test.mjs +0 -239
  134. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  135. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  136. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  137. package/scripts/recipe-prove.test.mjs +0 -1042
  138. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  139. package/scripts/release-label-required-prose.test.mjs +0 -71
  140. package/scripts/release-label-split-prose.test.mjs +0 -184
  141. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  142. package/scripts/release-ticket.test.mjs +0 -5099
  143. package/scripts/renovate-release-contract.test.mjs +0 -379
  144. package/scripts/repo-root.test.mjs +0 -873
  145. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  146. package/scripts/review-agent-report-only.test.mjs +0 -49
  147. package/scripts/review-core-booking.test.mjs +0 -35
  148. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  149. package/scripts/review-core-reads.test.mjs +0 -478
  150. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  151. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  152. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  153. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  154. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  155. package/scripts/review-core-testcmd.test.mjs +0 -335
  156. package/scripts/review-core-unrun.test.mjs +0 -566
  157. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  158. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  159. package/scripts/review-host-fixture.mjs +0 -89
  160. package/scripts/review-in-run-retry.test.mjs +0 -211
  161. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  162. package/scripts/review-path-default.test.mjs +0 -796
  163. package/scripts/review-runner-spawns.test.mjs +0 -95
  164. package/scripts/review-runner.test.mjs +0 -166
  165. package/scripts/review-tier-audit.test.mjs +0 -140
  166. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  167. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  168. package/scripts/run-team-local-hook.test.mjs +0 -442
  169. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  170. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  171. package/scripts/section-between-guard-prose.test.mjs +0 -379
  172. package/scripts/select-dimensions.test.mjs +0 -674
  173. package/scripts/shared-refusal.test.mjs +0 -388
  174. package/scripts/shell-traps-prose.test.mjs +0 -504
  175. package/scripts/shortlist.test.mjs +0 -380
  176. package/scripts/slow-transport.mjs +0 -72
  177. package/scripts/snapshot-repo.test.mjs +0 -1006
  178. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  179. package/scripts/spend-view.test.mjs +0 -312
  180. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  181. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  182. package/scripts/staleness.test.mjs +0 -893
  183. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  184. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  185. package/scripts/strip-comments.mjs +0 -44
  186. package/scripts/temp-dir.mjs +0 -47
  187. package/scripts/ticket-router.test.mjs +0 -981
  188. package/scripts/tier-check.test.mjs +0 -828
  189. package/scripts/tier-outcomes-header.test.mjs +0 -518
  190. package/scripts/tier-outcomes.test.mjs +0 -572
  191. package/scripts/tier-roles.test.mjs +0 -535
  192. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  193. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  194. package/scripts/unattended-git-sweep.test.mjs +0 -142
  195. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  196. package/scripts/verify-sha.test.mjs +0 -692
  197. package/scripts/watcher-degraded-block.test.mjs +0 -369
  198. package/scripts/watcher-key-prose.test.mjs +0 -106
  199. package/scripts/within-run-pair-prose.test.mjs +0 -212
  200. package/scripts/worktree-audit.test.mjs +0 -1408
  201. package/scripts/worktree-head-prose.test.mjs +0 -276
  202. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  203. package/scripts/worktree-model-prose.test.mjs +0 -216
  204. package/scripts/worktree-porcelain.mjs +0 -35
  205. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,1130 +0,0 @@
1
- // #1002. Phase 2 hands the controller a run of `>` blocks and says to carry
2
- // each one VERBATIM into every implementer prompt; the Reviewers section does
3
- // the same for the fix-applier prompt and for the halt-cause text it gives the
4
- // finisher. Those blocks are the only text a member ever sees.
5
- //
6
- // The presence pins on them — `dispatch-block-pins-prose.test.mjs`,
7
- // `member-prompt-prose.test.mjs`, `stash-prohibition-prose.test.mjs`,
8
- // `fix-applier-correction-rules-prose.test.mjs` — cover the LOCATION half and
9
- // only that half. A block deleted, gutted or moved out of the `>` quoting reds
10
- // there. A sentence APPENDED inside a block, carving an exception out of a rule
11
- // already pinned in it, leaves every pinned fragment byte-identical and stays
12
- // green; so does a meaning-changing clause inserted MID-GAP, between the two
13
- // anchors of an `<anchor A>.{0,N}?<anchor B>` span, wherever that gap still has
14
- // headroom. Both shapes are measured, not assumed — four mutants of the first
15
- // and four of the second, each recorded on #1002.
16
- //
17
- // MECHANISM, and #1002's triage ruling. A whole-block golden fixture. Not a
18
- // tighter regex: `doesNotMatch(/\bunless\b|\bexcept\b/i)` was tried against this
19
- // exact question and failed all three of its controls — scoped to the pinned
20
- // sentence it did not kill its own mutant, broadened enough to kill it four
21
- // rewordings preserved the defect, and it reds on a legitimate edit, since a
22
- // standing rule containing the word "unless" is exactly the kind of text that
23
- // belongs in a verbatim block. Not an LLM judge and not a schema'd rule format
24
- // either: both were considered and rejected on #1002, the first for buying
25
- // semantics at the price of a nondeterministic gate, the second as a large
26
- // change that still has to keep these blocks readable as prose. What settles it
27
- // is what the blocks ARE: verbatim dispatch text, whose whole purpose is
28
- // reaching the member unchanged. The assertion that fits that is equality
29
- // against a known-good copy, not the presence of fragments inside it.
30
- //
31
- // THE COST IS INTENDED. Because the expected text lives HERE, a legitimate edit
32
- // to a block reds until its fixture is updated in the same change. These blocks
33
- // are change-controlled by construction, and that re-blessing is the review
34
- // point a presence pin does not have. Every failure message below says so and
35
- // says where, so the next editor updates the fixture deliberately rather than
36
- // reading the red as breakage.
37
- //
38
- // COMPLEMENTARY TO THE PRESENCE PINS, never a replacement, and none of them was
39
- // deleted for this. A golden red says "this block changed"; a fragment red says
40
- // WHICH RULE was lost, and that is the more actionable half. Dropping a fragment
41
- // pin because this file now covers its block would trade a message naming the
42
- // rule for a diff the reader has to read.
43
- //
44
- // THE FIXTURES ARE OWNED HERE, never derived from `SKILL.md` at test time. A
45
- // fixture read out of the instruction file compares that file to itself and
46
- // asserts nothing — which is the one way to write this mechanism so that it
47
- // passes unconditionally.
48
- //
49
- // SCOPE. Every block of the implementer agent body and every quote run in the Reviewers
50
- // section has a fixture, and the two coverage tests below are what keep that
51
- // true as blocks are added — a block this file does not name is a block a
52
- // carve-out can be appended to unseen. Prose that is NOT verbatim dispatch text
53
- // is deliberately left out: the golden form is justified by these blocks being
54
- // change-controlled, and that argument does not carry to ordinary prose, where
55
- // the same ceiling stays recorded and open in
56
- // `immutable-body-claim-prose.test.mjs`. The copies of these blocks in other
57
- // files are a separate question too — `docs/agents/issue-tracker.md` reproduces
58
- // the issue-read block, and `tracker-block-copy-prose.test.mjs` compares the two
59
- // (#374 owns that comparison's own fixture; nothing here touches it).
60
- //
61
- // WHERE THE IMPLEMENTER BLOCKS LIVE (#1804). They were a run of `>` quote
62
- // blocks in SKILL.md's phase 2 until spec 2026-09-24 § 2 Decision 2 moved them
63
- // into the implementer agent body, `agents/fleet-implementer-<cell>.agent.md`
64
- // (byte-identical in every cell, pinned by implementer-model-tier.test.mjs), which each harness
65
- // injects as the member's system prompt; #1804 deleted the SKILL.md copy. The
66
- // body carries no `>` gutter, so a block there is delimited the only way the
67
- // body itself can say: it opens on its own opener's paragraph and runs to the
68
- // paragraph that opens the next fixtured block, or to the end of the body. That
69
- // makes the body's coverage STRONGER than a quote run's — any paragraph added
70
- // to it lands inside some fixtured block and reds that block's golden, and the
71
- // one place outside every block, ahead of the first opener, is pinned empty.
72
- import { test } from "node:test";
73
- import assert from "node:assert/strict";
74
- import { readFileSync } from "node:fs";
75
- import { join } from "node:path";
76
- import { between, phrase, quoteBlock, quoteBlocks } from "./prose-pin.mjs";
77
-
78
- const REPO = join(import.meta.dirname, "..");
79
- const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
80
-
81
- // The body alone — everything after the frontmatter's closing `---`.
82
- const AGENT_FILE = readFileSync(join(REPO, "agents", "fleet-implementer-slow-high.agent.md"), "utf8");
83
- const BODY = AGENT_FILE.split("---").slice(2).join("---");
84
-
85
- // The Reviewers section is sliced before any opener is looked for, for the
86
- // reason `quoteBlock`'s uniqueness assert would otherwise fire. The body is its
87
- // own surface and needs no slice; `body` exists so both surfaces take the same
88
- // shape — each takes the text to slice, defaulting to the real file, so the
89
- // mutation controls below can re-run the whole extraction against a modified
90
- // copy instead of asserting against a hand-built imitation of it.
91
- const body = (text = BODY) => text;
92
- const reviewers = (text = RUN_TEAM) =>
93
- between(text, "### Reviewers", "#### Fallback: hand-dispatched reviewer", "run-team's Reviewers section");
94
-
95
- // Wrapping is normalized away on both sides, and nothing else is.
96
- //
97
- // Wrapping, because every editor that touches `SKILL.md` reflows it, and a pin
98
- // that reds on a rewrap is one the next person weakens or deletes. `**`
99
- // emphasis, punctuation and word choice are NOT normalized: they are the
100
- // verbatim text itself. This is the one place where the golden is deliberately
101
- // stricter than the presence pins beside it, which do strip `**` — they have
102
- // to, because a `**` seam inside a regex-matched span makes the seam's exact
103
- // position test surface and reds with a message claiming some rule was lost. A
104
- // golden cannot misdirect that way: its message says the block changed, which a
105
- // moved `**` is.
106
- //
107
- // Paragraph boundaries are kept. A quote line with no words on it is a paragraph
108
- // break the member reads, so merging two paragraphs is a change to the block and
109
- // not a rewrap. Any such line closes the paragraph whatever its own gutter says,
110
- // which is also what keeps a gutter left with a trailing space (`> `) from
111
- // silently joining two paragraphs — the same false green `prose-pin.mjs`'s
112
- // `paragraph` matches `\n[ \t]*\n` to avoid.
113
- //
114
- // NESTING DEPTH IS STRUCTURE, not text, and this is the half a plain
115
- // one-level strip gets wrong. The fix-applier prompt quotes a refuter prompt
116
- // inside itself at `> >`; strip one level and those inner `>` markers become
117
- // ordinary words, so their position depends on where the OUTER block happens to
118
- // wrap — a pure reflow of that prompt then reds, which is exactly the false red
119
- // that gets a pin deleted (measured: the first draft of this file did that, and
120
- // the fix-applier fixture reddened on a 45-column rewrap of identical words).
121
- // Strip every level, count it instead, and re-emit the depth as a marker, and
122
- // the comparison is reflow-proof while un-nesting that prompt — which changes
123
- // what the fix-applier pastes — still reds.
124
- //
125
- // Depth is RELATIVE to the block's own outermost level, so how many gutter
126
- // levels the FIXTURE carries does not matter: a block re-blessed by copying it
127
- // out of `SKILL.md` with its `> ` markers left on normalizes the same as one
128
- // with them taken off, while the nesting INSIDE it is preserved either way.
129
- // Measured over lines that carry words, never over the breaks — a break written
130
- // as a bare newline rather than a bare `>` would otherwise drag the base level
131
- // down and re-read the whole block as one level of nesting.
132
- const norm = (text) => {
133
- const rows = text.split("\n").map((line) => {
134
- const gutter = line.match(/^(?:>[ \t]?)*/)[0];
135
- return { depth: (gutter.match(/>/g) ?? []).length, words: line.slice(gutter.length).trim() };
136
- });
137
- const written = rows.filter((r) => r.words !== "");
138
- const base = written.length === 0 ? 0 : Math.min(...written.map((r) => r.depth));
139
- const paragraphs = [];
140
- for (const { depth, words } of rows) {
141
- const open = paragraphs[paragraphs.length - 1];
142
- if (words === "") {
143
- if (open) open.closed = true;
144
- continue;
145
- }
146
- if (open && !open.closed && open.depth === depth) open.words.push(words);
147
- else paragraphs.push({ depth, words: [words], closed: false });
148
- }
149
- return paragraphs
150
- .map((p) => `${"> ".repeat(Math.max(p.depth - base, 0))}${p.words.join(" ").split(/\s+/).join(" ")}`)
151
- .join("\n\n");
152
- };
153
-
154
- // The body's blocks, by character span, so a block is always a true substring
155
- // of the text it came from — the mutation controls splice into the source by
156
- // `replace(raw, …)` and would silently miss on a rejoined copy.
157
- const paragraphSpans = (text) => {
158
- const spans = [];
159
- const sep = /\n[ \t]*\n/g;
160
- let at = 0;
161
- for (let m; (m = sep.exec(text)) !== null; at = m.index + m[0].length) spans.push([at, m.index]);
162
- spans.push([at, text.length]);
163
- return spans.filter(([a, b]) => text.slice(a, b).trim() !== "");
164
- };
165
- const opensOn = (text, [a, b], opener) =>
166
- new RegExp(`^${phrase(opener).source}`).test(text.slice(a, b).split(/\s+/).join(" ").trim());
167
- const heads = (text, spans) => spans.flatMap((sp, i) => (REGION_BLOCKS.some((b) => opensOn(text, sp, b.opener)) ? [i] : []));
168
-
169
- // Loud in both failure directions, for `quoteBlock`'s reason: an extractor that
170
- // returns "" for a block it cannot find compares empty against empty, and a
171
- // deleted block passes.
172
- function bodyBlock(text, opener, what) {
173
- const spans = paragraphSpans(text);
174
- const at = spans.flatMap((sp, i) => (opensOn(text, sp, opener) ? [i] : []));
175
- assert.notEqual(at.length, 0, `${what}: no paragraph of the implementer agent body opens on "${opener}" — the block was deleted or its opening words changed. Re-anchor or restore it; this throws rather than comparing a golden fixture against nothing`);
176
- assert.equal(at.length, 1, `${what}: ${at.length} paragraphs of the implementer agent body open on "${opener}" — narrow the opener`);
177
- const next = heads(text, spans).find((h) => h > at[0]);
178
- return text.slice(spans[at[0]][0], spans[(next ?? spans.length) - 1][1]);
179
- }
180
- // Every block the body holds, split at every fixtured opener, plus whatever sits
181
- // ahead of the first one — text no fixture covers.
182
- function bodyBlocks(text) {
183
- const spans = paragraphSpans(text);
184
- const hs = heads(text, spans);
185
- return {
186
- lead: hs.length === 0 ? text.trim() : text.slice(0, spans[hs[0]][0]).trim(),
187
- blocks: hs.map((h, k) => text.slice(spans[h][0], spans[(hs[k + 1] ?? spans.length) - 1][1])),
188
- };
189
- }
190
-
191
- // The fixtures. One entry per quote run, in source order — the coverage tests
192
- // below hold both halves of that: one per run, and in that order.
193
- //
194
- // `opener` is the block's identifier: the words it BEGINS with, which is what
195
- // makes it name the block rather than merely occur in it. `golden` is the block
196
- // as it must reach the member, gutter stripped, wrapped however `SKILL.md`
197
- // happened to wrap it when the fixture was last blessed — `norm` makes that
198
- // wrapping irrelevant on both sides.
199
- const REGION_BLOCKS = [
200
- {
201
- what: "the implementer body's unattended-member identity block",
202
- opener: "**You are an unattended fleet member.**",
203
- golden: [
204
- "**You are an unattended fleet member.** No maintainer is reachable, no user",
205
- "will answer you, and no approval gate will ever clear for you. Report to the",
206
- "controller and to nobody else. Where a skill offers a maintainer-present step",
207
- "and an unattended one, yours is the unattended one.",
208
- ],
209
- },
210
- {
211
- what: "the implementer body's worktree block",
212
- opener: "You are ALREADY in worktree",
213
- golden: [
214
- "You are ALREADY in worktree `<abs-path>` on branch `<branch>`. Do NOT create",
215
- "another worktree. Verify with `git rev-parse --git-dir` and",
216
- "`git rev-parse --git-common-dir`. Skip the using-git-worktrees skill's Step 1.",
217
- ],
218
- },
219
- {
220
- what: "the implementer body's edit/read session-root block",
221
- opener: "**`edit` and `read` resolve",
222
- golden: [
223
- "**`edit` and `read` resolve a bare relative path against the SESSION ROOT —",
224
- "the controller's own main checkout — not against your worktree and not",
225
- "against your `bash` cwd. Give them the absolute worktree path on every",
226
- "call.** They take no `cwd` parameter, so shell discipline does not reach",
227
- "them: a member whose every command is correctly scoped with `cd` or `git -C`",
228
- "still leaks through `edit`/`read` alone, and the rev-parse check above",
229
- "settles only where your SHELL is. Your worktree is the `<abs-path>` you were",
230
- "handed; the main checkout is the parent of `git rev-parse",
231
- "--path-format=absolute --git-common-dir`, which you derive yourself — nothing",
232
- "substitutes it for you.",
233
- "",
234
- "So: prefix every `edit` and `read` path with an absolute path — the",
235
- "worktree `<abs-path>` for repo files, `<scratch>/impl-<N>/` for scratch —",
236
- "never a bare relative one, and never `plugin/scripts/foo.mjs` on its own.",
237
- "A `member-write-guard` refusal means the path hit the main checkout — for",
238
- "`bash`, a missing or main-checkout `cwd` — so re-issue it absolute, under",
239
- "your worktree.",
240
- ],
241
- },
242
- {
243
- what: "the implementer body's distilled-brief block",
244
- opener: "Here is the ticket's distilled brief",
245
- golden: [
246
- "Here is the ticket's distilled brief, already read once at the Pull —",
247
- "title, plus whichever of the `## Agent Brief` comment or the issue body",
248
- "carries the ticket's actual brief, and its `Out of scope`, pasted verbatim:",
249
- "`<distilled brief>`. Skip the fetch below if this already answers what you",
250
- "need.",
251
- ],
252
- },
253
- {
254
- what: "the implementer body's issue-read block",
255
- opener: "Read the issue with",
256
- golden: [
257
- "Read the issue with `gh issue view <N> --json title,body,comments --jq '.title, .body, (.comments[]|.author.login + \": \" + .body)'`.",
258
- "Not bare `gh issue view <N> --comments` — non-interactively that prints only",
259
- "the comments, and nothing at all when there are none, dropping the title and",
260
- "body either way, exit 0, so the loss is silent. The `## Agent Brief` comment",
261
- "is authoritative over the issue body. Read the issue **before",
262
- "touching code**: with the repo in front of you, still undecided or needing",
263
- "human hands you do not have → bail, name the cause, do not implement.",
264
- ],
265
- },
266
- {
267
- what: "the implementer body's re-derive block",
268
- opener: "**Re-derive the ticket's claims",
269
- golden: [
270
- "**Re-derive the ticket's claims against `origin/main` before implementing** —",
271
- "not the working tree, and not the ticket's line numbers, which drift. The Pull",
272
- "runs a cheap version of this check, so what reaches you is what a `grep` could",
273
- "not settle; you have the tree, so you are the backstop. Already fixed → report",
274
- "that with the commit and do NOT invent work. An acceptance criterion the tree",
275
- "now **contradicts** is a bail, not a thing to implement: say which, and stop.",
276
- ],
277
- },
278
- {
279
- what: "the implementer body's claim-discipline block",
280
- opener: "**Claim discipline, on every ticket:**",
281
- golden: [
282
- "**Claim discipline, on every ticket:**",
283
- "",
284
- "1. The issue body is a lead, never a citation. Every factual claim the diff",
285
- " restates needs a settling command run against the tree first.",
286
- "2. Write no prose the ticket did not ask for — added prose is where minted",
287
- " claims enter.",
288
- "3. No positional references (`the closing/second/last X`); name the thing.",
289
- "4. Evidence from another repo is cited by host: a github.com source as",
290
- " `owner/repo#N`; anything else (GHE, GitLab, internal) as prose naming host",
291
- " and repo and saying it cannot be settled from this repo. A bare `#N` is only",
292
- " for the current repo's own issues and PRs.",
293
- "5. Never write a count or tally into present-tense prose; state the property",
294
- " instead (`every other test in the file`). A past-tense record of a",
295
- " measurement you performed stays as written.",
296
- "6. Every claim in a commit body or PR body gets its settling command re-run at",
297
- " the commit that ships it, written inline beside the claim — a pushed body",
298
- " cannot be edited.",
299
- "7. A settling command over literal text uses `grep -F`, and its zero counts",
300
- " only after the same command, with the same flags, finds a line known to",
301
- " match.",
302
- ],
303
- },
304
- {
305
- what: "the implementer body's commit-incrementally block",
306
- opener: "Commit incrementally as you go",
307
- golden: [
308
- "Commit incrementally as you go. Do not accumulate a large uncommitted diff — if",
309
- "you stop for any reason, uncommitted work is invisible to the controller and",
310
- "effectively unrecoverable.",
311
- ],
312
- },
313
- {
314
- what: "the implementer body's stash-prohibition block",
315
- opener: "**Never `git stash` or `git stash pop` to shelve",
316
- golden: [
317
- "**Never `git stash` or `git stash pop` to shelve your own progress — take a",
318
- "WIP commit instead: `git commit -m wip`, then amend it or",
319
- "`git reset --soft HEAD^` once you have something real to commit.** The",
320
- "stash stack is repo-global, not per-worktree or per-session — the same",
321
- "`refs/stash` is shared by every worktree, the main checkout, and every",
322
- "concurrent member. A bare pop takes whichever entry is on top, from any",
323
- "worktree, and it is **silent** about it — rc 0, no error — exactly when the",
324
- "tree receiving it is clean on the affected paths, which is the moment you",
325
- "would assume it is safe; it refuses loudly only when that tree is already",
326
- "dirty on them. A bare `git stash` (push) does **not** reach into a sibling",
327
- "worktree's uncommitted work — that half is unfounded, it acts on your own",
328
- "tree only — so the hazard is entirely on the pop side: yours can take a",
329
- "sibling's entry, or a sibling's pop can take yours. Nothing partitions the",
330
- "stack the way the scratch root below is partitioned — one `refs/stash` per",
331
- "repository, with no per-member address for it — so this prohibition is the",
332
- "whole of the protection, not a stopgap standing in for one.",
333
- ],
334
- },
335
- {
336
- what: "the implementer body's scratch-discipline block",
337
- opener: "**Every scratch file",
338
- golden: [
339
- "**Every scratch file, fixture or mutation copy you create goes under",
340
- "`<scratch>/impl-<N>/`, never into the scratch root by itself.** The scratchpad",
341
- "root your own system prompt names is injected unprompted into every dispatched",
342
- "member and is shared with every sibling running this session — `SKILL.md` does",
343
- "not choose that root and cannot keep it from being handed to you, so writing to",
344
- "it directly, not a subdir under it, is the defect. Derive your own path the",
345
- "same way `claim-ticket.sh` already derives per-ticket ports from the issue",
346
- "number (`postgres=16<N>`, `ollama=22<N>`): `<scratch>/impl-<N>/`, not a second",
347
- "scheme, and `mkdir -p` it yourself the first time — nothing creates it for you.",
348
- "The harm is a false measurement, not untidiness: a mutation harness writes a",
349
- "broken copy of a file, measures against it, then restores from `.orig`, and",
350
- "two members in one directory are one filename collision away from restoring a",
351
- "sibling's `.orig` over their own file, or measuring a \"clean baseline\" that is",
352
- "actually a sibling's mutant — silently, indistinguishable from a real result.",
353
- "This is not the worktree isolation rule: `claim-ticket.sh` already gives you",
354
- "your own worktree, and the scratch root sits deliberately outside every",
355
- "worktree so a harness never dirties one — nothing partitions the scratch root",
356
- "itself but this rule.",
357
- "",
358
- "**A subagent you dispatch gets its own directory under yours,",
359
- "`<scratch>/impl-<N>/<childName>/`, and you write that path, absolute, into its",
360
- "prompt — it writes nowhere else, and never derives a path of its own.**",
361
- "`<childName>` is a slug of the name you dispatch it under (omp's task `name`) —",
362
- "`[a-z0-9-]` only, never the raw field itself,",
363
- "which can carry spaces and `/` and would split or nest the path in an",
364
- "unquoted shell command — unique among your children and never one of your",
365
- "own entries (`probe`, `mutate`, or any other name you write under",
366
- "`<scratch>/impl-<N>/` yourself), so no child shares a directory with a",
367
- "sibling or with you. A child left to derive its own path has only the",
368
- "injected root above to derive it from, which is this block's collision one",
369
- "level down — and its files under your partition are what show the controller",
370
- "you are alive while you wait on it.",
371
- ],
372
- },
373
- {
374
- what: "the implementer body's eval-kernel-discipline block",
375
- opener: "**The `eval` kernel is shared",
376
- golden: [
377
- "**The `eval` kernel is shared with every sibling member and with the",
378
- "controller that dispatched you — namespace every binding you make in it, and",
379
- "never hand it a relative path.** Measured on #1447, live, three ways in one",
380
- "run: two sibling implementers dispatched in the same batch, and the",
381
- "controller above them, reported the SAME Python kernel pid and the same",
382
- "runner file, and each could read the others' top-level variables — a bare",
383
- "`WT` bound by one member was read back out of another member's own kernel,",
384
- "which is the exact collision an earlier member self-reported and could not",
385
- "prove. `omp://tools/eval.md` is where the mechanism is written down:",
386
- "retained kernels are keyed by `python:${sessionId}`, normalized cwd and",
387
- "interpreter (`js:${sessionId}` for the JS VM), and \"Parent and ordinary task",
388
- "subagents may share an inherited eval executor id\" — so no part of that key",
389
- "separates two members of one run, because the session id is inherited from",
390
- "the controller and the cwd is the same main checkout for all of you.",
391
- "",
392
- "Three consequences. The bare-name collision and a kernel `reset` leave nothing",
393
- "`git status` can surface at all; the relative-path hazard does only when the",
394
- "cell writes rather than reads. **A bare top-level name is a shared global** a",
395
- "sibling can overwrite between two of your own cells, so prefix what you bind",
396
- "with your own member NAME, not its bare ticket number —",
397
- "`WT_impl_1447`, never a bare `WT` and never a prefix a recovery member for",
398
- "the same ticket (`impl-1447-b`) would also produce. **The kernel's cwd is",
399
- "the MAIN CHECKOUT, not your worktree** — unlike `bash`, `eval` takes no",
400
- "`cwd` parameter at all — so a relative path in a cell resolves into the tree",
401
- "every member reads its instruments out of: measured, a bare `work/scripts`",
402
- "in a member's cell resolved under the main checkout root, never under that",
403
- "member's own worktree — the stray `work/` tree found there has exactly that",
404
- "shape — so pass absolute paths rooted at `<scratch>/impl-<N>/` or at your",
405
- "worktree, the same discipline the `edit`/`read` block above spells out.",
406
- "Treat that as one rule stated twice, with one difference: `member-write-guard`",
407
- "refuses a relative `write` or `edit` into the main checkout, and nothing",
408
- "refuses one here.",
409
- "And **never call",
410
- "`eval` with `reset: true`**, which is destructive to every other member",
411
- "sharing that backend session, not only to your own state.",
412
- "",
413
- "Using the kernel is not the defect, and this is not the `isolated` question",
414
- "— the bare name, the relative path and the reset are. The harm is that the",
415
- "collision fails in the looks-already-correct direction: you read a value",
416
- "that is a sibling's rather than your own, and nothing anywhere reports it.",
417
- ],
418
- },
419
- {
420
- what: "the implementer body's enumerate-the-class block",
421
- opener: "Your ticket names the cases",
422
- golden: [
423
- "Your ticket names the cases it was written from. **Before implementing, enumerate",
424
- "every member of that class — including any the ticket names only in passing — and",
425
- "say which you cover and which you deliberately leave** — a guard on one path",
426
- "has siblings, a predicate has other inputs, a check on a directory has",
427
- "subdirectories. Fixing exactly the named cases is how a fix ships without",
428
- "closing its own ticket.",
429
- "",
430
- "Build that list from **the ticket's own prose first**, then from the mechanism.",
431
- "A case the body names in passing is still a named case, and enumerating from",
432
- "first principles is how you miss it. Then ask the other half: **what can this",
433
- "change wrongly REFUSE?** A new guard's false-positive class is not its",
434
- "false-negative class, and a suite that only feeds it valid input pins neither —",
435
- "so leave one test behind that feeds it input it must ACCEPT.",
436
- "",
437
- "**Both halves above are about the bug class. The third is about YOUR EDIT:",
438
- "enumerate what your change newly does, not only what the code already did",
439
- "wrong.** Moving, reordering or wrapping a statement has effects the ticket",
440
- "never mentions — the last command of a script sets its exit status, a",
441
- "relocated line changes what `set -e` covers, a hoisted guard changes what runs",
442
- "first. **Ask which of the ticket's own acceptance criteria your restructuring",
443
- "could newly violate, and test that path.** Measured: #265 required \"no path in",
444
- "the script exits 1\", and the fix for it moved a guard to the file's end,",
445
- "regressing the default dry run from exit 0 to exit 1 — the ticket's exact",
446
- "defect, relocated onto the path nobody tested. The implementer had enumerated",
447
- "every exit-1 path and declared two it was leaving; all of them were",
448
- "pre-existing, and none was the one its own edit created.",
449
- "",
450
- "**Then check the suite can even see the mode you changed.** That regression",
451
- "shipped under 616 green tests because all eight call sites passed the same",
452
- "flag, so the default mode had no test at all. A green suite is evidence only",
453
- "about the paths it exercises.",
454
- ],
455
- },
456
- {
457
- what: "the implementer body's sizing-and-PR block",
458
- opener: "Run `sizing-a-ticket`",
459
- golden: [
460
- "Run `sizing-a-ticket` for the process path and proceed on **either row** —",
461
- "heavy is never a bail reason, and that skill owns the fleet's heavy-row entry",
462
- "point, whose condition you are. A brief that will not support a plan is the",
463
- "undecided case: bail and name the cause, never a heavy row. Selection and",
464
- "claiming are already done (`next-ticket` steps 1-5), so you start at",
465
- "`next-ticket` **step 6**, which is that sizing run.",
466
- "",
467
- "Then `next-ticket` **step 7**: rebase, re-run tests, push, `gh pr create` with",
468
- "`Closes #N` in the body, then `gh pr edit --add-label` as its own command",
469
- "carrying exactly one release label — `patch`/`minor`/`major`, the *label*, not",
470
- "the branch *type*. **Never fold `--label` into the create**: a create that",
471
- "outruns your tool timeout is backgrounded with the PR already open, its flags",
472
- "unapplied and no exit status for you to react to, so the label goes missing",
473
- "and every later gate still reads the PR as correctly opened. Separate, the",
474
- "label write has its own exit status and fails loudly. **Put your step-6 sizing verdict in the PR",
475
- "body on its own line, `Sizing: light` or `Sizing: heavy`, and name the signal",
476
- "it turned on beside it** — `Sizing: heavy — >3 implementation files, arg.mjs",
477
- "plus four consumers`. Your own words, one clause: never paste the skill's",
478
- "output, because that format will change and this line has to outlive it. A",
479
- "verdict with nothing beside it is indistinguishable from a guess, and is",
480
- "recorded as one. The controller reads this line as a difficulty covariate when",
481
- "it rules your review, and the PR body is the only place it survives your exit.",
482
- "**Report to the controller the PR number, the head SHA, and WHEN you ran",
483
- "`sizing-a-ticket` relative to opening the PR** — \"ran sizing-a-ticket at step",
484
- "6, before `gh pr create`\" if you kept that order, and say so plainly if you did",
485
- "not, including if the `Sizing:` line was written before the run and corrected",
486
- "after. Nothing in the PR body separates a measured verdict from one typed in",
487
- "early; that clause is the only thing that does, and an unreported ordering",
488
- "costs the covariate. Then exit. Never apply `ready-to-merge`, never merge.",
489
- ],
490
- },
491
- ];
492
-
493
- const REVIEWER_BLOCKS = [
494
- {
495
- what: "the fix-applier prompt",
496
- opener: "You are ALREADY in worktree",
497
- golden: [
498
- "You are ALREADY in worktree `<abs-path>`, whose PR branch is `<branch>` — the",
499
- "push destination below, given to you because a detached worktree cannot supply",
500
- "it. Do NOT create another worktree. The review is done and its result is the",
501
- "file below — do not re-review, do not dispatch specialists.",
502
- "",
503
- "**`edit` and `read` resolve a bare relative path against the SESSION ROOT —",
504
- "the controller's own main checkout — not against that worktree and not",
505
- "against your `bash` cwd, which they share no `cwd` parameter with. Give them",
506
- "the absolute worktree path on every call, mutation-probe copies included.**",
507
- "The main checkout is the parent of `git rev-parse --path-format=absolute",
508
- "--git-common-dir`. A `member-write-guard` refusal means the path hit the",
509
- "main checkout — for `bash`, a missing or main-checkout `cwd` — so re-issue",
510
- "it absolute, under your worktree.",
511
- "",
512
- "Read `$(~/.fleet/bin/fleet-run --root)/commands/review-and-fix.md` and run **steps 2, 3",
513
- "and 5 only**: split apply-now/defer, commit, push, file every deferral as its",
514
- "own issue with the label the finding's state calls for. Skip step 1 — the",
515
- "review already ran — and steps 4 and 6: the controller owns the CI wait and",
516
- "dispatches the finisher.",
517
- "",
518
- "**The review's result is `<scratch>/review-<pr>.json`** — the digest first",
519
- "(`jq '{pr, head, resume, testEnvironment, dimensionsRun, dimensionsUnrun, cwdAudit, counts}'`),",
520
- "then every finding (`jq '.survived'`, `jq '.unverified'`, `jq '.refuted'`).",
521
- "Read it through `review-and-fix.md`'s **The review result file**, which holds",
522
- "the rest of the recipes and every ruling on the findings: both",
523
- "mutual-exclusion scans, the suggested-fix re-derivation, `refuted=false` ≠",
524
- "apply, per-site measurement for a sibling-site extension, and `testEnvironment`",
525
- "and `cwdAudit` before any result of the shared test run. Every one of those",
526
- "rulings is yours — nobody upstream has made one, and the controller never",
527
- "reads the findings.",
528
- "",
529
- "**Every factual claim your diff restates needs a settling command run",
530
- "against the tree first** — the issue body is a lead, never a citation.",
531
- "**No positional references** (`the closing/second/last X`); name the thing",
532
- "semantically. **Never write a COUNT or a tally into prose; state the",
533
- "property instead** — unless it is a past-tense record of a measurement you",
534
- "performed, which stays as written; a present-tense claim about a live",
535
- "property must be restated as a property (`every other test in the file`),",
536
- "true at any count. **A settling grep over literal text takes `grep -F`, and",
537
- "its zero counts only after the same command finds a line known to match.**",
538
- "",
539
- "**Apply `survived` findings. A finding in `unverified` whose refuters ran and",
540
- "crashed always defers** — and which of the two it is, you read off",
541
- "`refutersDispatched`, never off severity and never off an empty vote list:",
542
- "above zero with nothing surviving means every refuter dispatched against it",
543
- "died, and at `critical` that is every one of them. Severity records how much a",
544
- "finding would matter if true, never whether anything looked. Say *in the",
545
- "deferral* that its refuters crashed rather than that it went unchecked — the",
546
- "review re-dispatched each crash once already and reports what died again, so",
547
- "a deferral that names the crash can still be re-verified. **A `suggestion` is also in `unverified`,",
548
- "for a different reason — `refutersDispatched` of zero, the 0-refuter budget",
549
- "the review gives that band by policy — and the rule below, not this one,",
550
- "covers it.**",
551
- "",
552
- "**A `suggestion` is budgeted 0 refuters, so it is unchecked until you check",
553
- "it.** For each one, first decide scope: is it inside the scope of the PR's own",
554
- "ticket, or a different piece of work? **Out of scope → defer and file, never",
555
- "apply.** **In scope → dispatch ONE refuter** against the finding before",
556
- "touching the tree, biased to refuse, and hand it the prompt below with one",
557
- "substitution: resolve `<scratch>/pr<N>/<finding>/` in it to an absolute path",
558
- "under your own run root — `mktemp -d` once per round for",
559
- "`<scratch>/pr<N>/fix-XXXXXXXX/`, never bare `pr<N>`, since finding ids",
560
- "restart at 1 each round too — and write that absolute path into the",
561
- "refuter's prompt in its place; a refuter never derives its own path:",
562
- "",
563
- "> Try to REFUTE this finding. Default to refuted=true if uncertain. Verify by",
564
- "> RUNNING something — compile it, run the test, apply the mutation. Do not",
565
- "> reason your way to agreement. Observe that run synchronously — run the",
566
- "> command, wait for it, read its exit code. Never poll a log file for a",
567
- "> completion marker: prefer ONE blocking run to a poll loop, and treat its",
568
- "> return as permission to look, never as the answer. Reading a log the run has",
569
- "> already finished writing is fine; waiting on one is not. If you match a test",
570
- "> reporter's own output, accepting both `ℹ` and `#` is necessary but NOT",
571
- "> sufficient — strip SGR escapes first as well. node's prefix moves with the",
572
- "> node version and with whether stdout is a TTY, and color wraps the whole line",
573
- "> so it begins with ESC and no prefix anchor matches at all, which returns",
574
- "> empty at exit 0 — indistinguishable from a hung run and from a run of zero",
575
- "> tests. For an uncolored baseline use `env -u FORCE_COLOR`; `FORCE_COLOR=`",
576
- "> empty still enables color, so it is not a control. State your search scope",
577
- "> AND what your pattern would have missed. A grep over one ref does not",
578
- "> support a claim about history; a pattern built from the token a diff removed",
579
- "> does not support a claim that the category is empty. A failure injection with",
580
- "> no positive control has produced NO result, never a negative one. Before you",
581
- "> read an injected fault — an env var, an argv word, a mutant — as having had",
582
- "> no effect, prove the injection reached the child: one run whose output",
583
- "> differs with it present versus absent, or the child echoing the injected",
584
- "> value back. Uncontrolled, the cell is unrun — say so in your verdict instead",
585
- "> of reporting a no-effect result. Build such an invocation as an array",
586
- "> expanded braced and quoted —",
587
- "> `cfg=(SETB=1 BADJ=1); env \"${cfg[@]}\" sh ./probe.sh` — or inline the",
588
- "> assignments literally — `env SETB=1 BADJ=1 sh ./probe.sh`; NEVER from an",
589
- "> unquoted scalar — `cfg=\"SETB=1 BADJ=1\"; env $cfg sh ./probe.sh` — which under",
590
- "> zsh passes ONE argument, sets a variable literally named `SETB` to",
591
- "> `1 BADJ=1`, never sets `BADJ` at all, and still exits 0. `env $cfg[@]` is not",
592
- "> the portable spelling either: measured, bash word-splits it into `SETB=1`",
593
- "> and `BADJ=1[@]`, so the injection variable is set to a corrupted value,",
594
- "> while zsh behaves exactly as with the bare `$cfg` — `BADJ` never set,",
595
- "> exit 0. Everything you",
596
- "> write — mutants, fixtures,",
597
- "> scratch repos — goes under `<scratch>/pr<N>/<finding>/` and nowhere else;",
598
- "> the checkout and any worktree are never write targets, though",
599
- "> `git show`/`git archive` at a pinned ref read fine anywhere. Chain the",
600
- "> directory change into the command, `cd \"$D\" && git …`, never",
601
- "> `cd \"$D\"; git …`, so a failed `cd` cannot leave a `git` command running in",
602
- "> the checkout — and bracket a fixture's own git with",
603
- "> `git rev-parse --show-toplevel`: before `git init` it must NOT resolve to",
604
- "> the repository, and a fresh scratch dir's `fatal: not a git repository`",
605
- "> (exit 128) is the pass, not a failure; before any `git commit` it must",
606
- "> resolve to your scratch path — compare resolved forms (`realpath`), since",
607
- "> `--show-toplevel` can report `/private/tmp/…` for a `/tmp` scratch dir on",
608
- "> macOS.",
609
- "",
610
- "Survives → apply it, with one hold: if its refuter reports a blast radius",
611
- "touching lines another finding also changes, that is the mutual-exclusion",
612
- "scan's second input — rule the pair before either change reaches the tree;",
613
- "you hold every finding, so only you can see that the two cannot both land. Refuted → defer and file it, and",
614
- "say the refutation in the issue body. **Apply only what survives — no report is not a survival.** A",
615
- "refuter you never hear from leaves the finding exactly as unchecked as it",
616
- "arrived, so it defers like a refuted one.",
617
- "",
618
- "**A finding's `suggested_fix` is a hypothesis, not a patch — the review never",
619
- "ran it.** Only the claim is verified adversarially; the remedy text is unchecked.",
620
- "Three were wrong as written in one run: a stated end state that dropped a",
621
- "load-bearing option and measured RED, an assertion against a property the test",
622
- "helper does not expose (`TypeError`), and an enumeration that stopped short of",
623
- "two further stale clauses — one of them false in the *dangerous* direction. Run",
624
- "the remedy before you commit it, and re-derive an assertion from the post-fix",
625
- "tree rather than from the finding, since a sibling finding may edit the very",
626
- "text it asserts on.",
627
- "",
628
- "**Retrieve that report yourself; do not wait to be handed it — this covers the",
629
- "refuters YOU dispatch, and only those.** The review's own specialists do leave",
630
- "transcripts, but nothing gives you their address: the review had `agent()`",
631
- "return their findings into the script, so the result file holds their findings",
632
- "and names no transcript, and nothing on disk indexes a transcript by PR or",
633
- "dimension. Hunting their paths gets you nothing; read the file. A report from a refuter you spawned is",
634
- "different — it surfaces to the controller rather than to you, and waiting for a",
635
- "relay that never comes strands the finding. Its transcript is at the output file",
636
- "named in your spawn result, and its report is the last record:",
637
- "",
638
- "A depth-2 helper cannot dispatch further (`task.maxRecursionDepth: 2`); reach it directly instead, by its full dotted id (`<member>.<helper>`), via `hub send` — delivered, woken, no transcript workaround needed.",
639
- "",
640
- "If retrieval comes back empty, ask the controller by name. Only when neither",
641
- "works is the finding **unchecked** — defer and file it, and say so in the body. This is",
642
- "`review-and-fix.md`'s **Specialists** rule; it reaches you here because the",
643
- "steps that point at it are the ones you skip.",
644
- "",
645
- "The CI facts in that file apply to you — a `rebase-check` red, or heavy jobs",
646
- "`skipped`, **solely** off a non-zero behind-count, is staleness and not a",
647
- "failure. Never rebase to clear it. **`solely` is the load-bearing word:**",
648
- "`ci.yml`'s `rebase-check` exits 1 on five conditions and only one is",
649
- "staleness, so a non-zero behind-count does not by itself settle which fired.",
650
- "The job log names the condition — and because the staleness condition exits",
651
- "before the merge-commit condition is evaluated, the log is silent on that one",
652
- "by construction, so measure it separately with",
653
- "`git fetch origin && git rev-list --merges --count \"origin/<base>..HEAD\"` —",
654
- "keep the fetch, or a stale local `origin/<base>` widens the range over the",
655
- "base's own merge commits and reports a merge commit this branch never added.",
656
- "A non-zero count does not send you to a local rebase either: the merge bot's",
657
- "step-1 `gh pr update-branch --rebase` drops merge commits too",
658
- "(`run-merge-bot.md` step 1), so both conditions clear on that one server-side",
659
- "rebase. What it buys you is knowing the red was never solely staleness.",
660
- "",
661
- "**Run `<testCmd>` from the worktree before committing**, copied verbatim.",
662
- "`tests 0` is a FAILED run, not a pass. Red or zero-test → fix it, or move that",
663
- "finding to defer; never commit over it. **Never `--no-verify`** — a failing",
664
- "hook is a finding you report, not an obstacle you route around. Report the test",
665
- "result with your SHA. Nothing re-reviews this commit: the review ran against a",
666
- "snapshot cut before your edits existed, and a refuter checked the finding's",
667
- "claim, never your patch.",
668
- "",
669
- "**A test you ADD must kill its own mutant** — break what it pins, confirm it and",
670
- "only it goes red, restore. **Then a change it should *not* catch, staying",
671
- "green** — else you proved it fails, not that it discriminates: a pin asserting",
672
- "whole-file text clears \"it and only it goes red\" and still reddens on any edit",
673
- "(measured). A green suite says nothing about a new test: one pin this run",
674
- "survived the exact mutation it was named for.",
675
- "",
676
- "**A mutation that never landed is not a green — it is a cell that did not",
677
- "run.** Same rule for any fault you inject to see what breaks: prove the",
678
- "injection reached the child before you read its result — one run whose output",
679
- "differs with the injection present versus absent, or the child echoing the",
680
- "injected value back. Without one, a probe that exits 0 reporting the mutant",
681
- "behaving exactly like its baseline is indistinguishable from a real no-effect",
682
- "result, and a reproduction that never happened reads as a refutation. Build",
683
- "such an invocation as an array expanded braced and quoted —",
684
- "`cfg=(SETB=1 BADJ=1); env \"${cfg[@]}\" sh ./probe.sh` — or inline the",
685
- "assignments literally — `env SETB=1 BADJ=1 sh ./probe.sh`; NEVER from an",
686
- "unquoted scalar — `cfg=\"SETB=1 BADJ=1\"; env $cfg sh ./probe.sh` — which under",
687
- "zsh passes ONE argument, sets a variable literally named `SETB` to `1 BADJ=1`,",
688
- "never sets `BADJ` at all, and still exits 0. `env $cfg[@]` is not the portable",
689
- "spelling either: measured, bash word-splits it into `SETB=1` and",
690
- "`BADJ=1[@]`, so the injection variable is set to a corrupted value, while",
691
- "zsh behaves exactly as with the bare `$cfg` — `BADJ` never set, exit 0.",
692
- "",
693
- "**Commit BEFORE you mutate, and restore with `cp`, never a git discard.**",
694
- "`git checkout -- <file>` reverts the whole file, not your mutant — so it also",
695
- "eats uncommitted edits you made earlier, and the \"clean baseline\" you measure",
696
- "next is silently the reverted file. Two members hit this in one run; one lost",
697
- "prose edits and caught it only because a non-catch control failed. Copy the",
698
- "file aside and copy it back. Better still, mutate a copy under",
699
- "`<scratch>/pr<N>/mutate/` and leave the worktree untouched — that is what",
700
- "refuters are already required to do, and it has no blast radius at all.",
701
- "",
702
- "**Never `git stash` or `git stash pop` here either — a WIP commit is the",
703
- "substitute, not a second scratch mechanism: `git commit -m wip`, then",
704
- "restore or amend once you're back to real work.** The stash stack is",
705
- "repo-global too, not per-worktree or per-session — the same `refs/stash`",
706
- "every concurrent member and the main checkout share, not partitioned the",
707
- "way `<scratch>/pr<N>/mutate/` above is. A bare pop takes whichever entry is",
708
- "on top, from any worktree, silently — rc 0, no error — when the tree",
709
- "receiving it is clean on the affected paths, and refuses only when that",
710
- "tree is already dirty there. A bare `git stash` (push) does not reach into",
711
- "a sibling's tree, so that half is not the risk — the pop is. Nothing",
712
- "partitions the stack; this prohibition is the whole of the protection.",
713
- "",
714
- "**Report LAST, and only once nothing can still change.** A report you have",
715
- "sent **pins that SHA** for the controller, which dispatches a finisher against",
716
- "it. If a further instruction arrives after you have reported, reply saying the",
717
- "SHA is moving *before* you touch the tree again — do not silently do the work",
718
- "and re-report. Measured: three members in one run sent a final report and kept",
719
- "working; one had its worktree audited mid-mutation, another handed over a SHA",
720
- "that was two commits stale, and a finisher dispatched on either would have",
721
- "halted on a diverged head.",
722
- "",
723
- "**Before you report, write every ruling to `<scratch>/dispositions-<pr>.json`**,",
724
- "beside the review file — the record the controller checks with",
725
- "`dispositions-check.mjs` before it dispatches any finisher. It is",
726
- "`{\"head\": \"<the review file's head>\", \"entries\": [ … ]}`: one entry per",
727
- "`survived` finding and per `unverified` finding, plus one per `refuted`",
728
- "finding you reverse, its evidence in `reason`. Each entry carries `bucket`",
729
- "(`survived|unverified|refuted`), `index` (its position in that bucket of the",
730
- "review file), `scope` (`in|out`), `claimKind` (`behavior|shape`) and",
731
- "`disposition` (`apply|defer`), and where they apply `reason`, `issue` (the",
732
- "number you filed it to or commented on), `verdictPath` (an in-scope",
733
- "suggestion's refuter verdict file) and `remedyFiles` (the files its remedy",
734
- "names). A finding with no `line`, or on a line the PR's diff touched —",
735
- "`git diff` from its merge-base with `origin/main` to the review's head — is",
736
- "in scope whatever its `scope` says. An in-scope `survived` finding you defer",
737
- "carries `reason` `false-rationale`, `mutual-exclusion`, `remedy-worse` or",
738
- "`remedy-outside-diff`; the last needs `remedyFiles` to name a file the PR's",
739
- "diff does not touch, and for a `critical` or `important` finding it sends the",
740
- "PR to a human instead of passing. Any",
741
- "other reason, none, or a `survived` or `unverified` finding with no entry is",
742
- "a mismatch, and the PR gets no finisher.",
743
- "",
744
- "Then report to the controller the pushed SHA, your apply/defer split, and",
745
- "the deferral issue numbers — a `filed: #N <subject>` line for every issue",
746
- "step 5 created, and `unrecorded: #N <subject>` for one whose `ledger.mjs filed`",
747
- "failed twice — and exit. **Deferring everything is a normal",
748
- "outcome, not a stall:** nothing is then staged, `git commit` refuses an empty",
749
- "index, `git push origin HEAD:<branch>` prints `Everything up-to-date`, and you",
750
- "report `no-op, HEAD unchanged at <sha>` in place of a new SHA. Say it",
751
- "explicitly — silence there is indistinguishable from a member that died. Never",
752
- "manufacture a commit to make CI fire.",
753
- ],
754
- },
755
- {
756
- what: "the finisher's instrument re-check block",
757
- opener: "**Re-check the instrument set before you act on what duty 1 or duty 2 read",
758
- golden: [
759
- "**Re-check the instrument set before you act on what duty 1 or duty 2 read,",
760
- "and again before you add the label.**",
761
- "`~/.fleet/bin/fleet-run instruments.sh --repo \"$(dirname \"$(env -u GIT_DIR -u GIT_WORK_TREE git rev-parse --git-common-dir)\")\"`.",
762
- "Exit 0 is the only code that lets you go on. Exit 1 (the set changed) and",
763
- "exit 2 (the check could not answer) both halt you: report what it printed,",
764
- "add no label, and do NOT re-read the script that gave you the reading.",
765
- "`--repo` is required and the spelling is the point — the run's baseline lives",
766
- "in the audited checkout's gitignored `.fleet/`, which the scratch worktree",
767
- "you take at duty 2 does not carry, so a bare invocation from there exits 2 on",
768
- "a missing baseline instead of comparing anything. The `env -u GIT_DIR -u",
769
- "GIT_WORK_TREE` wrapper guards against an ambient `GIT_DIR` in your own shell",
770
- "pointing this check at the wrong tree — the script's own internal unset",
771
- "cannot reach back and fix a path you already resolved wrong. The baseline",
772
- "itself names the tree to audit: a cross-workspace run pinned it once at",
773
- "phase 0, and your `--repo` only locates that baseline, never the audited",
774
- "tree — so an exit 2 naming a moved or unreadable audited tree is a halt",
775
- "like every other, not a spelling for you to correct.",
776
- ],
777
- },
778
- {
779
- what: "the finisher's test-run verdict block",
780
- opener: "**A test run is a verdict only if it ran to completion",
781
- golden: [
782
- "**A test run is a verdict only if it ran to completion — and you read that",
783
- "off the test command's own exit status.**",
784
- "Redirect the run's output to a file in your scratch directory and read the",
785
- "command's own `$?` straight after it, then read the file. In an `eval` cell",
786
- "there is no `$?`: spawn `<testCmd>` with its output going to that file and",
787
- "read the exit code and the signal off the spawn result — `exitCode` and",
788
- "`signalCode` on Bun's `spawnSync`, `returncode` on Python's `subprocess.run`,",
789
- "which is negative for a signal. Never read the status of",
790
- "`<testCmd> | tail` or `<testCmd> | grep`: a pipeline's status is its",
791
- "last stage's, so the filter's 0 hides the run's own exit, and the array that",
792
- "holds the earlier stages' statuses is spelled differently per shell. A run is",
793
- "a verdict only when that exit status is 0 **and** its summary shows `tests`",
794
- "above 0 and `cancelled` 0. A summary line without that",
795
- "is not a verdict, whatever pass count it prints.",
796
- "**A run completed when the command itself returned on its own** — an exit",
797
- "code, no signal, and no `timeout`, deadline or kill of yours having fired.",
798
- "Judge that by how the run ended, never by its `cancelled` count: a failing",
799
- "`before` hook or a per-test `timeout` cancels tests inside a run that",
800
- "completed, and a SIGTERM'd `node --test` can exit 1 with `cancelled` above 0",
801
- "in a run that did not.",
802
- "**Any run that did not complete is a killed run** — 124 (`timeout`), 137",
803
- "(SIGKILL), 143 (SIGTERM), a signal in the spawn result, an `eval` cell's",
804
- "deadline — and read for green it is FAILED, the same bucket as",
805
- "`tests 0`, however many tests had passed before the kill. Halt with cause",
806
- "`other` and the exit code plus the summary line as evidence; label nothing.",
807
- "The same holds for the mutation gate: a killed run is not a mutant that",
808
- "reddened, and the files it cancelled are not failures — only a run that",
809
- "completed can kill a mutant. A completed run that exits 1 is a plain failure,",
810
- "not a killed run, whatever its `cancelled` count, and exit 0 with `tests 0`",
811
- "stays FAILED.",
812
- "Do not wrap `<testCmd>` in an external `timeout`. Run a long suite in one",
813
- "`eval` cell with `timeout: 0`, as the review runner does, and wait for it.",
814
- ],
815
- },
816
- {
817
- what: "the finisher's duty-3 two-step block",
818
- opener: "**Duty 3 is two steps, and only the second one labels.**",
819
- golden: [
820
- "**Duty 3 is two steps, and only the second one labels.**",
821
- "(a) `gh pr view <M> --json labels` — confirm exactly one of",
822
- "`patch`/`minor`/`major`. Zero or more than one halts you before the label:",
823
- "name which you found. A repo whose `gh label list` defines none of the three",
824
- "does not gate on one.",
825
- "(b) `gh pr edit <M> --add-label ready-to-merge`. Step (a) passing labels",
826
- "nothing; this command is the duty.",
827
- "Then run `gh pr view <M> --json labels` once more and put its output in your",
828
- "report: that read-back is what tells the controller the label is on.",
829
- ],
830
- },
831
- {
832
- what: "the finisher's halt-cause block",
833
- opener: "Worktree differs from your pin",
834
- golden: [
835
- "Worktree differs from your pin, or from what you last read. **Check",
836
- "head-equality first: `worktree HEAD == the SHA you were dispatched against` on",
837
- "a clean tree settles it.** Against your dispatch pin, never against",
838
- "`PR headRefOid`: a member that kept working and pushed after the pin matches",
839
- "the branch tip on a clean tree, so a headRefOid comparison reports \"settled\"",
840
- "over commits no reviewer read — the exact divergence this halt exists to",
841
- "catch. `headRefOid` is a second, separate read (pushed vs unpushed), never the",
842
- "equality the halt turns on. A rebase entry sitting at or behind the pin is",
843
- "that head's provenance — the implementer's own pre-push replay — not",
844
- "divergence from it, and needs no adjudication at all. Three finishers in one",
845
- "run adjudicated a reflog this one check had already answered. Only when the",
846
- "head differs from your pin, work out what happened. Each cause below is cheap",
847
- "and self-checkable, and `anything else` is a cause too, not a gap:",
848
- "",
849
- "- **Live editor.** `git status --porcelain -unormal` is dirty. Sample",
850
- " `git diff --stat` twice, a minute apart — diffstat growing means someone",
851
- " is still writing. Halt, name `live-editor`, report both samples.",
852
- "- **Rebase.** `git status --porcelain -unormal` is clean, head still differs",
853
- " from your pin. `git reflog` in the worktree: a `reset`/rebase entry near",
854
- " the move, not a plain `commit`, means the branch replayed onto a new",
855
- " base — its own commits on a new parent, content-identical only on a",
856
- " conflict-free replay.",
857
- " Halt, name `rebase`, report the reflog line and the output of",
858
- " `git cherry <pin> HEAD origin/main`, run in the worktree.",
859
- "- **Work past the pin.** `git status --porcelain -unormal` is clean, head",
860
- " still differs from your pin, and `git reflog` in the worktree reads a plain",
861
- " `commit` at the move — no `reset`/rebase entry there, any of those sitting",
862
- " at or behind the pin as provenance. A member kept working and committed",
863
- " after you were dispatched. Measured 2026-08-28 on #983, where the finisher",
864
- " matched neither cause above and halted on its own judgement (#997).",
865
- " Halt, name `past-pin`, and report **the commit, and whether it",
866
- " is pushed, unpushed, or unknown**: `git log -1 --format='%h %s'` names it,",
867
- " and `git ls-remote origin <branch>` answers the rest — a non-zero exit or",
868
- " any other failed read is **unknown**, never folded into \"unpushed\": the",
869
- " same rule `release-ticket.sh`'s own `ls-remote` names (\"a failure here is",
870
- " an unknown answer, never a 'no'\") and `reaping.md`'s remote check shares",
871
- " (\"its failure is an unknown answer, never a 'not pushed'\"). Only a",
872
- " successful read settles pushed vs not: equal to that commit means pushed,",
873
- " and a fresh finisher can audit it; a successful read that comes back",
874
- " without it means the commit exists only in that worktree, where no",
875
- " reviewer can reach it. Ask the remote, not the PR object, whose head lags",
876
- " a ref move — the same field `run-merge-bot.md` refuses to poll, for that",
877
- " reason. The controller's next move differs between pushed, unpushed, and",
878
- " unknown, so a report naming only two of the three is not a report of this",
879
- " cause.",
880
- "- **Anything else.** Matching none of the above is not a licence to report",
881
- " the mismatch as unexplained — that report is the one this block exists to",
882
- " make unnecessary, and it is where labelling over a moved head starts",
883
- " looking reasonable. Halt, name `other`, and name what you did find: both",
884
- " `git status --porcelain -unormal` samples, the `git reflog` line at the",
885
- " move, and both SHAs. A cause nobody has named yet is still a cause you",
886
- " observed, and your report is what gets it named.",
887
- "",
888
- "Every cause halts, always — named or not, you never verify the dirt is",
889
- "harmless and label over it, a rebase is not a fast-forward you get to accept,",
890
- "a commit past the pin is not one either, and a cause you could not name is",
891
- "the least settled of the lot. Naming the cause makes the halt cheap to",
892
- "resolve, never a reason to skip it.",
893
- ],
894
- },
895
- ];
896
-
897
- const SURFACES = [
898
- {
899
- label: "the implementer agent body", file: "agents/fleet-implementer-slow-high.agent.md", source: BODY, slice: body,
900
- extract: bodyBlock, all: (text) => bodyBlocks(text).blocks, blocks: REGION_BLOCKS, table: "REGION_BLOCKS",
901
- },
902
- {
903
- label: "run-team's Reviewers section", file: "skills/run-team/SKILL.md", source: RUN_TEAM, slice: reviewers,
904
- extract: quoteBlock, all: quoteBlocks, blocks: REVIEWER_BLOCKS, table: "REVIEWER_BLOCKS",
905
- },
906
- ];
907
- const ALL = SURFACES.flatMap(({ file, source, slice, extract, blocks, table }) =>
908
- blocks.map((b) => ({ ...b, file, source, slice, extract, table })));
909
-
910
- // Says the red is a re-blessing point, and where. A golden's failure message is
911
- // the whole difference between an editor updating the fixture on purpose and an
912
- // editor reading an equality failure as breakage and loosening the comparison.
913
- const reblessing = (what, table, file) =>
914
- `${what} no longer matches its golden fixture. These blocks reach a member VERBATIM and are change-controlled, so this red is a re-blessing point, not necessarily a defect: if you edited the block on purpose, update the "${what}" entry in \`${table}\` in plugin/scripts/dispatch-block-golden-prose.test.mjs in the SAME change — copy the block out of plugin/${file}, with or without any "> " markers. A pure re-wrap cannot cause this; wrapping is normalized away on both sides. If you did NOT edit it, a sentence or clause was added to the block, which is what this fixture exists to catch.`;
915
-
916
- for (const { what, opener, golden, slice, extract, table, file } of ALL) {
917
- test(`${what} matches its golden fixture`, () => {
918
- assert.equal(norm(extract(slice(), opener, what)), norm(golden.join("\n")), reblessing(what, table, file));
919
- });
920
- }
921
-
922
- // The coverage half, and what keeps the mechanism from decaying one block at a
923
- // time: a block added to a dispatch surface that this file does not name is a
924
- // block an appended carve-out reaches unseen, and every per-block test above
925
- // would still pass. Compares the located runs against ALL the surface's runs, so
926
- // an unfixtured block reds, and so does a reordering — which changes the order
927
- // the member reads the rules in.
928
- //
929
- // Source-to-source, never against the fixtures: the equality tests above own
930
- // that comparison, and repeating it here would red twice for one edit while
931
- // saying nothing about coverage.
932
- for (const { label, slice, extract, all, blocks, table } of SURFACES) {
933
- test(`every verbatim block in ${label} has a golden fixture, in source order`, () => {
934
- assert.deepEqual(
935
- blocks.map((b) => extract(slice(), b.opener, b.what)),
936
- all(slice()),
937
- `${label} holds a quote block \`${table}\` does not name, or its blocks were reordered. A block with no fixture is one a carve-out can be appended to with this whole file green — add it to \`${table}\`, in source order.`,
938
- );
939
- });
940
- }
941
-
942
- // The body's one uncovered place: text ahead of its first fixtured opener
943
- // belongs to no block, so no golden sees a rule added there.
944
- test("the implementer agent body opens on its first fixtured block, with nothing ahead of it", () => {
945
- assert.equal(
946
- bodyBlocks(BODY).lead,
947
- "",
948
- "agents/fleet-implementer-slow-high.agent.md carries text ahead of its first fixtured block — a rule added there reaches every member and no golden fixture sees it",
949
- );
950
- });
951
-
952
- // The Reviewers coverage test above is bounded by its OWN surface's anchors —
953
- // a verbatim block added past `reviewers()`'s anchors (or wherever a future
954
- // dispatch surface lands in SKILL.md) is invisible to it and to the whole prose
955
- // suite. This test catches that shape: it counts every quote run in the WHOLE
956
- // file and asserts it equals the runs inside the Reviewers section, so a quote
957
- // run anywhere else reds here even though no per-surface loop above saw it.
958
- // That includes a re-pasted copy of the implementer blocks, which #1804 removed
959
- // from phase 2 because the agent body now carries them (a copy here would be
960
- // a second source free to drift from the one members actually read).
961
- test("run-team/SKILL.md has no verbatim block outside the fixtured Reviewers section", () => {
962
- assert.equal(
963
- quoteBlocks(RUN_TEAM).length,
964
- quoteBlocks(reviewers()).length,
965
- "run-team/SKILL.md holds a quote block outside the Reviewers section — a block added there is invisible to the coverage tests above, and an implementer block re-pasted into phase 2 is a second copy of what the agents/fleet-implementer-<cell>.agent.md body already carries",
966
- );
967
- });
968
-
969
- // Re-wrapped, one gutter depth at a time, so the fix-applier prompt's nested
970
- // refuter prompt is re-wrapped as its own quote rather than having its inner `>`
971
- // markers shuffled into the outer text. Wrapping at word boundaries, never one
972
- // word per line: an unconditional break would split the block's own opener and
973
- // red the extractor on its anchor instead of exercising the comparison.
974
- const rewrap = (block, width) =>
975
- block
976
- .split("\n")
977
- .reduce((groups, line) => {
978
- const gutter = line.match(/^(?:>[ \t]?)*/)[0];
979
- const depth = (gutter.match(/>/g) ?? []).length;
980
- const words = line.slice(gutter.length).trim();
981
- const last = groups[groups.length - 1];
982
- if (words !== "" && last && last.text.length > 0 && last.depth === depth) last.text.push(words);
983
- else groups.push({ gutter, depth, text: words === "" ? [] : [words] });
984
- return groups;
985
- }, [])
986
- .map(({ gutter, text }) => {
987
- const words = text.join(" ").split(/\s+/).filter(Boolean);
988
- if (words.length === 0) return gutter.trimEnd();
989
- return words
990
- .reduce((out, w) => {
991
- const tail = out[out.length - 1];
992
- if (tail !== undefined && `${tail} ${w}`.length <= width) out[out.length - 1] = `${tail} ${w}`;
993
- else out.push(w);
994
- return out;
995
- }, [])
996
- .map((l) => `${gutter}${l}`)
997
- .join("\n");
998
- })
999
- .join("\n");
1000
-
1001
- // The ACCEPT side, and the half that decides whether this mechanism survives
1002
- // contact with an editor. Re-wrapping is not drift, and a golden that reddened
1003
- // on it would be re-blessed once and then deleted.
1004
- //
1005
- // Every block, not one: these fixtures were blessed at TODAY'S wrap points, so a
1006
- // `norm` that handled them by accident would pass a single-block control. The
1007
- // staleness guard is per block for the same reason the comparison is — a block
1008
- // already at the target width would be re-wrapped to itself and prove nothing.
1009
- test("a re-wrapped block does not red — this mechanism refuses drift, not reflow", () => {
1010
- for (const { what, opener, golden, slice, extract, source } of ALL) {
1011
- const raw = extract(slice(), opener, what);
1012
- const narrow = rewrap(raw, 45);
1013
- assert.notEqual(narrow, raw, `the rewrap fixture no longer changes ${what}'s wrapping — it is already at or below 45 columns, so this control proves nothing about it`);
1014
- // Replacer function, not a replacement string: `$&`, `$'` and `` $` `` are
1015
- // interpreted in the latter, and the fix-applier prompt carries a literal
1016
- // `$(...)` command substitution today.
1017
- const mutated = source.replace(raw, () => narrow);
1018
- const after = extract(slice(mutated), opener, what);
1019
- assert.notEqual(after, raw, `the re-wrap never landed in ${what}'s slice — this control did not run`);
1020
- const flat = norm(after);
1021
- assert.equal(flat, norm(golden.join("\n")), `${what} reds on a pure re-wrap — the words are identical and only the wrap points moved, so the normalization above is broken, not the block`);
1022
- }
1023
- });
1024
-
1025
- // The REFUSE side, mutant by mutant. Each entry is a carve-out appended inside a
1026
- // block, after the rule it contradicts, keeping every word the presence pins
1027
- // match — the shape #1002 measured green against those pins four times, twice
1028
- // over on two different suites.
1029
- //
1030
- // `after` is asserted to be the block's own tail before the carve-out is
1031
- // appended, so a control that stops testing the measured insertion point says so
1032
- // instead of quietly moving to a different one.
1033
- const APPENDED = [
1034
- {
1035
- what: "the implementer body's commit-incrementally block",
1036
- after: "effectively unrecoverable.",
1037
- carveOut: "A single commit at the end is fine when the diff is small.",
1038
- },
1039
- {
1040
- what: "the implementer body's enumerate-the-class block",
1041
- after: "A green suite is evidence only about the paths it exercises.",
1042
- carveOut: "Skip the enumeration entirely when the ticket names only one case.",
1043
- },
1044
- {
1045
- what: "the implementer body's re-derive block",
1046
- after: "say which, and stop.",
1047
- carveOut: "If the criterion looks close enough, implement it anyway.",
1048
- },
1049
- {
1050
- what: "the implementer body's claim-discipline block",
1051
- after: "finds a line known to match.",
1052
- carveOut: "Skip all of this when the ticket is a pure code change.",
1053
- },
1054
- {
1055
- what: "the implementer body's issue-read block",
1056
- after: "bail, name the cause, do not implement.",
1057
- carveOut: "Unless the tree looks tractable to you, in which case implement anyway.",
1058
- },
1059
- ];
1060
-
1061
- test("a carve-out appended inside a block reds — the shape the presence pins cannot see", () => {
1062
- for (const { what, after, carveOut } of APPENDED) {
1063
- const entry = ALL.find((b) => b.what === what);
1064
- assert.ok(entry, `${what} has no golden fixture, so this mutant cannot be measured against one`);
1065
- const raw = entry.extract(entry.slice(), entry.opener, what);
1066
- assert.ok(
1067
- norm(raw).endsWith(after),
1068
- `${what} no longer ends on "${after}" — this mutant's measured insertion point moved, so appending after it no longer tests what #1002 measured`,
1069
- );
1070
- // Appended to the block's last line, so the carve-out lands INSIDE the block
1071
- // — its last paragraph — rather than after it. A mutation that
1072
- // never landed is not a green: the guard above and this splice's own
1073
- // difference from `raw` are what make the assertion below evidence.
1074
- const mutant = `${raw} ${carveOut}`;
1075
- assert.notEqual(mutant, raw, "the mutant is identical to the block — nothing was appended");
1076
- assert.notEqual(
1077
- norm(entry.extract(entry.slice(entry.source.replace(raw, () => mutant)), entry.opener, what)),
1078
- norm(entry.golden.join("\n")),
1079
- `a carve-out appended to ${what} does not red its golden fixture — the mechanism #1002 replaced the presence pins with is not seeing an insertion, which is the entire defect`,
1080
- );
1081
- }
1082
- });
1083
-
1084
- // The second measured shape, and the one no assertion in this repo saw before:
1085
- // a meaning-changing clause inserted strictly BETWEEN the two anchors of an
1086
- // ordered span, touching neither fragment, absorbed by that span's `.{0,N}?`
1087
- // tolerance. Measured on the enumerate pin's first half, whose gap spends 56 of
1088
- // its 120 characters today — this 27-character insertion fits, and the presence
1089
- // pin stays green.
1090
- test("a clause inserted mid-gap reds — the second shape the gap-bounded spans absorb", () => {
1091
- const entry = ALL.find((b) => b.what === "the implementer body's enumerate-the-class block");
1092
- const raw = entry.extract(entry.slice(), entry.opener, entry.what);
1093
- // Located through `phrase()`, never a literal: the words this clause is
1094
- // inserted between are two thirds of the way through a wrapped line, so a
1095
- // literal anchor stops finding them the moment the block is reflowed, and the
1096
- // guard below would then decline a control that should have run. Measured —
1097
- // it declined against a 45-column rewrap of the region until this anchor
1098
- // learned to span a wrap point.
1099
- const midGap = "every member of that class (yes, even the boring ones) —";
1100
- const mutant = raw.replace(phrase("every member of that class —"), () => midGap);
1101
- assert.notEqual(mutant, raw, "the mid-gap insertion point moved — the clause was never inserted, so what follows would measure nothing");
1102
- assert.notEqual(
1103
- norm(entry.extract(entry.slice(entry.source.replace(raw, () => mutant)), entry.opener, entry.what)),
1104
- norm(entry.golden.join("\n")),
1105
- "a clause inserted between the enumerate pin's two anchors does not red its golden fixture — the gap tolerance that absorbs it is still the only thing reading this block",
1106
- );
1107
- });
1108
-
1109
- // The extractors' loud half. A golden mechanism whose extractor returns "" for
1110
- // a block it cannot find compares empty against empty, or against a fixture
1111
- // nobody re-blessed, and a DELETED block passes — the one failure that would
1112
- // make every test above vacuous. One mutant per extractor: a body block
1113
- // deleted outright, and a Reviewers block moved out of the `>` quoting, which is
1114
- // #172's own defect and leaves every word of it still in the file.
1115
- test("a block that is gone, or no longer quoted, throws instead of comparing against nothing", () => {
1116
- {
1117
- const { what, opener, slice, extract, source } = ALL.find((b) => b.what === "the implementer body's scratch-discipline block");
1118
- const raw = extract(slice(), opener, what);
1119
- const deleted = source.replace(raw, () => "");
1120
- assert.notEqual(deleted, source, "the block was not deleted, so the throw below would prove nothing");
1121
- assert.throws(() => extract(slice(deleted), opener, what), /no paragraph of the implementer agent body opens on/, `deleting ${what} did not throw — a golden comparison would run against whatever the extractor returned instead`);
1122
- }
1123
- {
1124
- const { what, opener, slice, extract, source } = ALL.find((b) => b.what === "the finisher's halt-cause block");
1125
- const raw = extract(slice(), opener, what);
1126
- const unquoted = source.replace(raw, () => raw.split("\n").map((l) => l.replace(/^>[ \t]?/, "")).join("\n"));
1127
- assert.notEqual(unquoted, source, "the gutter was not stripped, so the throw below would prove nothing");
1128
- assert.throws(() => extract(slice(unquoted), opener, what), /no quote block opens on/, `moving ${what} out of the \`>\` quoting did not throw — the controller carries only the blocks, so an unquoted rule reaches the member by paraphrase or not at all`);
1129
- }
1130
- });