Repository navigation
Follow a link that leads out of the project when judging a pnpm store, so Bazel workspaces are covered (#2353) - #2443
Conversation
…pnpm entry A link in the project to a directory outside it kept every pnpm store entry, because what that directory's `node_modules` link was not read (#2430). One such link switched the fix of #2353 off for the whole project, and every Bazel workspace has four of them (`bazel-bin`, `bazel-out`, `bazel-testlogs`, `bazel-<name>`); a `link:` dependency on another checkout is one too. Such a link is now followed, since node loads what is behind it from where it really is. A directory behind it is read like the project. So is each `node_modules` in a directory above it, or above a file behind such a link, which is where node looks up the packages of what it loads from there: a member that left the workspace keeps the links pnpm wrote for it. The home directory and what lies above it are not looked at, as in git's own lookup. One budget of 500,000 directories and links holds for everything read, every link goes through the same checks as the ones in the project, and every entry is still kept when a directory cannot be read or the budget runs out. This also replaces the rule for a link to a file outside the project (every entry kept when a `node_modules` sits above the file): those `node_modules` are read, so one that links nothing changes nothing. Measured in a Bazel 9.3.2 workspace that links about 1,200 packages with aspect_rules_js 3.6.0: about 7,000 directories and 6,700 links behind the `bazel-*` links, and 9,200 directories of external repository contents behind those. After a vendored scan and the in-place install, vex attests without a warning; a link to the upstream entry in `bazel-bin`, in an external repository's contents or in a `node_modules` above the output tree's workspace directory brings the warning back. Following the links lists directories and resolves links outside the git checkout. No file is opened there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Following a link out of the project was done per store and per link, which left several gaps the review found: - A `node_modules` above a directory outside the project that is itself a link was not followed, so a link into the store behind it went unread. - A link to the home directory, or to one above it, was read like any other directory. It now keeps every entry, and no `node_modules` at the home directory or above it is looked at. - Bazel's `bazel-bin`, `bazel-out` and `bazel-<name>` lead to directories inside each other. Each was read in full and charged against the budget again. A directory is now read once, around what was read already. - Each store of a project repeated the whole pass, and a pass that failed was repeated as well. The links reached from a tree are now kept for the run, failures included. - A link to a file outside the project is handled as before this branch: it keeps every entry when a `node_modules` sits in a directory above the file. It is judged after every directory is read, so a file inside a directory that a later link leads to is not held against a `node_modules` that was read. The unit tests take the home directory as a value, so nothing of the machine's own home or temp directory is read by them. Part of #2353. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review findings on following a link out of the project: - The home directory was told by its path alone, so a link that spells it another way (macOS reaches it under /System/Volumes/Data as well) had the whole home directory read. It is told by identity now. - Each directory read was held against every directory read before it. With many separate directories outside that is quadratic. They are kept in order, and those below one are found by range. - A `node_modules` looked for above a directory outside was not charged to the budget. Each lookup counts now. - The real-pnpm steps read `node_modules` in every directory above the machine's temp directory. They run with the test's own directory as the home directory. - The independent reading in the tests did not record a `node_modules` that is a link, so it missed one that leads into the store. It records it and reads what lies above its target, and a leg now makes such a link. - The docs still said nothing above the scanned directory is read. A directory above it is read when a link leads to it or below it. - Two doc comments named a function that was renamed. Part of #2353. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s-dir' into fix/vex-pnpm-store-follow-links # Conflicts: # crates/socket-patch-cli/CLI_CONTRACT.md
PR SummaryMedium Risk Overview That fixes false Docs ( Reviewed by Cursor Bugbot for commit ace988a. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. Part of #2353, stacked on #2437. When Risk: medium. It only lists directories and resolves links, opens no file and reports nothing it reads outside. Every failure (unreadable directory, budget spent, a link to home or above) falls back to keeping every entry, which is today's stricter behaviour. The real cost is time and scope: a project run now lists directories outside its git checkout, and a link to a large tree is walked until the budget runs out. Look here
Verified
Changes I made. None. Open questions
Generated by Claude Code |
…m-store-follow-links Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…m-store-follow-links Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Stacked on #2437. Part of #2353.
Problem
#2430 keeps every pnpm store entry when a link in the project leads to a directory outside it, because what that directory's
node_moduleslink was not read. One such link switches the fix off for the whole project: the entry an in-place install leaves behind still refuses the patch (not_applied), or still warnsvendored_tree_out_of_sync.Every Bazel workspace has such links (
bazel-bin,bazel-out,bazel-testlogs,bazel-<name>), and so does a project with alink:dependency on another checkout.Fix
A link to a directory outside what is read is followed, since node loads what is behind it from where it really is:
node_modulesin a directory above it, which is where node looks up the packages of what it loads from there. A member that left the workspace keeps the links pnpm wrote for it. Anode_modulesthat is a link itself is followed like any other link;bazel-bin,bazel-outandbazel-<name>lead to directories inside each other;node_moduleslooked for. Every link found goes through the same checks as the ones in the project (another spelling of the store's path, the store itself, an entry that is not listed);node_modulesthere is not looked at, and a link to the home directory or above keeps every entry. The home directory is told by identity, so another spelling of its path (/System/Volumes/Data/Users/…on macOS) is the home directory still;A link to a file outside the project is handled as in #2430: it keeps every entry when a
node_modulessits in a directory above the file, because what the file loads by paths of its own is not read.With #2446
#2446 (the rule on Windows) is stacked on this PR and holds the merge of the two. On this branch alone every entry is still kept on Windows, and its tests are Unix-only. In #2446 a link to a directory outside the project keeps every entry on Windows, as it did before both PRs: following such a link was never run there, so it is not switched on there. Bazel on Windows is not claimed by either PR.
One choice for a maintainer
Following a link out of the project lists directories and resolves links outside the git checkout: Bazel's output tree and the contents of its external repositories are there. No file is opened, nothing read there is reported, and the budget bounds it. Elsewhere a project run reads no project file outside its checkout, and this is the one place that leaves it.
Three things are given up against #2430, which kept every entry for any such link:
require('../util')) is not followed to it. The project has the same limit since Stop vex refusing a hosted or vendored pnpm patch over the store entry an in-place install leaves behind (#2353) #2430.node_modulesin the home directory or above it. It is not looked at for a followed directory, as Stop vex refusing a hosted or vendored pnpm patch over the store entry an in-place install leaves behind (#2353) #2430 does not look at it for a file.Keeping every entry when a link leads out of the checkout is one condition if that is preferred; Bazel workspaces would then stay as on
main.Proof
bazel-*links lead into an output tree of about 7,000 directories and 6,700 links, and from there into the contents of the external repositories (about 9,200 directories). After a vendored scan andpnpm installover the existingnode_modules, Stop vex refusing a hosted or vendored pnpm patch over the store entry an in-place install leaves behind (#2353) #2430's build warnsvendored_tree_out_of_sync; this build attests without a warning. A link to the old entry placed inbazel-bin, in an external repository's contents (two links away), or in anode_modulesabove the output tree's workspace directory brings the warning back, and removing it clears it.vextakes 1.5 s there instead of 0.6 s (release builds).node_modulesabove it links the old entry,vexjudges the old copy again; a link to a file outside, below anode_modules, keeps every entry as before.*_in_place_install_is_judged_by_every_link): a link from the project to a directory beside it that links nothing changes nothing; once that directory'snode_moduleslinks the upstream package, or is itself a link into the upstream entry,vexrefuses the patch, and the independent link reading (which follows links out the same way, in its own code) finds the link. These steps run with the test's own directory as the home directory, so nothing the machine keeps above it is read.node_moduleslinks the leftover, one whosenode_modulesis a link into the leftover's entry, a directory below such anode_modules, a chain of two directories outside (each kept while the link in the project is there, left out once it is gone); directories outside that link nothing; an unreadable directory outside; the home rule (anode_modulesin the home directory and above it is not read, one below it is, a link to the home directory keeps every entry, also by another spelling of its path); anode_modulesthat is a link, with thenode_modulesabove what it leads to; and one budget across the project and directories outside that lie inside each other, each read once.cargo fmt --check,cargo clippy --locked --workspace --all-features -- -D warnings, the core unit tests (8,928), the CLI unit tests, theapply,cli,rollback,e2e_vex_redirectande2e_vex_vendorsuites, and the real-pnpm suites with the toolchain required (28 and 25 legs).Code review
Three
/code-review highpasses. Fixed: a linkednode_modulesabove a followed directory was not followed; a link to the home directory was read like any other; directories inside each other were read and charged twice; the pass was repeated per store; a file outside was judged before every directory was read; the bookkeeping of the directories read was quadratic in their number; thenode_moduleslookups were not charged to the budget; the home directory was told by its path alone; the real-pnpm steps readnode_modulesabove the machine's temp directory; the independent reading missed a linkednode_modules; the docs still said nothing above the scanned directory is read.Not changed, and why: the three points under "One choice for a maintainer" were raised as findings. Each follows from reading what a link leads to at all, within the limits #2430 already has, so they are stated there for the decision and not worked around.
CI
pnpm hosted compatibilitypasses on every pnpm version now that #2434 is onmainandmainis merged in. That push only mergedmain, so CI reused the previous head's results for the test jobs, as it does for such a push; the merge queue runs them again. Locally on the merged head (macOS):cargo fmt --check, clippy, the core unit tests (8,995 passed), the CLI unit tests, theapply,cli,rollback,e2e_vex_redirectande2e_vex_vendorsuites, and the real-pnpm suites with the toolchain required (28 and 25 legs). One interactiverollbacktest that this PR does not touch failed once while two builds ran beside it, and passed three reruns.🤖 Generated with Claude Code