@feigi/fleet-ctl 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/.claude-plugin/plugin.json +9 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +18 -0
  4. package/agents/fleet-finisher.agent.md +7 -0
  5. package/agents/fleet-implementer-alt.agent.md +210 -0
  6. package/agents/fleet-implementer.agent.md +210 -0
  7. package/agents/fleet-merge-bot.agent.md +7 -0
  8. package/agents/fleet-review-comments.agent.md +40 -0
  9. package/agents/fleet-review-correctness.agent.md +43 -0
  10. package/agents/fleet-review-runner.agent.md +73 -0
  11. package/agents/fleet-review-silent-failure.agent.md +49 -0
  12. package/agents/fleet-review-simplify.agent.md +46 -0
  13. package/agents/fleet-review-snapshot.agent.md +24 -0
  14. package/agents/fleet-review-tests.agent.md +46 -0
  15. package/agents/fleet-review-types.agent.md +41 -0
  16. package/agents/fleet-review-verifier.agent.md +29 -0
  17. package/commands/review-and-fix.md +98 -0
  18. package/commands/run-merge-bot.md +357 -0
  19. package/commands/run-team-help.md +17 -0
  20. package/package.json +23 -0
  21. package/scripts/agent-test-dir-prose.test.mjs +59 -0
  22. package/scripts/agent-test.test.mjs +1636 -0
  23. package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
  24. package/scripts/ambient-git-vars-prose.test.mjs +192 -0
  25. package/scripts/ancestry-check-position-prose.test.mjs +175 -0
  26. package/scripts/apply-ruleset.test.mjs +420 -0
  27. package/scripts/arg-header-probes-prose.test.mjs +393 -0
  28. package/scripts/arg.mjs +600 -0
  29. package/scripts/arg.test.mjs +1354 -0
  30. package/scripts/board-cli.test.mjs +694 -0
  31. package/scripts/board-identity.test.mjs +429 -0
  32. package/scripts/board-liveness-banner.test.mjs +119 -0
  33. package/scripts/board-prev-shape.test.mjs +229 -0
  34. package/scripts/board-tryparse-null.test.mjs +119 -0
  35. package/scripts/board.html +471 -0
  36. package/scripts/board.mjs +2037 -0
  37. package/scripts/board.test.mjs +3086 -0
  38. package/scripts/brief-after-cut-prose.test.mjs +53 -0
  39. package/scripts/candidates-exit3-prose.test.mjs +302 -0
  40. package/scripts/candidates.mjs +674 -0
  41. package/scripts/candidates.test.mjs +2101 -0
  42. package/scripts/caveat-unification-prose.test.mjs +98 -0
  43. package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
  44. package/scripts/ci-completes-premise-prose.test.mjs +257 -0
  45. package/scripts/ci-state-prose.test.mjs +113 -0
  46. package/scripts/ci-state.mjs +761 -0
  47. package/scripts/ci-state.test.mjs +1640 -0
  48. package/scripts/ci-vacuous-green.test.mjs +368 -0
  49. package/scripts/citation-sweep-prose.test.mjs +1572 -0
  50. package/scripts/claim-lifecycle.test.mjs +185 -0
  51. package/scripts/claim-ticket.sh +417 -0
  52. package/scripts/claim-ticket.test.mjs +1121 -0
  53. package/scripts/closing-keyword-prose.test.mjs +193 -0
  54. package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
  55. package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
  56. package/scripts/compute-board.mjs +579 -0
  57. package/scripts/compute-board.test.mjs +1060 -0
  58. package/scripts/compute-spend.mjs +329 -0
  59. package/scripts/compute-spend.test.mjs +451 -0
  60. package/scripts/cross-repo-citation-prose.test.mjs +156 -0
  61. package/scripts/cwd-isolation-pins.mjs +83 -0
  62. package/scripts/dedupe-guard-prose.test.mjs +243 -0
  63. package/scripts/derive-testcmd.sh +239 -0
  64. package/scripts/derive-testcmd.test.mjs +380 -0
  65. package/scripts/diff-stats.mjs +231 -0
  66. package/scripts/diff-stats.test.mjs +408 -0
  67. package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
  68. package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
  69. package/scripts/drop-merged-label.sh +173 -0
  70. package/scripts/drop-merged-label.test.mjs +480 -0
  71. package/scripts/expected-jobs-prose.test.mjs +80 -0
  72. package/scripts/filing-bar-seat-prose.test.mjs +242 -0
  73. package/scripts/filing-claim-bar-prose.test.mjs +166 -0
  74. package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
  75. package/scripts/finisher-halt-prose.test.mjs +106 -0
  76. package/scripts/finisher-name-prose.test.mjs +134 -0
  77. package/scripts/finisher-own-tree-prose.test.mjs +285 -0
  78. package/scripts/finisher-pin-race-prose.test.mjs +339 -0
  79. package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
  80. package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
  81. package/scripts/fleet-bootstrap +155 -0
  82. package/scripts/fleet-heartbeat.mjs +272 -0
  83. package/scripts/fleet-heartbeat.test.mjs +450 -0
  84. package/scripts/fleet-provenance +207 -0
  85. package/scripts/fleet-provenance.test.mjs +64 -0
  86. package/scripts/fleet-run +148 -0
  87. package/scripts/fleet-run.test.mjs +90 -0
  88. package/scripts/fleet-state.mjs +400 -0
  89. package/scripts/fleet-state.test.mjs +373 -0
  90. package/scripts/fleet-tick-prose.test.mjs +299 -0
  91. package/scripts/fleet-tick.mjs +832 -0
  92. package/scripts/fleet-tick.test.mjs +1332 -0
  93. package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
  94. package/scripts/frontmatter-allowlist.json +64 -0
  95. package/scripts/frontmatter-check.mjs +256 -0
  96. package/scripts/frontmatter-check.test.mjs +436 -0
  97. package/scripts/git-env.mjs +124 -0
  98. package/scripts/git-env.test.mjs +149 -0
  99. package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
  100. package/scripts/gone-walk.test.mjs +213 -0
  101. package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
  102. package/scripts/head-moved-after-label-prose.test.mjs +233 -0
  103. package/scripts/immutable-body-claim-prose.test.mjs +413 -0
  104. package/scripts/implementer-model-tier.test.mjs +643 -0
  105. package/scripts/inflight-citation-prose.test.mjs +144 -0
  106. package/scripts/inflight-exit2-prose.test.mjs +81 -0
  107. package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
  108. package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
  109. package/scripts/inflight.sh +1106 -0
  110. package/scripts/inflight.test.mjs +2984 -0
  111. package/scripts/injection-control-prose.test.mjs +404 -0
  112. package/scripts/install-root-audit.test.mjs +464 -0
  113. package/scripts/instrument-check-prose.test.mjs +235 -0
  114. package/scripts/instruments.sh +394 -0
  115. package/scripts/instruments.test.mjs +787 -0
  116. package/scripts/issue-tracker-prose.test.mjs +71 -0
  117. package/scripts/json.sh +248 -0
  118. package/scripts/json.test.mjs +364 -0
  119. package/scripts/ledger-dispatch.test.mjs +516 -0
  120. package/scripts/ledger-grammar.mjs +85 -0
  121. package/scripts/ledger-grammar.test.mjs +142 -0
  122. package/scripts/ledger-read-require-file.test.mjs +197 -0
  123. package/scripts/ledger.mjs +1753 -0
  124. package/scripts/ledger.test.mjs +3554 -0
  125. package/scripts/line-distance-prose.test.mjs +245 -0
  126. package/scripts/liveness-rationale-prose.test.mjs +83 -0
  127. package/scripts/locale-pin-prose.test.mjs +189 -0
  128. package/scripts/member-outcome-prose.test.mjs +167 -0
  129. package/scripts/member-outcomes-header.test.mjs +148 -0
  130. package/scripts/member-outcomes-prose.test.mjs +63 -0
  131. package/scripts/member-outcomes.mjs +231 -0
  132. package/scripts/member-outcomes.test.mjs +507 -0
  133. package/scripts/member-prompt-prose.test.mjs +161 -0
  134. package/scripts/member-record.mjs +605 -0
  135. package/scripts/member-record.test.mjs +516 -0
  136. package/scripts/member-write-guard.mjs +279 -0
  137. package/scripts/member-write-guard.test.mjs +211 -0
  138. package/scripts/merge-commit-probe-prose.test.mjs +122 -0
  139. package/scripts/merge-gate.mjs +262 -0
  140. package/scripts/merge-gate.test.mjs +613 -0
  141. package/scripts/muted-git-guard-sweep.test.mjs +493 -0
  142. package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
  143. package/scripts/net-watchdog-prose.test.mjs +79 -0
  144. package/scripts/net.sh +409 -0
  145. package/scripts/net.test.mjs +211 -0
  146. package/scripts/no-ci-gate-prose.test.mjs +108 -0
  147. package/scripts/no-undo-audit.sh +1134 -0
  148. package/scripts/no-undo-audit.test.mjs +3965 -0
  149. package/scripts/no-wave.test.mjs +138 -0
  150. package/scripts/node-floor-sweep.test.mjs +611 -0
  151. package/scripts/pointer-target-prose.test.mjs +186 -0
  152. package/scripts/pr-overlap.mjs +417 -0
  153. package/scripts/pr-overlap.test.mjs +695 -0
  154. package/scripts/printf-die-sweep.test.mjs +384 -0
  155. package/scripts/prompt-renderer.mjs +39 -0
  156. package/scripts/prompt-renderer.test.mjs +68 -0
  157. package/scripts/prose-pin.mjs +808 -0
  158. package/scripts/prose-pin.test.mjs +1034 -0
  159. package/scripts/prove-merge.sh +228 -0
  160. package/scripts/prove-merge.test.mjs +995 -0
  161. package/scripts/pull-table-relabel-prose.test.mjs +60 -0
  162. package/scripts/quiet-payload-prose.test.mjs +222 -0
  163. package/scripts/reap.sh +1768 -0
  164. package/scripts/reap.test.mjs +4395 -0
  165. package/scripts/reaping-prose.test.mjs +159 -0
  166. package/scripts/refuter-scratch-prose.test.mjs +135 -0
  167. package/scripts/release-label-required-prose.test.mjs +71 -0
  168. package/scripts/release-label-split-prose.test.mjs +169 -0
  169. package/scripts/release-ticket.sh +1716 -0
  170. package/scripts/release-ticket.test.mjs +5106 -0
  171. package/scripts/renovate-release-contract.test.mjs +379 -0
  172. package/scripts/repo-root.mjs +544 -0
  173. package/scripts/repo-root.test.mjs +873 -0
  174. package/scripts/reporter-output-rule-prose.test.mjs +208 -0
  175. package/scripts/review-agent-report-only.test.mjs +49 -0
  176. package/scripts/review-core-cwd-isolation.test.mjs +374 -0
  177. package/scripts/review-core-reads.test.mjs +478 -0
  178. package/scripts/review-core-refuter-scratch.test.mjs +148 -0
  179. package/scripts/review-core-snapshot-path.test.mjs +777 -0
  180. package/scripts/review-core-specialist-scratch.test.mjs +189 -0
  181. package/scripts/review-core-testcmd.test.mjs +288 -0
  182. package/scripts/review-core-unrun.test.mjs +530 -0
  183. package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
  184. package/scripts/review-core.mjs +1028 -0
  185. package/scripts/review-eval-resolver-path.test.mjs +55 -0
  186. package/scripts/review-eval.mjs +197 -0
  187. package/scripts/review-host-fixture.mjs +73 -0
  188. package/scripts/review-in-run-retry.test.mjs +187 -0
  189. package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
  190. package/scripts/review-path-default.test.mjs +796 -0
  191. package/scripts/review-runner-spawns.test.mjs +93 -0
  192. package/scripts/review-runner.test.mjs +155 -0
  193. package/scripts/review-tier-audit.test.mjs +140 -0
  194. package/scripts/run-artifact-pr-prose.test.mjs +341 -0
  195. package/scripts/run-merge-bot-prose.test.mjs +1391 -0
  196. package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
  197. package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
  198. package/scripts/section-between-guard-prose.test.mjs +378 -0
  199. package/scripts/select-dimensions.test.mjs +674 -0
  200. package/scripts/shared-refusal.test.mjs +388 -0
  201. package/scripts/shell-traps-prose.test.mjs +507 -0
  202. package/scripts/shortlist.mjs +355 -0
  203. package/scripts/shortlist.test.mjs +366 -0
  204. package/scripts/slow-transport.mjs +72 -0
  205. package/scripts/snapshot-repo.test.mjs +772 -0
  206. package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
  207. package/scripts/spend-view.test.mjs +312 -0
  208. package/scripts/staleness-qualifier-prose.test.mjs +251 -0
  209. package/scripts/staleness-verdict-prose.test.mjs +142 -0
  210. package/scripts/staleness.mjs +414 -0
  211. package/scripts/staleness.test.mjs +893 -0
  212. package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
  213. package/scripts/stash-prohibition-prose.test.mjs +313 -0
  214. package/scripts/strip-comments.mjs +44 -0
  215. package/scripts/tier-check.mjs +468 -0
  216. package/scripts/tier-check.test.mjs +726 -0
  217. package/scripts/tier-guard-gate-prose.test.mjs +216 -0
  218. package/scripts/tier-outcomes-header.test.mjs +586 -0
  219. package/scripts/tier-outcomes.mjs +441 -0
  220. package/scripts/tier-outcomes.test.mjs +342 -0
  221. package/scripts/tier-roles.mjs +250 -0
  222. package/scripts/tier-roles.test.mjs +316 -0
  223. package/scripts/tracker-block-copy-prose.test.mjs +288 -0
  224. package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
  225. package/scripts/unattended-git-sweep.test.mjs +142 -0
  226. package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
  227. package/scripts/verify-sha.sh +117 -0
  228. package/scripts/verify-sha.test.mjs +693 -0
  229. package/scripts/watcher-degraded-block.test.mjs +372 -0
  230. package/scripts/watcher-key-prose.test.mjs +106 -0
  231. package/scripts/within-run-pair-prose.test.mjs +208 -0
  232. package/scripts/worktree-audit.sh +482 -0
  233. package/scripts/worktree-audit.test.mjs +1407 -0
  234. package/scripts/worktree-head-prose.test.mjs +276 -0
  235. package/scripts/worktree-listing-sweep.test.mjs +217 -0
  236. package/scripts/worktree-model-prose.test.mjs +216 -0
  237. package/scripts/worktree.sh +470 -0
  238. package/skills/next-ticket/SKILL.md +138 -0
  239. package/skills/run-team/SKILL.md +3603 -0
  240. package/skills/run-team/references/ci-and-staleness.md +75 -0
  241. package/skills/run-team/references/correction-tickets.md +37 -0
  242. package/skills/run-team/references/isolation.md +23 -0
  243. package/skills/run-team/references/member-lifecycle.md +73 -0
  244. package/skills/run-team/references/reaping.md +73 -0
  245. package/skills/sizing-a-ticket/SKILL.md +39 -0
@@ -0,0 +1,643 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { between as section, sentences } from "./prose-pin.mjs";
6
+
7
+ // Implementers dispatch at the SESSION's tier, whatever the ticket class. The
8
+ // `class=routine` → `sonnet` binding was reverted 2026-08-16 when the phase-2
9
+ // guard fired, so the class now selects the correction-ticket DISCIPLINE and
10
+ // partitions the metrics file — never a model.
11
+ //
12
+ // Two ways this rots, and they pull in opposite directions. (a) The binding
13
+ // creeps back: someone re-reads the guard's rationale, sees the saving argued
14
+ // for at length, and restores `model: "sonnet"` in one of the two places that
15
+ // used to carry it. The negative pins below exist for that, and there are two
16
+ // because phase 0 and phase 2 each stated the binding independently — changing
17
+ // only one is exactly the half-revert this test failed to catch when the revert
18
+ // was first written. (b) The class judgement is dropped as pointless now that
19
+ // it prices nothing, taking the correction discipline with it. Nothing outside
20
+ // this file catches either; the fleet never reads back the model it dispatched
21
+ // at (board.mjs parses `message.usage` off the subagent JSONL and drops
22
+ // `message.model` on the same line).
23
+ //
24
+ // Presence pins are not enough here. An earlier draft of these tests passed
25
+ // with the rule INVERTED end to end — corrections at `sonnet`, everything else
26
+ // at top tier — because every token it looked for was still somewhere in the
27
+ // slice. Each class is therefore pinned to its tier by ADJACENCY, with the
28
+ // competing tier token excluded from the gap.
29
+ //
30
+ // Slice by named anchors and fail loudly when one moves; slice SIZE is what
31
+ // does the work. One slice per paragraph, never per phase: widen a slice to its
32
+ // phase and a neighbouring paragraph satisfies the pin on its own. Measured on
33
+ // the old phase 0 — delete step 4's `**correction-ticket discipline**` sentence
34
+ // and the pin on that phrase below stayed green regardless, on step 6's "which
35
+ // tickets carry the correction-ticket discipline" alone. #1804 retired step 6
36
+ // (the multi-select) and moved step 4 into phase 1's Pull as its step 3; the
37
+ // rule the measurement taught still holds, since phase 2's prompt paragraph
38
+ // names the same discipline a few hundred lines on.
39
+ const REPO = join(import.meta.dirname, "..");
40
+ const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
41
+
42
+ // These three slices are paragraph-tight. A failure here means the text was
43
+ // deleted OR relocated — check the rest of the file before assuming deletion.
44
+ const step4 = () =>
45
+ section(RUN_TEAM, "3. **Read the ticket in full, once**", "4. **Collision scan", "run-team phase 1 Pull step 3 (was phase 0 step 4)");
46
+ const dispatch = () =>
47
+ section(RUN_TEAM, "**Dispatch every implementer", "**Guard: accumulate per PR", "run-team phase 2 dispatch rule");
48
+ const guard = () =>
49
+ section(RUN_TEAM, "**Guard: accumulate per PR", "Why the agent body carries what it does", "run-team phase 2 tier guard");
50
+
51
+ // The dispatch slice's past-tense revert note — the one legitimate statement of
52
+ // the `class=routine` → `sonnet` binding, whose SPAN the rebindings scan exempts.
53
+ const REVERT_NOTE = /\*\*`class=routine` → `sonnet` was REVERTED on [\s\S]*?\*\*/;
54
+
55
+ // Every `class=routine`/`sonnet` binding stated in `slice` that starts outside
56
+ // `note`'s span. Read one sentence at a time, via `sentences()`, with a gap that
57
+ // tolerates a period — never a first-period `[^.]` window over the raw slice
58
+ // (#1983). Any hit is a fault, so a window cut short is this scan's silent
59
+ // direction: "`class=routine` tickets follow `agents/fleet-implementer.agent.md`
60
+ // at `sonnet`" ended the old window at the filename's period and passed. The
61
+ // sentence is what bounds the gap, so a `class=routine` in one sentence never
62
+ // pairs with a `sonnet` in the next. Each sentence's offset is recovered by
63
+ // searching the slice from the previous sentence's end — sentences() drops the
64
+ // whitespace it splits on — so a hit's index is still an index into `slice`,
65
+ // comparable against the note's span as before.
66
+ //
67
+ // The note's own span is masked out of whichever sentence it falls in before
68
+ // matching, the same technique citationFault uses for quoted/parenthesized
69
+ // spans. Found in review: without this, a restoration glued onto the note's
70
+ // closing `**` with no whitespace before it (`.**;`, `.**,`, or nothing at
71
+ // all) leaves the note and the restoration in ONE sentence, because
72
+ // `sentences()` only splits at a terminator FOLLOWED by whitespace. The
73
+ // note's own `class=routine`/`sonnet` pair would then anchor a match whose
74
+ // gap runs past the note and swallows the restoration, and the exemption
75
+ // filter below — keyed on where the match STARTS — would read the whole
76
+ // thing as covered by the note, a silent miss the OLD raw-slice scan did not
77
+ // have (the note's literal period ended its `[^.]` tail first). Masking
78
+ // keeps the sentence the same length, so the offsets recovered above still
79
+ // line up, and the filter below is now a second, redundant guard rather than
80
+ // the only one.
81
+ //
82
+ // RESIDUAL: sentences() still cuts short at a `.)`, `."`, a mid-sentence `?`,
83
+ // a capitalised "E.g." or an "etc." (silent here — none of those four is in
84
+ // this slice today), and still merges two real sentences across #1987's
85
+ // `**late**.[1]` and #1899's sentence-final lowercase "vs." (an over-fire
86
+ // here, also absent today). `.**` itself is common in this slice (14
87
+ // bold-lead sentence ends) but each is a genuine boundary between two
88
+ // unrelated sentences, not one straddling a rebinding fact — the note's own
89
+ // `.**` is the one exception, which is exactly what the masking above is for
90
+ // rather than trusting the corpus to stay accidentally clean.
91
+ const REBINDING = /`class=routine`[\s\S]{0,120}sonnet[\s\S]{0,40}|sonnet[\s\S]{0,120}`class=routine`[\s\S]{0,40}/g;
92
+ const rebindingsOutside = (slice, note) => {
93
+ const noteAt = slice.indexOf(note);
94
+ const noteEnd = noteAt + note.length;
95
+ const hits = [];
96
+ let cursor = 0;
97
+ for (const sentence of sentences(slice)) {
98
+ const at = slice.indexOf(sentence, cursor);
99
+ cursor = at + sentence.length;
100
+ const overlapStart = Math.max(at, noteAt);
101
+ const overlapEnd = Math.min(cursor, noteEnd);
102
+ const masked = overlapStart < overlapEnd
103
+ ? sentence.slice(0, overlapStart - at) + "#".repeat(overlapEnd - overlapStart) + sentence.slice(overlapEnd - at)
104
+ : sentence;
105
+ for (const hit of masked.matchAll(REBINDING)) {
106
+ const index = at + hit.index;
107
+ hits.push({ index, text: slice.slice(index, index + hit[0].length) });
108
+ }
109
+ }
110
+ return hits.filter((hit) => hit.index < noteAt || hit.index >= noteEnd).map((hit) => hit.text);
111
+ };
112
+
113
+ test("phase 0 step 4 still earns its class judgement now that the class prices nothing", () => {
114
+ const slice = step4();
115
+
116
+ // The criterion, not the label: what makes a ticket a correction ticket has
117
+ // to be checkable by the controller reading the issue, or the class is a coin
118
+ // flip. Not /docs|comments/ — this slice opens with `--json title,body,comments`,
119
+ // so the `comments` alternative stays green with the criterion deleted.
120
+ // Bound to the class it selects, with `routine` excluded from the gap: a bare
121
+ // /bad citations/ survives the two classes being swapped.
122
+ assert.match(
123
+ slice,
124
+ /bad citations(?:(?!routine)[^.])*?`class=correction`/,
125
+ "step 4 no longer routes the correction criterion to `class=correction`",
126
+ );
127
+ // What the class is FOR after the revert. Without this the judgement reads as
128
+ // vestigial and the next compression pass deletes it — taking the correction
129
+ // discipline, which is the half that caught real defects, with it.
130
+ assert.match(
131
+ slice,
132
+ /no longer selects a model tier/,
133
+ "step 4 no longer says the class stopped selecting a tier — the reverted binding reads as live again",
134
+ );
135
+ assert.match(
136
+ slice,
137
+ /correction-ticket\*{0,2} discipline/,
138
+ "step 4 no longer says what the class still selects, so the judgement reads as vestigial",
139
+ );
140
+ // THE NEGATIVE, half one of two. Restoring `class=routine` → `sonnet` here
141
+ // while phase 2 stays reverted is the self-contradiction the revert shipped
142
+ // with on its first pass: phase 0 priced the ticket, phase 2 ignored it, and
143
+ // nothing failed. The window spans sentences rather than one, because the
144
+ // stated reason for the one-sentence bound is false OF THIS SLICE: step 4
145
+ // holds ZERO `sonnet` occurrences, and every past-tense mention the bound was
146
+ // guarding against (L224, L235, L303, L304, L314) lives in the `dispatch` and
147
+ // `guard` slices, which this pin does not cover. Measured: under the old
148
+ // bound a restoration split across two sentences escaped the whole suite at
149
+ // 725/725; [\s\S]{0,400} reds it and leaves the clean tree green. Neither is
150
+ // the ORDER assumed — a restoration reading "`sonnet` is what `class=routine`
151
+ // tickets dispatch at" binds the class just as squarely and walks straight
152
+ // through the forward-only form, so both directions are scanned.
153
+ assert.doesNotMatch(
154
+ slice,
155
+ /`class=routine`[\s\S]{0,400}`sonnet`|`sonnet`[\s\S]{0,400}`class=routine`/,
156
+ "step 4 has re-bound `class=routine` to `sonnet` — the reverted rule is back in phase 0",
157
+ );
158
+ // Safe direction on a judgement with no tiebreak. The adjacent decided?
159
+ // judgement says "Torn → surface"; this one is cheap enough to just default.
160
+ assert.match(slice, /\*\*Torn → correction\*\*/, "step 4 lost its tiebreak, so a torn class dispatches on a guess");
161
+ // The citation is a precaution, NOT evidence about tiers —
162
+ // references/correction-tickets.md measures no tier and blames the ticket's
163
+ // framing. An earlier draft claimed the four-for-four happened "at top tier",
164
+ // a qualifier that reference does not carry. Pin the honesty, or it comes back.
165
+ assert.match(
166
+ slice,
167
+ /precaution, not a\s+\*{0,2}measurement/,
168
+ "step 4 states the correction exception as measured rather than as a precaution",
169
+ );
170
+ assert.match(
171
+ slice,
172
+ /measures no tier at\s+all/,
173
+ "step 4 no longer says the cited reference measures no tier — the citation reads as evidence again",
174
+ );
175
+ });
176
+
177
+ test("phase 2 dispatches every class at the session tier, and says so with a mechanism", () => {
178
+ const slice = dispatch();
179
+
180
+ // The rule, bound to "whatever the class" so a re-introduced per-class branch
181
+ // reds here rather than silently coexisting with this sentence.
182
+ assert.match(
183
+ slice,
184
+ /omit `model` on the `task`\s+call, whatever the class/,
185
+ "phase 2 no longer dispatches every class the same way — a per-class tier branch is back",
186
+ );
187
+ // The revert is dated and attributed, or the next reader takes the missing
188
+ // tier for an omission and helpfully restores it. Pinned BEFORE the scan
189
+ // below, whose exemption is the SPAN this note occupies: a reworded note has
190
+ // to be diagnosed as a reworded note, or the scan reports it as a restored
191
+ // binding and sends the reader hunting a rebinding nobody made.
192
+ assert.match(
193
+ slice,
194
+ /REVERTED on 2026-08-16/,
195
+ "phase 2 no longer records WHEN and WHY the tier binding was removed",
196
+ );
197
+ // THE POSITIVE SHAPE PIN (#553). The pin above only checks the phrase is
198
+ // PRESENT somewhere in the slice, so a restoration clause written INSIDE
199
+ // the note — keeping "was REVERTED on 2026-08-16" intact — still satisfies
200
+ // it, then rides the scan's note exemption below to green: that exemption
201
+ // drops every hit starting inside the note's span, whatever else the hit
202
+ // says. Pin the note's own shape instead of slicing the note out before the
203
+ // scan (the rejected remedy — a larger change, not needed once the shape
204
+ // itself is pinned). Isolated to the bold span itself, not the whole slice,
205
+ // so a present-tense rebinding written anywhere else in THIS DISPATCH SLICE
206
+ // stays the rebindings scan's job below. Not "anywhere in phase 2": the
207
+ // `## Phase 2` heading is far wider than this paragraph, and the guard
208
+ // paragraph inside it has no rebindings scan of its own — this file holds
209
+ // exactly one.
210
+ //
211
+ // This doc's own convention grounds the shape: a dated note states one
212
+ // action on one date (comment above — "dated and attributed"), so a
213
+ // restoration smuggled inside it surfaces as a further date (when the
214
+ // restoration happened), as the state the binding is restored TO, or as a
215
+ // second mention of the binding itself. Those are the three checks below,
216
+ // in that order. Settled against a single edit to this note — appending
217
+ // "and is RESTORED on 2026-08-18, so routine members dispatch at `sonnet`
218
+ // again." — each of the three matches it independently and names the
219
+ // note, not the scan. A pure whitespace reflow, or a past-tense reword
220
+ // that adds no further mention of the binding, trips none of them — but
221
+ // that is narrower than "any reword": the third check's own grid below
222
+ // measures which benign rewords DO trip it (3/7, corrected below).
223
+ const revertNote = REVERT_NOTE.exec(slice)?.[0];
224
+ assert.ok(
225
+ revertNote,
226
+ "the revert note's opening clause changed shape enough that this pin can no longer find it — read the slice and update the anchor",
227
+ );
228
+ assert.equal(
229
+ (revertNote.match(/\d{4}-\d{2}-\d{2}/g) ?? []).length,
230
+ 1,
231
+ "the revert note now names more than one date — a restoration is hiding inside the note whose span the rebindings scan exempts",
232
+ );
233
+ // ponytail: catches the measured restoration and any dated repeat of it,
234
+ // plus the specific verb this doc's own restorations are written with. The
235
+ // dateless restoration phrased without "restored" that this one lets past
236
+ // is the third check's job, below (#1226).
237
+ assert.doesNotMatch(
238
+ revertNote,
239
+ /\bRESTORED\b/i,
240
+ "the revert note now says the binding is RESTORED — a restoration is hiding inside the note whose span the rebindings scan exempts",
241
+ );
242
+ // THE TOKEN BUDGET (#1226). A restoration written inside the note that
243
+ // carries no second date and never spells "RESTORED" satisfies both checks
244
+ // above and then rides the scan's span exemption below, because that
245
+ // exemption drops every hit starting inside the note whatever the hit says.
246
+ // Measured from a copy of this tree under a scratch directory: the note
247
+ // re-ended "firing; that binding is back in force, so routine members
248
+ // dispatch at `sonnet`." left this file at 10/10.
249
+ //
250
+ // Pin what the note is ALLOWED TO SAY, not the vocabulary a restoration
251
+ // would say it in. The note's legitimate job is to state the reverted
252
+ // binding once; any further `class=routine` or `sonnet` inside it is a
253
+ // second statement of a binding the scan below is forbidden to look at.
254
+ // That invariant survives rewording. A word list does not.
255
+ //
256
+ // #1226 asked first whether #476's trigger was met, reading it as a count
257
+ // of misses. It is not a count: #476 closed with "re-open trigger: someone
258
+ // exhibits a regex that passes that grid", so the cross-review arithmetic
259
+ // the issue carried — is one review's two dimensions a second miss? — never
260
+ // gated anything; the grid did. Ten restoration mutants of this note and
261
+ // seven benign edits of it, each run as its own copy:
262
+ //
263
+ // instrument kills over-fires
264
+ // /\b(is|are) (now )?(back|restored|in force)\b/i 4/10 0/7
265
+ // the note states its binding exactly once 6/10 3/7 <- this
266
+ // tight one-clause template over the whole note 8/10 3/7
267
+ //
268
+ // Re-measured under independent review: an earlier pass of this comment
269
+ // claimed 0/7 for this row and claimed above that "a reflow or a
270
+ // past-tense-only reword trips none of them" — both wrong. This check
271
+ // counts mentions, not intent, so any benign edit that re-mentions
272
+ // `class=routine` or `sonnet` inside the note trips it exactly as a
273
+ // restoration would. The 3 over-fires on the 7-edit grid: pulling the
274
+ // guard paragraph's own adjacent "reverts `class=routine`" clause into the
275
+ // note, a reword naming the tier the class moved off to ("...instead of
276
+ // `sonnet`"), and a parenthetical gloss restating the binding for context.
277
+ // The other four — whitespace reflow, a past-tense-only reword that adds
278
+ // no mention, a comma fix, and a moved bold marker — leave the note's
279
+ // mention count at one and pass. Kept over the template row despite the
280
+ // now-tied 3/7: this row's over-fires are all edits that literally repeat
281
+ // the pinned tokens, the same shape a restoration takes, where the
282
+ // template's 3 over-fires (an em-dash reason, a semicolon expansion, a
283
+ // moved bold marker — #476's sentence-anchor column, reproduced) are
284
+ // structural and share nothing with a restoration. The suggested word list
285
+ // is rejected on its own mutant regardless of either row: drop "that
286
+ // binding is back in force" from the measured restoration and keep the
287
+ // restoration — "firing; routine members dispatch at `sonnet` again." —
288
+ // and it goes green where this check reds. Widening it is ruled out by
289
+ // docs/adr/0017-prose-pins-pin-content-not-modality.md (#529, #476).
290
+ //
291
+ // RESIDUAL, measured and still exposed — TWO gaps, not one:
292
+ // (1) a restoration that never re-states the binding at all — "that
293
+ // binding is back in force.", "That revert no longer holds.", "(since
294
+ // undone)." — passes all three checks here, because none of them read for
295
+ // restoration MODALITY, only for a repeated token or a repeated date.
296
+ // (2) a restoration that DOES re-state the binding, but in the doc's own
297
+ // unbackticked prose rather than the backticked `class=routine` literal —
298
+ // "routine members dispatch at `sonnet` again", placed outside the note —
299
+ // clears this check (it never touches the note) and clears the rebindings
300
+ // scan below (that scan's own regex requires the backticked
301
+ // `` `class=routine` `` token, which this reword never spells): measured
302
+ // 10/10 green on a copy of this tree. Gap (2) is strictly larger than gap
303
+ // (1) — it needs no dateless, wordless restoration trick, just the doc's
304
+ // ordinary vocabulary — and is not fixed here. Catching either is a
305
+ // question about prose MODALITY, and that is settled, not open:
306
+ // docs/adr/0017-prose-pins-pin-content-not-modality.md rules that prose
307
+ // pins assert content, never modality, and that an obligation which must
308
+ // not soften gets a code carrier (a script verdict surfaced as a
309
+ // fleet-tick row), not a prose pin. This residual is a recorded gap under
310
+ // that ADR. Do not close it with a longer word list.
311
+ assert.deepEqual(
312
+ (revertNote.match(/class=routine|sonnet/gi) ?? []).map((token) => token.toLowerCase()),
313
+ ["class=routine", "sonnet"],
314
+ "the revert note mentions `class=routine` or `sonnet` more than once — either a restoration is hiding inside the note whose span the rebindings scan exempts, or this is a benign reword that re-mentions the binding (see the grid above); read the note before assuming which",
315
+ );
316
+ // THE NEGATIVE, half two of two. See the step-4 companion: the binding was
317
+ // stated independently in both places, so restoring either one alone is
318
+ // undetectable without a pin on each. Nothing is assumed between the two
319
+ // tokens — not the arrow, not a verb, not the backticks around `sonnet` —
320
+ // because the `class=routine` → `model: "sonnet"` literal this used to require
321
+ // is only one spelling of the restoration. Measured: `→ `sonnet``, "now
322
+ // resolves to", and `model:'sonnet'` each re-bind the class in the file's own
323
+ // vocabulary and each walked straight through the literal form. The one
324
+ // legitimate statement of the binding in this slice is the past-tense revert
325
+ // note, exempted by the SPAN it occupies rather than by narrowing the pattern
326
+ // back to a literal — a narrower pattern is what let the half-revert through.
327
+ // Exempting on the phrase "was REVERTED" instead was measured to swallow a
328
+ // live restoration written AFTER the note that quoted that phrase in its own
329
+ // sentence: the hit began past the note's end and was dropped anyway, because
330
+ // the filter read the hit's words rather than where it sat. A span cannot be
331
+ // quoted. The ORDER is not assumed either, for the same reason the arrow is
332
+ // not: the mirrored sentence states the same binding and matched nothing at
333
+ // all.
334
+ assert.deepEqual(
335
+ rebindingsOutside(slice, revertNote),
336
+ [],
337
+ "phase 2 states a `class=routine` → `sonnet` binding outside the past-tense revert note — the reverted rule is back",
338
+ );
339
+ // Anchored to the omission, not the word "inherit": the tier is obtained by
340
+ // NOT passing `model`, and "implementers run at the session tier" with no
341
+ // mechanism is exactly the instruction-names-no-mechanism defect the skill's
342
+ // own tooling-fix triggers list calls out.
343
+ assert.match(
344
+ slice,
345
+ /dispatched with `model` set does not get the declared\s+tier back/,
346
+ "phase 2 no longer says HOW the declared tier is obtained — omitting `model` is still the mechanism",
347
+ );
348
+ // The omission resolves to the DEFINITION's tier first and the session's only
349
+ // after. Stated without that ordering, "omit `model`" reads as "inherit the
350
+ // session", which is what the declaration was written to stop being true.
351
+ assert.match(
352
+ slice,
353
+ /session's tier applies only when the definition\s+names none/,
354
+ "phase 2 states the omission mechanism without saying the definition's tier wins first",
355
+ );
356
+ // The dispatch rule has to NAME the definition, or the tier is declared
357
+ // somewhere the reader of this phase can neither find nor audit.
358
+ assert.match(
359
+ slice,
360
+ /agent: "fleet-implementer"/,
361
+ "phase 2 no longer dispatches the declared agent",
362
+ );
363
+ assert.match(
364
+ slice,
365
+ /agents\/fleet-implementer\.agent\.md/,
366
+ "phase 2 no longer says WHERE the declared tier lives",
367
+ );
368
+ // `name` is orthogonal to `agent` and is what confers team membership —
369
+ // the ledger token and the hub address; both the spend classifier and
370
+ // member-outcomes.mjs read it. A rewrite that swaps the name for the
371
+ // agent silently unmakes the member.
372
+ assert.match(
373
+ slice,
374
+ /Keep `name: impl-<N>`/,
375
+ "phase 2 no longer keeps the impl-<N> name alongside the dispatched agent",
376
+ );
377
+
378
+ // A lost class no longer misprices anything, but it still costs the correction
379
+ // discipline — so the recording rule has to survive the revert, and has to say
380
+ // what is actually lost or it reads as bookkeeping and gets dropped.
381
+ assert.match(
382
+ slice,
383
+ /\*\*No class recorded → record `class=unknown`, never a guess\.\*\*/,
384
+ "a missing class is no longer recorded as `class=unknown` — the gap goes invisible",
385
+ );
386
+ // Anchored to "still costs the", not bare: the phrase occurs TWICE in this
387
+ // slice — here, and incidentally in the REVERTED paragraph above ("it still
388
+ // governs the correction-ticket discipline"). Measured: an unanchored
389
+ // /correction-ticket discipline/ stayed green with this sentence's cost
390
+ // clause gutted, because the other copy satisfied it on its own. It pinned
391
+ // the phrase's existence somewhere in the slice, never the recording rule.
392
+ assert.match(
393
+ slice,
394
+ /still costs the \*\*correction-ticket discipline\*\*/,
395
+ "phase 2 no longer says what a lost class actually costs now that it prices nothing",
396
+ );
397
+ // Reconstructing the class from the model would resurrect the confound the
398
+ // revert removed, and would silently break under any future tier control.
399
+ assert.match(
400
+ slice,
401
+ /Never infer the class from the tier/,
402
+ "phase 2 no longer forbids inferring class from tier",
403
+ );
404
+
405
+ // All three ledger literals. Only `class=correction` was ever spelled, which
406
+ // left an absent field ambiguous between "ran routine", "never recorded" and
407
+ // "row predates the rule" — and partitioning by class is the guard's whole job.
408
+ for (const cls of ["routine", "correction", "unknown"]) {
409
+ assert.match(
410
+ slice,
411
+ new RegExp(`ledger\\.mjs row <N> "impl-<N> · class=${cls}"`),
412
+ `phase 2 no longer spells the ledger literal for class=${cls}`,
413
+ );
414
+ }
415
+ // `row` REPLACES the line (ledger.mjs's `data.rows[i] = line`). Replaying a
416
+ // two-token literal over a row carrying KILLED or → PR# drops those tokens with
417
+ // only `rewrote row #N` on stderr.
418
+ assert.match(
419
+ slice,
420
+ /replaces the whole line/,
421
+ "phase 2 shows a ledger literal without saying `row` replaces rather than appends",
422
+ );
423
+ });
424
+
425
+ test("a period in the gap does not hide a rebinding outside the revert note", () => {
426
+ // #1983's shape, both directions, on the real dispatch slice. Refuse: each
427
+ // restoration carries a period between the two tokens — a filename, an
428
+ // abbreviation — which ended the old `[^.]` window, green. Accept: the note
429
+ // itself stays exempt, and two tokens in DIFFERENT sentences are no binding.
430
+ const slice = dispatch();
431
+ const note = REVERT_NOTE.exec(slice)?.[0];
432
+ assert.ok(note, "the revert note is no longer findable — update REVERT_NOTE");
433
+ const after = (sentence) => slice.replace(note, `${note} ${sentence}`);
434
+ for (const restoration of [
435
+ "Every `class=routine` ticket follows `agents/fleet-implementer.agent.md` at `sonnet` again.",
436
+ "Dispatch `sonnet` for, e.g. docs fixes, every `class=routine` ticket.",
437
+ ]) {
438
+ assert.equal(rebindingsOutside(after(restoration), note).length, 1, `a restoration read as clean: ${restoration}`);
439
+ }
440
+ assert.deepEqual(
441
+ rebindingsOutside(after("Record `class=routine` in the ledger row. No member dispatches at `sonnet` by class."), note),
442
+ [],
443
+ "a `class=routine` and a `sonnet` in two different sentences read as one binding",
444
+ );
445
+ });
446
+
447
+ test("a rebinding glued onto the revert note with no sentence break does not hide inside its span", () => {
448
+ // Found in review of #1983: sentences() only splits at a terminator FOLLOWED
449
+ // by whitespace, so a restoration glued directly onto the note's closing
450
+ // `**` — a semicolon, a comma, or nothing at all before the next token —
451
+ // leaves the note and the restoration in ONE sentence. Unmasked, the note's
452
+ // own `class=routine`/`sonnet` pair anchors a match whose gap runs past the
453
+ // note and swallows the restoration, and the exemption filter, keyed on
454
+ // where the match starts, reads the whole thing as covered by the note.
455
+ const slice = dispatch();
456
+ const note = REVERT_NOTE.exec(slice)?.[0];
457
+ for (const glue of [
458
+ `${note}; \`class=routine\` is back at \`sonnet\`.`,
459
+ `${note}, and \`class=routine\` is back at \`sonnet\`.`,
460
+ `${note}\`class=routine\` binds \`sonnet\` immediately.`,
461
+ ]) {
462
+ const mutated = slice.replace(note, glue);
463
+ assert.notEqual(mutated, slice, `the glued fixture no longer matches the dispatch slice: ${glue}`);
464
+ assert.equal(rebindingsOutside(mutated, note).length, 1, `a rebinding glued onto the note's own span read as covered by it: ${glue}`);
465
+ }
466
+ });
467
+
468
+ test("phase 2's guard is mandatory, runnable, and scoped to one class", () => {
469
+ const slice = guard();
470
+
471
+ // The unit. Supply is one Pull per free slot (ADR 0013), so no batch of
472
+ // implementers exists to compare — the original rule compared one staged set
473
+ // of implementers against the set before it, two sets nobody can enumerate.
474
+ assert.match(slice, /unit is the PR/, "the guard's unit is no longer the PR");
475
+ assert.match(
476
+ slice,
477
+ /no implementer batches/,
478
+ "the guard no longer says why a batch is not a usable unit — it comes back otherwise",
479
+ );
480
+
481
+ // Runnable, not merely named. `compute-spend.mjs` is a pure module: no
482
+ // shebang, no process.argv, no main — running it prints nothing and exits 0,
483
+ // which reads as "no spend recorded". `board.mjs build` emits it at `.spend`
484
+ // (compute-board.mjs's `spend: inputs.spend ?? null`). The doesNotMatch is
485
+ // over a verified-zero baseline and needs the positive companion above it to
486
+ // stay meaningful. Case-sensitive on purpose, and ruled so twice (#529): the
487
+ // file on disk is lowercase and so is every reference to it, so an `i` flag
488
+ // would pin a spelling nothing in the repo can write. Settled with
489
+ // `grep -rio compute-spend --exclude-dir=.git . | grep -v ':compute-spend$'`,
490
+ // which is empty.
491
+ assert.match(slice, /board\.mjs build/, "the guard no longer names a runnable way to read spend");
492
+ assert.doesNotMatch(
493
+ slice,
494
+ /compute-spend\.mjs/,
495
+ "the guard points at compute-spend.mjs, which has no CLI — it exits 0 printing nothing",
496
+ );
497
+
498
+ // Normative, not advisory. This repo runs prose-compression passes that hedge
499
+ // exactly that way.
500
+ //
501
+ // A `/^\*\*Guard: /` pin sat here and was DELETED as a tautology (#529) — do
502
+ // not restore it on finding the guard heading unpinned. `section()` returns
503
+ // `source.slice(indexOf(startAnchor), end)`, so the slice opens with this
504
+ // block's start anchor whatever the end anchor is, and that regex carried no
505
+ // `m` flag: the start anchor alone satisfied it. A lead that breaks it breaks
506
+ // the anchor too, so `section()` reds first, under its own message.
507
+ //
508
+ // Settled by mutation, not argument. Replace the guard lead's
509
+ // `never conclude inside one run.**` with `never conclude inside one run —
510
+ // advisory, at your discretion, skip when time is short.**` in
511
+ // run-team/SKILL.md — the start anchor survives — then run
512
+ // `node --test plugin/scripts/*.test.mjs`: the suite stays green and
513
+ // the deleted pin's message appears nowhere in the output. Quote that whole
514
+ // span, not the `one run.**` tail: the tail is not unique in that SKILL, and
515
+ // its other hit is the `**Why not decide inside one run.**` heading that
516
+ // member-outcomes-prose.test.mjs uses as a `section()` end anchor — a global
517
+ // replace on the tail reds THAT suite, which reads as the deleted pin
518
+ // catching the hedge. Restore with `cp`, never `git checkout --`.
519
+ //
520
+ // That green is a recorded gap, not an open question:
521
+ // docs/adr/0017-prose-pins-pin-content-not-modality.md rules that prose
522
+ // pins pin content, never modality, and that this guard's obligation gets
523
+ // a code carrier — a script verdict surfaced as a fleet-tick row — with
524
+ // #2037's successor guard, not a stronger pin here. Until that lands, the
525
+ // mutation above stays green. The list below is a literal-word tripwire
526
+ // ONLY: it catches `Optional` and `you may` and nothing else, and the
527
+ // reworded lead uses neither. Widening it is ruled out by the same ADR,
528
+ // because that instrument was measured failing (#476).
529
+ assert.doesNotMatch(
530
+ slice,
531
+ /\bOptional\b|\byou may\b/i,
532
+ "the guard has been downgraded to advice — an optional guard is not a guard",
533
+ );
534
+
535
+ // A threshold, or "either climbs" fires on the first noisy pair or never.
536
+ assert.match(
537
+ slice,
538
+ /at least\s+three `class=routine` PRs/,
539
+ "the guard no longer states a minimum sample, so one PR's findings can trigger a revert",
540
+ );
541
+ // Findings/fix-rounds are the counter-signal: reviews run 3-5x LONGER than
542
+ // implementation, so an extra fix-round costs an implementer slot. A guard on
543
+ // spend alone measures the wrong side.
544
+ assert.match(
545
+ slice,
546
+ /one extra fix-round costs an implementer slot/,
547
+ "the guard measures spend without the fix-round cost that would eat the saving",
548
+ );
549
+ // The revert UNIT. `/revert/` alone stays green through "revert the rule",
550
+ // which is the wholesale revert this sentence exists to forbid.
551
+ assert.match(
552
+ slice,
553
+ /revert \*\*`class=routine`\*\*/,
554
+ "the guard no longer scopes the revert to the affected class",
555
+ );
556
+ // The first run under the rule has no top-tier PRs to compare against, so the
557
+ // guard reads clean by construction. Unstated, that silence reads as a pass.
558
+ assert.match(
559
+ slice,
560
+ /never read the guard's silence as a pass/i,
561
+ "the guard no longer warns that its first-run silence is a missing baseline, not a pass",
562
+ );
563
+ });
564
+
565
+ test("phase 3 owns the guard — otherwise nothing in the event loop ever runs it", () => {
566
+ // The guard lives in phase 2, which is entered per-dispatch, BEFORE the PRs it
567
+ // wants to measure exist. Phase 3's tick is what the controller actually acts
568
+ // on, and the alt Pull it names is where the floor is read (ADR 0005 as
569
+ // amended by ADR 0012), so the guard needs its paragraph there or it is
570
+ // unreachable by design.
571
+ const slice = section(RUN_TEAM, "**Tier guards under Pull.**", "**Own the CI waits.", "run-team phase 3 tier guard under Pull");
572
+ assert.match(
573
+ slice,
574
+ /alt Pull/,
575
+ "phase 3's tier-guard paragraph no longer names the alt Pull as where it runs",
576
+ );
577
+ assert.match(
578
+ slice,
579
+ /tier\s+guard/,
580
+ "no phase 3 step dispatches the tier guard — it is stated in phase 2 and never reached",
581
+ );
582
+ });
583
+
584
+ // ---------------------------------------------------------------------------
585
+ // THE DECLARATION ITSELF. Every pin above reads SKILL.md, so a tier changed in
586
+ // `agents/fleet-implementer.agent.md` leaves all of them green while the
587
+ // dispatched tier flips — the same silent drift they exist to catch, routed
588
+ // around the document they read. That hazard is why the declaration arrived
589
+ // with these three.
590
+ const frontmatterOf = (name) =>
591
+ readFileSync(join(REPO, "agents", `${name}.agent.md`), "utf8").split("---")[1] ?? "";
592
+
593
+ test("the implementer definition declares a model carrying both a role and a level", () => {
594
+ // The declaration is one key, `model: "@<role>:<level>"` — the level rides
595
+ // on the model's own suffix (ADR 0014), so there is no second key to omit
596
+ // independently and leave the level inherited from whatever session
597
+ // dispatched the member.
598
+ const fm = frontmatterOf("fleet-implementer");
599
+ assert.match(fm, /^model:\s*"@(slow|task|smol):(minimal|low|medium|high|xhigh|max)"$/m, "the implementer definition declares no tier route");
600
+ });
601
+
602
+ test("the declared model is a fleet tier route, never a vendor id — both definitions", () => {
603
+ // A vendor id rots into a superseded generation that is weaker AND
604
+ // dearer: pricing falls with each generation. The role alias tracks
605
+ // whatever model the operator's `modelRoles` currently points it at.
606
+ // Both definitions, not just the default: #1345's dispatch-time tier
607
+ // check compares this same field on fleet-implementer-alt, and a vendor
608
+ // id there would fail the role-target comparison silently reading as a
609
+ // real mismatch rather than a declaration defect.
610
+ for (const name of ["fleet-implementer", "fleet-implementer-alt"]) {
611
+ const model = /^model:\s*"?(\S+?)"?$/m.exec(frontmatterOf(name))?.[1];
612
+ assert.match(model, /^@(slow|task|smol):(minimal|low|medium|high|xhigh|max)$/, `${name}: not a tier route: ${model}`);
613
+ }
614
+ });
615
+
616
+ test("the definition lists no tools — a list would drop dispatch capability", () => {
617
+ // references/member-lifecycle.md's "Every member is named" section: the
618
+ // name is the ledger token and the hub address — a `tools:` list that
619
+ // narrows what the member can call costs it silently, with no error.
620
+ // Omit the key.
621
+ assert.doesNotMatch(frontmatterOf("fleet-implementer"), /^tools:/m);
622
+ });
623
+
624
+ // ADR 0014's ruling records the layer-1 (#1314) key set for every fleet
625
+ // agent file: `name`, `description`, `model` — the level no longer rides a
626
+ // separate key. This file only pins the two implementer definitions #1345's
627
+ // dispatch-time tier check reads — #1314 owns the general checker over
628
+ // every agent file in the tree.
629
+ test("both implementer definitions carry all three required keys", () => {
630
+ for (const name of ["fleet-implementer", "fleet-implementer-alt"]) {
631
+ const fm = frontmatterOf(name);
632
+ for (const key of ["name", "description", "model"]) {
633
+ assert.match(fm, new RegExp(`^${key}:\\s*\\S`, "m"), `${name}.agent.md declares no ${key}`);
634
+ }
635
+ }
636
+ });
637
+
638
+ // The alt definition differing from the default in ROLE ONLY is pinned in
639
+ // within-run-pair-prose.test.mjs's "the alternate definition differs from
640
+ // the default in ROLE ONLY, the level stays shared" — not repeated here.
641
+ // That test already asserts the level suffix is shared and the role alone
642
+ // diverges; duplicating it here would just be a second copy to keep in
643
+ // sync with the same two files.