@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.
- package/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,393 @@
|
|
|
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/merge-gate.mjs": ["--pr", "1", "--pre", "0".repeat(40)],
|
|
291
|
+
"scripts/pr-overlap.mjs": ["--a", "1", "--b", "1"],
|
|
292
|
+
"scripts/staleness.mjs": ["--path", "1", "--gone", "1"],
|
|
293
|
+
"scripts/tier-check.mjs": ["--batch", "1"],
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
test("no script the roster grep removes holds an unknown-flag refusal of its own", () => {
|
|
297
|
+
// The removed rows, derived the way the grep removes them: importers that
|
|
298
|
+
// bind defineFlags.
|
|
299
|
+
const delegators = [
|
|
300
|
+
...new Set(
|
|
301
|
+
rows(sh(IMPORT_GREP).stdout)
|
|
302
|
+
.filter((r) => r.text.trimStart().startsWith("import ") && r.text.includes("defineFlags"))
|
|
303
|
+
.map((r) => r.file),
|
|
304
|
+
),
|
|
305
|
+
];
|
|
306
|
+
assert.ok(delegators.length >= 3, `only ${delegators.length} importers bind defineFlags — the grep's -v defineFlags arm has nothing left to remove`);
|
|
307
|
+
|
|
308
|
+
// A guard above the sweep can answer first — a required flag the stray-only
|
|
309
|
+
// probe does not supply — and such a run never names the stray. Only a
|
|
310
|
+
// refusal that NAMES it is one this probe alone can credit to the script.
|
|
311
|
+
const guardFirst = [];
|
|
312
|
+
for (const file of delegators) {
|
|
313
|
+
const { status, out } = probeStray(file);
|
|
314
|
+
assert.equal(status, 2, `${file} ${STRAY} exited ${status}, not 2 — a stray flag reached real work`);
|
|
315
|
+
if (out.includes(STRAY)) {
|
|
316
|
+
assert.ok(
|
|
317
|
+
out.includes(SWEEP_PREFIX),
|
|
318
|
+
`${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`,
|
|
319
|
+
);
|
|
320
|
+
} else {
|
|
321
|
+
guardFirst.push(file);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Pinned, not silently skipped: a delegator falling out of this set (its
|
|
326
|
+
// guard stopped intercepting) or a new one falling into it (a fresh guard
|
|
327
|
+
// grew ahead of sweep()) reds here instead of quietly changing which
|
|
328
|
+
// delegators the loop above actually checks — the gap #1227's review found.
|
|
329
|
+
assert.deepEqual(
|
|
330
|
+
[...guardFirst].sort(),
|
|
331
|
+
Object.keys(GUARD_FIRST_FIXTURE).sort(),
|
|
332
|
+
"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",
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
// Clear each one's own guard for real and probe again: this is what makes a
|
|
336
|
+
// GENERIC-wording unknown-flag guard visible even though it never names the
|
|
337
|
+
// stray flag itself — the #365 second-edit-site shape this test guards
|
|
338
|
+
// against, invisible to the NAMES-the-flag check above.
|
|
339
|
+
for (const file of guardFirst) {
|
|
340
|
+
const { status, out } = probeArgv(file, GUARD_FIRST_FIXTURE[file]);
|
|
341
|
+
assert.equal(
|
|
342
|
+
status,
|
|
343
|
+
2,
|
|
344
|
+
`${file} ${GUARD_FIRST_FIXTURE[file].join(" ")} ${STRAY} exited ${status}, not 2 — its own required-arg guard was not actually cleared`,
|
|
345
|
+
);
|
|
346
|
+
assert.ok(
|
|
347
|
+
out.includes(SWEEP_PREFIX),
|
|
348
|
+
`${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`,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Review finding #3: deleting the exception test that named tier-check.mjs
|
|
354
|
+
// as the roster's one silent row (rather than re-pointing it) removed the
|
|
355
|
+
// suite's only detector of a NEW silent roster row — a future script that
|
|
356
|
+
// imports arg.mjs, is left out of both delegators (no defineFlags) and this
|
|
357
|
+
// file's own per-script prose, and never refuses an unknown flag at all.
|
|
358
|
+
// The "every script the roster grep returns refuses ... not sweep()'s"
|
|
359
|
+
// test above does not catch that shape: a script's own unrelated
|
|
360
|
+
// required-arg guard (a missing --thing, say) already exits 2 in wording
|
|
361
|
+
// that is not sweep()'s, satisfying that assertion without the stray flag
|
|
362
|
+
// ever being named or answered. Re-pointed at the now-empty set instead of
|
|
363
|
+
// deleted, so it keeps failing the moment a roster row goes silent again.
|
|
364
|
+
test("no roster row is silent: every row the roster grep returns names the stray flag it was probed with", () => {
|
|
365
|
+
const silent = scriptsOf(sh(ROSTER_GREP).stdout).filter((file) => !probeStray(file).out.includes(STRAY));
|
|
366
|
+
assert.deepEqual(
|
|
367
|
+
silent,
|
|
368
|
+
[],
|
|
369
|
+
"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",
|
|
370
|
+
);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
test("candidates.mjs refuses --limit under arg()'s generated wording", () => {
|
|
374
|
+
const got = sh(LIMIT_PROBE);
|
|
375
|
+
assert.equal(got.status, 2, `${LIMIT_PROBE} exited ${got.status}, not 2`);
|
|
376
|
+
assert.ok(
|
|
377
|
+
got.stderr.includes(argWording),
|
|
378
|
+
`${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`,
|
|
379
|
+
);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
test("candidates.mjs refuses --bogus under its own parseArgs", () => {
|
|
383
|
+
const got = sh(BOGUS_PROBE);
|
|
384
|
+
assert.equal(got.status, 2, `${BOGUS_PROBE} exited ${got.status}, not 2`);
|
|
385
|
+
assert.ok(
|
|
386
|
+
got.stderr.includes(parseArgsWording),
|
|
387
|
+
`${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`,
|
|
388
|
+
);
|
|
389
|
+
assert.ok(
|
|
390
|
+
!got.stderr.includes(SWEEP_PREFIX),
|
|
391
|
+
`${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`,
|
|
392
|
+
);
|
|
393
|
+
});
|