Repository navigation
Spawn every CLI test child through one hermetic Command builder; 10 test files inherit ambient SOCKET_* today #823
Description
[agent] Filed by the scheduled architecture audit routine (CLI and core). Register: register comment.
Kind: refactor (test structure). Source: review Part 8.5 D (forked env scrubbers), plus a new finding (test files with no scrub at all); register C30 / C47.
Problem
The CLI test tree already has a hermetic spawner: common::run_bin_with_env seeds and scrubs the high-risk vars, prefix-sweeps the remaining SOCKET_* (keeping the telemetry opt-outs, SOCKET_NO_CONFIG and SOCKET_NO_UPDATE_CHECK), and forces SOCKET_NO_CONFIG=1 / SOCKET_NO_UPDATE_CHECK=1. But it only returns (code, stdout, stderr), so tests that need a Command (stdin, PTY, extra env removal, output() bytes) hand-roll their own:
- 15 private
scrub_socket_envcopies with 14 different bodies. Some keepSOCKET_NO_CONFIG, some remove it (e2e_redirect_yarn_classic_build.rs#L98`` strips everySOCKET_*, including the `.cargo/config.toml` `SOCKET_NO_CONFIG=1` that keeps a developer's `socket login` token out of test children); none of the per-file copies keep `SOCKET_NO_UPDATE_CHECK`. Their real differences are per-PM extras (`YARN_`, `PNPM_`, `npm_config_*`, `VIRTUAL_ENV`). - 10 files that spawn the binary with no scrub at all (only
SOCKET_TELEMETRY_DISABLEDor a token removal):repair/repair_vendor_e2e.rs(L201-L212),``scan/scan_invariants.rs(L53), `scan/scan_sync_e2e.rs`, `cli/api_client_errors_e2e.rs`, `cli_parse_remove.rs`, `apply/in_process_npm_multicopy.rs`, `self_update_e2e.rs`, `self_update_failures_e2e.rs`, `update/covgap_update_swap.rs`, `update/covgap_update_download.rs`. (Some of the update files spawn through a fixture helper; the child PR should check each.)
Proof (on 045d7ec, debug build, run twice, as root in a cloud container):
| ambient var | repair_vendor_e2e (unscrubbed, 19 tests) |
the other 97 tests in the repair target (scrubbed) |
|---|---|---|
| none | 19 pass | 95 pass, 2 fail* |
SOCKET_DRY_RUN=true |
1 pass, 18 fail ("setup must vendor the tarball") | 95 pass, 2 fail* |
SOCKET_OFFLINE=true |
1 pass, 18 fail | 95 pass, 2 fail* |
*The two baseline failures are the "lock file unremovable" tests, which can't simulate an unremovable file as root; they are unrelated.
So the same ambient shell that the shared helper neutralizes silently changes what the unscrubbed suites exercise. Here it fails loudly; with a variable like SOCKET_ECOSYSTEMS, SOCKET_GLOBAL_PREFIX or SOCKET_API_TOKEN it can instead change the code path or aim a mutation at a real global cache.
Symptoms
None filed; contributors hit this as "passes in CI, fails locally".
Impact
Test hermeticity and maintenance: each new SOCKET_* variable has to be remembered in up to 16 places. Size: test-only, no production change.
Proposed change
- Split
run_bin_with_envintopub fn hermetic_command(bin: &Path) -> Command(seed, scrub, force the two opt-outs) and the existing runner, which becomeshermetic_command(bin)+ args + caller env +output(). - Give it the per-PM extras as an explicit opt-in, e.g.
scrub_pm_env(&mut cmd, &[Pm::Yarn, Pm::Pnpm]), keeping the seed-then-scrub guards the yarn/pnpm copies document. - Route the 10 unscrubbed files and the 15
scrub_socket_envcopies through it, and delete the 15 copies.
Size and scope
~25 test files, net negative (~−250 lines). Out of scope: binary() / git_sha256 deduplication and a separate test-support crate (later children of #824), and any production code.
Acceptance criteria
-
common::hermetic_commandexists, andrun_bin_with_envis built on it. -
grep -rn "fn scrub_socket_env" crates/socket-patch-cli/testsreturns nothing. - Every test file that spawns
CARGO_BIN_EXE_socket-patch(or a staged copy of it) does so throughhermetic_commandor therun*helpers; a guard test (or a grep in an existing lint test) keeps it that way. -
SOCKET_DRY_RUN=true cargo test -p socket-patch-cli --test repairgives the same result as without the variable; the same for--test scanand--test cli. - All existing tests stay green in CI; the yarn/pnpm seed-then-scrub guards still fail red when the scrub is removed.
Dependencies
Blocked by nothing. First child of tracking issue #824. Independent of #793 (RunCtx), though fewer env-reading paths there will shrink what the scrub has to cover.
Activity
audit-core: C28 rejected, C30 decomposed (#824, #823), C47 test herme…
refactor: re-rank queue at capacity (add #823)
mikolalysenko commentedon Oct 5, 2026
[agent] Triaged:
priority:p3(test-only refactor, CI hermeticity). Not a duplicate; child of tracking issue #824. No open PR addresses it yet.Generated by Claude Code
mikolalysenko commentedon Oct 5, 2026
[agent] Claiming this issue for the architecture refactor routine (highest leverage: test-only, collapses the per-file
scrub_socket_envcopies into onecommon::hermetic_command, first child of #824). Branch: arch-refactor/823-hermetic-command. Claim-ID: 2026-10-05T11:56:39Z-93d7a1Slice: add
hermetic_command, buildrun_bin_with_envon it, and migrate every spawner file that no openagent/fix-*PR touches. The files that open fix PRs change (#774, #802, #820, #837, #839, #849, #763) stay on an explicit allowlist in a guard test, to be migrated after those PRs land.Generated by Claude Code
mikolalysenko commentedon Oct 5, 2026
[agent] Draft PR: #850.
Generated by Claude Code
Spawn CLI test children via one hermetic builder
Spawn cli_dry_run_paths through the hermetic builder
mikolalysenko commentedon Oct 5, 2026
[agent] Slice taken in #850:
common::hermetic_commandexists, andrun_bin_with_envis built on it.scrub_socket_envcopies are deleted.run_installed), pluscli/cli_dry_run_paths_e2e.spawn_env_hygieneratchet guards both lists.SOCKET_DRY_RUN=truenow gives the same result for--test repairand--test clias running without it.What remains:
e2e_redirect_yarn_berry_build,e2e_redirect_yarn_classic_build,e2e_vendor_yarn_berry_build,e2e_vendor_yarn_classic_build,e2e_yarn4_pnpm_linker_build,e2e_yarn4_workspaces_build,scan/covgap_ecosystem_dispatch), plusscan/scan_invariantsandapply/in_process_npm_multicopy. All of these are changed by open fix PRs (Fix yarn berry hosted pin of catalog deps (#632) #763, Fix store-copy fold dropping copy writes (#756, #772) #774, Fix vendored mode replacing symlinked lockfiles (#627) #802, Fix vlt 1.3 brotli lock nodes being refused (#372) #820, Fix vendored npm-family tarballs dropped by .gitignore (#831) #837, Fix hosted yarn classic with an offline mirror (#364) #839, Fix vendored gem rewrite breaking positional args (#847) #849) and will move once those land;--test scanstays ambient-sensitive untilscan_invariantsmoves.Command::new(binary())spawners on thePENDING_RAW_SPAWNSallowlist.Generated by Claude Code
refactor: record #607 merge, open #850 (#823 slice 1)
28 remaining items
mikolalysenko commentedon Oct 12, 2026
[agent] Claiming slice 5: move the 13
scan_*, top-levelvendor_*andvex_terminal_output.rsfiles onPENDING_RAW_SPAWNSontotests/common/hermetic.rs. These files and their list lines don't overlap #1441 (slice 4), and no other open PR touches them. Branch: agent/fix-ci-hermetic-scan-vendor. Claim-ID: 2026-10-12T20:51:07Z-e9aa37Generated by Claude Code
mikolalysenko commentedon Oct 12, 2026
[agent] Slice 5 draft PR: #1448
Generated by Claude Code
Spawn scan/vendor test children hermetically
mikolalysenko commentedon Oct 12, 2026
[agent] Slice 5 is up for review in #1448. The 13
scan_*, top-levelvendor_*andvex_terminal_output.rsfiles now spawn throughtests/common/hermetic.rs, andPENDING_RAW_SPAWNSgoes from 126 to 113. Under a hostileSOCKET_*shell, main fails 28 tests across those suites and the branch fails none.New follow-up from the review:
hermetic::Extra::Venvremoves onlyVIRTUAL_ENV, but the Python crawler also falls back toCONDA_PREFIX. The two requirements-lock scan suites still remove both by hand for that reason. WideningExtra::Venv(plusCONDA_DEFAULT_ENV) would let them drop that.Generated by Claude Code
mikolalysenko commentedon Oct 12, 2026
[agent] Claiming slice 6: move the 16
in_process_redirect*,in_process_rollback_*,in_process_vendor*takeover,mode_migration_{bun,cargo,pypi},hosted_memory_*,hosted_superseding_pypiandremove_rollback_api_overridesfiles onPENDING_RAW_SPAWNSontotests/common/hermetic.rs. No overlap with #1448 (slice 5): different files and non-adjacent list lines. Branch: agent/fix-ci-hermetic-in-process. Claim-ID: 2026-10-12T21:51:07Z-265cc2Generated by Claude Code
mikolalysenko commentedon Oct 12, 2026
[agent] Slice 6 draft PR: #1452
Generated by Claude Code
CI: hermetic spawns in in_process tests
Share scrubs from the hermetic test helpers
mikolalysenko commentedon Oct 12, 2026
[agent] Claiming slice 7: move the 16
e2e_vex_lockfile/*,e2e_vex_build/{deno,hatch,poetry},e2e_vex.rs,e2e_vex_redirect.rsande2e_embedded_vex.rsfiles onPENDING_RAW_SPAWNSontotests/common/hermetic.rs. No overlap with #1448 or #1452: different files, and theirPENDING_RAW_SPAWNSlines aren't adjacent to these. Branch: agent/fix-ci-hermetic-vex. Claim-ID: 2026-10-12T22:50:49Z-c3b511Generated by Claude Code
mikolalysenko commentedon Oct 12, 2026
[agent] Slice 7 draft PR: #1454
Generated by Claude Code
Spawn VEX test children hermetically
Tidy VEX spawns after code review
mikolalysenko commentedon Oct 12, 2026
[agent] Slice 7 is up for review in #1454. The 16 VEX test files (
e2e_vex_lockfile/*,e2e_vex_build/{deno,hatch,poetry},e2e_vex.rs,e2e_vex_redirect.rs,e2e_embedded_vex.rs) and the sharedvex_e2e_common::run_vexnow spawn throughtests/common/hermetic.rs, andPENDING_RAW_SPAWNSgoes from 92 to 76 on main. CI is green and Bugbot found nothing.Left for later slices:
vex_e2e_common/uv.rs(its list line is adjacent to lines #1448 removes), and the privatePOETRY_*/UV_*sweeps, which can move ontohermetic::Extraonce #1452 landsExtra::Poetry.Generated by Claude Code
mikolalysenko commentedon Oct 12, 2026
[agent] Claiming slice 8: move the six
e2e_redirect_{bun,cargo,composer,gem,maven,npm}_build.rsfiles onPENDING_RAW_SPAWNSontotests/common/hermetic.rs. No overlap with #1452 or #1454 (different files, non-adjacent list lines).e2e_redirect_cargo_shapes.rsis left out because #1429 edits it. Branch: agent/fix-ci-hermetic-redirect-build. Claim-ID: 2026-10-12T23:50:54Z-ddb8e9Generated by Claude Code
mikolalysenko commentedon Oct 13, 2026
[agent] Slice 8 draft PR: #1457. Narrowed to five files:
e2e_redirect_bun_build.rswaits for #1452, which adds the bun tool-env scrub it needs.Generated by Claude Code