Skip to content

CI: hermetic spawns in npm/Bun suites (#823) - #1510

Merged
Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
agent/fix-ci-hermetic-npm-bun
Oct 14, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
agent/fix-ci-hermetic-npm-bun

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Refs #823 (slice 15: npm/Bun suites). Uses Refs, so #823 stays open for the remaining PENDING_RAW_SPAWNS files.

Summary

e2e_npm.rs, e2e_redirect_bun_build.rs and vendor/in_process_vendor_bun.rs now spawn socket-patch through tests/common/hermetic.rs and leave PENDING_RAW_SPAWNS (12 → 9 on main after #1505), so the ratchet in spawn_env_hygiene.rs keeps them hermetic. Test-only; no product code and no workflow changes.

Root cause

Each file started the CLI with a bare Command::new and its own SOCKET_* scrub, which had drifted from the shared builder:

  • e2e_npm and the Bun redirect suite never forced SOCKET_NO_CONFIG / SOCKET_NO_UPDATE_CHECK on, so a developer's socket login or an ambient SOCKET_NO_UPDATE_CHECK=0 reached the child.
  • The Bun redirect suite ran its bun fixtures under the cache sandbox's HOME but the CLI under the real one, so a registry/scope in the developer's ~/.npmrc could make them disagree. The CLI now gets the stand-in HOME (jvm_env::isolate_cli), and its redundant --no-telemetry is gone (the builder forces telemetry off).
  • The in-process Bun vendor FIFO helper skipped the stand-in HOME that every other spawn in that file gets via common::run_with_env.
  • e2e_npm's npm install children now drop ambient SOCKET_* too (hermetic::scrub_socket_vars). e2e_npm keeps its real HOME on purpose (the global auto-discovery test needs real prefixes).

Test evidence

  • Red: with only the PENDING_RAW_SPAWNS removal and none of the conversions, cargo test -p socket-patch-cli --test spawn_env_hygiene no_new_bare fails: These test files spawn the binary with a bare Command::new: ["e2e_npm.rs", "e2e_redirect_bun_build.rs", "vendor/in_process_vendor_bun.rs"].
  • Green: spawn_env_hygiene 16/16; vendor 95/95; e2e_redirect_bun_build 38/38 with real bun 1.4.2 and SOCKET_PATCH_BUN_E2E_REQUIRED=1, also run under hostile ambient SOCKET_ECOSYSTEMS=cargo SOCKET_DRY_RUN=true; e2e_npm non-ignored 20/20.
  • e2e_npm's 6 #[ignore]d live-API tests can't reach patches-api.socket.dev from the agent sandbox (proxy tunnel refused), so they weren't run locally; CI doesn't run them either (opt-in live smoke).
  • cargo fmt --all -- --check, cargo clippy --locked --workspace --all-features -- -D warnings: clean. No new clippy findings in the touched files under --tests.
  • A full cargo test --workspace ran out of sandbox disk; CI covers it.

/code-review high

Fixed: CLI vs bun HOME mismatch, redundant --no-telemetry, unscrubbed npm children. Not fixed:

  • Folding e2e_npm's run and the FIFO run_with_deadline into a shared common builder: a refactor of common outside this slice. The ratchet already stops new drift in the SOCKET_* handling.
  • "Stand-in HOME may hide a HOME-relative bun shim in the FIFO test": every other spawn in that file already runs under isolate_cli via common::run_with_env, and the test passes.

CI cost

No workflow changes. Lean PR run is the same before and after (~28 Linux jobs, ~8 min).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LsbTgBWpFb9LqLgDdQTsmf


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
The npm and Bun suites started socket-patch with a bare Command::new
and their own SOCKET_* scrubs, which had drifted from
tests/common/hermetic.rs. e2e_npm and the Bun redirect suite never
forced the config layer or update notifier off, so a developer's
`socket login` or an ambient SOCKET_NO_UPDATE_CHECK=0 reached the
child; the in-process Bun vendor FIFO helper skipped the stand-in
HOME the rest of that file's spawns get through common::run_with_env.

All three now start from hermetic::command. The Bun redirect suite
keeps its shared bun/npm registry scrub through
scrub_ambient_bun_tool_env, the variant that leaves the builder's
SOCKET_* opt-outs alone, and the FIFO helper adds
jvm_env::isolate_cli to match run_with_env. e2e_npm keeps its partial
cache pins so the global auto-discovery test still sees real
prefixes. The files leave PENDING_RAW_SPAWNS (15 -> 12), so the
ratchet keeps them hermetic.

Refs #823

Assisted-by: Claude Code:claude-opus-5-5
From /code-review high: the Bun redirect suite ran its bun fixture
installs under the cache sandbox's home but the CLI under the real
one, so a registry or scope in the developer's ~/.npmrc would make
the two disagree. The CLI now gets the stand-in HOME
(jvm_env::isolate_cli), as run_with_env gives every other suite.
Its --no-telemetry flag goes: hermetic::command already forces
telemetry off, and the flag would override a caller opting back in.

e2e_npm's npm installs now drop ambient SOCKET_* vars too
(hermetic::scrub_socket_vars), like the package-manager children of
the other converted suites.

Refs #823

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 14, 2026 00:14
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

…-npm-bun

# Conflicts:
#	crates/socket-patch-cli/tests/spawn_env_hygiene.rs

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 94e91a1. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 14, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review at 94e91a1502433ee079ca9f9ae405993e590ca372.

  • CI: all checks on this head are green (ci-ok success, 34 succeeded, the rest skipped by the lean PR matrix). No main-wide failures.
  • Bugbot: reviewed 94e91a1 (the merge from main) and 2bf2c2e. No findings either time.
  • Mergeable: yes. Already approved by Tanmay Singla (@Tanmay182003) at this head.
  • For the reviewer: test-only change. It moves three npm/Bun suites onto the shared hermetic spawn builder and shrinks PENDING_RAW_SPAWNS from 12 to 9.

Slack announcement didn't go out: this session has no Slack send tool. The next run will retry.


Generated by Claude Code

Merged via the queue into main with commit 23fa8d4 Oct 14, 2026
54 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-ci-hermetic-npm-bun branch October 14, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants