Skip to content

fix(package-manager): stop nesting hoisted deps that won the root slot - #13306

Merged
zkochan merged 4 commits into
mainfrom
fix-hoisted-root-slot-duplication
Jul 25, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix-hoisted-root-slot-duplication

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

With nodeLinker: hoisted, pacquet gave every workspace project a link to each of its direct dependencies — including the ones already materialized in the workspace-root node_modules. Node resolution walks up from the project, so that entry is redundant, and it is a second copy for the build pass to run lifecycle scripts in.

pnpm nests a copy only for the versions that lost the root slot. Upstream's per-importer map is derived from the hoisting hierarchy, so a dependency the hoister moved to the root is simply absent from the importer's entry (lockfileToHoistedDepGraph.ts → directDepsMap(Object.keys(nextHierarchy), graph)); pacquet derives the same map from the importer's lockfile declarations, which keeps the winner in it, so the link pass has to recognize and skip it.

The workspace root is exempt — it owns the hoisted slot, and its entries are the real directories rather than links to them.

Behavior

Upstream's fixture for this is run pre/postinstall scripts in a workspace that uses node-linker=hoisted (installing/deps-installer/test/install/lifecycleScripts.ts:718): four projects, two on @1 and two on @2, asserting that the projects on the root-slot version have no nested copy while the other two do.

location before after (= pnpm)
root node_modules/<pkg> (v1, root-slot winner) real dir, built unchanged
project-1, project-2 (@1 — won the slot) extra link to the root copy no entry
project-3, project-4 (@2 — lost the slot) nested real dir, built unchanged

Tests

This closes the known failure registered for exactly this divergence: known_failures::hoisted_workspace_layout_does_not_duplicate_root_version in hoisted_node_linker.rs, whose stub reason was

Pacquet's hoisted linker materializes each workspace project's direct dependency under the project's own node_modules even when the same version already won the workspace-root slot. Upstream nests a copy only for versions that lost the root slot.

The stub is gone and the assertion is now real, inside run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker — the sibling test that was already carrying the fixture and had a comment explaining why it could not assert this yet. That leaves hoisted_node_linker.rs with no known_failures module at all.

One other test asserted the old shape: install_filters.rs::filtered_hoisted_install_materializes_full_shared_graph_but_links_only_selected_projects expected the selected project to nest a dependency that the same test also asserts is hoisted to the root. It now asserts the absence, for the same reason.

Full suite green (7003 tests), clippy and dylint clean.

Note on the tracker

Picked up from #13167, whose description is well out of date — it lists 34 unchecked plan items and 39 allow_known_failure! sites; the real numbers on main were 9 (7 of them deliberate "do not port" entries) and 2. Details in this comment. After this PR one stub remains, importer_level_link_closure_divergence, which is blocked on a cross-stack decision rather than on code.

Refs #13167

Squash Commit Body

With nodeLinker=hoisted, every workspace project got a link to each of its
direct dependencies, including the ones already materialized in the
workspace-root node_modules. Node resolution walks up from the project, so
that second entry is redundant — and it is a second copy for the build
pass to run lifecycle scripts in.

pnpm nests a copy only for the versions that lost the root slot. Upstream's
map comes from the hoisting hierarchy, so a dependency the hoister moved to
the root is simply absent from the importer's entry; pacquet derives it from
the importer's lockfile declarations, which keeps the winner in the map, so
the link pass has to recognize and skip it.

The workspace root itself is exempt: it owns the hoisted slot, and its
entries are the real directories rather than links to them.

Two tests asserted the old shape and now pin the upstream rule, and the
known-failure stub registered for this divergence
(hoisted_workspace_duplicate_materialization) becomes a real assertion in
run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker.

Refs pnpm/pnpm#13167

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 (Claude Code, claude-opus-5).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Improved hoisted workspace installation to deduplicate already-shared dependencies at the workspace root, matching pnpm CLI behavior.
    • Prevents lifecycle scripts from being triggered against duplicate dependency copies.
  • Bug Fixes
    • Fixed hoisted direct dependency linking for filtered installs so selected projects don’t create redundant nested copies and resolve via the workspace-root location.
    • Automatically cleans up stale project-level links when the “winning” workspace-root version changes.

With nodeLinker=hoisted, every workspace project got a link to each of its
direct dependencies, including the ones already materialized in the
workspace-root node_modules. Node resolution walks up from the project, so
that second entry is redundant — and it is a second copy for the build
pass to run lifecycle scripts in.

pnpm nests a copy only for the versions that lost the root slot. Upstream's
map comes from the hoisting hierarchy, so a dependency the hoister moved to
the root is simply absent from the importer's entry; pacquet derives it from
the importer's lockfile declarations, which keeps the winner in the map, so
the link pass has to recognize and skip it.

The workspace root itself is exempt: it owns the hoisted slot, and its
entries are the real directories rather than links to them.

Two tests asserted the old shape and now pin the upstream rule, and the
known-failure stub registered for this divergence
(hoisted_workspace_duplicate_materialization) becomes a real assertion in
run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker.

Refs #13167

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

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 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 745f4d12-eb22-4a4c-a350-b036eb92cdeb

📥 Commits

Reviewing files that changed from the base of the PR and between afb3220 and cb1886e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (5)
  • pnpm/crates/cli/tests/hoisted_node_linker.rs
  • pnpm/crates/fs/src/symlink_dir.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs
  • pnpm/crates/testing-utils/Cargo.toml
  • pnpm/crates/testing-utils/src/fs.rs

📝 Walkthrough

Walkthrough

Hoisted direct dependency linking now avoids duplicating workspace-root dependency versions in non-root projects. Shared symlink detection is centralized, and tests validate nested materialization for losing versions, root-slot resolution, stale-link removal, and removal of obsolete known-failure gating.

Changes

Hoisted root-slot deduplication

Layer / File(s) Summary
Shared symlink detection
pnpm/crates/fs/src/symlink_dir.rs, pnpm/crates/testing-utils/...
A shared cross-platform helper detects symlinks and Windows junctions, and testing utilities delegate to it.
Root-slot link filtering
pnpm/crates/package-manager/src/install_frozen_lockfile.rs, .changeset/...
Non-root projects skip links for aliases already occupying the workspace-root slot, remove stale links, and document the patch release.
Hoisted layout validation
pnpm/crates/cli/tests/hoisted_node_linker.rs, pnpm/crates/cli/tests/install_filters.rs
Tests assert nested copies only for root-slot losers, verify root-slot resolution, and cover stale-copy cleanup after reinstall.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

  • pnpm/pacquet#438 — Covers workspace hoisted-linker deduplication, root-slot reuse, and stale nested-copy cleanup.

Possibly related PRs

  • pnpm/pnpm#13152 — Adds earlier hoisted workspace linker assertions and known-failure coverage.
  • pnpm/pnpm#13176 — Overlaps with hoisted lifecycle and frozen-lockfile test coverage.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ 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 fix-hoisted-root-slot-duplication

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 hoisted linker: don't nest root-slot winners in workspace projects

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Skip per-project links for hoisted dependencies that already occupy the root slot.
• Preserve nesting only for versions that lost the root slot (pnpm-compatible layout).
• Convert the prior known-failure into real assertions and update affected tests.
Diagram

graph TD
  A["install_frozen_lockfile.rs"] --> B["link_selected_hoisted_direct_dependencies"] --> C{{"Workspace root?"}}
  C -- "yes" --> E["Link direct deps"] --> H[("Project node_modules")]
  C -- "no" --> D{{"Root-slot winner?"}}
  D -- "yes" --> F["Skip per-project entry"] --> H
  D -- "no" --> E --> H
  B --> G[("Root node_modules")]

  subgraph Legend
    direction LR
    _proc["Process"] ~~~ _dec{{"Decision"}} ~~~ _dir[("Directory")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Derive per-importer directDepsMap from hoisting hierarchy
  • ➕ Matches pnpm/upstream behavior earlier (winner absent from importer map)
  • ➕ Keeps linking phase simpler (no special-case skip)
  • ➖ Requires refactoring how pacquet builds/represents importer direct deps
  • ➖ Risk of subtle behavior changes for non-hoisted/linker modes if shared codepaths exist
2. Pre-filter direct deps per importer before link loop
  • ➕ Still localized, but separates concerns (compute vs apply)
  • ➕ Reduces repeated path-normalization checks inside the inner loop
  • ➖ Needs extra data passed around (root-slot winners set)
  • ➖ More moving parts than the current minimal skip condition
3. Keep duplicate entry but skip lifecycle/build execution for it
  • ➕ Avoids filesystem layout changes
  • ➕ Potentially less risk to resolution edge cases
  • ➖ Diverges from pnpm layout expectations
  • ➖ Harder to guarantee no other codepath observes/uses the duplicate entry

Recommendation: Current approach (skip creating a per-project entry when it points at the root-slot directory, with an explicit workspace-root exemption) is the best tradeoff: it’s a minimal, targeted fix that aligns pacquet’s hoisted layout with pnpm while avoiding broader changes to dependency graph derivation.

Files changed (4) +36 / -49

Bug fix (1) +15 / -0
install_frozen_lockfile.rsSkip linking direct deps that already resolve to root hoisted slot +15/-0

Skip linking direct deps that already resolve to root hoisted slot

• Detects when a project's direct dependency target is the same path as the workspace-root node_modules/<alias> and skips creating a redundant per-project entry. Exempts the workspace root itself since its entries are real directories rather than links.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs

Tests (2) +16 / -49
hoisted_node_linker.rsTurn hoisted root-slot duplication known-failure into real assertions +12/-48

Turn hoisted root-slot duplication known-failure into real assertions

• Updates the workspace lifecycle-scripts fixture to assert that only root-slot losers have nested copies built, and that root-slot winners have no per-project node_modules entry. Removes the entire known_failures module now that the divergence is fixed.

pnpm/crates/cli/tests/hoisted_node_linker.rs

install_filters.rsUpdate filtered hoisted install test to expect no nested root-slot winner +4/-1

Update filtered hoisted install test to expect no nested root-slot winner

• Adjusts the test expectation so a selected project does not nest a dependency that is already hoisted to the workspace root. Adds commentary aligning the behavior with upstream/pnpm resolution-by-walking-up.

pnpm/crates/cli/tests/install_filters.rs

Documentation (1) +5 / -0
pacquet-hoisted-no-duplicate-root-version.mdAdd changeset documenting hoisted root-slot de-duplication +5/-0

Add changeset documenting hoisted root-slot de-duplication

• Adds a patch-level changeset explaining that workspace projects no longer get a redundant per-project entry for dependencies that already won the workspace-root hoisted slot. Documents the behavior change and rationale (avoid duplicate lifecycle script runs).

.changeset/pacquet-hoisted-no-duplicate-root-version.md

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.8±0.04ms    31.7 MB/sec    1.00     11.9±0.02ms    31.6 MB/sec
packument/parse                1.00     38.5±0.16µs  1721.4 MB/sec    1.00     38.5±0.06µs  1723.3 MB/sec
tarball/download_dependency    1.04      2.3±0.11ms  1872.4 KB/sec    1.00      2.2±0.07ms  1952.7 KB/sec

@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 `@pnpm/crates/cli/tests/hoisted_node_linker.rs`:
- Around line 543-549: Update the loop over nested projects in the hoisted
linker test to assert each project resolves to version 2.0.0 before or alongside
checking its generated build artifacts. Use the existing package-resolution or
manifest assertion helpers and preserve the current requirement that every
nested copy is built.

In `@pnpm/crates/package-manager/src/install_frozen_lockfile.rs`:
- Around line 1838-1842: Validate the alias and construct link_path via
safe_join_modules_dir before the root-slot fast path condition. Update the
branch around the lexical_normalize comparison so malformed or absolute aliases
return InvalidAlias rather than reaching continue; reuse the validated link_path
for the comparison and preserve the existing workspace-root behavior.
🪄 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: 87176378-186f-45c2-9c11-593ec70e1c3d

📥 Commits

Reviewing files that changed from the base of the PR and between 8e00149 and afb3220.

📒 Files selected for processing (4)
  • .changeset/pacquet-hoisted-no-duplicate-root-version.md
  • pnpm/crates/cli/tests/hoisted_node_linker.rs
  • pnpm/crates/cli/tests/install_filters.rs
  • pnpm/crates/package-manager/src/install_frozen_lockfile.rs

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the current cleanup recognizes both symlinks and Windows junctions, removes stale project-local links, and preserves real nested directories for the existing pruner.

Reviews (3): Last reviewed commit: "style: taplo-format the testing-utils ma..." | Re-trigger Greptile

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Junctions bypass stale-link cleanup ✓ Resolved 🐞 Bug ≡ Correctness
Description
The new root-slot-winner skip removes stale entries only when link_path.is_symlink() is true; on
Windows, pacquet may create junctions (reparse points) that are not reported as symlinks, so the
redundant project-local entry can survive reinstalls and keep the duplicate lifecycle/build behavior
this PR is trying to eliminate.
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1861-1862]

+                if link_path.is_symlink() {
+                    pacquet_fs::remove_symlink_dir(&link_path).map_err(|error| {
Relevance

⭐⭐ Medium

Windows junction/symlink edge cases are taken seriously, but similar junction-hardening has also
been rejected as too much.

PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new cleanup path is gated on is_symlink(), but the repo’s filesystem abstraction documents
that Windows “directory links” may be junctions and must be removed via remove_dir, implying
callers must handle link-types beyond is_symlink(). The repo also already has Windows-specific
reparse-point handling elsewhere, reinforcing that is_symlink() alone is insufficient for
“link-like” entries on Windows.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1846-1877]
pnpm/crates/fs/src/symlink_dir.rs[78-93]
pnpm/crates/fs/src/symlink_dir.rs[95-123]
pnpm/crates/cli/src/cli_args/deploy.rs[711-720]

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

### Issue description
`link_selected_hoisted_direct_dependencies()` attempts to clean up stale project-local entries for dependencies that now win the workspace-root hoisted slot. The cleanup is guarded by `Path::is_symlink()`, which may not detect Windows junctions (even though the filesystem helpers explicitly support junctions). This can leave behind a stale project-local junction and defeats the dedupe behavior on Windows.

### Issue Context
- `pacquet_fs::remove_symlink_dir()` is explicitly designed to remove both true symlinks and junctions on Windows.
- The caller’s predicate should therefore detect “symlink OR junction”, not just `is_symlink()`.

### Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1855-1877]

### Suggested fix
- Replace `if link_path.is_symlink()` with a predicate that detects both symlinks and junctions, e.g.:
 - `if pacquet_fs::read_symlink_dir(&link_path).is_ok() { ... }`
- Keep the safety property: do **not** remove real directories here (those are for the pruner), only remove entries that are confirmed to be link-types created by the linker.
- Consider ignoring `NotFound` from the removal, since this is a best-effort cleanup path.

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



Remediation recommended

2. Redundant Windows fs probes 🐞 Bug ➹ Performance ⭐ New
Description
On Windows, pacquet_fs::is_symlink_or_junction() calls junction::exists() whenever
Path::is_symlink() is false, including for missing paths; this turns a boolean check into two
filesystem probes and forces callers to special-case NotFound. In the hoisted direct-dep cleanup
path this adds avoidable per-entry syscall overhead and extra error-handling complexity on Windows.
Code

pnpm/crates/fs/src/symlink_dir.rs[R84-101]

+pub fn is_symlink_or_junction(link: &Path) -> io::Result<bool> {
+    #[cfg(windows)]
+    {
+        // Check the symlink case first so a true symlink never reaches
+        // `junction::exists`.
+        if link.is_symlink() {
+            return Ok(true);
+        }
+        // `junction::exists` reports a path that is not a reparse point
+        // at all (a plain directory) as `ERROR_NOT_A_REPARSE_POINT`
+        // rather than `Ok(false)`; for this question that is a plain
+        // "no".
+        const ERROR_NOT_A_REPARSE_POINT: i32 = 4390;
+        return match junction::exists(link) {
+            Ok(is_junction) => Ok(is_junction),
+            Err(error) if error.raw_os_error() == Some(ERROR_NOT_A_REPARSE_POINT) => Ok(false),
+            Err(error) => Err(error),
+        };
Relevance

⭐⭐ Medium

Team sometimes accepts perf wins, but has rejected similar micro-optimizations; Windows
syscall/NotFound semantics change is nontrivial.

PR-#13288
PR-#13297

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper unconditionally falls through to junction::exists(link) after link.is_symlink() is
false, which includes the non-existent-path case. The new hoisted-linker cleanup code then has to
special-case ErrorKind::NotFound from this helper and treat it as “nothing to clean up,”
indicating this error path is expected/normal in practice.

pnpm/crates/fs/src/symlink_dir.rs[78-105]
pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1861-1885]

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_fs::is_symlink_or_junction()` performs two filesystem queries on Windows for the common non-symlink case (including non-existent paths): first `Path::is_symlink()`, then `junction::exists()`. This shows up in the new hoisted direct-dependency stale-link cleanup branch, where missing `node_modules/<alias>` entries are expected to be common.

### Issue Context
- The helper currently cannot distinguish “not a symlink” from “path does not exist” after `Path::is_symlink()` returns false.
- Callers (e.g. hoisted direct-dep cleanup) now have to catch `ErrorKind::NotFound` and treat it as `false`.

### Fix Focus Areas
- pnpm/crates/fs/src/symlink_dir.rs[84-101]

### Suggested change
On Windows, implement the check using a single `symlink_metadata` call first:
- If `symlink_metadata` returns `NotFound`, return `Ok(false)`.
- If metadata indicates a symlink, return `Ok(true)`.
- Otherwise, only then call `junction::exists()` (and keep mapping `ERROR_NOT_A_REPARSE_POINT` to `Ok(false)`).

This reduces syscalls in the common missing-path case and makes the helper’s behavior closer to `Path::is_symlink()` semantics.

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


3. Historical predates this rule comment 📘 Rule violation ⚙ Maintainability
Description
A newly added comment explains behavior using historical phrasing (predates this rule), which
violates the requirement to describe current behavior rather than past implementations. This reduces
clarity and can become stale as the code evolves.
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1855-1860]

+                // An install that predates this rule, or one where the
+                // version had lost the slot, leaves a link here. Left in
+                // place it keeps shadowing the root copy, which is the
+                // duplicate this skip exists to avoid. A real directory is
+                // the pruner's to remove, and only ever belongs to a
+                // version that lost the slot.
Relevance

⭐⭐⭐ High

Team has accepted rewriting comments to describe current intent and avoid historical “before the
fix” phrasing.

PR-#13246

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist forbids comments that reference past behavior/implementations. The added comment
explicitly refers to installs that "predate this rule", which is historical phrasing rather than a
present-tense description of the current invariant and cleanup behavior.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1855-1860]

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

## Issue description
A comment in `link_selected_hoisted_direct_dependencies` uses historical phrasing (`predates this rule`) instead of describing the current behavior/state the code handles.

## Issue Context
Compliance requires comments to describe current behavior, not past implementations. Here, the intent can be expressed without referencing a prior state/version of the code.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1855-1860]

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


4. Dangling symlink undetected 🐞 Bug ☼ Reliability
Description
The new “must not nest its own copy” assertions use Path::exists(), which returns false for
dangling symlinks, so a broken leftover entry under node_modules/<dep> can slip through and the
tests still pass. This weakens regression coverage for hoisted-linker correctness around link
removal / repair behaviors.
Code

pnpm/crates/cli/tests/install_filters.rs[R757-761]

+    // The selected project's dependency won the workspace-root slot, so
+    // it resolves by walking up; nesting a second entry for it is what
+    // upstream avoids.
+    assert!(!selected.join("node_modules").join(HELLO).exists());
    assert!(!unselected.join("node_modules").exists());
Relevance

⭐⭐⭐ High

Team previously accepted replacing exists() with symlink_metadata() to catch dangling symlink
regressions in tests.

PR-#11904

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
install_filters.rs now uses !exists() to assert the selected project does not have a nested
dependency entry. The hoisted-node-linker workspace test uses the same !exists() pattern.
Elsewhere, the codebase explicitly uses metadata-following checks to treat dangling symlinks as
broken, and a past merged fix documents that exists() is insufficient for this style of assertion.

pnpm/crates/cli/tests/install_filters.rs[751-762]
pnpm/crates/cli/tests/hoisted_node_linker.rs[552-559]
pnpm/crates/package-manager/src/install.rs[2828-2837]
PR-#11904

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 tests assert that certain `node_modules/<dep>` entries are absent using `Path::exists()`. `exists()` follows symlinks and returns `false` for dangling symlinks, so these assertions can pass even when a directory entry still exists but is broken.

### Issue Context
This repository has already hit this exact pitfall in tests: using `symlink_metadata()` is the reliable way to assert “no entry exists” (including broken symlinks/junctions).

### Fix Focus Areas
- pnpm/crates/cli/tests/install_filters.rs[757-761]
- pnpm/crates/cli/tests/hoisted_node_linker.rs[552-558]

### Suggested change
Replace `!path.exists()` with an lstat-style absence check, e.g.:
- `assert!(std::fs::symlink_metadata(&path).is_err(), "...");`

(Apply the same pattern in both tests where the new assertions were added.)

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


View more (1)
5. Alias validation bypassed ✓ Resolved 🐞 Bug ⛨ Security
Description
link_selected_hoisted_direct_dependencies can continue on the new root-slot-winner skip before
validating alias via safe_join_modules_dir, which means a malformed alias could bypass the
intended invalid-alias error path and be silently skipped. This is primarily a
robustness/correctness gap (security impact depends on whether untrusted lockfiles can reach this
codepath).
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1838-1846]

+            if !is_workspace_root
+                && pacquet_fs::lexical_normalize(target)
+                    == pacquet_fs::lexical_normalize(&root_modules_dir.join(alias))
+            {
+                continue;
+            }
            let link_path =
                crate::safe_join_modules_dir::safe_join_modules_dir(&modules_dir, alias).map_err(
                    |source| {
Relevance

⭐⭐⭐ High

Repo emphasizes safe_join_modules_dir as the alias-validation boundary; bypassing it is likely to
be fixed (reorder/validate first).

PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The dep-graph builder populates per-importer direct deps by iterating lockfile importer dependency
keys (for (alias, spec) in dep_map). safe_join_modules_dir is the project’s boundary for
validating aliases before using them as node_modules paths. In the modified linker code, the new
skip condition runs before safe_join_modules_dir, so that boundary can be bypassed for skipped
entries.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1819-1856]
pnpm/crates/package-manager/src/hoisted_dep_graph.rs[417-450]
pnpm/crates/package-manager/src/safe_join_modules_dir.rs[1-40]
pnpm/crates/package-manager/src/install.rs[2790-2801]

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 root-slot-winner skip checks `root_modules_dir.join(alias)` and may `continue` before `safe_join_modules_dir(&modules_dir, alias)` runs. That changes the control flow so alias validation is no longer guaranteed to run for all direct-dependency aliases.

### Issue Context
`safe_join_modules_dir` exists specifically to enforce npm-name validity before joining an alias into a `node_modules` path. Separately, the hoisted dep-graph’s per-importer direct-deps map is built from lockfile importer dependency-map keys (alias strings).

### Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1819-1856]

### Suggested change
Reorder the loop so alias validation happens before the skip, e.g.:
1. Compute `link_path = safe_join_modules_dir(&modules_dir, alias)` at the top of the `(alias, target)` loop (preserving existing error mapping).
2. Then apply the root-slot-winner skip condition.

This preserves the invalid-alias boundary while keeping the new “skip nesting root-slot winner” behavior.

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



Informational

6. Misleading cleanup error message 🐞 Bug ◔ Observability
Description
When stale-link removal fails, the error is wrapped as SymlinkPackageError::SymlinkDir, whose
diagnostic message says “Failed to create symlink…”, even though the operation is deleting an
existing link. This makes failures in the new cleanup path confusing to debug.
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1867-1871]

+                                source: SymlinkPackageError::SymlinkDir {
+                                    symlink_target: target.clone(),
+                                    symlink_path: link_path.clone(),
+                                    error,
+                                },
Relevance

⭐⭐⭐ High

They frequently accept fixes to make error/help text accurately describe the operation for better
diagnostics.

PR-#13075

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call site is performing a delete (remove_symlink_dir) but wraps failures in an error variant
whose Display explicitly describes creating a symlink, so any failure in the new cleanup will
misreport what operation actually failed.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1861-1875]
pnpm/crates/package-manager/src/symlink_package.rs[10-27]

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 stale-link cleanup path calls `pacquet_fs::remove_symlink_dir()`, but maps errors into `SymlinkPackageError::SymlinkDir` (a *creation* failure). This produces misleading diagnostics.

### Issue Context
`SymlinkPackageError::SymlinkDir` formats as “Failed to create symlink…”, which does not match the removal operation.

### Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1862-1874]
- pnpm/crates/package-manager/src/symlink_package.rs[10-27]

### Suggested fix
- Introduce a deletion-specific error variant (either in `SymlinkPackageError` or in `SymlinkDirectDependenciesError`) such as `RemoveSymlinkDir { symlink_path, error }`, with an appropriate display string.
- Use that new variant for the `remove_symlink_dir()` failure mapping in this cleanup path.

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


Grey Divider

Previous review results

Review updated until commit cb1886e

Results up to commit afb3220 ⚖️ Balanced


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


Remediation recommended
1. Dangling symlink undetected 🐞 Bug ☼ Reliability
Description
The new “must not nest its own copy” assertions use Path::exists(), which returns false for
dangling symlinks, so a broken leftover entry under node_modules/<dep> can slip through and the
tests still pass. This weakens regression coverage for hoisted-linker correctness around link
removal / repair behaviors.
Code

pnpm/crates/cli/tests/install_filters.rs[R757-761]

+    // The selected project's dependency won the workspace-root slot, so
+    // it resolves by walking up; nesting a second entry for it is what
+    // upstream avoids.
+    assert!(!selected.join("node_modules").join(HELLO).exists());
    assert!(!unselected.join("node_modules").exists());
Relevance

⭐⭐⭐ High

Team previously accepted replacing exists() with symlink_metadata() to catch dangling symlink
regressions in tests.

PR-#11904

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
install_filters.rs now uses !exists() to assert the selected project does not have a nested
dependency entry. The hoisted-node-linker workspace test uses the same !exists() pattern.
Elsewhere, the codebase explicitly uses metadata-following checks to treat dangling symlinks as
broken, and a past merged fix documents that exists() is insufficient for this style of assertion.

pnpm/crates/cli/tests/install_filters.rs[751-762]
pnpm/crates/cli/tests/hoisted_node_linker.rs[552-559]
pnpm/crates/package-manager/src/install.rs[2828-2837]
PR-#11904

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 tests assert that certain `node_modules/<dep>` entries are absent using `Path::exists()`. `exists()` follows symlinks and returns `false` for dangling symlinks, so these assertions can pass even when a directory entry still exists but is broken.

### Issue Context
This repository has already hit this exact pitfall in tests: using `symlink_metadata()` is the reliable way to assert “no entry exists” (including broken symlinks/junctions).

### Fix Focus Areas
- pnpm/crates/cli/tests/install_filters.rs[757-761]
- pnpm/crates/cli/tests/hoisted_node_linker.rs[552-558]

### Suggested change
Replace `!path.exists()` with an lstat-style absence check, e.g.:
- `assert!(std::fs::symlink_metadata(&path).is_err(), "...");`

(Apply the same pattern in both tests where the new assertions were added.)

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


2. Alias validation bypassed ✓ Resolved 🐞 Bug ⛨ Security
Description
link_selected_hoisted_direct_dependencies can continue on the new root-slot-winner skip before
validating alias via safe_join_modules_dir, which means a malformed alias could bypass the
intended invalid-alias error path and be silently skipped. This is primarily a
robustness/correctness gap (security impact depends on whether untrusted lockfiles can reach this
codepath).
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1838-1846]

+            if !is_workspace_root
+                && pacquet_fs::lexical_normalize(target)
+                    == pacquet_fs::lexical_normalize(&root_modules_dir.join(alias))
+            {
+                continue;
+            }
            let link_path =
                crate::safe_join_modules_dir::safe_join_modules_dir(&modules_dir, alias).map_err(
                    |source| {
Relevance

⭐⭐⭐ High

Repo emphasizes safe_join_modules_dir as the alias-validation boundary; bypassing it is likely to
be fixed (reorder/validate first).

PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The dep-graph builder populates per-importer direct deps by iterating lockfile importer dependency
keys (for (alias, spec) in dep_map). safe_join_modules_dir is the project’s boundary for
validating aliases before using them as node_modules paths. In the modified linker code, the new
skip condition runs before safe_join_modules_dir, so that boundary can be bypassed for skipped
entries.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1819-1856]
pnpm/crates/package-manager/src/hoisted_dep_graph.rs[417-450]
pnpm/crates/package-manager/src/safe_join_modules_dir.rs[1-40]
pnpm/crates/package-manager/src/install.rs[2790-2801]

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 root-slot-winner skip checks `root_modules_dir.join(alias)` and may `continue` before `safe_join_modules_dir(&modules_dir, alias)` runs. That changes the control flow so alias validation is no longer guaranteed to run for all direct-dependency aliases.

### Issue Context
`safe_join_modules_dir` exists specifically to enforce npm-name validity before joining an alias into a `node_modules` path. Separately, the hoisted dep-graph’s per-importer direct-deps map is built from lockfile importer dependency-map keys (alias strings).

### Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1819-1856]

### Suggested change
Reorder the loop so alias validation happens before the skip, e.g.:
1. Compute `link_path = safe_join_modules_dir(&modules_dir, alias)` at the top of the `(alias, target)` loop (preserving existing error mapping).
2. Then apply the root-slot-winner skip condition.

This preserves the invalid-alias boundary while keeping the new “skip nesting root-slot winner” behavior.

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


Results up to commit d02654e ⚖️ Balanced


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


Action required
1. Junctions bypass stale-link cleanup ✓ Resolved 🐞 Bug ≡ Correctness
Description
The new root-slot-winner skip removes stale entries only when link_path.is_symlink() is true; on
Windows, pacquet may create junctions (reparse points) that are not reported as symlinks, so the
redundant project-local entry can survive reinstalls and keep the duplicate lifecycle/build behavior
this PR is trying to eliminate.
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1861-1862]

+                if link_path.is_symlink() {
+                    pacquet_fs::remove_symlink_dir(&link_path).map_err(|error| {
Relevance

⭐⭐ Medium

Windows junction/symlink edge cases are taken seriously, but similar junction-hardening has also
been rejected as too much.

PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new cleanup path is gated on is_symlink(), but the repo’s filesystem abstraction documents
that Windows “directory links” may be junctions and must be removed via remove_dir, implying
callers must handle link-types beyond is_symlink(). The repo also already has Windows-specific
reparse-point handling elsewhere, reinforcing that is_symlink() alone is insufficient for
“link-like” entries on Windows.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1846-1877]
pnpm/crates/fs/src/symlink_dir.rs[78-93]
pnpm/crates/fs/src/symlink_dir.rs[95-123]
pnpm/crates/cli/src/cli_args/deploy.rs[711-720]

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

### Issue description
`link_selected_hoisted_direct_dependencies()` attempts to clean up stale project-local entries for dependencies that now win the workspace-root hoisted slot. The cleanup is guarded by `Path::is_symlink()`, which may not detect Windows junctions (even though the filesystem helpers explicitly support junctions). This can leave behind a stale project-local junction and defeats the dedupe behavior on Windows.

### Issue Context
- `pacquet_fs::remove_symlink_dir()` is explicitly designed to remove both true symlinks and junctions on Windows.
- The caller’s predicate should therefore detect “symlink OR junction”, not just `is_symlink()`.

### Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1855-1877]

### Suggested fix
- Replace `if link_path.is_symlink()` with a predicate that detects both symlinks and junctions, e.g.:
 - `if pacquet_fs::read_symlink_dir(&link_path).is_ok() { ... }`
- Keep the safety property: do **not** remove real directories here (those are for the pruner), only remove entries that are confirmed to be link-types created by the linker.
- Consider ignoring `NotFound` from the removal, since this is a best-effort cleanup path.

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



Remediation recommended
2. Historical predates this rule comment 📘 Rule violation ⚙ Maintainability
Description
A newly added comment explains behavior using historical phrasing (predates this rule), which
violates the requirement to describe current behavior rather than past implementations. This reduces
clarity and can become stale as the code evolves.
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1855-1860]

+                // An install that predates this rule, or one where the
+                // version had lost the slot, leaves a link here. Left in
+                // place it keeps shadowing the root copy, which is the
+                // duplicate this skip exists to avoid. A real directory is
+                // the pruner's to remove, and only ever belongs to a
+                // version that lost the slot.
Relevance

⭐⭐⭐ High

Team has accepted rewriting comments to describe current intent and avoid historical “before the
fix” phrasing.

PR-#13246

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist forbids comments that reference past behavior/implementations. The added comment
explicitly refers to installs that "predate this rule", which is historical phrasing rather than a
present-tense description of the current invariant and cleanup behavior.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1855-1860]

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

## Issue description
A comment in `link_selected_hoisted_direct_dependencies` uses historical phrasing (`predates this rule`) instead of describing the current behavior/state the code handles.

## Issue Context
Compliance requires comments to describe current behavior, not past implementations. Here, the intent can be expressed without referencing a prior state/version of the code.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1855-1860]

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



Informational
3. Misleading cleanup error message 🐞 Bug ◔ Observability
Description
When stale-link removal fails, the error is wrapped as SymlinkPackageError::SymlinkDir, whose
diagnostic message says “Failed to create symlink…”, even though the operation is deleting an
existing link. This makes failures in the new cleanup path confusing to debug.
Code

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[R1867-1871]

+                                source: SymlinkPackageError::SymlinkDir {
+                                    symlink_target: target.clone(),
+                                    symlink_path: link_path.clone(),
+                                    error,
+                                },
Relevance

⭐⭐⭐ High

They frequently accept fixes to make error/help text accurately describe the operation for better
diagnostics.

PR-#13075

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call site is performing a delete (remove_symlink_dir) but wraps failures in an error variant
whose Display explicitly describes creating a symlink, so any failure in the new cleanup will
misreport what operation actually failed.

pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1861-1875]
pnpm/crates/package-manager/src/symlink_package.rs[10-27]

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 stale-link cleanup path calls `pacquet_fs::remove_symlink_dir()`, but maps errors into `SymlinkPackageError::SymlinkDir` (a *creation* failure). This produces misleading diagnostics.

### Issue Context
`SymlinkPackageError::SymlinkDir` formats as “Failed to create symlink…”, which does not match the removal operation.

### Fix Focus Areas
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs[1862-1874]
- pnpm/crates/package-manager/src/symlink_package.rs[10-27]

### Suggested fix
- Introduce a deletion-specific error variant (either in `SymlinkPackageError` or in `SymlinkDirectDependenciesError`) such as `RemoveSymlinkDir { symlink_path, error }`, with an appropriate display string.
- Use that new variant for the `remove_symlink_dir()` failure mapping in this cleanup path.

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

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.47619% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.02%. Comparing base (9675da4) to head (cb1886e).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...tes/package-manager/src/install_frozen_lockfile.rs 34.21% 25 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #13306    +/-   ##
========================================
  Coverage   87.02%   87.02%            
========================================
  Files         531      532     +1     
  Lines       91442    91642   +200     
========================================
+ Hits        79574    79755   +181     
- Misses      11868    11887    +19     

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

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: d02654edb211

Each scenario reports direct installs and pnpr installs. 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.549 ± 0.149 2.356 2.743 1.75 ± 0.21
pacquet@main 2.597 ± 0.182 2.362 2.798 1.79 ± 0.23
pnpr@HEAD 1.515 ± 0.155 1.353 1.750 1.04 ± 0.15
pnpr@main 1.455 ± 0.154 1.341 1.778 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.54893384904,
      "stddev": 0.14944767204023177,
      "median": 2.56413595084,
      "user": 1.6724535,
      "system": 1.3136407599999997,
      "min": 2.3563048973400003,
      "max": 2.74283837934,
      "times": [
        2.3865960913400004,
        2.73192019434,
        2.6423963023400003,
        2.64892273934,
        2.63765348034,
        2.49061842134,
        2.3563048973400003,
        2.74283837934,
        2.48199185134,
        2.37009613334
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.59745927704,
      "stddev": 0.18222093504616887,
      "median": 2.6647377058400004,
      "user": 1.6602891,
      "system": 1.30191166,
      "min": 2.36159338134,
      "max": 2.7984743243400003,
      "times": [
        2.3676575053400004,
        2.75544362634,
        2.7384888323400003,
        2.77625866234,
        2.4591782973400003,
        2.6409058243400003,
        2.3880227293400003,
        2.36159338134,
        2.68856958734,
        2.7984743243400003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.51503685004,
      "stddev": 0.15503567208498403,
      "median": 1.48613078634,
      "user": 1.1887124,
      "system": 1.15514896,
      "min": 1.3525032423399999,
      "max": 1.74950385334,
      "times": [
        1.6947030733400001,
        1.40017162434,
        1.52960186634,
        1.5021088873400001,
        1.35798206334,
        1.47015268534,
        1.74950385334,
        1.3525032423399999,
        1.72057061734,
        1.37307058734
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.45463108694,
      "stddev": 0.15438022695569706,
      "median": 1.4071474848399999,
      "user": 1.1844687999999999,
      "system": 1.14605526,
      "min": 1.34117073534,
      "max": 1.77814361934,
      "times": [
        1.42727150234,
        1.69384358634,
        1.44279620134,
        1.34117073534,
        1.35327600134,
        1.42963824234,
        1.38702346734,
        1.35065970534,
        1.77814361934,
        1.34248780834
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 252.0 ± 8.2 240.3 264.3 1.03 ± 0.04
pacquet@main 245.0 ± 7.0 234.4 254.3 1.00
pnpr@HEAD 266.2 ± 8.0 254.6 277.7 1.09 ± 0.04
pnpr@main 270.3 ± 7.4 263.6 286.1 1.10 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2520189105,
      "stddev": 0.008164913930436318,
      "median": 0.252074615,
      "user": 0.19484428000000004,
      "system": 0.52341648,
      "min": 0.240303168,
      "max": 0.264312895,
      "times": [
        0.264312895,
        0.243519954,
        0.252649287,
        0.240303168,
        0.258985032,
        0.244798974,
        0.261954294,
        0.255417169,
        0.246748389,
        0.251499943
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.24498405029999998,
      "stddev": 0.006983357582208611,
      "median": 0.24602258300000002,
      "user": 0.18721378,
      "system": 0.51134878,
      "min": 0.234372501,
      "max": 0.25429303600000003,
      "times": [
        0.251656655,
        0.234372501,
        0.237350698,
        0.246293189,
        0.250244653,
        0.249130363,
        0.245751977,
        0.25429303600000003,
        0.24523025,
        0.235517181
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26621399879999996,
      "stddev": 0.007963278453245628,
      "median": 0.266954912,
      "user": 0.21514987999999996,
      "system": 0.49643708000000003,
      "min": 0.254632641,
      "max": 0.27767423,
      "times": [
        0.254632641,
        0.267507958,
        0.27767423,
        0.263242502,
        0.261921934,
        0.269003957,
        0.269339113,
        0.277582162,
        0.266401866,
        0.254833625
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.2702926885,
      "stddev": 0.007406219013765955,
      "median": 0.268013958,
      "user": 0.19453828,
      "system": 0.53276868,
      "min": 0.26358251,
      "max": 0.28605900700000003,
      "times": [
        0.270010719,
        0.270656583,
        0.26358251,
        0.267769884,
        0.263649833,
        0.266769985,
        0.280740762,
        0.268258032,
        0.26542957,
        0.28605900700000003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.754 ± 0.007 2.740 2.765 1.71 ± 0.16
pacquet@main 2.745 ± 0.008 2.733 2.755 1.71 ± 0.16
pnpr@HEAD 1.707 ± 0.124 1.520 1.825 1.06 ± 0.13
pnpr@main 1.606 ± 0.149 1.445 1.884 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7541932812800005,
      "stddev": 0.007366001975724782,
      "median": 2.75529446128,
      "user": 1.8565308999999999,
      "system": 1.33992914,
      "min": 2.7403200672800003,
      "max": 2.7650797272800003,
      "times": [
        2.75765690928,
        2.7545895772800004,
        2.7559993452800002,
        2.75633359528,
        2.74389148428,
        2.7650797272800003,
        2.75256166028,
        2.75434055828,
        2.7611598882800004,
        2.7403200672800003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.74479608048,
      "stddev": 0.008088338527941843,
      "median": 2.74581520828,
      "user": 1.8354217,
      "system": 1.2983878399999997,
      "min": 2.7330958952800004,
      "max": 2.75508070528,
      "times": [
        2.75365603328,
        2.7446687932800002,
        2.7330958952800004,
        2.7466755052800003,
        2.75508070528,
        2.74667503028,
        2.73466817128,
        2.73537322928,
        2.7531120552800004,
        2.74495538628
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.7073701408799997,
      "stddev": 0.12351185098685981,
      "median": 1.77216211528,
      "user": 1.1821888,
      "system": 1.1597037399999999,
      "min": 1.51961446328,
      "max": 1.82454369128,
      "times": [
        1.80207177428,
        1.51961446328,
        1.82454369128,
        1.67918458928,
        1.76946568128,
        1.77485854928,
        1.5211657002799999,
        1.8010772712799998,
        1.80519071228,
        1.5765289762799999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6059466053800002,
      "stddev": 0.14942431265005332,
      "median": 1.5518943322799998,
      "user": 1.1912979,
      "system": 1.1332004399999998,
      "min": 1.44468965028,
      "max": 1.88444848428,
      "times": [
        1.88444848428,
        1.50015324928,
        1.44468965028,
        1.68252180728,
        1.67415385528,
        1.50685159328,
        1.59109894228,
        1.46463993228,
        1.79821881728,
        1.51268972228
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 588.7 ± 14.7 562.3 613.2 2.00 ± 0.07
pacquet@main 569.9 ± 9.9 558.3 586.7 1.93 ± 0.06
pnpr@HEAD 294.6 ± 7.4 283.3 305.1 1.00
pnpr@main 299.5 ± 8.8 289.2 314.3 1.02 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.58867044294,
      "stddev": 0.014702609371322091,
      "median": 0.59089019814,
      "user": 0.7221323199999998,
      "system": 0.6685702400000001,
      "min": 0.56230232914,
      "max": 0.61321881214,
      "times": [
        0.5734518561399999,
        0.58399855914,
        0.59515824814,
        0.60090790614,
        0.58937669214,
        0.61321881214,
        0.57827807614,
        0.59240370414,
        0.56230232914,
        0.59760824614
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.56989804094,
      "stddev": 0.009926307468278592,
      "median": 0.56788775064,
      "user": 0.6887779199999999,
      "system": 0.6676998399999999,
      "min": 0.5583338691399999,
      "max": 0.5866866831399999,
      "times": [
        0.5733104811399999,
        0.56408624014,
        0.56590435714,
        0.56987114414,
        0.55923704814,
        0.58172937614,
        0.5866866831399999,
        0.5787476311399999,
        0.5583338691399999,
        0.56107357914
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29464731454000004,
      "stddev": 0.007373423210208567,
      "median": 0.29342083564000004,
      "user": 0.18110621999999996,
      "system": 0.50182914,
      "min": 0.28332137614,
      "max": 0.30513655814,
      "times": [
        0.29785696014,
        0.28517744914000004,
        0.30013782914000003,
        0.29274466414000005,
        0.29221000814000003,
        0.28332137614,
        0.30460059214,
        0.29119070114,
        0.29409700714000003,
        0.30513655814
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29952672403999997,
      "stddev": 0.008751511036669187,
      "median": 0.29926834814000003,
      "user": 0.18180871999999998,
      "system": 0.52538014,
      "min": 0.28921529014,
      "max": 0.31433722814000004,
      "times": [
        0.31433722814000004,
        0.30286378914,
        0.28921529014,
        0.30173213814000005,
        0.29680455814,
        0.31213784114000004,
        0.29069651814,
        0.29140522214000003,
        0.29398729314000005,
        0.30208736214000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.908 ± 0.010 1.894 1.920 6.44 ± 0.15
pacquet@main 1.892 ± 0.016 1.875 1.920 6.39 ± 0.15
pnpr@HEAD 0.300 ± 0.009 0.285 0.316 1.01 ± 0.04
pnpr@main 0.296 ± 0.007 0.286 0.306 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9077918317599998,
      "stddev": 0.009946998542120618,
      "median": 1.9083953991600002,
      "user": 0.9447758399999998,
      "system": 0.7605408199999999,
      "min": 1.89413717516,
      "max": 1.9200241931600002,
      "times": [
        1.89413717516,
        1.9095676941600002,
        1.89683840916,
        1.89810444416,
        1.91982104016,
        1.9166732241600002,
        1.91529851116,
        1.9002305221600002,
        1.90722310416,
        1.9200241931600002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.89243709896,
      "stddev": 0.01552115349051835,
      "median": 1.89320727016,
      "user": 0.9363406399999998,
      "system": 0.73658442,
      "min": 1.87461925216,
      "max": 1.9198907901600002,
      "times": [
        1.90102128716,
        1.9198907901600002,
        1.88810013016,
        1.87461925216,
        1.87489450416,
        1.88325597316,
        1.89831441016,
        1.87649405216,
        1.8983510351600001,
        1.90942955516
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29972097676000004,
      "stddev": 0.008577964324366319,
      "median": 0.29779545766000004,
      "user": 0.18486483999999997,
      "system": 0.50178992,
      "min": 0.28514282316,
      "max": 0.31620397716000004,
      "times": [
        0.29600676416000005,
        0.29635217916,
        0.30168269416000004,
        0.29332221116,
        0.30862350916000003,
        0.29833713416,
        0.29725378116,
        0.28514282316,
        0.30428469416000004,
        0.31620397716000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29604121306,
      "stddev": 0.0066938466062139625,
      "median": 0.29635256316,
      "user": 0.18909854000000004,
      "system": 0.5107025199999999,
      "min": 0.28586689616,
      "max": 0.30625943616,
      "times": [
        0.29362675416,
        0.29423602016,
        0.30625943616,
        0.30259884116,
        0.29846910616,
        0.29374604616,
        0.28586689616,
        0.29853610516,
        0.30106355116,
        0.28600937416
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 358.8 ± 5.4 350.3 371.8 4.10 ± 0.12
pacquet@main 360.0 ± 5.9 353.5 373.7 4.11 ± 0.13
pnpr@HEAD 87.6 ± 2.3 84.2 92.4 1.00
pnpr@main 89.1 ± 3.8 85.3 105.1 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35883458714000005,
      "stddev": 0.005407291891711202,
      "median": 0.35812290404,
      "user": 0.34523057999999995,
      "system": 0.077464,
      "min": 0.35026917254000006,
      "max": 0.37182455054,
      "times": [
        0.35652606254,
        0.35713902654,
        0.35833047854000005,
        0.36082121754,
        0.35827822954000005,
        0.35796757854000005,
        0.36052641954000003,
        0.37182455054,
        0.35026917254000006,
        0.35666313554000006
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.35998714474,
      "stddev": 0.005932195720258952,
      "median": 0.35799642254,
      "user": 0.34567628,
      "system": 0.07041449999999999,
      "min": 0.35348812454000006,
      "max": 0.37368935554000005,
      "times": [
        0.36079507954000006,
        0.37368935554000005,
        0.35728193754000004,
        0.35603890354000006,
        0.35677206554,
        0.35348812454000006,
        0.36621756854000004,
        0.36038713954,
        0.35871090754,
        0.35649036554
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08761799154000004,
      "stddev": 0.0022599110767084463,
      "median": 0.08695890754,
      "user": 0.021880583225806455,
      "system": 0.009141519354838711,
      "min": 0.08418882354000001,
      "max": 0.09241881954,
      "times": [
        0.09127004854000001,
        0.08819068554000001,
        0.08654592954000001,
        0.08574594654,
        0.08695890754,
        0.08581143754000001,
        0.08720107054000001,
        0.08587820054,
        0.08762157454000001,
        0.09080935354000001,
        0.09146413854,
        0.08623553054000001,
        0.08677686854000001,
        0.08706517554000001,
        0.09054012054,
        0.08750316054000001,
        0.08669397754000001,
        0.09167338054,
        0.08765787554000001,
        0.08418882354000001,
        0.08719364254,
        0.08496148754,
        0.08806932954,
        0.08570007054,
        0.08535801454000001,
        0.08660106054000001,
        0.09155603654000001,
        0.08635694654,
        0.09241881954,
        0.08574653354,
        0.08636359054000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08912385996424244,
      "stddev": 0.0037642351182108117,
      "median": 0.08838837054000001,
      "user": 0.020238134545454547,
      "system": 0.011912354545454544,
      "min": 0.08528949654000001,
      "max": 0.10508863354,
      "times": [
        0.08565419554,
        0.09025909154,
        0.08784586054000001,
        0.08933382054000001,
        0.08993210754000001,
        0.08669367454,
        0.08546812254000001,
        0.08770105554,
        0.08535762054000001,
        0.09155469454000001,
        0.08669685454,
        0.09122691354000001,
        0.08649275254000001,
        0.08794015354000001,
        0.08554554054,
        0.08603422554000001,
        0.09210998854,
        0.08974074254,
        0.08639905154000001,
        0.10508863354,
        0.08909712254,
        0.08528949654000001,
        0.08657334154,
        0.08670925154,
        0.08723772454,
        0.08968092254000001,
        0.09005327754,
        0.09066704154,
        0.09352656654000001,
        0.09195280654000001,
        0.09235066254,
        0.08838837054000001,
        0.09248569454000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.594 ± 0.159 4.440 4.881 1.31 ± 0.05
pacquet@main 4.533 ± 0.124 4.418 4.817 1.30 ± 0.04
pnpr@HEAD 3.495 ± 0.045 3.445 3.570 1.00
pnpr@main 3.513 ± 0.102 3.448 3.765 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.594311962040001,
      "stddev": 0.15888070567492585,
      "median": 4.58754017834,
      "user": 1.8499221999999995,
      "system": 1.38008268,
      "min": 4.43953429834,
      "max": 4.88104201234,
      "times": [
        4.6649287073400005,
        4.61973706734,
        4.88104201234,
        4.6015455023400005,
        4.445364194340001,
        4.454707899340001,
        4.8190858293400005,
        4.443639255340001,
        4.57353485434,
        4.43953429834
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5333760424400005,
      "stddev": 0.12356023612121941,
      "median": 4.4969376293400005,
      "user": 1.8352484,
      "system": 1.41124328,
      "min": 4.41752295634,
      "max": 4.8170391963400006,
      "times": [
        4.41752295634,
        4.45035695434,
        4.6217135993400005,
        4.515174362340001,
        4.47870089634,
        4.8170391963400006,
        4.54410536334,
        4.61547768534,
        4.43839062534,
        4.43527878534
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.4952662891400004,
      "stddev": 0.04533260016592008,
      "median": 3.48962005134,
      "user": 1.2971318999999997,
      "system": 1.2121191800000002,
      "min": 3.44515409134,
      "max": 3.56973553034,
      "times": [
        3.49434467734,
        3.5231490973399997,
        3.44515409134,
        3.45281899434,
        3.49278948734,
        3.46556195034,
        3.56973553034,
        3.45486598734,
        3.48645061534,
        3.56779246034
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.51342820064,
      "stddev": 0.10227107090613913,
      "median": 3.48164943384,
      "user": 1.2837621000000001,
      "system": 1.22355048,
      "min": 3.44771025734,
      "max": 3.76542848734,
      "times": [
        3.44771025734,
        3.46743343634,
        3.44792604434,
        3.49663910434,
        3.44818788034,
        3.45071936934,
        3.49678404034,
        3.49586543134,
        3.61758795534,
        3.76542848734
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13306
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,740.32 ms
(-3.00%)Baseline: 2,825.03 ms
3,390.03 ms
(80.83%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,894.14 ms
(-5.27%)Baseline: 1,999.49 ms
2,399.38 ms
(78.94%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
562.30 ms
(-15.60%)Baseline: 666.24 ms
799.48 ms
(70.33%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
350.27 ms
(-14.22%)Baseline: 408.32 ms
489.98 ms
(71.49%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,356.30 ms
(-2.47%)Baseline: 2,415.93 ms
2,899.11 ms
(81.28%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,439.53 ms
(-1.72%)Baseline: 4,517.18 ms
5,420.62 ms
(81.90%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
240.30 ms
(-12.41%)Baseline: 274.34 ms
329.20 ms
(73.00%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13306
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,519.61 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
285.14 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
283.32 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.19 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,352.50 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,445.15 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
254.63 ms
🐰 View full continuous benchmarking report in Bencher

… the root slot

Review follow-ups on the root-slot skip:

- Skipping the link was not enough on a repeat install. An install that
  predates this rule, or one where the version had lost the slot, leaves a
  link in the project; left in place it keeps shadowing the root copy,
  which is the duplicate the skip exists to remove. The pruner reclaims the
  real directories the graph walk creates, but not the links this pass
  used to create, so remove one here when it is in the way. A real
  directory stays the pruner's, and only ever belongs to a losing version.

- Run the skip after link_path is built, so an alias that
  safe_join_modules_dir would reject still reports InvalidAlias instead of
  silently taking the skip.

- Assert the nested copies are 2.0.0. The build-artifact checks alone also
  pass if a project links the built root 1.0.0 copy.

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

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 Jul 25, 2026
@qodo-code-review

Copy link
Copy Markdown

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

@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 and others added 2 commits July 25, 2026 13:44
Path::is_symlink only reports IO_REPARSE_TAG_SYMLINK, so the stale-entry
cleanup missed every junction — and a junction is exactly what symlink_dir
falls back to on Windows when it cannot create a true symlink. The
duplicate the skip exists to remove therefore survived on the platform
where the fallback is taken.

A junction-aware predicate already existed, but only in
pacquet-testing-utils, where production code cannot reach it. Move it to
pacquet-fs beside its siblings remove_symlink_dir and read_symlink_dir,
which already handle both reparse shapes, and let testing-utils delegate.
That drops the duplicate copy along with the windows-only junction
dependency testing-utils carried solely for it.

A missing path is the common case here, and junction::exists reports it as
an error rather than Ok(false), so NotFound reads as "nothing to clean up"
while every other IO error propagates.

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

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 cb1886e

kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
pnpm#13306)

With nodeLinker=hoisted, every workspace project got a link to each of its
direct dependencies, including the ones already materialized in the
workspace-root node_modules. Node resolution walks up from the project, so
that second entry is redundant — and it is a second copy for the build
pass to run lifecycle scripts in.

pnpm nests a copy only for the versions that lost the root slot. Upstream's
map comes from the hoisting hierarchy, so a dependency the hoister moved to
the root is simply absent from the importer's entry; pacquet derives it from
the importer's lockfile declarations, which keeps the winner in the map, so
the link pass has to recognize and skip it.

The workspace root itself is exempt: it owns the hoisted slot, and its
entries are the real directories rather than links to them.

Two tests asserted the old shape and now pin the upstream rule, and the
known-failure stub registered for this divergence
(hoisted_workspace_duplicate_materialization) becomes a real assertion in
run_pre_and_postinstall_scripts_in_a_workspace_with_hoisted_linker.

Refs pnpm#13167
zkochan added a commit that referenced this pull request Nov 19, 2026
… suite (#13355)

`just known-failures` piped into `rg`, which exits 1 on no matches, so an
empty expected-failure list reported as a recipe failure. The workspace
build now runs on its own un-silenced line, so a compile failure still
aborts with cargo's diagnostics, and only the listing line tolerates a
nonzero status, through just's `-` line prefix.

The CLI end-to-end tests build as one target, so a stub lists as
`<module>::known_failures::<name>` and the `^known_failures::` anchor
never matched it. The pattern now matches the segment at any depth.

TEST_PORTING.md pointed at a hoisted-layout stub that #13306
replaced with real assertions; the entry now names that test.

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants