@feigi/fleet-ctl 3.23.35 → 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.
- package/package.json +1 -1
- 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,397 +0,0 @@
|
|
|
1
|
-
// #1599. ambient-git-vars-prose.test.mjs's own header says why it cannot see
|
|
2
|
-
// this file's subject: its scan is `readdirSync(DIR).filter(n =>
|
|
3
|
-
// n.endsWith(".sh"))` and its detector is the literal shell line `unset
|
|
4
|
-
// GIT_DIR GIT_WORK_TREE` — neither exists in a `.mjs` script, where there is
|
|
5
|
-
// no shell to `unset` in and a caller scrubs by building the CHILD's env
|
|
6
|
-
// instead. This file is the census #1020 asked to be re-derived, re-derived
|
|
7
|
-
// for the language the original could not see.
|
|
8
|
-
//
|
|
9
|
-
// Two design questions the ticket posed, and the answer each got:
|
|
10
|
-
//
|
|
11
|
-
// Detector shape. A source scan for "a spawn whose options carry a
|
|
12
|
-
// scrubbed env" has no single-line anchor the way `unset GIT_DIR
|
|
13
|
-
// GIT_WORK_TREE` is one in shell — env objects are built in as many shapes
|
|
14
|
-
// as there are call sites (compare `ledger.mjs`'s pre-existing inline
|
|
15
|
-
// `delete gitEnv.GIT_DIR` against `repo-root.mjs`'s three separate spawns,
|
|
16
|
-
// each merging its own extra keys). `git-env.mjs`'s `gitEnv()` helper turns
|
|
17
|
-
// the detector back into a one-name grep — does a file's git-invoking
|
|
18
|
-
// primitive route its env through `gitEnv(`? — the same job `unset GIT_DIR
|
|
19
|
-
// GIT_WORK_TREE` does for shell. See git-env.mjs's own header for the rest
|
|
20
|
-
// of that reasoning, including why the two pre-existing inline sites below
|
|
21
|
-
// are not retroactively migrated to call it.
|
|
22
|
-
//
|
|
23
|
-
// Per-site ruling. Six files were uncensused; measuring each (not copying
|
|
24
|
-
// one script's reason across the set — #1020's own PR found a prescribed
|
|
25
|
-
// shared reason false at one of five sites) found something #1020 did not:
|
|
26
|
-
// every one of them is exposed on AT LEAST one of the two variables, most
|
|
27
|
-
// on both, and one half being inert is the exception here, not the rule
|
|
28
|
-
// `ambient-git-vars-prose.test.mjs`'s own three `.sh` cases show. Nothing
|
|
29
|
-
// below is EXEMPT — the two-way split that file's `COVERED`/`EXEMPT`
|
|
30
|
-
// pair encodes has no membership on the EXEMPT side yet in this file, so
|
|
31
|
-
// that dict is not declared here at all; a future `.mjs` file measured
|
|
32
|
-
// inert on both variables is what would first populate it, with its own
|
|
33
|
-
// measurement, the same discipline `EXEMPT` enforces below the `COVERED`
|
|
34
|
-
// list in that file.
|
|
35
|
-
//
|
|
36
|
-
// What this file does NOT pin: per-site behaviour, or that EVERY git-naming
|
|
37
|
-
// line in a COVERED file individually reaches `gitEnv(`. That lives in each
|
|
38
|
-
// file's own test file, behaviourally — ledger.test.mjs, pr-overlap.test.mjs,
|
|
39
|
-
// repo-root.test.mjs, staleness.test.mjs — where a mutation
|
|
40
|
-
// that deletes any ONE of a multi-site file's scrub calls (repo-root.mjs
|
|
41
|
-
// carries three separate ones) reds exactly the fixture built for that site
|
|
42
|
-
// and leaves its siblings green; that per-site isolation is what a source
|
|
43
|
-
// count here cannot tell apart from a file that merely happens to mention
|
|
44
|
-
// `gitEnv(` once for an unrelated reason. What IS pinned here, as source, is
|
|
45
|
-
// the same reason `ambient-git-vars-prose.test.mjs` pins its own detector as
|
|
46
|
-
// source: the exact number of `gitEnv(` call expressions a file's own git
|
|
47
|
-
// calls need is a fact about that file, derived once below by reading it
|
|
48
|
-
// (see COVERED_MJS's own comments) and it cannot silently drop without this
|
|
49
|
-
// file noticing — a deleted call changes the count.
|
|
50
|
-
//
|
|
51
|
-
// Also pinned: the two pre-existing inline scrub sites — `fleet-state.mjs`'s
|
|
52
|
-
// `statePath()` and `ledger.mjs`'s tracker-query probe — the "two-name-only
|
|
53
|
-
// exemption list" the second design question above answers with. Neither is
|
|
54
|
-
// migrated to call `gitEnv()`: `fleet-state.mjs` is explicitly out of #1599's
|
|
55
|
-
// scope (already fixed and covered, by PR #1598) and `ledger.mjs`'s
|
|
56
|
-
// tracker-query scrub is likewise already measured and covered
|
|
57
|
-
// (`ledger.test.mjs`, "an inherited GIT_DIR or GH_REPO cannot retarget the
|
|
58
|
-
// query…") — touching either to satisfy this file's own detector would be
|
|
59
|
-
// churn with no behavioural change. `MJS_LEGACY_INLINE` records both by name
|
|
60
|
-
// with the measurement that already settled each, so a reader does not have
|
|
61
|
-
// to re-derive why they are not `gitEnv(` call sites.
|
|
62
|
-
|
|
63
|
-
import { test } from "node:test";
|
|
64
|
-
import assert from "node:assert/strict";
|
|
65
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
66
|
-
import { fileURLToPath } from "node:url";
|
|
67
|
-
import { join } from "node:path";
|
|
68
|
-
import { stripComments } from "./strip-comments.mjs";
|
|
69
|
-
|
|
70
|
-
const DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
71
|
-
const read = (f) => readFileSync(join(DIR, f), "utf8");
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* A git-invoking primitive in `.mjs` source: `spawnSync`/`execFileSync`
|
|
75
|
-
* called with the literal string `"git"`, or a same-shaped wrapper
|
|
76
|
-
* (`tryRun("git", …)`, `run("git", …)`) called the identical way — the
|
|
77
|
-
* spelling every one of this directory's git callers actually uses, measured
|
|
78
|
-
* against the whole directory (see this file's own final test). Comments are
|
|
79
|
-
* stripped first (`stripComments`), the same instrument
|
|
80
|
-
* `ambient-git-vars-prose.test.mjs`'s own `codeLines` is for its shell
|
|
81
|
-
* detector, so a call site named only in a paragraph cannot satisfy this.
|
|
82
|
-
*
|
|
83
|
-
* Deliberately NOT anchored to `spawnSync`/`execFileSync` by name: a file
|
|
84
|
-
* whose git calls all route through a locally-defined wrapper (`staleness.mjs`'s
|
|
85
|
-
* `git(args)`, called as `git(["rev-parse", …])`) never spells `"git"` as an
|
|
86
|
-
* argument at its OWN call sites — only once, where the wrapper is defined.
|
|
87
|
-
* The broader match still finds that file, through the definition line, which
|
|
88
|
-
* is all file-level discovery needs.
|
|
89
|
-
*/
|
|
90
|
-
const GIT_CALL_MJS = /\b\w+\(\s*(?:"git"|'git')/;
|
|
91
|
-
|
|
92
|
-
// Joined back into one string before testing, not tested one physical line
|
|
93
|
-
// at a time: a git-invoking call formatted across physical lines (mirrors
|
|
94
|
-
// ledger.mjs's own tracker-query `execFileSync("gh", [...], {...})` shape,
|
|
95
|
-
// its first argument and its options object each on their own line) never
|
|
96
|
-
// puts `(` and `"git"` on the same physical line, so a per-line test never
|
|
97
|
-
// sees it (measured, #1599 review) — `GIT_CALL_MJS`'s `\s*` already matches
|
|
98
|
-
// a newline; testing the whole joined string is what lets it use that.
|
|
99
|
-
const codeLines = (src) => stripComments(src).split("\n").filter((l) => l.trim() !== "");
|
|
100
|
-
|
|
101
|
-
const usesGit = (src) => GIT_CALL_MJS.test(codeLines(src).join("\n"));
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Drop a trailing `//` comment from one line. Quote-aware: `stripComments()`
|
|
105
|
-
* only blanks a comment that is its own whole line (its own documented
|
|
106
|
-
* ceiling) and leaves `code; // note` untouched, so prose merely NAMING
|
|
107
|
-
* `gitEnv(` in a trailing comment would otherwise inflate the call count
|
|
108
|
-
* below — measured (#1599 review): deleting a real `gitEnv()` scrub call
|
|
109
|
-
* while leaving a trailing comment elsewhere in the file that mentions
|
|
110
|
-
* `gitEnv(` left the count below unchanged, silently. A `//` inside a
|
|
111
|
-
* string literal (a URL) is not a comment start and must not truncate real
|
|
112
|
-
* code at it.
|
|
113
|
-
*/
|
|
114
|
-
function stripTrailingSlashComment(line) {
|
|
115
|
-
let quote = null;
|
|
116
|
-
for (let i = 0; i < line.length; i++) {
|
|
117
|
-
const c = line[i];
|
|
118
|
-
if (quote) {
|
|
119
|
-
if (c === "\\") i++;
|
|
120
|
-
else if (c === quote) quote = null;
|
|
121
|
-
} else if (c === "'" || c === '"' || c === "`") {
|
|
122
|
-
quote = c;
|
|
123
|
-
} else if (c === "/" && line[i + 1] === "/") {
|
|
124
|
-
return line.slice(0, i);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return line;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The number of real `gitEnv(` call EXPRESSIONS a file's own code carries —
|
|
132
|
-
* comments dropped at both granularities `stripComments()` covers
|
|
133
|
-
* (whole-line, block) and the one it does not (a trailing `// note`), so a
|
|
134
|
-
* comment that merely names `gitEnv(` cannot mask a deleted scrub call
|
|
135
|
-
* sitting elsewhere in the same file.
|
|
136
|
-
*/
|
|
137
|
-
const countGitEnvCalls = (src) =>
|
|
138
|
-
(codeLines(src).map(stripTrailingSlashComment).join("\n").match(/gitEnv\(/g) ?? []).length;
|
|
139
|
-
|
|
140
|
-
// The files whose git-invoking primitive(s) route their env through
|
|
141
|
-
// `gitEnv()` — this ticket's fix. Each value is the exact number of
|
|
142
|
-
// `gitEnv(` call EXPRESSIONS the file's own code carries today, derived once
|
|
143
|
-
// by reading it rather than guessed, and written out rather than computed
|
|
144
|
-
// from the git-call count above: the two numbers disagree on purpose in
|
|
145
|
-
// staleness.mjs, whose `git` wrapper is ONE spawn primitive several named
|
|
146
|
-
// call sites share, and therefore one scrub.
|
|
147
|
-
const COVERED_MJS = {
|
|
148
|
-
// Three separate `spawnSync`/`execFileSync` calls, no shared wrapper —
|
|
149
|
-
// `isTrackedBy()`, `repoRoot()`, `trackedFiles()` (behind all three of
|
|
150
|
-
// `trackedPaths()`, `trackedShellScripts()` and `trackedNodeScripts()`) —
|
|
151
|
-
// each with its own `gitEnv(…)` call. Measured per site in
|
|
152
|
-
// repo-root.test.mjs: GIT_DIR and GIT_WORK_TREE are each exposed on at
|
|
153
|
-
// least one of the three, and `isTrackedBy`'s absolute pathspec is exposed
|
|
154
|
-
// on BOTH — no half here is inert the uniform way
|
|
155
|
-
// `ambient-git-vars-prose.test.mjs`'s `inflight.sh`/`derive-testcmd.sh` are.
|
|
156
|
-
"repo-root.mjs": 3,
|
|
157
|
-
// ONE spawn primitive (`git(args)`), reused for all four of this file's
|
|
158
|
-
// named git call sites (`rev-parse --show-toplevel`, then three `-C root`
|
|
159
|
-
// calls) — one scrub for the whole set.
|
|
160
|
-
"staleness.mjs": 1,
|
|
161
|
-
// ONE spawn primitive, `trackedBasenameCounts()`'s own `git ls-files -z`.
|
|
162
|
-
"pr-overlap.mjs": 1,
|
|
163
|
-
// ONE of `ledger.mjs`'s TWO git-invoking primitives — `defaultLedgerPath()`,
|
|
164
|
-
// #1599's own measured hazard (an ambient GIT_DIR relocated the run's
|
|
165
|
-
// ledger into another repository, silently, at exit 0). The file's OTHER
|
|
166
|
-
// primitive, the tracker-query probe, is `MJS_LEGACY_INLINE` below, not a
|
|
167
|
-
// second `gitEnv(` call — it predates the helper and is already covered on
|
|
168
|
-
// its own terms.
|
|
169
|
-
"ledger.mjs": 1,
|
|
170
|
-
// ONE git-invoking primitive, `gitCommonDir()` — the probe behind #1582's
|
|
171
|
-
// cockpit instance resolution. Same hazard defaultLedgerPath() carries
|
|
172
|
-
// directly above, one seam further on: an ambient GIT_DIR answers
|
|
173
|
-
// `--git-common-dir` for a DIFFERENT repository, so the cockpit derives
|
|
174
|
-
// ITS workspace — state directory and port both — from someone else's
|
|
175
|
-
// checkout and writes board.json there, at exit 0 and in silence.
|
|
176
|
-
// Measured in board.test.mjs, "an ambient GIT_DIR cannot move the cockpit
|
|
177
|
-
// into another repository's workspace". The file's other children (gh,
|
|
178
|
-
// `node ci-state.mjs`, `--open`'s browser launcher) go through `tryRun` or
|
|
179
|
-
// `openBrowser`, which name no git and are not git-invoking primitives.
|
|
180
|
-
"board.mjs": 1,
|
|
181
|
-
// ONE git-invoking primitive, `readInstruments()`'s `rev-parse
|
|
182
|
-
// --git-common-dir`, which names the checkout instruments.sh is sent to
|
|
183
|
-
// audit. An ambient GIT_DIR answers it for a DIFFERENT repository, so the
|
|
184
|
-
// gate would certify that tree's instrument set, at exit 0. Measured in
|
|
185
|
-
// merge-gate.test.mjs, "an ambient GIT_DIR cannot move the audited
|
|
186
|
-
// instrument set into another repository". Its other children (gh,
|
|
187
|
-
// `node ci-state.mjs`, `sh instruments.sh`) name no git.
|
|
188
|
-
"merge-gate.mjs": 1,
|
|
189
|
-
// TWO git-invoking primitives. `shortlistPath()`'s `--git-common-dir` probe —
|
|
190
|
-
// defaultLedgerPath()'s resolution for `.fleet/shortlist.json` (#1798) —
|
|
191
|
-
// carries the hazard of writing the run's shortlist into another
|
|
192
|
-
// repository's workspace; measured in shortlist.test.mjs, "an ambient
|
|
193
|
-
// GIT_DIR naming another repository cannot move the shortlist there".
|
|
194
|
-
// `probeState()`'s `gh … view` call carries the identical hazard one layer
|
|
195
|
-
// up — gh's own remote resolution follows GIT_DIR/GIT_WORK_TREE too
|
|
196
|
-
// (ledger.mjs's tracker-query probe measured this first, and GH_REPO
|
|
197
|
-
// besides) — so an ambient GIT_DIR could flip a blocker or
|
|
198
|
-
// exclusion-premise verdict while the shortlist file still lands in the
|
|
199
|
-
// right workspace; measured in shortlist.test.mjs, "an inherited GIT_DIR
|
|
200
|
-
// cannot retarget probeState's gh calls to another repository". Its other
|
|
201
|
-
// children (`node candidates.mjs`, `node ledger.mjs`, `sh inflight.sh`)
|
|
202
|
-
// name no git.
|
|
203
|
-
"shortlist.mjs": 2,
|
|
204
|
-
// FOUR. The first two are the pair shortlist.mjs carries (#1803), the
|
|
205
|
-
// third is below (#2485), the fourth after it. `shortlistPath()`'s
|
|
206
|
-
// `--git-common-dir` probe names the `.fleet/shortlist.json` the tick PULLs
|
|
207
|
-
// from; an ambient GIT_DIR would read another repository's shortlist and
|
|
208
|
-
// name its tickets. Measured in fleet-tick.test.mjs, "an ambient GIT_DIR
|
|
209
|
-
// naming another repository cannot move the shortlist read".
|
|
210
|
-
// `liftedPremise()`'s `gh issue view` asks whether a `behind-issue:#M`
|
|
211
|
-
// premise has closed, and gh's remote resolution follows GIT_DIR too;
|
|
212
|
-
// measured in fleet-tick.test.mjs, "an inherited GIT_DIR cannot retarget
|
|
213
|
-
// the behind-issue premise probe". Its other children (`gh pr list`,
|
|
214
|
-
// `node ledger.mjs`, `node shortlist.mjs`) are not git-invoking primitives.
|
|
215
|
-
// `closedTickets()`'s `gh issue view` asks whether a tier-mismatched
|
|
216
|
-
// implementer's ticket is already closed, and resolves the repository the
|
|
217
|
-
// same way; measured in fleet-tick.test.mjs, "an inherited GIT_DIR cannot
|
|
218
|
-
// retarget the tier-mismatch closed-ticket probe".
|
|
219
|
-
// `finishedReviewPrs()`'s `gh pr view` asks whether a PR with a dangling
|
|
220
|
-
// in-flight review is already merged or closed, and resolves the repository
|
|
221
|
-
// the same way; measured in fleet-tick.test.mjs, "an inherited GIT_DIR
|
|
222
|
-
// cannot retarget the merged-PR review probe".
|
|
223
|
-
"fleet-tick.mjs": 4,
|
|
224
|
-
// ONE spawn primitive, `git(args, cwd)`, behind both of the file's git calls
|
|
225
|
-
// — `resolveMainRoot()`'s `rev-parse --git-common-dir` and `checkIgnored()`'s
|
|
226
|
-
// `check-ignore` (#1411). An ambient GIT_DIR would answer the first for
|
|
227
|
-
// another repository, so the guard would compare a member's write against
|
|
228
|
-
// the wrong checkout and let a main-checkout write through. Measured in
|
|
229
|
-
// member-write-guard.test.mjs, "an ambient GIT_DIR naming another repository
|
|
230
|
-
// does not change the answer".
|
|
231
|
-
"member-write-guard.mjs": 1,
|
|
232
|
-
// ONE spawn primitive, `git(what, args, cwd, env)`, behind both of the
|
|
233
|
-
// file's git calls — `resolveMainCheckout()`'s `rev-parse --git-common-dir`
|
|
234
|
-
// and `snapshot()`'s `status --porcelain -uall` (#2210). An ambient GIT_DIR
|
|
235
|
-
// would answer both for another repository, so the tick would compare —
|
|
236
|
-
// and `--record` would baseline — the wrong tree. Measured in
|
|
237
|
-
// main-checkout.test.mjs, "an ambient GIT_DIR naming another repository
|
|
238
|
-
// does not change the answer (#1599)".
|
|
239
|
-
"main-checkout.mjs": 1,
|
|
240
|
-
// ONE spawn primitive, `git(repo, args, what)`, behind all four of the
|
|
241
|
-
// file's git calls — the merge-base against `origin/main`, the diff the
|
|
242
|
-
// touched lines come from, `rev-parse --show-toplevel` (#2342), and
|
|
243
|
-
// `rev-parse --git-common-dir`, which locates the ledger. An ambient GIT_DIR
|
|
244
|
-
// would answer all four for another repository and judge the record against
|
|
245
|
-
// that repository's diff and write its verdict to that repository's ledger.
|
|
246
|
-
// Measured in dispositions-check.test.mjs, "an ambient GIT_DIR naming
|
|
247
|
-
// another repository does not change the answer" (the diff and merge-base)
|
|
248
|
-
// and "… does not change which ledger is found" (the common dir).
|
|
249
|
-
"dispositions-check.mjs": 1,
|
|
250
|
-
// ONE scrubbed env, built once and handed to every child — the `git(args,
|
|
251
|
-
// cwd)` primitive behind the common-dir, origin/main, worktree, status and
|
|
252
|
-
// diff calls, AND the one `sh -c` runner of the Install step, the Test
|
|
253
|
-
// entrypoint and the mutation. An ambient GIT_DIR would answer the first for
|
|
254
|
-
// another repository and run the Recipe against that repository's tree while
|
|
255
|
-
// the cache landed here. Measured in recipe-prove.test.mjs, "an ambient
|
|
256
|
-
// GIT_DIR naming another repository does not change the answer" (the git
|
|
257
|
-
// primitive) and "the Install step and the Test entrypoint run against their
|
|
258
|
-
// own worktree whatever GIT_DIR the caller exports" (the `sh -c` runner). The
|
|
259
|
-
// cache reader child gets the same env but unsets both itself, so no
|
|
260
|
-
// fixture can tell its env apart.
|
|
261
|
-
"recipe-prove.mjs": 1,
|
|
262
|
-
// TWO scrubbed children. `defaultGuardPath()`'s `rev-parse --git-common-dir`
|
|
263
|
-
// names the workspace the guard file is written into: an ambient GIT_DIR
|
|
264
|
-
// would answer for ANOTHER repository, and the verdict would land in its
|
|
265
|
-
// `.fleet/` at exit 0 while fleet-tick reads this one's. Measured in
|
|
266
|
-
// pr-cost.test.mjs, "an ambient GIT_DIR naming another repository cannot move
|
|
267
|
-
// the guard file out of the repository pr-cost runs in". The `gh pr list`
|
|
268
|
-
// child is the second: gh's remote resolution follows GIT_DIR too (measured
|
|
269
|
-
// for shortlist.mjs's `probeState()` above), so merged state could be read
|
|
270
|
-
// for another repository's PRs; the gh stub in pr-cost.test.mjs, "an ambient
|
|
271
|
-
// GIT_DIR does not reach the gh child that reads merged state", records
|
|
272
|
-
// that the child sees no GIT_DIR.
|
|
273
|
-
"pr-cost.mjs": 2,
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
// The two-name-only exemption list #1599's second design question answers
|
|
277
|
-
// with: sites that scrub GIT_DIR/GIT_WORK_TREE without calling `gitEnv()`,
|
|
278
|
-
// because each already carries its own measurement and its own behavioural
|
|
279
|
-
// fixture, predating this helper, and retrofitting either to satisfy this
|
|
280
|
-
// file's detector would be churn with no behavioural change.
|
|
281
|
-
const MJS_LEGACY_INLINE = {
|
|
282
|
-
"fleet-state.mjs":
|
|
283
|
-
"statePath() — `{ ...process.env }` then two `delete`s, inline. Fixed and covered by PR #1598 " +
|
|
284
|
-
"(fleet-heartbeat.test.mjs); out of #1599's scope by the ticket's own words.",
|
|
285
|
-
"ledger.mjs":
|
|
286
|
-
"the tracker-query probe inside runCheck() — `const queryEnv = { ...process.env, GH_REPO: \"\" }` then two " +
|
|
287
|
-
"`delete`s, inline (predates this directory's `gitEnv()` helper; renamed from `gitEnv` to `queryEnv` so the " +
|
|
288
|
-
"local no longer shadows the module-level import). " +
|
|
289
|
-
"Measured and covered in ledger.test.mjs, \"an inherited GIT_DIR or GH_REPO cannot retarget the query…\".",
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
for (const [f, count] of Object.entries(COVERED_MJS)) {
|
|
293
|
-
test(`${f} routes its git call(s) through gitEnv(), ${count} call site(s)`, () => {
|
|
294
|
-
const src = read(f);
|
|
295
|
-
assert.ok(usesGit(src),
|
|
296
|
-
`${f} appears to invoke no git at all, so this assertion would hold vacuously — either the file stopped using git (move it out of COVERED_MJS) or GIT_CALL_MJS no longer recognises the spelling it uses`);
|
|
297
|
-
const actual = countGitEnvCalls(src);
|
|
298
|
-
assert.equal(actual, count,
|
|
299
|
-
`${f} carries ${actual} \`gitEnv(\` call(s), expected ${count}. A lower count means a scrub was deleted from one of this ` +
|
|
300
|
-
"file's git-invoking primitives — see this file's own header comment for which call sites exist and why each needs one. " +
|
|
301
|
-
"A higher count is a call site COVERED_MJS does not know about yet; update the count here once its own behavioural fixture exists.");
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
for (const [f, reason] of Object.entries(MJS_LEGACY_INLINE)) {
|
|
306
|
-
test(`${f}'s legacy inline scrub is recorded with its own measurement`, () => {
|
|
307
|
-
assert.ok(usesGit(read(f)), `${f} is recorded in MJS_LEGACY_INLINE but no longer invokes git — delete the entry`);
|
|
308
|
-
assert.ok(reason.length > 40, `${f}'s MJS_LEGACY_INLINE entry must carry the measurement that settled it, not a placeholder`);
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// The unaccounted computation the closing census test below needs, factored
|
|
313
|
-
// out so a regression fixture can drive it with a synthetic `scripts`/`read`
|
|
314
|
-
// pair instead of writing a throwaway file into this real directory.
|
|
315
|
-
const unaccountedGitUsers = (scripts, readSrc, accounted) =>
|
|
316
|
-
scripts.filter((f) => usesGit(readSrc(f))).filter((f) => !accounted.has(f));
|
|
317
|
-
|
|
318
|
-
// The census, and the reason it is a test rather than a paragraph — the same
|
|
319
|
-
// reason `ambient-git-vars-prose.test.mjs`'s own closing test gives: a new
|
|
320
|
-
// `.mjs` script that shells out to git now has to make a decision — call
|
|
321
|
-
// `gitEnv()` and add it to COVERED_MJS with its own behavioural fixture, or
|
|
322
|
-
// record why not — instead of inheriting the exposure by default.
|
|
323
|
-
test("every .mjs script that invokes git either routes through gitEnv() or is recorded on the legacy-inline list", () => {
|
|
324
|
-
const scripts = readdirSync(DIR).filter((n) => n.endsWith(".mjs") && !n.endsWith(".test.mjs")).sort();
|
|
325
|
-
assert.ok(scripts.length > 0, "fixture: no .mjs files found, so this scan would pass over nothing");
|
|
326
|
-
|
|
327
|
-
const accounted = new Set([...Object.keys(COVERED_MJS), ...Object.keys(MJS_LEGACY_INLINE)]);
|
|
328
|
-
const unaccounted = unaccountedGitUsers(scripts, read, accounted);
|
|
329
|
-
|
|
330
|
-
assert.deepEqual(unaccounted, [],
|
|
331
|
-
"a .mjs file invokes git and is neither in COVERED_MJS nor MJS_LEGACY_INLINE: route its call(s) through " +
|
|
332
|
-
"git-env.mjs's gitEnv(), add it to COVERED_MJS with the number of gitEnv( call sites and a behavioural fixture " +
|
|
333
|
-
"in its own test file per call site (measured, not copied from another file's reason) — or, if an ambient " +
|
|
334
|
-
"GIT_DIR/GIT_WORK_TREE measurably cannot make every one of its git calls answer wrongly, record it with that " +
|
|
335
|
-
"measurement instead. Do not simply widen either list.");
|
|
336
|
-
|
|
337
|
-
// Every COVERED_MJS/MJS_LEGACY_INLINE entry must really be a git-invoking
|
|
338
|
-
// .mjs file in this directory, or a rename/removal would leave its entry
|
|
339
|
-
// pinning a file the scan above no longer sees.
|
|
340
|
-
for (const f of accounted) {
|
|
341
|
-
assert.ok(scripts.includes(f), `${f} is recorded above but is not a .mjs file in this directory`);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
// Regression (#1599 review, finding 1): the count above must not be fooled
|
|
346
|
-
// by a comment that merely NAMES `gitEnv(` — measured live, deleting a real
|
|
347
|
-
// scrub call from repo-root.mjs while leaving a trailing `// gitEnv(x)...`
|
|
348
|
-
// comment elsewhere in the file left the whole census suite green.
|
|
349
|
-
test("a trailing comment naming gitEnv( cannot mask a deleted scrub call", () => {
|
|
350
|
-
const withCall = 'import { gitEnv } from "./git-env.mjs";\n' +
|
|
351
|
-
'import { spawnSync } from "node:child_process";\n' +
|
|
352
|
-
"\n" +
|
|
353
|
-
"export function probe() {\n" +
|
|
354
|
-
' return spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf8", env: gitEnv() });\n' +
|
|
355
|
-
"}\n";
|
|
356
|
-
const scrubDeleted = 'import { spawnSync } from "node:child_process";\n' +
|
|
357
|
-
"\n" +
|
|
358
|
-
"export function probe() {\n" +
|
|
359
|
-
' return spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf8" }); // gitEnv(x) trailing comment, should not count\n' +
|
|
360
|
-
"}\n";
|
|
361
|
-
assert.equal(countGitEnvCalls(withCall), 1,
|
|
362
|
-
"a real gitEnv() call must be counted once");
|
|
363
|
-
assert.equal(countGitEnvCalls(scrubDeleted), 0,
|
|
364
|
-
"deleting a real gitEnv() scrub call must drop the count to 0 even when a trailing comment elsewhere in the " +
|
|
365
|
-
"file still mentions gitEnv( — the count must not be fooled by prose naming the function");
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
// Regression (#1599 review, finding 2): the git-call detector must not go
|
|
369
|
-
// blind on a call formatted across physical lines — measured live, a new
|
|
370
|
-
// script with a multi-line git spawn and no gitEnv()/legacy-inline entry
|
|
371
|
-
// passed the census (8/8) when it should have failed it.
|
|
372
|
-
test("a new .mjs file with a MULTI-LINE git-spawning call and no gitEnv()/legacy-inline entry fails the census", () => {
|
|
373
|
-
// Mirrors ledger.mjs's own tracker-query `execFileSync("gh", [...], {...})`
|
|
374
|
-
// shape: the callee's first argument and its options object each sit on
|
|
375
|
-
// their own physical line, so `(` and `"git"` never share one.
|
|
376
|
-
const multiLineGitCall = 'import { execFileSync } from "node:child_process";\n' +
|
|
377
|
-
"\n" +
|
|
378
|
-
"export function probe(root) {\n" +
|
|
379
|
-
" return execFileSync(\n" +
|
|
380
|
-
' "git",\n' +
|
|
381
|
-
' ["rev-parse", "--show-toplevel"],\n' +
|
|
382
|
-
' { cwd: root, encoding: "utf8" },\n' +
|
|
383
|
-
" );\n" +
|
|
384
|
-
"}\n";
|
|
385
|
-
|
|
386
|
-
assert.ok(usesGit(multiLineGitCall),
|
|
387
|
-
"a git call split across physical lines must still be detected");
|
|
388
|
-
|
|
389
|
-
const scripts = ["repo-root.mjs", "new-uncensused.mjs"];
|
|
390
|
-
const sources = { "repo-root.mjs": read("repo-root.mjs"), "new-uncensused.mjs": multiLineGitCall };
|
|
391
|
-
const accounted = new Set([...Object.keys(COVERED_MJS), ...Object.keys(MJS_LEGACY_INLINE)]);
|
|
392
|
-
const unaccounted = unaccountedGitUsers(scripts, (f) => sources[f], accounted);
|
|
393
|
-
|
|
394
|
-
assert.deepEqual(unaccounted, ["new-uncensused.mjs"],
|
|
395
|
-
"a new .mjs file with a multi-line git-spawning call and no gitEnv()/legacy-inline entry must fail the " +
|
|
396
|
-
"census, not pass over it invisibly");
|
|
397
|
-
});
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
// #1020. Seven scripts carry `unset GIT_DIR GIT_WORK_TREE`, and for four of
|
|
2
|
-
// them one HALF of that line has no behavioural detector at all.
|
|
3
|
-
//
|
|
4
|
-
// That is the gap this file exists for, and it is measured, not assumed.
|
|
5
|
-
// GIT_DIR and GIT_WORK_TREE break a script through different call sites, so
|
|
6
|
-
// whether a given script can SHOW the damage depends on which calls it makes:
|
|
7
|
-
//
|
|
8
|
-
// inflight.sh, derive-testcmd.sh — GIT_WORK_TREE is inert. Their git calls
|
|
9
|
-
// read refs and the object database (`for-each-ref`, `ls-remote`,
|
|
10
|
-
// `worktree list`, `ls-tree`, `show`); none consults a work tree, so no
|
|
11
|
-
// ambient value changes a byte of output.
|
|
12
|
-
// instruments.sh — GIT_DIR is inert. `ls-files` only names
|
|
13
|
-
// paths, and both the digest and the baseline are read from files on
|
|
14
|
-
// disk.
|
|
15
|
-
// release-ticket.sh — GIT_DIR does not misdirect its `-C`
|
|
16
|
-
// calls (recorded in release-ticket.test.mjs's own #427 pair).
|
|
17
|
-
//
|
|
18
|
-
// A behavioural fixture for an inert half can only be vacuous, which is the
|
|
19
|
-
// exact failure PR #1015 measured and this ticket was filed to avoid. So the
|
|
20
|
-
// halves that CAN be measured are pinned behaviourally, in each script's own
|
|
21
|
-
// test file, one fixture per variable; and the line itself is pinned here, as
|
|
22
|
-
// source, so the inert half cannot be quietly dropped by an editor who tries
|
|
23
|
-
// deleting it and finds the suite still green. Same instrument, same reason,
|
|
24
|
-
// as locale-pin-prose.test.mjs: some corrections have no behavioural shadow on
|
|
25
|
-
// the platform CI runs, and a source assertion is what is left.
|
|
26
|
-
//
|
|
27
|
-
// What this file does NOT pin: per-script behaviour. That lives in
|
|
28
|
-
// claim-ticket.test.mjs, derive-testcmd.test.mjs, inflight.test.mjs,
|
|
29
|
-
// instruments.test.mjs, no-undo-audit.test.mjs, reap.test.mjs,
|
|
30
|
-
// release-ticket.test.mjs and worktree-audit.test.mjs, and eleven fixtures
|
|
31
|
-
// across them go red when the corresponding half is deleted.
|
|
32
|
-
//
|
|
33
|
-
// Also not pinned, and stated rather than left to be noticed: the `.mjs`
|
|
34
|
-
// scripts in this directory. The scan below is `.sh`-only and the detector is a
|
|
35
|
-
// shell line, so a Node caller's hazard and its remedy — an env object built
|
|
36
|
-
// for the child, since there is no shell to `unset` in — are both invisible
|
|
37
|
-
// here, and "a NEW script cannot join the exposed set in silence" holds for
|
|
38
|
-
// shell only. `ambient-git-vars-mjs-prose.test.mjs` carries that census
|
|
39
|
-
// (#1599): `ledger.mjs`'s default ledger path was the one measured-exposed
|
|
40
|
-
// site, and every one of the six uncensused `.mjs` git callers now routes
|
|
41
|
-
// through `git-env.mjs`'s `gitEnv()` helper or is recorded there by name,
|
|
42
|
-
// the way `EXEMPT` above records a `.sh` script's own settled measurement.
|
|
43
|
-
// `fleet-state.mjs`'s own `rev-parse --git-common-dir` call scrubs both
|
|
44
|
-
// variables inline (predating that helper) and has a behavioural fixture in
|
|
45
|
-
// fleet-heartbeat.test.mjs.
|
|
46
|
-
|
|
47
|
-
import { test } from "node:test";
|
|
48
|
-
import assert from "node:assert/strict";
|
|
49
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
50
|
-
import { fileURLToPath } from "node:url";
|
|
51
|
-
import { join } from "node:path";
|
|
52
|
-
|
|
53
|
-
const DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
54
|
-
const read = (f) => readFileSync(join(DIR, f), "utf8");
|
|
55
|
-
|
|
56
|
-
const LINE = "unset GIT_DIR GIT_WORK_TREE";
|
|
57
|
-
|
|
58
|
-
// The scripts that carry the line. Written out rather than globbed, for the
|
|
59
|
-
// reason locale-pin-prose.test.mjs writes its own list out: adding a script
|
|
60
|
-
// here is a decision, and a glob would make it an accident.
|
|
61
|
-
const COVERED = [
|
|
62
|
-
"claim-ticket.sh",
|
|
63
|
-
"derive-testcmd.sh",
|
|
64
|
-
"inflight.sh",
|
|
65
|
-
"instruments.sh",
|
|
66
|
-
"no-undo-audit.sh",
|
|
67
|
-
"reap.sh",
|
|
68
|
-
"release-ticket.sh",
|
|
69
|
-
"worktree-audit.sh",
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
// The scripts that invoke git and deliberately do NOT carry it, each with the
|
|
73
|
-
// measurement or the reason that settled it. This is the census #1020 asked to
|
|
74
|
-
// be re-derived, written down so the next person does not have to re-derive it
|
|
75
|
-
// from scratch — and so a NEW script cannot join the exposed set in silence,
|
|
76
|
-
// which is exactly how the prose numbers on that ticket had drifted.
|
|
77
|
-
const EXEMPT = {
|
|
78
|
-
"net.sh":
|
|
79
|
-
"a library, sourced into someone else's shell — `unset` there would reach back into the caller's environment for every later command in it, which is the caller's decision to make. Every entrypoint that sources it (reap.sh, inflight.sh) unsets on its own account.",
|
|
80
|
-
"worktree.sh":
|
|
81
|
-
"a library, for the same reason as net.sh. All four of its callers — claim-ticket.sh, reap.sh, worktree-audit.sh, release-ticket.sh — carry the line.",
|
|
82
|
-
"prove-merge.sh":
|
|
83
|
-
"measured (#1020): with an ambient GIT_DIR naming an unrelated repository, `git cat-file -e \"${obj}^{commit}\"` cannot resolve the argument and the run REFUSES at exit 2 in its own voice. Never a wrong verdict, which is the whole class. GIT_WORK_TREE is inert — every call is an object-database read.",
|
|
84
|
-
"verify-sha.sh":
|
|
85
|
-
"measured (#1020): same shape as prove-merge.sh — an ambient GIT_DIR naming an unrelated repository refuses at exit 2 (`cannot resolve <sha> to a commit`) rather than certifying anything. GIT_WORK_TREE is inert for the same reason.",
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* A `git` invocation in shell code: line start, or immediately after a shell
|
|
90
|
-
* operator, a command substitution, or a compound-command keyword.
|
|
91
|
-
*
|
|
92
|
-
* Not a bare `/git /`: this file's whole job is locating the FIRST real call,
|
|
93
|
-
* and the scripts echo their own commands for the operator (`echo "$ git
|
|
94
|
-
* fetch --prune origin"`, `printf ' would: git worktree add …'`). A bare
|
|
95
|
-
* match lands on one of those, several lines above the code, and the
|
|
96
|
-
* ordering assertion below would then be pinning a string in a message.
|
|
97
|
-
*/
|
|
98
|
-
const GIT_CALL = /(?:^|[;&|(]\s*|\$\(\s*|!\s+|\b(?:if|elif|then|else|do|while|until)\s+)git\s/;
|
|
99
|
-
|
|
100
|
-
/** Code lines only — comments and blanks cannot invoke anything. */
|
|
101
|
-
const codeLines = (src) =>
|
|
102
|
-
src.split("\n")
|
|
103
|
-
.map((l, i) => ({ n: i + 1, l }))
|
|
104
|
-
.filter(({ l }) => l.trim() !== "" && !/^\s*#/.test(l));
|
|
105
|
-
|
|
106
|
-
const firstGitCall = (src) => codeLines(src).find(({ l }) => GIT_CALL.test(l)) ?? null;
|
|
107
|
-
|
|
108
|
-
for (const f of COVERED) {
|
|
109
|
-
test(`${f} unsets both ambient git variables, ahead of every git call`, () => {
|
|
110
|
-
const src = read(f);
|
|
111
|
-
const lines = src.split("\n");
|
|
112
|
-
|
|
113
|
-
// BOTH names on ONE line, and exactly one such line. Spelled as an
|
|
114
|
-
// equality against the whole line rather than a `/unset GIT_DIR/` match,
|
|
115
|
-
// because the failure this guards is `unset GIT_DIR` alone surviving a
|
|
116
|
-
// cleanup — which every substring match on either name still passes.
|
|
117
|
-
const at = lines.indexOf(LINE);
|
|
118
|
-
assert.notEqual(at, -1,
|
|
119
|
-
`${f} lost \`${LINE}\`. Whichever half is inert in this script today has no behavioural test that can tell, and the other half's fixtures pass on a line that unsets only one of the two.`);
|
|
120
|
-
assert.equal(lines.filter((l) => l === LINE).length, 1,
|
|
121
|
-
`${f} carries \`${LINE}\` more than once — one of them is unreachable or redundant, and a reader cannot tell which is the live one`);
|
|
122
|
-
|
|
123
|
-
// The property that actually matters. An unset BELOW the calls it protects
|
|
124
|
-
// is not a fix, exactly as a locale pin below its own pipelines is not a
|
|
125
|
-
// pin — and presence alone stays green on that mutant.
|
|
126
|
-
const git = firstGitCall(src);
|
|
127
|
-
assert.ok(git,
|
|
128
|
-
`${f} appears to invoke no git at all, so this assertion would hold vacuously. Either the script stopped using git — in which case it belongs in EXEMPT, not COVERED — or GIT_CALL no longer recognises the spelling it uses.`);
|
|
129
|
-
assert.ok(at + 1 < git.n,
|
|
130
|
-
`${f} unsets the ambient git variables at line ${at + 1}, but line ${git.n} already runs git above it: ${JSON.stringify(git.l)}`);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// #1020's remedy names a placement, not just a presence, and the placement is
|
|
135
|
-
// forced from both sides. Below, because locale-pin-prose.test.mjs's PROLOGUE
|
|
136
|
-
// regex admits only comments, blanks and `set -[eux]+` above the locale pin
|
|
137
|
-
// and would refuse an `unset` there. DIRECTLY below, because anything else
|
|
138
|
-
// that crept between the two would be work running under neither correction
|
|
139
|
-
// — the same argument the locale pin makes for itself, applied to the `unset`
|
|
140
|
-
// it now shelters.
|
|
141
|
-
//
|
|
142
|
-
// claim-ticket.sh and instruments.sh are absent here and that is not an
|
|
143
|
-
// oversight: neither carries a locale pin (both are deliberately off
|
|
144
|
-
// locale-pin-prose.test.mjs's own PINNED list), so there is nothing for their
|
|
145
|
-
// line to sit under and the ordering assertion above is the whole constraint.
|
|
146
|
-
const PINNED_TOO = COVERED.filter((f) => !["claim-ticket.sh", "instruments.sh"].includes(f));
|
|
147
|
-
|
|
148
|
-
for (const f of PINNED_TOO) {
|
|
149
|
-
test(`${f} unsets directly below its locale pin, with nothing working in between`, () => {
|
|
150
|
-
const lines = read(f).split("\n");
|
|
151
|
-
const pin = lines.findIndex((l) => /^export LC_ALL=C\b/.test(l));
|
|
152
|
-
assert.notEqual(pin, -1,
|
|
153
|
-
`${f} lost its locale pin, so this file's placement claim no longer has an anchor; locale-pin-prose.test.mjs owns that failure`);
|
|
154
|
-
|
|
155
|
-
const next = lines.slice(pin + 1).find((l) => l.trim() !== "" && !/^\s*#/.test(l));
|
|
156
|
-
assert.equal(next, LINE,
|
|
157
|
-
`${f}'s first working line below \`export LC_ALL=C\` is ${JSON.stringify(next)}, not \`${LINE}\`. Anything inserted between the two runs under neither correction.`);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// The census, and the reason it is a test rather than a paragraph: #1020's own
|
|
162
|
-
// prose numbers had drifted by the time anyone acted on them, because nothing
|
|
163
|
-
// re-derived them. A new script that shells out to git now has to make a
|
|
164
|
-
// decision — carry the line, or record why not — instead of inheriting the
|
|
165
|
-
// exposure by default.
|
|
166
|
-
test("every script that invokes git either unsets the ambient variables or is exempt on the record", () => {
|
|
167
|
-
const scripts = readdirSync(DIR).filter((n) => n.endsWith(".sh")).sort();
|
|
168
|
-
assert.ok(scripts.length > 0, "fixture: no .sh files found, so this scan would pass over nothing");
|
|
169
|
-
|
|
170
|
-
const usesGit = scripts.filter((f) => firstGitCall(read(f)) !== null);
|
|
171
|
-
const uncovered = usesGit.filter((f) => !COVERED.includes(f));
|
|
172
|
-
|
|
173
|
-
assert.deepEqual(uncovered.sort(), Object.keys(EXEMPT).sort(),
|
|
174
|
-
`a script that invokes git is neither in COVERED nor in EXEMPT. Add \`${LINE}\` below its locale pin (or below \`set -eu\` if it has none) and a behavioural fixture for each half that reproduces; or, if an ambient variable measurably cannot make it answer wrongly, add it to EXEMPT with that measurement. Do not simply widen this list.`);
|
|
175
|
-
|
|
176
|
-
// The other direction, so a script cannot be listed as exempt after it has
|
|
177
|
-
// stopped using git — a stale entry reads as a considered exemption and is
|
|
178
|
-
// really just a name nobody removed.
|
|
179
|
-
for (const f of Object.keys(EXEMPT)) {
|
|
180
|
-
assert.ok(usesGit.includes(f),
|
|
181
|
-
`${f} is recorded as exempt from \`${LINE}\` but no longer invokes git — delete the entry rather than leaving a justification for a hazard that is gone`);
|
|
182
|
-
assert.ok(EXEMPT[f].length > 40,
|
|
183
|
-
`${f}'s exemption must carry the measurement or the reason that settled it, not a placeholder`);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Every COVERED script must really be in the scanned set, or a rename would
|
|
187
|
-
// leave its entry pinning a file that no longer exists while every
|
|
188
|
-
// assertion above skipped it.
|
|
189
|
-
for (const f of COVERED) {
|
|
190
|
-
assert.ok(scripts.includes(f), `${f} is listed in COVERED but is not a .sh file in this directory`);
|
|
191
|
-
}
|
|
192
|
-
});
|