@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,216 @@
1
+ // #528. Phase 3 is the only place in the loop that dispatches phase 2's tier
2
+ // guard, so whatever it says the gate is IS the gate. It used to state one of
3
+ // its own — "once three or more `class=routine` PRs have been ruled since the
4
+ // last check" — which failed twice over: it is a second threshold beside phase
5
+ // 2's, free to drift from it, and it keys on a set nothing on disk records. A
6
+ // grep for any last-check marker over `skills` and `docs` returned only that
7
+ // sentence itself, and `docs/metrics/tier-outcomes.tsv` has no check-state
8
+ // column, so no controller could evaluate it and no marker would survive a
9
+ // compaction.
10
+ //
11
+ // The same document already ruled against this shape one phase earlier: the
12
+ // phase-2 guard rejects concluding inside one run and fires on the accumulated
13
+ // file instead. This pins phase 3 to that same floor.
14
+ //
15
+ // WHERE THE GUARD RUNS (#1805, ADR 0005 as amended by ADR 0012). Its trigger
16
+ // was the pool-empty event — "Pool empty → phase 0 again" — until the slot
17
+ // loop retired both the pool and phase 0's re-entry. It now runs at every alt
18
+ // Pull, before the alternate tier is chosen: the one dispatch the floor can
19
+ // still change. Every pin below was moved with it, unchanged in what it bans.
20
+ //
21
+ // HOW THIS FILE WAS WRONG THE FIRST TIME (PR #1122 review, dimensions
22
+ // `correctness` and `tests`, both reproduced by refuters). It pinned the duty as
23
+ // four word-presence checks — /tier\s+guard/, /phase\s+2/, /floor/,
24
+ // /accumulated/ — and banned two literal wordings. Measured GREEN against that:
25
+ // a sentence NEGATING the duty ("Do NOT run phase 2's tier guard here, on the
26
+ // floor phase 2 defines over the accumulated `…tsv` or otherwise"); one
27
+ // rescoping the floor to the run in front of the controller ("over this run's
28
+ // rows only rather than the accumulated `…tsv`"); phase 2's floor restated here
29
+ // in a one-word paraphrase; an incremental key phrased "after the most recent
30
+ // check"; and the counts "at least four", "more than three", "six or more" and
31
+ // "3+". Every one of those is a fixture below now — but the lesson is the shape,
32
+ // not the list: a presence check is satisfied by the sentence that repudiates
33
+ // it, and a wording ban catches the wording it was written from and nothing
34
+ // adjacent to it.
35
+ //
36
+ // So the duty is pinned as one wrap-tolerant PHRASE, and the two defect classes
37
+ // are banned structurally — any count, not any comparator.
38
+ //
39
+ // THE PHRASE PIN IS DELIBERATELY TIGHT. Reflowing the paragraph stays green (the
40
+ // accept test at the bottom flattens every wrap in the bullet and proves it);
41
+ // rewording the sentence does not. That clause is #528's whole deliverable, so a
42
+ // reword is exactly the moment someone should read this file. Reworded on
43
+ // purpose → update the string in DUTY. Do not delete the pin to clear the red.
44
+ //
45
+ // THE CEILING: this proves phase 3 defers to phase 2's floor. It cannot prove
46
+ // the floor itself is the right one — that lives in phase 2 and #528 left it
47
+ // deliberately untouched.
48
+ import { test } from "node:test";
49
+ import assert from "node:assert/strict";
50
+ import { readFileSync } from "node:fs";
51
+ import { join } from "node:path";
52
+ import { between, phrase, sentences } from "./prose-pin.mjs";
53
+
54
+ const REPO = join(import.meta.dirname, "..");
55
+ const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
56
+
57
+ // Paragraph-tight, and bounded at both ends: widen this to the phase and the
58
+ // tier-guard prose living elsewhere in phase 3 satisfies the pins on its own.
59
+ // The start anchor is single-hit, so the slice cannot silently start elsewhere:
60
+ // grep -c -- '\*\*Tier guards under Pull\.\*\*' skills/run-team/SKILL.md → 1
61
+ const START = "**Tier guards under Pull.**";
62
+ const gate = (text = RUN_TEAM) =>
63
+ between(text, START, "**`--max-reviews <n>`", "run-team phase 3 tier guard under Pull");
64
+
65
+ // The duty as a phrase, not as the words it is built from. `phrase` puts `\s+`
66
+ // at every word gap, so a hard wrap landing anywhere inside it is fine, while
67
+ // any rewriting of the claim — negation, rescoping, restatement — is not.
68
+ const DUTY = phrase(
69
+ "Run phase 2's tier guard before choosing the alternate tier, on the floor phase 2 defines over the accumulated `docs/metrics/tier-outcomes.tsv` and on no gate of this Pull's own",
70
+ );
71
+ // DUTY pins the imperative with its leading capital, so a mid-sentence "…do not
72
+ // run phase 2's tier guard here" already fails it. This is the belt, for a
73
+ // negation that capitalises.
74
+ const NEGATED = /(?:\bnot|\bnever|n't)\s+run\b/i;
75
+
76
+ // A count of the step's own. Every threshold is a count, whatever comparator it
77
+ // wears — "at least three", "more than two", "six or more", "3+", "a further
78
+ // four" — so ban the numbers and not the wordings; enumerating comparators is
79
+ // what let four of those five through. Three spans in this bullet are counts of
80
+ // nothing and are removed before the check, and nothing else is exempt:
81
+ // `phase N` — how this step names the owner it defers to;
82
+ // a backticked span — a path or identifier (`tier-outcomes.tsv`, `run_date`);
83
+ // "the one that/which" — the pronoun, as in "drift from the one that governs".
84
+ // CEILING: a count written inside backticks is exempt with them, and a threshold
85
+ // stated with no number at all ("once a handful have queued") is not covered by
86
+ // this or by any regex over prose.
87
+ const countable = (text) =>
88
+ text
89
+ .replace(/`[^`]*`/g, " ")
90
+ .replace(/\bphase\s+\d+\b/gi, " ")
91
+ .replace(/\bthe one\s+(?=that\b|which\b)/gi, " ");
92
+ const OWN_COUNT = /\b(?:one|two|three|four|five|six|seven|eight|nine|ten|\d+)\b/i;
93
+
94
+ // A set nothing persists. The literal that shipped was "since the last check";
95
+ // the shapes measured green against that literal were "since it was last
96
+ // checked" (words between the halves) and "after the most recent check" (a
97
+ // different preposition and a different recency word).
98
+ // CEILING: this covers a since/after clause reaching a recency word, and a
99
+ // "not yet <verb>ed" set. A recency set named without either — "the rows this
100
+ // run appended" — is caught only when it displaces DUTY, which is where the
101
+ // review's own within-run mutant was caught.
102
+ //
103
+ // Read one sentence at a time, via `sentences()`, with a gap that tolerates a
104
+ // period — never a first-period `[^.]` window (#1983). The pin is NEGATIVE, so
105
+ // a window cut short is its silent direction: an "e.g." or a `SKILL.md` between
106
+ // "since" and "last" ended the old window before the recency word. The sentence
107
+ // is what bounds the gap, so a "since" in one sentence never pairs with a
108
+ // recency word in the next. RESIDUAL: sentences() still cuts short at a
109
+ // `.)`, `."`, a mid-sentence `?`, a capitalised "E.g." or an "etc." (silent
110
+ // here — none of those four is in this paragraph today), and still merges
111
+ // two real sentences across #1987's `**late**.[1]` and #1899's
112
+ // sentence-final lowercase "vs." (an over-fire here, also absent today).
113
+ // `.**` itself IS in this slice once (its own opening bold lead), but that
114
+ // boundary is a genuine sentence end, not one straddling the since/recency
115
+ // pair this pin reads.
116
+ const UNPERSISTED_SET =
117
+ /\b(?:since|after)\b[\s\S]{0,40}\b(?:last|previous|prior|earlier|latest|most\s+recent)\b|\bnot\s+yet\s+\w+ed\b/i;
118
+ const unpersisted = (slice) => sentences(slice).filter((s) => UNPERSISTED_SET.test(s));
119
+
120
+ // Every pin in one place, so a fixture can assert WHICH ones fire rather than
121
+ // that something somewhere went red — a pin that reddens on the wrong mutant has
122
+ // discriminated nothing.
123
+ const PINS = {
124
+ duty: (slice) => !DUTY.test(slice),
125
+ negation: (slice) => NEGATED.test(slice),
126
+ count: (slice) => OWN_COUNT.test(countable(slice)),
127
+ unpersisted: (slice) => unpersisted(slice).length > 0,
128
+ };
129
+ const firing = (slice) => Object.keys(PINS).filter((name) => PINS[name](slice));
130
+
131
+ test("every alt Pull runs phase 2's tier guard against phase 2's floor", () => {
132
+ const slice = gate();
133
+ // Positive control against a vacuous pin: a stale start anchor that matched an
134
+ // empty slice would pass every doesNotMatch below while asserting nothing.
135
+ assert.ok(slice.length > START.length, "the tier-guard slice is no longer than its anchor — the extractor is broken, not the docs");
136
+ assert.match(slice, DUTY, "the alt Pull no longer states, word for word, that it runs phase 2's tier guard on phase 2's accumulated floor and on no gate of its own — reworded on purpose? update DUTY. Do not delete it");
137
+ assert.doesNotMatch(slice, NEGATED, "the alt Pull now says NOT to run the guard it is the only step that dispatches");
138
+ });
139
+
140
+ test("the alt-Pull gate states no count of its own", () => {
141
+ // The drift direction: a second threshold here is a second definition, and
142
+ // nothing makes the two move together.
143
+ assert.doesNotMatch(countable(gate()), OWN_COUNT, "the alt-Pull gate has grown a count of its own beside phase 2's floor");
144
+ });
145
+
146
+ test("the alt-Pull gate keys on nothing that has to be remembered between runs", () => {
147
+ assert.deepEqual(unpersisted(gate()), [], "the alt-Pull gate names a set nothing on disk records");
148
+ });
149
+
150
+ // The refuse direction. Entry one is the sentence #528 actually removed; the
151
+ // rest are the shapes the PR #1122 review measured green against this file's
152
+ // first pins. Each mutation asserts it changed the document before it is scored,
153
+ // because a mutation that fails to apply is green in exactly the way a pin that
154
+ // does not bite is green — and this file's prose wraps, so every search here is
155
+ // a wrap-tolerant `phrase` rather than the line breaks it has today.
156
+ const append = (sentence) => (text) =>
157
+ text.replace(START, `${START} ${sentence}\n\n${START}`);
158
+ // Built with `phrase`, not written out with the wraps the file happens to have
159
+ // today: a fixture that hardcodes "\n" applies nothing the moment someone
160
+ // reflows the paragraph, and its own notEqual guard then reddens a reflow the
161
+ // accept test at the bottom promises is green.
162
+ const PREDICATE_TAIL = phrase("on the floor phase 2 defines over the accumulated `docs/metrics/tier-outcomes.tsv` and on no gate of this Pull's own");
163
+ const IMPERATIVE = phrase("Run phase 2's tier guard before choosing the alternate tier");
164
+
165
+ const mutants = [
166
+ ["the incremental gate #528 removed comes back", ["count", "unpersisted"],
167
+ append("→ run the guard once three or more `class=routine` PRs have been ruled since the last check.")],
168
+ ["phase 2's floor is restated here in a paraphrase", ["duty", "count"],
169
+ (text) => text.replace(PREDICATE_TAIL, "on the floor over the accumulated `docs/metrics/tier-outcomes.tsv`: it holds at least three `class=routine` PRs spanning two distinct `run_date`s")],
170
+ ["the duty is negated outright", ["duty", "negation"],
171
+ (text) => text.replace(IMPERATIVE, "Do NOT run phase 2's tier guard before choosing the alternate tier")],
172
+ ["the floor is rescoped to the run in front of the controller", ["duty"],
173
+ (text) => text.replace(PREDICATE_TAIL, "on the floor phase 2 defines over this run's rows only rather than the accumulated `docs/metrics/tier-outcomes.tsv` it was written for")],
174
+ ["an incremental key comes back in fresh wording", ["unpersisted"],
175
+ append("Re-run it only for rows appended after the most recent check.")],
176
+ ["a count no comparator list reaches", ["count"],
177
+ append("Run it once six or more `class=routine` PRs have been ruled, or 3+ in a day.")],
178
+ // #1983: a period in the gap ended the old `[^.]` window before the recency
179
+ // word, and both of these were green.
180
+ ["an incremental key comes back with an abbreviation in the gap", ["unpersisted"],
181
+ append("Re-run it only for rows appended after, e.g., the most recent check.")],
182
+ ["an incremental key comes back with a filename in the gap", ["unpersisted"],
183
+ append("Re-run it only for rows appended since SKILL.md was last edited.")],
184
+ ];
185
+
186
+ for (const [what, expected, mutate] of mutants) {
187
+ test(`the pins redden when ${what}`, () => {
188
+ const mutated = mutate(RUN_TEAM);
189
+ assert.notEqual(mutated, RUN_TEAM, `the "${what}" fixture no longer matches the paragraph and applied nothing — update the fixture, do not delete it`);
190
+ assert.deepEqual(firing(gate(mutated)), expected, `the "${what}" fixture did not fire exactly the pins it is here to exercise`);
191
+ });
192
+ }
193
+
194
+ test("a since/after in one sentence does not pair with the next sentence's recency word", () => {
195
+ // The accept half of #1983's widening: the gap tolerates a period now, so the
196
+ // SENTENCE is all that keeps the two halves apart. Benign, and red the moment
197
+ // the scan reads the raw slice instead of `sentences()`.
198
+ const mutated = append("It runs after each Pull's dispatch. The last word on the floor is phase 2's.")(RUN_TEAM);
199
+ assert.notEqual(mutated, RUN_TEAM, "the accept fixture no longer matches the paragraph — update it");
200
+ assert.deepEqual(firing(gate(mutated)), [], "a since/after paired with a recency word in the NEXT sentence");
201
+ });
202
+
203
+ test("reflowing the paragraph and editing it elsewhere stays green", () => {
204
+ // The accept direction. A pin that reddens on any edit to the section has
205
+ // discriminated nothing, and would be deleted by whoever next reflows this
206
+ // paragraph. `between` returns raw text, so every pin above must tolerate a
207
+ // line break landing anywhere in the prose it reads — this joins every wrap
208
+ // inside it at once — and `phase 1` must not read as a count.
209
+ const para = gate();
210
+ const benign = RUN_TEAM.replace(para, () =>
211
+ para
212
+ .replace(/([^\n])\n(?=[^\n])/g, "$1 ")
213
+ .replace("Nothing else in the loop owns it.", "Nothing else in the loop owns it. Re-enter phase 1 for each slot it opens."));
214
+ assert.notEqual(benign, RUN_TEAM, "the benign-edit fixture no longer matches the paragraph — update it");
215
+ assert.deepEqual(firing(gate(benign)), [], "a reflow plus an unrelated edit reddened a pin — the pins are over-tight, not the docs wrong");
216
+ });