Skip to content

Route hosted pnpm pins through one named registry per patch - #2167

Merged
Mikola Lysenko (mikolalysenko) merged 27 commits into
mainfrom
mik/pnpm-named-registry
Nov 24, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 27 commits into
mainfrom
mik/pnpm-named-registry

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Summary

Hosted mode repoints pnpm-lock.yaml entries at the patch server. pnpm 11.10 and later check every lock entry that records a tarball URL against a registry, so the scan has been writing trustLockfile: true, which turns that check off for every entry in the lock, not only the patched ones. And a hosted entry does not survive pnpm resolving again: pnpm update and dedupe put the upstream tarball back on every release, and pnpm add does on pnpm 12.19 and later when the patched package has peer dependencies.

On pnpm 11.20 and newer, the scan now routes each patched release to the patch server as its registry. pnpm verifies those entries itself, lockfile verification stays on, and the patch stays installed across add, update and dedupe.

What the scan writes

Each patch gets its own named registry, socket-<first 8 hex digits of the patch UUID>, at the directory its tarball is served from, and one override that routes the patched release there. For three patches:

# pnpm-workspace.yaml
namedRegistries:
  socket-1417d719: https://<patch server>/patch/npm/@a2ui/web_core/0.9.2/<token>/<patch uuid>/
  socket-2a2a2a2a: https://<patch server>/patch/npm/zod-to-json-schema/3.25.2/<token>/<patch uuid>/
  socket-58f14d5a: https://<patch server>/patch/npm/picomatch/2.3.1/<token>/<patch uuid>/
overrides:
  '@a2ui/web_core@0.9.2': 'socket-1417d719:0.9.2'
  'zod-to-json-schema@3.25.2': 'socket-2a2a2a2a:3.25.2'
  'picomatch@2.3.1': 'socket-58f14d5a:2.3.1'

Every governing pnpm-lock.yaml is rewritten to exactly what pnpm writes for that configuration: the overrides: record, keys and references of the form picomatch@socket-58f14d5a:2.3.1, and the importer specifier of a direct dependency. No trustLockfile is written.

One registry per patch is deliberate. The patch service serves one fixed document per patch, which every project using that patch shares, so nothing it serves depends on a project's set of patches.

  • A name that is taken (two patches sharing eight digits, or a registry of the user's) takes four more digits at a time.
  • A registry is the CLI's only by its name together with its address. Everything else under namedRegistries and overrides is the user's and is never touched, and a lock key under a registry the user named socket is no longer read as a hosted release.
  • A user override on a package the scan would route means no route for the run, with the reason.

When the scan takes the route

All of these must hold. Otherwise the whole lock stays on trustLockfile as before, and the warning names the packages or the reason:

  • the project's own root pnpm-workspace.yaml is what pnpm reads, every governing lock is lockfile version 9, and it is not a Rush project;
  • every hosted pin has a registry address from the patch service, or is already routed in the files (a run granted only part of the project's patches leaves the rest routed);
  • the project's pnpm pins prove 11.20 or newer. pnpm 11.10 to 11.19 resolve through the registry but write another lockfile key form, so they stay on trustLockfile;
  • the pin is not on a patch mirror;
  • no rules_js hub of a Bazel workspace reads a governing lock (see "Bazel workspaces");
  • the lock is one of the shapes the rewrite is pinned against (see "What a user will notice").

Cleanup

Nothing of the route outlives its use. Per patch, the registry, the override, the lock's overrides: record and the registry-form keys go together.

  • Every hosted scan reconciles, with no extra flag: a dependency that was removed, upgraded past the patched version, or whose patch was withdrawn or replaced takes its entries with it, including leftovers no earlier run recorded.
  • repair and scan --prune do the same offline, from the files alone, and look in members' own locks too (sharedWorkspaceLockfile: false), where an override record of the route can be the only thing left. --prune in hosted mode is no longer described as ignored: the scan has already removed the entries, and the gc report counts them.
  • rollback, remove and a switch to vendored mode take a restored package's entries with it. A pnpm-workspace.yaml a run created is deleted once nothing else is in it; a user's file gets its bytes back.
  • The workspace overrides and the lock's overrides: record always change together, so a frozen install passes after every cleanup. Where they cannot (a governing lock that cannot be read, member locks that cannot be listed), the command refuses and changes nothing.
  • Each removal is reported (registry_entry_unused, gc.removedRegistryEntries), a dry run lists the same and writes nothing, and a registry address is never printed.
  • On a patch server the run was not told about, a cleanup command leaves such registries alone and says so (registry_cleanup_unknown_host), naming the origin and --patch-server-url.

Bazel workspaces

In a Bazel workspace the route is taken only where the files that were read make it certain that no rules_js hub reads a governing lock. A lock that an npm.npm_translate_lock names (the root lock or a member's own), or a call whose pnpm_lock is not written out, is never routed. Neither is one where a hub may be out of sight: a file that MODULE.bazel includes and that cannot be read, a use of the extension that is not a plain call, a WORKSPACE file that brings in rules_js or cannot be read. The project is then pinned exactly as on a patch service that offers no registry, which is the pin the Bazel CI legs build, and the warning names the call or what was not read.

  • The lock reader of rules_js is not the reason. Measured on real Bazel: rules_js 3.6.0 on Bazel 9.3.2 and rules_js 2.9.3 on Bazel 8.8.2 build a routed lock for a hub without update_pnpm_lock, and the built packages hold the patched bytes.
  • The pnpm a hub runs with update_pnpm_lock is. It sees pnpm-workspace.yaml only where the call lists it, and it may be older than 11.20. Run that way without the file, pnpm 11.28.13 and 12.22.0 reject a routed lock (ERR_PNPM_MISSING_NAMED_REGISTRY). No Bazel CI leg builds a routed lock yet, so lifting the rule is a follow-up.
  • A project routed before its hub was added leaves the route whole on its next scan (registry, override, the lock's record and the registry keys together) and ends on the pin.
  • Where the hub also hides pnpm-workspace.yaml from a pnpm 11 (redirect_pnpm_bazel_workspace_hidden), nothing is written for the root lock, so a route of an earlier run is left exactly as it is, in the workspace file and in every lock.
  • A hosted scan treats the lock the same whatever it was granted. A scan that is granted no npm patch, or that crawls nothing, leaves the lock and the workspace file to a hub that hides the workspace file, exactly as a scan with a patch does. A scan that crawls packages also keeps an emptied pnpm-workspace.yaml as the packages scaffold under a hub that reads or may read a lock, instead of deleting a file the hub may list. The scan that crawls nothing takes the offline sweep's path there (see "Not covered").
  • Where the route is left as it is, nothing is written, and no trustLockfile is added to a project that is still on per-package registries.
  • Not covered, and said in the docs: repair, scan --prune without a mode, rollback and remove settle a route from the lockfiles alone and read no Bazel file, here as on main, so they give the same files with and without a hub and can delete a workspace file the scan created even where a hub added later lists it. And the in-memory engine sees the project's own files only (beside a pnpm-lock.yaml or a pnpm-workspace.yaml it now asks for MODULE.bazel, the files it can include and the WORKSPACE files, as it already does beside a gem lock): a Bazel root above the project is not seen there, for the pin (as on main) and for the route.

What a user will notice

A patched package stays at the patched version until the next scan. The override that routes a release is an ordinary pnpm override, and pnpm applies it to every dependency whose range admits that version, direct or transitive. So pnpm update and pnpm dedupe keep the package at the patched version even when a newer release would satisfy the range. To take a newer release, change the dependency to a range that no longer admits the patched version, or run socket-patch remove <package>; the next scan then drops the registry and the override, or routes the new version if it has a patch.

A dependent on a newer release in range moves to the patched one. Measured with real pnpm: with one package on leaf 1.0.0 (patched) and another on ^1.0.0 locked at 1.5.0, a frozen install and a plain pnpm install leave the scan's lock byte for byte, pnpm update and pnpm dedupe move the second package to the patched 1.0.0 on every release from 11.20.0 to 12.22.0, and pnpm add does on pnpm 11 only. The lock does not record a transitive dependent's range, so the scan cannot rule this out; it adds a note naming the package and both versions when a governing lock holds a newer release in the routed release's caret range.

Some lock shapes stay on trustLockfile. The scan does not take the route where it cannot write what pnpm writes, and says why:

  1. a package installed both with and without the patched release as its peer dependency, which pnpm 11 and pnpm 12 lock differently;
  2. the patched release installed as another package's optional peer dependency: pnpm resolves that copy from the default registry, around the override, so on the route it would be the unpatched package;
  3. a routed release whose deprecation message spans several paragraphs.

A replaced patch renames its registry. A new patch has a new UUID, so the scan that picks it up renames that release's lock keys, not only its tarball.

Backend dependency

Needs the matching change in Socket's backend: the npmRegistryUrl field on a package reference (the directory of the artifact URL), and a registry document there that carries the package's own dependency fields. Against a patch service without the field nothing changes.

Release order. pnpm takes a routed package's dependencies from the registry document, never from the tarball, so the backend offers the address only for a patch whose dependency fields it has stored. The production patch service does that as of 2026-11-24, and it is still filling in the fields of older patches. Until a patch has them, a project that pins it stays on trustLockfile and the scan names the package. A release is best cut once that backfill has finished.

Testing

  • cargo fmt, cargo check, and clippy in the CI form: clean.
  • Core suite: 9226 passed, 0 failed.
  • CLI suite: 5757 passed, 2 failed. Both failures are in e2e_vendor_cargo_build.rs, which this change does not touch; they fail the same way on main on the machine that ran them (an x86_64 toolchain it cannot execute).
  • Golden lockfiles generated with real pnpm 12.22.0 and byte-identical on 11.20.0, 11.25.0, 11.28.13, 12.0.0, 12.4.2, 12.10.0, 12.16.0, 12.19.0 and 12.21.0 (the generator fails otherwise). The scan reproduces every routed case byte for byte through the whole engine.
  • Real-pnpm legs against two loopback servers, on 11.20.0, 11.28.13, 12.0.0, 12.19.0 and 12.22.0: pnpm re-locks the scan's files unchanged; a fresh-store frozen install lands patched bytes; add, update, dedupe and install --fix-lockfile keep a peer-dependent package and a transitive leaf routed; a frozen install passes after each cleanup by scan, repair --offline and scan --prune. On 11.20.0 and 12.22.0, a project routed before a Bazel hub was added: the scan changes neither file where the hub hides the workspace file, or takes the whole route out in one run and pins the release; a fresh-store frozen install lands patched bytes after either.
  • The hosted flow of the Bazel npm CI legs now has a patch service that offers the registry and a checkout that proves pnpm 12, and asserts the rule: pinned on trustLockfile under the plain key, the warning names the hub's call, and the Bazel build of that pin is the patched one. Run here on Bazel 9.3.2 before the push, together with the flow for a hub that keeps the lock up to date with a pnpm 11; both pass.
  • Real Bazel on the project routed against production (two routed releases, one with peer dependencies), for a hub without update_pnpm_lock: rules_js 3.6.0 on Bazel 9.3.2 builds it, and the built braces and next equal pnpm 12.22.0's own install of the same lock apart from the README, changelog and licence files rules_js leaves out of every package. rules_js 2.9.3 on Bazel 8.8.2 builds the same lock with the same result once the lock is one it can read at all (it reads no two-document lock that pnpm 12 writes for a project with packageManager, routed or not).
  • End to end against the production patch service, with real pnpm 12.22.0 and no credentials (free patches), on a project with next 15.1.11, react, react-dom and braces 3.0.2 and its own pnpm-workspace.yaml: the scan added two registries and overrides beside the project's own setting; pnpm re-locked unchanged; a fresh-store frozen install passed with verification on and installed next with its dependencies; add, update and dedupe kept both packages routed; after pnpm remove next, repair --offline removed exactly its three entries and the next scan changed nothing; rollback restored the workspace file and the lock byte for byte. A second project whose selected patch has no stored fields yet stayed on trustLockfile, with the package named in the warning.
  • Repeated against production on the final head: same project, same results. And the same project inside a Bazel workspace whose hub reads the lock (rules_js 3.6.0, Bazel 9.3.2): the scan took no route, pinned both packages on trustLockfile beside the project's own setting and named the hub's call; the Bazel build passed, and every file Bazel built for braces and next is identical to pnpm's install of the patched packages.
  • End to end against a second deployment of the patch service, with real pnpm 12.22.0: the scan wrote two registries and overrides; pnpm re-locked unchanged; a fresh-store frozen install passed with verification on and installed patched bytes with the patched package's dependencies; add, update and dedupe kept both packages routed; after pnpm remove of one, scan removed exactly its three entries and repair --offline left identical files; rollback deleted the created workspace file and restored the lock byte for byte.

Code review

/code-review high returned ten findings. Each confirmed one was reproduced by a failing test before its fix.

  • Fixed (8): a lock key under a registry the user named socket, socket-patch or socket-N was read as a hosted release; leaving the route or rolling back with a lock that could not be read, or member locks that could not be listed, stripped the workspace entries and left the lock routed; --no-trust-lockfile-config with a replaced patch repointed the tarball under the old registry's key; a workspace file the route created was kept and given trustLockfile when the project left the route; a multi-line deprecated: value was removed as one line; two doc comments described an abandoned design; the lock was rescanned once per touched package (246 ms to 19 ms on a 61,000-line lock).
  • Refuted (1): a user override in package.json. pnpm 11.20.0 to 12.22.0 read no override from package.json (pnpm.overrides with a warning, resolutions silently), measured and asserted in the real-pnpm leg.
  • Not fixed (1), by decision: the dependent on a newer release in range, described above. It is how pnpm applies an override and cannot be decided from the lock, so the scan notes it instead of refusing the route.
  • Review bot (2 findings), both confirmed and fixed: the delete of an emptied pnpm-workspace.yaml read the file with an unguarded read after its lstat, so a FIFO put there in between made the command wait; the probe that decides whether a cleanup looks for a route read the root files alone, so an override record left only in a member's own lock stayed (repair answered manifest_not_found). One more found on the way: a scan that selects no patch took the registries and overrides out of the workspace file while members' own locks still routed through them.
  • Two more passes over the Bazel interaction (the commits that merged main's guard). The first returned ten findings, all confirmed and fixed, five of them reproduced by a failing test first: the route was still taken where a hub could be out of the reader's sight; a scan granted no npm patch pruned what a scan with one leaves to the hub; trustLockfile was appended where the route was reported as left as it is; every pnpm refusal was read as the Bazel case; the warning gave a path from the Bazel root without saying so; and the Bazel files and the members' locks were read more than once, with disk reads inside the planner. A re-check of those fixes returned ten more: six fixed (the in-memory engine did not ask for the Bazel files of a workspace with no root lock; the scan that crawls nothing and the engine decided the hub's answer differently; a hosted run deleted an emptied workspace file under a hub that only reads the lock; a WORKSPACE file about something else blocked the route; a withheld root lock was not counted when deciding that no trustLockfile is needed; a link put in the file's place during the read could be unlinked), two documented as limits (the two under "Not covered" above), and two left: a no-patch hosted run in a per-member workspace reads the members' locks more than once, and a cleanup helper is threaded through three callers that ask once.
  • Left as is: a registry the user names exactly socket-<8 to 32 hex digits> is still read by its name. The per-pin copy of the lock was measured and left.

Not verified

  • Windows and Linux. The real-pnpm legs ran on macOS only; CI runs them on all three.
  • The pnpm that CI's legs get through corepack; explicit binaries were used locally.
  • scan --sync end to end in a wet run (it shares the --prune pass, which is covered).
  • pnpm releases newer than 12.22.0.
  • Under real Bazel: update_pnpm_lock = True on a routed lock, rules_js 4 alpha, a WORKSPACE hub, Linux and Windows. The rule above keeps a lock that a hub reads off the route, so none of these is reached for a hub the reader sees.
  • repair and scan --prune say nothing about a lock key whose registry the workspace file no longer declares; a hosted scan that is granted the patch restores the route around it.

Generated by Claude Code

On pnpm 11.20 and newer, hosted mode now has pnpm verify each patched
package against the patch server instead of trusting the whole lock,
and keeps the patch installed when pnpm resolves again.

What the scan writes. Each patch gets its own named registry in
pnpm-workspace.yaml, `socket-<first 8 hex digits of the patch UUID>`,
whose address is the directory the patch's tarball is served from (the
grant's `npmRegistryUrl`, used verbatim). An override routes the patched
release to it (`'name@version': 'socket-<id>:version'`), and every
governing pnpm-lock.yaml is rewritten to exactly what pnpm writes for
that: the `overrides:` record, `name@socket-<id>:version` keys and
references, importer specifiers. No `trustLockfile` is written.

- A name that is taken (two patches sharing eight digits, or a registry
  of the user's) takes four more digits at a time.
- A registry is the CLI's only by its name together with its address, a
  patch's directory on a patch server; everything else under
  `namedRegistries` and `overrides` is the user's and is never touched.
  A lock key under a registry the user named `socket` is not read as a
  hosted release.
- The route is taken only when every hosted pin has an address and the
  project's pnpm pins prove 11.20; otherwise the whole lock stays on
  `trustLockfile` and the warning names the packages or the reason. A
  run granted only part of the project's patches leaves the rest routed.
  A pin on a patch mirror stays on `trustLockfile`.
- Lock shapes pnpm does not lock as a respelling stay on
  `trustLockfile`: a package installed with and without the patched
  release as its peer, a patched optional peer, and a routed release
  with a multi-paragraph deprecation message.
- A patch replaced by a newer one has a new UUID, so its registry is
  renamed and the release's lock keys with it.
- An override holds every dependency whose range admits the patched
  version. When a governing lock also holds a newer release in that
  range, the scan notes that pnpm may move its dependents to the
  patched one the next time it resolves.

Cleanup. Nothing of the route outlives its use, per patch: the registry,
the override, the lock's record and the registry-form keys go together.
Every hosted scan reconciles them; `repair` and `scan --prune` do it
offline from the files alone; `rollback`, `remove` and a switch to
vendored mode take a restored package's entries with it. Each removal
is reported (`registry_entry_unused`, `gc.removedRegistryEntries`), a
dry run lists the same and writes nothing, and a pnpm-workspace.yaml a
run created is deleted once nothing else is in it. A registry address
is never printed.

- The workspace overrides and the lock's record change together. A
  lock that cannot be read, or member locks that cannot be listed,
  keep the route whole: leaving the route does nothing and rollback
  refuses the pin.
- With `--no-trust-lockfile-config`, a routed release stays on the
  patch it is routed to (`redirect_pnpm_registry_held`).
- On a patch server the run was not told about, a cleanup leaves such
  registries alone and says so (`registry_cleanup_unknown_host`).

The lock rewrite is pinned byte for byte to real pnpm by golden
fixtures (scripts/gen-pnpm-registry-override-golden.mjs), generated
with pnpm 12.22.0 and identical on 11.20.0 through 12.21.0. Real-pnpm
e2e legs cover frozen installs, `pnpm add` / `update` / `dedupe` /
`install --fix-lockfile`, a newer release in range, and every cleanup.

Shapes written by unreleased builds of this branch are converted or
removed by the next scan.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) changed the title Declare hosted pnpm pins as named registries instead of trusting the lock Route hosted pnpm pins through one named registry per patch Nov 23, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 24, 2026 16:32
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes how hosted pnpm pins are wired and lockfiles/workspace YAML are rewritten, with broad impact on install/resolve behavior; cleanup touches shared project files and needs correct patch-server host configuration to avoid leaving stale registry state.

Overview
pnpm hosted mode now prefers a per-patch registry route (namedRegistries + overrides in pnpm-workspace.yaml, matching lock keys) when pnpm ≥11.20 and eligibility checks pass, instead of only writing trustLockfile: true. The CLI contract documents gating, supersede/rename behavior, user-registry safety, and mirror mode (still trustLockfile).

Unused route entries are reconciled from lockfiles alone: every hosted scan, repair cleanup (including hosted-only projects), and scan --prune / --sync remove registries/overrides/lock records nothing references. New registry_gc drives sweep_pnpm_registry_route, emits registry_entry_unused events and gc.removedRegistryEntries, and surfaces registry_cleanup_* warnings (unknown patch-server host, skipped/failed I/O). Hosted scans without patches still take the lock to tidy routes; empty CLI-created pnpm-workspace.yaml can be deleted after cleanup.

CLI/contract updates: --no-trust-lockfile-config opt-out covers the registry write or trustLockfile; human reminders distinguish named-registry vs trust paths; JSON GcReport gains removedRegistryEntries.

Reviewed by Cursor Bugbot for commit 1825ed6. Configure here.

@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.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

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

Reviewed by Cursor Bugbot for commit 1825ed6. Configure here.

Brings in the guard for Bazel workspaces whose rules_js hub keeps
pnpm-lock.yaml up to date with a pnpm 11 that does not see
pnpm-workspace.yaml: hosted mode writes nothing for that lock and
warns (redirect_pnpm_bazel_workspace_hidden).

Conflicts:

- hosted/engine.rs (tests): both tests are kept, the one that routes
  the members' own locks through the root workspace file and the one
  that pins them beside a root lock a Bazel hub withholds.
- patch/redirect/upstream/npm.rs: the undo of a hosted pin keeps the
  branch's order (the lock's record of the overrides, the named
  registries, then the trust key) and asks main's shared check whether
  the workspace file is the one hosted mode creates.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A hosted scan that selects no patch tidies what is left of the pnpm
registry route. In a workspace that keeps one lock per member
(sharedWorkspaceLockfile: false) it read the root lock alone, which
holds no patched package, so it took the registries and the overrides
out of pnpm-workspace.yaml while the members' locks still routed their
releases through them. pnpm then refused those locks.

Such a run now reads the members' own locks whenever the root files
name a route, as a run with a patch does, so an entry goes only when no
lock of the workspace uses it. A test holds both: nothing changes while
a member routes the release, and the route goes whole once none does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hosted mode routes a patched pnpm release through a named registry of
pnpm-workspace.yaml when the patch service offers one and the project
pins pnpm 11.20 or later. A rules_js hub of a Bazel workspace reads the
same lock with its own lock reader, and with update_pnpm_lock with a
pnpm that sees the workspace file only where the call lists it. Run as
the hub runs it, without that file, pnpm 11.28.13 and 12.22.0 reject a
routed lock (ERR_PNPM_MISSING_NAMED_REGISTRY), and no Bazel build has
been run on a routed lock. A scan that exits 0 must not leave a build
that fails.

So a lock that an npm.npm_translate_lock names (or may name: a
pnpm_lock that is not a plain string) is never routed. The project is
pinned exactly as on a patch service that offers no registry, which is
the pin the Bazel legs build, and the warning names the call. A project
routed before the hub was there leaves the route whole on its next
scan, the locks and the workspace file together.

Where the hub also hides the workspace file from a pnpm 11, main's
answer comes first, while the files are read, and the root lock is not
part of the run. The route then changes nothing at all: the members'
own locks are pinned on trustLockfile, and a route of an earlier run
stays as it is in the workspace file and in every lock, because the
root lock records the same overrides and is not written. Taking the
entries out of the file alone would have left a lock pnpm refuses.

A pnpm-workspace.yaml that holds nothing but a route and that the hub
lists now counts as a file that holds only what hosted mode writes:
the scan that leaves the route would turn it into the file rollback
removes, and the call would name a missing file.

repair, scan --prune with no mode, rollback and remove settle a route
from the lockfiles alone and pin nothing; tests hold them to the same
result with and without the hub.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The warning of a project whose pnpm lock a rules_js hub reads had runs
of spaces in it, and it and the docs said that no Bazel build had been
run on a routed lock. One has now: rules_js 3.6.0 on Bazel 9.3.2 builds
a routed lock for a hub without update_pnpm_lock, with the patched
bytes in the built packages, and rules_js 2.9.3 on Bazel 8.8.2 does
too.

The warning, the module docs and the docs now say what was measured
and what holds the route back: the pnpm a hub runs with
update_pnpm_lock sees pnpm-workspace.yaml only where the call lists it
and may be older than pnpm 11.20, and no Bazel leg builds a routed
lock that way yet. The rule is unchanged: a lock that a hub reads
keeps the trustLockfile pin.

A real-pnpm leg holds the project that was routed before its hub was
added, on pnpm 11.20.0 and 12.22.0. Where the hub hides the workspace
file from a pnpm 11, the scan changes neither file. Where the hub only
reads the lock, the scan takes the registry, the override, the lock's
record and the registry keys out in one run and pins the release. A
frozen install from an empty store lands the patched bytes after
either.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A hosted scan that takes the last of a registry route out of a
pnpm-workspace.yaml it created deletes the file, after checking that
it is still the regular file the run wrote. The check of what is at
the path and the read were two steps, and the read was a plain one: a
FIFO or a device put there in between made the command wait in open(2)
with no timeout.

The read now goes through the opener every other project file is read
with, which never blocks and refuses what the opened handle shows is
no regular file. A test holds the read to that with a FIFO at the path
(it waited out its five seconds before), and another holds the step as
a whole: the file the run wrote goes, a changed file, a link and a
FIFO stay with the reason.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
repair, scan --prune and a hosted scan that crawls no package tidy
what is left of the pnpm registry route only where a probe says the
project holds some of it. The probe read the root pnpm-workspace.yaml
and the root lock alone. In a workspace that keeps one lock per member
(sharedWorkspaceLockfile: false), a member's lock can be the only file
that still records an override of the route, and pnpm then refuses a
frozen install of that member. The three commands did nothing there,
and repair answered manifest_not_found.

The probe now reads the members' own locks too, and a hosted scan that
is granted nothing reads them on the same answer. In the golden
workspace with the route taken out by hand everywhere but in one
member's lock, each of the three takes the unused record out and the
project is the one pnpm locked, byte for byte.

A release that a member's lock still keys by a registry is no
leftover: none of these commands restores a pin. It stays, and a
hosted scan that is granted the patch puts the whole route back around
it. Tests hold both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings in four changes of main: a hosted NuGet pin is withheld where a
rules_csharp hub would not take it, a hosted gem is left alone while a
rules_ruby hub holds it to another sha256, the BUILD.bazel that
cargo-bazel writes into a vendored crate is accepted, and a scan says
when a merged patch is not ready yet.

No conflicts. The NuGet and gem answers ride to their rewriters under
keys of their own in the files a run reads, beside the pnpm locks the
registry route works on, and neither touches the other.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
"This lock keys a release by a registry of ours, or records an override
that routes one there" was written out four times: in the probe of
what a route left behind, where a scan decides whether a project was
routed, where it takes a route back out, and in the offline sweep.
OverrideLock::holds_route() is that question now, and the four ask it.
No behaviour changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The plan of the pnpm registry route asked the Bazel workspace itself
whether a hub reads a lock: a walk to the git root and a second parse
of MODULE.bazel, synchronously, inside the planner, on every pass. And
it took any refusal of the root pnpm lock for the Bazel one, so the
route was blocked there only because the two readings happened to
agree.

The workspace is now read once, where the files are read and off the
async runtime, and that one read answers both questions: whether a hub
keeps the root lock out of the run, and whether one reads a lock. The
answers travel with the files (CandidateFiles::pnpm_bazel), and the
planner is a function of what was read. A root lock that a hub keeps
out of the run blocks the route by that answer alone, with a reason of
its own, and a pnpm refusal of another kind is no longer read as it.

judge and the reader share one helper for the lock a hub call names.
No run changes its files: a test holds the plan to the carried answer
on a checkout with no Bazel file at all.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A scan routed a pnpm lock through a named registry in a Bazel
workspace whenever no npm.npm_translate_lock call that it had read
named the lock. A hub it could not see reads the lock all the same:
one that a WORKSPACE file defines, one in a file that MODULE.bazel
includes and that is missing or was not handed to the in-memory
engine, one behind a use of the extension that is not a plain call.
The pnpm such a hub runs would reject or rewrite the routed lock.

The answer for a pin passes over what it cannot see, so that no
project loses a patch. Declining the route costs nothing, the project
gets the pin it gets today, so here doubt decides: the reader's doubts
about the workspace or about the hub's tags, and a WORKSPACE file that
says more than workspace(...), each keep the project off the route,
and the warning names what was not read. A pnpm_lock that is no label
counts as one that may be any lock.

The in-memory engine now asks for the same Bazel files beside a pnpm
lock as beside a gem lock (MODULE.bazel, the files it can include and
the WORKSPACE files), so that it gives the answer of a checkout.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The warning of a pnpm project that stays off the registry route named
the hub's call as `MODULE.bazel:7`. For a project in a directory of
the Bazel workspace that file is at the workspace's root, and a run in
the project's directory has no file of that name beside it. The
warning now says that its paths are from the root of the Bazel
workspace, as the warning for a lock that is left to the hub does, for
a call and for what could not be read alike.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A hosted scan that is granted an npm patch asks the Bazel workspace
about the pnpm lock, and where a hub would fail on a pin it leaves the
root lock and pnpm-workspace.yaml alone. A scan granted no npm patch
did not ask. In a project routed before the hub was added it took the
unused entries of the route out of the lock and the workspace file,
and with the last of them deleted the file a hub lists in its data, so
the next bazel build failed on a missing file. Whether that happened
turned on an unrelated patch being granted.

Both no-patch paths now give the answer of a run with a patch: the
scan that crawls packages and is granted nothing asks Bazel where the
files are read, and the scan that crawls nothing asks before its sweep
of the lockfiles. Each leaves the files and reports
redirect_pnpm_bazel_workspace_hidden. A project that holds nothing of
a route is still read no Bazel file for.

repair and scan --prune without a mode are unchanged: they settle a
route from the lockfiles alone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Where a Bazel hub keeps the root pnpm lock out of a run, the members'
own locks that an earlier run routed stay routed, and the run reported
the route as left as it is. It still wrote `trustLockfile: true` to
pnpm-workspace.yaml: the routed entries carry the patch server's
tarball, and the run took that for a pin that needs the key. The key
switched pnpm's verification off for the whole lock of a project that
was still on per-package registries, in a run that wrote no lock.

Such a run now writes nothing to the workspace file, which is byte for
byte what it was, and says that the route stays instead of that the
patches rely on trustLockfile. A release the run pins in the plain
shape beside the routed ones still brings the key, which that pin
needs. The test asserted a prefix of the file and so passed over the
appended line; it now holds the run to no file and no edit.

Where a route stays because a lock could not be converted back, the
project no longer qualifies for it, and the key is still written as
the fallback, as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every hosted scan, repair and scan --prune first asks whether the
project holds anything of the pnpm registry route. Since that question
looks in the members' own locks, it was expensive for a workspace that
keeps one lock per member and never had a route: every call globbed
the members and parsed each of their locks in full, the hosted scan
asked whether or not the answer could matter, and a --prune pass asked
again before its sweep. A scan granted nothing then listed the members
and read their locks a second time.

Now a lock is parsed only when its bytes name a route, the workspace
file settles the question for a routed project before any lock is
read, and a project without a workspace file lists no members. A
hosted scan asks only when it selects no patch or was told to prune,
each GC pass asks once and its sweep reuses the answer, and a scan
granted nothing lists the members once for the question and for the
read.

A test holds the cheap test to the parsed answer on every lock of the
golden projects, routed and not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The step that deletes an emptied pnpm-workspace.yaml looked at the
path, and then read it through a one-line function that existed only
so that a test could call the read past that look. The look is now for
a link alone, which is never followed or removed in the file's place.
What else is at the path is settled by the opener itself, on the
handle it opened: a FIFO or a device is refused there without a wait,
and nothing stands between the check and the read.

The test drives the whole step with a FIFO at the path under a
timeout. Against a plain read it waits the timeout out and fails.

The MODULE.bazel of a hub was written out in two test modules of the
core crate; they share one fixture now. The copies in the CLI's
integration tests stay: each of those files is a crate of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hosted mode does not route a pnpm lock through a named registry where
a rules_js hub reads the lock. Nothing that runs a Bazel checked it:
the stand-in patch service of the Bazel npm flows offered no registry,
so the route was never in question there.

The hosted flow on real Bazel now has both things the route asks for.
Its patch service offers the patch's registry, and the checkout
carries pnpm 12's mark in node_modules, which Bazel does not read. The
flow's own assertions then say what the rule says: the lock is pinned
on trustLockfile with the package under its plain key, the warning
names the hub's call, and the Bazel build of that pin is the patched
one.

A test without a Bazel runs the flow's other steps on the same
arrangement (the scan and its documents, the second scan, the undo),
and shows that the same files in a checkout that is no Bazel workspace
are routed, so the offer is live and the hub is what decides.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings in the hosted scan that takes the jars a pinned
rules_jvm_external hub builds for its packages, and that takes a stale
entry out of the Bazel workspace's block.

One conflict, in the JSON output of a hosted scan that crawls nothing
(commands/scan/mod.rs). Main records its sweep of stale entries there
and reports no rewritten file; the branch reports the files that the
pnpm registry cleanup took entries out of. Both are kept: the sweep is
recorded first, and the `redirect` block names the cleanup's files.

The two do not meet. The sweep runs first, under the apply lock, and
writes the Maven block of a Bazel workspace; the cleanup runs after it
under its own lock and writes pnpm-workspace.yaml and the pnpm locks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The merge of main left two things in the hosted scan that crawls
nothing: main's sweep of a stale entry of the Bazel workspace's block,
and the cleanup of what a pnpm registry route left. The test puts both
in one project and holds the run to both: the entry leaves the block,
the route's three entries leave the lock and the workspace file, and
the envelope carries the event of each and names the route's files as
what the run rewrote.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The in-memory engine was handed the Bazel files of a workspace only
beside a root pnpm-lock.yaml. A workspace that keeps one lock per
member can have none, and a hub can read a member's own lock: on disk
such a lock is kept off the registry route, and in memory, where
MODULE.bazel and WORKSPACE were never fetched, it was routed.

Path selection now asks for those files beside a pnpm-workspace.yaml
as well, which is what marks such a root.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A hosted scan that takes the last of a registry route out of a
pnpm-workspace.yaml it created deletes the file. Under a Bazel hub
that reads the pnpm lock and lists that file in its data, the next
build would be handed a missing file. A scan with no npm patch did
this where the hub reads the lock but runs no pnpm of its own, the one
case in which the lock is not left to the hub altogether.

A hosted scan now deletes the file only where no hub reads, or may
read, a lock of the project. Under such a hub the unused entries still
go and the file stays as the `packages` list it was created with.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A hosted scan that crawls nothing asked whether a Bazel hub would fail
on a pin in the root pnpm lock without looking for that lock. The scan
that crawls a package asks the same and drops the answer where the
project has no root lock, as a workspace with one lock per member can.
So in such a workspace the two disagreed: the first tidied what a
route had left in a member's lock, and the second left it and said
that a pnpm-lock.yaml which does not exist "was not rewritten".

The rule now sits with the answer itself: a project with no pnpm lock
is asked nothing, and one without a root lock has no lock to leave to
a hub. Both paths go through it, with the root lock read the same way.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Any WORKSPACE file that said more than workspace(...) kept a pnpm
project off the registry route, as a place where a rules_js hub might
be defined unseen. A Bazel 8 or 9 repository that keeps such a file
for an unrelated http_archive has no hub there.

The file now counts only where it cannot be read or brings in
rules_js: a load from @aspect_rules_js, a load of npm_translate_lock
from anywhere, or a call of that rule under its own name or one a load
gives it. That is how the other rulesets' lanes read the file. The
warning names the line. A macro of a .bzl file that makes the call is
not looked at, as there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Where a Bazel hub keeps the root pnpm lock out of a run and the
members' locks stay routed, the run writes no trustLockfile when every
hosted entry is under a key of its registry. It asked that of the
locks it had read, which leaves out the very lock the hub withholds. A
plain hosted pin there, from before the hub was added, is one that
pnpm takes only with the key: the run reported the project as settled
on its registries, wrote nothing, and pnpm 11 would reject that entry.

The withheld root lock is now read for this one question and counted
with the others, so such a project gets the key as it did before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The step that deletes an emptied pnpm-workspace.yaml refuses a link at
the path, then reads the file through an opener that follows links,
then unlinks the path. Its comment said that a link is never removed
in the file's place. A link that took the file's place between the
look and the read, to a file with the same bytes, was read through and
then unlinked.

The path is now looked at once more after the read, and only what is a
regular file at that look is unlinked. The comment says what the code
does, and what it cannot: there is no unlink by handle, so the last
look and the unlink are still two steps.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two limits of the pnpm registry route in a Bazel workspace were true
of the code and missing from the docs.

repair, scan --prune without a mode, rollback and remove read no Bazel
file. Under a hub whose data lists a pnpm-workspace.yaml that a routed
scan created, they still delete that file with the last of the route,
and the build is then handed a missing file. The docs now say so where
those commands are described, with the way round it.

The route is taken "only where it is certain that no hub reads the
lock". In memory that is certain of the files the engine was handed,
and a Bazel root above the project is not among them, for the route as
for the pin. The docs and the module docs say that beside the claim.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants