Repository navigation
Route a hosted pnpm lock under a rules_js hub whose build takes a routed lock - #2232
Mikola Lysenko (mikolalysenko) wants to merge 7 commits into
Conversation
…rkspace file Tests only. They record what hosted mode does today for two cases of a hub that keeps its lock up to date (`update_pnpm_lock = True`), lists the user's `pnpm-workspace.yaml` in `data` and runs pnpm 11.28.10. The next commit changes both. A registry is offered. The patch service offers the patch's own registry and the checkout proves pnpm 12, so outside Bazel the lock would be routed through a named registry. Beside the hub hosted mode pins the lock with `trustLockfile: true` instead and says the hub is why. Three flows build that pin on a real Bazel, one for each way a workspace states the pnpm of a hub that socket-patch reads as written out: `pnpm_version` on the `pnpm.pnpm` tag, `pnpm_version_from` with the `packageManager` of `package.json`, and a `use_pnpm` label for the repository of a named tag. Each ends in the patched build, and `rollback` in the upstream one. The scan is told not to write the setting (`--no-trust-lockfile-config`). It exits 0 and pins the lock without `trustLockfile: true`, and the pnpm that Bazel runs rejects that lock: the build fails with `ERR_PNPM_TARBALL_URL_MISMATCH` until `rollback`. This is the known problem that docs/ecosystems.md lists for such a hub, measured by hand so far; a flow now builds it. Two tests without Bazel hold the same files and warnings, the second also for a hub that runs pnpm 10, which has no such check. The flows ran on Bazel 9.3.2, 8.8.2 and 7.7.2 (macOS) against this commit's product code. The workflow runs every `npm::` flow of the target, so its legs pick them up; its header names them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ted lock Hosted mode can route a patched pnpm release through a named registry of pnpm-workspace.yaml in place of `trustLockfile: true`. So far it never did for a lock that an `npm.npm_translate_lock` hub of a Bazel workspace reads, because no build had shown what the pnpm of a hub with `update_pnpm_lock` does with such a lock. And a scan under `--no-trust-lockfile-config` on such a hub exited 0 with a pin that the pnpm of the build rejects (`ERR_PNPM_TARBALL_URL_MISMATCH`), a known problem of docs/ecosystems.md. What was built, on Bazel 9.3.2, 8.8.2 and 7.7.2 with rules_js 3.6.0 (macOS), with a lock that hosted mode routed: - A hub without `update_pnpm_lock` builds the patched package. A second build changes no file, a `--lockfile_mode=error` build passes right after the scan, and `rollback` restores every file and the upstream build. - A hub with `update_pnpm_lock = True`, pnpm-workspace.yaml in `data` and pnpm 11.20.0, 11.28.10 or 12.17.0 does the same. Its pnpm asks the patch's registry about the package and writes the lock back as it is, also after a `package.json` asks for another package. The pnpm was stated by `pnpm_version`, by `pnpm_version_from` and by a `use_pnpm` label. - The same hub without the file in `data` fails the build (`ERR_PNPM_MISSING_NAMED_REGISTRY`). - With the file and a pnpm below 11.20 the first build is the patched one, but once that pnpm resolves again pnpm 11.19.0 puts the upstream release back without a word and pnpm 10.34.9 fails the build (`ERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER`; Bazel 9.3.2). - A hub of the first shape with a `patches` entry that is keyed by the package's name and version fails the build on a routed lock (`Patch file key ... does not match any npm packages`): the lock holds the patched release under another version, which the entry does not name. The pin keeps the package's key and builds. So `bazel::pnpm` now says of every call that reads a lock whether its build takes a routed lock (`Reader::Takes`), and the route is taken under a hub exactly in the first two shapes: the project is at the root of the Bazel workspace, the call names the root lock in a plain string and passes nothing but the attributes those builds had (`name`, `pnpm_lock`, `data`, `update_pnpm_lock`, `use_pnpm`; no `*` or `**`), and it either runs no pnpm, or lists the workspace file and runs a pnpm that the root module states as a release of 11.20.0 or later. Any other attribute keeps the pin: `patches` for the reason above, and `npm_package_lock`, `yarn_lock` and `preupdate` because a pnpm then writes the lock anew, which no build was run for. A prerelease and a number of fewer than three parts are not such a release. And the stated release counts for the route only where its repository is one of the use of the pnpm extension that every module shares: a `use_repo` on another extension's proxy can take a repository under the name of a tag, a use with `isolate` has tags and repositories of its own, and an `inject_repo` on the extension is not read. The pin is not held to that: what is withheld, and when, is decided as before. Under such a hub the run is the one of the same project without Bazel, byte for byte. Everything else keeps today's pin, and the `redirect_pnpm_trust_lockfile` warning now names what kept the hub off the route. What the reader may not have seen (a missing include, a `WORKSPACE` file that brings in rules_js) still blocks the route, also beside a call in one of the two shapes. A hub whose listed file would hold only what hosted mode writes is still left alone, so no `rollback` leaves the call naming a missing file. So is one whose listed file says `trustLockfile: false`, also where the lock would be routed; the warning there now says that taking the line out is enough. `--no-trust-lockfile-config` keeps hosted mode from writing to pnpm-workspace.yaml: the setting, and the registries of the route too. Where a hub lists that file, runs a pnpm that may be 11 or later, and the file does not hold `trustLockfile: true` already, such a run now writes nothing for the root lock, exits 0 and warns `redirect_pnpm_bazel_workspace_hidden` with what to do (drop the option, or set the setting yourself). The code's meaning covers it: the pnpm of the hub reads a file that hosted mode does not write the setting to. The build stays the unpatched one that passes. A run that ends routed is not withheld: in a project that an earlier run routed, whose file holds the route of every pin, it has nothing to write there and reports the packages as it does without Bazel. A hub that runs no pnpm or a pnpm known to be older than 11 is pinned under the option as before. The answer is read with the Bazel files and applied where the option is known, in the rewrite, so the in-memory engine gives it too, and a scan that crawls nothing gives the same warning. Tests. On a real Bazel the flows now hold the routed build: the hosted flow of the fixture's hub, which runs no pnpm, and the three flows of the previous commit, one for each way of stating pnpm 11.28.10 (first build, second build, the build that may update nothing, `rollback`, the VEX documents). The hosted flow runs a second time on the pin with `trustLockfile: true`, for a patch service that offers no registry. The flow of the option holds nothing written with the unpatched build passing, then the routed build once the option is dropped, then the option again on the routed project. A new flow holds the pin beside a `patches` entry of the hub. Without Bazel: the table of shapes in `bazel::pnpm`, the engine (the same files as without Bazel, a trust pin that moves to the route and loses its setting, a second run that changes nothing, a project that leaves the route when its hub stops qualifying), the same transitions through the commands with `rollback`, a scan that crawls nothing, and the in-memory engine against a checkout. The flow with `patches` also records a problem that is not new: on Bazel 7 an output base that built the package keeps that output after the pin, and after its `rollback`, until `bazel clean`. For a package with a `patches` entry rules_js hands the build a directory it unpacked at fetch time, and Bazel 7 does not look into a source directory. docs/ecosystems.md lists it. Existing expectations that changed, because their hub is one that is routed now: the flow `npm::hosted_npm_translate_lock` and its twin without Bazel (`a_lock_that_a_hub_reads_stays_on_the_trust_pin_...`, renamed), which held the trust pin beside the fixture's hub; `hosted_registry_route_is_not_taken_for_a_lock_a_bazel_hub_reads` (in_process_redirect_pnpm; rewritten around a hub whose pnpm decides); the unit tests `a_lock_that_a_bazel_hub_reads_is_not_routed` (split in two) and `a_hub_reads_the_lock_it_names_whatever_else_it_says` (replaced by the table); and the second half of the real-pnpm leg `registry_route_is_left_for_a_bazel_hub_added_later`, which now uses a hub that runs pnpm 10. That leg needs a pnpm from Corepack and was not run here; an in-process test holds the same files. The unit tests that hold the `trustLockfile: false` advice follow its new words. The loc budget of the `bazel` group follows the tree. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main brought vendored mode for a Maven patch of a pinned rules_jvm_external hub. One conflict: the line cap of the `bazel` group, which is the count of the merged tree, 4069. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… build The route through named registries is taken under a rules_js hub only in shapes whose build was run with a routed lock. Two shapes that no build was run for were taken all the same, and the answer for `--no-trust-lockfile-config` reached one command that pins nothing. A pnpm that a dev dependency states. `use_extension(..., dev_dependency = True)` makes a proxy whose tags Bazel drops under `--ignore_dev_dependency` (`ModuleFileGlobals.useExtension` at 7.7.2, 8.8.2 and 9.3.2). A hub whose pnpm 11.28.10 was stated on such a proxy was routed, and a build under that option runs the pnpm that rules_js picks instead, a pnpm 10 at 3.6.0, which builds a routed lock only until it resolves again (measured for this branch: once a `package.json` asks for another package the build fails). A release that a use with `dev_dependency` states, written as `True` or not written out, no longer counts for the route, and the warning names that. The pin is not held to it: its setting is in the file the hub lists, for whichever pnpm asks for it. More than one lock. A hub of the root lock was taken for the route also in a project that keeps a lock per workspace member (`sharedWorkspaceLockfile: false`). The route records its overrides in every lock of the project, and the pnpm of a hub resolves in a directory that holds the one lock its call names. Such a project keeps the pin now, whichever of the two shapes its hub is in, and the warning says so. A scan that crawls nothing. Under `--no-trust-lockfile-config` it was kept from taking out what a route left, beside a hub that lists pnpm-workspace.yaml and runs a pnpm 11, and warned that `bazel build` would fail on a lock that it had not rewritten. That answer is about a pin which the pnpm of the hub would reject, and this scan adds none: it takes out what no lock uses, in the lock and in the file together, and the file it is about holds a line of the user's own. It tidies again as it does on main, and says nothing of the hub. A hub that hides the file is left its lock as before, which the test of this path now holds too. The words of that warning. Core gives it to the in-memory engine as well, whose caller has no `--no-trust-lockfile-config` to drop. It now says to let hosted mode write to pnpm-workspace.yaml, that this run was told not to, and what that is called on the command line. One read for the three answers. Every hosted scan asked the question of the pin twice, for a run that writes the setting and for one that does not, and the route's answer read the pnpm of the hub again. So pnpm-workspace.yaml, the `package.json` that a tag takes its release from and `MODULE.bazel.lock` were read and parsed two or three times a scan. The file beside the lock and the pnpm of each hub are now read once, when the first answer asks for them, and the hubs are listed once. A test counts the reads. One reader of proxies. The hub reader had its own way of finding the `use_repo` and `inject_repo` calls of a proxy and the `use_extension` behind a tag, beside the one of the workspace reader. `Tag` now carries `isolate` beside `dev_dependency`, and `Tags::handed` lists the calls that take a proxy by its name, so the hub reader asks the workspace reader. One reading changes with it: `isolate = False` is the use that every module shares, as Bazel takes it and as `dev_dependency = False` is read, where any `isolate` used to keep the hub on the pin. An `isolate` that is not written out still does. Existing expectations that changed: the row of the hub table for a use that says `isolate = False` (now on the route); the reader of a project with a member's lock and no root lock in `a_checkout_and_a_project_in_memory_are_told_the_same` (now the clause about several locks); the test of a scan that crawls nothing under the option, which held the withheld cleanup and is rewritten around the cleanup; and every test that holds the words of the option's advice. Not built on a real Bazel: a pnpm of a dev dependency under `--ignore_dev_dependency`, and a project with members' own locks under a hub. Both keep the pin that main writes for them. The loc budget of the `bazel` group follows the tree. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gnore line `cargo::vendored_from_cargo_with_config` comments out the line the scan wrote in `.bazelignore` and expects `bazel cquery //...` and `bazel query 'deps(//...)'` to fail on a repository that the main repository does not see. It looked for the hub's repository (`@crates__...`) alone. The build file that cargo-bazel writes into the committed copy names `@platforms` as well, and Bazel reports the first one it meets: on a Linux runner with Bazel 9.3.2 the query named `@platforms` and the flow failed on its own check. The flow now takes either name for that failure. Test only: nothing the command does changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The check of the commands that fail once the ignore line is commented out now reads the name out of Bazel's message and takes it only when the message is about the main repository's view: `platforms`, or a repository of the crate hub. The same words about another repository's view, or about another name, are a different failure and no longer pass for the expected one. A test without Bazel holds the check to the two messages that were seen and to three it must not take. The module docs, the comment at the call and the section on the build file in a vendored crate said the commands end on the dependency's repository alone. They now name `platforms` as well, which is what a user who comments the line out can see. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Hubs that don’t qualify (extra attributes such as
Bazel workspace parsing gains CI/docs and e2e Bazel npm tests expand: routed vs trust-pin flows, Reviewed by Cursor Bugbot for commit 43a201e. Configure here. |
|
Not ready yet: a Windows run of this branch (workflow dispatch, |
A scan is one large async function, and a debug build builds every future on the poll frame of the function that awaits it, also in a branch that is not taken. The scan awaits the hosted flow in line, so the size of that flow's future is stack for a scan in every mode. An agent scan that applies a gem in place needs 2,013,673 bytes of the 2 MiB a test thread has on main (macOS arm64), and the Windows job of `in_process_gem_multi_platform`, which passes on main, overflowed on this branch. Two things of this branch were in that size. The answers about a Bazel workspace (`bazel::pnpm::Hubs`) grew from 80 to 144 bytes, with the answer for `--no-trust-lockfile-config` and the reason a hub is off the route, and the files a hosted run reads hold them by value (`CandidateFiles::pnpm_bazel`). The hosted flow keeps three copies of those files, so its future grew by 192 bytes, the poll frame of the scan by 384 and the frame that builds the scan's future by 192: 576 bytes more on that chain on macOS arm64. The files now hold the answers in a box, and are 72 bytes smaller than on main. The two passes of a run under `--no-trust-lockfile-config` were a recursion inside `rewrite_once`, boxed in line. The future of the inner pass was built on the frame of every hosted rewrite, with the option or without, and the clone of the files it takes stayed in the future of every pass (3,024 to 3,608 bytes, and `rewrite` from 5,488 to 6,200), which the hosted flow builds on its own frame in turn: a hosted scan needed 12 to 15 KB more stack than on main. `rewrite_once` is main's again. The two passes are a function of their own, `rewrite_told`, and `rewrite_pass`, which is no `async fn`, builds and boxes it on a frame that is gone before anything is polled: a pass is `rewrite_once` or that pointer. What a run does is unchanged. The smallest stack on which a test passes (macOS arm64, debug, to about 1 KiB), on main, before this commit and after it: - in_process_gem_multi_platform, rollback_all_over_broad_manifest_succeeds: 2,013,673, 2,014,841, 2,013,673 - in_process_redirect, scan_redirect_npm_stale_legacy_bundle_mirror_still_attests: 1,722,841, 1,734,521, 1,714,665 - in_process_redirect, redirect_vex_verifies_manifest_patches_normally: 1,720,505, 1,733,353, 1,713,497 - in_process_redirect_pnpm, hosted_pnpm_vex_emits_redirected_attestation: 1,719,337, 1,731,017, 1,712,329 No future of the command-line crate is larger than on main now (`-Zprint-type-sizes`), and no test of those three targets or of in_process_rollback_hosted writes more stack than it does on main; the gem tests write 640 bytes less. A unit test holds the two sizes: the files hold the answers behind one pointer, and a pass is no larger than `rewrite_once` and a pointer. Not run on Windows. The gem tests stay as close to the limit as they are on main, because the future of the hosted flow is still built on the frame of the scan. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The stack overflow is fixed in ed9693b: a Windows run of this head passes |
Hosted mode now routes a pnpm lock through the patch's named registry also where an aspect_rules_js hub of a Bazel workspace reads the lock in a shape whose build takes a routed lock, and a hosted scan under
--no-trust-lockfile-configno longer writes a pin that the pnpm of such a hub rejects.Main at e685fb1 is merged in (74e1bbb), and the findings of the code review are applied in one commit on top of it (49438ce): see "Code review" at the end.
The Windows job of
in_process_gem_multi_platformoverflowed the stack of a test thread on this branch, where it passes on main. A scan builds the future of the hosted flow on its own frame in every mode, and an agent scan that applies a gem in place needs 2,013,673 of the 2,097,152 bytes of such a thread on main already (macOS arm64, debug); this branch had made that future 192 bytes larger, with the answers about Bazel in the files a hosted run reads, and that chain 576 bytes deeper, and it had made a hosted scan 12 to 15 KB deeper with the two passes of a run under the option, boxed in line inrewrite_once. ed9693b holds the answers in a box and builds the two passes off the frame of the rewrite: the gem test needs what it needs on main (2,013,673 bytes; 2,014,841 before), no future of the command-line crate is larger than on main, and the three deepest hosted tests need 7 to 8 KB less than on main. It was not run on Windows, and the gem tests stay as close to the limit as they are on main.Decisions for the maintainer
--no-trust-lockfile-config: withhold, or keep pinning with a warning? This change withholds. Where a hub keeps the lock up to date (update_pnpm_lock), listspnpm-workspace.yamlindata, runs a pnpm that may be 11 or later, and the file does not already holdtrustLockfile: true, a scan with the option writes nothing for the root pnpm lock, exits 0 and warnsredirect_pnpm_bazel_workspace_hiddenwith what to do. Before, it exited 0 with a pin, and the nextbazel buildfailed (ERR_PNPM_TARBALL_URL_MISMATCH). The other choice is to keep the pin and the warning that pnpm 11 rejects it, which keeps a command that exits 0 and breaks the build. The price of withholding: the package stays unpatched in the Bazel build until the option is dropped or the setting is written by hand. A project that is routed already is not withheld: its file holds the route, so the run has nothing to write there and reports the package as applied. Nor is a scan that crawls nothing: it adds no pin, and takes out what a route left as it does on main.socket-<id>:1.0.0). A hub whosepatchesentry is keyed by the package's name and version then names no package, and rules_js fails the build (measured). So the route is taken only where the hub's call passes nothing but the attributes of the calls that were built:name,pnpm_lock,data,update_pnpm_lock,use_pnpm. Every other attribute keeps today's pin, also the ones that most likely change nothing (npmrc,verify_node_modules_ignored), because no build was run with them. Many real hubs have one of those, so say which attributes should be built next to widen the route.--no-trust-lockfile-configopts out of every write topnpm-workspace.yaml, the route's entries included. That rule is main's and is not changed here. So the option on a hub that would be routed is the withheld case of 1; dropping the option routes it. If the option should only mean "notrustLockfile", that is a separate change for every pnpm project.package.json: pnpm 11.19.0 puts the upstream release back without a word, and pnpm 10.34.9 fails the build. The hub's pnpm has to be stated as a release of 11.20.0 or later: three numbers, no prerelease.trustLockfile: falsein the listed file still withholds, also where the lock would be routed. A routed lock needs no setting, but that answer is given before the route is planned, as on main, and no build was run with such a file. The warning now says that taking the line out is enough. Say if the route should go ahead there.sharedWorkspaceLockfile: false) keeps the pin, whichever lock the hub names, because the route records its overrides in every lock and the pnpm of a hub resolves beside the one its call names (new with the review; no build of it was run). A pnpm that only a use of the extension withdev_dependencystates does not count: Bazel drops the tags of such a use under--ignore_dev_dependency, and the hub then runs the pnpm that rules_js picks (new with the review; read in Bazel's source at 7.7.2, 8.8.2 and 9.3.2, not built). And the rules_js release is not checked: every build here was on 3.6.0.redirect_pnpm_bazel_workspace_hiddenalready covers a listed file that hosted mode does not write the setting to; the option is a third reason for the same thing.patchesentry for the package builds the output of the earlier build untilbazel clean, andvexsaysnot_affectedmeanwhile. It is listed as a known problem, and a flow records it. Whether the scan should warn, orvexshould not attest there, is for a separate change.isolate = Falseis now the use that every module shares (changed with the review). Before, anyisolateon theuse_extensionof the pnpm extension kept the hub on the pin, to keep the reader small. The workspace reader now readsisolateas it readsdev_dependency:Falseis what Bazel takes it for (read in its source at the three releases),Trueand a value that is not written out keep the pin. Say if anyisolateshould keep the pin as before.--no-trust-lockfile-configbeside a hub of decision 1, the rewrite runs once without the withhold to learn whether the run ends routed, and again with it when it does not. The cost is one more in-memory rewrite, for that case alone. Deciding it in the route step instead needs a second way to withhold, after the rewriters have run, which is more code than the function of sixteen lines there is (rewrite_told, which is built off the frame of every other rewrite since ed9693b). A guard of about five lines would skip the first run wherepnpm-workspace.yamlholds no route at all; say if you want it.What the code does today
On main (e685fb1), for pnpm 11.20 and later, hosted mode routes each patched release through one named registry of
pnpm-workspace.yamlin place oftrustLockfile: true. For a lock that annpm.npm_translate_lockhub reads it never does: the project is pinned withtrustLockfile: true, and the warning says that a lock that a hub reads is not routed yet. The docs give the reason: no Bazel test builds a routed lock withupdate_pnpm_lock.Where a hub keeps the lock up to date with a pnpm 11 that does not see
pnpm-workspace.yaml, hosted mode writes nothing and warnsredirect_pnpm_bazel_workspace_hidden. That answer does not look at--no-trust-lockfile-config: with the option the lock is pinned without the setting, the command exits 0, and the pnpm that Bazel runs rejects the lock.docs/ecosystems.mdlists this as a known problem, measured by hand.What was measured, and where
On macOS arm64, real Bazel 9.3.2, 8.8.2 and 7.7.2, each with aspect_rules_js 3.6.0, the fixture and the loopback stand-in of the existing npm flows. The routed checkout was written by hosted mode itself. Every pnpm was one that rules_js 3.6.0 holds a checksum for.
update_pnpm_lockrollbackrestores every file and the upstream build.update_pnpm_lock = True, file indata, pnpm 11.28.10 bypnpm_version, bypnpm_version_from/packageManager, by ause_pnpmlabel; pnpm 11.20.0 and 12.17.0 bypnpm_version.aspect/. Before that build a frozen build fails, as after any lock change; after it frozen builds pass.rollbackrestores the files, and the next build is the upstream one.dataERR_PNPM_MISSING_NAMED_REGISTRY.package.jsonasks for another package (Bazel 9.3.2): 11.19.0 rewrites the lock to the upstream release, 10.34.9 fails withERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER. pnpm 11.20.0, 11.28.10 and 12.17.0 keep the patched release.update_pnpm_lock, and apatchesentry keyed by the package's name and version, with a routed lockPatch file key `…@1.0.0` does not match any npm packages.rollbackrestores the build.trustLockfile: truebazel clean, then it is the patched one; afterrollbackthe same holds the other way.--no-trust-lockfile-configERR_PNPM_TARBALL_URL_MISMATCH.--no-trust-lockfile-configNothing here contradicts what main's docs state. No build was added for the review commit: the two shapes it takes off the route keep the pin that main writes for them, and what it says of
--ignore_dev_dependencyand ofisolateis read in Bazel's source (ModuleFileGlobals.useExtensionat 7.7.2, 8.8.2 and 9.3.2).What changes
bazel::pnpmnow says of every call that reads a lock whether its build takes a routed lock. Hosted mode routes the lock when the project is at the root of the Bazel workspace, its rootpnpm-lock.yamlis its one pnpm lock, and every call that reads it names it in a plain string, passes nothing butname,pnpm_lock,data,update_pnpm_lockanduse_pnpm, and is one of two shapes: noupdate_pnpm_lock(orFalse); orupdate_pnpm_lock = True, a written-outdatathat lists thepnpm-workspace.yamlbeside the lock, and a pnpm that the root module states as a release of 11.20.0 or later. The run is then the one of the same project without Bazel, byte for byte. AtrustLockfile: truethat an earlier run wrote goes as it does outside Bazel.dev_dependencymay state it. The hub has nouse_pnpm, or ause_repoon the name of a proxy of that extension takes the repository. Ause_repoon another extension's proxy can take a repository under the name of apnpm.pnpmtag, a use withisolate = Truehas tags of its own, aninject_repoon the extension is not read, and the tags of a dev dependency are gone under--ignore_dev_dependency: each keeps the hub on the pin. What hosted mode withholds, and when, is decided as before.redirect_pnpm_trust_lockfilewarning names what kept the hub off the route: apnpm_lockthat is not written out, a workspace member's own lock, a project below the Bazel root, a project with members' own locks, an attribute no routed lock was built with, anupdate_pnpm_lockthat is not written out, adatawithout the file, a pnpm that is not stated as 11.20 or later or is not shown to be the one the hub runs in every build. What the reader could not see (a missing include, aWORKSPACEfile that brings in rules_js) still blocks the route, also beside a call in one of the two shapes.trustLockfile: false,redirect_pnpm_bazel_workspace_hiddennow says to set it totrueor to take the line out. For a run under the option it says to let hosted mode write topnpm-workspace.yaml, that this run was told not to, and that this is--no-trust-lockfile-configon the command line: the in-memory engine gives the same text to a caller that has no such flag.isolateof a tag's use besidedev_dependency, and lists theuse_repoandinject_repocalls that take a proxy, so the hub reader no longer finds them a second way. And one answer about a project reads thepnpm-workspace.yamlbeside the lock, thepackage.jsonthat a tag takes its release from andMODULE.bazel.lockonce, where it read them two or three times.docs/ecosystems.md("Bazel workspaces: npm", the tested shapes, the known problems),docs/testing/pnpm-compatibility.mdand the rows ofCLI_CONTRACT.mdsay what is now true. The known problem of the option is removed from the list, and the Bazel 7 one of decision 8 is added.Limits
latest, a prerelease, apackage.jsonthat is not read, or no tag at all keep the pin, also where the pnpm is in fact new enough. So does ause_repothat takes the repository from the extension call written in place (use_repo(use_extension(...), ...)), and a dev dependency also where the hub itself is one: only the plain forms are followed.pnpm-workspace.yamlhas to hold a line of the user's own, as before: one that would hold only what hosted mode writes is left alone, becauserollbackwould delete it under the call that names it.pnpm_version_fromfile that is not among the project's own manifests reads as no version, so a lock that a checkout routes can be pinned there.rollback,remove,repairandscan --pruneread no Bazel file, as before.Contents
Four commits of this change and a merge of main. Two commits for the check of a Cargo flow are on the branch as well (bdce0b5, 43a201e).
npm.rs+283 lines; the header ofbazel-npm.yml, whose legs run everynpm::flow.bazel/pnpm.rs+118 / −87 (code +12),bazel/workspace.rs+45 / −27 (code +10),hosted/engine.rs+12 / −12 (code −4),commands/scan/gc.rs+1 / −4 (code −3, the file is main's again). Unit tests in those files +276 / −14. Integration tests +48 / −29. Docs +27 / −12.hosted/engine.rs+75 / −23 implementation lines (code lines +36) and one unit test, +51 / −1.The whole branch against main: implementation +512 / −134 lines (code lines +230):
bazel/pnpm.rs+352 / −80,bazel/workspace.rs+44 / −26,hosted/engine.rs+99 / −15,hosted/guidance.rs+17 / −13. Unit tests in those files +908 / −91. Integration tests +1063 / −123 (e2e_bazel_build/npm.rs,in_process_redirect_pnpm.rs,hosted_memory_parity.rs,in_process_pnpm_registry_cleanup.rs,e2e_redirect_pnpm_build.rs, ande2e_bazel_build/cargo.rsof the two Cargo commits). Docs +172 / −62. Thebazelgroup ofscripts/loc-budget.jsongoes from 3917 to 4091, the count of the tree.Existing expectations that changed, because their hub is one that is routed now: the flow
npm::hosted_npm_translate_lockand its twin without Bazel;hosted_registry_route_is_not_taken_for_a_lock_a_bazel_hub_reads(rewritten around a hub whose pnpm decides); the unit testsa_lock_that_a_bazel_hub_reads_is_not_routedanda_hub_reads_the_lock_it_names_whatever_else_it_says; and the second half of the real-pnpm legregistry_route_is_left_for_a_bazel_hub_added_later, which now uses a hub that runs pnpm 10. The unit tests that hold thetrustLockfile: falseadvice follow its new words. The full hosted flow on the trust pin is kept as a flow of its own (npm::hosted_npm_translate_lock_on_the_trust_pin).Expectations that the review commit changed: the row of the hub table for a use that says
isolate = False, which is on the route now (decision 9); the reader of a project with a member's lock and no root lock ina_checkout_and_a_project_in_memory_are_told_the_same, which is now the clause about members' own locks; the test of a scan that crawls nothing under the option, which held the withheld cleanup and now holds the cleanup (a_scan_that_crawls_nothing_tidies_beside_a_listing_hub_also_under_the_option, with a hub that hides the file as the case that is still left alone); and the four tests that hold the words of the option's advice.What it proves, and where
npm::flows at the head ed9693b: pass (152 s, one Bazel at a time). The four routed flows hold the patched build, the second build that changes no file, the build that may update nothing,rollbackto the upstream build, and the VEX documents of the routed build. The flow of the option holds nothing written, the unpatched build passing, the routed build once the option is dropped, and the option again on the routed project. The flow withpatchesholds the pin, the warning that names the attribute, and the build of the pin.rollback_all_over_broad_manifest_succeedsofin_process_gem_multi_platform2,013,673 / 2,014,841 / 2,013,673; of the hosted tests the three deepest,scan_redirect_npm_stale_legacy_bundle_mirror_still_attests1,722,841 / 1,734,521 / 1,714,665 andredirect_vex_verifies_manifest_patches_normally1,720,505 / 1,733,353 / 1,713,497 (in_process_redirect),hosted_pnpm_vex_emits_redirected_attestation1,719,337 / 1,731,017 / 1,712,329 (in_process_redirect_pnpm). None of the 186 tests of those three targets and ofin_process_rollback_hostedwrites more stack than on main. Five mutations of the commit are each caught by a unit test.socket-patch-core(8549 passed, 1 ignored), the hosted pnpm integration targets of the core (92; no file under the core'stestsdiffers from main, so main's golden files for the registry route pass unchanged), nineteen CLI targets that run hosted pnpm (1046 passed, 24 ignored, the real-pnpm legs),in_process_gem_multi_platform(9),e2e_bazel_buildwithout Bazel (69 passed, 36 ignored), theclitarget (120), the script tests (423),cargo checkof all targets, clippy with-D warnings, the line budget.Not covered
registry_route_is_left_for_a_bazel_hub_added_laterneeds a pnpm from Corepack and was not run; an in-process test holds the same files for its changed half.npm_package_lock,yarn_lockorpreupdate, where a pnpm writes the lock anew, and every other attribute beyond the five: no build with a routed lock was run, so they keep the pin.use_pnpmrepository of another extension, an isolated use of the pnpm extension and aninject_repowere not built on a real Bazel: tests without Bazel hold that they keep the pin.--ignore_dev_dependency, and a project with members' own locks under a hub, were not built on a real Bazel either: tests without Bazel hold that they keep the pin, and the pin of each is main's.package.jsonchange were measured on Bazel 9.3.2 only.patchesentry; rules_js unpacks a package with lifecycle hooks the same way, which was not measured.update_pnpm_lockandWORKSPACE-mode rules_js are not part of this change.Code review
/code-review highon the draft gave seven findings. Six are fixed in 49438ce; one is left with its reason.pnpm-workspace.yamltogether, and the file that the option's answer is about holds a line of the user's own, so the lock it leaves is one that the hub's pnpm takes. The warning that described a pin is gone for this path; a hub that hides the file is left its lock as before.dev_dependencystates (written asTrue, or not written out) does not count, and the warning names it. The pin is not held to it.rewrite_oncethey cost every hosted rewrite stack, so they are a function of their own now, behind a pointer.Tag::isolateandTags::handedin the workspace reader, used by the hub reader: about fifteen fewer code lines there, ten more in the workspace reader.isolate = Falseis read as the shared use with it (decision 9).🤖 Generated with Claude Code