@feigi/fleet-ctl 3.23.36 → 3.23.37

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 (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,394 +0,0 @@
1
- // #1227. `arg.mjs`'s header names the second edit sites for the refusal
2
- // contract and quotes five commands it presents as settling: a `die()` grep,
3
- // two `from "./arg.mjs"` greps, and two `candidates.mjs` invocations. Each was
4
- // correct when it was written and none was executed by anything, which is the
5
- // defect that same header argues for #563/#567 — a requirement recorded where
6
- // nothing runs it. Measured before this file existed (#712, deferred out of
7
- // #1223): deleting the whole `candidates.mjs` paragraph left `arg.test.mjs`,
8
- // `shared-refusal.test.mjs`, `candidates.test.mjs` and
9
- // `line-distance-prose.test.mjs` green.
10
- //
11
- // Two halves, the two sizes #1227 files together.
12
- //
13
- // THE PROBES. The header's commands are EXTRACTED from its comment run and RUN
14
- // in a shell, from the directory they are written against — never restated. Two
15
- // assertions, and both are needed. The extracted list is compared against
16
- // `PROBES` below, so a paragraph deleted from the header reds here instead of
17
- // quietly shrinking the set the test happens to check; that is the vacuous
18
- // direction a derive-everything pin takes, and it is the direction #1227
19
- // measured. What each command must ANSWER is asserted separately, so a command
20
- // still spelled the way the header spells it, now reporting something else,
21
- // reds too.
22
- //
23
- // Every expected answer is DERIVED by calling the generator that produces it —
24
- // `defineFlags`, `makeArg`, `node:util`'s own `parseArgs` — never typed out here.
25
- // Rewording a refusal in `arg.mjs` moves this pin with it; rewording it in one
26
- // place only does not.
27
- //
28
- // THE ROSTER. Not a list of filenames: the scripts are read off the header's
29
- // own anchored grep, and each is then RUN with a flag nothing accepts. The
30
- // header's mechanism claim — a row binding `defineFlags` has delegated the
31
- // unknown-flag refusal, so the grep minus `defineFlags` leaves the rows that hold
32
- // their own — is the two containments asserted below: no row the grep leaves
33
- // answers in `sweep()`'s generated wording, and no row it removes answers in
34
- // anything else. A script renamed keeps the pin.
35
- //
36
- // CEILING, and it is the header's own. The header does not claim to NAME every
37
- // row its grep returns — `fleet-heartbeat.mjs`, for one, is in that output
38
- // and is not named, and the header says the scripts it names
39
- // "exemplify a way of qualifying, and were never the whole of it". So nothing
40
- // here demands a paragraph per row; the roster is the grep's output, and the
41
- // paragraphs are pinned only through the commands they carry.
42
- //
43
- // `review-core.mjs` is the site this grep cannot see at all, by the
44
- // header's own argument, and its copy of the digits rule is already executed by
45
- // `shared-refusal.test.mjs`. Left there rather than re-pinned here.
46
- import test from "node:test";
47
- import assert from "node:assert/strict";
48
- import { readFileSync } from "node:fs";
49
- import { spawnSync } from "node:child_process";
50
- import { join } from "node:path";
51
- import { parseArgs } from "node:util";
52
- import { anchorAt, stripSlashGutter } from "./prose-pin.mjs";
53
- import { makeArg, defineFlags } from "./arg.mjs";
54
-
55
- // The header's commands are written against the plugin root (`scripts/*.mjs`),
56
- // so that is where they run. Running them from anywhere else would test a
57
- // different command than the one a reader would type.
58
- const ROOT = join(import.meta.dirname, "..");
59
- const ARG = readFileSync(join(import.meta.dirname, "arg.mjs"), "utf8");
60
-
61
- // The header block, bounded by CODE at both ends: the start of the file and the
62
- // first import. `runAbove` is the shared bound for a comment run above a
63
- // declaration and does not fit — it requires the run to sit flush against its
64
- // anchor, and a blank line separates this header from that import. The bound is
65
- // asserted rather than assumed, in `HEADER IS THE WHOLE LEADING COMMENT RUN`
66
- // below, so a code line landing inside it cannot pass unnoticed.
67
- const HEADER = ARG.slice(0, anchorAt(ARG, 'import { writeSync } from "node:fs"', "arg.mjs header"));
68
-
69
- // A command quoted in a comment block wraps twice: at the `//` gutter, and at a
70
- // shell continuation backslash the header uses to keep a long grep readable.
71
- // Strip the gutter first, then fold the continuation, then collapse the
72
- // remaining whitespace — so a REWRAP of the header, which changes every one of
73
- // those break points and nothing else, leaves the extracted command identical.
74
- // That is the change this pin must not catch.
75
- const FLAT = stripSlashGutter(HEADER).replace(/\\\n/g, " ").replace(/\s+/g, " ").trim();
76
-
77
- // Code spans that are commands, not the other things this header code-quotes
78
- // (symbol names, flag names, message fragments, `gh pr diff`). A command here
79
- // is one a reader is meant to run from the plugin root, and both kinds the
80
- // header carries start with their binary.
81
- const quoted = [...FLAT.matchAll(/`([^`]+)`/g)].map((m) => m[1].trim());
82
- const commands = quoted.filter((s) => /^(?:grep|node) /.test(s));
83
-
84
- // The pin. Deleting a header paragraph deletes its commands from `commands`,
85
- // and this is what notices.
86
- const PROBES = [
87
- `grep -ln '^function die(' scripts/*.mjs`,
88
- `grep -n 'from "./arg.mjs"' scripts/*.mjs | grep -v test`,
89
- `grep -n '^import .*makeDie.* from "./arg.mjs"' scripts/*.mjs | grep -v test | grep -v defineFlags`,
90
- "node scripts/candidates.mjs --limit",
91
- "node scripts/candidates.mjs --bogus",
92
- ];
93
- const [DIE_GREP, IMPORT_GREP, ROSTER_GREP, LIMIT_PROBE, BOGUS_PROBE] = PROBES;
94
-
95
- const sh = (cmd) => spawnSync("sh", ["-c", cmd], { cwd: ROOT, encoding: "utf8" });
96
-
97
- // A flag no script accepts, and no prefix of one: `sweep()` and `parseArgs`
98
- // both match a flag NAME exactly, so a token nothing declares is refused by
99
- // whichever guard the script actually has — which is the thing being measured.
100
- const STRAY = "--zz-no-such-flag-1227";
101
-
102
- // What `sweep()` says, asked at run time rather than transcribed. A row whose
103
- // refusal is this string delegated to the shared sweep; a row whose refusal is
104
- // anything else did not.
105
- const sweepWordingFor = (known) => {
106
- const saved = process.argv;
107
- process.argv = ["node", "probe", STRAY];
108
- try {
109
- defineFlags(
110
- (m) => {
111
- throw new Error(m);
112
- },
113
- { flags: Object.fromEntries(known.map((k) => [k, "value"])) },
114
- ).sweep();
115
- } catch (e) {
116
- return e.message;
117
- } finally {
118
- process.argv = saved;
119
- }
120
- assert.fail("sweep() accepted a flag nothing declares — arg.test.mjs owns that contract, and it just changed");
121
- };
122
-
123
- // The wording minus the accepted-flag tail, which is per-script. The boundary
124
- // between them is DIFFED rather than cut at the literal " — accepted:" text:
125
- // two runs with accepted-lists that diverge at their first character share a
126
- // prefix exactly up to wherever `sweep()` starts writing the list, whatever
127
- // words carry it. Cutting at a hardcoded separator instead degrades silently
128
- // on a reword — `indexOf` returns -1, `slice(0, -1)` keeps nearly the whole
129
- // message, and a delegator answering in ITS OWN wording (which still shares
130
- // that near-whole prefix by coincidence of the run-time only) reads as
131
- // sweep()'s: a false accusation against an unrelated script, not a report
132
- // that the pin needs to move.
133
- const sweepA = sweepWordingFor(["aaa-boundary-probe"]);
134
- const sweepB = sweepWordingFor(["zzz-boundary-probe"]);
135
- let sharedLength = 0;
136
- while (sharedLength < sweepA.length && sharedLength < sweepB.length && sweepA[sharedLength] === sweepB[sharedLength]) sharedLength++;
137
- assert.ok(
138
- sharedLength > 0 && sharedLength < sweepA.length,
139
- "sweep()'s wording no longer varies with the accepted list the way this derivation needs — two different one-item lists produced identical (or entirely different) messages",
140
- );
141
- const SWEEP_PREFIX = sweepA.slice(0, sharedLength);
142
-
143
- // What `arg()` says for a valued flag given no value, asked the same way.
144
- const argWording = (() => {
145
- const saved = process.argv;
146
- process.argv = ["node", "probe", "--limit"];
147
- try {
148
- makeArg((m) => {
149
- throw new Error(m);
150
- })("limit");
151
- } catch (e) {
152
- return e.message;
153
- } finally {
154
- process.argv = saved;
155
- }
156
- assert.fail("arg() accepted --limit with no value — arg.test.mjs owns that contract, and it just changed");
157
- })();
158
-
159
- // What `node:util`'s `parseArgs` says, so "refuses under its OWN parseArgs" is
160
- // checked against the parser rather than against a copy of its message.
161
- const parseArgsWording = (() => {
162
- try {
163
- parseArgs({ args: ["--bogus"], options: {}, strict: true });
164
- } catch (e) {
165
- return e.message;
166
- }
167
- assert.fail("node:util parseArgs no longer refuses an undeclared flag in strict mode");
168
- })();
169
-
170
- // `file:line:text` rows, as both greps emit them.
171
- const rows = (out) =>
172
- out
173
- .split("\n")
174
- .filter(Boolean)
175
- .map((l) => {
176
- const m = /^([^:]+):(\d+):(.*)$/.exec(l);
177
- assert.ok(m, `unparsable grep row: ${l}`);
178
- return { file: m[1], text: m[3] };
179
- });
180
-
181
- const scriptsOf = (out) => [...new Set(rows(out).map((r) => r.file))];
182
-
183
- // Runs a script the way a stray flag reaches it, and reports what it
184
- // answered. `extra` supplies argv ahead of the stray flag — needed to clear a
185
- // delegator's own required-arg guard so a probe can reach sweep() for real,
186
- // rather than dying earlier for an unrelated reason.
187
- const probeArgv = (file, extra = []) => {
188
- const r = spawnSync("node", [file, ...extra, STRAY], { cwd: ROOT, encoding: "utf8" });
189
- return { status: r.status, out: `${r.stdout}${r.stderr}` };
190
- };
191
- const probeStray = (file) => probeArgv(file);
192
-
193
- test("arg.mjs's header is one leading comment run, so the slice above holds prose and no code", () => {
194
- const code = HEADER.split("\n").filter((l) => l.trim() && !l.startsWith("//"));
195
- assert.deepEqual(code, [], "a non-comment line sits inside arg.mjs's header slice — re-anchor this test, never widen it");
196
- assert.ok(HEADER.length > 2000, "arg.mjs's header collapsed to almost nothing — the slice anchor moved");
197
- });
198
-
199
- test("arg.mjs's header quotes exactly the commands this file executes", () => {
200
- assert.deepEqual(
201
- commands,
202
- PROBES,
203
- "arg.mjs's header no longer quotes exactly these commands. A paragraph naming a second edit site was deleted, added, or its command reworded — update PROBES and the assertion for it, never drop the difference",
204
- );
205
- });
206
-
207
- test("the die() grep the header quotes reports none, and reports arg.mjs without its anchor", () => {
208
- const got = sh(DIE_GREP);
209
- assert.equal(got.stdout, "", `${DIE_GREP} named a script: a private module-scope die() is back`);
210
- assert.equal(got.status, 1, "grep reported an error rather than a clean no-match");
211
-
212
- // The header's reason for the `^`, executed: unanchored, the command answers
213
- // with the file that asserts it settles nothing. Derived from the header's
214
- // own command by dropping the anchor, not retyped.
215
- const loose = DIE_GREP.replace("'^function die('", "'function die('");
216
- assert.notEqual(loose, DIE_GREP, "the die() grep no longer carries the ^ anchor this test strips to make the header's point executable");
217
- assert.match(
218
- sh(loose).stdout,
219
- /scripts\/arg\.mjs/,
220
- "unanchored, the die() grep no longer reports arg.mjs — the header's reason for anchoring it has gone stale",
221
- );
222
- });
223
-
224
- test("arg.mjs has no module-scope die() declaration under any spelling, not only the header's anchored grep", () => {
225
- // Independent of DIE_GREP's exact anchor text: that command only proves
226
- // TODAY's pinned `^function die(` finds nothing, and would miss a
227
- // realistic reintroduction in a syntactically different form just as
228
- // silently as it would miss one restated in prose. Reasoned separately —
229
- // over ARG's own lines rather than a shell grep — so the two probes cannot
230
- // share a blind spot: a module-scope `die` binding starts at column zero
231
- // (an unindented top-level statement, optionally `export`/`async`), which
232
- // is what distinguishes it from the many functions in this file that take
233
- // or return something named `die` as a LOCAL — `makeDie`'s own returned
234
- // `function die(msg)` is indented and does not match.
235
- const dieDecl = /^(export\s+)?(default\s+)?(async\s+)?(function\*?\s+die\s*\(|const\s+die\s*=|let\s+die\s*=|var\s+die\s*=)/;
236
- const found = ARG.split("\n").filter((line) => dieDecl.test(line));
237
- assert.deepEqual(
238
- found,
239
- [],
240
- "arg.mjs declares a module-scope die() under a spelling the header's anchored grep would not catch — a private die() is back in a different shape",
241
- );
242
- });
243
-
244
- test("the unanchored import grep matches arg.mjs's own comment; the anchored one does not", () => {
245
- const loose = sh(IMPORT_GREP);
246
- assert.equal(loose.status, 0, `${IMPORT_GREP} matched nothing`);
247
- const selfRows = rows(loose.stdout).filter((r) => r.file.endsWith("arg.mjs"));
248
- assert.ok(
249
- selfRows.length > 0 && selfRows.every((r) => !r.text.trimStart().startsWith("import ")),
250
- "the unanchored import grep no longer reports arg.mjs's own comment rows — the header's reason for anchoring on ^import has gone stale",
251
- );
252
-
253
- const strict = sh(ROSTER_GREP);
254
- assert.equal(strict.status, 0, `${ROSTER_GREP} matched nothing`);
255
- assert.deepEqual(
256
- rows(strict.stdout).filter((r) => r.file.endsWith("arg.mjs")),
257
- [],
258
- "the anchored roster grep now reports arg.mjs itself — the anchor stopped doing the work the header credits it with",
259
- );
260
- assert.ok(
261
- rows(strict.stdout).every((r) => r.text.trimStart().startsWith("import ")),
262
- "the roster grep returned a row that is not an import",
263
- );
264
- });
265
-
266
- test("every script the roster grep returns refuses a stray flag in its own wording, not sweep()'s", () => {
267
- const roster = scriptsOf(sh(ROSTER_GREP).stdout);
268
- assert.ok(roster.length >= 4, `the roster grep returned only ${roster.length} rows — it has stopped finding the edit sites`);
269
- for (const file of roster) {
270
- const { status, out } = probeStray(file);
271
- assert.equal(status, 2, `${file} ${STRAY} exited ${status}, not 2 — a stray flag reached real work`);
272
- assert.ok(
273
- !out.includes(SWEEP_PREFIX),
274
- `${file} answers a stray flag in sweep()'s generated wording, yet the roster grep returns it: it has delegated the unknown-flag refusal and is no longer a second edit site`,
275
- );
276
- }
277
- });
278
-
279
- // Delegators whose own required-arg guard runs BEFORE sweep(): a probe
280
- // carrying only the stray flag never reaches sweep() for these, so it never
281
- // learns whether they hold a refusal of their own. Each entry is the minimal
282
- // real argv (not a placeholder that would itself be refused — staleness.mjs
283
- // treats --gone and --present as mutually exclusive, so only one is given)
284
- // that clears exactly that script's OWN required-arg check, derived from
285
- // reading its guard, so the stray flag can reach sweep() and this test can
286
- // assert on what sweep() answers instead of silently skipping the script.
287
- const GUARD_FIRST_FIXTURE = {
288
- "scripts/ci-state.mjs": ["--pr", "1"],
289
- "scripts/diff-stats.mjs": ["--pr", "1"],
290
- "scripts/dispositions-check.mjs": ["--member", "fix-pr-1", "--scratch", "1"],
291
- "scripts/merge-gate.mjs": ["--pr", "1", "--pre", "0".repeat(40)],
292
- "scripts/pr-overlap.mjs": ["--a", "1", "--b", "1"],
293
- "scripts/staleness.mjs": ["--path", "1", "--gone", "1"],
294
- "scripts/tier-check.mjs": ["--batch", "1"],
295
- };
296
-
297
- test("no script the roster grep removes holds an unknown-flag refusal of its own", () => {
298
- // The removed rows, derived the way the grep removes them: importers that
299
- // bind defineFlags.
300
- const delegators = [
301
- ...new Set(
302
- rows(sh(IMPORT_GREP).stdout)
303
- .filter((r) => r.text.trimStart().startsWith("import ") && r.text.includes("defineFlags"))
304
- .map((r) => r.file),
305
- ),
306
- ];
307
- assert.ok(delegators.length >= 3, `only ${delegators.length} importers bind defineFlags — the grep's -v defineFlags arm has nothing left to remove`);
308
-
309
- // A guard above the sweep can answer first — a required flag the stray-only
310
- // probe does not supply — and such a run never names the stray. Only a
311
- // refusal that NAMES it is one this probe alone can credit to the script.
312
- const guardFirst = [];
313
- for (const file of delegators) {
314
- const { status, out } = probeStray(file);
315
- assert.equal(status, 2, `${file} ${STRAY} exited ${status}, not 2 — a stray flag reached real work`);
316
- if (out.includes(STRAY)) {
317
- assert.ok(
318
- out.includes(SWEEP_PREFIX),
319
- `${file} binds defineFlags, so the roster grep removes it, yet it refuses ${STRAY} in wording of its own: it is a second edit site the header's grep hides`,
320
- );
321
- } else {
322
- guardFirst.push(file);
323
- }
324
- }
325
-
326
- // Pinned, not silently skipped: a delegator falling out of this set (its
327
- // guard stopped intercepting) or a new one falling into it (a fresh guard
328
- // grew ahead of sweep()) reds here instead of quietly changing which
329
- // delegators the loop above actually checks — the gap #1227's review found.
330
- assert.deepEqual(
331
- [...guardFirst].sort(),
332
- Object.keys(GUARD_FIRST_FIXTURE).sort(),
333
- "the set of delegators whose required-arg guard intercepts a stray-only probe changed — update GUARD_FIRST_FIXTURE and this list together, never drop the difference",
334
- );
335
-
336
- // Clear each one's own guard for real and probe again: this is what makes a
337
- // GENERIC-wording unknown-flag guard visible even though it never names the
338
- // stray flag itself — the #365 second-edit-site shape this test guards
339
- // against, invisible to the NAMES-the-flag check above.
340
- for (const file of guardFirst) {
341
- const { status, out } = probeArgv(file, GUARD_FIRST_FIXTURE[file]);
342
- assert.equal(
343
- status,
344
- 2,
345
- `${file} ${GUARD_FIRST_FIXTURE[file].join(" ")} ${STRAY} exited ${status}, not 2 — its own required-arg guard was not actually cleared`,
346
- );
347
- assert.ok(
348
- out.includes(SWEEP_PREFIX),
349
- `${file} binds defineFlags, so the roster grep removes it, yet — once its own required-arg guard is satisfied — it refuses ${STRAY} outside sweep()'s wording: it is a second edit site the header's grep hides`,
350
- );
351
- }
352
- });
353
-
354
- // Review finding #3: deleting the exception test that named tier-check.mjs
355
- // as the roster's one silent row (rather than re-pointing it) removed the
356
- // suite's only detector of a NEW silent roster row — a future script that
357
- // imports arg.mjs, is left out of both delegators (no defineFlags) and this
358
- // file's own per-script prose, and never refuses an unknown flag at all.
359
- // The "every script the roster grep returns refuses ... not sweep()'s"
360
- // test above does not catch that shape: a script's own unrelated
361
- // required-arg guard (a missing --thing, say) already exits 2 in wording
362
- // that is not sweep()'s, satisfying that assertion without the stray flag
363
- // ever being named or answered. Re-pointed at the now-empty set instead of
364
- // deleted, so it keeps failing the moment a roster row goes silent again.
365
- test("no roster row is silent: every row the roster grep returns names the stray flag it was probed with", () => {
366
- const silent = scriptsOf(sh(ROSTER_GREP).stdout).filter((file) => !probeStray(file).out.includes(STRAY));
367
- assert.deepEqual(
368
- silent,
369
- [],
370
- "a roster row exists that never names a stray flag it was probed with — a script gained an arg.mjs import without gaining a real unknown-flag refusal of its own, the #365 fail-open reached from a third side",
371
- );
372
- });
373
-
374
- test("candidates.mjs refuses --limit under arg()'s generated wording", () => {
375
- const got = sh(LIMIT_PROBE);
376
- assert.equal(got.status, 2, `${LIMIT_PROBE} exited ${got.status}, not 2`);
377
- assert.ok(
378
- got.stderr.includes(argWording),
379
- `${LIMIT_PROBE} no longer answers with arg()'s generated "${argWording}" — the header's claim that arg()'s refusals DO reach candidates.mjs has gone stale`,
380
- );
381
- });
382
-
383
- test("candidates.mjs refuses --bogus under its own parseArgs", () => {
384
- const got = sh(BOGUS_PROBE);
385
- assert.equal(got.status, 2, `${BOGUS_PROBE} exited ${got.status}, not 2`);
386
- assert.ok(
387
- got.stderr.includes(parseArgsWording),
388
- `${BOGUS_PROBE} no longer answers with node:util parseArgs' own "${parseArgsWording}" — the second edit site the header names at candidates.mjs is not where it says it is`,
389
- );
390
- assert.ok(
391
- !got.stderr.includes(SWEEP_PREFIX),
392
- `${BOGUS_PROBE} now answers in sweep()'s wording — candidates.mjs routes through the shared sweep after all, and the header argues at refuseUnknown() that it deliberately does not`,
393
- );
394
- });