Skip to content

Test npm hosted and vendored modes under rules_js on real Bazel - #2109

Open
Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
bazel-small/01-go-hosted-cellsfrom
bazel-small/02-npm-rules-js
Open

Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
bazel-small/01-go-hosted-cellsfrom
bazel-small/02-npm-rules-js

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

No user-visible change.

Stacked on #2107. The base of this pull request is that pull request's branch, so the diff here is the npm part alone. It moves onto main when #2107 has landed.

What this is

Tests of what the released socket-patch already does for an npm package in a Bazel workspace that aspect_rules_js builds from a pnpm lock: hosted mode and vendored mode, on a real Bazel, in GitHub Actions.

Tests only. No file under crates/*/src changes. The shared harness (harness.rs), the Go flow (go.rs), the reusable workflow (bazel-compatibility.yml) and the Go caller (bazel-go.yml) are the files of #2107, unchanged.

Contents

Against #2107's branch at f1aa02b79: 9 files changed, 793 lines added, none removed. No implementation line and no binary file. Tests and workflow are 735 lines, the fixture 58.

File Lines What it is
crates/socket-patch-cli/tests/e2e_bazel_build/npm.rs 602 Module npm of the real-Bazel test target. Two #[ignore] tests, one per flow (npm::hosted_npm_translate_lock, npm::vendored_npm_translate_lock), and one test that needs no Bazel (npm::a_test_pins_the_one_entry_of_the_fixture_lock).
crates/socket-patch-cli/tests/e2e_bazel_build/main.rs 1 mod npm;
.github/workflows/bazel-npm.yml 132 The npm caller: when the npm legs run and on which Bazel releases. It calls the reusable bazel-compatibility.yml.
crates/socket-patch-cli/tests/fixtures/bazel/rules_js/bzlmod/common/ 47 pnpm-lock.yaml (22), BUILD.bazel (12), package.json (11), consumer.js (1), .bazelignore (1)
crates/socket-patch-cli/tests/fixtures/bazel/rules_js/bzlmod/e9/MODULE.bazel 11 aspect_rules_js 3.6.0 and npm.npm_translate_lock(pnpm_lock = "//:pnpm-lock.yaml")

The fixture is an aspect_rules_js 3.6.0 workspace under Bzlmod with a lock of lockfileVersion: '9.0', one direct dependency, and a js_binary that prints OUT: and what the package exports. One MODULE.bazel serves Bazel 7.6.0 through 9.

The package is the tests' own, @socketsecurity/bazel-fixture-upstream@1.0.0. The scope is the one this repository publishes its own packages in, so nobody else can publish the name. A test builds its tarballs, new for every run: the entry file holds an id of the run. The fixture's lock holds a placeholder integrity (the sha512 of sixty-four zero bytes), and a test writes the real one into its workspace copy. No tarball and no sum is committed.

One loopback server per checkout (two per test: the second machine has its own) plays the Socket API, the patch host and registry.npmjs.org. The lock entry names no URL, as pnpm writes one, so rules_js asks for the tarball at the public registry's URL. The harness names a downloader config outside the checkout on every Bazel command, and that config rewrites the URL to the stand-in. No pnpm runs, and the machine needs no Node: the ruleset downloads the one that runs the consumer.

What it proves, and where

Each flow is one test, on the Bazel its leg installed, in a fresh output base. As asserted now:

  1. The unpatched build. bazel build //:consumer passes, bazel run //:consumer prints OUT: PRISTINE <id of the run>, Bazel wrote MODULE.bazel.lock, and the stand-in registry was asked for the upstream tarball.
  2. The one command of the mode, with the changed files held to its list.
    • scan --mode hosted --yes exits 0 with one applied event for the package and the patch. It names pnpm-lock.yaml and pnpm-workspace.yaml as rewritten, and those two are the only files that differ. The lock's entry of the package holds the integrity of the patched tarball and its URL on the patch host. pnpm-workspace.yaml is, whole, the root as the one package and trustLockfile: true.
    • scan --mode vendored --yes exits 0 with one package downloaded and applied. Eight files differ and no other: four in .socket/vendor/npm/<uuid>/ (.gitattributes, .gitignore, socket-patch.vendor.json and the tarball, under a directory of its scope), .socket/vendor/state.json, package.json, pnpm-lock.yaml and a new pnpm-workspace.yaml. The committed tarball is byte for byte the one the patch host served. The lock's entry names it by path and by sum, pnpm.overrides of package.json sends the package's one version to it, and pnpm-workspace.yaml is, whole, the root as the one package and that same override.
  3. The same two Bazel commands, with no step in between, print OUT: PATCHED <id of the patch>. Bazel changed no file of the checkout, MODULE.bazel.lock included, and a --lockfile_mode=error build passes. Hosted: the stand-in's patch route was asked during that build. Vendored: the stand-in received no request during it.
  4. The undo (rollback --yes, or vendor --revert) exits 0 and counts one package. Every file of the checkout is the one of before, byte for byte, with no file added or left, and the build prints OUT: PRISTINE <id> again without changing a file.
  5. A second machine (a new output base and, on Bazel 9, a new contents cache, with a stand-in of its own) runs the command against a second patch, and the pinned place holds other bytes: the patch host serves them (hosted), or they are written over the committed tarball (vendored). The build fails with Checksum was sha512-... but wanted sha512-... and the registry is not asked for the upstream tarball instead. Hosted: the patch host was asked. Vendored: the error names the committed file.

The third test needs no Bazel and runs wherever cargo test runs the target, on Unix. It holds the fixture's directories and the caller's legs to the test's table of releases, the one placeholder entry of the fixture's lock, the version the fixture depends on, that two runs build two different upstream tarballs, and the package's names, the @socketsecurity/ scope among them.

Runs

macOS arm64, this head (9194943ca), the release binaries that scripts/bazel-pins.txt pins, the command of the reusable workflow's run step (list the ignored tests, keep the names that start with npm::, run them by exact name), SOCKET_PATCH_BAZEL_E2E_REQUIRED=1, the release held by SOCKET_PATCH_BAZEL_E2E_VERSION, a fresh output root per release, and one repository cache for the three, empty before the first.

Bazel Result Leg Hosted test Vendored test Repository cache after
9.3.2 2 passed 31 s 25.5 s 25.8 s 102 MB
8.8.2 2 passed 23 s 20.1 s 20.5 s 114 MB
7.7.2 2 passed 35 s 27.2 s 27.4 s 122 MB

The leg time is the two cargo commands with the test target already built. In every run each stand-in answered one request for the upstream tarball and one for the patched one.

Each assertion that this revision adds or changes was shown to fail, on 9.3.2, with a temporary edit that was undone again:

  • The vendored pnpm-workspace.yaml expected without its packages: list: the vendored test fails on the comparison and prints the file as written.
  • The lock entries expected without the quotes pnpm gives a scoped key: both tests fail at step 2.
  • The vendored tarball expected outside its scope directory: the vendored test fails on the list of changed files.
  • The event looked for under pkg:npm/@socketsecurity/... while the API stand-in serves %40: the hosted test fails with no event for ....
  • One fixed upstream tarball, second run on the same repository cache: both tests fail with the build did not fetch the upstream tarball from the stand-in registry.
  • The registry's version document served under the name with a plain /: the hosted test fails at step 4 (see known behaviour).
  • No other bytes in step 5: both tests fail with other bytes built.
  • Five edits of what the Bazel-free test reads (the fixture on the old name, another tarball name, the package under another scope everywhere, the purl with a literal @, the fixture lock's key unquoted): each fails it.

Earlier revisions of this branch, with the package still unscoped, showed on 9.3.2 that both tests fail without the socket-patch step and with the upstream bytes served as the patched tarball.

Linux x86_64 (the CI runner): both flows passed on the first run there, on all three releases (run 44062752971; checks npm / bazel (9.3.2, e9), (8.8.2, e9), (7.7.2, e9)). Test time on the runner, with no cache saved yet: 64 s on 9.3.2, 31 s on 8.8.2, 39 s on 7.7.2.

What starts on main

  • The caller is .github/workflows/bazel-npm.yml. It runs three Linux legs (Bazel 9.3.2, 8.8.2 and 7.7.2, all on the one MODULE.bazel) and one macOS leg (9.3.2).
  • Pull requests (opened, synchronize, reopened, ready for review; drafts are skipped) start the Linux legs when they change: the caller or the reusable workflow, the Bazel installer or its pins, npm.rs or harness.rs, the rules_js fixture, or the npm-family files of socket-patch-core that the two flows run through. Those are every file with pnpm in its name or directory, vendor/npm_*, vendor/lock_inventory/npm_family.rs, patch/redirect/npmrc.rs, patch/redirect/upstream/npm.rs, vex/discover/npm.rs, crawlers/npm_crawler.rs and formats/package_json.rs.
  • Pushes to main start them for the same paths and for what only a push covers: main.rs of the test target, the shared engine code (patch/redirect/**, vendor/**, hosted/**, the CLI's commands/**), the shared test helpers and the toolchain files. A main push outside the list waits for the nightly.
  • Nightly at 04:27 UTC, and on demand with workflow_dispatch. The macOS leg runs only then. The nightly has a concurrency group of its own, so a push to main cannot replace a nightly that waits.
  • The merge of this pull request starts the three Linux npm legs, and the three Go legs as well, because main.rs is in the Go caller's push list.
  • Outside hosts. The package and every Socket host are loopback stand-ins. A leg still reaches bcr.bazel.build on every run, and with an empty cache github.com with release-assets.githubusercontent.com and codeload.github.com (the Bazel release and the ruleset archives) and nodejs.org (Node). The list of hosts was measured on the first revision of this branch and not again.
  • Cache. The first leg to finish on main saves the repository cache bazel-repos-npm-e9-<os>-<arch>-<hash of the fixture>: 102 MB after one release here, 122 MB after all three. No tarball of a run can come from it, because every run builds its own.
  • Not required for merge. No merge_group trigger, and no job is a needs of ci-ok. The repository variable BAZEL_COMPAT_DISABLED turns every leg off.

Not claimed

  • macOS on a GitHub runner until the nightly. Windows at all.
  • Any other rules_js release, WORKSPACE, a lock in a sub-package, update_pnpm_lock = True, rules_nodejs npm_install, agent mode.
  • A Bazel 7 older than 7.6.0, the minimum the fixture's table gives rules_js 3.6.0. No leg runs one.
  • A transitive patched package, a package with lifecycle hooks, more than one importer. An unscoped package at this head: earlier revisions ran one on the three releases, the final head runs the scoped one only.
  • A fetch from the real patch host or over https. The lock pins a plain-http loopback URL, and the socket-patch child gets SOCKET_PATCH_SERVER_URL and SOCKET_NPM_REGISTRY so that rollback recognises the pin and finds the upstream entry. Production pins https://patch.socket.dev and needs neither.
  • What the real API and patch host return for a scoped package. The purl spelling (%40socketsecurity/...) and the URL shape (/patch/npm/@scope/name/<version>/<token>/<uuid>/<file>) are those of this repository's other tests and fixtures.
  • That pnpm writes this lock byte for byte. It is the 9.0 form, cut to one package by hand. No pnpm ran.
  • The rest of what vendored mode writes: only the package's entry of the lock is held, not its overrides: block or importer, and the four ledger files are held by name, the tarball by content.
  • That the undo removes an empty .socket directory: the tests compare files, not directories.
  • Whether the name @socketsecurity/bazel-fixture-upstream is registered. It was not looked up.
  • The released 5.1.0 binary at this head. The first revision passed against it with the unscoped package.

Known behaviour the flow records

  • Hosted mode adds a file beside a 9.0 lock. It creates pnpm-workspace.yaml with trustLockfile: true, to be committed with the lock. The scan's own warning (redirect_pnpm_trust_lockfile) says why: pnpm 11 and later reject the rewritten lock without it, and the setting makes pnpm skip its re-verification of every lock entry, while the sha512 pins stay enforced. The test holds the file's content; it does not hold the warning, and no pnpm ran.
  • The hosted lock entry carries the URL as the API hands it out, with its access-token level in the path.
  • A relock discards a hosted pin. The same warning tells the user not to rebuild the lock with pnpm. Not run here.
  • Vendored mode changes eight files (step 2), which the user commits together. For a scoped package the tarball sits in a directory named for the scope.
  • Other bytes are caught when Bazel fetches, not after. Step 5 asserts the failure on a second machine. An output base that already built the vendored tarball goes on building it after the committed file is overwritten: on 9.3.2 at this head the build and the run passed, printed the patched marker and made no request. An earlier revision saw the same on 8.8.2 and 7.7.2. No step asserts this. A step that did was removed in the first review round, because it could not tell an output base that does not read the file again from Bazel's repository cache handing the tarball out.
  • rollback needs the registry. It reads the upstream entry from the registry's version document, which for a scoped name it asks for as <registry>/@scope%2fname/<version>. With that document missing, rollback exits 1 with hosted_restore_refused and tells the user to restore the lock from version control. Seen in one run with the stand-in's document moved; in the suite the registry is the stand-in.
  • scan takes a scoped purl in either spelling and names the patch in its events as the API spelled it. With @ in place of %40 everywhere, both flows also pass.
  • The undo differs by mode: rollback --yes for hosted, vendor --revert for vendored.

Code review

First round

  • The vendored "stale file" step proved nothing. It overwrote the committed tarball and expected the patched build, but Bazel's repository cache already held that tarball. The step and its claims are gone.
  • Step 1 never checked that the upstream tarball came through the stand-in. On a warm cache a broken rewrite went unnoticed. The upstream tarball is now new for every run and step 1 asserts the stand-in registry was asked.
  • The caller's proxy and Node settings reached Bazel and the consumer. The shared harness answers this: it adds loopback to no_proxy and removes NODE_OPTIONS and NODE_PATH from every Bazel child. A dead HTTPS_PROXY still fails any flow, by design: the machine's proxy stays the way to the Bazel registry.
  • One path list served every ecosystem, and *npm* matched the bench fixtures. The npm legs have their own caller, with a list scoped to socket-patch-core and read from a coverage build of the binary under both flows.
  • The stand-in server and the generic steps were copies of the Go module's. npm.rs uses the harness's.
  • The committed lock's sha512 followed from the exact bytes the archive crates emit. No sum is committed any more.
  • npm.rs parsed the Bazel release itself to pick the downloader option. The harness names the downloader config.

Second round

  • This description was stale. Rewritten for the final head.
  • The fixture depended on fixture-upstream, an unscoped name anyone can register. A downloader rewrite that stopped applying, or a pnpm run in the fixture directory, would have asked the public registry for a stranger's package. The package is now @socketsecurity/bazel-fixture-upstream, in the fixture and in the test, and both flows pass on the three releases.
  • A comparison in the hosted flow could never be the assertion that fails. It said the patched build did not fetch the upstream tarball. After step 1 the repository cache holds that tarball, and a wrong fetch fails inside the build first. Deleted; the assertion that the patch route served the patched tarball stays.
  • The vendored flow never held the content of the pnpm-workspace.yaml it creates, although rules_js reads that file. It now compares the whole file.
  • The second machine's setup was copied between the two tests. A copy without the twin's downloader rewrite would have sent its Bazel to the first stand-in unnoticed. One helper, second_machine, serves both.
  • A path glob matched nothing (crates/socket-patch-core/src/vendor/npm_*/**). Removed from both lists; every remaining glob matches a tracked file, and the pull request list is a subset of the push list.
  • Left open: a Bazel 7 older than 7.6.0 fails in the harness with the harness's message instead of skipping. The message is the harness's, and a skip for a release below a ruleset's minimum is a harness change, which belongs to Run the hosted Go flow on real Bazel in CI #2107's files. No leg runs such a release.
  • Left open: grant mounts its own patch record ahead of the shared API mock's, because that mock's file hashes are fixed and vendored mode checks the downloaded file against them. The fix is in a helper that other test targets share. A comment at the route now says why it is there.
  • Left open: two small helpers repeat the Go module's (text, and the wrapper around the harness's socket_patch). They belong in harness.rs with its next change.
  • From Run the hosted Go flow on real Bazel in CI #2107's review: the nightly run has a concurrency group of its own, as in the Go caller.

Decisions for the owner

  • The package name. @socketsecurity/bazel-fixture-upstream is not published by this pull request and was not looked up. Say if another name under the scope is preferred; the rename is mechanical.
  • The three findings left open all sit in files that Run the hosted Go flow on real Bazel in CI #2107 owns or that other test targets share. Say if any of them should land in this stack before merge instead of with the next harness change.
  • Nothing here is required for merge.

🤖 Generated with Claude Code

The real-Bazel suite held one flow, hosted mode for a Go module. This
adds the two modes that reach an npm package Bazel builds:
aspect_rules_js reads pnpm-lock.yaml itself (npm.npm_translate_lock
under Bzlmod), so what a rewritten lock entry names is what the next
`bazel build` fetches. No file under crates/*/src changes.

Two tests, `npm::hosted_npm_translate_lock` and
`npm::vendored_npm_translate_lock`, on Bazel 9.3.2, 8.8.2 and 7.7.2,
with aspect_rules_js 3.6.0 and a lock of version 9.0. Each one, in a
fresh output base:

- builds the fixture workspace and reads "OUT: PRISTINE" from
  `bazel run //:consumer`;
- runs the one command of its mode and holds the changed files to its
  list. `scan --mode hosted --yes` rewrites the package's entry of
  pnpm-lock.yaml (integrity and tarball URL) and creates
  pnpm-workspace.yaml. `scan --mode vendored --yes` commits the patched
  tarball and its ledger under .socket/vendor and points pnpm-lock.yaml,
  package.json and a new pnpm-workspace.yaml at it;
- runs the same two Bazel commands and reads the patched marker, which
  holds an id made for the run. Hosted: Bazel fetched the tarball from
  the stand-in patch host. Vendored: Bazel read the committed file and
  asked the stand-in for nothing. Bazel changed no file of the checkout,
  and a `--lockfile_mode=error` build passes;
- runs the undo (`rollback --yes`, or `vendor --revert`): every file of
  the checkout is the one of before, byte for byte, and the build prints
  "OUT: PRISTINE" again;
- runs the command on a second machine (a new output base) against a
  second patch, with other bytes at the pinned place: served by the
  patch host, or written over the committed tarball. The build fails on
  the sha512 and does not take the registry's tarball in its place.

The checksum guards a fetch, and an output base fetches a repository
once. The vendored test holds that as well: when the committed tarball
changes after the build, that output base goes on building the bytes it
fetched, with no error. That is how Bazel and the ruleset behave, not
socket-patch; the step is there because it is the caveat of the mode,
and it goes when a release reads the file again.

The package is the tests' own, and no registry holds it. Its tarballs
are built in the test (tar under a gzip layer that stores, so the bytes
follow from the file contents alone), the fixture's lock pins the sha512
of the upstream one, and a hermetic test holds the two together: no
binary is committed. One loopback wiremock server per checkout plays the
Socket API, the patch host and registry.npmjs.org. The lock entry names
no URL, as pnpm writes it, so rules_js asks for the tarball at the
public registry's URL, and a downloader config in the workspace copy
rewrites that URL to the stand-in. The repository cache the tests of a
leg share holds the upstream tarball after the first fetch, so no test
counts the requests for it; a patched tarball is new for every run. For
the same reason a rewrite that stopped applying would show on an empty
cache only: Bazel then asks the public registry for the name, and the
first build fails on the answer or on the lock's sha512. The Bazel
registry, the ruleset archives and Node come from the network. No pnpm
runs, and no Node of the machine is used.

- crates/socket-patch-cli/tests/e2e_bazel_build/npm.rs: the tarballs,
  the stand-in, the two flows and two hermetic tests. harness.rs is
  unchanged.
- crates/socket-patch-cli/tests/fixtures/bazel/rules_js/bzlmod/{common,e9}:
  the workspace, with one MODULE.bazel for the three releases.
- .github/workflows/bazel-compatibility.yml: one Linux leg per Bazel
  release and one nightly macOS leg for `npm::`; the npm and pnpm
  source files and formats/package_json.rs in both path filters, and
  vendor/ in the push filter.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-rules-js

The harness now holds the stand-in server, the shared steps of a flow and
the downloader config, and bazel-compatibility.yml is a reusable workflow
with one caller per ecosystem.

The conflict in bazel-compatibility.yml is resolved to the harness
branch's file: the npm legs move to a caller of their own in the next
commit, which also ports npm.rs to the harness. Until then the npm module
does not build against the merged harness.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
npm.rs now takes the stand-in server, the steps every flow is made of and
the downloader config from harness.rs. Its own copies go, and with them
its parsing of the Bazel release for the downloader option.

The npm legs get a caller of their own, bazel-npm.yml, which calls the
reusable bazel-compatibility.yml as bazel-go.yml does. Its pull request
path list names the npm-family files of socket-patch-core that the two
flows run through, and no longer a `*npm*` glob over every crate, which
also matched the bench fixtures.

The upstream tarball is new for every run. Its entry file holds an id made
for the run, the test writes the sum of those bytes into the lock of its
workspace copy, and the fixture's own lock holds a placeholder. Until now
the fixture pinned one fixed sha512:

- Bazel's downloader took that tarball from the repository cache on every
  run but the first, so a downloader rewrite or a registry route that had
  stopped working went unnoticed. Step (a) now has to fetch the tarball
  from the stand-in registry and asserts that it did.
- The sum followed from the exact bytes flate2 and tar emit, so a bump of
  either could fail a hermetic test of an unrelated change. The hermetic
  test now holds what is still fixed: the one entry of the fixture's lock
  that a test pins, the version the fixture depends on, the names of the
  package, and that two runs serve two tarballs.

The vendored flow no longer overwrites the committed tarball between
steps (c) and (d). That build could not fail for the reason the step
gave: the repository cache holds the patched tarball under its checksum,
so a Bazel that fetched again would not read the file either.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The rules_js fixture depended on `fixture-upstream`, an unscoped name
that anyone can register on the public npm registry. The integrity a
test pins keeps Bazel from building foreign bytes, but a downloader
rewrite that stopped applying, or a pnpm run in the fixture directory,
would have asked the registry for a stranger's package. The package is
now `@socketsecurity/bazel-fixture-upstream`, under the scope this
repository publishes its own packages in. The rename goes through the
fixture's package.json, lock, BUILD file and consumer, and through the
test: the registry's tarball path, the purl (`%40socketsecurity/...`,
as this crate's tests spell the API's purl of a scoped package), the
quoted keys of the lock, the vendored tarball's path under a directory
of its scope, and the `%2f` name with which `rollback` asks for the
registry's version document. The hermetic test holds the name to the
scope.

In npm.rs:

- The hosted flow no longer compares the number of upstream fetches
  before and after the patched build. That comparison could never be
  the assertion that fails: after step (a) Bazel's repository cache
  holds the upstream tarball, and a wrong fetch fails inside the build
  before it. The assertion that the patch route served the patched
  tarball stays.
- The vendored flow compares the whole `pnpm-workspace.yaml` the
  command creates, as the hosted flow does for its own. rules_js reads
  that file, and until now only its presence was held.
- One helper, `second_machine`, sets up the second machine of step (e)
  for both flows. The two copies differed only in the mode and the
  bytes served, and a copy without the twin's downloader rewrite would
  have sent the twin's Bazel to the first stand-in unnoticed.
- The comment at the patch record of `grant` says why it is mounted
  ahead of the shared API mock's.

In bazel-npm.yml:

- The glob `crates/socket-patch-core/src/vendor/npm_*/**` leaves both
  path lists: no directory matches it.
- The nightly run has a concurrency group of its own, as in
  bazel-go.yml: in the group of main's pushes a second push would
  replace a nightly that waits, and the nightly is the only run with
  the macOS leg.

Tests, their fixture and their workflow only: no file under
crates/*/src changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 17, 2026 10:13
@cursor

cursor Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only and workflow additions with no changes to socket-patch production code; CI cost and path-filter scope are the main effects.

Overview
Adds npm to the real-Bazel e2e suite and wires it into CI, mirroring the existing Go flow from the stacked harness work.

A new npm test module exercises hosted and vendored scan against an aspect_rules_js Bzlmod workspace that uses npm_translate_lock on a pnpm 9.0 lock. Tests drive unpatched/patched builds, rollback/revert, checksum refusal on tampering, and assert registry traffic via loopback stand-ins. A smaller hermetic test validates fixture lock pinning without Bazel.

.github/workflows/bazel-npm.yml invokes the shared bazel-compatibility.yml on Linux for Bazel 7.7.2, 8.8.2, and 9.3.2, with path filters scoped to npm/pnpm-related code and fixtures; macOS runs on nightly/workflow_dispatch. The fixture under rules_js/bzlmod/ adds the consumer js_binary, placeholder lock integrity, and MODULE.bazel for rules_js 3.6.0.

Reviewed by Cursor Bugbot for commit 9194943. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for 9194943

What it does: On a pnpm-lock workspace under aspect_rules_js 3.6.0, it runs a hosted and a vendored scan, then rollback / vendor --revert, on real Bazel 9.3.2, 8.8.2 and 7.7.2. It asserts that the patched marker comes from the built output, that exactly the expected files change, and that a --lockfile_mode=error build passes. It also checks that a tampered tarball is refused on its sha512.

Risk: low. It adds only tests and an optional, non-required workflow.

Look here

  • npm.rs:225 lock_pinning and npm.rs:259 grant
  • npm.rs:379 refuses (the tampered tarball)
  • [npm.rs:425-440](https://github.com/SocketDev/socket-patch/blob/9194943cab80418b10265bedc05db94cd1864349/crates/socket-patch-cli/tests/e2e_bazel_build/npm.rs#L425-L440): the hosted lock entry and the patched build
  • [npm.rs:511-534](https://github.com/SocketDev/socket-patch/blob/9194943cab80418b10265bedc05db94cd1864349/crates/socket-patch-cli/tests/e2e_bazel_build/npm.rs#L511-L534): the vendored file set, with a check that no request is made

Verified: merged onto its base in a scratch tree, cargo test --test e2e_bazel_build passes on the non-ignored tests, and clippy is clean. The workflow's exact-name selection picks npm::hosted_npm_translate_lock and npm::vendored_npm_translate_lock. A socket-patch that did nothing would fail the pinned_by and OUT: PATCHED <uuid> checks. The diff has LF line endings and no debug leftovers. ci-ok and clippy are green.

Changes I made: none.

Open questions (minor)

Stacking and merge order: this PR's base is bazel-small/01-go-hosted-cells (#2107), not main, so it can merge only after #2107 lands and it is moved onto main. #2109, #2110 and #2111 each add one mod line after mod harness; in e2e_bazel_build/main.rs, so whichever lands second and third needs a one-line merge that keeps all three (mod npm; mod pypi; mod ruby;). With that resolved, all three build together and pass. I have not armed auto-merge here: on this base it would merge into #2107's branch instead of main.

Shared notes (#2109–#2111): none of these PRs touches ci.yml, ci-ok, the reusable workflow, harness.rs or CHANGELOG.md, and none has a merge_group trigger. After all three land, a Cargo.lock or CLI-source push to main starts 4 Bazel workflows × 3 Linux legs (45-minute timeout each). The macOS legs run only nightly or on dispatch, so their first nightly run is the first macOS test of this ecosystem.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 17, 2026
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.

1 participant