@futurelastic/colab-handbook 1.12.0-rc.16 → 1.12.0-rc.18
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/tools/colab +42 -14
- package/tools/lib/git.js +20 -1
- package/tools/lib/group-labels.js +65 -0
- package/tools/lib/hermetic.js +72 -6
package/package.json
CHANGED
package/tools/colab
CHANGED
|
@@ -2398,7 +2398,7 @@ function cmdGateRecorded(argv) {
|
|
|
2398
2398
|
// `live-env:`.
|
|
2399
2399
|
// ---------------------------------------------------------------------------
|
|
2400
2400
|
|
|
2401
|
-
const HELP_GATE_HERMETIC = `colab gate-hermetic [--net auto|on] [--keep VAR,...] [--json] [--verbose] [--repo <path>] -- <test command...>
|
|
2401
|
+
const HELP_GATE_HERMETIC = `colab gate-hermetic [--net auto|on] [--keep VAR,...] [--no-pin] [--json] [--verbose] [--repo <path>] -- <test command...>
|
|
2402
2402
|
|
|
2403
2403
|
Runs the repo's TEST STEP twice and gives one verdict (#403, code-wrap A3):
|
|
2404
2404
|
|
|
@@ -2408,7 +2408,11 @@ Runs the repo's TEST STEP twice and gives one verdict (#403, code-wrap A3):
|
|
|
2408
2408
|
daemon/fleet runtime unset (*_URL *_HOST *_PORT *_TOKEN *_KEY *_SECRET *_SOCK
|
|
2409
2409
|
COLAB_* CLAUDE* GH_* …); network off where the platform allows it —
|
|
2410
2410
|
macOS sandbox-exec, Linux unshare --net (loopback stays up in both) — and the
|
|
2411
|
-
line saying which is always printed.
|
|
2411
|
+
line saying which is always printed. Toolchain-manager homes you have NOT set
|
|
2412
|
+
(RUSTUP_HOME CARGO_HOME PYENV_ROOT RBENV_ROOT ASDF_DATA_DIR NVM_DIR VOLTA_HOME
|
|
2413
|
+
MISE_DATA_DIR GOPATH) are pinned to their real directory first, when it exists,
|
|
2414
|
+
so a rustup/pyenv/asdf proxy still finds the installed toolchain instead of
|
|
2415
|
+
trying to download one (#447). Every pin is printed.
|
|
2412
2416
|
|
|
2413
2417
|
Verdicts (exit 0 = may count as green, 1 = not):
|
|
2414
2418
|
green both runs passed exit 0
|
|
@@ -2425,6 +2429,8 @@ pass \`-- sh -c '…'\` for pipes or &&.
|
|
|
2425
2429
|
--net on do not cut the network (reported); default auto = best effort
|
|
2426
2430
|
--keep A,B pass these variables through to the hermetic run anyway — printed in the
|
|
2427
2431
|
verdict, so a pass-through is never silent
|
|
2432
|
+
--no-pin do not pin toolchain-manager homes: the strict run, for a suite suspected of
|
|
2433
|
+
reading a manager's own config or package cache (~/.cargo/config.toml, …)
|
|
2428
2434
|
--json one JSON object instead of the text verdict
|
|
2429
2435
|
--verbose print each run's full output (default: failing names + a short tail on red)
|
|
2430
2436
|
--repo <path> working tree to run in (default: cwd)
|
|
@@ -2440,7 +2446,7 @@ function cmdGateHermetic(argv) {
|
|
|
2440
2446
|
const cmd = dd === -1 ? [] : argv.slice(dd + 1);
|
|
2441
2447
|
const opts = parseArgs(own, {
|
|
2442
2448
|
values: { '--repo': 'repo', '--net': 'net', '--keep': 'keep' },
|
|
2443
|
-
flags: { '--json': 'json', '--verbose': 'verbose', '-h': 'help', '--help': 'help' },
|
|
2449
|
+
flags: { '--json': 'json', '--verbose': 'verbose', '--no-pin': 'noPin', '-h': 'help', '--help': 'help' },
|
|
2444
2450
|
});
|
|
2445
2451
|
if (opts.help) return print(HELP_GATE_HERMETIC);
|
|
2446
2452
|
if (opts._.length) throw new UserError(`unexpected argument "${opts._[0]}" — the test command goes after \`--\` (see --help)`);
|
|
@@ -2488,7 +2494,10 @@ function cmdGateHermetic(argv) {
|
|
|
2488
2494
|
if (normal.ok && !skip) {
|
|
2489
2495
|
homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'colab-hermetic-home-'));
|
|
2490
2496
|
try {
|
|
2491
|
-
|
|
2497
|
+
const pins = opts.noPin ? [] : hermetic.toolchainPins(process.env, (d) => {
|
|
2498
|
+
try { return fs.statSync(d).isDirectory(); } catch (_) { return false; }
|
|
2499
|
+
});
|
|
2500
|
+
envInfo = hermetic.hermeticEnv(process.env, homeDir, keep, { pins });
|
|
2492
2501
|
net = hermetic.probeNetworkIsolation({
|
|
2493
2502
|
platform: process.platform, mode: netMode,
|
|
2494
2503
|
run: (c, a) => spawnSync(c, a, { stdio: 'ignore' }),
|
|
@@ -2508,7 +2517,7 @@ function cmdGateHermetic(argv) {
|
|
|
2508
2517
|
verdict, ok: exitCode === 0, command: cmd,
|
|
2509
2518
|
liveEnv: { skip, trunkSource, value: trunkLive.value },
|
|
2510
2519
|
normal: { ok: normal.ok, exit: normal.exit },
|
|
2511
|
-
hermetic: herm ? { ok: herm.ok, exit: herm.exit, stripped: envInfo.stripped, kept: envInfo.kept, network: net.note } : null,
|
|
2520
|
+
hermetic: herm ? { ok: herm.ok, exit: herm.exit, stripped: envInfo.stripped, kept: envInfo.kept, pinned: envInfo.pinned, network: net.note } : null,
|
|
2512
2521
|
failing, notes,
|
|
2513
2522
|
}, null, 2));
|
|
2514
2523
|
return exitCode;
|
|
@@ -2522,6 +2531,8 @@ function cmdGateHermetic(argv) {
|
|
|
2522
2531
|
lines.push(`hermetic run: ${herm.ok ? 'green' : 'RED'} (exit ${herm.exit === null ? 'none' : herm.exit}${herm.signal ? `, ${herm.signal}` : ''})`);
|
|
2523
2532
|
lines.push(` HOME=<fresh empty dir>; unset ${envInfo.stripped.length} var(s)${envInfo.stripped.length ? `: ${envInfo.stripped.join(' ')}` : ''}`);
|
|
2524
2533
|
if (envInfo.kept.length) lines.push(` --keep passed through: ${envInfo.kept.join(' ')}`);
|
|
2534
|
+
if (envInfo.pinned.length) lines.push(` toolchain homes pinned to their real dirs: ${envInfo.pinned.join(' ')}`);
|
|
2535
|
+
else if (opts.noPin) lines.push(' toolchain homes: NOT pinned (--no-pin)');
|
|
2525
2536
|
lines.push(` ${net.note}`);
|
|
2526
2537
|
} else {
|
|
2527
2538
|
lines.push('hermetic run: not attempted (normal run is red)');
|
|
@@ -2541,6 +2552,13 @@ function cmdGateHermetic(argv) {
|
|
|
2541
2552
|
for (const l of hermetic.tail(out)) lines.push(` | ${l}`);
|
|
2542
2553
|
}
|
|
2543
2554
|
}
|
|
2555
|
+
if (verdict === 'live-env' && hermetic.looksLikeToolchainMiss(herm.output)) {
|
|
2556
|
+
lines.push('', 'hint: the hermetic failure looks like a toolchain manager that could not find its install',
|
|
2557
|
+
' (a proxy trying to download a toolchain with the network off) — not necessarily the tests. Its',
|
|
2558
|
+
' default homes under $HOME are pinned already, so its install lives elsewhere (or --no-pin was given):',
|
|
2559
|
+
' export the manager\'s home variable (e.g. RUSTUP_HOME, CARGO_HOME) so it passes through, and re-run.',
|
|
2560
|
+
' Name it in the distill comment (#447).');
|
|
2561
|
+
}
|
|
2544
2562
|
lines.push('', `VERDICT: ${verdict} — ${hermetic.VERDICT_TEXT[verdict]}`);
|
|
2545
2563
|
print(lines.join('\n'));
|
|
2546
2564
|
return exitCode;
|
|
@@ -6213,9 +6231,15 @@ function cmdDoctor(argv) {
|
|
|
6213
6231
|
const entry = { repo: shortRepo(repo), label: v.name, verdict: v.verdict,
|
|
6214
6232
|
total: v.total, open: v.open, members: v.members, deleted: false, error: null };
|
|
6215
6233
|
if (opts.prune && v.verdict === 'spent') {
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6234
|
+
// #448: `spent` came from the search-backed listing; confirm through the issues table.
|
|
6235
|
+
const t = groupLabels.teardownSpentGroupLabel(v.name, {
|
|
6236
|
+
searchOpen: [],
|
|
6237
|
+
confirmOpen: (name) => git.ghOpenIssueNumbersByLabel(repo, name),
|
|
6238
|
+
deleteLabel: (name) => git.ghLabelDelete(repo, name),
|
|
6239
|
+
});
|
|
6240
|
+
entry.deleted = t.deleted;
|
|
6241
|
+
if (t.action === 'keep') entry.error = groupLabels.keptReason(v.name, t);
|
|
6242
|
+
else if (!t.deleted) entry.error = t.error;
|
|
6219
6243
|
}
|
|
6220
6244
|
report.spentGroupLabels.push(entry);
|
|
6221
6245
|
}
|
|
@@ -12394,12 +12418,16 @@ function shipLandedTail({ repoAbs, sess, target, trunk, gh, sha, closeIssues, re
|
|
|
12394
12418
|
// its last member.
|
|
12395
12419
|
if (gh) {
|
|
12396
12420
|
for (const gl of groupLabelsCarried) {
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12421
|
+
// #448: search says zero → a non-search read must agree before the repo-wide delete.
|
|
12422
|
+
const t = groupLabels.teardownSpentGroupLabel(gl, {
|
|
12423
|
+
searchOpen: (name) => git.ghIssueListByLabel(repoAbs, name, 'open', ['number']),
|
|
12424
|
+
confirmOpen: (name) => git.ghOpenIssueNumbersByLabel(repoAbs, name),
|
|
12425
|
+
deleteLabel: (name) => git.ghLabelDelete(repoAbs, name),
|
|
12426
|
+
});
|
|
12427
|
+
if (t.reason === 'open') continue; // still binds the remainder — leave it
|
|
12428
|
+
if (t.action === 'keep') { warn(groupLabels.keptReason(gl, t)); continue; }
|
|
12429
|
+
if (t.deleted) print(` deleted spent group label ${gl} (every member now closed)`);
|
|
12430
|
+
else warn(`could not delete spent group label ${gl}: ${t.error}`);
|
|
12403
12431
|
}
|
|
12404
12432
|
}
|
|
12405
12433
|
|
package/tools/lib/git.js
CHANGED
|
@@ -695,6 +695,25 @@ function ghIssueListByLabel(repo, label, state, fields) {
|
|
|
695
695
|
catch (_) { return null; }
|
|
696
696
|
}
|
|
697
697
|
|
|
698
|
+
/**
|
|
699
|
+
* #448: the open issues carrying `label`, as numbers, read through the REST issues list — NOT
|
|
700
|
+
* search. `gh issue list --label` (ghIssueListByLabel above) is served by GraphQL `search(...)`,
|
|
701
|
+
* whose index can lag a burst of closes and answer "0 open" for a label still on an open issue;
|
|
702
|
+
* this endpoint reads the issues table directly. Pull requests share the endpoint and are dropped.
|
|
703
|
+
* Null on any failure — "could not read", never "none open", same contract as ghIssueListByLabel.
|
|
704
|
+
* Used as the confirming read before a `group:` label is deleted (group-labels.js
|
|
705
|
+
* teardownSpentGroupLabel).
|
|
706
|
+
*/
|
|
707
|
+
function ghOpenIssueNumbersByLabel(repo, label) {
|
|
708
|
+
const r = ghApi(repo, [
|
|
709
|
+
'--method', 'GET', '--paginate', 'repos/{owner}/{repo}/issues',
|
|
710
|
+
'-f', `labels=${label}`, '-f', 'state=open', '-f', 'per_page=100',
|
|
711
|
+
'--jq', '.[] | select(.pull_request == null) | .number',
|
|
712
|
+
]);
|
|
713
|
+
if (!r.ok) return null;
|
|
714
|
+
return String(r.stdout || '').split('\n').map((l) => l.trim()).filter(Boolean).map(Number);
|
|
715
|
+
}
|
|
716
|
+
|
|
698
717
|
/**
|
|
699
718
|
* `gh label delete <name> --yes` — returns {ok, stderr}. Deletes the LABEL OBJECT from the
|
|
700
719
|
* repo's tracker, not one issue's use of it — every issue that carried it loses it. Callers
|
|
@@ -1050,7 +1069,7 @@ module.exports = {
|
|
|
1050
1069
|
claimRemote, remoteHeads,
|
|
1051
1070
|
worktreeList, worktreeListDetailed, resolveWorktreePathForBranch, gitFailureLine,
|
|
1052
1071
|
dirtyTracked, dirtyUntracked, dirtyAny,
|
|
1053
|
-
ghAvailable, ghState, ghIssueEdit, ghListLabels, ghAssignedIssues,
|
|
1072
|
+
ghAvailable, ghState, ghIssueEdit, ghListLabels, ghOpenIssueNumbersByLabel, ghAssignedIssues,
|
|
1054
1073
|
ghCurrentLogin, ghIssueView, ghIssueComment, ghRunForSha, ghRunForCommit, ghRunsForCommit, ghRunsForRef, ghRunsAtCommit, ghRunForCommitAnyRef, commitTimeMs, ghRunsSince, summarizeRunsForCommit,
|
|
1055
1074
|
ghRunJobCount, ghRunJobs,
|
|
1056
1075
|
ghIssueListByLabel, ghLabelDelete, ghLabelCreate, ghListLabelsDetailed, ghLabelEditDescription,
|
|
@@ -115,6 +115,71 @@ function reportableLabels(verdicts) {
|
|
|
115
115
|
return (verdicts || []).filter((v) => v && v.verdict !== 'mid-flight');
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* #448: the second read before a destructive delete. Measured in an adopting repo: ship's (i)
|
|
120
|
+
* teardown deleted `group:<key>` while a fourth, deliberately-unshipped member still carried it
|
|
121
|
+
* OPEN — the open-member listing had come back empty 29 s after the squash closed the other three.
|
|
122
|
+
* That listing is `gh issue list --label`, which `gh` serves through GraphQL `search(...)`
|
|
123
|
+
* (verified with GH_DEBUG=api), and the search index lags the issues table: a burst of closes and
|
|
124
|
+
* label writes can leave it answering "0 open" for a label still on an open issue.
|
|
125
|
+
*
|
|
126
|
+
* `gh label delete` is repo-wide and cannot be undone per issue, so "0 open" from search alone is
|
|
127
|
+
* not enough to act on. The confirming read is the REST issues list (`ghOpenIssueNumbersByLabel`),
|
|
128
|
+
* which reads the issues table, not the index. The two failures are asymmetric exactly as
|
|
129
|
+
* isOpenMember's note says — keeping a spent label costs one stale picker entry until the next
|
|
130
|
+
* ship or `doctor --sync --prune`; deleting a live one strips a grouping from work in flight — so
|
|
131
|
+
* every case but "both reads agree on zero" keeps the label.
|
|
132
|
+
*
|
|
133
|
+
* @param {Array|null} searchOpen open members per the search-backed listing; null = could not read
|
|
134
|
+
* @param {Array|null} confirmOpen open member NUMBERS per the non-search read; null = could not read
|
|
135
|
+
* @returns {{action:'delete'|'keep', reason:string, open:number[]}}
|
|
136
|
+
* reason ∈ unread · open · unconfirmed · disagree · spent
|
|
137
|
+
*/
|
|
138
|
+
function spentLabelDecision(searchOpen, confirmOpen) {
|
|
139
|
+
if (searchOpen === null || searchOpen === undefined) return { action: 'keep', reason: 'unread', open: [] };
|
|
140
|
+
if (Array.isArray(searchOpen) && searchOpen.length > 0) return { action: 'keep', reason: 'open', open: [] };
|
|
141
|
+
if (confirmOpen === null || confirmOpen === undefined || !Array.isArray(confirmOpen)) {
|
|
142
|
+
return { action: 'keep', reason: 'unconfirmed', open: [] };
|
|
143
|
+
}
|
|
144
|
+
if (confirmOpen.length > 0) {
|
|
145
|
+
const nums = confirmOpen.map((m) => (m && typeof m === 'object' ? m.number : m))
|
|
146
|
+
.filter((n) => n !== undefined && n !== null);
|
|
147
|
+
return { action: 'keep', reason: 'disagree', open: nums };
|
|
148
|
+
}
|
|
149
|
+
return { action: 'delete', reason: 'spent', open: [] };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The I/O shell around spentLabelDecision, with every call injected so the delete path is pinned by
|
|
154
|
+
* a test with no network (#448). `searchOpen` may be passed pre-read (doctor already has the
|
|
155
|
+
* membership from its classify pass) or as a function; `confirmOpen` and `deleteLabel` are always
|
|
156
|
+
* functions and are only CALLED when needed — the confirm read only when search said zero, the
|
|
157
|
+
* delete only when both reads agree.
|
|
158
|
+
*
|
|
159
|
+
* @returns {{action:'delete'|'keep', reason:string, open:number[], deleted:boolean, error:string|null}}
|
|
160
|
+
*/
|
|
161
|
+
function teardownSpentGroupLabel(name, { searchOpen, confirmOpen, deleteLabel }) {
|
|
162
|
+
if (!isGroupLabel(name)) return { action: 'keep', reason: 'unread', open: [], deleted: false, error: null };
|
|
163
|
+
const s = typeof searchOpen === 'function' ? searchOpen(name) : searchOpen;
|
|
164
|
+
const needConfirm = Array.isArray(s) && s.length === 0;
|
|
165
|
+
const c = needConfirm ? confirmOpen(name) : null;
|
|
166
|
+
const d = spentLabelDecision(s, needConfirm ? c : null);
|
|
167
|
+
if (d.action !== 'delete') return { ...d, deleted: false, error: null };
|
|
168
|
+
const r = deleteLabel(name) || {};
|
|
169
|
+
return { ...d, deleted: !!r.ok, error: r.ok ? null : (r.stderr || 'gh label delete failed') };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** One human line for a kept label — the CLI and its test read the same words. */
|
|
173
|
+
function keptReason(name, d) {
|
|
174
|
+
switch (d.reason) {
|
|
175
|
+
case 'unread': return `could not check membership of ${name} — left in place`;
|
|
176
|
+
case 'unconfirmed': return `${name} reads 0 open members by search but the confirming (non-search) read failed — left in place`;
|
|
177
|
+
case 'disagree': return `${name} reads 0 open members by search, but #${d.open.join(', #')} still carr${d.open.length === 1 ? 'ies' : 'y'} it open (non-search read) — left in place; the search index is lagging (#448)`;
|
|
178
|
+
default: return '';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
118
182
|
module.exports = {
|
|
119
183
|
isOpenMember, classifyGroupLabel, classifyGroupLabels, deletableLabels, reportableLabels,
|
|
184
|
+
spentLabelDecision, teardownSpentGroupLabel, keptReason,
|
|
120
185
|
};
|
package/tools/lib/hermetic.js
CHANGED
|
@@ -51,6 +51,70 @@ const TEST_RUNNER_LEAKS = ['NODE_TEST_CONTEXT', 'NODE_TEST_WORKER_ID'];
|
|
|
51
51
|
// HOME-derived locations re-pointed INTO the fresh home, so nothing reaches the real one through them.
|
|
52
52
|
const XDG_DIRS = { XDG_CONFIG_HOME: '.config', XDG_DATA_HOME: '.local/share', XDG_CACHE_HOME: '.cache', XDG_STATE_HOME: '.local/state' };
|
|
53
53
|
|
|
54
|
+
// Toolchain-manager homes (#447). A version manager's proxy (`cargo`/`rustc` from rustup, a pyenv
|
|
55
|
+
// or asdf shim, …) finds its installed toolchain through ONE variable whose default is under
|
|
56
|
+
// $HOME. With HOME swapped for an empty dir the proxy finds nothing, tries to install a toolchain,
|
|
57
|
+
// and — network off — fails; the verdict then read `live-env` and blamed the code for a machine
|
|
58
|
+
// dependency it does not have (measured: a rustup-managed Rust workspace, `live-env` locally,
|
|
59
|
+
// green on CI where the container brings its own toolchain). An installed toolchain is the
|
|
60
|
+
// compiler/interpreter the test step runs ON, not live state the tests READ, so the variable is
|
|
61
|
+
// pinned to the real directory BEFORE HOME moves — only when the caller has not set it already
|
|
62
|
+
// (a set value passes through untouched: none of these names match a strip rule) and only when
|
|
63
|
+
// that directory actually exists (nothing is invented). Every pin is printed in the verdict, the
|
|
64
|
+
// same visibility rule as --keep. The cost, stated: such a home also holds the manager's own
|
|
65
|
+
// config and package cache (~/.cargo/config.toml, ~/.cargo/registry, ~/go/pkg/mod), and a test
|
|
66
|
+
// reading THOSE is not caught — `--no-pin` restores the strict run for a suite suspected of it.
|
|
67
|
+
const TOOLCHAIN_HOMES = [
|
|
68
|
+
{ name: 'RUSTUP_HOME', rel: '.rustup', manager: 'rustup' },
|
|
69
|
+
{ name: 'CARGO_HOME', rel: '.cargo', manager: 'rustup/cargo' },
|
|
70
|
+
{ name: 'PYENV_ROOT', rel: '.pyenv', manager: 'pyenv' },
|
|
71
|
+
{ name: 'RBENV_ROOT', rel: '.rbenv', manager: 'rbenv' },
|
|
72
|
+
{ name: 'ASDF_DATA_DIR', rel: '.asdf', manager: 'asdf' },
|
|
73
|
+
{ name: 'NVM_DIR', rel: '.nvm', manager: 'nvm' },
|
|
74
|
+
{ name: 'VOLTA_HOME', rel: '.volta', manager: 'volta' },
|
|
75
|
+
// mise follows XDG_DATA_HOME, which the hermetic run re-points — so its default must be resolved
|
|
76
|
+
// against the CALLER's XDG_DATA_HOME, not the fresh one.
|
|
77
|
+
{ name: 'MISE_DATA_DIR', rel: '.local/share/mise', xdg: ['XDG_DATA_HOME', 'mise'], manager: 'mise' },
|
|
78
|
+
{ name: 'GOPATH', rel: 'go', manager: 'go (GOTOOLCHAIN downloads + module cache)' },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Which toolchain homes to pin → `[{ name, value, manager }]`. `exists(path)` is injected so this
|
|
83
|
+
* stays pure; the CLI passes a real directory check. A variable already set in `env` is never in
|
|
84
|
+
* the list — it reaches the hermetic run unchanged anyway.
|
|
85
|
+
*/
|
|
86
|
+
function toolchainPins(env, exists) {
|
|
87
|
+
const home = env.HOME;
|
|
88
|
+
const pins = [];
|
|
89
|
+
for (const t of TOOLCHAIN_HOMES) {
|
|
90
|
+
if (env[t.name]) continue;
|
|
91
|
+
let dir = null;
|
|
92
|
+
if (t.xdg && env[t.xdg[0]]) dir = `${env[t.xdg[0]].replace(/\/+$/, '')}/${t.xdg[1]}`;
|
|
93
|
+
else if (home) dir = `${home.replace(/\/+$/, '')}/${t.rel}`;
|
|
94
|
+
if (dir && exists(dir)) pins.push({ name: t.name, value: dir, manager: t.manager });
|
|
95
|
+
}
|
|
96
|
+
return pins;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The output shapes of a version manager that could not find its toolchain — what a missed pin
|
|
100
|
+
// looks like. Used only for a hint line under a `live-env` verdict; the verdict itself is unchanged.
|
|
101
|
+
const TOOLCHAIN_MISS_PATTERNS = [
|
|
102
|
+
/syncing channel updates for/i, // rustup proxy installing a toolchain
|
|
103
|
+
/static\.rust-lang\.org/i,
|
|
104
|
+
/rustup could not choose a version|no default toolchain/i,
|
|
105
|
+
/pyenv: version .* is not installed/i,
|
|
106
|
+
/rbenv: version .* is not installed/i,
|
|
107
|
+
/No version is set for command|No preset version installed/i, // asdf
|
|
108
|
+
/mise .*(is not installed|missing:)/i,
|
|
109
|
+
/go: downloading go\d|toolchain not available/i,
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
/** True when a failed run's output looks like a toolchain manager missing its install. */
|
|
113
|
+
function looksLikeToolchainMiss(output) {
|
|
114
|
+
const s = String(output || '');
|
|
115
|
+
return TOOLCHAIN_MISS_PATTERNS.some((re) => re.test(s));
|
|
116
|
+
}
|
|
117
|
+
|
|
54
118
|
function shouldStrip(name) {
|
|
55
119
|
if (name === 'HOME' || name === 'PATH') return false;
|
|
56
120
|
if (STRIP_EXACT.has(name) || STRIP_EXACT.has(name.toLowerCase())) return true;
|
|
@@ -65,15 +129,17 @@ function normalEnv(env) {
|
|
|
65
129
|
}
|
|
66
130
|
|
|
67
131
|
/**
|
|
68
|
-
* The hermetic run's env → `{ env, stripped, kept }`. `home` is the fresh directory the
|
|
69
|
-
* created. `keep` names variables the caller explicitly passes through anyway — every one is
|
|
70
|
-
* echoed in the verdict, so a pass-through is visible, never silent.
|
|
132
|
+
* The hermetic run's env → `{ env, stripped, kept, pinned }`. `home` is the fresh directory the
|
|
133
|
+
* caller created. `keep` names variables the caller explicitly passes through anyway — every one is
|
|
134
|
+
* echoed in the verdict, so a pass-through is visible, never silent. `pins` (from `toolchainPins`)
|
|
135
|
+
* are toolchain-manager homes set to their real directories before HOME moves (#447) — echoed too.
|
|
71
136
|
*/
|
|
72
|
-
function hermeticEnv(env, home, keep = []) {
|
|
137
|
+
function hermeticEnv(env, home, keep = [], { pins = [] } = {}) {
|
|
73
138
|
const keepSet = new Set(keep);
|
|
74
139
|
const out = {};
|
|
75
140
|
const stripped = [];
|
|
76
141
|
const kept = [];
|
|
142
|
+
for (const p of pins) out[p.name] = p.value;
|
|
77
143
|
for (const [k, v] of Object.entries(env)) {
|
|
78
144
|
if (TEST_RUNNER_LEAKS.includes(k)) continue;
|
|
79
145
|
if (keepSet.has(k)) { out[k] = v; if (shouldStrip(k)) kept.push(k); continue; }
|
|
@@ -83,7 +149,7 @@ function hermeticEnv(env, home, keep = []) {
|
|
|
83
149
|
}
|
|
84
150
|
out.HOME = home;
|
|
85
151
|
for (const [k, rel] of Object.entries(XDG_DIRS)) if (!keepSet.has(k)) out[k] = `${home}/${rel}`;
|
|
86
|
-
return { env: out, stripped: stripped.sort(), kept: kept.sort() };
|
|
152
|
+
return { env: out, stripped: stripped.sort(), kept: kept.sort(), pinned: pins.map((p) => p.name) };
|
|
87
153
|
}
|
|
88
154
|
|
|
89
155
|
// ---- the network ----------------------------------------------------------------------------
|
|
@@ -188,6 +254,6 @@ const VERDICT_TEXT = {
|
|
|
188
254
|
};
|
|
189
255
|
|
|
190
256
|
module.exports = {
|
|
191
|
-
parseLiveEnv, shouldStrip, normalEnv, hermeticEnv, probeNetworkIsolation, parseFailures, tail,
|
|
257
|
+
parseLiveEnv, shouldStrip, normalEnv, hermeticEnv, toolchainPins, looksLikeToolchainMiss, TOOLCHAIN_HOMES, probeNetworkIsolation, parseFailures, tail,
|
|
192
258
|
classify, VERDICT_TEXT, DARWIN_PROFILE, LINUX_WRAPPER, TEST_RUNNER_LEAKS,
|
|
193
259
|
};
|