@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,312 @@
1
+ // #1499. #1053 corrected one falsified premise — that the finisher edge fires
2
+ // on the fix-applier's own push, so green alone licenses a dispatch — at three
3
+ // sites. Two are pinned by `ci-completes-premise-prose.test.mjs` (the phase-3
4
+ // **Monitor: CI run completes** bullet and the narrative finisher paragraph,
5
+ // both in `skills/run-team/SKILL.md`). The third is this file's subject:
6
+ // `commands/review-and-fix.md` step 4, the copy a fix-applier actually reads.
7
+ // That sibling's own comment already says its slices do not reach here, and
8
+ // nothing else did either — the premise closed at two sites and stayed open at
9
+ // the third, which is the exact shape of the loophole #1053 was filed for.
10
+ //
11
+ // THE CLASS, enumerated. `dispatch(es) a finisher` occurs at four prose sites
12
+ // besides the two already pinned:
13
+ // - `commands/review-and-fix.md` step 4 — the dispatch GATE. COVERED here.
14
+ // - `skills/run-team/SKILL.md` "which dispatches a finisher against" (inside
15
+ // the quoted fix-applier dispatch block) — a SHA-pinning instruction, not
16
+ // the green gate; already held byte-for-byte by
17
+ // `dispatch-block-golden-prose.test.mjs`'s golden fixture. Left.
18
+ // - `skills/run-team/SKILL.md` "a tree to dispatch a finisher against" —
19
+ // worktree lifetime, a different claim entirely. Left.
20
+ // - `head-moved-after-label-prose.test.mjs`'s own comment — a test comment,
21
+ // not instruction prose. Left.
22
+ // Re-pinning the two sibling sites is out of scope (#1499 says so); this file
23
+ // adds the third guard and touches neither.
24
+ //
25
+ // WHY ONE CONTIGUOUS SPAN, not two presence checks. Both halves of the gate are
26
+ // load-bearing — the report having arrived, and CI being green — and the rule
27
+ // lives in their JOIN. Pinning the halves separately stays green on a mutant
28
+ // that keeps both phrases and swaps the conjunction ("arrived OR CI is green"),
29
+ // which is the pre-#1053 defect restored with more words. One exact span refuses
30
+ // all four mutations below, so that is the shape used, with the reflow control
31
+ // alongside it as the proof it is not thereby over-tight.
32
+ //
33
+ // Mutation-tested by hand, 2026-09-18, against a scratch copy of
34
+ // `commands/review-and-fix.md` under `/tmp/fleet-scratch/impl-1499/` (never the
35
+ // real checkout), each substitution asserted to have applied before the run was
36
+ // believed. Family = `plugin/scripts/*prose*.test.mjs` + `prose-pin.test.mjs`.
37
+ //
38
+ // BEFORE this file, 601/601 green on every one of:
39
+ // (M1) the clause reverted to the pre-#1053 "dispatches a finisher on green"
40
+ // (M2) only the report-arrival half dropped ("once CI is green")
41
+ // (M3) only the CI half dropped ("once your report has arrived")
42
+ // Nothing reddened — the reversion was invisible to the whole family, which is
43
+ // the defect this file exists to remove. (Triage measured the same on a
44
+ // 570-test family; it has grown to 601 since, same result.)
45
+ //
46
+ // AFTER this file, 606/606 green clean, and each mutation reds exactly the pins
47
+ // that own it, by test NAME — never a raw failure count, which `node --test`
48
+ // prints twice per red:
49
+ // (M1) "dispatches a finisher on green" → 3 red: span pin, reverted-
50
+ // wording pin, reflow control
51
+ // (M2) "once CI is green" → 2 red: span pin, reflow control
52
+ // (M3) "once your report has arrived" → 2 red: span pin, reflow control
53
+ // (M4) "...has arrived OR CI is green" → 2 red: span pin, reflow control
54
+ // — the mutant half-pins miss
55
+ // (C1) step 4 rewrapped at 53 cols, meaning identical → every pin in this
56
+ // file green
57
+ // M2/M3 reddening on their own is what proves each half is separately
58
+ // load-bearing; only M1 additionally trips the reverted-wording pin, which is
59
+ // that pin owning exactly its one claim. The reflow control reds alongside the
60
+ // span pin on all four because it is derived from the LIVE slice rather than a
61
+ // quoted copy of today's line — the property that makes it a reflow control and
62
+ // not a second fixture to keep in sync.
63
+ //
64
+ // C1 used to also redden ONE pin outside this file — `pointer-target-prose.
65
+ // test.mjs`'s "every pointer clause in the document is still recognised",
66
+ // which extracted `see **…**` clauses per PHYSICAL line and found 3 instead
67
+ // of 5 once step 4 wraps. That was pre-existing brittleness in another
68
+ // file's pin, not fallout from this one, and #1609 is what closed it: that
69
+ // pin's scan now reads the document's LOGICAL lines, so the same C1 rewrap
70
+ // no longer loses any pointer (measured on this branch: 5 before and after).
71
+ // Nothing here needed to change — #1499 scoped this ticket to the third
72
+ // site's guard and explicitly out of migrating anything else.
73
+ //
74
+ // THE CEILING: a prose pin. It proves the two-condition gate is STATED where a
75
+ // fix-applier reads it, bounded to the step that states it. It cannot prove a
76
+ // controller obeys it, nothing here calls `gh`, and — matching the sibling pins'
77
+ // strictness rather than exceeding it — the span is matched against raw bytes,
78
+ // so a `**` moved INTO the pinned words would red it. No emphasis sits inside
79
+ // that span today and `#1465`/`#1492`'s helper migrations are explicitly not
80
+ // this ticket's to make.
81
+ import { test } from "node:test";
82
+ import assert from "node:assert/strict";
83
+ import { readFileSync } from "node:fs";
84
+ import { join } from "node:path";
85
+ import { betweenPhrases, phrase, unemphasized } from "./prose-pin.mjs";
86
+
87
+ const REPO = join(import.meta.dirname, "..");
88
+ const DOC = "commands/review-and-fix.md";
89
+ const reviewAndFix = () => readFileSync(join(REPO, ...DOC.split("/")), "utf8");
90
+
91
+ // The slice. Not `paragraph()`: this document writes one long line per numbered
92
+ // step with no blank line between them, so the next `\n[ \t]*\n` after step 4
93
+ // sits below step 6 — a blank-line bound would hand back three steps, and a pin
94
+ // on the gate would then be satisfiable from step 6's own green/label prose.
95
+ //
96
+ // Bounded instead by two landmarks NEITHER half of the gate owns: step 4's own
97
+ // opening imperative, and the instruction the premise justifies. Both sit
98
+ // OUTSIDE every mutation above by construction — a mutant that rewrote a bound
99
+ // would make `anchorAt` throw instead of the pin reddening, which is the harness
100
+ // losing its footing rather than a pin discriminating. Both go through
101
+ // `phrase()` (`anchorAt` does it for the start, `betweenPhrases` for the
102
+ // end), so a reflow moves neither, and both are single-hit in this file:
103
+ // grep -cF "Under the fleet, do not hold this wait" → 1
104
+ // grep -cF "so push, then report to the controller a" → 1
105
+ const STEP4_FROM = "Under the fleet, do not hold this wait";
106
+ const STEP4_TO = "so push, then report to the controller a";
107
+ const WHAT = `${DOC} step 4 finisher-dispatch premise`;
108
+
109
+ // Throws rather than widening at BOTH ends. The start half is `anchorAt`'s
110
+ // own exactly-once count. The end half cannot be a bare exactly-once count
111
+ // over the rest of the document: if step 4's own closing instruction is
112
+ // reworded away, the LAST thing left matching `STEP4_TO` is whatever comes
113
+ // after it — a single, unambiguous, and entirely wrong match, so a raw count
114
+ // would see exactly 1 and let it through.
115
+ //
116
+ // Bounded instead to step 4's own markdown list item — up to the next
117
+ // ordered-list marker at column 0 (`\n5. `, never indented — the ACCEPT SIDE
118
+ // reflow fixture below and C1 in the header both continue a wrapped line
119
+ // with `\n` plus INDENT, so neither is mistaken for the next item). A decoy
120
+ // ADDED on any later step, real closing instruction left untouched, can
121
+ // never enter the count — the search never reaches past this item's own
122
+ // boundary to find it. A decoy ADDED on step 4's own item, real closing
123
+ // instruction left untouched, still trips the same exactly-once check
124
+ // `betweenPhrases` uses for the end (mirroring `anchorAt`'s for the start).
125
+ //
126
+ // Not covered, by either end, and not a new gap this bound opens: rewording
127
+ // the true anchor AWAY in the same edit that plants its exact replacement
128
+ // text once, elsewhere, leaves exactly one match — indistinguishable from a
129
+ // legitimate reflow-driven re-anchor. `anchorAt` has this same limitation on
130
+ // the start side already; matching it on the end side is parity, not
131
+ // exceeding what a phrase anchor can promise. Silently falling back to the
132
+ // whole document, or binding past this slice's true end to an ADDED decoy
133
+ // on a later step, is the false green this bound exists to deny, and the
134
+ // bound-integrity test at the bottom holds every half of that claim.
135
+ const dispatchPremise = (text = reviewAndFix()) =>
136
+ betweenPhrases(text, STEP4_FROM, STEP4_TO, WHAT, { bound: /\n\d+\.\s/ });
137
+
138
+ // The gate, as ONE span: the dispatch, the report having arrived, and CI being
139
+ // green, in the order and with the conjunction the corrected prose uses.
140
+ const GATE = "dispatches a finisher once your report has arrived and CI is green";
141
+
142
+ // The pre-#1053 wording, verbatim from the commit that removed it (1be2080).
143
+ // Narrow on purpose: it must not match the corrected clause, whose "finisher"
144
+ // is followed by "once", not "on".
145
+ const REVERTED = "dispatches a finisher on green";
146
+
147
+ // Deliberately RAW BYTES, never `unemphasized()` — unlike the whole-document
148
+ // negative below. A `**` moved INTO this span (bolding part of the gate for
149
+ // emphasis) reds this test on purpose: it matches the sibling pins'
150
+ // strictness (see THE CEILING in the header) rather than exceeding OR
151
+ // loosening it, and this file's own #1499 scope excludes migrating this span
152
+ // pin onto an emphasis-tolerant helper. The negative below normalizes
153
+ // emphasis for a different reason — it is a coverage backstop over the WHOLE
154
+ // document, not a claim about this span's own bytes — so the two are not in
155
+ // tension: one enforces exact wording where a fix-applier reads it, the
156
+ // other refuses to let the pre-#1053 defect hide behind formatting anywhere
157
+ // else.
158
+ test("review-and-fix.md step 4 gates the finisher on the member's report AND CI, never on green alone", () => {
159
+ assert.match(
160
+ dispatchPremise(),
161
+ phrase(GATE),
162
+ `${DOC} step 4 no longer says "${GATE}". This is the sentence every fix-applier reads before pushing: with either half dropped it licenses a dispatch onto a SHA the member may still move, or onto a PR whose report has not arrived — the falsified premise #1053 corrected at two other sites.`,
163
+ );
164
+ });
165
+
166
+ // The negative, deliberately at the WIDEST scope this file owns — the whole
167
+ // document, not the slice. A copy of the pre-#1053 premise surviving anywhere in
168
+ // the member-facing command is the defect back, whether or not it sits in step
169
+ // 4 — and whether or not it is typed with `**` around part of it: bolding
170
+ // "green" for emphasis changes nothing about what the sentence licenses, so
171
+ // this check runs on `unemphasized(live)`, never on raw bytes (contrast the
172
+ // span pin above, which is deliberately raw-byte strict — see THE CEILING).
173
+ // The positive companion on the same normalized text is what keeps this from
174
+ // passing vacuously: alone, a `doesNotMatch` is satisfied by a document that
175
+ // has degenerated to nothing, and this one would then pass while the sentence
176
+ // was gone. The companion is deliberately the DISPATCH CLAUSE only, never the
177
+ // whole gate — pinning the gate here too would red this test on every
178
+ // mutation that drops a half, duplicating the span pin above and destroying
179
+ // the per-pin discrimination the mutation evidence in the header reports.
180
+ // This test owns exactly one claim: the pre-#1053 wording is not back, under
181
+ // any emphasis.
182
+ test("no sentence anywhere in review-and-fix.md licenses a finisher on green alone", () => {
183
+ const live = unemphasized(reviewAndFix());
184
+ assert.match(live, phrase("dispatches a finisher"), `${DOC} no longer says "dispatches a finisher" at all — the negative below would pass on a document that had lost the sentence entirely`);
185
+ assert.doesNotMatch(
186
+ live,
187
+ phrase(REVERTED),
188
+ `${DOC} says "${REVERTED}" again — that is the #1053 defect verbatim, whether or not it is typed with emphasis. The implementer's own push fires the CI edge first for every PR, so green arrives before any review has returned and this wording dispatches a finisher into it.`,
189
+ );
190
+ });
191
+
192
+ // The slice is step 4's own sentence and cannot reach its neighbours below it.
193
+ // Without this, a drifted end bound would let the gate pin above be satisfied
194
+ // from step 5 or step 6 — both of which talk about green, labels and
195
+ // reporting — and the pin would go on passing with step 4's premise reverted.
196
+ // (No equivalent check runs backward into step 3: the slice starts AT step
197
+ // 4's own anchor, so it can never reach step 3 regardless of how far the end
198
+ // bound drifts forward — that assert would be unfalsifiable by construction,
199
+ // never the guard the two below actually are.)
200
+ test("the pinned span is bounded to step 4 — neither neighbouring step is inside it", () => {
201
+ const slice = dispatchPremise();
202
+ assert.doesNotMatch(slice, phrase("File each deferred finding"), `${WHAT}: the slice runs forward into step 5`);
203
+ assert.doesNotMatch(slice, phrase("Diff-check green"), `${WHAT}: the slice runs forward into step 6`);
204
+ });
205
+
206
+ // ACCEPT SIDE — reflow. Derived from the LIVE slice, never a quoted copy of
207
+ // today's line, so a reword of neighbouring prose is not what this measures.
208
+ // Re-wrapped at a width nothing here assumes and rejoined with the newline plus
209
+ // list indent a markdown wrap actually produces: the span pin must still hold,
210
+ // because what it refuses is drift in the gate, not where the lines break. The
211
+ // inequality assert first — a fixture that has stopped changing the wrapping
212
+ // proves nothing and must be updated rather than left passing.
213
+ test("a rewrapped step 4 is ACCEPTED — the gate pin refuses drift, not line breaks", () => {
214
+ const live = dispatchPremise();
215
+ const rewrapped = live
216
+ .split(/\s+/)
217
+ .filter(Boolean)
218
+ .reduce((acc, w) => {
219
+ const last = acc[acc.length - 1];
220
+ if (last && `${last} ${w}`.length <= 41) acc[acc.length - 1] = `${last} ${w}`;
221
+ else acc.push(w);
222
+ return acc;
223
+ }, [])
224
+ .join("\n ");
225
+ assert.notEqual(rewrapped, live, "the rewrap fixture no longer changes the wrapping — update it");
226
+ assert.match(rewrapped, phrase(GATE), "the gate pin reds on a pure reflow — it is over-tight, not strict");
227
+ assert.doesNotMatch(rewrapped, phrase(REVERTED));
228
+ });
229
+
230
+ // The bound's failure mode, asserted rather than assumed. #1499's own acceptance
231
+ // criterion: if an anchor moves, this slicer must THROW — a slicer that fell
232
+ // back to the whole document would leave the gate pin passing off step 6's
233
+ // prose, which is the vacuous green every bound in this directory exists to
234
+ // prevent. Both ends get the SAME two failure directions: a start anchor that
235
+ // is gone (`anchorAt`), one that occurs twice (a restatement above the real
236
+ // one would otherwise bind the pin to the wrong copy), an end anchor that is
237
+ // gone (moved), and one that occurs twice (a restatement below the real one
238
+ // would otherwise bind the pin to the later copy, widening the slice into
239
+ // whatever follows it — the shape measured in this file's own header fixes).
240
+ //
241
+ // Each fixture is cut with a `phrase()` REGEX, never a literal `replace()`, and
242
+ // every one is asserted to have changed the document before it is believed.
243
+ // Measured, and the reason this is not a style preference: with literal
244
+ // substrings here, the end-anchor fixture silently no-ops the moment step 4 is
245
+ // rewrapped — the words are still there, just with a newline among them — so
246
+ // `dispatchPremise` does not throw, and the assertion fails claiming the BOUND
247
+ // is broken when only the fixture was. A no-op fixture that reports as a
248
+ // finding is worse than one that reds honestly.
249
+ const cut = (text, target, replacement, label) => {
250
+ const mutant = text.replace(phrase(target), replacement);
251
+ assert.notEqual(mutant, text, `the ${label} fixture no longer changes the document — update it, do not trust a result measured against it`);
252
+ return mutant;
253
+ };
254
+
255
+ test("the slice bound throws rather than widening when an anchor moves", () => {
256
+ const live = reviewAndFix();
257
+ assert.throws(
258
+ () => dispatchPremise(cut(live, STEP4_FROM, "Under the fleet, do not sit on this wait", "vanished start anchor")),
259
+ /slice anchor .* moved — re-anchor this test, never widen it/,
260
+ "a vanished start anchor widened the slice instead of throwing",
261
+ );
262
+ assert.throws(
263
+ () => dispatchPremise(`${live}\n\n${STEP4_FROM} — a restatement below.\n`),
264
+ /occurs 2 times/,
265
+ "a duplicated start anchor bound the pin to one copy instead of throwing",
266
+ );
267
+ assert.throws(
268
+ () => dispatchPremise(cut(live, "so push, then report to the controller a", "so push and then report a", "moved end anchor")),
269
+ /slice end anchor .* moved — re-anchor this test, never widen it/,
270
+ "a moved end anchor ran the slice past step 4 instead of throwing",
271
+ );
272
+ assert.throws(
273
+ () =>
274
+ dispatchPremise(
275
+ cut(
276
+ live,
277
+ STEP4_FROM,
278
+ `${STEP4_FROM} — so push, then report to the controller a decoy, restated further on`,
279
+ "duplicated end anchor onto step 4's own line",
280
+ ),
281
+ ),
282
+ /occurs 2 times/,
283
+ "a duplicated end anchor on step 4's own line bound the pin to one copy instead of throwing",
284
+ );
285
+ // The scenario a bare exactly-once count over the rest of the document
286
+ // would miss: step 4's real closing instruction reworded away, with the
287
+ // only remaining match sitting on a LATER line (step 5's). A count over
288
+ // the rest of the document sees exactly 1 hit and lets it through,
289
+ // silently binding the slice to the decoy and widening it into step 5.
290
+ // Bounding the search to step 4's own item excludes that decoy from the
291
+ // count entirely, so this still throws rather than silently widening — with
292
+ // the past-the-bound message, since the decoy is a copy of the end anchor
293
+ // sitting beyond the bound. Both mutations go through `cut()`, never a
294
+ // literal `.replace()`: a literal target here breaks the same way the
295
+ // header already warns for step 4, and the same mechanism applies here to
296
+ // step 5.
297
+ const decoyDoc = cut(
298
+ cut(live, "so push, then report to the controller a", "so push and then report a", "moved end anchor"),
299
+ "File each deferred finding",
300
+ "so push, then report to the controller a decoy on step 5's own line. File each deferred finding",
301
+ "later-line decoy",
302
+ );
303
+ const decoyAt = decoyDoc.indexOf("so push, then report to the controller a decoy");
304
+ const decoyLineNo = decoyDoc.slice(0, decoyDoc.lastIndexOf("\n", decoyAt) + 1).split("\n").length;
305
+ assert.throws(
306
+ () => dispatchPremise(decoyDoc),
307
+ new RegExp(
308
+ `slice end anchor .* lies past the end bound, which first matched at line ${decoyLineNo} \\("5\\. so push, then report to the controller a decoy`,
309
+ ),
310
+ "a reworded end anchor with a same-text decoy on a LATER line silently widened the slice instead of throwing",
311
+ );
312
+ });
@@ -0,0 +1,106 @@
1
+ // #2083. A finisher halt had no record rule and no resolution rule, so every
2
+ // halt parked its PR until a human read the report. The ruling: a halt is its
3
+ // own outcome (`finisher-pr-M=halted:<cause>`), it escalates on the PR itself
4
+ // (cockpit flag + `gh pr comment`, no label), and each cause has one
5
+ // resolution — two automatic, every other one escalated.
6
+ //
7
+ // Each pin is sliced to the one table row, sentence or bullet carrying its
8
+ // claim, never the whole section: the causes' names recur all over it, so a
9
+ // section-wide match would stay green with a resolution swapped between rows.
10
+ // The cause vocabulary itself is read from ledger-grammar.mjs, the one parser
11
+ // that accepts or refuses a settle — the prose and the grammar naming
12
+ // different causes is exactly a halt the ledger refuses to record.
13
+
14
+ import { test } from "node:test";
15
+ import assert from "node:assert/strict";
16
+ import { readFileSync } from "node:fs";
17
+ import { join } from "node:path";
18
+ import { between, paragraph, phrase, sentences } from "./prose-pin.mjs";
19
+ import { HALT_CAUSES } from "./ledger-grammar.mjs";
20
+
21
+ const RUN_TEAM = readFileSync(join(import.meta.dirname, "..", "skills", "run-team", "SKILL.md"), "utf8");
22
+ const flat = (s) => s.replace(/\s+/g, " ");
23
+
24
+ const RESOLVING = "**Resolving a finisher halt.**";
25
+ const resolutionRows = () => {
26
+ const table = between(RUN_TEAM, "| Cause | Resolution |", "\n\n", "halt resolution table");
27
+ return table.split("\n").filter((l) => l.startsWith("| `"));
28
+ };
29
+ // A row's first-cell backticked causes, in order — shared by rowFor's
30
+ // lookup and the coverage test below so the two cannot read the table's
31
+ // cells differently.
32
+ const causesIn = (row) => [...row.split("|")[1].matchAll(/`([^`]+)`/g)].map((m) => m[1]);
33
+ // The row whose first cell names exactly these causes.
34
+ const rowFor = (causes) => {
35
+ const rows = resolutionRows().filter((r) => causesIn(r).join(",") === causes.join(","));
36
+ assert.equal(rows.length, 1, `the resolution table has ${rows.length} rows for ${causes.join(", ")}`);
37
+ return rows[0].split("|")[2];
38
+ };
39
+
40
+ test("the resolution table resolves every cause the grammar accepts, each exactly once", () => {
41
+ // HALT_CAUSES is the exported, shared array parseToken's own grammar
42
+ // validates against — copy it before sorting, since sort mutates in
43
+ // place. resolutionRows().flatMap(causesIn) is a fresh array every call,
44
+ // needing no copy of its own.
45
+ assert.deepEqual(resolutionRows().flatMap(causesIn).sort(), [...HALT_CAUSES].sort());
46
+ });
47
+
48
+ test("live-editor resolves automatically: ask the member by name, wait, re-finish at the current head — past-pin if it moved", () => {
49
+ const r = rowFor(["live-editor"]);
50
+ assert.match(r, /^\s*\*\*Automatic\.\*\*/);
51
+ assert.match(r, /Ask the live member \*\*by name\*\* for its report, wait for it, then dispatch `finisher-pr-<M>-b` at the current head\./);
52
+ assert.match(r, /If the head moved in the meantime, resolve it as `past-pin` instead\./);
53
+ });
54
+
55
+ test("past-pin resolves automatically through the tick, as a re-review", () => {
56
+ const r = rowFor(["past-pin"]);
57
+ assert.match(r, /^\s*\*\*Automatic, through the tick: re-review\.\*\*/);
58
+ assert.match(r, /The tick prints `DISPATCH review PR#<M>` for a PR whose latest finisher is `halted:past-pin` and whose latest `reviewed=<head>` is not its current head/);
59
+ });
60
+
61
+ test("rebase escalates with the git cherry read, and has no automatic rule yet", () => {
62
+ const r = rowFor(["rebase"]);
63
+ assert.match(r, /^\s*\*\*Escalate\*\* — comment and flag, nothing more\./);
64
+ assert.match(r, /only `-` lines is a clean rebase, and a `\+` line is a conflict resolution that changed content or a commit past the pin/);
65
+ assert.match(r, /`git cherry <pin> HEAD origin\/main`/);
66
+ assert.match(r, /No automatic rule until a live halt shows the case recurring\./);
67
+ assert.doesNotMatch(r, /Automatic\./);
68
+ });
69
+
70
+ test("unreadable, missing, absent and other escalate with no automatic retry", () => {
71
+ const r = rowFor(["unreadable", "missing", "absent", "other"]);
72
+ assert.match(r, /^\s*\*\*Escalate\*\* — comment and flag, no automatic retry\.\s*$/);
73
+ });
74
+
75
+ test("every halt escalates on the PR itself — a comment that outlives the run — and never by label", () => {
76
+ const para = flat(paragraph(RUN_TEAM, RESOLVING, "halt resolution lead-in"));
77
+ const s = sentences(para);
78
+ const settle = s.find((x) => x.includes("Record it"));
79
+ assert.match(settle ?? "", /Record it `ledger\.mjs settle finisher-pr-<M>=halted:<cause>`/);
80
+ assert.match(para, /so it is never `failed`, which stays for a finisher that crashed or gave up\./);
81
+ assert.match(
82
+ para,
83
+ /Every halt escalates two ways: the cockpit flags the PR `halted:<cause>` at severity 4 off that token, and you post the finisher's halt report — cause and evidence — with `gh pr comment <M>`, so it outlives the run\./,
84
+ );
85
+ assert.match(para, /\*\*No label\*\*: the missing `ready-to-merge` already keeps the PR out of the merge queue\./);
86
+ });
87
+
88
+ test("the tick paragraph says why past-pin cannot use the dead-review path, and that a fix-applier push stays not due", () => {
89
+ const para = flat(paragraph(RUN_TEAM, "`past-pin` needs the tick because", "past-pin tick rationale"));
90
+ assert.match(para, /settling that review `=failed` re-queues nothing — that path covers only a review that died before returning\./);
91
+ assert.match(para, /A head that moved past `reviewed=` with no such halt — a fix-applier's push — stays not due: duty 2 verifies what it applied\./);
92
+ });
93
+
94
+ test("finisher duty 4 names the cause in the ledger's vocabulary, and a rebase report carries git cherry", () => {
95
+ const duty = flat(between(RUN_TEAM, "4. Report you the label", "\n\n", "finisher duty 4"));
96
+ const vocab = sentences(duty).find((x) => x.includes("vocabulary")) ?? "";
97
+ for (const c of HALT_CAUSES) assert.match(vocab, new RegExp(`\`${c}\``), `duty 4 no longer names \`${c}\``);
98
+ assert.match(vocab, /`other` for every other halt/);
99
+ assert.match(duty, /A `rebase` halt's report carries the output of `git cherry <pin> HEAD origin\/main`, run in the worktree\./);
100
+ });
101
+
102
+ test("the settle grammar summary lists halted:<cause> with the grammar's own causes", () => {
103
+ const bulletText = flat(between(RUN_TEAM, "- **`ledger.mjs settle <member> <outcome>`**", "\n- **", "settle summary"));
104
+ assert.match(bulletText, phrase("`finisher-pr-M` = `labelled | failed | killed | halted:<cause>`"));
105
+ assert.match(bulletText, phrase(`\`<cause>\` one of \`${HALT_CAUSES.join(" | ")}\``));
106
+ });
@@ -0,0 +1,134 @@
1
+ // The finisher's member name is a convention two documents state and two
2
+ // modules read. Nothing pinned it: adding it to run-team's naming list moved no
3
+ // test, which is why the convention could be read by `classifyRole` while being
4
+ // written down nowhere (#326).
5
+ //
6
+ // The fix-applier's own presence in the same paragraph is pinned separately, in
7
+ // review-path-default.test.mjs by "the member-naming rule still names the
8
+ // fix-applier". These are not duplicates: that one guards one name against
9
+ // deletion, these guard the list against disagreeing with the module that
10
+ // reads it.
11
+ import { test } from "node:test";
12
+ import assert from "node:assert/strict";
13
+ import { readFileSync } from "node:fs";
14
+ import { join } from "node:path";
15
+ import { classifyRole } from "./compute-spend.mjs";
16
+ import { parseMemberName } from "./member-outcomes.mjs";
17
+ import { between } from "./prose-pin.mjs";
18
+
19
+ const REPO = join(import.meta.dirname, "..");
20
+ const read = (...p) => readFileSync(join(REPO, ...p), "utf8");
21
+
22
+ // Every slice is flattened before matching, so a rewrap of the same words is a
23
+ // no-op. A pin that reds on a reflow discriminates nothing — it only teaches the
24
+ // next editor to work around it.
25
+ const flat = (s) => s.replace(/\s+/g, " ");
26
+
27
+ // Read RAW, not flattened: the slice below ends at the blank line that closes
28
+ // the paragraph, and flattening collapses it away. Flattening happens after.
29
+ const SKILL = read("skills", "run-team", "SKILL.md");
30
+ const LIFECYCLE = read("skills", "run-team", "references", "member-lifecycle.md");
31
+ const SPEND = flat(read("scripts", "compute-spend.mjs"));
32
+
33
+ const MEMBER_NAMES = ["impl-<issue#>", "fix-pr-<pr#>", "review-pr-<pr#>", "finisher-pr-<pr#>", "merge-bot-<n>"];
34
+
35
+ // Sliced to the naming PARAGRAPH, never file-wide: run-team mentions the
36
+ // finisher in its narrative dozens of times, and any of those hits would
37
+ // satisfy a file-wide match, leaving this list free to lose the name with the
38
+ // pin green. The paragraph, not the sentence: ending the slice at the first "."
39
+ // truncates on any inner period — an abbreviation, or the
40
+ // references/member-lifecycle.md pointer this very paragraph already carries —
41
+ // which reds the pin and reports every name as removed while none was. A blank
42
+ // line outlives a rewrap the way a sentence boundary does not. `between` is the
43
+ // shared two-ended slicer the rest of this directory already uses, and it
44
+ // carries the "update this test" guard for either anchor moving.
45
+ const namingSentence = (doc, label) => flat(between(doc, "Names follow", "\n\n", label));
46
+
47
+ test("both member-naming lists name every member, the finisher included", () => {
48
+ // Both, not just the runbook's: SKILL.md's list ends by pointing at
49
+ // references/member-lifecycle.md, which carries the same list, so a reader who
50
+ // follows the pointer must not land on one that omits the finisher.
51
+ //
52
+ // Compared as a SET. List order carries no instruction, and a pin that fires
53
+ // on a reorder is one the next editor learns to work around. Every missing
54
+ // name is collected and reported at once — asserting inside the loop would let
55
+ // the first miss mask the rest, and the count of failures would read as the
56
+ // count of defects.
57
+ for (const [label, doc] of [["run-team/SKILL.md", SKILL], ["references/member-lifecycle.md", LIFECYCLE]]) {
58
+ const sentence = namingSentence(doc, label);
59
+ const missing = MEMBER_NAMES.filter((n) => !sentence.includes(`\`${n}\``));
60
+ assert.deepEqual(
61
+ missing,
62
+ [],
63
+ `${label}'s member-naming list no longer names ${missing.join(", ")} — a controller reading it names that member something else, and a misnamed member loses the Agent tool with no error`,
64
+ );
65
+ }
66
+ });
67
+
68
+ test("every name compute-spend calls stable-because-run-team-fixes-it is one run-team fixes", () => {
69
+ // The comment's claim is about run-team, so it is only true while run-team's
70
+ // own list carries every name the comment cites. Derived from the comment
71
+ // rather than restated: a name added to the comment alone — the exact half-fix
72
+ // #326 was deferred to avoid — reds here, and a restated list would not.
73
+ const m = /run-team fixes them \(([^)]*)\)/.exec(SPEND);
74
+ assert.ok(m, "compute-spend.mjs's 'run-team fixes them' comment moved — re-anchor this pin");
75
+ const cited = [...m[1].matchAll(/`([a-z-]+)-<n>`/g)].map((x) => x[1]);
76
+ assert.ok(cited.length > 0, `no member names parsed out of the comment's list: ${m[1]}`);
77
+ assert.ok(cited.includes("finisher-pr"), "the finisher is missing from the list the comment claims run-team fixes");
78
+ // The naming list, not the whole file — which is what the comment above says
79
+ // this checks. A name cited here reaches SKILL.md's narrative without ever
80
+ // being added to the list, and a file-wide haystack scores that as a hit.
81
+ const list = namingSentence(SKILL, "run-team/SKILL.md");
82
+ for (const role of cited) {
83
+ assert.match(
84
+ list,
85
+ new RegExp("`" + role + "-<(?:issue#|pr#|n)>`"),
86
+ `compute-spend.mjs claims run-team fixes \`${role}-<n>\`, but run-team's naming list never mentions it`,
87
+ );
88
+ }
89
+ });
90
+
91
+ test("classifyRole and parseMemberName accept the same finisher spellings", () => {
92
+ // The other half, and the half that fails silently. Documenting one canonical
93
+ // name must not narrow what either module accepts — and the two answer
94
+ // different questions, so a narrowing of one alone does not show up in the
95
+ // other's output. `classifyRole` decides the role the spend headline counts;
96
+ // `parseMemberName` decides which PR the name books, which is the join key
97
+ // into tier-outcomes.tsv. Narrow the parser alone and every member still
98
+ // classifies as a finisher, the headline stays right, and only the row
99
+ // linkage disappears — the failure that once cost 120 of 283 finisher members
100
+ // their join key. #969 pinned the classifier against all five of these and
101
+ // never imported the parser, so that narrowing passed the whole suite (#1072).
102
+ //
103
+ // All five member names below are in docs/metrics/member-outcomes.tsv verbatim,
104
+ // each booked to exactly the PR number its own name carries. The descriptions
105
+ // deliberately carry no finisher word — the name has to carry the match, or
106
+ // this passes for the wrong reason. The last is a retry suffix: the same
107
+ // member's second attempt, not a different name. It is the only one of the
108
+ // five that reds when the classifier anchors to a trailing number, and the
109
+ // only one that reds when the parser stops stripping that suffix.
110
+ //
111
+ // `merge-bot-<n>` is deliberately absent: its number is a per-run dispatch
112
+ // counter, never a PR, and the parser refusing to book it as a PR is correct
113
+ // disagreement, not drift. It is pinned where it belongs, in
114
+ // member-outcomes.test.mjs.
115
+ const NAMES = ["finisher-pr-945", "finish-pr-751", "finisher-933", "finish-315", "finisher-pr-958-b"];
116
+
117
+ // Compared as ONE table rather than asserted inside the loop: the first
118
+ // disagreement would otherwise mask the rest, and a failure that names one
119
+ // broken spelling when four broke reads as a smaller defect than it is.
120
+ const got = NAMES.map((name) => {
121
+ const { ticket, pr } = parseMemberName(name);
122
+ const role = classifyRole({ spawnDepth: 0, memberName: name, description: "Apply reviewer findings" });
123
+ return `${name}: role=${role} ticket=${JSON.stringify(ticket)} pr=${JSON.stringify(pr)}`;
124
+ });
125
+ // The expected PR is READ OUT OF the name, never restated beside it. "pr is
126
+ // non-empty" is satisfied by a parser that books some other row's number, and
127
+ // a restated column drifts into agreeing with whatever the parser now returns.
128
+ const want = NAMES.map((name) => `${name}: role=finisher ticket="" pr=${JSON.stringify(/(\d+)/.exec(name)[1])}`);
129
+ assert.deepEqual(
130
+ got,
131
+ want,
132
+ "classifyRole and parseMemberName no longer accept the same finisher spellings — a spelling only one of them still recognises either moves the spend headline for a run already recorded, or silently drops that member's join key into tier-outcomes.tsv",
133
+ );
134
+ });