Skip to content

fix(gvs): expose hoisted transitive deps in GVS package node_modules - #12972

Closed
kairosci wants to merge 2 commits into
pnpm:mainfrom
kairosci:fix/gvs-hoisted-transitive-deps-resolution
Closed

kairosci wants to merge 2 commits into
pnpm:mainfrom
kairosci:fix/gvs-hoisted-transitive-deps-resolution

Conversation

@kairosci

@kairosci kairosci commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When enableGlobalVirtualStore: true, packages that execute code from the global links store (e.g. Angular build workers, Nuxt postinstall scripts) fail to resolve transitive dependencies because Node's module resolution cannot reach deps that are only wired into the project's local hoist location. This fix creates symlinks for hoisted transitive dependencies inside each GVS slot's node_modules/, mirroring the project-level hoist structure so runtime resolution works from the links store.

Closes #12437.

Squash Commit Body

fix(gvs): expose hoisted transitive deps in GVS package node_modules

Packages that execute code from the GVS links store could not resolve
transitive dependencies because hoisted deps were only symlinked at the
project level (node_modules/.pnpm/node_modules/), not inside each GVS
slot's own node_modules/. Node module resolution walks up from the
executing package's directory and never reaches those hoisted symlinks.

The fix computes per-package hoisted transitive deps using the hoist
algorithm (treating each GVS package as a virtual root with its direct
deps) and creates symlinks for them inside the slot's node_modules/.
Applied in both the TypeScript deps-restorer/deps-installer and the
Rust pacquet create_symlink_layout pass.

Closes pnpm/pnpm#12437.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pnpm/ port, or the description notes what still needs porting.
  • Added or updated tests.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Global Virtual Store installs now include hoisted transitive dependencies, honoring configured hoist patterns for improved runtime resolution.
    • Fresh and frozen lockfile installs create additional GVS-aware hoisted-children links when GVS is enabled.
  • Bug Fixes
    • Invalid/unparsable version ranges now surface a clear validation error.
    • Registry error responses are now sanitized and truncated, including an explicit “response body truncated” notice.
    • Fetch retries are refined to avoid retrying when response body parsing fails.
  • Tests
    • Added/extended tests to verify hoisted transitive dependency resolution for both ESM and CJS in GVS.

@kairosci
kairosci requested a review from zkochan as a code owner July 13, 2026 14:12
Copilot AI lite review requested due to automatic review settings July 13, 2026 14:12
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds GVS hoisted-child symlink creation across Rust and JavaScript installation paths, with runtime coverage for transitive dependency resolution. It also changes pnpm deprecate version-range errors, fetch retry classification, and bounded registry response rendering.

Changes

Global virtual store dependency resolution

Layer / File(s) Summary
GVS hoisted symlink construction
pnpm/crates/package-manager/src/create_symlink_layout.rs
Adds parallel computation and creation of hoisted child symlinks for GVS snapshots.
Rust install-path wiring
pnpm/crates/package-manager/src/install_frozen_lockfile.rs, pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
Invokes GVS hoisted-child symlink creation during frozen and fresh lockfile installation.
JavaScript linker integration and validation
pnpm11/installing/deps-installer/src/install/link.ts, pnpm11/installing/deps-restorer/src/index.ts, pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts
Passes hoist configuration through linking, augments GVS child mappings, and verifies ESM and CJS runtime loading of a hoisted transitive dependency.

CLI deprecate behavior

Layer / File(s) Summary
Deprecate parsing and response handling
pnpm/crates/cli/src/cli_args/deprecate.rs, pnpm/crates/cli/tests/deprecate.rs
Reports invalid ranges as InvalidPackageSpec, retries only response-body read failures, renders bounded sanitized bodies, and removes the obsolete invalid-range integration test.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InstallCommand
  participant LinkPipeline
  participant getHoistedDependencies
  participant GVSNodeModules
  InstallCommand->>LinkPipeline: pass dependency graph and hoist patterns
  LinkPipeline->>getHoistedDependencies: compute hoisted child aliases
  getHoistedDependencies-->>LinkPipeline: return alias-to-package mappings
  LinkPipeline->>GVSNodeModules: merge mappings and create symlinks
Loading

Assessment against linked issues

Objective Addressed Explanation
[#12437] Make transitive dependencies resolvable for packages executing from the GVS links store ✅

Out-of-scope changes

Code Change Explanation
Invalid version_range parsing and candidate filtering (pnpm/crates/cli/src/cli_args/deprecate.rs:228-241) The linked issue concerns GVS transitive dependency resolution, not CLI deprecate behavior.
Fetch retry and registry response-body handling (pnpm/crates/cli/src/cli_args/deprecate.rs:333, 434, 456-496) These CLI networking changes are unrelated to the GVS resolution objective.
Removal of the invalid-range deprecate test (pnpm/crates/cli/tests/deprecate.rs:103-104) This test change does not validate or implement GVS dependency resolution.

Possibly related PRs

  • pnpm/pnpm#11867: Both PRs modify the fresh-lockfile installation flow.
  • pnpm/pnpm#12884: Both PRs modify deprecate.rs version-range and response-body handling.

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan, copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

  • Safe to merge. The GVS hoisting logic is symmetric across both stacks, the path-traversal guard is preserved in all new symlink creation paths, and runtime-resolution tests cover both ESM and CJS cases.
  • The core fix is well-scoped and correctly mirrors the TS getGvsHoistedChildrenPaths pattern in both the TypeScript and Rust stacks. The installability guard asymmetry between link.ts and deps-restorer/src/index.ts was already flagged and is tracked separately. The remaining findings are style-only.
  • No files require special attention beyond the style comments noted.

Reviews (24): Last reviewed commit: "style(gvs): collapse long let binding to..." | Re-trigger Greptile

Copilot AI review requested due to automatic review settings July 13, 2026 14:20
@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 060bc46 to a40a213 Compare July 13, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pnpm/crates/cli/src/cli_args/dispatch_query.rs (1)

244-245: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove comment that narrates the function body.

The comment "The handler is synchronous, so this resolves to a ready future once the output is printed" restates what the code already makes obvious. The leading fragment "print split" is unclear. Per coding guidelines, comments should only capture non-obvious rationale, not describe what the code does.

♻️ Suggested change
-// print split. The handler is synchronous, so this resolves to a ready future
-// once the output is printed.
 pub(super) fn pack<'a>(ctx: &RunCtx<'a>, args: &PackArgs) -> miette::Result<CommandFuture<'a>> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/cli/src/cli_args/dispatch_query.rs` around lines 244 - 245,
Remove the adjacent comment above the synchronous handler’s output-printing
logic, including the unclear “print split” fragment and the explanation about
the ready future; leave the implementation unchanged.

Sources: Coding guidelines, Path instructions

pnpm/crates/package-manager/src/create_symlink_layout.rs (1)

45-143: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

GVS hoisted-children symlink helper looks correct.

Target/dest computation, self-name + direct-dep skip guards, and the pre-create-dirs-then-parallel-symlink ordering are sound.

One optional consideration: get_hoisted_dependencies is recomputed per snapshot inside the rayon pass, so total work scales as O(snapshots × graph). It is parallelized, but on very large graphs this could dominate the hoist phase. Worth confirming against a large fixture if not already measured.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/package-manager/src/create_symlink_layout.rs` around lines 45 -
143, Measure create_gvs_hoisted_children_symlinks with a large snapshot/graph
fixture to confirm whether per-snapshot get_hoisted_dependencies calls dominate
runtime. If confirmed, reduce repeated hoist computation through an appropriate
cache or reuse strategy while preserving each snapshot’s dependency-specific
results and existing parallel symlink behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pnpm/crates/cli/src/cli_args/dispatch_query.rs`:
- Around line 244-245: Remove the adjacent comment above the synchronous
handler’s output-printing logic, including the unclear “print split” fragment
and the explanation about the ready future; leave the implementation unchanged.

In `@pnpm/crates/package-manager/src/create_symlink_layout.rs`:
- Around line 45-143: Measure create_gvs_hoisted_children_symlinks with a large
snapshot/graph fixture to confirm whether per-snapshot get_hoisted_dependencies
calls dominate runtime. If confirmed, reduce repeated hoist computation through
an appropriate cache or reuse strategy while preserving each snapshot’s
dependency-specific results and existing parallel symlink behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0883c1b7-db11-4cbc-9ce0-2db7735aca93

📥 Commits

Reviewing files that changed from the base of the PR and between 6a590de and 060bc46.

📒 Files selected for processing (9)
  • pnpm/crates/cli/src/cli_args/deprecate.rs
  • pnpm/crates/cli/src/cli_args/dispatch_query.rs
  • pnpm/crates/cli/tests/deprecate.rs
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts
  • pnpm11/installing/deps-restorer/src/index.ts
💤 Files with no reviewable changes (1)
  • pnpm/crates/cli/tests/deprecate.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/cli/src/cli_args/dispatch_query.rs`:
- Around line 246-261: Update pnpm/crates/cli/src/cli_args/dispatch.rs routing
to call dispatch_query::pack(ctx, &args), and remove or replace the
CliCommand::Change|Version|Lane and CliCommand::Star|Unstar|Stars arms that
reference missing handlers. The sites in
pnpm/crates/cli/src/cli_args/dispatch_query.rs at lines 149, 180, and 246-261
require no direct change; use the existing pack function signature and available
handlers as the routing targets.

In `@pnpm11/installing/deps-installer/src/install/link.ts`:
- Around line 604-633: Honor optional-dependency filtering in every GVS hoist
implementation: in pnpm11/installing/deps-installer/src/install/link.ts lines
604-633, pass the optional setting into getGvsHoistedChildrenPaths and exclude
depNode.optionalDependencies when optional dependencies are disabled; in
pnpm/crates/package-manager/src/install_frozen_lockfile.rs lines 1245-1261, pass
whether DependencyGroup::Optional is included; and in
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs lines 1940-1956,
pass the fresh install’s effective optional-inclusion state.
- Around line 448-452: Update the GVS reconciliation flow around
enableGlobalVirtualStore and hoistPattern so hoist-setting or hoist-graph
changes refresh all affected existing slots, not only newPkgs and direct-child
updates. Include removed GVS-hoisted aliases in removedAliases and ensure the
no-change early return is bypassed when the desired GVS children differ.
Preserve existing behavior for unaffected slots.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cf74f63-8155-4324-bbbb-62920c043596

📥 Commits

Reviewing files that changed from the base of the PR and between 060bc46 and a40a213.

📒 Files selected for processing (9)
  • pnpm/crates/cli/src/cli_args/deprecate.rs
  • pnpm/crates/cli/src/cli_args/dispatch_query.rs
  • pnpm/crates/cli/tests/deprecate.rs
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts
  • pnpm11/installing/deps-restorer/src/index.ts
💤 Files with no reviewable changes (1)
  • pnpm/crates/cli/tests/deprecate.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm/crates/cli/src/cli_args/deprecate.rs

Copilot AI review requested due to automatic review settings July 13, 2026 14:38
@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from a40a213 to 9a78d7a Compare July 13, 2026 14:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts`:
- Around line 540-573: Extend the test “GVS package runtime can resolve hoisted
transitive dependencies” with a CommonJS probe alongside the existing probe.mjs
ESM check. Write a .cjs file in the same package directory that requires
`@pnpm.e2e/dep-of-pkg-with-1-dep`, then execute it and assert successful
resolution, preserving the existing ESM assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 76c1e625-9fe9-4fa7-9afe-caf1a80371a5

📥 Commits

Reviewing files that changed from the base of the PR and between a40a213 and 9a78d7a.

📒 Files selected for processing (6)
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts
  • pnpm11/installing/deps-restorer/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-restorer/src/index.ts

Copilot AI review requested due to automatic review settings July 13, 2026 14:46
@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 9a78d7a to 3b73241 Compare July 13, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/installing/deps-installer/src/install/link.ts`:
- Around line 607-650: Update getGvsHoistedChildrenPaths so direct child aliases
are reserved even when their childDepPath is a workspace/local link absent from
depGraph; reuse the complete aliases emitted by getChildrenPaths, or otherwise
track all entries in depNode.children, before adding hoistedChildren. Ensure
link: aliases cannot be selected or overwritten during the subsequent
Object.assign merge.
- Around line 588-605: Update the symlinkAllModules preparation around
getGvsHoistedChildrenPaths so invariant GVS hoist-pattern merging occurs once
outside the depNodes.map loop, and reuse any available project-level hoist
result instead of traversing depGraph for each depNode. Preserve the existing
children, modules, and name mappings while eliminating repeated graph-wide work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9915bb9b-1989-4de0-8f2a-8ccc704dc205

📥 Commits

Reviewing files that changed from the base of the PR and between 9a78d7a and 3b73241.

📒 Files selected for processing (6)
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts
  • pnpm11/installing/deps-restorer/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm11/installing/deps-restorer/src/index.ts

Copilot AI review requested due to automatic review settings July 13, 2026 15:04
@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 3b73241 to 42e4e5e Compare July 13, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts`:
- Around line 605-606: Replace execSync and its shell-interpolated command in
the global virtual store test with execFileSync, passing node and probeFile as
separate arguments while preserving the existing stdio option and no-throw
assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b98ff49-e038-42d9-a235-152011309f33

📥 Commits

Reviewing files that changed from the base of the PR and between 3b73241 and 42e4e5e.

📒 Files selected for processing (6)
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts
  • pnpm11/installing/deps-restorer/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm/crates/package-manager/src/create_symlink_layout.rs
  • pnpm11/installing/deps-installer/src/install/link.ts

Copilot AI review requested due to automatic review settings July 13, 2026 15:19
@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 03e96ec to 62467da Compare August 7, 2026 09:37
@kairosci kairosci closed this Aug 7, 2026
@kairosci kairosci reopened this Aug 7, 2026
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 62467da to 0ffb65e Compare August 7, 2026 09:59
@kairosci
kairosci force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 0ffb65e to 0a8d42b Compare August 29, 2026 11:04
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 29, 2026
@kairosci

Copy link
Copy Markdown
Contributor Author

@zkochan could you take a look at it? Thanks!

@zkochan
zkochan force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 1266c9a to 5708a10 Compare September 25, 2026 16:14
Copilot AI review requested due to automatic review settings September 25, 2026 16:14
@greptile-apps
greptile-apps Bot dismissed their stale review September 25, 2026 16:14

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@qodo-code-review

qodo-code-review Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (7) 📘 Rule violations (5) 🔗 Cross-repo conflicts (0) 📜 Skill insights (1)

Grey Divider


Action required

1. Headless installs omit hoisted links 🐞 Bug ≡ Correctness ⭐ New
Description
getGvsHoistedChildrenPaths indexes depGraph with keys from hoistedDependencies, even though
those keys are dependency paths and the restorer graph is indexed by filesystem directories. During
a headless GVS install, normal hoisted packages therefore reach the !pkg branch and their aliases
are omitted from the slot layout.
Code

pnpm11/installing/deps-restorer/src/index.ts[R1632-1633]

+    const pkg = depGraph[depPath]
+    if (!pkg) continue
Relevance

●●● Strong

This is a concrete key-space mismatch causing missing links, matching accepted precedents for
correctness fixes in dependency restoration.

PR-#13464
PR-#15480

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The graph builder stores each node under graph[dir], while the hoist algorithm records the public
result under node.depPath; the newly added direct lookup therefore combines incompatible key
spaces. The changed guard then silently discards every unresolved entry instead of adding its alias.

pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[319-334]
pnpm11/installing/linking/hoist/src/index.ts[544-555]
pnpm11/installing/deps-restorer/src/index.ts[1619-1638]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The headless GVS helper looks up dependency-path keys in a graph indexed by package directories, so it silently drops hoisted aliases.

## Fix Focus Areas
- pnpm11/installing/deps-restorer/src/index.ts[1619-1638]

## Recommended Fix
Use the hoist result's node-ID mapping to retrieve packages from `depGraph`, then explicitly filter nodes whose `depPath` is skipped before adding aliases. Alternatively, build a dependency-path-to-node lookup once and use it for the `hoistedDependencies` entries.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Large GVS installs do quadratic work 🐞 Bug ➹ Performance
Description
create_gvs_hoisted_children_symlinks and slot_hoisted_symlinks start a fresh importer map and
hoist pass for every Rust snapshot, while both TypeScript linkAllModules paths call
getGvsHoistedChildrenPaths and getHoistedDependencies once per dependency node. With GVS
hoisting enabled, large or deeply connected lockfiles repeatedly allocate traversal state,
recursively visit and sort reachable nodes, and may repeat symlink work despite parallel execution
and the Rust link phase already having a global hoist plan.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[R233-236]

+    let pairs: Vec<SymlinkWork> = snapshots
+        .par_iter()
+        .flat_map(|(pkg_key, snapshot)| {
+            slot_hoisted_symlinks(
Relevance

●●● Strong

Recent precedents accept eliminating repeated graph traversals and redundant filesystem work in
installation paths.

PR-#14841
PR-#13170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Rust parallel snapshot loop invokes a per-snapshot helper that creates a new importer map and
calls the hoist algorithm, while the TypeScript helpers invoke the same logical operation from
per-node maps. Each invocation initializes fresh traversal state, including a visited set,
recursively collects reachable dependencies, sorts the entries, and performs another hoist pass
rather than reusing a precomputed result; the normal Rust link phase already receives a globally
computed hoist plan, demonstrating that shared analysis is available as an alternative.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[165-201]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-251]
pnpm/crates/deps-restorer/src/hoist.rs[290-331]
pnpm11/installing/deps-installer/src/install/link.ts[685-733]
pnpm11/installing/deps-restorer/src/index.ts[1515-1627]
pnpm11/installing/linking/hoist/src/index.ts[390-416]
pnpm11/installing/linking/hoist/src/index.ts[449-477]
pnpm11/installing/linking/hoist/src/index.ts[529-536]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[165-200]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-245]
pnpm/crates/deps-restorer/src/hoist.rs[290-323]
pnpm/crates/deps-restorer/src/hoist.rs[335-353]
pnpm11/installing/deps-installer/src/install/link.ts[685-698]
pnpm11/installing/deps-restorer/src/index.ts[1515-1531]
pnpm11/installing/linking/hoist/src/index.ts[390-406]
pnpm11/installing/linking/hoist/src/index.ts[638-675]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
GVS link generation independently computes a complete hoist result for every Rust snapshot and every dependency node in both TypeScript linking paths. Each calculation allocates fresh traversal state, walks and sorts the reachable dependency graph, and can repeat filesystem work, causing poor scaling on large dependency graphs.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[165-251]
- pnpm/crates/deps-restorer/src/hoist.rs[290-331]
- pnpm11/installing/deps-installer/src/install/link.ts[678-746]
- pnpm11/installing/deps-restorer/src/index.ts[1509-1640]
- pnpm11/installing/linking/hoist/src/index.ts[390-416]
- pnpm11/installing/linking/hoist/src/index.ts[638-675]

## Recommended Fix
Replace the per-package full graph walks with a batched, memoized, or precomputed graph analysis shared across slots. Key reusable results by the effective direct-dependency set and hoist configuration, derive each slot's aliases from the shared traversal state, and use the shared calculation in both TypeScript linking paths while preserving current per-slot behavior, result ordering, and alias-conflict semantics. Add install benchmarks using realistic 2,000–3,000-package graphs and verify that CPU usage, peak memory, and created-link counts remain bounded.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Packages retain obsolete GVS links 🐞 Bug ≡ Correctness
Description
The TypeScript install paths append computed GVS-hoisted aliases after removedAliases has already
been derived only from direct dependency aliases in current and wanted snapshots, while the Rust
path likewise only creates collected alias pairs. When hoist patterns or the transitive graph change
and the same GVS slot is reused, aliases no longer selected have no deletion path through installer,
headless restorer, or Rust reconciliation and remain resolvable.
Code

pnpm11/installing/deps-restorer/src/index.ts[R1520-1528]

+      const childrenPaths = { ...filteredChildren }
+      if (opts.enableGlobalVirtualStore && mergedHoistPattern.length > 0) {
+        const existingAliases = new Set(Object.keys(childrenPaths))
+        Object.assign(childrenPaths, getGvsHoistedChildrenPaths(depNode, opts.depGraph, {
+          hoistPattern: mergedHoistPattern,
+          skipped: opts.skipped,
+          existingAliases,
+          optional: opts.optional,
+        }))
Relevance

●●● Strong

Recent linker precedents accept stale-link cleanup and require filesystem reconciliation when
lockfiles remain unchanged.

PR-#13464
PR-#14518

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cited TypeScript code performs ordinary cleanup by comparing direct lockfile or dependency-node
children before merging computed hoisted aliases into the maps passed to symlinkAllModules, so an
alias generated only by the earlier GVS hoist configuration cannot appear in removedAliases. The
Rust path similarly creates every collected alias pair without identifying aliases removed solely by
a hoist-pattern change, demonstrating that none of the affected paths reconciles previously
generated aliases against the newly computed set.

pnpm11/installing/deps-restorer/src/index.ts[1505-1531]
pnpm11/installing/deps-restorer/src/index.ts[1549-1589]
pnpm11/installing/deps-installer/src/install/link.ts[678-703]
pnpm11/worker/src/start.ts[554-563]
pnpm11/installing/deps-installer/src/install/link.ts[757-781]
pnpm11/installing/deps-restorer/src/index.ts[1505-1536]
pnpm11/installing/deps-restorer/src/index.ts[1538-1570]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-251]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Per-slot GVS-hoisted aliases are created or updated after ordinary direct-dependency cleanup, but are not tracked for deletion. Reusing a GVS slot after narrowing hoist patterns or changing the dependency graph can therefore leave obsolete generated aliases resolvable.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/link.ts[678-703]
- pnpm11/installing/deps-installer/src/install/link.ts[757-802]
- pnpm11/installing/deps-restorer/src/index.ts[1505-1536]
- pnpm11/installing/deps-restorer/src/index.ts[1538-1570]
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-251]

## Recommended Fix
Persist or discover the aliases previously generated by this GVS-hoisting feature for each slot, compute the newly desired generated alias set, and reconcile the slot before linking by removing obsolete generated links and then creating replacements. Do not delete links owned by direct dependencies; apply equivalent reconciliation in the installer, headless restorer, and Rust paths, and add a test that reinstalls with a narrower hoist pattern and verifies that the former alias is gone.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (3)
4. Rust slots retain obsolete links 🐞 Bug ≡ Correctness
Description
create_gvs_hoisted_children_symlinks creates or replaces only destinations in the current computed
pair list and never enumerates obsolete entries in existing slot directories. When a global-store
slot is reused after its hoist patterns or reachable graph change, aliases from the prior
calculation remain available to code running from that slot.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[R247-252]

+    ensure_parent_directories(&pairs);
+
+    pairs
+        .par_iter()
+        .try_for_each(|(target, dest)| symlink_package(target.as_ref(), dest.as_ref()).map(drop))
+}
Relevance

●●● Strong

Recent GVS precedents require validating existing slot contents and repairing missing or stale
layout entries.

PR-#14518
PR-#14772

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added pass collects only current pairs and invokes symlink_package for them. That helper
reuses or replaces its requested destination but does not remove unrelated siblings, while the slot
identity is derived from package graph inputs rather than hoist patterns.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[217-252]
pnpm/crates/deps-restorer/src/symlink_package.rs[24-46]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[49-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Rust GVS pass only writes the links produced by the current hoist result. Since global-store slots are reused independently of hoist-pattern configuration, links produced by an earlier calculation survive when the current calculation no longer includes their aliases.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[217-252]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[49-60]

## Recommended Fix
Persist or reliably identify the aliases owned by the GVS hoist pass, then reconcile each slot's generated child links with the current alias set before creating new links. Delete stale generated links without deleting the package's direct-dependency links or unrelated filesystem contents.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Optional packages remain linked 🐞 Bug ≡ Correctness
Description
getGvsHoistedChildrenPaths includes every child in the hoist roots and compares resulting
dependency paths with depNode.optionalDependencies, even though that set is keyed by aliases and
getHoistedDependencies traverses optional edges by default. When optional dependencies are
excluded but an optional root or package remains installed elsewhere in the graph, both TypeScript
linking paths still reach aliases for otherwise-unreachable transitive children and add them to the
GVS slot.
Code

pnpm11/installing/deps-restorer/src/index.ts[R1631-1637]

+  for (const [depPath, aliases] of Object.entries(hoisted.hoistedDependencies)) {
+    const pkg = depGraph[depPath]
+    if (!pkg) continue
+    if (!opts.optional && depNode.optionalDependencies.has(depPath)) continue
+    for (const alias of Object.keys(aliases)) {
+      if (alias === depNode.name || directDeps.has(alias) || opts.existingAliases.has(alias) || hoistedChildren[alias]) continue
+      hoistedChildren[alias] = pkg.dir
Relevance

●●● Strong

Recent precedents accept filtering skipped or optional dependency edges consistently across Rust and
TypeScript implementations.

PR-#15165
PR-#13369

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The graph node builds optionalDependencies from Object.keys(pkgSnapshot.optionalDependencies),
so its entries are aliases, while the changed condition calls Set.has() with depPath; existing
direct-child filtering correctly uses childAlias, confirming the key mismatch. Both new helpers
also populate directDeps from every child, and the shared graph walker includes optional
dependencies unless explicitly configured otherwise, allowing an optional transitive edge to reach
the result-building loop.

pnpm11/installing/deps-restorer/src/index.ts[1630-1639]
pnpm11/installing/deps-restorer/src/lockfileToHoistedDepGraph.ts[342-342]
pnpm11/installing/linking/hoist/src/index.ts[390-406]
pnpm11/installing/linking/hoist/src/index.ts[638-675]
pnpm11/installing/deps-installer/src/install/link.ts[736-745]
pnpm11/installing/deps-installer/src/install/link.ts[718-740]
pnpm11/installing/deps-installer/src/install/link.ts[810-825]
pnpm11/installing/deps-restorer/src/index.ts[1612-1634]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The GVS-only hoist calculation includes optional direct dependencies and traverses their child edges even when optional dependencies are disabled, then attempts to filter the results by comparing dependency paths with a set of aliases. Consequently, optional transitive packages can be linked into GVS package directories when the omitted optional root or package remains present elsewhere in the graph.

## Fix Focus Areas
- pnpm11/installing/deps-restorer/src/index.ts[1612-1637]
- pnpm11/installing/deps-installer/src/install/link.ts[718-744]
- pnpm11/installing/linking/hoist/src/index.ts[390-406]
- pnpm11/installing/deps-restorer/src/lockfileToHoistedDepGraph.ts[342-342]

## Recommended Fix
When optional dependencies are disabled, build the virtual-root direct-dependency map without entries whose aliases are in `depNode.optionalDependencies`, and add or use a hoist traversal option that excludes optional child edges from this GVS calculation. Apply the same behavior in both TypeScript callers, remove the ineffective final dependency-path membership check against the alias set, and add tests where an omitted optional root is also present elsewhere in the graph to confirm that none of its otherwise-unreachable transitive packages are linked.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Rust regressions can pass unnoticed 📜 Skill insight ▣ Testability
Description
create_gvs_hoisted_children_symlinks adds the Rust runtime behavior, but its test module never
invokes it and the only new GVS regression cases are TypeScript tests. Reverting the Rust call
therefore leaves its stack without a failing test for slot symlink creation or runtime resolution.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[R218-220]

+/// Symlinks hoisted transitive dependencies inside each GVS slot's `node_modules`.
+pub fn create_gvs_hoisted_children_symlinks(
+    hoist_graph: &HashMap<PackageKey, HoistGraphNode>,
Relevance

●● Moderate

Coverage findings are often accepted, but a closely matching Rust-versus-TypeScript parity test
request was previously rejected.

PR-#15165
PR-#14259

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cross-stack testing rule requires regression coverage for every affected implementation. The PR
adds two TypeScript runtime tests, while the Rust test module contains no invocation or assertion
for the newly introduced GVS hoisted-child pass.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[218-252]
pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs[1-401]
pnpm11/installing/deps-installer/test/install/globalVirtualStore.ts[606-672]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The shared GVS bug is fixed in both implementations, but only the TypeScript implementation has regression tests proving runtime resolution from a GVS slot. The Rust implementation needs equivalent coverage that fails when its new linking pass is removed.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[218-252]
- pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs[1-401]

## Recommended Fix
Add a Rust regression test that constructs the corresponding dependency graph and GVS layout, runs the Rust symlink pass, and asserts that the transitive package link exists inside the package slot and resolves to the expected package.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

7. A Rust doc comment repeats its function 📘 Rule violation ⚙ Maintainability ⭐ New
Description
create_gvs_hoisted_children_symlinks is preceded by a doc comment that merely paraphrases its name
and implementation. The comment supplies no contract, edge case, or rationale for callers, so it can
become stale when the linking behavior changes.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[218]

+/// Symlinks hoisted transitive dependencies inside each GVS slot's `node_modules`.
Relevance

●●● Strong

Recent Rust review precedents accept removing doc comments that merely narrate or restate
implementation.

PR-#14739
PR-#14861

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added comment directly restates the function's symlink operation, which the cited rule prohibits
when no rationale, constraint, or non-obvious behavior is added.

Rule 713467: Avoid redundant comments that restate the code
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[218-226]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Rust doc comment only repeats that the function creates symlinks and does not add useful contract information.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[218-226]

## Recommended Fix
Replace the comment with documentation of when the operation runs, what filesystem state it guarantees, and how failures are returned, or remove it if no useful contract needs documenting.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Release note leads with internals 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The changeset's first sentence describes where pnpm install creates symlinks rather than leading
with the runtime resolution behavior users receive. Readers must reach the second sentence to learn
that packages executing from the links store can now resolve hoisted transitive dependencies.
Code

.changeset/gvs-hoisted-transitive-deps.md[8]

+When `enableGlobalVirtualStore` is enabled, `pnpm install` now creates symlinks for hoisted transitive dependencies inside each package's `node_modules` directory in the global virtual store. Packages executing from the links store can now resolve their hoisted transitive dependencies at runtime [#12437](https://github.com/pnpm/pnpm/issues/12437).
Relevance

●●● Strong

Recent changeset reviews consistently accept concise, user-facing release notes over
implementation-led wording.

PR-#15190
PR-#15455

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changeset begins with the internal symlink-placement mechanism, while the observable runtime
outcome appears only afterward, contrary to the required first-sentence format.

Rule 3058297: Format changeset entry first sentence as user-visible command/setting/behavior change
.changeset/gvs-hoisted-transitive-deps.md[8-8]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset begins with the internal symlink layout instead of the user-visible dependency-resolution fix.

## Fix Focus Areas
- .changeset/gvs-hoisted-transitive-deps.md[8-8]

## Recommended Fix
Rewrite the first sentence to say that packages executing from the global virtual store can now resolve hoisted transitive dependencies when `enableGlobalVirtualStore` is enabled. Put any symlink-layout detail in a later sentence.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Skipped packages get dependency links 🐞 Bug ≡ Correctness ⭐ New
Description
create_gvs_hoisted_children_symlinks iterates the complete snapshot map, and
slot_hoisted_symlinks neither limits roots to the current installation closure nor rejects a root
present in hoist_skipped. When installability, failed-fetch, optional-dependency, or
dependency-group filtering leaves a snapshot unmaterialized, a skipped package with a hoistable
descendant can still receive a newly created slot node_modules tree and dependency links.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[R233-243]

+    let pairs: Vec<SymlinkWork> = snapshots
+        .par_iter()
+        .flat_map(|(pkg_key, snapshot)| {
+            slot_hoisted_symlinks(
+                pkg_key,
+                snapshot,
+                layout,
+                hoist_graph,
+                (private_pattern, public_pattern),
+                hoist_skipped,
+            )
Relevance

●●● Strong

Recent precedents accept filtering skipped or non-materialized packages from graph-derived
installation work.

PR-#13141
PR-#14518

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call site supplies all wanted-lockfile snapshots even though LinkLockfiles separately carries
the filtered sidecar lockfile and materialized selection, and the new parallel iterator forwards
every snapshot key to the per-slot calculation. Snapshot planning records installability,
failed-fetch, and optional-exclusion cases in SkippedSnapshots and filters skipped snapshots out
of survivors because they are not materialized, but the new function has no equivalent root filter;
the hoist traversal documentation explains that skipped nodes may still be visited for traversal,
and ensure_parent_directories then materializes the destinations collected for those skipped
roots.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[165-201]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-245]
pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[89-101]
pnpm/crates/deps-restorer/src/hoist.rs[210-214]
pnpm/crates/deps-restorer/src/linking.rs[351-360]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-247]
pnpm/crates/deps-restorer/src/phase_options.rs[30-43]
pnpm/crates/deps-restorer/src/installability.rs[65-84]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Rust GVS child-hoist pass processes every wanted-lockfile snapshot, including roots excluded from the current installation by installability, failed-fetch, optional-dependency, or dependency-group filtering. It can therefore perform hoisting and filesystem writes for package slots that the installation deliberately did not materialize.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/linking.rs[354-360]
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[165-201]
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[233-247]

## Recommended Fix
Pass the current installation's filtered snapshot closure into the GVS child-link pass, or filter `snapshots` before invoking `slot_hoisted_symlinks`, and skip any root whose `pkg_key` is present in `hoist_skipped`. Preserve traversal through skipped children where the hoist algorithm requires it, but never emit links into a skipped root slot; continue processing relevant slots that already existed before this run so upgrades still populate their new links.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (4)
10. Large installs add avoidable filesystem scans 🐞 Bug ➹ Performance ⭐ New
Description
ensure_parent_directories calls create_dir_all for every unique target and destination parent
before the symlink pass, even though symlink_package already creates a missing destination parent
during its retry path. On global-store installs with many hoisted packages, these mostly-existing
slot directories add up to two extra synchronous directory operations per emitted link pair on the
install linking hot path.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[R203-215]

+fn ensure_parent_directories(pairs: &[SymlinkWork]) {
+    let mut dir_set = HashSet::new();
+    for (target, dest) in pairs {
+        if let Some(parent) = target.parent() {
+            dir_set.insert(parent);
+        }
+        if let Some(parent) = dest.parent() {
+            dir_set.insert(parent);
+        }
+    }
+    for dir in dir_set {
+        let _ = std::fs::create_dir_all(dir);
+    }
Relevance

●● Moderate

Performance optimization is plausible, but available precedent rejects similar filesystem-work
reductions; context is not identical.

PR-#13173
PR-#14265

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new helper eagerly creates both parent classes before every symlink operation. The existing
shared helper delegates to force_symlink_dir, whose documented retry already creates missing
parents and specifically explains that eager precreation adds unnecessary filesystem checks in the
common case.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[203-215]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[247-251]
pnpm/crates/deps-restorer/src/symlink_package.rs[54-68]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
The new GVS linker eagerly runs `create_dir_all` for all symlink target and destination parents. The shared symlink helper already creates missing destination parents, while target parents do not need to exist merely to create a symlink, so this adds synchronous filesystem work to large installs.

Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[203-215]
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[247-251]
- pnpm/crates/deps-restorer/src/symlink_package.rs[54-68]

Recommended Fix
Remove the eager target-parent creation and rely on `symlink_package` to create a destination parent only when it is absent. If scoped destination setup is still required for platform-specific behavior, create only the necessary destination scope parents, not target-slot parents.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


11. Unrelated test fixes widen the PR 📘 Rule violation ⚙ Maintainability
Description
read(true) changes three sparse-mirror tests in the npm resolver even though the GVS fix does not
use metadata mirror I/O. The separate Windows file-handle adjustment belongs to another defect and
reaches a resolver test area unrelated to package-slot linking.
Code

pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[526]

+        .read(true)
Relevance

●●● Strong

The separate resolver commit confirms unrelated test-only changes are outside this GVS fix’s scope.

PR-#13686

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The scope rule permits only behavior needed for the reported bug or local mechanical changes
required to compile and test it. These edits affect unrelated npm metadata mirror tests and are
identified by a separate commit message rather than the GVS linking path.

Rule 2255067: Bug fix changes must not include unrelated refactors or reformatting
pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[523-529]
pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[550-556]
pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[582-588]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR includes a separate Windows sparse-file test adjustment that is unrelated to exposing hoisted dependencies in GVS package slots. Mixing the changes expands review and regression scope beyond the stated bug fix.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[526-526]
- pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[553-553]
- pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs[585-585]

## Recommended Fix
Remove the three `read(true)` changes from this PR and submit them with the corresponding Windows sparse-mirror defect and regression context in a separate pull request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


12. Linked dependencies can be overwritten 📘 Rule violation ≡ Correctness
Description
snapshot_direct_deps drops dependency aliases whose references do not resolve to PackageKey,
while push_alias_symlinks excludes only aliases retained in that map. When a slot already contains
a link: child whose alias matches a hoisted transitive package, the later Rust pass replaces that
child symlink while both TypeScript paths preserve it.
Code

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[R120-123]

+        if alias == pkg_name || direct_deps.contains_key(alias) {
+            continue;
+        }
+        if let Ok(dest) = safe_join_modules_dir(virtual_node_modules_dir, alias) {
Relevance

●●● Strong

Recent Rust hoisting precedents accept alias-resolution correctness fixes and regression coverage
for traversal-root omissions.

PR-#13455
PR-#15165

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The alignment rule requires equivalent observable behavior in the Rust and TypeScript stacks. The
Rust exclusion checks only the resolvable direct-dependency map, while both TypeScript
implementations construct and check an existingAliases set before adding hoisted links.

Rule 3102961: Keep pnpm v11 and v12 bug-fix code paths functionally aligned
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[97-126]
pnpm/crates/deps-restorer/src/symlink_package.rs[21-31]
pnpm11/installing/deps-installer/src/install/link.ts[686-695]
pnpm11/installing/deps-restorer/src/index.ts[1517-1528]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Rust GVS hoisting pass can overwrite an existing child such as a `link:` dependency because unresolved child references are absent from `direct_deps`. This diverges from both TypeScript paths, which exclude every alias already present in the slot.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[97-126]

## Recommended Fix
Collect all existing snapshot child aliases separately from resolvable direct dependencies, pass that alias set into `push_alias_symlinks`, and skip every hoisted alias already represented by a child. Add coverage for a `link:` child whose alias collides with a transitive hoist.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


13. Twin hoist helpers can drift apart 📘 Rule violation ⚙ Maintainability
Description
getGvsHoistedChildrenPaths is implemented separately in the dependency installer and dependency
restorer despite performing the same graph traversal, hoist calculation, and alias filtering. A
later fix can update only regular or headless installation, producing different GVS layouts
depending on which installation path runs.
Code

pnpm11/installing/deps-installer/src/install/link.ts[R706-709]

+function getGvsHoistedChildrenPaths (
+  depNode: Pick<DependenciesGraphNode, 'children' | 'modules' | 'name' | 'optionalDependencies'>,
+  depGraph: DependenciesGraph,
+  opts: {
Relevance

●● Moderate

Shared extraction is plausible, but no close precedent establishes acceptance for duplicating these
distinct installation-path helpers.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The reuse rule requires shared extraction when new functions perform the same algorithm on the same
domain data. Both helpers build direct dependencies, invoke getHoistedDependencies with equivalent
options, apply the same alias exclusions, and return package directories; both consumers already
depend on the hoist package.

Rule 713439: Avoid reimplementing existing functionality; extract and reuse shared modules
pnpm11/installing/deps-installer/src/install/link.ts[706-747]
pnpm11/installing/deps-restorer/src/index.ts[1600-1641]
pnpm11/installing/linking/hoist/src/index.ts[388-407]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The installer and restorer contain near-identical implementations for calculating GVS hoisted child paths. Keeping both copies makes regular and headless installation behavior liable to diverge.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/link.ts[706-747]
- pnpm11/installing/deps-restorer/src/index.ts[1600-1641]
- pnpm11/installing/linking/hoist/src/index.ts[388-407]

## Recommended Fix
Move the common graph traversal and alias-selection logic into the existing hoist package and call it from both consumers. Preserve the installer-specific installability filter through a typed predicate or option rather than retaining duplicate traversal code.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
Review mode: 🧠 Deep: This push contains dense, substantive logic across multiple independent Rust and TypeScript paths—including GVS linking, dependency resolution, lockfile handling, and configuration—with many opportunities for subtle defects.
ⓘ  1 issues published inline · 5 in summary

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Critical optional-dependency, symlink-configuration, and stale-link issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity · 7 Medium severity · 1 Low severity

Open (12)

Copilot AI review requested due to automatic review settings September 25, 2026 16:44
@zkochan
zkochan force-pushed the fix/gvs-hoisted-transitive-deps-resolution branch from 5708a10 to b209d50 Compare September 25, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b209d50

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no, we can't accept this solution. The gvs can't have symlinks specific to a project's context as that context may vary in different projects.

@zkochan zkochan closed this Sep 26, 2026
@kairosci
kairosci deleted the fix/gvs-hoisted-transitive-deps-resolution branch September 27, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global virtual store: packages that execute from the links store can't resolve transitive deps (Angular build, Nuxt install)

4 participants