@feigi/fleet-ctl 3.23.36 → 3.23.38
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/package.json +1 -1
- package/scripts/cell-readout.mjs +38 -11
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
// The audit guard for the install-only dev loop (#1335, ADR 0003 point 4).
|
|
2
|
-
// Two invariants, independent of each other:
|
|
3
|
-
//
|
|
4
|
-
// (a) no script under `plugin/scripts/` derives the repo it OPERATES ON
|
|
5
|
-
// from its own location — the pattern the OLD `instruments.sh` had
|
|
6
|
-
// (#1337) and ADR 0003's own text names: a `git -C`/`git rev-parse`
|
|
7
|
-
// call rooted at `dirname "$0"` (sh) or
|
|
8
|
-
// `import.meta.dirname`/`__dirname` (js).
|
|
9
|
-
// (b) no prose under `plugin/skills/ plugin/commands/ plugin/agents/
|
|
10
|
-
// plugin/workflows/` contains a literal source path, harness cache
|
|
11
|
-
// path, or registry filename — the exact defect that produced the 35
|
|
12
|
-
// `~/dev/fleet-plugin/…` callsites ADR 0003 documents and #1336
|
|
13
|
-
// rewrote through the Resolver, draining this to zero.
|
|
14
|
-
//
|
|
15
|
-
// Both detectors are exported as plain functions over source TEXT precisely
|
|
16
|
-
// so they can be mutation-tested against fixture strings below, independent
|
|
17
|
-
// of what happens to be checked into the tree right now — the sweep tests
|
|
18
|
-
// further down are what points them at this repo.
|
|
19
|
-
import { test } from "node:test";
|
|
20
|
-
import assert from "node:assert/strict";
|
|
21
|
-
import { readFileSync } from "node:fs";
|
|
22
|
-
import { join } from "node:path";
|
|
23
|
-
import { fileURLToPath } from "node:url";
|
|
24
|
-
import { repoRoot, skipWithoutRepo, trackedPaths } from "./repo-root.mjs";
|
|
25
|
-
import { stripComments } from "./strip-comments.mjs";
|
|
26
|
-
|
|
27
|
-
const DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
28
|
-
const ROOT = repoRoot(DIR);
|
|
29
|
-
const SKIP_WITHOUT_REPO = skipWithoutRepo(ROOT, "the install-root audit (#1335)");
|
|
30
|
-
|
|
31
|
-
// ==================== Rule (a): own-location repo derivation ====================
|
|
32
|
-
|
|
33
|
-
// Whole-line `#` comments only — same ceiling as `stripComments.mjs` for js,
|
|
34
|
-
// and enough to keep instruments.sh's own PROSE description of the pattern
|
|
35
|
-
// it used to have (a comment, wrapped across two lines) from tripping this.
|
|
36
|
-
function stripShComments(src) {
|
|
37
|
-
return src.split("\n").map((l) => (/^\s*#/.test(l) ? "" : l)).join("\n");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// `git -C "$(dirname "$0")"`, inlined — the exact shape instruments.sh's own
|
|
41
|
-
// comment names as the pre-#1337 contract — PLUS the parent-directory
|
|
42
|
-
// spellings a production script one level below the repo root (every script
|
|
43
|
-
// lives directly under `scripts/`) would naturally reach for: a trailing
|
|
44
|
-
// `/..`, `dirname` applied twice, or a symlink-resolved `cd "$(dirname
|
|
45
|
-
// "$0")" && pwd`. Measured (#1355 review) that the un-widened rule let all
|
|
46
|
-
// three straight through against fixtures built from this file's own
|
|
47
|
-
// exports.
|
|
48
|
-
const SH_SELFLOC = String.raw`(?:\$\(\s*cd\s+"?\$\(\s*dirname\s+"?\$0"?\s*\)"?\s*&&\s*pwd\s*\)`
|
|
49
|
-
+ String.raw`|\$\(\s*dirname\s+"?\$\(\s*dirname\s+"?\$0"?\s*\)"?\s*\)`
|
|
50
|
-
+ String.raw`|\$\(\s*dirname\s+"?\$0"?\s*\))(?:/\.\.)?`;
|
|
51
|
-
const SH_GIT_C_INLINE = new RegExp(String.raw`git\s+-C\s+"?${SH_SELFLOC}`);
|
|
52
|
-
// A variable assigned EXACTLY one of the SH_SELFLOC shapes — bare (plus an
|
|
53
|
-
// optional trailing `/..`), nothing else appended. This is what
|
|
54
|
-
// distinguishes it from sibling-library sourcing
|
|
55
|
-
// (`json_lib="$(dirname "$0")/json.sh"`), which always appends a filename
|
|
56
|
-
// and therefore never matches this end-of-line anchor.
|
|
57
|
-
const SH_BARE_DIRNAME_ASSIGN = new RegExp(String.raw`^\s*(\w+)="?${SH_SELFLOC}"?\s*$`);
|
|
58
|
-
|
|
59
|
-
/** A description of the self-location violation in a POSIX-sh source, or `null`. */
|
|
60
|
-
export function shSelfLocationViolation(src) {
|
|
61
|
-
const code = stripShComments(src);
|
|
62
|
-
if (SH_GIT_C_INLINE.test(code)) return 'git -C anchored directly at "$(dirname "$0")" (or a parent/canonicalized spelling of it)';
|
|
63
|
-
for (const line of code.split("\n")) {
|
|
64
|
-
const m = SH_BARE_DIRNAME_ASSIGN.exec(line);
|
|
65
|
-
if (!m) continue;
|
|
66
|
-
const v = m[1];
|
|
67
|
-
if (new RegExp(`git\\s+-C\\s+"?\\$\\{?${v}\\}?"?`).test(code)) {
|
|
68
|
-
return `git -C "$${v}" where ${v} := an own-location expression (bare — no sibling filename appended)`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const JS_SELFLOC = String.raw`(?:import\.meta\.dirname`
|
|
75
|
-
+ String.raw`|dirname\(\s*fileURLToPath\(\s*import\.meta\.url\s*\)\s*\)`
|
|
76
|
-
+ String.raw`|fileURLToPath\(\s*new URL\(\s*["']\.["'],\s*import\.meta\.url\s*\)\s*\)`
|
|
77
|
-
+ String.raw`|__dirname)`;
|
|
78
|
-
// The parent-directory spelling — `join(SELFLOC, "..")` / `resolve(SELFLOC,
|
|
79
|
-
// "..")` — reaches the repo root from a script one level below it, exactly
|
|
80
|
-
// as naturally as the sh side's trailing `/..`. Measured (#1355 review) to
|
|
81
|
-
// escape the un-widened rule.
|
|
82
|
-
const JS_SELFLOC_MAYBE_PARENT = String.raw`(?:(?:join|resolve)\(\s*${JS_SELFLOC}\s*,\s*["'][.\/]+["']\s*\)|${JS_SELFLOC})`;
|
|
83
|
-
const JS_BARE_SELFLOC_ASSIGN = new RegExp(
|
|
84
|
-
String.raw`(?:const|let|var)\s+(\w+)\s*=\s*${JS_SELFLOC_MAYBE_PARENT}\s*;`,
|
|
85
|
-
"g",
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// A git invocation "anchored" at `target` (either the raw self-location
|
|
89
|
-
// pattern or an escaped variable name), in either of the two shapes node
|
|
90
|
-
// code roots a git call at a directory: the spawn/exec `cwd` option, or
|
|
91
|
-
// git's own `-C <dir>` argv element. Bounded windows, not a whole-file
|
|
92
|
-
// proximity scan — a whole-file scan is what produced a false positive
|
|
93
|
-
// against this repo's own sibling-sourcing shape during development (an
|
|
94
|
-
// UNRELATED `git -C "$root"` call landing within a wide window of an
|
|
95
|
-
// UNRELATED `dirname "$0"` sibling-sourcing line); these windows stay
|
|
96
|
-
// inside one call expression's own text. `(?!\w)` rather than `\b` after
|
|
97
|
-
// `target`: `\b` requires a word/non-word transition and silently fails to
|
|
98
|
-
// match when `target` is a compound expression ending in `)` followed by
|
|
99
|
-
// more punctuation (`join(import.meta.dirname, "..")` inlined directly as
|
|
100
|
-
// `cwd:`'s value) — measured (#1355 review) to let that exact shape through.
|
|
101
|
-
function jsAnchoredAtTarget(code, target) {
|
|
102
|
-
const cwdForm = new RegExp(
|
|
103
|
-
String.raw`\bgit\b[\s\S]{0,150}?(rev-parse|--show-toplevel|"-C")[\s\S]{0,250}?cwd\s*:\s*${target}(?!\w)`
|
|
104
|
-
+ `|`
|
|
105
|
-
+ String.raw`cwd\s*:\s*${target}(?!\w)[\s\S]{0,250}?\bgit\b[\s\S]{0,150}?(rev-parse|--show-toplevel|"-C")`,
|
|
106
|
-
);
|
|
107
|
-
const argvCForm = new RegExp(String.raw`\bgit\b[\s\S]{0,80}?\[[\s\S]{0,80}?["'\`]-C["'\`]\s*,\s*${target}(?!\w)`);
|
|
108
|
-
return cwdForm.test(code) || argvCForm.test(code);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** A description of the self-location violation in a js/mjs source, or `null`. */
|
|
112
|
-
export function jsSelfLocationViolation(src) {
|
|
113
|
-
const code = stripComments(src);
|
|
114
|
-
if (jsAnchoredAtTarget(code, JS_SELFLOC_MAYBE_PARENT)) {
|
|
115
|
-
return "a git rev-parse/-C call anchored (cwd: or -C) at this script's own location (or its parent)";
|
|
116
|
-
}
|
|
117
|
-
JS_BARE_SELFLOC_ASSIGN.lastIndex = 0;
|
|
118
|
-
let m;
|
|
119
|
-
while ((m = JS_BARE_SELFLOC_ASSIGN.exec(code))) {
|
|
120
|
-
const v = m[1];
|
|
121
|
-
if (jsAnchoredAtTarget(code, v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) {
|
|
122
|
-
return `a git rev-parse/-C call anchored (cwd: or -C) at ${v}, an own-location variable`;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// sh by extension or `#!/bin/sh`; js by `.mjs` extension (excluding tests,
|
|
129
|
-
// filtered by the caller) or a node shebang for the three extensionless
|
|
130
|
-
// Resolver scripts; anything else (board.html) is not a script this rule
|
|
131
|
-
// has an opinion about — and neither is one of those three once it loses
|
|
132
|
-
// its shebang, which is why the sweep below names them (#1923).
|
|
133
|
-
function classifyScript(rel, content) {
|
|
134
|
-
if (rel.endsWith(".sh")) return "sh";
|
|
135
|
-
if (rel.endsWith(".mjs")) return "js";
|
|
136
|
-
const firstLine = content.slice(0, content.indexOf("\n") === -1 ? undefined : content.indexOf("\n"));
|
|
137
|
-
if (/^#!.*\bsh\b/.test(firstLine)) return "sh";
|
|
138
|
-
if (/^#!.*\bnode\b/.test(firstLine)) return "js";
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// The extensionless entrypoints, by path — the same three
|
|
143
|
-
// node-floor-sweep.test.mjs names in its own NODE_SHEBANG_ENTRYPOINTS
|
|
144
|
-
// (#1884). classifyScript() finds them by their first line alone, a line CI
|
|
145
|
-
// never needs — .github/scripts/install-and-smoke.sh runs all three as
|
|
146
|
-
// `node <path>`, so losing it breaks only direct-exec callers at run time —
|
|
147
|
-
// so one that lost it came back `null` and was skipped by the sweep below
|
|
148
|
-
// without a word. The sweep's `files.length > 30` guard cannot notice, since it
|
|
149
|
-
// counts the tracked list BEFORE classification, where the dozens of
|
|
150
|
-
// `.sh`/`.mjs` files, classified by extension, keep it non-empty. Measured
|
|
151
|
-
// (#1923): `fleet-run` with its shebang deleted and a
|
|
152
|
-
// `git rev-parse` call anchored at `cwd: __dirname` appended left this
|
|
153
|
-
// suite green; with the shebang kept, the same call fails it.
|
|
154
|
-
const NODE_SHEBANG_ENTRYPOINTS = ["plugin/scripts/fleet-bootstrap", "plugin/scripts/fleet-provenance", "plugin/scripts/fleet-run"];
|
|
155
|
-
|
|
156
|
-
// Per-kind floors over what classifyScript() returns, at ~60% of each kind's
|
|
157
|
-
// measured baseline — the same ratio the #1821 retired-word sweep's own
|
|
158
|
-
// tracked-file floor uses. Measured
|
|
159
|
-
// 2026-09-27 (#2025): 14
|
|
160
|
-
// `sh` (every `.sh`) and 36 `js` (33 `.mjs` plus the three
|
|
161
|
-
// NODE_SHEBANG_ENTRYPOINTS), out of 52 tracked; board.html and the one
|
|
162
|
-
// `.json` classify `null` and are policed by nothing here, so they carry no
|
|
163
|
-
// floor. The aggregate `files.length > 30` guard cannot see a filter bug that
|
|
164
|
-
// empties ONE kind: dropping every `.sh` leaves 38 entries, still above it,
|
|
165
|
-
// while shSelfLocationViolation() runs over nothing (measured, PR #2023
|
|
166
|
-
// review). Counted after classification, so a broken classifyScript() branch
|
|
167
|
-
// that sends a whole extension to `null` fails here too.
|
|
168
|
-
const KIND_FLOORS = { sh: 8, js: 21 };
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Each KIND_FLOORS kind that `kinds` (rel → classifyScript() result) holds
|
|
172
|
-
* fewer of than its floor, as a description; empty when every kind clears.
|
|
173
|
-
*/
|
|
174
|
-
export function kindFloorShortfalls(kinds) {
|
|
175
|
-
const counts = {};
|
|
176
|
-
for (const k of kinds.values()) if (k !== null) counts[k] = (counts[k] ?? 0) + 1;
|
|
177
|
-
return Object.entries(KIND_FLOORS)
|
|
178
|
-
.filter(([k, floor]) => (counts[k] ?? 0) < floor)
|
|
179
|
-
.map(([k, floor]) => `${k}: ${counts[k] ?? 0} classified, under its floor of ${floor}`);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
test(
|
|
183
|
-
"no tracked production script under plugin/scripts/ derives the repo it operates on from its own location",
|
|
184
|
-
{ skip: SKIP_WITHOUT_REPO },
|
|
185
|
-
() => {
|
|
186
|
-
const files = trackedPaths(ROOT, ["plugin/scripts/*"]).filter((f) => !f.endsWith(".test.mjs"));
|
|
187
|
-
assert.ok(
|
|
188
|
-
files.length > 30,
|
|
189
|
-
`the instrument set has only ${files.length} entries — too few to be plugin/scripts/*'s real non-test-file tree, and the sweep below would pass vacuously over an empty or near-empty list`,
|
|
190
|
-
);
|
|
191
|
-
const violations = [];
|
|
192
|
-
const kinds = new Map();
|
|
193
|
-
for (const rel of files) {
|
|
194
|
-
const content = readFileSync(join(ROOT, rel), "utf8");
|
|
195
|
-
const kind = classifyScript(rel, content);
|
|
196
|
-
kinds.set(rel, kind);
|
|
197
|
-
if (kind === null) continue;
|
|
198
|
-
const v = kind === "sh" ? shSelfLocationViolation(content) : jsSelfLocationViolation(content);
|
|
199
|
-
if (v) violations.push(`${rel}: ${v}`);
|
|
200
|
-
}
|
|
201
|
-
assert.deepEqual(
|
|
202
|
-
kindFloorShortfalls(kinds),
|
|
203
|
-
[],
|
|
204
|
-
"a filter or classifyScript() bug is thinning one script kind out of the instrument set while the aggregate "
|
|
205
|
-
+ "count floor above still clears — that kind's detector would sweep a near-empty list (#2025)",
|
|
206
|
-
);
|
|
207
|
-
// Over what THIS loop classified, not a second pass beside it: `js` is
|
|
208
|
-
// the only kind that runs an entrypoint through the js detector.
|
|
209
|
-
const unpoliced = NODE_SHEBANG_ENTRYPOINTS
|
|
210
|
-
.filter((rel) => kinds.get(rel) !== "js")
|
|
211
|
-
.map((rel) => `${rel} (${kinds.has(rel) ? `classified ${kinds.get(rel)}` : "not tracked"})`);
|
|
212
|
-
assert.deepEqual(
|
|
213
|
-
unpoliced,
|
|
214
|
-
[],
|
|
215
|
-
"an extensionless entrypoint is classified js by its node shebang alone, so one that lost that first line "
|
|
216
|
-
+ "(or a broken shebang probe in classifyScript) escapes this rule while it still runs as `node <path>`. "
|
|
217
|
-
+ "Restore the shebang; or, if the file was renamed or retired, update NODE_SHEBANG_ENTRYPOINTS (#1884, #1923)",
|
|
218
|
-
);
|
|
219
|
-
assert.deepEqual(
|
|
220
|
-
violations,
|
|
221
|
-
[],
|
|
222
|
-
"This rule polices deriving a REPO ROOT from own location — a git rev-parse/-C call anchored at "
|
|
223
|
-
+ "dirname \"$0\" / import.meta.dirname — not every own-location read. It does not flag, and needs no "
|
|
224
|
-
+ "explicit exemption for: sibling-library sourcing (json_lib=\"$(dirname \"$0\")/json.sh\" and its "
|
|
225
|
-
+ "net.sh/worktree.sh equivalents) or board.mjs's SCRIPT_DIR-relative board.html asset path, because "
|
|
226
|
-
+ "neither ever calls git — they name a co-located FILE, never a repo boundary. fleet-run's own "
|
|
227
|
-
+ "directory is likewise never fed to git (see that file's header comment). scripts/repo-root.mjs's "
|
|
228
|
-
+ "repoRoot(cwd) takes an explicit cwd parameter rather than deriving one, so it never appears here "
|
|
229
|
-
+ "either — #1339's own fix to trackedShellScripts is untouched by this rule.",
|
|
230
|
-
);
|
|
231
|
-
},
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
// ---- kindFloorShortfalls: the per-kind floors must refuse a one-kind drop the aggregate floor passes, and accept the real shape ----
|
|
235
|
-
|
|
236
|
-
function kindsOf(counts) {
|
|
237
|
-
const kinds = new Map();
|
|
238
|
-
for (const [kind, n] of Object.entries(counts)) {
|
|
239
|
-
for (let i = 0; i < n; i++) kinds.set(`plugin/scripts/${kind}-${i}`, kind === "null" ? null : kind);
|
|
240
|
-
}
|
|
241
|
-
return kinds;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
test("kindFloorShortfalls: accepts the measured baseline shape and each kind sitting exactly at its floor", () => {
|
|
245
|
-
assert.deepEqual(kindFloorShortfalls(kindsOf({ sh: 14, js: 36, null: 2 })), []);
|
|
246
|
-
assert.deepEqual(kindFloorShortfalls(kindsOf({ sh: 8, js: 21 })), []);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test("kindFloorShortfalls: flags every .sh dropped even though 38 entries still clear the aggregate > 30 floor", () => {
|
|
250
|
-
const kinds = kindsOf({ js: 36, null: 2 });
|
|
251
|
-
assert.ok(kinds.size > 30);
|
|
252
|
-
assert.deepEqual(kindFloorShortfalls(kinds), ["sh: 0 classified, under its floor of 8"]);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test("kindFloorShortfalls: flags a kind thinned to one under its floor, and js as well as sh", () => {
|
|
256
|
-
assert.deepEqual(kindFloorShortfalls(kindsOf({ sh: 7, js: 36 })), ["sh: 7 classified, under its floor of 8"]);
|
|
257
|
-
assert.deepEqual(kindFloorShortfalls(kindsOf({ sh: 14, js: 20 })), ["js: 20 classified, under its floor of 21"]);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// ---- Mutation tests: rule (a) must fail on the introduced pattern and pass without it, both directions ----
|
|
261
|
-
|
|
262
|
-
test("shSelfLocationViolation: flags git -C inlined directly at dirname \"$0\"", () => {
|
|
263
|
-
assert.match(
|
|
264
|
-
shSelfLocationViolation('#!/bin/sh\ngit -C "$(dirname "$0")" rev-parse --show-toplevel\n'),
|
|
265
|
-
/git -C anchored directly/,
|
|
266
|
-
);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
test("shSelfLocationViolation: flags a captured bare dirname \"$0\" variable later used with git -C", () => {
|
|
270
|
-
const src = '#!/bin/sh\nroot="$(dirname "$0")"\ngit -C "$root" rev-parse --show-toplevel\n';
|
|
271
|
-
assert.match(shSelfLocationViolation(src), /root/);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
test("shSelfLocationViolation: does not flag sibling-library sourcing plus an unrelated git -C call", () => {
|
|
275
|
-
const src = '#!/bin/sh\n'
|
|
276
|
-
+ 'json_lib="$(dirname "$0")/json.sh"\n'
|
|
277
|
-
+ '[ -r "$json_lib" ] || die "cannot read $json_lib"\n'
|
|
278
|
-
+ '. "$json_lib"\n'
|
|
279
|
-
+ 'git -C "$root" status\n';
|
|
280
|
-
assert.equal(shSelfLocationViolation(src), null);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
test("shSelfLocationViolation: does not flag a root passed in explicitly", () => {
|
|
284
|
-
assert.equal(shSelfLocationViolation('#!/bin/sh\nroot="$1"\ngit -C "$root" rev-parse --show-toplevel\n'), null);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test("shSelfLocationViolation: a comment merely describing the old pattern does not flag", () => {
|
|
288
|
-
const src = '#!/bin/sh\n'
|
|
289
|
-
+ '# the OLD own-location contract (`git -C "$(dirname\n'
|
|
290
|
-
+ '# "$0")" ...`) resolved the wrong tree\n'
|
|
291
|
-
+ 'root="$1"\n'
|
|
292
|
-
+ 'git -C "$root" rev-parse --show-toplevel\n';
|
|
293
|
-
assert.equal(shSelfLocationViolation(src), null);
|
|
294
|
-
});
|
|
295
|
-
test("shSelfLocationViolation: flags the trailing /.. parent-directory spelling", () => {
|
|
296
|
-
const src = '#!/bin/sh\nroot="$(dirname "$0")/.."\ngit -C "$root" status\n';
|
|
297
|
-
assert.match(shSelfLocationViolation(src), /root/);
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
test("shSelfLocationViolation: flags the symlink-resolved cd \"$(dirname \"$0\")\" && pwd spelling", () => {
|
|
301
|
-
const src = '#!/bin/sh\nroot="$(cd "$(dirname "$0")" && pwd)"\ngit -C "$root" status\n';
|
|
302
|
-
assert.match(shSelfLocationViolation(src), /root/);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
test("shSelfLocationViolation: flags the nested dirname \"$(dirname \"$0\")\" parent spelling", () => {
|
|
306
|
-
const src = '#!/bin/sh\nroot="$(dirname "$(dirname "$0")")"\ngit -C "$root" status\n';
|
|
307
|
-
assert.match(shSelfLocationViolation(src), /root/);
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
test("jsSelfLocationViolation: flags git rev-parse with cwd anchored at import.meta.dirname", () => {
|
|
312
|
-
const src = 'execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd: import.meta.dirname });';
|
|
313
|
-
assert.match(jsSelfLocationViolation(src), /own location/);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
test("jsSelfLocationViolation: flags a captured own-directory variable used as git's -C argument", () => {
|
|
317
|
-
const src = 'const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));\n'
|
|
318
|
-
+ 'spawnSync("git", ["-C", SCRIPT_DIR, "rev-parse", "HEAD"]);\n';
|
|
319
|
-
assert.match(jsSelfLocationViolation(src), /SCRIPT_DIR/);
|
|
320
|
-
});
|
|
321
|
-
test("jsSelfLocationViolation: flags the join(SELFLOC, \"..\") parent-directory spelling, captured", () => {
|
|
322
|
-
const src = 'const ROOT = join(import.meta.dirname, "..");\n'
|
|
323
|
-
+ 'execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd: ROOT });\n';
|
|
324
|
-
assert.match(jsSelfLocationViolation(src), /ROOT/);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test("jsSelfLocationViolation: flags join(SELFLOC, \"..\") inlined directly with no variable", () => {
|
|
328
|
-
const src = 'execFileSync("git", ["rev-parse"], { cwd: join(import.meta.dirname, "..") });';
|
|
329
|
-
assert.match(jsSelfLocationViolation(src), /own location/);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
test("jsSelfLocationViolation: flags resolve(__dirname, \"..\") used as git's -C argument", () => {
|
|
333
|
-
const src = 'const ROOT = resolve(__dirname, "..");\nexecFileSync("git", ["-C", ROOT, "status"]);\n';
|
|
334
|
-
assert.match(jsSelfLocationViolation(src), /ROOT/);
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
test("jsSelfLocationViolation: does not flag SCRIPT_DIR's own \"..\" used only for an unrelated asset path", () => {
|
|
338
|
-
const src = 'const ASSET = join(SCRIPT_DIR, "..", "assets", "logo.png");\nreadFileSync(ASSET);\n';
|
|
339
|
-
assert.equal(jsSelfLocationViolation(src), null);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
test("jsSelfLocationViolation: does not flag SCRIPT_DIR used only for a co-located asset path", () => {
|
|
344
|
-
const src = 'const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));\n'
|
|
345
|
-
+ 'copyFileSync(join(SCRIPT_DIR, "board.html"), join(stateDir, "board.html"));\n';
|
|
346
|
-
assert.equal(jsSelfLocationViolation(src), null);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
test("jsSelfLocationViolation: does not flag SCRIPT_DIR used only to spawn a sibling script", () => {
|
|
350
|
-
const src = 'const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));\n'
|
|
351
|
-
+ 'spawnSync(process.execPath, [join(SCRIPT_DIR, "candidates.mjs")], { encoding: "utf8" });\n';
|
|
352
|
-
assert.equal(jsSelfLocationViolation(src), null);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
test("jsSelfLocationViolation: does not flag repoRoot's own explicit cwd parameter", () => {
|
|
356
|
-
const src = 'export function repoRoot(cwd) {\n'
|
|
357
|
-
+ ' const r = spawnSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf8" });\n'
|
|
358
|
-
+ ' return r.stdout.trim();\n'
|
|
359
|
-
+ '}\n';
|
|
360
|
-
assert.equal(jsSelfLocationViolation(src), null);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
// ==================== Rule (b): literal source/harness/registry paths in prose ====================
|
|
364
|
-
|
|
365
|
-
// The four literal tokens ADR 0003/CONTEXT.md's Resolver entry forbid in a
|
|
366
|
-
// prose callsite: an absolute source-checkout path, an absolute macOS home
|
|
367
|
-
// path, omp's cache path, or the registry filename itself.
|
|
368
|
-
const LITERAL_PATTERNS = [
|
|
369
|
-
{ name: "home-dev-checkout", re: /~\/dev\// },
|
|
370
|
-
{ name: "absolute-Users-path", re: /\/Users\// },
|
|
371
|
-
{ name: "omp-plugin-cache", re: /~\/\.omp\/plugins\/cache/ },
|
|
372
|
-
{ name: "registry-filename", re: /installed_plugins\.json/ },
|
|
373
|
-
];
|
|
374
|
-
|
|
375
|
-
// #1336 rewrote all 35 `~/dev/fleet-plugin/…` callsites ADR 0003 documented
|
|
376
|
-
// (script AND cross-doc references alike) through the Resolver, so no
|
|
377
|
-
// allowlist exists any more — a `~/dev/` match anywhere in this prose is a
|
|
378
|
-
// plain violation, full stop.
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Every literal-pattern match in one source text, each `{ pattern, index }`.
|
|
382
|
-
*/
|
|
383
|
-
export function literalPathMatches(text) {
|
|
384
|
-
const violations = [];
|
|
385
|
-
for (const { name, re } of LITERAL_PATTERNS) {
|
|
386
|
-
const g = new RegExp(re.source, "g");
|
|
387
|
-
let m;
|
|
388
|
-
while ((m = g.exec(text))) {
|
|
389
|
-
violations.push({ pattern: name, index: m.index });
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return { violations };
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
test(
|
|
396
|
-
"no prose under plugin/skills/ plugin/commands/ plugin/agents/ contains a literal "
|
|
397
|
-
+ "source/harness/registry path",
|
|
398
|
-
{ skip: SKIP_WITHOUT_REPO },
|
|
399
|
-
() => {
|
|
400
|
-
const files = trackedPaths(ROOT, ["plugin/skills/*", "plugin/commands/*", "plugin/agents/*"]);
|
|
401
|
-
assert.ok(
|
|
402
|
-
files.length > 15,
|
|
403
|
-
`the prose set has only ${files.length} entries — too few to be the real tree across plugin/skills/, plugin/commands/ and plugin/agents/, and the sweep below would pass vacuously over an empty or near-empty list`,
|
|
404
|
-
);
|
|
405
|
-
for (const d of ["plugin/skills/", "plugin/commands/", "plugin/agents/"]) {
|
|
406
|
-
assert.ok(
|
|
407
|
-
files.some((f) => f.startsWith(d)),
|
|
408
|
-
`${d} contributed no tracked file to the prose set — an over-narrow pathspec or filter bug can drop one whole directory without the count floor above noticing`,
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
const violations = [];
|
|
412
|
-
for (const rel of files) {
|
|
413
|
-
const text = readFileSync(join(ROOT, rel), "utf8");
|
|
414
|
-
const r = literalPathMatches(text);
|
|
415
|
-
for (const v of r.violations) {
|
|
416
|
-
const line = text.slice(0, v.index).split("\n").length;
|
|
417
|
-
violations.push(`${rel}:${line} (${v.pattern})`);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
assert.deepEqual(
|
|
421
|
-
violations,
|
|
422
|
-
[],
|
|
423
|
-
"a literal source path, harness cache path, or registry filename in prose is exactly the split-brain "
|
|
424
|
-
+ "defect ADR 0003 exists to close — route it through fleet-run instead",
|
|
425
|
-
);
|
|
426
|
-
},
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
// ---- Mutation tests: rule (b) must fail on the introduced literal and pass without it, both directions ----
|
|
430
|
-
|
|
431
|
-
test("literalPathMatches: flags a literal absolute /Users/ path", () => {
|
|
432
|
-
const r = literalPathMatches("see the log under /Users/anyone/whatever for details");
|
|
433
|
-
assert.equal(r.violations.length, 1);
|
|
434
|
-
assert.equal(r.violations[0].pattern, "absolute-Users-path");
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
test("literalPathMatches: an unrelated sentence with no literal path is clean", () => {
|
|
438
|
-
const r = literalPathMatches("run it via `fleet-run arg.mjs` from anywhere");
|
|
439
|
-
assert.deepEqual(r.violations, []);
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
test("literalPathMatches: flags the omp plugin cache path literally", () => {
|
|
443
|
-
const r = literalPathMatches("or ~/.omp/plugins/cache/plugins/fleet-plugin___fleet-ctl___0.1.1 on omp");
|
|
444
|
-
assert.equal(r.violations.length, 1);
|
|
445
|
-
assert.equal(r.violations[0].pattern, "omp-plugin-cache");
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
test("literalPathMatches: flags the registry filename literally", () => {
|
|
449
|
-
const r = literalPathMatches("read it back out of installed_plugins.json yourself");
|
|
450
|
-
assert.equal(r.violations.length, 1);
|
|
451
|
-
assert.equal(r.violations[0].pattern, "registry-filename");
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
test("literalPathMatches: a ~/dev/fleet-plugin/ callsite is a plain violation, not allowlisted", () => {
|
|
455
|
-
const r = literalPathMatches("Read `~/dev/fleet-plugin/scripts/instruments.sh` and run it.");
|
|
456
|
-
assert.equal(r.violations.length, 1);
|
|
457
|
-
assert.equal(r.violations[0].pattern, "home-dev-checkout");
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
test("literalPathMatches: a bare ~/dev/ NOT naming fleet-plugin is still a violation", () => {
|
|
461
|
-
const r = literalPathMatches("clone it into ~/dev/some-other-repo first");
|
|
462
|
-
assert.equal(r.violations.length, 1);
|
|
463
|
-
assert.equal(r.violations[0].pattern, "home-dev-checkout");
|
|
464
|
-
});
|