@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,175 @@
1
+ // #814. Phase 0 step 4's staleness recipe named the commit that removed a
2
+ // string with `git log -S '<old string>' --oneline origin/main -- <file>` and
3
+ // then prescribed `git merge-base --is-ancestor <sha> origin/main` to "prove it
4
+ // is not a pre-rebase orphan". `git log <ref>` enumerates only commits
5
+ // reachable from `<ref>`, so that sha is an ancestor of `origin/main` BY
6
+ // CONSTRUCTION, and `--is-ancestor` is true again when the two are equal: the
7
+ // step could not answer no in the position it was written into, and a step that
8
+ // always passes reads as a check that was performed.
9
+ //
10
+ // Measured in this repository while the defect was live: the walk for the
11
+ // defect's own wording, `git log -S 'proves it is not a pre-rebase orphan'
12
+ // --format=%H -n1 origin/main -- plugin/skills/run-team/SKILL.md`, names
13
+ // `9c930a7`, and `git merge-base --is-ancestor 9c930a7 origin/main` exits 0;
14
+ // `git merge-base --is-ancestor origin/main origin/main` exits 0 as well. The
15
+ // check is not inert — on a commit that did NOT come from that walk it exits 1
16
+ // (measured on this branch's own tip, unreachable from `origin/main`) — so the
17
+ // defect is the position, never the check.
18
+ //
19
+ // WHY A PIN AT ALL, given the check's own redundancy is the finding: the
20
+ // vacuous wording shipped and survived the entire suite for the whole of its
21
+ // life, because nothing in `*.test.mjs` read this paragraph. The probe that
22
+ // carries the same reasoning in code (`staleness.mjs`'s call-site comment) is
23
+ // itself backed by a test that the citation walk is scoped to `origin/main`
24
+ // (`staleness.test.mjs`, #813) — the prose half had no equivalent. A revert of
25
+ // the fix is one sentence, and `git revert` reproduces the old wording
26
+ // byte-for-byte.
27
+ //
28
+ // THE SLICE IS WHAT ANCHORS. Matched over the whole document these phrases are
29
+ // satisfiable from outside the rule: this file discusses `origin/main`
30
+ // scoping, `--is-ancestor`, orphans and pre-rebase shas across several
31
+ // neighbouring paragraphs, and `plugin/commands/run-merge-bot.md` prescribes
32
+ // the same command for its own (non-vacuous) input. `paragraph()` cuts the
33
+ // recipe to the one block carrying the rule and throws rather than widening if
34
+ // the anchor moves.
35
+ //
36
+ // MUTATION-VERIFIED BOTH WAYS, on a copy of this worktree's file kept outside
37
+ // it (`<scratch>/impl-814/SKILL.md.orig`, restored and sha-256-compared after
38
+ // every run). Five tests here; three of the 35 pre-existing prose pins over
39
+ // this same document — liveness-rationale, staleness-verdict,
40
+ // staleness-qualifier, 12 tests together — stayed green on every mutation,
41
+ // which is the discrimination:
42
+ // - the old wording restored whole (`git show origin/main:` before this fix):
43
+ // 5 of 5 red. That wording is green on origin/main's own CI, which is the
44
+ // measurement that this paragraph was unpinned.
45
+ // - the reachability reason cut out ("so every commit it can print is
46
+ // reachable from `origin/main` by construction" → "so the commit it names
47
+ // is the one to cite"): 3 red — the no-check-here pin plus the two
48
+ // accept-side tests, which derive their fixtures FROM the live paragraph
49
+ // and so red whenever a pinned span leaves it. The relocation pin and the
50
+ // negative both stay green: the mutation removed the reason, not the
51
+ // position.
52
+ // - the relocated input unnamed ("a sha the TICKET quotes" → "a sha from
53
+ // some other source"): 3 red — the relocation pin and the same two
54
+ // accept-side tests; the no-check-here pin stays green.
55
+ // - THE ACCEPT SIDE, measured on the file rather than a fixture: the whole
56
+ // paragraph re-wrapped at a width nothing here assumes — 5 of 5 GREEN.
57
+ // These pins refuse drift, not reflow.
58
+ // - the decoy, which is what the slice bound is for: both pinned spans
59
+ // deleted from the recipe and appended verbatim as a stray paragraph at
60
+ // the end of the file — 4 red, not bought off by the copy. The negative
61
+ // pin stays green there, correctly: nothing re-attached the proof claim.
62
+ //
63
+ // THE CEILING: two positive spans and one negative. The negative pins the
64
+ // LITERAL reverted clause — the walk's output bound to the proof claim — and a
65
+ // reworded re-attachment evades it; the positive spans are what carry the
66
+ // meaning. Neither half pins the exit-1/exit-128 reading note that follows
67
+ // them, which is a reading aid, not the rule. `git show` resolving an orphan is
68
+ // stated in the prose and not asserted here: it is a property of git, not of
69
+ // this document.
70
+ import { test } from "node:test";
71
+ import assert from "node:assert/strict";
72
+ import { readFileSync } from "node:fs";
73
+ import { join } from "node:path";
74
+ import { paragraph, phrase } from "./prose-pin.mjs";
75
+
76
+ const SKILL = "skills/run-team/SKILL.md";
77
+ const ANCHOR = "**Grep for the ticket's ASKED-FOR CHANGE, not only its subject construct**";
78
+ const text = () => readFileSync(join(import.meta.dirname, "..", ...SKILL.split("/")), "utf8");
79
+
80
+ // `**` stripped, nothing else: every pinned span below opens on a bolded lead
81
+ // clause, and where the emphasis sits is not what this file is about — dropping
82
+ // or moving the asterisks must not red a pin that holds the words. Whitespace
83
+ // is left to `phrase()`, which joins on `\s+` and so already absorbs the
84
+ // hard-wrap.
85
+ const recipe = () => paragraph(text(), ANCHOR, SKILL).replace(/\*\*/g, "");
86
+
87
+ // ONE contiguous span, never three presence checks: the rule is the JOIN of the
88
+ // instruction (no ancestry check here), its reason (reachable by construction,
89
+ // because that is where the walk starts) and the tautology's second case (true
90
+ // again when the sha IS the ref). Independent matches on those three would each
91
+ // stay green with the reason attached to the wrong clause, which is the shape
92
+ // the defect had.
93
+ const NO_CHECK_HERE =
94
+ "No ancestry check on what that walk printed. `origin/main` is where the walk starts, so every commit it can print is reachable from `origin/main` by construction, and `git merge-base --is-ancestor <sha> origin/main` is true for all of them — true again when the sha *is* `origin/main`.";
95
+
96
+ // The relocation, as one span for the same reason: the check, the input it
97
+ // belongs to (a sha the TICKET quotes) and the mechanism that lets that input
98
+ // answer no. "It can fail somewhere" with no named input is what the recipe
99
+ // already read like.
100
+ const BELONGS_TO_TICKET_SHA =
101
+ "That check belongs one input over — a sha the TICKET quotes, where it can answer no: a rebase leaves the commit it orphaned a whole object, so `git show` resolves it happily while nothing in `origin/main`'s history reaches it";
102
+
103
+ // The reverted clause, verbatim from `origin/main` before this fix: the walk's
104
+ // output bound to the proof claim. Narrow on purpose — the phrase "pre-rebase
105
+ // orphan" is LEGITIMATE in this paragraph when it describes the ticket-quoted
106
+ // sha, which is the whole point of the relocation, so a bare search for it
107
+ // would red correct prose. The accept-side test below feeds exactly that
108
+ // wording in and requires this pin to stay green on it.
109
+ const REVERTED =
110
+ "the commit that removed it, `git merge-base --is-ancestor <sha> origin/main` proves it is not a pre-rebase orphan";
111
+
112
+ test("the phase-0 recipe states the walk's own output needs no ancestry check, and why", () => {
113
+ assert.match(
114
+ recipe(),
115
+ phrase(NO_CHECK_HERE),
116
+ `${SKILL}'s "${ANCHOR}" paragraph no longer says "${NO_CHECK_HERE}". Without the reason bound to the instruction, the next reader restores the check — it looks like evidence, and nothing on the page says the walk already answers it. #814.`,
117
+ );
118
+ });
119
+
120
+ test("the phase-0 recipe keeps the ancestry check on the input where it can answer no", () => {
121
+ assert.match(
122
+ recipe(),
123
+ phrase(BELONGS_TO_TICKET_SHA),
124
+ `${SKILL}'s "${ANCHOR}" paragraph no longer says "${BELONGS_TO_TICKET_SHA}". The check is not wrong, it was in the wrong position — dropping the ticket-quoted-sha case loses the one input it is evidence for, and a sha a ticket quotes is where a stale premise hides. #814.`,
125
+ );
126
+ });
127
+
128
+ test("the phase-0 recipe does not re-attach the proof claim to the sha the walk printed", () => {
129
+ assert.doesNotMatch(
130
+ recipe(),
131
+ phrase(REVERTED),
132
+ `${SKILL}'s "${ANCHOR}" paragraph says "${REVERTED}" again — that is the #814 defect verbatim: the sha came from a walk starting at \`origin/main\`, so the check cannot answer no about it and proves nothing. Run it on a sha the ticket quotes instead.`,
133
+ );
134
+ });
135
+
136
+ // ACCEPT SIDE 1 — the guard's own false-positive class. "Pre-rebase orphan" is
137
+ // correct English about the ticket-quoted sha; the relocation is the reason
138
+ // that wording still belongs in this paragraph, so a future author spelling
139
+ // the relocated check that way must not red anything here. The fixture is the
140
+ // live paragraph plus exactly that sentence, about the ticket's sha: the
141
+ // negative pin stays green because what it refuses is the ADJACENCY to the
142
+ // walk's output, not the words.
143
+ test("naming the relocated check a pre-rebase-orphan test is ACCEPTED, not refused", () => {
144
+ const live = recipe();
145
+ const reworded = `${live} Run \`git merge-base --is-ancestor <sha> origin/main\` on the sha the ticket quotes: exit 0 proves it is not a pre-rebase orphan, exit 1 says it is one and the premise is stale.`;
146
+ assert.doesNotMatch(
147
+ reworded,
148
+ phrase(REVERTED),
149
+ "the negative pin fires on a LEGITIMATE use of the orphan wording on the ticket-quoted sha — narrow it to the walk-output adjacency",
150
+ );
151
+ assert.match(reworded, phrase(NO_CHECK_HERE));
152
+ assert.match(reworded, phrase(BELONGS_TO_TICKET_SHA));
153
+ });
154
+
155
+ // ACCEPT SIDE 2 — reflow. Derived from the live paragraph, never a quoted copy
156
+ // of today's lines, so a reword of the surrounding prose is not what this
157
+ // measures: re-wrapped at a width nothing here assumes, every pin above still
158
+ // holds. These pins refuse drift, not line breaks.
159
+ test("a rewrapped recipe paragraph still matches every pin above", () => {
160
+ const live = recipe();
161
+ const narrow = live
162
+ .split(/\s+/)
163
+ .filter(Boolean)
164
+ .reduce((acc, w) => {
165
+ const last = acc[acc.length - 1];
166
+ if (last && `${last} ${w}`.length <= 45) acc[acc.length - 1] = `${last} ${w}`;
167
+ else acc.push(w);
168
+ return acc;
169
+ }, [])
170
+ .join("\n ");
171
+ assert.notEqual(narrow, live, "the rewrap fixture no longer changes the paragraph's wrapping — update it");
172
+ assert.match(narrow, phrase(NO_CHECK_HERE));
173
+ assert.match(narrow, phrase(BELONGS_TO_TICKET_SHA));
174
+ assert.doesNotMatch(narrow, phrase(REVERTED));
175
+ });
@@ -0,0 +1,420 @@
1
+ // #164 / ADR 0007. Gate for `.github/scripts/apply-ruleset.sh`, the only
2
+ // sanctioned path for changing this repo's merge gate.
3
+ //
4
+ // The script's own header calls the post-write readback "the whole point of the
5
+ // script", and every branch it has is an error branch: the happy path is one
6
+ // line. Nothing executed it before this file — it was reachable only through
7
+ // prose. So what is pinned here is the behaviour an operator reads off it:
8
+ // the exit status, the message, and whether a PUT was issued at all.
9
+ //
10
+ // Three defects this file was written against, all reproduced before the fix:
11
+ // - the name lookup did not filter `source_type == "Repository"`, so an
12
+ // inherited org ruleset sharing the name either blocked the applier or sent
13
+ // the PUT to the parent's id (which the repo token cannot write);
14
+ // - the post-PUT readback was an unguarded command substitution, so the one
15
+ // state that matters — write landed, cannot be proven — exited with `gh`'s
16
+ // raw status and no message naming the unverified write;
17
+ // - `norm` compared `rules` positionally, so a server-side reorder turned a
18
+ // correct gate into a permanent refusal.
19
+ //
20
+ // Nothing here executes a workflow or reaches the network: `gh` is a stub on
21
+ // PATH and the script under test is the real file at the repo root, never a
22
+ // copy. `t_applies_a_genuine_difference` is the harness's positive control — if
23
+ // the stub or the PATH were wrong, every "exits 2" assertion below would pass
24
+ // for the wrong reason, and that one would fail.
25
+
26
+ import { test } from "node:test";
27
+ import assert from "node:assert/strict";
28
+ import { spawnSync } from "node:child_process";
29
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
30
+ import { tmpdir } from "node:os";
31
+ import { join } from "node:path";
32
+ import { fileURLToPath } from "node:url";
33
+
34
+ const ROOT = fileURLToPath(new URL("../../", import.meta.url));
35
+ const SCRIPT = join(ROOT, ".github/scripts/apply-ruleset.sh");
36
+ const SHIPPED_SPEC = join(ROOT, ".github/rulesets/main.json");
37
+ // Resolved once from the ambient PATH: the missing-tool tests below hand the
38
+ // script a PATH with one entry, and a relative `bash` would then fail to spawn
39
+ // at all — an error indistinguishable from the refusal being asserted.
40
+ const BASH = which("bash");
41
+
42
+ function which(name) {
43
+ const found = spawnSync("sh", ["-c", `command -v ${name}`], { encoding: "utf8" });
44
+ assert.equal(found.status, 0, `${name} must be on PATH for this file to test anything`);
45
+ return found.stdout.trim();
46
+ }
47
+
48
+ assert.ok(existsSync(SCRIPT), "apply-ruleset.sh is missing — this file tests nothing");
49
+
50
+ // Canned `gh`. Logs every invocation so a test can assert a PUT did or did not
51
+ // happen, which no exit status reports. Reads are numbered: the pre-PUT read
52
+ // and the post-PUT readback hit the same URL and have to be answerable apart.
53
+ // The listing is paged the way the real endpoint is — the second page exists
54
+ // only for a caller that asked for all of them.
55
+ const GH_STUB = [
56
+ "#!/bin/sh",
57
+ 'printf "%s\\n" "$*" >> "$GH_LOG"',
58
+ 'if [ "$1" = "repo" ]; then',
59
+ ' if [ -f "$GH_FIX/repo.fail" ]; then echo "gh: HTTP 401: Bad credentials" >&2; exit 1; fi',
60
+ ' printf "%s\\n" "acme/widget"; exit 0',
61
+ "fi",
62
+ 'shift # drop the `api` verb',
63
+ "method=GET; path=; paginate=0",
64
+ "while [ $# -gt 0 ]; do",
65
+ " case $1 in",
66
+ " -X|--method) method=$2; shift 2 ;;",
67
+ " --input|--jq) shift 2 ;;",
68
+ " --paginate) paginate=1; shift ;;",
69
+ " -*) shift ;;",
70
+ " *) path=$1; shift ;;",
71
+ " esac",
72
+ "done",
73
+ 'if [ "$method" = PUT ]; then',
74
+ ' if [ -f "$GH_FIX/put.fail" ]; then echo "gh: HTTP 422: Validation Failed" >&2; exit 1; fi',
75
+ ' echo "{}"; exit 0',
76
+ "fi",
77
+ 'case "$path" in',
78
+ " */rulesets)",
79
+ ' if [ -f "$GH_FIX/list.fail" ]; then echo "gh: HTTP 503: Service Unavailable" >&2; exit 1; fi',
80
+ ' cat "$GH_FIX/list.json"',
81
+ ' if [ "$paginate" = 1 ] && [ -f "$GH_FIX/list2.json" ]; then cat "$GH_FIX/list2.json"; fi ;;',
82
+ " */rulesets/*)",
83
+ ' n=$(cat "$GH_FIX/reads" 2>/dev/null || echo 0); n=$((n + 1)); echo "$n" > "$GH_FIX/reads"',
84
+ ' if [ -f "$GH_FIX/read$n.fail" ]; then echo "gh: HTTP 502 (post-PUT read)" >&2; exit 1; fi',
85
+ ' if [ -f "$GH_FIX/read$n.json" ]; then cat "$GH_FIX/read$n.json"; else cat "$GH_FIX/read.json"; fi ;;',
86
+ " *)",
87
+ ' echo "gh stub: unexpected path [$path]" >&2; exit 91 ;;',
88
+ "esac",
89
+ ].join("\n");
90
+
91
+ /** A minimal but shaped-like-the-real-thing ruleset spec. */
92
+ const spec = (over = {}) => ({
93
+ name: "main",
94
+ target: "branch",
95
+ enforcement: "active",
96
+ bypass_actors: [],
97
+ conditions: { ref_name: { exclude: [], include: ["~DEFAULT_BRANCH"] } },
98
+ rules: [
99
+ { type: "deletion" },
100
+ { type: "pull_request", parameters: { allowed_merge_methods: ["merge"], required_approving_review_count: 0 } },
101
+ { type: "required_status_checks", parameters: { strict_required_status_checks_policy: true, required_status_checks: [{ context: "check", integration_id: 15368 }] } },
102
+ ],
103
+ ...over,
104
+ });
105
+
106
+ /**
107
+ * The server's view of a ruleset: the spec's writable fields plus the
108
+ * server-only ones the projection has to ignore.
109
+ */
110
+ const served = (obj, id = 42) => ({
111
+ id,
112
+ source_type: "Repository",
113
+ created_at: "2026-07-31T14:10:14Z",
114
+ updated_at: "2026-07-31T16:37:01Z",
115
+ _links: { self: { href: "https://api.github.com/..." } },
116
+ ...obj,
117
+ });
118
+
119
+ const listed = (...entries) => entries.map(([id, name, source_type]) => ({ id, name, source_type }));
120
+
121
+ /**
122
+ * Run the shipped script against `fixtures`.
123
+ *
124
+ * `spec` is the spec file's content (an object, or a raw string for the
125
+ * malformed cases). `list` is the listing's first page and `list2` its second,
126
+ * which only a paginating caller ever sees. `reads` are the successive answers
127
+ * to the by-id GET; `readFails` names the 1-based read that should fail
128
+ * instead. `args` are options placed before the spec path. `path` overrides
129
+ * PATH for the missing-tool cases.
130
+ */
131
+ function run(t, { spec: specObj, list = listed([42, "main", "Repository"]), list2, reads = [], readFails = [], repoFails = false, putFails = false, listFails = false, specPath, args = [], path } = {}) {
132
+ const dir = mkdtempSync(join(tmpdir(), "apply-ruleset-"));
133
+ t.after(() => rmSync(dir, { recursive: true, force: true }));
134
+ const fix = join(dir, "fix");
135
+ const bin = join(dir, "bin");
136
+ mkdirSync(fix);
137
+ mkdirSync(bin);
138
+ writeFileSync(join(bin, "gh"), GH_STUB, { mode: 0o755 });
139
+
140
+ const specFile = join(dir, "spec.json");
141
+ if (specObj !== undefined) {
142
+ writeFileSync(specFile, typeof specObj === "string" ? specObj : JSON.stringify(specObj, null, 2));
143
+ }
144
+ writeFileSync(join(fix, "list.json"), JSON.stringify(list));
145
+ if (list2) writeFileSync(join(fix, "list2.json"), JSON.stringify(list2));
146
+ reads.forEach((r, i) => writeFileSync(join(fix, `read${i + 1}.json`), JSON.stringify(r)));
147
+ if (reads.length > 0) writeFileSync(join(fix, "read.json"), JSON.stringify(reads[reads.length - 1]));
148
+ for (const n of readFails) writeFileSync(join(fix, `read${n}.fail`), "");
149
+ if (repoFails) writeFileSync(join(fix, "repo.fail"), "");
150
+ if (putFails) writeFileSync(join(fix, "put.fail"), "");
151
+ if (listFails) writeFileSync(join(fix, "list.fail"), "");
152
+
153
+ const log = join(dir, "gh.log");
154
+ writeFileSync(log, "");
155
+
156
+ const r = spawnSync(BASH, [SCRIPT, ...args, specPath ?? specFile], {
157
+ cwd: dir,
158
+ encoding: "utf8",
159
+ env: { PATH: path ?? `${bin}:${process.env.PATH}`, HOME: dir, GH_FIX: fix, GH_LOG: log },
160
+ });
161
+
162
+ const calls = readFileSync(log, "utf8").split("\n").filter(Boolean);
163
+ return {
164
+ status: r.status,
165
+ out: `${r.stdout}${r.stderr}`,
166
+ calls,
167
+ puts: calls.filter((c) => c.includes("-X PUT")),
168
+ };
169
+ }
170
+
171
+ /** A PATH holding only the named real tools, for the "not on PATH" branches. */
172
+ function pathWith(t, names) {
173
+ const dir = mkdtempSync(join(tmpdir(), "apply-ruleset-path-"));
174
+ t.after(() => rmSync(dir, { recursive: true, force: true }));
175
+ for (const n of names) {
176
+ // `gh` is the stub even here: this PATH exists to make one tool missing,
177
+ // never to let a real API call out.
178
+ if (n === "gh") writeFileSync(join(dir, n), GH_STUB, { mode: 0o755 });
179
+ else writeFileSync(join(dir, n), `#!/bin/sh\nexec ${which(n)} "$@"\n`, { mode: 0o755 });
180
+ }
181
+ return dir;
182
+ }
183
+
184
+ // ---- the positive control ------------------------------------------------
185
+
186
+ test("applies a genuine difference and re-reads it", (t) => {
187
+ const want = spec();
188
+ const r = run(t, { spec: want, reads: [served({ ...want, enforcement: "disabled" }), served(want)] });
189
+ assert.equal(r.status, 0, r.out);
190
+ assert.equal(r.puts.length, 1, r.out);
191
+ assert.match(r.out, /applied and verified/);
192
+ });
193
+
194
+ test("a live object equal to the spec is left alone", (t) => {
195
+ const want = spec();
196
+ const r = run(t, { spec: want, reads: [served(want)] });
197
+ assert.equal(r.status, 0, r.out);
198
+ assert.deepEqual(r.puts, [], "nothing to apply must not write");
199
+ assert.match(r.out, /already matches/);
200
+ });
201
+
202
+ // ---- resolving the ruleset ----------------------------------------------
203
+
204
+ test("an inherited org ruleset sharing the name does not shadow the repo's own", (t) => {
205
+ const want = spec();
206
+ const r = run(t, {
207
+ spec: want,
208
+ list: listed([42, "main", "Repository"], [7777777, "main", "Organization"]),
209
+ reads: [served(want)],
210
+ });
211
+ assert.equal(r.status, 0, r.out);
212
+ assert.ok(
213
+ r.calls.some((c) => c.includes("rulesets/42")),
214
+ `must resolve the repository-level id, got: ${r.calls.join(" | ")}`,
215
+ );
216
+ assert.ok(!r.calls.some((c) => c.includes("7777777")), "must never address the parent's id");
217
+ });
218
+
219
+ test("an inherited org ruleset alone is not a repository ruleset", (t) => {
220
+ const r = run(t, { spec: spec(), list: listed([7777777, "main", "Organization"]) });
221
+ assert.equal(r.status, 2);
222
+ assert.match(r.out, /no repository-level ruleset named 'main'/);
223
+ assert.deepEqual(r.puts, [], "must not write to a ruleset it cannot own");
224
+ });
225
+
226
+ test("two repository rulesets sharing the name are refused, not guessed between", (t) => {
227
+ const r = run(t, { spec: spec(), list: listed([42, "main", "Repository"], [43, "main", "Repository"]) });
228
+ assert.equal(r.status, 2);
229
+ assert.match(r.out, /more than one ruleset named 'main'/);
230
+ assert.deepEqual(r.puts, []);
231
+ });
232
+
233
+ test("a quote in the ruleset name resolves instead of breaking the lookup", (t) => {
234
+ const want = spec({ name: 'ma"in' });
235
+ const r = run(t, { spec: want, list: listed([42, 'ma"in', "Repository"]), reads: [served(want)] });
236
+ assert.equal(r.status, 0, r.out);
237
+ assert.match(r.out, /already matches/);
238
+ });
239
+
240
+ test("a ruleset past the listing's first page is still found", (t) => {
241
+ const want = spec();
242
+ const filler = Array.from({ length: 30 }, (_, i) => [100 + i, `other-${i}`, "Repository"]);
243
+ const r = run(t, {
244
+ spec: want,
245
+ list: listed(...filler),
246
+ list2: listed([42, "main", "Repository"]),
247
+ reads: [served(want)],
248
+ });
249
+ assert.equal(r.status, 0, r.out);
250
+ assert.match(r.out, /already matches/);
251
+ });
252
+
253
+ // ---- the comparable projection ------------------------------------------
254
+
255
+ test("a server-side reorder of rules is not a difference", (t) => {
256
+ const want = spec();
257
+ const r = run(t, { spec: want, reads: [served({ ...want, rules: [...want.rules].reverse() })] });
258
+ assert.equal(r.status, 0, r.out);
259
+ assert.deepEqual(r.puts, [], "a pure reorder must not provoke a write");
260
+ });
261
+
262
+ test("a changed top-level field is a difference", (t) => {
263
+ const want = spec();
264
+ const live = served({ ...want, enforcement: "evaluate" });
265
+ const r = run(t, { spec: want, reads: [live, live] });
266
+ assert.equal(r.status, 2, r.out);
267
+ assert.match(r.out, /refusing to report success/);
268
+ });
269
+
270
+ test("a field changed deep inside a rule's parameters is a difference", (t) => {
271
+ const want = spec();
272
+ const drift = want.rules.map((x) => (x.type === "pull_request" ? { ...x, parameters: { ...x.parameters, allowed_merge_methods: ["squash"] } } : x));
273
+ const live = served({ ...want, rules: drift });
274
+ const r = run(t, { spec: want, reads: [live, live] });
275
+ assert.equal(r.status, 2, r.out);
276
+ assert.match(r.out, /still differs from/);
277
+ assert.match(r.out, /squash/, "the refusal must show what differs");
278
+ });
279
+
280
+ // ---- the failures an operator has to be able to read ---------------------
281
+
282
+ test("a write that cannot be proven says so, rather than exiting on gh's status", (t) => {
283
+ const want = spec();
284
+ const r = run(t, { spec: want, reads: [served({ ...want, enforcement: "disabled" })], readFails: [2] });
285
+ assert.equal(r.puts.length, 1, "the PUT must have been attempted for this to be the unprovable case");
286
+ assert.equal(r.status, 2, "a status the script itself never produces reads as a crash");
287
+ assert.match(r.out, /UNVERIFIED/);
288
+ });
289
+
290
+ test("a failing PUT is not diagnosed as a scope problem", (t) => {
291
+ const want = spec();
292
+ const r = run(t, { spec: want, reads: [served({ ...want, enforcement: "disabled" })], putFails: true });
293
+ assert.equal(r.status, 2);
294
+ assert.match(r.out, /PUT failed/);
295
+ assert.doesNotMatch(r.out, /repo-admin scope/, "422 is not a permissions failure");
296
+ });
297
+
298
+ test("a failing listing is not diagnosed as a scope problem", (t) => {
299
+ const r = run(t, { spec: spec(), listFails: true });
300
+ assert.equal(r.status, 2);
301
+ assert.match(r.out, /cannot list rulesets/);
302
+ assert.doesNotMatch(r.out, /repo-admin scope/, "503 is not a permissions failure");
303
+ });
304
+
305
+ test("a failing repo lookup is not diagnosed as being outside a checkout", (t) => {
306
+ const r = run(t, { spec: spec(), repoFails: true });
307
+ assert.equal(r.status, 2);
308
+ assert.doesNotMatch(r.out, /run this inside the checkout/, "401 has nothing to do with cwd");
309
+ });
310
+
311
+ // ---- refusing before it touches anything ---------------------------------
312
+
313
+ test("a missing spec file is refused before any API call", (t) => {
314
+ const r = run(t, { specPath: "/nonexistent/ruleset.json" });
315
+ assert.equal(r.status, 2);
316
+ assert.match(r.out, /no ruleset spec at/);
317
+ assert.deepEqual(r.calls, [], "must not reach for gh before it has a spec");
318
+ });
319
+
320
+ test("a malformed spec is named by the script, not left to jq's exit code", (t) => {
321
+ const r = run(t, { spec: '{ "name": "main",' });
322
+ assert.equal(r.status, 2, "jq's own exit status escaping would be 5");
323
+ assert.match(r.out, /apply-ruleset: .*is not valid JSON/);
324
+ });
325
+
326
+ test("a spec without a name cannot resolve a target", (t) => {
327
+ const r = run(t, { spec: { target: "branch" } });
328
+ assert.equal(r.status, 2);
329
+ assert.match(r.out, /has no \.name/);
330
+ });
331
+
332
+ test("a missing gh is refused by name", (t) => {
333
+ const r = run(t, { spec: spec(), path: pathWith(t, ["jq"]) });
334
+ assert.equal(r.status, 2);
335
+ assert.match(r.out, /gh is not on PATH/);
336
+ });
337
+
338
+ test("a missing jq is refused by name", (t) => {
339
+ const r = run(t, { spec: spec(), path: pathWith(t, ["gh"]) });
340
+ assert.equal(r.status, 2);
341
+ assert.match(r.out, /jq is not on PATH/);
342
+ });
343
+
344
+ // ---- --check: the same comparison, asked by something that cannot write ----
345
+ //
346
+ // #1710. The four contexts ADR 0007 added sat in the spec and not in the
347
+ // live gate for the 4d22h between ratification and reconcile, because
348
+ // nothing reads the gate unless a person decides to. What makes the flag
349
+ // worth its branch is the third status: an unattended caller holds no
350
+ // admin, and a read it was never allowed to make must not reach it as "the
351
+ // gate has drifted".
352
+
353
+ test("--check reports a difference and writes nothing", (t) => {
354
+ const want = spec();
355
+ const r = run(t, { args: ["--check"], spec: want, reads: [served({ ...want, enforcement: "disabled" })] });
356
+ assert.equal(r.status, 3, r.out);
357
+ assert.deepEqual(r.puts, [], "--check must never write");
358
+ assert.match(r.out, /does NOT match/);
359
+ assert.match(r.out, /disabled/, "the diff itself has to reach the caller, not just the verdict");
360
+ });
361
+
362
+ test("--check on a gate that matches its spec is an ordinary success", (t) => {
363
+ const want = spec();
364
+ const r = run(t, { args: ["--check"], spec: want, reads: [served(want)] });
365
+ assert.equal(r.status, 0, r.out);
366
+ assert.deepEqual(r.puts, [], "--check must never write");
367
+ });
368
+
369
+ test("--check on a listing with no matching repository-level ruleset is drift, not unanswerable", (t) => {
370
+ // The worst drift there is — the gate itself is gone — must not collapse
371
+ // into the same status a caller without a credential gets: 3, not 2.
372
+ const want = spec();
373
+ const r = run(t, { args: ["--check"], spec: want, list: listed([7777777, "main", "Organization"]) });
374
+ assert.equal(r.status, 3, "a deleted or renamed gate is drift, not merely unanswerable");
375
+ assert.match(r.out, /has no repository-level ruleset named/);
376
+ assert.deepEqual(r.puts, [], "--check must never write");
377
+ });
378
+
379
+ test("--check cannot read the gate at all is not reported as drift", (t) => {
380
+ const want = spec();
381
+ const r = run(t, { args: ["--check"], spec: want, readFails: [1] });
382
+ assert.equal(r.status, 2, "a read that fails outright must not be reported as though a diff was seen");
383
+ assert.match(r.out, /cannot read/);
384
+ });
385
+
386
+ test("--check without admin visibility into bypass_actors is not reported as drift", (t) => {
387
+ // GitHub answers a non-admin's GET with 200 and the `bypass_actors` key
388
+ // simply absent, never with a failed read. norm() would otherwise turn
389
+ // that absence into JSON `null` and compare it against the spec's `[]` as
390
+ // though it were a real difference (#1710's actual failure mode).
391
+ const want = spec();
392
+ const { bypass_actors, ...withheld } = served(want);
393
+ const r = run(t, { args: ["--check"], spec: want, reads: [withheld] });
394
+ assert.equal(r.status, 2, "a 200 that withholds bypass_actors is a missing credential, not a null-vs-[] diff");
395
+ assert.match(r.out, /bypass_actors/);
396
+ assert.doesNotMatch(r.out, /does NOT match/, "must never be compared as drift");
397
+ });
398
+
399
+ test("an unknown option is refused rather than read as a spec path", (t) => {
400
+ const r = run(t, { args: ["--dry-run"], spec: spec(), reads: [served(spec())] });
401
+ assert.equal(r.status, 2, r.out);
402
+ assert.match(r.out, /unknown option --dry-run/);
403
+ assert.deepEqual(r.calls, [], "refused before it reaches the API");
404
+ });
405
+
406
+ test("-- ends option parsing rather than being read as an unknown option", (t) => {
407
+ const want = spec();
408
+ const r = run(t, { args: ["--"], spec: want, reads: [served(want)] });
409
+ assert.equal(r.status, 0, r.out);
410
+ assert.match(r.out, /already matches/);
411
+ });
412
+
413
+ // ---- the shipped spec ----------------------------------------------------
414
+
415
+ test("the shipped ruleset spec is one this script can compare", (t) => {
416
+ const shipped = JSON.parse(readFileSync(SHIPPED_SPEC, "utf8"));
417
+ const r = run(t, { spec: shipped, list: listed([20119969, shipped.name, "Repository"]), reads: [served(shipped, 20119969)] });
418
+ assert.equal(r.status, 0, r.out);
419
+ assert.match(r.out, /already matches/);
420
+ });