Skip to content

fix: materialize and hash link: dependencies in virtual-store slots - #13658

Merged
zkochan merged 7 commits into
mainfrom
link-peers
Aug 5, 2026
Merged

zkochan merged 7 commits into
mainfrom
link-peers

Conversation

@zkochan

@zkochan zkochan commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix link: dependencies in global-virtual-store package slots across the TypeScript CLI and pacquet.

  • Materialize pacquet's linked snapshot dependencies inside their package slots, including aliases and targets outside the workspace.
  • Represent resolved link targets as synthetic leaf nodes in both dependency graphs so target identity affects the package itself and every transitive ancestor.
  • Preserve slot sharing when different projects resolve a link to the same target.
  • Keep optional links aligned with --no-optional, including when reusing a warm global-virtual-store slot, while preserving transitive optionals during partial installs.
  • Add regression coverage for direct and transitive links, aliases, shared targets, packages without links, optional-link transitions, and partial-install optional selection.
  • Use one cross-stack fixture to pin link-path normalization and final slot hashes for empty, parent-segment, and Windows drive-letter targets.
  • Reject dangling or non-directory optional-child entries, propagate unexpected metadata errors, and defer optional-child scans until a warm slot passes the cheaper reuse checks.

Squash Commit Body

Materialize linked snapshot dependencies inside pacquet's virtual-store slots so packages remain self-contained when those slots live outside the project.

Model each resolved link target as a leaf in the TypeScript and Rust dependency graphs. This makes a changed link target affect the recursively computed slot hash of every ancestor while allowing projects that resolve to the same target to keep sharing a slot. Keep the graph extension limited to global-virtual-store hashing so side-effects-cache keys retain their existing behavior.

Thread optional-dependency selection through pacquet's slot materialization and inspect warm slots before reuse. This removes stale optional links under --no-optional and restores them when optional dependencies are enabled again. Preserve transitive optional dependencies during partial installs, where a narrowed direct dependency-group selection does not express --no-optional intent.

Pin the normalization contract with a fixture consumed by both stacks, covering empty targets, parent segments, and Windows drive-letter casing and asserting the final slot hash as well as each synthetic node. Treat missing, dangling, and non-directory expected optional children as a reuse mismatch, detect dangling unexpected entries too, and surface other metadata errors. Run optional-child scans only after the slot passes the cheaper existence and integrity checks.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
  • Updated the documentation if needed.

Written by an agent (Codex, GPT-5).

Summary by CodeRabbit

  • Bug Fixes

    • Fixed missing link: dependencies when using the global virtual store.
    • Linked dependencies are now correctly materialized as symlinks or junctions.
    • Prevented different local link targets from incorrectly sharing dependency slots.
    • Ensured linked packages resolve relative to the lockfile location.
    • Fixed optional linked dependencies during installs with or without optional dependencies.
  • Tests

    • Added coverage for linked dependency resolution, slot isolation, shared targets, and optional dependency handling.

A package whose peer dependency is satisfied by a `link:` records that
edge in the lockfile but never got a symlink for it. Project-locally the
omission is invisible: the slot sits under the importer's `node_modules`,
so Node's upward walk reaches the importer's own copy of the link. Under
the global virtual store the slot lives in the shared store, that walk
never reaches the project, and the dependency is missing at runtime.

The same edge was dropped from the GVS hash, so two projects linking
different directories collapsed onto one slot and shared whichever
symlink was written first. Scope by the resolved link target rather than
by the project, so projects linking the same directory still share.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 5, 2026 08:43

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 Aug 5, 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

link: dependencies now resolve from the lockfile directory, materialize in GVS slots, and contribute normalized target paths to slot hashes. Optional dependency selection propagates through installation and snapshot planning. Tests cover materialization, removal, slot scoping, and hashing.

Changes

Global virtual store link dependency handling

Layer / File(s) Summary
Layout context and slot scoping
pnpm/crates/deps-restorer/src/virtual_store_layout.rs, pnpm11/deps/graph-hasher/src/index.ts, pnpm11/deps/graph-builder/src/iteratePkgsForVirtualStore.ts
Lockfile-directory context flows into graph construction. Resolved link: targets become graph nodes and affect recursive GVS slot hashes.
Link dependency materialization and optional selection
pnpm/crates/deps-restorer/src/create_symlink_layout.rs, pnpm/crates/deps-restorer/src/create_virtual_*.rs, pnpm/crates/deps-restorer/src/install_*.rs, pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
The install pipeline propagates optional-dependency selection. Validated link: targets are created in dependent slots, and excluded optional links are removed.
Validation and release metadata
pnpm/crates/cli/tests/global_virtual_store.rs, pnpm/crates/deps-restorer/src/**/*tests.rs, pnpm11/deps/graph-hasher/test/*, .changeset/gvs-link-deps-in-slots.md
Tests cover materialization, missing lockfile context, optional-link removal, distinct and equivalent targets, alias-sensitive hashes, and install selection. The changeset records the patch release.

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

Possibly related PRs

  • pnpm/pnpm#13383: Both modify lockfile-directory-aware GVS graph and layout handling.
  • pnpm/pnpm#13173: Both modify optional dependency materialization in the virtual-store pipeline.
  • pnpm/pnpm#13641: Both modify optional-dependency pruning and materialization behavior.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: copilot

Sequence Diagram(s)

sequenceDiagram
  participant InstallWithFreshLockfile
  participant CreateVirtualStore
  participant VirtualStoreLayout
  participant create_symlink_layout
  InstallWithFreshLockfile->>CreateVirtualStore: pass optional dependency selection
  CreateVirtualStore->>VirtualStoreLayout: build layout with lockfile directory
  VirtualStoreLayout->>VirtualStoreLayout: hash resolved link target
  CreateVirtualStore->>create_symlink_layout: materialize slot dependencies
  create_symlink_layout-->>CreateVirtualStore: create or remove optional link
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch link-peers

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix GVS slots: materialize link: deps and scope slot hash by link target

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Materialize link: dependencies inside virtual-store slots using lockfile-relative targets.
• Add link-target scoping to GVS slot hashing to prevent cross-project slot collisions.
• Add unit + CLI e2e tests to pin linking and hashing behavior under GVS.
Diagram

graph TD
  A["pnpm-lock.yaml dir"] --> B["VirtualStoreLayout"] --> C["GVS slot hash"] --> D["Slot dir (.pnpm/<slot>)"]
  B --> E["create_symlink_layout"] --> F["Slot node_modules"] --> G["Symlink to link target"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Scope GVS slots by project path
  • ➕ Simpler mental model: avoids collisions without resolving targets
  • ➕ No need to parse/normalize link targets for hashing
  • ➖ Eliminates intended cross-project sharing when multiple projects link the same directory (e.g., shared toolchains)
  • ➖ Increases store duplication and reduces cache effectiveness
2. Include peer suffix in the GVS hash
  • ➕ Avoids collisions for peer-resolved edges without adding new scope concepts
  • ➖ Changes hashing behavior broadly (more churn) and may reduce sharing more than necessary
  • ➖ Doesn’t directly address slot contents depending on resolved link: target paths
3. Materialize `link:` deps only in importer node_modules
  • ➕ Keeps slot contents independent of external directories
  • ➕ Avoids creating outbound symlinks inside the store
  • ➖ Doesn’t work for global virtual store slots where runtime resolution occurs from the shared store
  • ➖ Breaks when a package inside a slot requires the peer directly

Recommendation: The PR’s approach is the best trade-off: (1) materialize link: deps inside the slot to make runtime resolution correct under GVS, and (2) scope hashing by the resolved link target (and alias) to prevent collisions while preserving desirable sharing for identical targets. The conditional behavior (no lockfile_dir => keep prior behavior; no link deps => unchanged hash) minimizes churn and risk.

Files changed (6) +391 / -4

Bug fix (2) +99 / -4
create_symlink_layout.rsMaterialize 'link:' dependencies inside slot node_modules when lockfile_dir is known +20/-3

Materialize 'link:' dependencies inside slot node_modules when lockfile_dir is known

• Adds special handling for 'SnapshotDepRef::Link' to create a symlink in the slot pointing to the lockfile-relative target resolved against the lockfile directory. Preserves prior behavior by skipping link deps when lockfile_dir is unavailable.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs

virtual_store_layout.rsCarry lockfile_dir and include resolved 'link:' targets in GVS hash scoping +79/-1

Carry lockfile_dir and include resolved 'link:' targets in GVS hash scoping

• Extends VirtualStoreLayout with optional lockfile_dir and uses it to compute a link-target scope string for snapshots containing 'link:' dependencies (including alias and normalized resolved path). Applies the scope only when no existing local-directory scope applies, preserving existing hashes for unaffected snapshots.

pnpm/crates/deps-restorer/src/virtual_store_layout.rs

Tests (3) +283 / -0
global_virtual_store.rsAdd CLI e2e test ensuring 'link:' peers are symlinked inside GVS slots +66/-0

Add CLI e2e test ensuring 'link:' peers are symlinked inside GVS slots

• Adds an end-to-end test that installs a workspace with a peer satisfied via 'link:' and asserts the slot contains a symlink/junction pointing to the correct workspace directory.

pnpm/crates/cli/tests/global_virtual_store.rs

tests.rsAdd unit tests for 'link:' symlink creation and lockfile_dir fallback +76/-0

Add unit tests for 'link:' symlink creation and lockfile_dir fallback

• Adds a test that verifies a 'link:' dependency becomes a symlink to the correct resolved directory. Adds a second test ensuring link deps are skipped (not guessed) when no lockfile_dir is provided.

pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs

tests.rsAdd tests for link-target-based slot hashing and hash stability without links +141/-0

Add tests for link-target-based slot hashing and hash stability without links

• Adds unit tests ensuring snapshots with different link targets get different slots, identical resolved targets share across projects, and snapshots without link deps keep the same slot identity.

pnpm/crates/deps-restorer/src/virtual_store_layout/tests.rs

Documentation (1) +9 / -0
gvs-link-deps-in-slots.mdAdd changeset describing GVS 'link:' materialization and hashing scope +9/-0

Add changeset describing GVS 'link:' materialization and hashing scope

• Introduces a patch changeset documenting the runtime bug under global virtual store and the fix: creating 'link:' symlinks inside slots and scoping slots by resolved link targets to avoid collisions.

.changeset/gvs-link-deps-in-slots.md

@greptile-apps

greptile-apps Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported lossy-path behavior is deliberate, documented, and preserves cross-stack slot identity.

Reviews (7): Last reviewed commit: "fix: rebuild dangling optional links" | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.06     11.3±0.12ms    33.2 MB/sec    1.00     10.7±0.15ms    35.1 MB/sec
packument/parse                                  1.11     39.8±1.08µs  1668.4 MB/sec    1.00     35.9±0.56µs  1846.1 MB/sec
tarball/download_dependency                      1.01      2.8±0.16ms  1539.0 KB/sec    1.00      2.8±0.09ms  1560.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.06   174.2±10.19ms 91.8 KElem/sec    1.00    164.6±3.02ms 97.2 KElem/sec
workspace_resolution/hoist_heavy                 1.07    250.5±1.11ms        ? ?/sec    1.00    234.7±7.87ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.08%. Comparing base (1ee45b9) to head (fc1dc6b).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...restorer/src/create_virtual_store/snapshot_plan.rs 93.96% 7 Missing ⚠️
...eps-restorer/src/create_virtual_dir_by_snapshot.rs 87.50% 1 Missing ⚠️
...s/deps-restorer/src/install_package_by_snapshot.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #13658    +/-   ##
========================================
  Coverage   88.07%   88.08%            
========================================
  Files         590      604    +14     
  Lines       98784    98986   +202     
========================================
+ Hits        87005    87189   +184     
- Misses      11779    11797    +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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

🧹 Nitpick comments (1)
pnpm/crates/deps-restorer/src/virtual_store_layout/tests.rs (1)

573-616: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add alias-sensitive slot coverage.

link_target_scope includes the alias because it changes the symlink path inside the slot. Add a test where two snapshots use different aliases for one resolved target and assert that their slot directories differ.

As per path instructions, tests should be regression-proving and meaningful.

🤖 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/deps-restorer/src/virtual_store_layout/tests.rs` around lines 573
- 616, Extend snapshots_with_link_deps_get_a_slot_per_link_target with coverage
for alias-sensitive paths: create two snapshots using different dependency
aliases that resolve to the same link target, compute each slot through
VirtualStoreLayout::slot_dir, and assert the slot directories differ. Keep the
existing distinct-target assertion and use the snapshot/link helper symbols
already present.

Source: Path instructions

🤖 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 @.changeset/gvs-link-deps-in-slots.md:
- Around line 7-9: Update the changeset description to retain only the concise,
user-facing explanation of the fix and remove the internal layout details,
failure mechanism, lockfile examples, and global virtual store implementation
discussion. Keep the observable behavior and affected dependency-linking
scenario described in the existing release note.

---

Nitpick comments:
In `@pnpm/crates/deps-restorer/src/virtual_store_layout/tests.rs`:
- Around line 573-616: Extend
snapshots_with_link_deps_get_a_slot_per_link_target with coverage for
alias-sensitive paths: create two snapshots using different dependency aliases
that resolve to the same link target, compute each slot through
VirtualStoreLayout::slot_dir, and assert the slot directories differ. Keep the
existing distinct-target assertion and use the snapshot/link helper symbols
already present.
🪄 Autofix

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: 3a23ca56-22b2-4570-be5e-e94a1019dee1

📥 Commits

Reviewing files that changed from the base of the PR and between 420f91b and 6f56073.

📒 Files selected for processing (6)
  • .changeset/gvs-link-deps-in-slots.md
  • pnpm/crates/cli/tests/global_virtual_store.rs
  • pnpm/crates/deps-restorer/src/create_symlink_layout.rs
  • pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs
  • pnpm/crates/deps-restorer/src/virtual_store_layout.rs
  • pnpm/crates/deps-restorer/src/virtual_store_layout/tests.rs

Comment thread .changeset/gvs-link-deps-in-slots.md Resolved
@qodo-code-review

qodo-code-review Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (2) 📜 Skill insights (0)

Grey Divider


Action required

1. Dangling optional link passes probe ✓ Resolved 🐞 Bug ⛨ Security ⭐ New
Description
optional_children_match() uses std::fs::symlink_metadata() and treats any successful lstat as
“exists”, which also succeeds for dangling symlinks and does not validate that the entry resolves to
a directory. This can make plan_snapshots() incorrectly reuse a warm slot and skip relinking,
leaving an optional dependency missing/broken at runtime (and potentially preserving an unexpected
on-disk entry).
Code

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[R211-214]

+        |path| match std::fs::symlink_metadata(path) {
+            Ok(_) => Ok(true),
+            Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(false),
+            Err(error) => Err(error),
Relevance

●●● Strong

Correctness/security bug: dangling symlink counted as present can skip relinking; team often accepts
fs/symlink hardening.

PR-#13170
PR-#13306

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The warm-slot reuse path calls optional_children_match() during current_slot_matches; that
helper currently uses symlink_metadata() and returns Ok(true) for any existing directory entry,
which includes dangling symlinks. This can cause the slot to be considered current and skipped even
though optional dependency links are broken, mirroring a previously accepted bug pattern in the
repo.

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[85-155]
pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[196-216]
PR-#13151

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

### Issue description
Warm-slot reuse validation currently treats `symlink_metadata()` success as proof that an optional dependency entry is correctly present. This is insufficient because `symlink_metadata()` only inspects the directory entry (lstat) and can succeed even when the link target is missing, and it doesn’t ensure the entry resolves to a directory.

### Issue Context
This probe gates whether a snapshot is considered “current” and can be skipped during installs. If the probe returns a false-positive, the install may skip relinking and leave a broken optional dependency in the slot.

### Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[196-216]
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[219-255]

### Suggested fix
- In `optional_children_match()`, replace the `symlink_metadata`-based `child_exists` predicate with a predicate that *follows* the entry and requires a directory:
 - Use `std::fs::metadata(path)` and return `Ok(meta.is_dir())`.
 - Map `ErrorKind::NotFound` to `Ok(false)` as today.
 - Preserve the current behavior of propagating other I/O errors as `InspectOptionalDependency`.

Optionally (stronger hardening): when `should_exist` is `true`, also verify the entry is a link/junction (not a real directory) using the project’s existing “symlink-or-junction” detection helper, and treat non-link directories as mismatch so the slot is rebuilt.

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



Remediation recommended

2. lockfileToDepGraph missing trailing comma 📘 Rule violation ⚙ Maintainability
Description
The multi-line parameter lists for lockfileToDepGraph and lockfileDepsToGraphChildren omit
trailing commas on their last parameters, violating the repo’s TypeScript trailing-comma requirement
and potentially creating noisier diffs.
Code

pnpm11/deps/graph-hasher/src/index.ts[R377-380]

export function lockfileToDepGraph (
  lockfile: LockfileObject,
-  supportedArchitectures?: SupportedArchitectures
+  supportedArchitectures?: SupportedArchitectures,
+  lockfileDir?: string
Relevance

●●● Strong

Trailing-comma style fixes are routinely accepted to satisfy formatting/lint rules and avoid noisy
diffs.

PR-#11855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas for multi-line TypeScript constructs; both updated
function signatures are formatted across multiple lines but end their final parameters
(lockfileDir?: string in lockfileToDepGraph and linkTargetNodes: Set<DepPath> in
lockfileDepsToGraphChildren) without a trailing comma, directly contradicting the rule.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/deps/graph-hasher/src/index.ts[377-381]
pnpm11/deps/graph-hasher/src/index.ts[450-454]

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 multi-line parameter lists for `lockfileToDepGraph` and `lockfileDepsToGraphChildren` are missing trailing commas after their last parameters.

## Issue Context
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs to keep formatting consistent and reduce diff churn.

## Fix Focus Areas
- pnpm11/deps/graph-hasher/src/index.ts[377-381]
- pnpm11/deps/graph-hasher/src/index.ts[450-454]

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


3. Warm install extra FS stats 🐞 Bug ➹ Performance
Description
plan_snapshots now calls optional_children_match on the warm-install reuse path, which performs
symlink_metadata per optional dependency entry to decide whether a snapshot can be skipped. On
large lockfiles with many optionalDependencies, this adds substantial filesystem calls to every
warm install and can noticeably slow installs on high-latency or heavily monitored filesystems.
Code

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[R105-112]

+            if !optional_children_match(
+                snapshot_key,
+                snapshot,
+                layout,
+                skipped,
+                link_dependencies,
+                include_optional_dependencies,
+            ) {
Relevance

●●● Strong

Team has accepted reducing redundant filesystem probes; this adds many symlink_metadata calls on
warm path.

PR-#13170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The warm-install skip predicate now invokes optional_children_match, which iterates
optional_dependencies and performs std::fs::symlink_metadata(...) for each optional alias,
making the cost proportional to the number of optional deps in otherwise-skippable snapshots.

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[88-114]
pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[186-221]

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

### Issue description
Warm installs now perform per-optional-dependency `symlink_metadata` checks to determine whether a snapshot can be reused, which can add many filesystem calls and slow down reinstall scenarios.

### Issue Context
The new `optional_children_match(...)` runs during the current-lockfile skip filtering. For snapshots with `optional_dependencies`, it iterates every optional alias and stats its `node_modules/<alias>` path.

### Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[105-114]
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[186-221]

### Suggested fix direction
- Record whether optional-dependency links were included in the slot (e.g., a small marker file under the slot, or a field in an existing per-slot manifest/metadata).
- In `plan_snapshots`, replace the per-alias `symlink_metadata` loop with a single check of that marker (or a small constant number of checks), and fall back to full relink only when the marker indicates mismatch.

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


4. used to in doc comment 📘 Rule violation ⚙ Maintainability
Description
New Rust doc comments include historical phrasing (e.g., Nothing used to..., `pre-existing
behaviour`) instead of documenting only current behavior, which can mislead future maintenance.
Code

pnpm/crates/cli/tests/global_virtual_store.rs[R1276-1278]

+/// `@pnpm.e2e/abc` snapshot (see the `exclude_links_from_lockfile`
+/// suite for the resolution half). Nothing used to create that link:
+/// project-locally the omission is invisible, because the slot sits
Relevance

●●● Strong

Repo frequently accepts rewording comments to remove “used to”/historical phrasing.

PR-#13138
PR-#13652

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids historical/temporal phrasing in added/modified comments. The new
comments explicitly reference prior behavior using phrases like Nothing used to... and
pre-existing behaviour.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/global_virtual_store.rs[1274-1278]
pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs[324-327]

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

## Issue description
Added comments use historical phrasing ("used to", "pre-existing") rather than describing the current behavior/contract.

## Issue Context
Inline comments/docstrings must describe current behavior and invariants; historical notes should live in PR/commit history or design docs.

## Fix Focus Areas
- pnpm/crates/cli/tests/global_virtual_store.rs[1274-1282]
- pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs[324-327]

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


View more (3)
5. Changeset missing pnpm entry ✓ Resolved 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and omits pnpm, which violates the
requirement to explicitly include the pnpm package and bump type in changesets.
Code

.changeset/gvs-link-deps-in-slots.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

●●● Strong

Strong precedent: changesets missing explicit pnpm bump were fixed/accepted recently.

PR-#13403
PR-#13337

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to include an explicit pnpm entry with a
valid bump type. The added changeset front-matter lists only pacquet and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/gvs-link-deps-in-slots.md[1-3]

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 front-matter is missing an explicit `pnpm` entry.

## Issue Context
Compliance requires changeset front-matter to include `pnpm` with a valid bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/gvs-link-deps-in-slots.md[1-3]

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


6. Relative link target symlink 🐞 Bug ☼ Reliability
Description
create_symlink_layout now symlinks link: deps to lockfile_dir.join(link_target); if
lockfile_dir is relative, the symlink target is also relative and will resolve relative to the
slot directory, producing broken or incorrect links (especially under GVS where Node can’t “walk up”
into the project). VirtualStoreLayout stores lockfile_dir verbatim, and the install pipeline
derives it from manifest paths without canonicalizing, so a relative lockfile/workspace root can
flow into this new symlink path.
Code

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

+            let symlink_path =
+                safe_join_modules_dir(virtual_node_modules_dir, &alias_name.to_string())
+                    .map_err(SymlinkPackageError::InvalidAlias)?;
+            return symlink_package(&lockfile_dir.join(link_target), &symlink_path).map(drop);
Relevance

●● Moderate

Potentially real edge case, but fix requires behavioral/IO decisions; no close precedent found.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR now forwards lockfile_dir.join(link_target) directly into the symlink syscall. Because
VirtualStoreLayout stores lockfile_dir without making it absolute, and the install pipeline
derives workspace_root from a manifest path without canonicalizing, a relative root can propagate
into this new code path and create a relative symlink target, which is resolved relative to the slot
directory.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[41-60]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[205-217]
pnpm/crates/package-manifest/src/lib.rs[187-193]
pnpm/crates/package-manager/src/install/run.rs[133-149]
pnpm/crates/deps-restorer/src/symlink_package.rs[54-71]

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

## Issue description
`create_symlink_layout` uses `symlink_package(&lockfile_dir.join(link_target), ...)` for `link:` deps. If `lockfile_dir` is relative, the computed symlink target is relative too, and OS symlink semantics resolve that relative target against the symlink’s parent directory (the slot), not against `lockfile_dir`, leading to broken/misdirected `link:` dependencies under the global virtual store.

## Issue Context
- `VirtualStoreLayout::new` stores `lockfile_dir` as `lockfile_dir.map(Path::to_path_buf)` (no absolutization).
- The installer derives `workspace_root` (passed as `lockfile_dir`) from `manifest.path().parent()` without canonicalization.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[52-60]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[205-217]
- pnpm/crates/package-manager/src/install/run.rs[133-149]

## Suggested fix
- In `create_symlink_layout`, ensure the symlink target passed to `symlink_package` is absolute:
 - If `lockfile_dir.is_absolute()`: use `pacquet_fs::lexical_normalize(&lockfile_dir.join(link_target))`.
 - Else: resolve `lockfile_dir` against a known absolute base (preferably the install’s absolute workspace root if available; otherwise `std::env::current_dir()` as a fallback) before joining.
- Add a regression test that exercises a relative `lockfile_dir` and asserts the created slot symlink points to the intended target (and not a store-relative path).

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


7. GVS hash adds link_scope ✓ Resolved 📘 Rule violation ≡ Correctness
Description
Pacquet now scopes GVS slot hashing by resolved link: targets, but pnpm TypeScript's GVS hasher
drops link: dependencies from the hashed graph, so pnpm and pacquet can compute different slot
paths for the same scenario.
Code

pnpm/crates/deps-restorer/src/virtual_store_layout.rs[R278-282]

+            let link_scope = match directory_scope {
+                Some(_) => None,
+                None => link_target_scope(snapshot, lockfile_dir),
+            };
+            let project = directory_scope.or(link_scope.as_deref());
Relevance

●● Moderate

Hash-parity with pnpm is subtle/user-visible; change is plausible but needs strong alignment
evidence.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713429 requires pacquet not to introduce new user-visible behavior beyond pnpm. The
pacquet change adds link_target_scope(...) into GVS hashing, while pnpm TypeScript's hashing path
(via refToRelative) drops link: refs and only scopes by lockfileDir for directory deps,
indicating the link: target is not part of pnpm's hash input.

Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[272-282]
pnpm11/deps/path/src/index.ts[156-162]
pnpm11/deps/graph-hasher/src/index.ts[261-271]

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

## Issue description
Pacquet's GVS hashing now includes a `link:`-target scope, but pnpm TypeScript's graph-hasher appears to omit `link:` dependencies from the hash input.

## Issue Context
To preserve pnpm/pacquet compatibility, equivalent inputs should produce equivalent GVS slot paths (or the divergence must be eliminated by porting the behavior).

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[272-282]
- pnpm11/deps/path/src/index.ts[156-169]
- pnpm11/deps/graph-hasher/src/index.ts[261-271]

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



Informational

8. Excess String churn in hashing 🐞 Bug ➹ Performance
Description
GVS hashing now builds the dependency graph with String keys and repeatedly converts PackageKey
to String (lockfile_to_dep_graph, built_dep_paths, and per-snapshot graph_key) while
computing suffixes. This increases allocations and hashing overhead during layout construction,
especially for large lockfiles, even though some owned-string usage is necessary for synthetic
link: target nodes.
Code

pnpm/crates/deps-restorer/src/virtual_store_layout.rs[R275-279]

+            let graph_key = snapshot_key.to_string();
            let hex_digest = calc_graph_node_hash(
                &graph,
                &mut cache,
-                snapshot_key,
+                &graph_key,
Relevance

● Weak

Similar micro-optimizations avoiding to_string()/String allocations were explicitly rejected in
nearby Rust hashing/ordering code.

PR-#13368
PR-#13455

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new code constructs a HashMap<String, DepsGraphNode<String>> graph, inserts nodes using
snapshot_key.to_string(), collects built_dep_paths as HashSet<String>, and allocates another
snapshot_key.to_string() per snapshot during hashing; these are all additional allocations vs a
PackageKey-keyed graph.

pnpm/crates/deps-restorer/src/virtual_store_layout.rs[228-289]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[547-581]

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 layout construction now allocates and clones many `String`s while building the dependency graph and computing node hashes, which can increase CPU and memory overhead for large graphs.

### Issue Context
The graph is now keyed by `String` and link targets are modeled as synthetic `link:<abs-path>` leaf nodes. This requires some owned strings, but currently `snapshot_key.to_string()` is performed in multiple places (graph build + per-node hashing + build gating set).

### Fix Focus Areas
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[228-246]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[275-284]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[547-581]

### Suggested fix direction
- Precompute and store a `HashMap<PackageKey, String>` (or similar) of `PackageKey::to_string()` once, and reuse it for:
 - graph node keys
 - children values (for snapshot nodes)
 - `built_dep_paths` population
 - per-snapshot `graph_key` passed into `calc_graph_node_hash`
- Alternatively, use an enum key type (e.g., `NodeKey::Snapshot(PackageKey)` / `NodeKey::LinkTarget(String|PathBuf)`) to keep snapshot nodes keyed by `PackageKey` while still supporting link target leaf nodes.

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


Grey Divider

Context used
✅ Compliance rules (platform): 24 rules

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Previous review results

Review updated until commit fc1dc6b

Results up to commit 6f56073 ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. used to in doc comment 📘 Rule violation ⚙ Maintainability
Description
New Rust doc comments include historical phrasing (e.g., Nothing used to..., `pre-existing
behaviour`) instead of documenting only current behavior, which can mislead future maintenance.
Code

pnpm/crates/cli/tests/global_virtual_store.rs[R1276-1278]

+/// `@pnpm.e2e/abc` snapshot (see the `exclude_links_from_lockfile`
+/// suite for the resolution half). Nothing used to create that link:
+/// project-locally the omission is invisible, because the slot sits
Relevance

●●● Strong

Repo frequently accepts rewording comments to remove “used to”/historical phrasing.

PR-#13138
PR-#13652

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids historical/temporal phrasing in added/modified comments. The new
comments explicitly reference prior behavior using phrases like Nothing used to... and
pre-existing behaviour.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/global_virtual_store.rs[1274-1278]
pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs[324-327]

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

## Issue description
Added comments use historical phrasing ("used to", "pre-existing") rather than describing the current behavior/contract.

## Issue Context
Inline comments/docstrings must describe current behavior and invariants; historical notes should live in PR/commit history or design docs.

## Fix Focus Areas
- pnpm/crates/cli/tests/global_virtual_store.rs[1274-1282]
- pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs[324-327]

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


2. Changeset missing pnpm entry ✓ Resolved 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and omits pnpm, which violates the
requirement to explicitly include the pnpm package and bump type in changesets.
Code

.changeset/gvs-link-deps-in-slots.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

●●● Strong

Strong precedent: changesets missing explicit pnpm bump were fixed/accepted recently.

PR-#13403
PR-#13337

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to include an explicit pnpm entry with a
valid bump type. The added changeset front-matter lists only pacquet and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/gvs-link-deps-in-slots.md[1-3]

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 front-matter is missing an explicit `pnpm` entry.

## Issue Context
Compliance requires changeset front-matter to include `pnpm` with a valid bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/gvs-link-deps-in-slots.md[1-3]

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


3. Relative link target symlink 🐞 Bug ☼ Reliability
Description
create_symlink_layout now symlinks link: deps to lockfile_dir.join(link_target); if
lockfile_dir is relative, the symlink target is also relative and will resolve relative to the
slot directory, producing broken or incorrect links (especially under GVS where Node can’t “walk up”
into the project). VirtualStoreLayout stores lockfile_dir verbatim, and the install pipeline
derives it from manifest paths without canonicalizing, so a relative lockfile/workspace root can
flow into this new symlink path.
Code

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

+            let symlink_path =
+                safe_join_modules_dir(virtual_node_modules_dir, &alias_name.to_string())
+                    .map_err(SymlinkPackageError::InvalidAlias)?;
+            return symlink_package(&lockfile_dir.join(link_target), &symlink_path).map(drop);
Relevance

●● Moderate

Potentially real edge case, but fix requires behavioral/IO decisions; no close precedent found.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR now forwards lockfile_dir.join(link_target) directly into the symlink syscall. Because
VirtualStoreLayout stores lockfile_dir without making it absolute, and the install pipeline
derives workspace_root from a manifest path without canonicalizing, a relative root can propagate
into this new code path and create a relative symlink target, which is resolved relative to the slot
directory.

pnpm/crates/deps-restorer/src/create_symlink_layout.rs[41-60]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[205-217]
pnpm/crates/package-manifest/src/lib.rs[187-193]
pnpm/crates/package-manager/src/install/run.rs[133-149]
pnpm/crates/deps-restorer/src/symlink_package.rs[54-71]

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

## Issue description
`create_symlink_layout` uses `symlink_package(&lockfile_dir.join(link_target), ...)` for `link:` deps. If `lockfile_dir` is relative, the computed symlink target is relative too, and OS symlink semantics resolve that relative target against the symlink’s parent directory (the slot), not against `lockfile_dir`, leading to broken/misdirected `link:` dependencies under the global virtual store.

## Issue Context
- `VirtualStoreLayout::new` stores `lockfile_dir` as `lockfile_dir.map(Path::to_path_buf)` (no absolutization).
- The installer derives `workspace_root` (passed as `lockfile_dir`) from `manifest.path().parent()` without canonicalization.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[52-60]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[205-217]
- pnpm/crates/package-manager/src/install/run.rs[133-149]

## Suggested fix
- In `create_symlink_layout`, ensure the symlink target passed to `symlink_package` is absolute:
 - If `lockfile_dir.is_absolute()`: use `pacquet_fs::lexical_normalize(&lockfile_dir.join(link_target))`.
 - Else: resolve `lockfile_dir` against a known absolute base (preferably the install’s absolute workspace root if available; otherwise `std::env::current_dir()` as a fallback) before joining.
- Add a regression test that exercises a relative `lockfile_dir` and asserts the created slot symlink points to the intended target (and not a store-relative path).

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


View more (1)
4. GVS hash adds link_scope ✓ Resolved 📘 Rule violation ≡ Correctness
Description
Pacquet now scopes GVS slot hashing by resolved link: targets, but pnpm TypeScript's GVS hasher
drops link: dependencies from the hashed graph, so pnpm and pacquet can compute different slot
paths for the same scenario.
Code

pnpm/crates/deps-restorer/src/virtual_store_layout.rs[R278-282]

+            let link_scope = match directory_scope {
+                Some(_) => None,
+                None => link_target_scope(snapshot, lockfile_dir),
+            };
+            let project = directory_scope.or(link_scope.as_deref());
Relevance

●● Moderate

Hash-parity with pnpm is subtle/user-visible; change is plausible but needs strong alignment
evidence.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713429 requires pacquet not to introduce new user-visible behavior beyond pnpm. The
pacquet change adds link_target_scope(...) into GVS hashing, while pnpm TypeScript's hashing path
(via refToRelative) drops link: refs and only scopes by lockfileDir for directory deps,
indicating the link: target is not part of pnpm's hash input.

Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[272-282]
pnpm11/deps/path/src/index.ts[156-162]
pnpm11/deps/graph-hasher/src/index.ts[261-271]

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

## Issue description
Pacquet's GVS hashing now includes a `link:`-target scope, but pnpm TypeScript's graph-hasher appears to omit `link:` dependencies from the hash input.

## Issue Context
To preserve pnpm/pacquet compatibility, equivalent inputs should produce equivalent GVS slot paths (or the divergence must be eliminated by porting the behavior).

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[272-282]
- pnpm11/deps/path/src/index.ts[156-169]
- pnpm11/deps/graph-hasher/src/index.ts[261-271]

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


Results up to commit a5a3f38 ⚖️ Balanced


🐞 Bugs (2) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. lockfileToDepGraph missing trailing comma 📘 Rule violation ⚙ Maintainability
Description
The multi-line parameter lists for lockfileToDepGraph and lockfileDepsToGraphChildren omit
trailing commas on their last parameters, violating the repo’s TypeScript trailing-comma requirement
and potentially creating noisier diffs.
Code

pnpm11/deps/graph-hasher/src/index.ts[R377-380]

export function lockfileToDepGraph (
  lockfile: LockfileObject,
-  supportedArchitectures?: SupportedArchitectures
+  supportedArchitectures?: SupportedArchitectures,
+  lockfileDir?: string
Relevance

●●● Strong

Trailing-comma style fixes are routinely accepted to satisfy formatting/lint rules and avoid noisy
diffs.

PR-#11855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas for multi-line TypeScript constructs; both updated
function signatures are formatted across multiple lines but end their final parameters
(lockfileDir?: string in lockfileToDepGraph and linkTargetNodes: Set<DepPath> in
lockfileDepsToGraphChildren) without a trailing comma, directly contradicting the rule.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/deps/graph-hasher/src/index.ts[377-381]
pnpm11/deps/graph-hasher/src/index.ts[450-454]

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 multi-line parameter lists for `lockfileToDepGraph` and `lockfileDepsToGraphChildren` are missing trailing commas after their last parameters.

## Issue Context
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs to keep formatting consistent and reduce diff churn.

## Fix Focus Areas
- pnpm11/deps/graph-hasher/src/index.ts[377-381]
- pnpm11/deps/graph-hasher/src/index.ts[450-454]

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


2. Warm install extra FS stats 🐞 Bug ➹ Performance
Description
plan_snapshots now calls optional_children_match on the warm-install reuse path, which performs
symlink_metadata per optional dependency entry to decide whether a snapshot can be skipped. On
large lockfiles with many optionalDependencies, this adds substantial filesystem calls to every
warm install and can noticeably slow installs on high-latency or heavily monitored filesystems.
Code

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[R105-112]

+            if !optional_children_match(
+                snapshot_key,
+                snapshot,
+                layout,
+                skipped,
+                link_dependencies,
+                include_optional_dependencies,
+            ) {
Relevance

●●● Strong

Team has accepted reducing redundant filesystem probes; this adds many symlink_metadata calls on
warm path.

PR-#13170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The warm-install skip predicate now invokes optional_children_match, which iterates
optional_dependencies and performs std::fs::symlink_metadata(...) for each optional alias,
making the cost proportional to the number of optional deps in otherwise-skippable snapshots.

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[88-114]
pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[186-221]

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

### Issue description
Warm installs now perform per-optional-dependency `symlink_metadata` checks to determine whether a snapshot can be reused, which can add many filesystem calls and slow down reinstall scenarios.

### Issue Context
The new `optional_children_match(...)` runs during the current-lockfile skip filtering. For snapshots with `optional_dependencies`, it iterates every optional alias and stats its `node_modules/<alias>` path.

### Fix Focus Areas
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[105-114]
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs[186-221]

### Suggested fix direction
- Record whether optional-dependency links were included in the slot (e.g., a small marker file under the slot, or a field in an existing per-slot manifest/metadata).
- In `plan_snapshots`, replace the per-alias `symlink_metadata` loop with a single check of that marker (or a small constant number of checks), and fall back to full relink only when the marker indicates mismatch.

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



Informational
3. Excess String churn in hashing 🐞 Bug ➹ Performance
Description
GVS hashing now builds the dependency graph with String keys and repeatedly converts PackageKey
to String (lockfile_to_dep_graph, built_dep_paths, and per-snapshot graph_key) while
computing suffixes. This increases allocations and hashing overhead during layout construction,
especially for large lockfiles, even though some owned-string usage is necessary for synthetic
link: target nodes.
Code

pnpm/crates/deps-restorer/src/virtual_store_layout.rs[R275-279]

+            let graph_key = snapshot_key.to_string();
            let hex_digest = calc_graph_node_hash(
                &graph,
                &mut cache,
-                snapshot_key,
+                &graph_key,
Relevance

● Weak

Similar micro-optimizations avoiding to_string()/String allocations were explicitly rejected in
nearby Rust hashing/ordering code.

PR-#13368
PR-#13455

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new code constructs a HashMap<String, DepsGraphNode<String>> graph, inserts nodes using
snapshot_key.to_string(), collects built_dep_paths as HashSet<String>, and allocates another
snapshot_key.to_string() per snapshot during hashing; these are all additional allocations vs a
PackageKey-keyed graph.

pnpm/crates/deps-restorer/src/virtual_store_layout.rs[228-289]
pnpm/crates/deps-restorer/src/virtual_store_layout.rs[547-581]

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 layout construction now allocates and clones many `String`s while building the dependency graph and computing node hashes, which can increase CPU and memory overhead for large graphs.

### Issue Context
The graph is now keyed by `String` and link targets are modeled as synthetic `link:<abs-path>` leaf nodes. This requires some owned strings, but currently `snapshot_key.to_string()` is performed in multiple places (graph build + per-node hashing + build gating set).

### Fix Focus Areas
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[228-246]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[275-284]
- pnpm/crates/deps-restorer/src/virtual_store_layout.rs[547-581]

### Suggested fix direction
- Precompute and store a `HashMap<PackageKey, String>` (or similar) of `PackageKey::to_string()` once, and reuse it for:
 - graph node keys
 - children values (for snapshot nodes)
 - `built_dep_paths` population
 - per-snapshot `graph_key` passed into `calc_graph_node_hash`
- Alternatively, use an enum key type (e.g., `NodeKey::Snapshot(PackageKey)` / `NodeKey::LinkTarget(String|PathBuf)`) to keep snapshot nodes keyed by `PackageKey` while still supporting link target leaf nodes.

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


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.

- `[crate::create_symlink_layout]` is ambiguous between the function and
  its test module; CI documents with `-D warnings --document-private-items`
  so it failed there while a plain `cargo doc` passed.
- Document why the link-target scope converts paths lossily, matching the
  rationale already recorded for `project_scope`.
- Trim the changeset to the user-facing effect.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 5, 2026 08:59

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.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 5, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1f1cc31

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

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 469b86d85c8b

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.636 ± 0.160 2.370 2.907 1.77 ± 0.20
pacquet@main 2.475 ± 0.140 2.367 2.758 1.67 ± 0.19
pnpr@HEAD 1.510 ± 0.144 1.359 1.763 1.02 ± 0.14
pnpr@main 1.486 ± 0.143 1.358 1.753 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6359223556799996,
      "stddev": 0.16025149572069927,
      "median": 2.5826830206799998,
      "user": 2.0467825399999997,
      "system": 1.60080862,
      "min": 2.37042254168,
      "max": 2.90704723468,
      "times": [
        2.53405104668,
        2.5873980886799997,
        2.55268120668,
        2.57796795268,
        2.90704723468,
        2.84797878468,
        2.56162438868,
        2.7463234866799997,
        2.67372882568,
        2.37042254168
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.4747470850799997,
      "stddev": 0.14034595798640023,
      "median": 2.4071497756799998,
      "user": 1.6064325400000001,
      "system": 1.40721812,
      "min": 2.36650152568,
      "max": 2.75790188968,
      "times": [
        2.36650152568,
        2.40153978168,
        2.3907309356799997,
        2.42012572868,
        2.37097597168,
        2.66212812168,
        2.5827476316799998,
        2.41275976968,
        2.38205949468,
        2.75790188968
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5101973868800003,
      "stddev": 0.14362663696628897,
      "median": 1.4793567871800002,
      "user": 1.14108784,
      "system": 1.18155822,
      "min": 1.3594268736800001,
      "max": 1.7625133316800001,
      "times": [
        1.55572247768,
        1.3960393966800002,
        1.7030158946800003,
        1.4064529706800002,
        1.3784535396800002,
        1.5522606036800002,
        1.7625133316800001,
        1.4030269236800001,
        1.58506185668,
        1.3594268736800001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.4856529970800003,
      "stddev": 0.14288647426886406,
      "median": 1.4377017356800001,
      "user": 1.1248190399999998,
      "system": 1.20338502,
      "min": 1.3577736076800002,
      "max": 1.7526258246800002,
      "times": [
        1.3577736076800002,
        1.36399411468,
        1.4487314266800002,
        1.6494971196800001,
        1.38155098768,
        1.3791521266800002,
        1.6472941496800002,
        1.44923856868,
        1.42667204468,
        1.7526258246800002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 295.4 ± 10.9 274.6 310.4 1.11 ± 0.09
pacquet@main 266.8 ± 18.8 244.2 306.8 1.00
pnpr@HEAD 289.1 ± 10.5 276.7 306.0 1.08 ± 0.09
pnpr@main 286.0 ± 13.4 272.2 320.3 1.07 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29540338520000003,
      "stddev": 0.010903201932267187,
      "median": 0.2943160943,
      "user": 0.25599281999999995,
      "system": 0.56118382,
      "min": 0.2745612563,
      "max": 0.3103542103,
      "times": [
        0.2884490573,
        0.29100776429999997,
        0.3071072203,
        0.2927364423,
        0.3103542103,
        0.2958957463,
        0.2745612563,
        0.3003933273,
        0.30602112929999997,
        0.2875076983
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.2667872477,
      "stddev": 0.018795512075450476,
      "median": 0.2622286378,
      "user": 0.23067991999999998,
      "system": 0.50751082,
      "min": 0.24421987530000003,
      "max": 0.3068162933,
      "times": [
        0.3068162933,
        0.2920332813,
        0.2664674603,
        0.2593332673,
        0.24421987530000003,
        0.2605579193,
        0.2638993563,
        0.2583119083,
        0.2653783353,
        0.25085478029999997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2890502359,
      "stddev": 0.010489873663219943,
      "median": 0.28657929979999996,
      "user": 0.22975441999999996,
      "system": 0.56562102,
      "min": 0.2766677343,
      "max": 0.3060122933,
      "times": [
        0.3025297103,
        0.3060122933,
        0.2985061823,
        0.2921684053,
        0.2871411303,
        0.2771392483,
        0.2790939023,
        0.2860174693,
        0.2852262833,
        0.2766677343
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.2859939857,
      "stddev": 0.01336150822829008,
      "median": 0.2818687798,
      "user": 0.23169071999999996,
      "system": 0.56379402,
      "min": 0.2721930373,
      "max": 0.3203083693,
      "times": [
        0.2852004143,
        0.3203083693,
        0.2797246273,
        0.2944967693,
        0.2774140663,
        0.2817889443,
        0.2819486153,
        0.2817282003,
        0.2851368133,
        0.2721930373
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.625 ± 0.029 2.595 2.690 1.62 ± 0.14
pacquet@main 2.599 ± 0.014 2.579 2.625 1.60 ± 0.14
pnpr@HEAD 1.686 ± 0.119 1.505 1.840 1.04 ± 0.12
pnpr@main 1.622 ± 0.139 1.453 1.864 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6249119749000007,
      "stddev": 0.029425791631036886,
      "median": 2.6162306390000003,
      "user": 1.52884002,
      "system": 1.3828929200000002,
      "min": 2.594985798,
      "max": 2.6901297920000005,
      "times": [
        2.594985798,
        2.645178382,
        2.5976681170000004,
        2.6110668090000004,
        2.6901297920000005,
        2.6289070750000003,
        2.647650167,
        2.601072331,
        2.6113692860000004,
        2.621091992
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5987484669,
      "stddev": 0.013600763370041426,
      "median": 2.5985950115000005,
      "user": 1.4919887200000002,
      "system": 1.34714682,
      "min": 2.5793538910000002,
      "max": 2.6254171170000005,
      "times": [
        2.598913356,
        2.5793538910000002,
        2.6254171170000005,
        2.606408688,
        2.5938992610000002,
        2.6110923030000004,
        2.582578829,
        2.5982766670000004,
        2.601405837,
        2.59013872
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6862172873000003,
      "stddev": 0.11855405832025918,
      "median": 1.6762698630000001,
      "user": 1.10358432,
      "system": 1.1569331199999997,
      "min": 1.504880676,
      "max": 1.83996211,
      "times": [
        1.529552793,
        1.83996211,
        1.7936822890000002,
        1.8183471750000002,
        1.504880676,
        1.768862414,
        1.633905999,
        1.6421153210000001,
        1.620439691,
        1.7104244050000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6218023551999998,
      "stddev": 0.1386604731710847,
      "median": 1.592354993,
      "user": 1.0855876199999999,
      "system": 1.1690465199999998,
      "min": 1.45284812,
      "max": 1.864094284,
      "times": [
        1.506797356,
        1.45284812,
        1.864094284,
        1.549889287,
        1.7235102770000001,
        1.598163484,
        1.746741589,
        1.456570391,
        1.732862262,
        1.586546502
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 397.5 ± 20.2 368.0 447.5 1.26 ± 0.07
pacquet@main 381.0 ± 21.7 351.4 431.4 1.21 ± 0.07
pnpr@HEAD 315.1 ± 4.7 306.7 323.6 1.00
pnpr@main 319.5 ± 8.9 308.4 336.4 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.39752819446000004,
      "stddev": 0.02020300931645038,
      "median": 0.39505814506000003,
      "user": 0.50984686,
      "system": 0.7105164,
      "min": 0.36796850506,
      "max": 0.44747581506000006,
      "times": [
        0.36796850506,
        0.39627991906000004,
        0.38921981406000006,
        0.39779585606,
        0.39863950906,
        0.40609129006000005,
        0.38928306306000005,
        0.44747581506000006,
        0.38869180206000004,
        0.39383637106
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.38100873246000005,
      "stddev": 0.02165056479995112,
      "median": 0.37627692456000006,
      "user": 0.50328396,
      "system": 0.6506635000000001,
      "min": 0.35142779306000005,
      "max": 0.43138731106000006,
      "times": [
        0.37280740106000004,
        0.36265222606,
        0.37397625506000004,
        0.35142779306000005,
        0.37282639706000004,
        0.38309579606000005,
        0.38679272706,
        0.43138731106000006,
        0.37857759406,
        0.39654382406000005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31506824576,
      "stddev": 0.004694766793100149,
      "median": 0.31490368106,
      "user": 0.20172136,
      "system": 0.5329598000000001,
      "min": 0.30672352306,
      "max": 0.32361714006000003,
      "times": [
        0.31464263106,
        0.30672352306,
        0.31516473106000004,
        0.31250016806,
        0.31769531306000004,
        0.31716404406000004,
        0.31898730706,
        0.32361714006000003,
        0.31359654706,
        0.31059105306
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.31951886636000004,
      "stddev": 0.00888198496906527,
      "median": 0.31634379456000006,
      "user": 0.20914986,
      "system": 0.5512659999999999,
      "min": 0.30840883706000005,
      "max": 0.33637722506,
      "times": [
        0.33637722506,
        0.32782857706,
        0.32635829506,
        0.31715483706,
        0.30840883706000005,
        0.31355419806,
        0.32455300706,
        0.31031937406000004,
        0.31553275206000003,
        0.31510156106000003
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.778 ± 0.028 1.736 1.824 5.07 ± 0.28
pacquet@main 1.770 ± 0.030 1.727 1.813 5.04 ± 0.29
pnpr@HEAD 0.357 ± 0.015 0.331 0.380 1.02 ± 0.07
pnpr@main 0.351 ± 0.019 0.327 0.379 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.77785995704,
      "stddev": 0.028004533697235517,
      "median": 1.7782558127399999,
      "user": 0.8094870399999999,
      "system": 0.7966021400000001,
      "min": 1.73561683024,
      "max": 1.82439492924,
      "times": [
        1.7585000442399998,
        1.7788412512399998,
        1.7762008112399998,
        1.74268778424,
        1.77818387724,
        1.73561683024,
        1.8137869712399999,
        1.82439492924,
        1.77832774824,
        1.79205932324
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.7699876117400002,
      "stddev": 0.029775088344458592,
      "median": 1.76440655074,
      "user": 0.7847919399999999,
      "system": 0.8047704400000001,
      "min": 1.72716734724,
      "max": 1.81313870324,
      "times": [
        1.79797893324,
        1.79374803624,
        1.8021702182400001,
        1.75949019024,
        1.76932291124,
        1.72716734724,
        1.74604442024,
        1.74348949024,
        1.7473258672399998,
        1.81313870324
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3572296434400001,
      "stddev": 0.014796562374578198,
      "median": 0.35911055074000003,
      "user": 0.24665134000000002,
      "system": 0.62232394,
      "min": 0.33054048424000004,
      "max": 0.38019826224000003,
      "times": [
        0.33054048424000004,
        0.34341794524,
        0.36028588424,
        0.36701215024000006,
        0.36875871124000004,
        0.36793586424,
        0.35128801024000006,
        0.34492390524000005,
        0.38019826224000003,
        0.35793521724000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.35099409094000006,
      "stddev": 0.018953351742900266,
      "median": 0.34895253774,
      "user": 0.24432403999999996,
      "system": 0.6035456399999999,
      "min": 0.32725032224000006,
      "max": 0.37949243524000004,
      "times": [
        0.37949243524000004,
        0.37004111924000005,
        0.37603034124000007,
        0.35497303324000007,
        0.34940936124000005,
        0.34849571424000003,
        0.34017885024000005,
        0.32725032224000006,
        0.33391655624000005,
        0.33015317624
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 177.7 ± 6.4 170.3 190.3 2.03 ± 0.08
pacquet@main 185.9 ± 12.7 172.0 219.6 2.13 ± 0.15
pnpr@HEAD 87.5 ± 1.1 85.8 92.3 1.00
pnpr@main 87.5 ± 0.9 85.5 90.4 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.17768163590666666,
      "stddev": 0.006431167362174902,
      "median": 0.17610055364000002,
      "user": 0.16525915333333335,
      "system": 0.06754936666666667,
      "min": 0.17027811964,
      "max": 0.19026056364000002,
      "times": [
        0.19026056364000002,
        0.17745448564,
        0.17806785664,
        0.18933729964,
        0.17610055364000002,
        0.17381452064,
        0.17027811964,
        0.17343889564,
        0.17159135664,
        0.17222671964,
        0.17289028564,
        0.18767764364,
        0.17564038964,
        0.17815468064,
        0.17829116764
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.18594589170249998,
      "stddev": 0.012699074590553777,
      "median": 0.18157436214,
      "user": 0.17390894499999995,
      "system": 0.0681971,
      "min": 0.17198017564,
      "max": 0.21962800064000002,
      "times": [
        0.17448715364,
        0.17787984464,
        0.21962800064000002,
        0.17566847164000002,
        0.18152595164000002,
        0.19944223464,
        0.19036358664,
        0.19638442164,
        0.19242589964,
        0.19109768464000002,
        0.19411742664,
        0.17867053964000001,
        0.18162277264,
        0.17682434264,
        0.17301576064000002,
        0.17198017564
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08746946960969697,
      "stddev": 0.0011286587072284482,
      "median": 0.08717846364,
      "user": 0.02144494121212121,
      "system": 0.008568363636363636,
      "min": 0.08583691464,
      "max": 0.09228654564,
      "times": [
        0.08583691464,
        0.09228654564,
        0.08636989564,
        0.08658391764,
        0.08845375964,
        0.08983415164,
        0.08646029564,
        0.08767412364,
        0.08725775264,
        0.08796717463999999,
        0.08704714664,
        0.08713862864,
        0.08689372964,
        0.08717846364,
        0.08815126164,
        0.08744038563999999,
        0.08675884664,
        0.08732619164,
        0.08756678363999999,
        0.08694252063999999,
        0.08712697664,
        0.08718691964,
        0.08818742864,
        0.08694148964,
        0.08688874964,
        0.08812769764,
        0.08680387064,
        0.08787615464,
        0.08692723264,
        0.08765731264,
        0.08706026264,
        0.08744137764,
        0.08709853464
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08749788042125001,
      "stddev": 0.0008816990299068934,
      "median": 0.08736733414,
      "user": 0.02001735125,
      "system": 0.00955821875,
      "min": 0.08554498664,
      "max": 0.09044469664,
      "times": [
        0.08807273364,
        0.08554498664,
        0.08777494364,
        0.08716846464,
        0.08709771164,
        0.08729118564,
        0.08781258564,
        0.08748271564,
        0.08690358764,
        0.08757897564,
        0.08806480764,
        0.08729786764,
        0.08690455864,
        0.08745875964,
        0.08765827464,
        0.08691494864,
        0.08768754064,
        0.08738021364,
        0.08735445464,
        0.08717148064,
        0.08741744264,
        0.08724974764,
        0.09044469664,
        0.08952379764,
        0.08696300964,
        0.08734827264,
        0.08723655163999999,
        0.08774584864,
        0.08820744563999999,
        0.08652766164,
        0.08608847664,
        0.08855842564
      ]
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 963.2 ± 184.5 747.6 1227.4 1.05 ± 0.33
pacquet@main 918.8 ± 226.8 599.4 1222.3 1.00
pnpm@HEAD 3019.7 ± 194.6 2769.0 3383.6 3.29 ± 0.84
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.9631811835666668,
      "stddev": 0.18446330159853572,
      "median": 0.9738289529,
      "user": 0.8971054955555555,
      "system": 0.19635352888888885,
      "min": 0.7475901679,
      "max": 1.2273975189000002,
      "times": [
        0.8339900229,
        0.9738289529,
        1.0110327759000002,
        0.7904559429,
        1.2221323829000001,
        1.0687285879000001,
        0.7475901679,
        0.7934742999000001,
        1.2273975189000002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.9187875739000001,
      "stddev": 0.22677926078356617,
      "median": 0.8250051499000001,
      "user": 0.8550318288888888,
      "system": 0.19752464000000003,
      "min": 0.5994172369,
      "max": 1.2223134529000002,
      "times": [
        0.9747422289000001,
        1.2051762619000002,
        1.1345470939,
        0.5994172369,
        0.8057173309,
        0.8250051499000001,
        0.6887341169,
        0.8134352929,
        1.2223134529000002
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0196944219,
      "stddev": 0.19464897062941502,
      "median": 2.9832120558999997,
      "user": 4.58511194,
      "system": 0.27360052888888886,
      "min": 2.7690383538999996,
      "max": 3.3835854879,
      "times": [
        2.9521873109,
        3.2873056898999997,
        2.7690383538999996,
        3.0085138819,
        2.8708763619,
        2.9863342359,
        2.9832120558999997,
        3.3835854879,
        2.9361964189
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.534 ± 0.123 4.453 4.846 1.30 ± 0.04
pacquet@main 4.588 ± 0.108 4.475 4.766 1.31 ± 0.03
pnpr@HEAD 3.499 ± 0.038 3.454 3.556 1.00
pnpr@main 3.539 ± 0.060 3.471 3.672 1.01 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.53395724608,
      "stddev": 0.12281406172572143,
      "median": 4.47724010488,
      "user": 1.78669022,
      "system": 1.3762508,
      "min": 4.45339907388,
      "max": 4.84561848488,
      "times": [
        4.48554532288,
        4.46893488688,
        4.50748772688,
        4.45339907388,
        4.84561848488,
        4.5512850258799995,
        4.46514714188,
        4.46545812688,
        4.63412018788,
        4.46257648288
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5882660914799995,
      "stddev": 0.10828827593155252,
      "median": 4.58855335288,
      "user": 1.87396102,
      "system": 1.4116542,
      "min": 4.47516205488,
      "max": 4.76584325288,
      "times": [
        4.5214597118799995,
        4.65564699388,
        4.76584325288,
        4.69122152988,
        4.47516205488,
        4.4761796048799996,
        4.49163855388,
        4.66007630488,
        4.65658341288,
        4.48884949488
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.49876981368,
      "stddev": 0.03761406819782511,
      "median": 3.49046386088,
      "user": 1.3021770199999998,
      "system": 1.2826944,
      "min": 3.45417022988,
      "max": 3.55618587188,
      "times": [
        3.47528702788,
        3.46273564988,
        3.45417022988,
        3.48813493088,
        3.55618587188,
        3.46858243288,
        3.49279279088,
        3.55512693188,
        3.49901467788,
        3.53566759288
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.53883111808,
      "stddev": 0.059967012978334545,
      "median": 3.5130819123799997,
      "user": 1.3874583199999997,
      "system": 1.3455909,
      "min": 3.4705127328799996,
      "max": 3.6716581758799998,
      "times": [
        3.60093342288,
        3.5138104758799997,
        3.5089398368799998,
        3.5123533488799996,
        3.4705127328799996,
        3.6716581758799998,
        3.50340585088,
        3.56481290088,
        3.54746236988,
        3.49442206588
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13658
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,594.99 ms
(-3.58%)Baseline: 2,691.42 ms
3,229.70 ms
(80.35%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,735.62 ms
(-3.98%)Baseline: 1,807.62 ms
2,169.14 ms
(80.01%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
367.97 ms
(-17.83%)Baseline: 447.80 ms
537.37 ms
(68.48%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
170.28 ms
(-17.49%)Baseline: 206.38 ms
247.65 ms
(68.76%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,370.42 ms
(-2.25%)Baseline: 2,424.94 ms
2,909.93 ms
(81.46%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,453.40 ms
(-0.73%)Baseline: 4,486.29 ms
5,383.54 ms
(82.72%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
274.56 ms
(-3.60%)Baseline: 284.82 ms
341.78 ms
(80.33%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
747.59 ms
(+8.91%)Baseline: 686.40 ms
823.68 ms
(90.76%)
🐰 View full continuous benchmarking report in Bencher

Represent resolved link targets as leaf nodes in the global virtual store graph.

This lets changes propagate to every ancestor in both pnpm implementations.

Keep optional link materialization aligned with selected dependency groups, including warm slots.
Copilot AI review requested due to automatic review settings August 5, 2026 10:11

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.

@zkochan zkochan changed the title fix(pacquet): materialize link: deps inside virtual-store slots fix: materialize and hash link: dependencies in virtual-store slots Aug 5, 2026

@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

🧹 Nitpick comments (3)
pnpm/crates/deps-restorer/src/create_symlink_layout.rs (1)

61-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Normalize the link target here as the hasher does.

lockfile_to_dep_graph hashes pacquet_fs::lexical_normalize(&lockfile_dir.join(link_target)). This call site symlinks the unnormalized join. Both resolve to the same directory, so behavior is unchanged, but the slot identity and the materialized target are then derived from two different textual forms of one path. Use the same helper so a future change to the resolution rule stays applied in both places.

♻️ Proposed change
-            return symlink_package(&lockfile_dir.join(link_target), &symlink_path).map(drop);
+            let target = pacquet_fs::lexical_normalize(&lockfile_dir.join(link_target));
+            return symlink_package(&target, &symlink_path).map(drop);
🤖 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/deps-restorer/src/create_symlink_layout.rs` at line 61, Update
the symlink target passed by the return path around symlink_package to wrap
lockfile_dir.join(link_target) with pacquet_fs::lexical_normalize, matching the
path normalization used by lockfile_to_dep_graph and keeping slot identity and
materialized targets consistent.
pnpm/crates/deps-restorer/src/virtual_store_layout.rs (1)

564-565: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Collect link targets inside the closure instead of re-scanning by string prefix.

build_children_with accepts FnMut, so the closure can record the node when it creates it. This removes the second pass and the implicit assumption that no resolved snapshot key starts with link:.

♻️ Proposed refactor
     for (snapshot_key, snapshot) in snapshots {
         let children = crate::deps_graph::build_children_with(snapshot, |alias, dep_ref| {
             if let Some(snapshot_key) = dep_ref.resolve(alias) {
                 return Some(snapshot_key.to_string());
             }
             let link_target = dep_ref.as_link_target()?;
             let lockfile_dir = lockfile_dir?;
             let resolved = pacquet_fs::lexical_normalize(&lockfile_dir.join(link_target));
-            Some(format!("link:{}", resolved.to_string_lossy()))
+            let node = format!("link:{}", resolved.to_string_lossy());
+            link_target_nodes.insert(node.clone());
+            Some(node)
         });
-        link_target_nodes
-            .extend(children.values().filter(|child_key| child_key.starts_with("link:")).cloned());
🤖 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/deps-restorer/src/virtual_store_layout.rs` around lines 564 -
565, Update build_children_with to collect each link target directly inside its
FnMut closure when the node is created, appending it to link_target_nodes at
that point. Remove the later children.values() scan and starts_with("link:")
filtering, while preserving collection of all and only the resolved link nodes.
pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs (1)

66-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document a non-obvious contract or remove these comments.

Both comments restate their Boolean field.

  • pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs#L66-L68: remove the comment, or document the slot-layout invariant that requires this flag.
  • pnpm/crates/deps-restorer/src/create_virtual_store.rs#L152-L154: remove the comment, or document the install-mode contract that determines this flag.

As per coding guidelines, comments must not merely restate code.

🤖 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/deps-restorer/src/create_virtual_dir_by_snapshot.rs` around lines
66 - 68, Remove the Boolean-restating comments for include_optional_dependencies
in create_virtual_dir_by_snapshot.rs (lines 66-68) and create_virtual_store.rs
(lines 152-154), or replace them with comments documenting the respective
slot-layout invariant and install-mode contract that determine the flag.

Source: Coding guidelines

🤖 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/package-manager/src/install_with_fresh_lockfile.rs`:
- Line 1380: Update the include_optional_dependencies assignment in the install
configuration so partial installs always pass true, regardless of whether
dependency_groups contains DependencyGroup::Optional; only a full install that
explicitly omits optional dependencies should pass false. Add a regression test
covering a partial install without the optional group and verify existing
optional child links are preserved.

---

Nitpick comments:
In `@pnpm/crates/deps-restorer/src/create_symlink_layout.rs`:
- Line 61: Update the symlink target passed by the return path around
symlink_package to wrap lockfile_dir.join(link_target) with
pacquet_fs::lexical_normalize, matching the path normalization used by
lockfile_to_dep_graph and keeping slot identity and materialized targets
consistent.

In `@pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs`:
- Around line 66-68: Remove the Boolean-restating comments for
include_optional_dependencies in create_virtual_dir_by_snapshot.rs (lines 66-68)
and create_virtual_store.rs (lines 152-154), or replace them with comments
documenting the respective slot-layout invariant and install-mode contract that
determine the flag.

In `@pnpm/crates/deps-restorer/src/virtual_store_layout.rs`:
- Around line 564-565: Update build_children_with to collect each link target
directly inside its FnMut closure when the node is created, appending it to
link_target_nodes at that point. Remove the later children.values() scan and
starts_with("link:") filtering, while preserving collection of all and only the
resolved link nodes.
🪄 Autofix

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: 5ca71276-ef80-4475-8607-bf0ac36c00cf

📥 Commits

Reviewing files that changed from the base of the PR and between 1f1cc31 and a5a3f38.

📒 Files selected for processing (19)
  • .changeset/gvs-link-deps-in-slots.md
  • pnpm/crates/cli/tests/global_virtual_store.rs
  • pnpm/crates/deps-restorer/src/create_symlink_layout.rs
  • pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs
  • pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs
  • pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot/tests.rs
  • pnpm/crates/deps-restorer/src/create_virtual_store.rs
  • pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs
  • pnpm/crates/deps-restorer/src/create_virtual_store/tests.rs
  • pnpm/crates/deps-restorer/src/deps_graph.rs
  • pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs
  • pnpm/crates/deps-restorer/src/install_package_by_snapshot.rs
  • pnpm/crates/deps-restorer/src/install_package_by_snapshot/tests.rs
  • pnpm/crates/deps-restorer/src/virtual_store_layout.rs
  • pnpm/crates/deps-restorer/src/virtual_store_layout/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/deps/graph-builder/src/iteratePkgsForVirtualStore.ts
  • pnpm11/deps/graph-hasher/src/index.ts
  • pnpm11/deps/graph-hasher/test/lockfileToDepGraph.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/gvs-link-deps-in-slots.md

@qodo-code-review

Copy link
Copy Markdown

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants