@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,219 @@
1
+ // #1045, the residue of #503. The guidance a controller reads to judge whether
2
+ // a member has died offered the transcript as the evidence, and the transcript
3
+ // cannot answer: a member wedged on a blocked tool call emits the dead
4
+ // member's whole signature — record counts unchanged from one poll to the
5
+ // next. Settled against `origin/main` before this landed:
6
+ //
7
+ // git show origin/main:plugin/skills/run-team/SKILL.md \
8
+ // | grep -ciE 'mtime|blocked tool call|frozen transcript' -> 0
9
+ //
10
+ // #503's own "Also worth pinning" item names the discriminator and the
11
+ // measurement behind it: its refuter sat forever on
12
+ // `until grep -q "^# fail" mut_a.txt` while `node --test` wrote the `ℹ`
13
+ // prefix, "record counts were unchanged across two polls while `pin.log` /
14
+ // `mut2.txt` / `base.log` all carried fresh mtimes". PR #1043 closed #503
15
+ // carrying only the refuter's observation rule, so this half survived nowhere
16
+ // but the tracker.
17
+ //
18
+ // WHERE IT GOES, and that is half the ticket. The clause sits in `## Failure
19
+ // handling`, between the table row that acts on a dead member and the
20
+ // Settle/liveness pair that says how to ask each harness — not in Phase 3's
21
+ // narrative, which is about reacting to artifacts rather than judging death.
22
+ // The killed row itself carries the gate in one clause, because a controller
23
+ // scanning the table acts off the row.
24
+ //
25
+ // THE SPAN IS ONE JOIN, not four assertions. The instruction runs from "does
26
+ // not establish" through the two verdicts, the carve-out, and the measurement
27
+ // that produced it, and a `\s+`-joined span has nowhere for a splice to land;
28
+ // split into separate matches, a sentence reinstating a transcript-only
29
+ // verdict fits between any two of them and every match stays green. The
30
+ // why-prose after it — the filenames, the cost asymmetry, the symmetry with
31
+ // #1043's own rule — is deliberately NOT pinned, so it stays rewordable.
32
+ //
33
+ // THE CEILING. A deliberate reword of the instruction reds this, and the fix
34
+ // is to re-anchor the phrase here, never to drop a half. A rewrap is a no-op
35
+ // by construction (`phrase()` joins on `\s+`). An emphasis move inside the
36
+ // span reds it too: the `**` markers around the verdict pair are matched
37
+ // literally, because moving them moves which half a reader sees as the rule.
38
+ import { test } from "node:test";
39
+ import assert from "node:assert/strict";
40
+ import { readFileSync } from "node:fs";
41
+ import { join } from "node:path";
42
+ import { between, paragraph, phrase } from "./prose-pin.mjs";
43
+
44
+ const SKILL = "skills/run-team/SKILL.md";
45
+ const read = () => readFileSync(join(import.meta.dirname, "..", ...SKILL.split("/")), "utf8");
46
+
47
+ // The paragraph carrying the rule, and no more of the file than that — the
48
+ // shared bound, which also asserts the anchor occurs exactly once. This
49
+ // document says "transcript", "scratch" and "mtime" in several other places
50
+ // (`board.mjs`'s ranking is discussed nowhere near here, but the dispatch
51
+ // prompts' own scratch-partition rule is), so an unbounded match is
52
+ // satisfiable from outside the clause it guards.
53
+ const ANCHOR = "**A frozen transcript does not establish that a member is dead";
54
+ const clause = () => paragraph(read(), ANCHOR, `${SKILL}'s stalled-member liveness clause`);
55
+
56
+ // One span: the epistemic rule, the discriminator, BOTH verdicts, the
57
+ // carve-out that keeps the second verdict from licensing a false kill, and the
58
+ // #503 measurement. #1150 made the read RECURSIVE — files anywhere under the
59
+ // assigned directory, with the command that reads them that way — because a
60
+ // member waiting on a child it dispatched writes nothing itself while the
61
+ // child writes below it, so a direct-children-only read shows that live parent
62
+ // the dead signature.
63
+ const INSTRUCTION = `A frozen transcript does not establish that a member is dead — the
64
+ discriminator is its scratch dir.** A member wedged on a blocked tool call
65
+ emits the whole signature of a dead one: record counts unchanged from one poll
66
+ of its transcript to the next. So read the mtimes of the files anywhere under
67
+ the scratch directory its own dispatch prompt assigned it, subdirectories
68
+ included — \`<scratch>/impl-<N>/\` for an implementer, that member's own
69
+ run-scoped subdirectory under \`<scratch>/pr<N>/\` on the review side, never
70
+ the bare \`pr<N>/\` tree those siblings share — since a member waiting on a
71
+ child it dispatched writes
72
+ nothing itself while that child writes below it. Read them at two observations
73
+ a poll apart — \`touch\` a marker file outside that directory at the first, and
74
+ \`find <dir> -type f -newer <marker>\` at the second lists every file that
75
+ moved: **mtimes that moved between the two mean BLOCKED, a live member
76
+ still holding its claim and its worktree, so the killed row above does not
77
+ apply to it; mtimes unchanged at both are the dead signature.** Only the first
78
+ of those two verdicts is conclusive — a member wedged on a call that writes
79
+ nothing freezes its scratch dir too — so settle the dead one on the liveness
80
+ read below, never on the two listings alone. Measured on #503: a refuter
81
+ wedged forever on \`until grep -q\` for a marker \`node --test\` never writes, its
82
+ transcript's record counts unchanged across two polls while its own scratch
83
+ files carried fresh mtimes throughout — alive the entire time it read as dead.`;
84
+
85
+ test("the stalled-member guidance says a frozen transcript does not establish death, and names the mtime discriminator with both its verdicts", () => {
86
+ assert.match(
87
+ clause(),
88
+ phrase(INSTRUCTION),
89
+ `${SKILL}'s stalled-member clause no longer carries the whole instruction. One of these went, or a sentence was spliced between them: (1) a frozen transcript does not establish death; (2) the signature it shares with a blocked tool call; (3) the discriminator — the mtimes of the files anywhere under the member's own scratch directory, subdirectories included, read at TWO observations a poll apart with the command that reads them recursively; (4) moved mtimes mean BLOCKED, unchanged mtimes are the dead signature; (5) only the blocked verdict is conclusive, because a call that writes nothing freezes the scratch dir too; (6) the #503 measurement it was derived from. Without (3) and (4) the controller is back to judging death off the transcript, which is #503's own residue; a (3) that stops at the directory's direct children reads a member waiting on its own child as dead; without (5) the clause licenses killing a live member wedged on a network read. Re-anchor this span against the reworded paragraph rather than dropping a half.`,
90
+ );
91
+ });
92
+
93
+ // The mutation a presence pin cannot see, and the one this ticket names: the
94
+ // clause left intact with a contradiction appended BESIDE it — "a transcript
95
+ // frozen across three polls is enough", "where the scratch dir is empty, treat
96
+ // the member as dead". That contradiction does not have to land inside the
97
+ // clause's own paragraph to be a carve-out: it lands just as easily as a new
98
+ // paragraph immediately after the clause, tacked onto the paragraph
99
+ // immediately above it ("A red PR never silently becomes `ready-to-merge`."),
100
+ // or as a new row in the failure table below. A ban scoped to only the
101
+ // clause's own paragraph is blind to all three, so it scans the whole
102
+ // neighbourhood the clause sits in instead — see NEIGHBOURHOOD below — plus a
103
+ // second, narrower ban over the failure table for the row case.
104
+ //
105
+ // The ban is the paragraph's own subject vocabulary, over what is left once
106
+ // the pinned span is removed from that neighbourhood. A carve-out that
107
+ // reuses at least one of the things the rule is about — the transcript, the
108
+ // scratch dir, the mtimes, the record counts, or the two verdicts themselves
109
+ // — is caught outside the span. A carve-out phrased to avoid every word in
110
+ // this list is NOT caught: this is a ban on the paragraph's literal
111
+ // vocabulary, not a semantic detector that catches a carve-out at any
112
+ // wording — closing that fully would need no finite list. The unpinned
113
+ // why-prose is written to carry none of them: it talks about filenames,
114
+ // listings, cost and the fleet, and the "A red PR never..." / "Settle
115
+ // outcome..." sentences that bound the neighbourhood carry none of them
116
+ // either. `replace` is deliberately non-global — a SECOND copy of the
117
+ // instruction is itself drift, and it lands in the residue where the ban
118
+ // catches it.
119
+ //
120
+ // The strip is REQUIRED to find something first, and that is not
121
+ // belt-and-braces. Measured on this pin: with the instruction deleted or
122
+ // half-deleted, an unguarded `replace` removes nothing, the whole mutated
123
+ // neighbourhood becomes the residue, and this test reds telling the reader a
124
+ // carve-out was appended beside a clause that is in fact missing — the wrong
125
+ // repair, pointed at the wrong sentence. A probe that could not look says so
126
+ // instead and leaves the presence pin above to name the real defect. It never
127
+ // goes green on that case: a vacuous pass here is what would let a deletion
128
+ // and a carve-out land together with only one of them reported.
129
+ //
130
+ // Binding the neighbourhood to the surrounding prose (below) rather than to
131
+ // the clause's own anchor has a second effect, free of an extra assertion:
132
+ // if the whole clause paragraph is moved elsewhere in the file, INSTRUCTION
133
+ // no longer appears between the two fixed sentences NEIGHBOURHOOD is bounded
134
+ // by, and the `assert.ok(span, ...)` in the test below reds — this also
135
+ // catches the clause moving out of its place in `## Failure handling`, not
136
+ // only a carve-out landing beside it where it stays.
137
+ const SUBJECT_VOCABULARY = /\b(?:transcripts?|mtimes?|record\s+counts?|scratch|frozen|dead|blocked)\b/i;
138
+
139
+ // The region a carve-out beside the clause can land in: from the sentence
140
+ // immediately above the clause through to the paragraph immediately below
141
+ // it, not just the clause's own paragraph. Bounded at both ends for
142
+ // `between`'s own reason (prose-pin.mjs) — an unbounded scan is satisfiable
143
+ // from outside the clause it guards.
144
+ const NEIGHBOURHOOD = () =>
145
+ between(
146
+ read(),
147
+ "A red PR never silently becomes",
148
+ "Settle outcome and liveness are different facts",
149
+ `${SKILL}'s stalled-member clause neighbourhood`,
150
+ );
151
+
152
+ test("nothing beside the clause carves an exception out of it", () => {
153
+ const whole = NEIGHBOURHOOD();
154
+ const span = whole.match(phrase(INSTRUCTION));
155
+ assert.ok(
156
+ span,
157
+ `${SKILL}'s stalled-member instruction does not match inside its neighbourhood (between "A red PR never silently becomes" and "Settle outcome and liveness are different facts") — read the presence pin above first: if it is green, the instruction is intact but the whole clause moved out of this neighbourhood, which this pin also treats as a failure.`,
158
+ );
159
+ const residue = whole.replace(span[0], "");
160
+ assert.doesNotMatch(
161
+ residue,
162
+ SUBJECT_VOCABULARY,
163
+ `${SKILL}'s stalled-member neighbourhood says something about the transcript, the scratch dir, the mtimes or the verdicts OUTSIDE the pinned instruction — in the paragraph above it, the paragraph below it, or appended to the clause's own paragraph. That is either a carve-out — the mutation this pin exists to catch, since the instruction itself survives it intact — or an unpinned restatement, which drifts from the pinned copy and becomes a contradiction. Fold the sentence into the span this file pins, or delete it.`,
164
+ );
165
+ });
166
+
167
+ // Cross-slice, same hazard the file's other table pins name: the table is the
168
+ // controller's index, and the killed row is where it acts on a death it has
169
+ // concluded. A gate stated only two paragraphs below is a gate a row-scanner
170
+ // never reads.
171
+ //
172
+ // BOTH halves of the row in one span, for opposite reasons. Dropping the gate
173
+ // puts the row back to answering a frozen transcript. Dropping the response
174
+ // leaves the gate with nothing behind it — a controller that has confirmed a
175
+ // death and has no row authorizing the replacement, which is the direction
176
+ // this clause could wrongly REFUSE in, and the one a suite that only ever
177
+ // feeds it a live member never tests.
178
+ const failureTable = () =>
179
+ between(read(), "## Failure handling", "A red PR never silently becomes", `${SKILL}'s failure table`);
180
+
181
+ test("the killed row gates on confirming death, not on a frozen transcript", () => {
182
+ assert.match(
183
+ failureTable(),
184
+ phrase("| Member **killed** (spend limit, API error, crash) | Confirm it is dead first — a frozen transcript does not establish that; see below — then new member, new name, prompt carries inherited state |"),
185
+ `${SKILL}'s killed row lost a half. The GATE half — confirm it is dead first, a frozen transcript does not establish that — is what keeps the row from answering a frozen transcript, where the controller replaces a member it never established was gone, discarding work in flight and colliding with its own claim and worktree. The RESPONSE half — new member, new name, prompt carries inherited state — is what a CONFIRMED death must still reach; a gate with no response behind it strands the case this clause exists to let through.`,
186
+ );
187
+ });
188
+
189
+ // The row-shaped carve-out the neighbourhood ban above cannot see: a new
190
+ // table row naming the transcript lands above "A red PR never silently
191
+ // becomes", outside that ban's start bound, in the same table this file
192
+ // already slices via `failureTable()`. Narrower than SUBJECT_VOCABULARY on
193
+ // purpose — "blocked" is ordinary vocabulary elsewhere in this same table
194
+ // (the "Implementer blocked or ambiguous *mid-implementation*" row), so the
195
+ // full list would false-positive there; "transcript" is not used by any
196
+ // other row today (`git show origin/main:plugin/skills/run-team/SKILL.md |
197
+ // grep -c transcript` inside the table is 1, the killed row itself), so this
198
+ // narrower ban is satisfiable without also banning words the table already
199
+ // uses for unrelated failures.
200
+ const CARVEOUT_TABLE_VOCABULARY = /transcript/i;
201
+
202
+ test("nothing in the failure table beside the killed row's own gate mentions the transcript", () => {
203
+ const table = failureTable();
204
+ const killedRow = table.match(
205
+ phrase(
206
+ "| Member **killed** (spend limit, API error, crash) | Confirm it is dead first — a frozen transcript does not establish that; see below — then new member, new name, prompt carries inherited state |",
207
+ ),
208
+ );
209
+ assert.ok(
210
+ killedRow,
211
+ `${SKILL}'s killed row does not match — read the presence pin above, which names which half of the row went. Nothing here is a verdict on a carve-out row until that row is restored.`,
212
+ );
213
+ const residue = table.replace(killedRow[0], "");
214
+ assert.doesNotMatch(
215
+ residue,
216
+ CARVEOUT_TABLE_VOCABULARY,
217
+ `${SKILL}'s failure table mentions the transcript in a row OTHER than the killed row's own gate. A row claiming a frozen transcript settles death on its own is the carve-out this clause exists to prevent — fold it into the killed row's gate, or delete it.`,
218
+ );
219
+ });
@@ -0,0 +1,313 @@
1
+ // #1148. The git stash stack is a property of the REPOSITORY, not of a
2
+ // worktree or a session: every fleet worktree, the main checkout, and every
3
+ // concurrent member share the one `refs/stash`. A bare `git stash pop` takes
4
+ // whichever entry is on top regardless of which worktree pushed it — silently
5
+ // (rc 0) when the receiving tree is clean on the affected paths, which is
6
+ // exactly when a victim would assume it is safe, and loudly (rc 1) only when
7
+ // that tree is already dirty there. A bare `git stash` (push) does NOT reach
8
+ // into a sibling's tree — that half is unfounded, measured separately in the
9
+ // ticket's Agent Brief — so the hazard is entirely on the pop side.
10
+ //
11
+ // Before this ticket the prohibition lived only in the controller's own
12
+ // never-force-a-rebase guard (SKILL.md's "Never force a rebase to start", the
13
+ // `git stash` mention run-merge-bot-prose.test.mjs and no-undo-audit.test.mjs
14
+ // already pin) and in member-lifecycle.md's refill-recovery checklist. Neither
15
+ // reaches the members who actually reach for `git stash` in practice —
16
+ // implementers and fix-appliers isolating a mutation-testing pass — because
17
+ // neither is copied into a dispatch prompt. This file pins the two new
18
+ // paragraphs that close that gap: one in phase 2's implementer block, beside
19
+ // the commit-incrementally rule it extends, one in the Reviewers section's
20
+ // fix-applier block, beside the commit-before-you-mutate rule it extends.
21
+ //
22
+ // Measured against this tree before either paragraph existed (i.e. against
23
+ // `origin/main`): neither `skills/run-team/SKILL.md`'s phase-2 member prompt
24
+ // nor its fix-applier prompt mentioned `git stash` at all —
25
+ // `awk 'NR==849,NR==955' skills/run-team/SKILL.md | grep -i stash` and
26
+ // `awk 'NR==1483,NR==1642' skills/run-team/SKILL.md | grep -i stash` both hit
27
+ // nothing. No test in `*prose*.test.mjs` mentioned `WIP commit` either. This
28
+ // file's two anchors are unique file-wide (verified: each of
29
+ // "**Never `git stash` or `git stash pop` to shelve" and
30
+ // "**Never `git stash` or `git stash pop` here either" occurs exactly once),
31
+ // so each block is sliced directly with `between()`, without first narrowing
32
+ // through a parent section the way files whose anchor text repeats have to.
33
+ //
34
+ // SHAPE, matching this suite's convention (`dispatch-block-pins-prose.test.mjs`
35
+ // header): each block is its OWN slice, bounded by the neighbouring block's
36
+ // opening words on both ends, and a fact that lives in the JOIN between two
37
+ // clauses — the pop's silence on a clean tree paired with its refusal on a
38
+ // dirty one — is pinned as ONE contiguous span, never two independent
39
+ // presence checks that a swap of "clean" and "dirty" between the clauses
40
+ // could satisfy separately (`finisher-pin-race-prose.test.mjs`'s "exception
41
+ // clause splice" rule: N independent matches pin N facts, never the relation
42
+ // between them).
43
+ //
44
+ // MUTATION-VERIFIED both ways on an isolated scratch copy of this tree
45
+ // (method: `dispatch-block-pins-prose.test.mjs`'s own comment, and the
46
+ // project's own prose-pin discipline — copy, mutate, run, restore). All four
47
+ // mutations below were run against both the implementer AND the fix-applier
48
+ // block, independently, restoring the clean file between each:
49
+ // - Deleting either new paragraph outright (the whole `> **Never \`git
50
+ // stash\`...` through the sentence before the next block's opener) reds
51
+ // every test below that reads that block, via `between()`'s own "no
52
+ // longer contains" throw — 6 of this file's 12 tests (5 pins + the
53
+ // block's own rewrap check), 0 elsewhere in this file or in
54
+ // `dispatch-block-pins-prose.test.mjs` / `fix-applier-correction-rules-
55
+ // prose.test.mjs` (their anchors are untouched by this deletion).
56
+ // - Swapping the substitute back out for a bare stash mention — rewriting
57
+ // "take a WIP commit instead: `git commit -m wip`, then amend it or
58
+ // `git reset --soft HEAD^` once you have something real to commit." to
59
+ // "stash it instead: `git stash push -u -m wip`, then `git stash pop`
60
+ // once you are ready to make a real commit." (prohibition wording left
61
+ // intact, so the block's own `between()` anchor still resolves) — reds
62
+ // exactly 2 of 12: the mutated block's "names a WIP commit as the
63
+ // substitute" test and its own rewrap check. The other 10, including
64
+ // that same pair in the untouched block, stay green, because they pin
65
+ // the mechanism paragraph the substitution never touches. This is the
66
+ // correct discrimination: the substitute-naming test is the one whose
67
+ // whole job is catching this mutation, not a side effect of a looser one.
68
+ // - Swapping "clean"/"dirty" between the two halves of the pop-mechanism
69
+ // sentence (silent-when-dirty / refuses-when-clean, the inverted claim)
70
+ // also reds exactly 2 of 12 — the mutated block's single-span
71
+ // pop-mechanism test and its rewrap check — because the contiguous
72
+ // phrase no longer occurs verbatim; two independent presence checks on
73
+ // "clean" and "dirty" separately would NOT have caught this, since both
74
+ // words remain present somewhere in the slice.
75
+ // - The two `rewrapped …` tests below are the accept-side control: on the
76
+ // unmutated file both pass, proving the pins hold the words, not today's
77
+ // line breaks.
78
+ //
79
+ // THE CEILING these pins have: they are pins on text being PRESENT and
80
+ // adjacent. A sentence appended after a pinned span that carves an exception
81
+ // into it touches no pinned fragment and stays green.
82
+ //
83
+ // Both blocks this file pins are covered against that by #1002's whole-block
84
+ // golden fixtures in `dispatch-block-golden-prose.test.mjs` — the implementer's
85
+ // block as one of phase 2's, the fix-applier's inside the fix-applier prompt —
86
+ // so an appended carve-out reds there on the equality while staying invisible
87
+ // here. Measured: appending "A bare pop is fine when no sibling is running." to
88
+ // the implementer block left every pre-existing prose pin green, including all
89
+ // of this file's, and red the golden. The two are complementary — the golden
90
+ // says the block changed, and a red HERE says which of the two stash rules lost
91
+ // its WIP-commit substitute.
92
+ import { test } from "node:test";
93
+ import assert from "node:assert/strict";
94
+ import { readFileSync } from "node:fs";
95
+ import { join } from "node:path";
96
+ import { between, phrase } from "./prose-pin.mjs";
97
+
98
+ const REPO = join(import.meta.dirname, "..");
99
+ const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
100
+ // The implementer's copy lives in the implementer agent body since #1804 (spec
101
+ // 2026-09-24 § 2 Decision 2): the body is what each harness injects as the
102
+ // member's system prompt, and SKILL.md's phase 2 no longer re-pastes it. The
103
+ // fix-applier's copy is still a quote block in SKILL.md's Reviewers section.
104
+ const IMPLEMENTER_BODY = readFileSync(join(REPO, "agents", "fleet-implementer.agent.md"), "utf8").split("---").slice(2).join("---");
105
+
106
+ // `>` gutter and `**` emphasis stripped, whitespace collapsed — mirrors
107
+ // `dispatch-block-pins-prose.test.mjs`'s `flatten`, so a pin here survives the
108
+ // same rewrap/bold-move classes that file's does. Backticks are left alone:
109
+ // every pinned span below quotes real code (`` `git stash` ``, `` `refs/stash` ``)
110
+ // and no `**` occurs inside one of those spans (verified), so nothing here
111
+ // needs to learn about a backtick-wrapped `**`.
112
+ const flatten = (s) =>
113
+ s
114
+ .split("\n")
115
+ .map((l) => l.replace(/^\s*>?\s?/, ""))
116
+ .join(" ")
117
+ .replace(/\*\*/g, "")
118
+ .split(/\s+/)
119
+ .join(" ")
120
+ .trim();
121
+
122
+ // Bounded by the new rule's own opening words and the NEXT block's opening
123
+ // words — the same two-sided bound every block in `dispatch-block-pins-
124
+ // prose.test.mjs` uses, and for the same reason: an unbounded end lets the
125
+ // scratch-discipline block's own vocabulary ("scratch root", "sibling")
126
+ // satisfy an assertion with this block's real text gone.
127
+ const implementerStashBlock = () =>
128
+ flatten(
129
+ between(
130
+ IMPLEMENTER_BODY,
131
+ "**Never `git stash` or `git stash pop` to shelve",
132
+ "**Every scratch file",
133
+ "the implementer body's stash-prohibition block",
134
+ ),
135
+ );
136
+
137
+ const fixApplierStashBlock = () =>
138
+ flatten(
139
+ between(
140
+ RUN_TEAM,
141
+ "**Never `git stash` or `git stash pop` here either",
142
+ "**Report LAST",
143
+ "the fix-applier's stash-prohibition block",
144
+ ),
145
+ );
146
+
147
+ test("the implementer's stash rule forbids a bare stash/pop and names a WIP commit as the substitute", () => {
148
+ const b = implementerStashBlock();
149
+ assert.match(
150
+ b,
151
+ phrase(
152
+ "Never `git stash` or `git stash pop` to shelve your own progress — take a WIP commit instead: `git commit -m wip`, then amend it or `git reset --soft HEAD^` once you have something real to commit.",
153
+ ),
154
+ "the implementer block no longer forbids a bare stash/pop with the WIP-commit substitute bound to it",
155
+ );
156
+ });
157
+
158
+ test("the implementer's stash rule states the stack is repo-global, shared by every worktree and session", () => {
159
+ const b = implementerStashBlock();
160
+ assert.match(
161
+ b,
162
+ phrase(
163
+ "The stash stack is repo-global, not per-worktree or per-session — the same `refs/stash` is shared by every worktree, the main checkout, and every concurrent member.",
164
+ ),
165
+ "the implementer block no longer states the stash stack is repo-global and shared by every worktree/session",
166
+ );
167
+ });
168
+
169
+ // ONE contiguous span, not two presence checks — see the header's mutation
170
+ // note. Independent `clean` / `dirty` checks would both stay green under a
171
+ // swap of which state is silent and which refuses.
172
+ test("the implementer's stash rule binds the pop's silence on a clean tree to its refusal on a dirty one", () => {
173
+ const b = implementerStashBlock();
174
+ assert.match(
175
+ b,
176
+ phrase(
177
+ "A bare pop takes whichever entry is on top, from any worktree, and it is silent about it — rc 0, no error — exactly when the tree receiving it is clean on the affected paths, which is the moment you would assume it is safe; it refuses loudly only when that tree is already dirty on them.",
178
+ ),
179
+ "the implementer block no longer binds the pop's clean-tree silence to its dirty-tree refusal in one span",
180
+ );
181
+ });
182
+
183
+ test("the implementer's stash rule states a bare push does not reach into a sibling worktree", () => {
184
+ const b = implementerStashBlock();
185
+ assert.match(
186
+ b,
187
+ phrase(
188
+ "A bare `git stash` (push) does not reach into a sibling worktree's uncommitted work — that half is unfounded, it acts on your own tree only — so the hazard is entirely on the pop side",
189
+ ),
190
+ "the implementer block no longer states that a bare stash push does not reach a sibling's tree",
191
+ );
192
+ });
193
+
194
+ test("the implementer's stash rule says nothing partitions the stack, so the prohibition is the whole protection", () => {
195
+ const b = implementerStashBlock();
196
+ assert.match(
197
+ b,
198
+ phrase(
199
+ "Nothing partitions the stack the way the scratch root below is partitioned — one `refs/stash` per repository, with no per-member address for it — so this prohibition is the whole of the protection, not a stopgap standing in for one.",
200
+ ),
201
+ "the implementer block no longer says nothing partitions the stack or drops the whole-protection close",
202
+ );
203
+ });
204
+
205
+ test("the fix-applier's stash rule forbids a bare stash/pop and names a WIP commit as the substitute", () => {
206
+ const b = fixApplierStashBlock();
207
+ assert.match(
208
+ b,
209
+ phrase(
210
+ "Never `git stash` or `git stash pop` here either — a WIP commit is the substitute, not a second scratch mechanism: `git commit -m wip`, then restore or amend once you're back to real work.",
211
+ ),
212
+ "the fix-applier block no longer forbids a bare stash/pop with the WIP-commit substitute bound to it",
213
+ );
214
+ });
215
+
216
+ test("the fix-applier's stash rule states the stack is repo-global, shared by every worktree and session", () => {
217
+ const b = fixApplierStashBlock();
218
+ assert.match(
219
+ b,
220
+ phrase(
221
+ "The stash stack is repo-global too, not per-worktree or per-session — the same `refs/stash` every concurrent member and the main checkout share, not partitioned the way `<scratch>/pr<N>/mutate/` above is.",
222
+ ),
223
+ "the fix-applier block no longer states the stash stack is repo-global and shared by every worktree/session",
224
+ );
225
+ });
226
+
227
+ test("the fix-applier's stash rule binds the pop's silence on a clean tree to its refusal on a dirty one", () => {
228
+ const b = fixApplierStashBlock();
229
+ assert.match(
230
+ b,
231
+ phrase(
232
+ "A bare pop takes whichever entry is on top, from any worktree, silently — rc 0, no error — when the tree receiving it is clean on the affected paths, and refuses only when that tree is already dirty there.",
233
+ ),
234
+ "the fix-applier block no longer binds the pop's clean-tree silence to its dirty-tree refusal in one span",
235
+ );
236
+ });
237
+
238
+ test("the fix-applier's stash rule states a bare push does not reach into a sibling's tree", () => {
239
+ const b = fixApplierStashBlock();
240
+ assert.match(
241
+ b,
242
+ phrase(
243
+ "A bare `git stash` (push) does not reach into a sibling's tree, so that half is not the risk — the pop is.",
244
+ ),
245
+ "the fix-applier block no longer states that a bare stash push does not reach a sibling's tree",
246
+ );
247
+ });
248
+
249
+ test("the fix-applier's stash rule says nothing partitions the stack, so the prohibition is the whole protection", () => {
250
+ const b = fixApplierStashBlock();
251
+ assert.match(
252
+ b,
253
+ phrase("Nothing partitions the stack; this prohibition is the whole of the protection."),
254
+ "the fix-applier block no longer says nothing partitions the stack or drops the whole-protection close",
255
+ );
256
+ });
257
+
258
+ // ACCEPT side, mirroring `dispatch-block-pins-prose.test.mjs`'s own rewrap
259
+ // test: re-wrapping either paragraph at a column width nothing here assumes
260
+ // must not red a single assertion above. The fixture is DERIVED from the live
261
+ // block, never a quoted line, so a future reword of the surrounding prose is
262
+ // not what this test measures. Flattening `narrow` directly (rather than
263
+ // splicing it back into RUN_TEAM and re-locating it with `between()`) sidesteps
264
+ // a real bug the first draft of this helper hit: this block's own opening
265
+ // anchor is 9 words / ~50 characters, longer than the 45-character rewrap
266
+ // width, so a `between()` search for it against the SPLICED file broke across
267
+ // the very line break the rewrap introduced. `narrow` already IS the
268
+ // rewrapped block; there is nothing left to re-locate.
269
+ function assertSurvivesRewrap(source, startAnchor, endAnchor, what, assertions) {
270
+ const raw = between(source, startAnchor, endAnchor, what);
271
+ const body = raw.replace(/\n*>?\s*$/, "");
272
+ const words = body.replace(/\n>\s?/g, " ").split(/\s+/).filter(Boolean);
273
+ const lines = words.reduce((acc, w) => {
274
+ const last = acc[acc.length - 1];
275
+ if (last && `${last} ${w}`.length <= 45) acc[acc.length - 1] = `${last} ${w}`;
276
+ else acc.push(w);
277
+ return acc;
278
+ }, []);
279
+ const narrow = lines.join("\n> ");
280
+ assert.notEqual(narrow, raw, `${what}: the rewrap fixture no longer changes the block's wrapping — update it`);
281
+ const rewrapped = flatten(narrow);
282
+ for (const a of assertions) assert.match(rewrapped, a);
283
+ }
284
+
285
+ test("a rewrapped implementer stash block still matches every pin above — these pins refuse drift, not reflow", () => {
286
+ assertSurvivesRewrap(
287
+ IMPLEMENTER_BODY,
288
+ "**Never `git stash` or `git stash pop` to shelve",
289
+ "**Every scratch file",
290
+ "the implementer body's stash-prohibition block",
291
+ [
292
+ phrase("Never `git stash` or `git stash pop` to shelve your own progress — take a WIP commit instead"),
293
+ phrase("The stash stack is repo-global, not per-worktree or per-session"),
294
+ phrase("it refuses loudly only when that tree is already dirty on them"),
295
+ phrase("Nothing partitions the stack the way the scratch root below is partitioned"),
296
+ ],
297
+ );
298
+ });
299
+
300
+ test("a rewrapped fix-applier stash block still matches every pin above — these pins refuse drift, not reflow", () => {
301
+ assertSurvivesRewrap(
302
+ RUN_TEAM,
303
+ "**Never `git stash` or `git stash pop` here either",
304
+ "**Report LAST",
305
+ "the fix-applier's stash-prohibition block",
306
+ [
307
+ phrase("Never `git stash` or `git stash pop` here either — a WIP commit is the substitute"),
308
+ phrase("The stash stack is repo-global too, not per-worktree or per-session"),
309
+ phrase("refuses only when that tree is already dirty there"),
310
+ phrase("Nothing partitions the stack; this prohibition is the whole of the protection"),
311
+ ],
312
+ );
313
+ });
@@ -0,0 +1,44 @@
1
+ // Blank out a JS file's comments so a source-text assertion cannot be
2
+ // satisfied by a declaration or a paragraph a reader's eye skips.
3
+ //
4
+ // Both escapes were MEASURED green pre-cutover, on this repo's then-retired
5
+ // review workflow script, before this existed: the three diff schema fields
6
+ // wrapped in `/* */` (the schema drops
7
+ // them, `usableDiff` returns null forever, 12 pass / 0 fail), and the snapshot
8
+ // agent's `Report \`diffPath\`` paragraph deleted and re-inserted inside a
9
+ // block comment (same, 12 pass / 0 fail). A `^(?!\s*//)` anchor closes
10
+ // neither: the commented-out line starts with `/*`, and per-assertion anchors
11
+ // have to be remembered once per pin.
12
+ //
13
+ // It lives here rather than inline in one test file because remembering it is
14
+ // exactly what fails. `review-core-reads.test.mjs` carried a private copy;
15
+ // `review-core-testcmd.test.mjs` was then written against raw source and its
16
+ // schema-declaration pin was vacuous against a block-commented `testCmd:
17
+ // { type: "string" },` — 9 pass / 0 fail with the field genuinely dead under
18
+ // `additionalProperties: false` (#142 review, measured).
19
+ //
20
+ // Line-based on purpose. A regex stripper (`/\*[\s\S]*?\*\//`) would open a
21
+ // comment at `"node --test plugin/scripts/*.test.mjs"` — a glob inside a
22
+ // string literal — and swallow real code up to the next `*/`. Blank lines
23
+ // rather than deleted ones, so offsets stay line-aligned with the file.
24
+ //
25
+ // Known ceiling: whole-line comments only. A TRAILING `code; // note` keeps
26
+ // its comment text, and `//` inside a string literal (a URL, a glob) is left
27
+ // alone — which is the point, since blanking those would delete real code.
28
+ // Neither form can hide a declaration from a pin, which is what this is for.
29
+ export function stripComments(source) {
30
+ const out = [];
31
+ let inBlock = false;
32
+ for (const line of source.split("\n")) {
33
+ if (inBlock) {
34
+ if (line.includes("*/")) inBlock = false;
35
+ out.push("");
36
+ } else if (/^\s*\/\*/.test(line)) {
37
+ if (!line.includes("*/")) inBlock = true;
38
+ out.push("");
39
+ } else {
40
+ out.push(/^\s*\/\//.test(line) ? "" : line);
41
+ }
42
+ }
43
+ return out.join("\n");
44
+ }