@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,257 @@
1
+ // #1053. The phase-3 **Monitor: CI run completes** bullet stated one
2
+ // precondition — that the edge fires on the fix-applier's own push — and
3
+ // derived its whole guard from it: empty your outbox *to it*, a final report
4
+ // from *it* is not proof it stopped. Both presuppose a fix-applier exists.
5
+ //
6
+ // Measured against the artifacts, not the ticket body (`gh api
7
+ // repos/feigi/fleet-plugin/actions/runs/<id>`): every run the three PRs of
8
+ // one fleet run produced carried `event=pull_request`, and each PR's first run was
9
+ // created 3-4 seconds after `gh pr create` — so the implementer's own firing
10
+ // is first for every PR, arriving before any review has returned. A fourth
11
+ // firing on PR #1052 (`33306306230`, head `fa65476`) came from a fix-applier
12
+ // that had pushed and not yet reported. The stated guard catches neither: the
13
+ // first has no fix-applier to owe anything to, so the outbox is *vacuously*
14
+ // empty; the second owed nothing, so it is *genuinely* empty.
15
+ //
16
+ // The root cause is that the gate was phrased over WHO PUSHED rather than over
17
+ // WHAT MUST BE TRUE, and that phrasing appears at two sites — this bullet
18
+ // (where the controller acts) and the narrative finisher paragraph (where the
19
+ // same condition is restated at length). Correcting one leaves the other
20
+ // reachable, so both are pinned here.
21
+ //
22
+ // The ACCEPT side is the half a new gate breaks: "the fix-applier has
23
+ // reported" must not hold a PR that never got one. Two such PRs exist — the
24
+ // **A review result lands** bullet's nothing-survived case, and the sibling
25
+ // **A fix-applier reports `no-op`** bullet, whose head's CI edge has already
26
+ // fired and will never fire again. Both are pinned as input the gate must
27
+ // accept.
28
+ //
29
+ // THE CEILING: these are prose pins. They prove the corrected premise and the
30
+ // two-condition gate are stated where the controller reads them; they cannot
31
+ // prove a controller obeys them, and nothing here calls `gh`.
32
+ import { test } from "node:test";
33
+ import assert from "node:assert/strict";
34
+ import { readFileSync } from "node:fs";
35
+ import { join } from "node:path";
36
+ import { between, phrase } from "./prose-pin.mjs";
37
+
38
+ const REPO = join(import.meta.dirname, "..");
39
+ const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
40
+ // The third site: the member-facing command that names the same gate. Its own
41
+ // suite doesn't guard it, so the falsified premise closing here while staying
42
+ // open there is exactly the loophole #1053 found.
43
+ const REVIEW_AND_FIX = readFileSync(join(REPO, "commands", "review-and-fix.md"), "utf8");
44
+ // Every negative pin below wants the WIDEST scope, both sites combined — a
45
+ // copy of the false premise surviving in either file is the whole defect back.
46
+ const ALL_PROSE = `${RUN_TEAM}\n${REVIEW_AND_FIX}`;
47
+
48
+ // One bullet each. The phase-3 loop is a flat list of `- **...**` items and
49
+ // `finisher`, `dispatch`, `push` and `report` all recur through every one of
50
+ // them, so a slice spanning two bullets is satisfied by either — which is
51
+ // exactly the false green the pair-coherence test below has to deny.
52
+ const ciEdge = () =>
53
+ between(RUN_TEAM, "- **Monitor: CI run completes**", "- **A fix-applier reports", "run-team CI-completes edge");
54
+
55
+ const noOpEdge = () =>
56
+ between(RUN_TEAM, "- **A fix-applier reports", '- **`ci-state.mjs --pr <N>` reads', "run-team no-op edge");
57
+
58
+ // The nothing-survived route to a finisher, which bypasses the fix-applier
59
+ // entirely. Bounded by the next bullet: unbounded it runs into the CI edge
60
+ // below and the accept-side assertion passes off the very text it is meant to
61
+ // be independent of.
62
+ const reviewSlotEdge = () =>
63
+ between(RUN_TEAM, "- **A review result lands**", "- **Monitor: `ready-to-merge` appears**", "run-team review-result wake");
64
+
65
+ // The second site stating the same gate, in the narrative rather than the
66
+ // loop. Its start anchor is the paragraph opener; its end anchor is the
67
+ // following paragraph, so the slice cannot widen into the duty list.
68
+ const narrativeGate = () =>
69
+ between(
70
+ RUN_TEAM,
71
+ "**The fix-applier pushes and exits",
72
+ "**An unanswered question from the member",
73
+ "run-team narrative finisher gate",
74
+ );
75
+
76
+ test("no sentence anywhere claims the edge fires on the pushing member, or that green alone licenses a dispatch", () => {
77
+ // Deliberately file-wide across both sites naming this gate (SKILL.md's
78
+ // loop bullet and review-and-fix.md step 4) — the mirror image of every
79
+ // positive pin here: a negative wants the WIDEST scope, because a copy of
80
+ // the false premise surviving just outside a narrow slice, or in the other
81
+ // file entirely, is the whole defect back again.
82
+ //
83
+ // Wording-specific, not claim-specific: these patterns catch the
84
+ // demonstrated paraphrases (`a fix-applier` as well as `the fix-applier`,
85
+ // `only once ... has pushed` as well as `fires on`, and the gate's inverse
86
+ // — "green alone" licensing a dispatch, or the review condition read as a
87
+ // formality) but remain matches over phrasing rather than a semantic
88
+ // check: a restatement outside these alternations could still slip past.
89
+ assert.doesNotMatch(
90
+ ALL_PROSE,
91
+ /edge\s+fires\s+(?:on|only\s+(?:when|once))\s+(?:the|a)\s+fix-applier/,
92
+ "the falsified premise is back: the edge fires on every CI run the PR produces, and the implementer's own firing is first for every PR",
93
+ );
94
+ assert.doesNotMatch(
95
+ ALL_PROSE,
96
+ /green\s+alone\s+(?:is\s+(?:enough|sufficient)|suffices|licens\w*\s+a\s+dispatch)/i,
97
+ "the gate's inverse is back: green alone licensing a dispatch",
98
+ );
99
+ assert.doesNotMatch(
100
+ ALL_PROSE,
101
+ /review\s+return(?:ed|ing|s)?\s+is\s+(?:a\s+)?formality/i,
102
+ "the gate's inverse is back: the review-returned condition demoted to a formality rather than a condition",
103
+ );
104
+ });
105
+
106
+ test("the premise names every firing, with the implementer's stated as the ordinary first one", () => {
107
+ const s = ciEdge();
108
+ assert.match(
109
+ s,
110
+ phrase("This edge fires for every CI run the PR produces, and the implementer's own firing comes first for every PR"),
111
+ "the edge's premise no longer covers the implementer's push, which is the firing every PR produces first",
112
+ );
113
+ // The mechanism, or the corrected premise reads as an assertion to take on
114
+ // trust and the next editor narrows it back to the fix-applier.
115
+ assert.match(s, phrase("`ci.yml` triggers on `pull_request`"));
116
+ // The consequence is what makes it a defect rather than a detail.
117
+ assert.match(
118
+ s,
119
+ phrase("no review has run at all when it arrives"),
120
+ "the bullet no longer says what is true at the first firing — that nothing has reviewed the PR",
121
+ );
122
+ });
123
+
124
+ test("the finisher gate names both conditions and distinguishes pushed from reported", () => {
125
+ const s = ciEdge();
126
+ assert.match(
127
+ s,
128
+ phrase("dispatch a finisher only once the PR's review has returned AND its fix-applier, if one was dispatched, has sent its report"),
129
+ "the finisher gate no longer names both conditions — green alone is back to being sufficient",
130
+ );
131
+ // The mid-work firing is the shape an empty outbox cannot see, and a gate
132
+ // saying only "the fix-applier has finished" reads as satisfied by a push.
133
+ assert.match(
134
+ s,
135
+ phrase("pushed is not reported"),
136
+ "the gate no longer separates a member that pushed from one that reported — the mid-work SHA passes again",
137
+ );
138
+ assert.match(s, phrase("mid-work on a SHA the member may still move"));
139
+ // Both failure shapes, and WHY the outbox is blind to each: without them the
140
+ // two-condition gate reads as a belt-and-braces restatement of the outbox
141
+ // rule and gets cut as duplication.
142
+ assert.match(s, phrase("vacuously"));
143
+ assert.match(s, phrase("genuinely"));
144
+ });
145
+
146
+ test("the first actionable clause in the loop bullet is already conditioned, not an unconditional dispatch", () => {
147
+ const s = ciEdge();
148
+ assert.match(
149
+ s,
150
+ phrase("a finisher CANDIDATE (gated below)"),
151
+ "the arrow clause is back to an unconditional dispatch instruction, so a top-to-bottom reader hits it before reaching the two-condition gate 9 lines later",
152
+ );
153
+ const candidateIndex = s.indexOf("a finisher CANDIDATE");
154
+ const gateIndex = s.indexOf("Green is therefore not the gate");
155
+ assert.ok(candidateIndex >= 0, "the conditioned arrow clause is missing");
156
+ assert.ok(gateIndex >= 0, "the corrective gate sentence is missing");
157
+ assert.ok(
158
+ candidateIndex < gateIndex,
159
+ "the arrow clause no longer precedes the gate sentence it defers to, so the deferral reads backwards",
160
+ );
161
+ });
162
+
163
+ test("the outbox rule survives, as the last test rather than the only one", () => {
164
+ const s = ciEdge();
165
+ assert.match(
166
+ s,
167
+ phrase("The outbox is the last test, not the only one, and it stands wherever a fix-applier exists"),
168
+ "the outbox rule was demoted or dropped — it is correct wherever a fix-applier exists and this ticket does not weaken it",
169
+ );
170
+ assert.match(
171
+ s,
172
+ phrase("never dispatch off it while you do"),
173
+ "the CI-completes edge lost the outstanding-ruling gate itself, not just its premise",
174
+ );
175
+ assert.match(s, phrase("including any ruling you have withdrawn or reversed"));
176
+ assert.match(s, phrase("a final report is not proof it stopped"));
177
+ });
178
+
179
+ test("the controller records the bound run identifier under a named field, not just that CI was green", () => {
180
+ const s = ciEdge();
181
+ assert.match(
182
+ s,
183
+ phrase('record it as `ci=<run-id>:<attempt>:<conclusion>`, not just "CI green"'),
184
+ "the bullet no longer tells the controller to record the bound run identifier under a named field",
185
+ );
186
+ assert.match(
187
+ s,
188
+ phrase("`row` **replaces the whole line** (above), so repeat `class=`, `ports=` and `→ PR#`"),
189
+ "the instruction no longer cross-references the replace-whole-line warning, so a controller following it will silently destroy the row's other tokens",
190
+ );
191
+ assert.match(
192
+ s,
193
+ phrase("That key cannot be reconstructed once the head is superseded"),
194
+ "the reason the whole key has to be recorded is gone, which is what stops it being cut as bookkeeping",
195
+ );
196
+ });
197
+
198
+ test("the pair stays coherent — a PR needing no fixes still reaches a finisher", () => {
199
+ // ACCEPT side, and the stranding hazard this ticket's own brief names: the
200
+ // head's CI edge has already fired, so a second event never arrives and this
201
+ // bullet is that PR's only remaining route.
202
+ assert.match(
203
+ ciEdge(),
204
+ phrase("A PR that needs nothing fixed reaches a finisher through the **fix-applier reports `no-op`** bullet below"),
205
+ "the CI edge no longer points at its sibling, so a clean PR reads as gated on an event that will never fire",
206
+ );
207
+ const sibling = noOpEdge();
208
+ assert.match(
209
+ sibling,
210
+ phrase("a `no-op` report satisfies the gate above by itself"),
211
+ "the sibling no longer says a no-op report meets the new gate — the clean PR is stranded behind a condition it has already met",
212
+ );
213
+ assert.match(
214
+ sibling,
215
+ phrase("dispatch the finisher **now**"),
216
+ "the sibling's dispatch-now instruction was weakened while the gate above was tightened",
217
+ );
218
+ // The gate must not reach the route that never had a fix-applier at all.
219
+ assert.match(
220
+ reviewSlotEdge(),
221
+ phrase("skip the fix-applier and dispatch the **finisher** directly"),
222
+ "the nothing-survived route to a finisher was gated on a fix-applier report it will never get",
223
+ );
224
+ });
225
+
226
+ test("the narrative dispatch site states the same gate as the bullet", () => {
227
+ // The bullet is where the controller acts, but this paragraph is where the
228
+ // dispatch conditions are stated at length — the site whose `check`-green
229
+ // trigger carried the same defect. Pinned so the two cannot drift apart,
230
+ // which is how one gets corrected and the other keeps licensing the
231
+ // unreviewed dispatch.
232
+ const s = narrativeGate();
233
+ assert.match(
234
+ s,
235
+ phrase("once the PR's review has returned and its fix-applier, if one was dispatched, has sent its report"),
236
+ "the narrative finisher dispatch is back to `check`-green alone, contradicting the corrected bullet",
237
+ );
238
+ // Without this, the OUTBOX sentence below reads as denying that the member's
239
+ // report is part of the gate at all — the reading the corrected bullet
240
+ // contradicts.
241
+ assert.match(
242
+ s,
243
+ phrase("That is the test of THIS condition only"),
244
+ "the outbox test is unscoped again, so it reads as ruling the member's report out of the gate",
245
+ );
246
+ assert.match(s, /Never dispatch\s*\n?one while you still owe the fix-applier a ruling/);
247
+ });
248
+
249
+ test("the CI-edge slice is one bullet — a drifted end anchor would satisfy the pair test from inside it", () => {
250
+ // The sibling assertions above are the ones a widened slice would answer, so
251
+ // this is not a cosmetic bound: `edge-keyed` occurs only in the sibling.
252
+ assert.doesNotMatch(
253
+ ciEdge(),
254
+ /edge-keyed/,
255
+ "ciEdge() has widened across the sibling bullet, so the pair-coherence test can pass without the sibling saying anything",
256
+ );
257
+ });
@@ -0,0 +1,113 @@
1
+ // Pins the two scope words #182's dedup dropped from the `ci-state.mjs`
2
+ // paragraph in both fleet command documents (#198). The reference is the
3
+ // comment beside the `missing` computation in ci-state.mjs, which carries both:
4
+ // force-push as the cause of the cancelled run whose finished jobs keep their
5
+ // conclusions, and "reads as pending" scoped to a checks summary — the
6
+ // aggregating view — rather than to ci-state.mjs itself. On an absent job
7
+ // ci-state.mjs pushes a reason naming the absent jobs — read out of ci-state.mjs
8
+ // below rather than restated here — and a non-empty `reasons` is verdict
9
+ // `not-green`, exit 1.
10
+ //
11
+ // THE CEILING: a sentence added beside an intact span that negates it stays
12
+ // green. And these do not run ci-state.mjs — ci-state.test.mjs owns its
13
+ // behavior.
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 { paragraph, phrase, unemphasized } from "./prose-pin.mjs";
19
+
20
+ const REPO = join(import.meta.dirname, "..");
21
+ const REVIEW_AND_FIX = readFileSync(join(REPO, "commands", "review-and-fix.md"), "utf8");
22
+ const RUN_MERGE_BOT = readFileSync(join(REPO, "commands", "run-merge-bot.md"), "utf8");
23
+
24
+ // The reason string belongs to ci-state.mjs, so read it from ci-state.mjs: renaming
25
+ // it there reddens these pins too, instead of leaving both documents quoting a
26
+ // string the source no longer emits. Captures the template's literal head only —
27
+ // everything before `${missing.join(...)}`, which no document can contain.
28
+ const CI_STATE = readFileSync(join(import.meta.dirname, "ci-state.mjs"), "utf8");
29
+ const ABSENT_REASON = (CI_STATE.match(/reasons\.push\(`([^`$]+)\$\{missing\.join/) ?? [])[1];
30
+
31
+ // Each claim is ONE contiguous span (prose-pin.mjs's convention), because
32
+ // keywords bound only by the slice were not enough: with the `pending`
33
+ // sentence gutted and its phrases restated as a second sentence in the same
34
+ // paragraph, meaning inverted, three independent checks (two regexes and a
35
+ // substring match) stayed green (#491,
36
+ // measured — both documents). The slice still does its own half: it bounds
37
+ // WHERE the span may be found. Both documents discuss `pending`, cancelled runs
38
+ // and force-pushes in neighbouring paragraphs, so each slice stops at the end
39
+ // of its own PARAGRAPH, not at the next section marker: without that bound a
40
+ // gutted sentence stays pinned by a fresh paragraph inserted before the marker
41
+ // (measured — both documents, suite green).
42
+ //
43
+ // The shared bound, not a local copy of it (#1372). What it closes that a local
44
+ // copy could not: a blank line carrying whitespace, which a literal `\n\n`
45
+ // search runs straight past into the next paragraph, and an anchor occurring
46
+ // more than once, which binds the pin to whichever copy of the anchored block
47
+ // comes first. What it does NOT close is a blank line deleted outright — the
48
+ // paragraphs then merge and the slice takes both, a hole that predates this
49
+ // bound and is open still (#1377).
50
+ //
51
+ // The local copy this replaced took a SECOND bound, the opening of the next
52
+ // paragraph, and used the blank line only as a tightener. In both documents the
53
+ // blank line already falls where that opening begins, so the migrated slices are
54
+ // byte-identical to what the local copy returned. But the local copy also
55
+ // ASSERTED that opening was reachable, and that assert is the one thing that
56
+ // sees the merge — so it is kept, as its own check rather than as a bound.
57
+ const reviewAndFix = () =>
58
+ paragraph(REVIEW_AND_FIX, "Its job-presence check is what catches the case above", "review-and-fix job-presence sentence");
59
+
60
+ const runMergeBot = () =>
61
+ paragraph(RUN_MERGE_BOT, "That presence requirement is what catches the case above", "run-merge-bot presence-requirement sentence");
62
+
63
+ // The blank line each slice stops at is a bound only while it is there: delete
64
+ // it and the following paragraph merges into the slice, where a copy of the
65
+ // gutted clause satisfies every assertion in this file (measured — either
66
+ // document, whole suite green without this check). `paragraph` cannot tell a
67
+ // merged paragraph from a genuine one, so the opening of the next paragraph is
68
+ // asserted here, with the blank line that separates it included in the literal.
69
+ const NEXT_PARAGRAPH = [
70
+ ["review-and-fix", REVIEW_AND_FIX, "\n\n**A repo with no workflow files"],
71
+ ["run-merge-bot", RUN_MERGE_BOT, "\n\n **Why twice: a conclusion can invert under a fixed run id.**"],
72
+ ];
73
+
74
+ test("each pinned paragraph is still followed by a blank line and the paragraph that opened after it", () => {
75
+ for (const [label, doc, opening] of NEXT_PARAGRAPH) {
76
+ assert.ok(
77
+ doc.includes(opening),
78
+ `${label}: ${JSON.stringify(opening)} is gone. If the blank line went, the pinned slice now runs on into that paragraph and a gutted clause reads as pinned; if the paragraph itself moved or was reworded, re-anchor this check`,
79
+ );
80
+ }
81
+ });
82
+
83
+ // Both documents carry both claims, but each words the aftermath its own way,
84
+ // so the force-push span is per-document and the `pending` span is shared.
85
+ // Pinning either claim against one document only leaves the other free to lose
86
+ // it. Matched through `unemphasized()` so a `**` move stays green, and through
87
+ // `phrase()` so a reflow does.
88
+ const DOCS = [
89
+ ["review-and-fix", reviewAndFix, "a force-push cancels the run under you, its finished jobs keep the conclusions they already reached"],
90
+ ["run-merge-bot", runMergeBot, "a force-push cancels the run under you, its finished jobs go on reporting what they concluded"],
91
+ ];
92
+
93
+ test("both documents name the force-push that cancels the run whose finished jobs keep reporting", () => {
94
+ for (const [label, slice, span] of DOCS) {
95
+ assert.match(
96
+ unemphasized(slice()),
97
+ phrase(span),
98
+ `${label}: lost or reworded the span "${span}" — the claim that a force-push cancels the run and its finished jobs go on reporting. If the claim still stands in new words, re-pin this span deliberately`,
99
+ );
100
+ }
101
+ });
102
+
103
+ test("both documents scope `pending` to the aggregating view, never to ci-state.mjs", () => {
104
+ assert.ok(ABSENT_REASON, "ci-state.mjs no longer pushes a reason built from `missing` — update this test");
105
+ const span = `reads as \`pending\` in an aggregating checks summary, never here: \`ci-state.mjs\` names it in the reason \`${ABSENT_REASON}…\` and refuses green`;
106
+ for (const [label, slice] of DOCS) {
107
+ assert.match(
108
+ unemphasized(slice()),
109
+ phrase(span),
110
+ `${label}: lost or reworded the span "${span}" — the claim that \`pending\` belongs to an aggregating checks summary while ci-state.mjs names the absent job in its actual reason string and withholds green. If the claim still stands in new words, re-pin this span deliberately`,
111
+ );
112
+ }
113
+ });