Skip to content

fix(resolver): stop hoisted peers from ignoring the declared peer range - #12932

Merged
zkochan merged 6 commits into
pnpm:mainfrom
spencerbeggs:poinsoned-peers
Jul 11, 2026
Merged

zkochan merged 6 commits into
pnpm:mainfrom
spencerbeggs:poinsoned-peers

Conversation

@spencerbeggs

@spencerbeggs spencerbeggs commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Related to #12847 and #12921. Continues the same cleanup as #12927: #12847 was our fix, and this addresses the remaining correctness gap it did not close. The change is independent of #12927 (verified: the two touch disjoint product code, and the reproduction measures the same 46 poisoned snapshots with or without it), so it targets main directly and can land before or after the deadlock fix.

First, an apology: #12847's two-pass split hung pnpm install for every [email protected] user until #12927. We are sorry for the disruption that caused.

What was still broken after #12847

hoistPeers only checked preferred versions against the wanted peer range when the range was an exact version. For an ordinary semver range (^1.0.0), it deduplicated onto semver.maxSatisfying(versions, '*') — the highest preferred version overall, with the declared range never consulted.

In a multi-importer workspace, allPreferredVersions aggregates versions contributed by every importer. So importer A depending on [email protected] put 2.0.0 into the candidate set, and a package deep inside importer B's self-contained 1.x closure — declaring peerDependencies: { foo: "^1.0.0" } — was handed 2.0.0, because it is numerically highest and '*' matches anything. pnpm then only warned about the violation, so the incoherent peer graph shipped silently and failed at runtime. This happens upstream of resolvePeers, so #12847 (single-importer case, fixed) and #12927 (deadlock, orthogonal) do not reach it.

Measured on a minimal 4-file reproduction (two importers, autoInstallPeers: true): 46 poisoned snapshots on pnpm 11.11.0 → 0 with this change, on both the TypeScript CLI and the Rust port.

The fix

  • hoistPeers / hoist_peers now validate the wanted range with semver.validRange (not just semver.valid) and dedupe onto the highest preferred version that satisfies the range. When preferred versions exist but none satisfies, the range itself is resolved from the registry instead of installing a version the peer explicitly rejects. Non-semver specifiers (workspace:, npm: aliases, dist-tags) cannot be range-checked and keep the dedupe-to-highest behavior.
  • Fixing this exposed a Rust-port divergence the old behavior had masked: resolve_peers indexed a node's children into ParentRefs only by install alias, so an npm-alias child could never provide a peer under its real package name below the importer level. Descent-time children are now indexed by both alias and real name, matching resolvePeers.ts.

Why we believe this matches pnpm's intended behavior

  • Auto-installing peers exists to satisfy declared peer ranges; a version the range explicitly rejects can never satisfy it. Deduplication is an optimization and should not override an explicit constraint from a manifest.
  • The exact-version branch added earlier already embodies this principle (pick a satisfying version, else resolve the range from the registry); this extends the same rule to ordinary ranges instead of leaving them on a '*' match.
  • Peers that the user's own tree genuinely provides still resolve as before (warn on mismatch, never error) — this only changes versions pnpm itself introduces via hoisting/auto-install.
  • It is a behavior change for lockfiles that relied on dedupe-to-highest (a few existing tests asserted the old outcome and were updated in both stacks). With pnpm 12 about to release, this seems like the right time to land it.

Follow-up: re-resolve consistency (second commit)

Investigating the two-pass behavior surfaced a second, related defect in the TypeScript CLI. On a fresh install, a missing peer that a workspace-root dependency provides is hoisted to that root dependency's own specifier. On a re-resolve with an existing lockfile, root dependencies reused from the lockfile skip full resolution and were invisible to that branch, so the hoist could pick a different version than a fresh install of the same manifest — the lockfile depended on how you arrived at it. The old '*'-dedupe made the two flows coincidentally identical, which is why this was never visible before. The hoist's root-dep table now falls back to the importer's wanted specifiers, its entry type is narrowed to the exact fields the hoist reads (the same shape as the Rust port's WorkspaceRootDep), and both stacks carry a regression test pinning the shared expectation: adding a dependent to an existing lockfile binds the same peer provider as a fresh install. The Rust port already behaved correctly in both flows (its peers dry-run sees providers regardless of lockfile reuse) and needed no product change.

Squash Commit Body

When deduplicating a missing peer onto the workspace's preferred
versions, hoistPeers matched candidates against '*' unless the wanted
range was an exact version. In a multi-importer workspace,
allPreferredVersions aggregates versions from every importer, so a peer
declared as ^1.0.0 inside one importer's closure could be auto-installed
as a 2.x resolved for another importer, silently producing a peer graph
that mixes incompatible majors. This survived pnpm/pnpm#12847 (which
fixed the single-importer case in resolvePeers) and is independent of
the pnpm/pnpm#12921 deadlock fix: the wrong version is chosen upstream
of peer resolution, during peer hoisting.

Both stacks now dedupe onto the highest preferred version that
satisfies the wanted range and fall back to resolving the range from
the registry when no candidate satisfies it. Non-semver specifiers
(workspace:, npm: aliases, dist-tags) keep the dedupe-to-highest
behavior.

Fixing this exposed a pacquet-only divergence the old behavior masked:
resolve_peers indexed a node's children into ParentRefs only by their
install alias, so an npm-alias child could never provide a peer under
its real package name below the importer level, and the binding fell
through to the importer-level hoisted entry. Descent-time children are
now indexed by both alias and real name, matching resolvePeers.ts.

Measured on the multi-importer reproduction: 46 poisoned snapshots on
pnpm 11.11.0, 0 with this change, in both the TypeScript CLI and
pacquet.

Additionally, hoistPeers now binds the same peer on a re-resolve with
an existing lockfile as on a fresh install of the same manifest: root
dependencies reused from the lockfile skip full resolution and were
invisible to the workspace-root branch of the hoist, so the picked
version depended on whether a lockfile was present. The root-dep table
falls back to the importer's wanted specifiers, and its entry type is
narrowed to HoistableRootDep — the fields hoistPeers reads, matching
the Rust port's WorkspaceRootDep.

Related to pnpm/pnpm#12847 and pnpm/pnpm#12921.

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.

Written by an agent (Claude Code, claude-fable-5).

Signed-off-by: C. Spencer Beggs [email protected]

Summary by CodeRabbit

  • Bug Fixes
    • Peer dependencies now deduplicate and resolve to the highest version that satisfies the declared semver range, including non-exact caret ranges.
    • Auto-installed peer selection now respects semver-checkable peer ranges and falls back safely when no compatible preferred version exists.
    • Peer hoisting stays consistent across fresh installs vs existing lockfile installs.
    • Improved peer matching for aliased installations using the provider’s real package name, with fixes for prerelease and unsupported-range edge cases.
  • Tests
    • Added regression coverage and updated expectations for peer hoisting, deduplication behavior, alias handling, and lockfile consistency.

@coderabbitai

coderabbitai Bot commented Jul 11, 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: 35144f30-ed96-4589-9cd1-3fc78ff1c303

📥 Commits

Reviewing files that changed from the base of the PR and between 8bd4f3d and ea6b790.

📒 Files selected for processing (2)
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs

📝 Walkthrough

Walkthrough

Peer hoisting now respects declared semver ranges, preserves workspace-root dependencies during re-resolution, and matches aliased peer providers by real package name. Rust, TypeScript, CLI, and integration tests cover these behaviors.

Changes

Peer resolution and hoisting

Layer / File(s) Summary
Peer range selection
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs, pnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rs, pnpm11/installing/deps-resolver/src/hoistPeers.ts, pnpm11/installing/deps-resolver/test/hoistPeers.test.ts, pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts
Preferred peer versions are selected only when they satisfy semver ranges; otherwise the declared range or no hoisted peer is used according to configuration.
Workspace-root peer inputs
pnpm11/installing/deps-resolver/src/hoistPeers.ts, pnpm11/installing/deps-resolver/src/resolveDependencies.ts
Root dependencies passed to peer hoisting preserve aliases, package names, and normalized specifiers.
Aliased peer-provider matching
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs, pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
Peer context recognizes providers by install alias or real package name, with tests covering aliased provider resolution.
Existing-lockfile peer binding
pnpm/crates/cli/tests/install.rs, .changeset/peer-hoist-respect-range.md
A regression test verifies consistent peer binding when installing against an existing lockfile, and the changeset records the fixes.

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

Possibly related PRs

  • pnpm/pnpm#11944: Modifies the peer-resolution path around workspace link handling.

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan

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

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

❤️ Share

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

@spencerbeggs
spencerbeggs marked this pull request as ready for review July 11, 2026 05:13
@spencerbeggs
spencerbeggs requested a review from zkochan as a code owner July 11, 2026 05:13
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@codecov-commenter

codecov-commenter commented Jul 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.45%. Comparing base (3c6718b) to head (ea6b790).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12932   +/-   ##
=======================================
  Coverage   85.45%   85.45%           
=======================================
  Files         474      474           
  Lines       74561    74561           
=======================================
  Hits        63716    63716           
  Misses      10845    10845           

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

@spencerbeggs
spencerbeggs marked this pull request as draft July 11, 2026 05:39
@spencerbeggs
spencerbeggs marked this pull request as ready for review July 11, 2026 05:42
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@spencerbeggs
spencerbeggs changed the base branch from fix-12921 to main July 11, 2026 05:58
@spencerbeggs
spencerbeggs marked this pull request as draft July 11, 2026 05:59
@spencerbeggs
spencerbeggs marked this pull request as ready for review July 11, 2026 06:01
Copilot AI review requested due to automatic review settings July 11, 2026 06:01
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a peer auto-install/hoisting correctness gap where hoistPeers could deduplicate to the highest preferred version across a workspace without checking whether it satisfies the declared peer semver range, which could silently produce an incompatible peer graph in multi-importer workspaces. It also aligns the Rust port’s peer resolution behavior with the TypeScript implementation for npm-alias children and adds regression coverage for re-resolve vs fresh install consistency.

Changes:

  • Update hoistPeers / hoist_peers to dedupe onto the highest preferred version that satisfies the peer range, and fall back to resolving the range when preferred versions exist but none satisfy.
  • Fix pacquet resolve_peers to allow an npm-alias child to satisfy a peer by its real package name (matching the TS behavior).
  • Add/adjust tests (TS + Rust) to lock in the new behavior and re-resolve consistency; add a changeset for the user-visible behavior change.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm11/installing/deps-resolver/test/hoistPeers.test.ts Updates/extends unit coverage to ensure preferred-version dedupe respects semver ranges and key edge cases (including prerelease behavior).
pnpm11/installing/deps-resolver/src/resolveDependencies.ts Builds a workspaceRootDeps table that can fall back to wanted specifiers when lockfile reuse skips normalization, ensuring consistent hoist behavior across re-resolve.
pnpm11/installing/deps-resolver/src/hoistPeers.ts Core logic change: validate as semver range and select max satisfying preferred version; otherwise fall back appropriately.
pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts Strengthens integration test to ensure auto-installed peers don’t reuse an incompatible preferred version from elsewhere in the graph.
pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs Updates Rust tests to assert alias children can satisfy peers by real package name.
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs Aligns parent-ref indexing with TS by treating alias children as peer-relevant when either alias or real name matches peer names.
pnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rs Mirrors TS hoist-peers tests for range-respecting preferred dedupe and fallback behavior.
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs Mirrors TS hoist-peers range validation and “fallback to range” behavior when preferred versions don’t satisfy.
pnpm/crates/cli/tests/install.rs Adds regression test ensuring re-resolve with an existing lockfile binds peers the same way as a fresh install.
.changeset/peer-hoist-respect-range.md Records the user-visible fix and lockfile consistency improvement for release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs (1)

87-119: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don't fall back to the highest preferred version for unsatisfied semver ranges. In pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs, the auto_install_peers == false fallback still uses max_satisfying_any(&versions) when is_semver_range is true and no preferred version matches, so it can hoist a range-rejecting major anyway. Mirror the same fix in pnpm11/installing/deps-resolver/src/hoistPeers.ts.

🤖 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/resolving-deps-resolver/src/hoist_peers.rs` around lines 87 -
119, Update the fallback logic in the hoisting code to avoid selecting
max_satisfying_any(&versions) when is_semver_range is true but no preferred
version satisfies the requested range, especially when auto_install_peers is
false; preserve non-semver fallback behavior and resolve unsatisfied semver
ranges from the range instead. Apply the equivalent change to hoistPeers in
pnpm11/installing/deps-resolver/src/hoistPeers.ts.

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.

Outside diff comments:
In `@pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs`:
- Around line 87-119: Update the fallback logic in the hoisting code to avoid
selecting max_satisfying_any(&versions) when is_semver_range is true but no
preferred version satisfies the requested range, especially when
auto_install_peers is false; preserve non-semver fallback behavior and resolve
unsatisfied semver ranges from the range instead. Apply the equivalent change to
hoistPeers in pnpm11/installing/deps-resolver/src/hoistPeers.ts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c2997e0-c17a-432e-a98e-6611fc2b8263

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb4e94 and cf63810.

📒 Files selected for processing (10)
  • .changeset/peer-hoist-respect-range.md
  • pnpm/crates/cli/tests/install.rs
  • pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs
  • pnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
  • pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts
  • pnpm11/installing/deps-resolver/src/hoistPeers.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts
  • pnpm11/installing/deps-resolver/test/hoistPeers.test.ts

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 11, 2026
spencerbeggs added a commit to spencerbeggs/pnpm that referenced this pull request Jul 11, 2026
…to-install

With autoInstallPeers off (the dedupe-peer-dependents hoist), a semver
peer range that no preferred version satisfies fell through to the
dedupe-to-highest branch and could still hoist a version the range
rejects. Leave the peer missing instead — the ordinary missing-peer
warning applies. Raised by CodeRabbit on pnpm#12932.

Signed-off-by: C. Spencer Beggs <[email protected]>
Copilot AI review requested due to automatic review settings July 11, 2026 06:33
@spencerbeggs

Copy link
Copy Markdown
Contributor Author

Addressed CodeRabbit's outside-diff finding on hoist_peers.rs in 987f4f8: with autoInstallPeers off (the dedupe-peer-dependents hoist), a semver peer range that no preferred version satisfies no longer falls through to the dedupe-to-highest branch — the peer is left missing and gets the ordinary missing-peer warning instead of a version its range rejects. Mirrored in pnpm11/installing/deps-resolver/src/hoistPeers.ts in the same commit, with unit tests pinning the behavior in both stacks.


Written by an agent (Claude Code, claude-fable-5).

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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@spencerbeggs

Copy link
Copy Markdown
Contributor Author

The Rust CI / Test / ubuntu failure on 987f4f8 was stale_pin_dedupe::refreshes_stale_transitive_pin_for_caret_range_direct_dep — the optimistic-repeat-install mtime race already tracked in #12730 (the failing lockfile shows the second install no-opped on the fast path; the scenario involves no peer dependencies). It passes 15/15 locally on this branch. Retriggered CI with an empty commit since the failed job can't be rerun without admin rights.


Written by an agent (Claude Code, claude-fable-5).

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: ab24de9a85a2

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.099 ± 0.131 3.982 4.324 1.90 ± 0.12
pacquet@main 4.049 ± 0.148 3.905 4.416 1.88 ± 0.13
pnpr@HEAD 2.172 ± 0.122 2.042 2.329 1.01 ± 0.08
pnpr@main 2.154 ± 0.121 2.004 2.355 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.09903901452,
      "stddev": 0.13055466946721822,
      "median": 4.04792488902,
      "user": 3.9347863599999995,
      "system": 3.4397765799999993,
      "min": 3.98204685202,
      "max": 4.32424004802,
      "times": [
        4.21734254302,
        4.32424004802,
        3.99287231402,
        4.06929425702,
        4.27365528102,
        3.98809328402,
        3.98248826302,
        4.02655552102,
        4.13380178202,
        3.98204685202
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.048509955519999,
      "stddev": 0.1484015324908731,
      "median": 4.02494718452,
      "user": 3.9401107600000005,
      "system": 3.44815978,
      "min": 3.90541797402,
      "max": 4.41635601402,
      "times": [
        4.03695827002,
        4.41635601402,
        4.01293609902,
        4.07514856802,
        4.08785813602,
        3.90541797402,
        3.9547258760200004,
        3.91736996302,
        3.95980304202,
        4.11852561302
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.17238569912,
      "stddev": 0.12176760625992558,
      "median": 2.1592768950199996,
      "user": 2.76988426,
      "system": 2.95323438,
      "min": 2.04191156602,
      "max": 2.32863631102,
      "times": [
        2.32687210302,
        2.23652287202,
        2.04191156602,
        2.21071185902,
        2.04319647002,
        2.10784193102,
        2.06235401502,
        2.06171120102,
        2.32863631102,
        2.30409866302
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.15435309372,
      "stddev": 0.120607257179547,
      "median": 2.10763117752,
      "user": 2.74863856,
      "system": 2.9418326799999996,
      "min": 2.00397784302,
      "max": 2.35474322202,
      "times": [
        2.28919223702,
        2.1083894610200002,
        2.10687289402,
        2.09866566502,
        2.23861302702,
        2.00397784302,
        2.03745676402,
        2.35474322202,
        2.04858152202,
        2.25703830202
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 668.5 ± 10.0 650.8 681.0 1.00
pacquet@main 683.5 ± 75.4 637.1 892.7 1.02 ± 0.11
pnpr@HEAD 737.2 ± 95.1 687.5 1004.6 1.10 ± 0.14
pnpr@main 729.5 ± 9.2 716.3 740.7 1.09 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6684769064600001,
      "stddev": 0.009969768808813678,
      "median": 0.6697000630600001,
      "user": 0.41088509999999995,
      "system": 1.3402659199999998,
      "min": 0.65082770706,
      "max": 0.6810166280600001,
      "times": [
        0.67982300106,
        0.65992550106,
        0.67023634706,
        0.65082770706,
        0.6595654790600001,
        0.66916377906,
        0.66378477006,
        0.6810166280600001,
        0.6714564430600001,
        0.67896940906
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6834991760600001,
      "stddev": 0.07538558396795338,
      "median": 0.6589987420600001,
      "user": 0.38654230000000006,
      "system": 1.3395096199999998,
      "min": 0.63708513806,
      "max": 0.89268469506,
      "times": [
        0.68652939406,
        0.66290896706,
        0.6462511750600001,
        0.6789232070600001,
        0.63708513806,
        0.65508851706,
        0.64617604206,
        0.6491246970600001,
        0.89268469506,
        0.6802199280600001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7372040815600001,
      "stddev": 0.09506848787931015,
      "median": 0.70731624906,
      "user": 0.418748,
      "system": 1.35541432,
      "min": 0.68750187106,
      "max": 1.0046209100599999,
      "times": [
        0.7253390460600001,
        0.7159091870600001,
        0.69840433806,
        0.70844655006,
        0.6882457510600001,
        0.68750187106,
        0.7047454670600001,
        1.0046209100599999,
        0.7326417470600001,
        0.70618594806
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.72951844446,
      "stddev": 0.009191100996470322,
      "median": 0.73203615156,
      "user": 0.4013331,
      "system": 1.40122052,
      "min": 0.71630366706,
      "max": 0.7406551060600001,
      "times": [
        0.7386188880600001,
        0.7406551060600001,
        0.73842422506,
        0.71630366706,
        0.7262857380600001,
        0.7311137160600001,
        0.7191560130600001,
        0.73295858706,
        0.73420515606,
        0.71746334806
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.311 ± 0.027 4.261 4.345 2.06 ± 0.09
pacquet@main 4.329 ± 0.050 4.239 4.412 2.07 ± 0.09
pnpr@HEAD 2.156 ± 0.147 2.038 2.549 1.03 ± 0.08
pnpr@main 2.088 ± 0.087 2.002 2.304 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.31105912486,
      "stddev": 0.027296323073829995,
      "median": 4.3155930399599995,
      "user": 3.89089174,
      "system": 3.33861572,
      "min": 4.2611457899600005,
      "max": 4.34537937396,
      "times": [
        4.32156374496,
        4.29412010096,
        4.2611457899600005,
        4.3392340459600005,
        4.34537937396,
        4.2764896849600005,
        4.30649299196,
        4.31273916296,
        4.33497943596,
        4.31844691696
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.329499830960001,
      "stddev": 0.049776629775337325,
      "median": 4.32892175896,
      "user": 3.9056600399999994,
      "system": 3.3454023200000003,
      "min": 4.23907853996,
      "max": 4.41227109396,
      "times": [
        4.23907853996,
        4.27131997596,
        4.33096285796,
        4.33772501196,
        4.31150138796,
        4.41227109396,
        4.3268806599600005,
        4.38015617096,
        4.32552069096,
        4.35958191996
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1564066337599996,
      "stddev": 0.14698987952938894,
      "median": 2.10179265896,
      "user": 2.606273039999999,
      "system": 2.85091802,
      "min": 2.0377890449600002,
      "max": 2.5492438279600003,
      "times": [
        2.5492438279600003,
        2.2021473249600003,
        2.18122776596,
        2.0815766089600003,
        2.1036329459600003,
        2.06758495896,
        2.09995237196,
        2.14603725996,
        2.09487422796,
        2.0377890449600002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.08784249376,
      "stddev": 0.08731701609331732,
      "median": 2.06238412046,
      "user": 2.60925094,
      "system": 2.8475464199999996,
      "min": 2.00246777696,
      "max": 2.30403698396,
      "times": [
        2.00246777696,
        2.30403698396,
        2.04248417996,
        2.05862733296,
        2.0552307669600003,
        2.15135391096,
        2.0113442419600003,
        2.06614090796,
        2.08343740896,
        2.1033014269600003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.427 ± 0.012 1.411 1.444 2.09 ± 0.03
pacquet@main 1.430 ± 0.045 1.385 1.540 2.09 ± 0.07
pnpr@HEAD 0.692 ± 0.021 0.674 0.747 1.01 ± 0.03
pnpr@main 0.684 ± 0.010 0.672 0.697 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4273389554400002,
      "stddev": 0.012188124484527016,
      "median": 1.42319056944,
      "user": 1.3984827799999997,
      "system": 1.7329195799999997,
      "min": 1.41142365444,
      "max": 1.44395134444,
      "times": [
        1.41478400144,
        1.41595556544,
        1.42269958544,
        1.43686021144,
        1.42316108044,
        1.43761713144,
        1.41142365444,
        1.44371692144,
        1.44395134444,
        1.42322005844
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.42973404894,
      "stddev": 0.04522988568412074,
      "median": 1.42315389494,
      "user": 1.3634850799999998,
      "system": 1.7241813799999999,
      "min": 1.38504907344,
      "max": 1.54024081344,
      "times": [
        1.4043522904399999,
        1.44899602444,
        1.54024081344,
        1.41519095144,
        1.3983310764399999,
        1.3896821024400001,
        1.38504907344,
        1.44826850644,
        1.43111683844,
        1.43611281244
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6915095040400001,
      "stddev": 0.021207567955761817,
      "median": 0.68596441094,
      "user": 0.37380388,
      "system": 1.2810505799999998,
      "min": 0.67412080144,
      "max": 0.74665169344,
      "times": [
        0.68937918544,
        0.67412080144,
        0.67828391844,
        0.69357753844,
        0.74665169344,
        0.69042411644,
        0.6818011834400001,
        0.67622524244,
        0.70208172444,
        0.68254963644
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6841067798400001,
      "stddev": 0.009676331543613704,
      "median": 0.68539625844,
      "user": 0.35231757999999996,
      "system": 1.2864856799999997,
      "min": 0.67221459644,
      "max": 0.6971277824400001,
      "times": [
        0.67427054744,
        0.67437910444,
        0.67221459644,
        0.67530344744,
        0.68626442544,
        0.68452809144,
        0.6971277824400001,
        0.69621613144,
        0.69441991744,
        0.6863437544400001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.191 ± 0.037 3.128 3.226 4.67 ± 0.07
pacquet@main 3.219 ± 0.062 3.177 3.382 4.71 ± 0.10
pnpr@HEAD 0.683 ± 0.007 0.669 0.691 1.00
pnpr@main 0.691 ± 0.016 0.677 0.732 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.1913319595,
      "stddev": 0.0365194694734581,
      "median": 3.2046170925,
      "user": 1.93122912,
      "system": 2.0224480599999994,
      "min": 3.1281342665,
      "max": 3.2264619555,
      "times": [
        3.1923553625,
        3.2020508265,
        3.2182242795,
        3.2166931284999998,
        3.2260955145,
        3.2264619555,
        3.2071833585,
        3.1546949895,
        3.1414259135,
        3.1281342665
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.2193624746999996,
      "stddev": 0.06202043466184382,
      "median": 3.200432827,
      "user": 1.9025370199999998,
      "system": 2.05267916,
      "min": 3.1773398335,
      "max": 3.3816183095,
      "times": [
        3.2093890595,
        3.2195422805,
        3.1787441015,
        3.1773398335,
        3.2582538205,
        3.1827192105,
        3.2045767585,
        3.3816183095,
        3.1962888955,
        3.1851524775
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6832898783000001,
      "stddev": 0.006870468117246211,
      "median": 0.6850266225,
      "user": 0.37690722,
      "system": 1.2826396599999998,
      "min": 0.6692689085,
      "max": 0.6912448445,
      "times": [
        0.6863309545,
        0.6811560655000001,
        0.6740944205,
        0.6857774605,
        0.6912448445,
        0.6884038845,
        0.6832868315,
        0.6692689085,
        0.6890596285,
        0.6842757845
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6910295479999999,
      "stddev": 0.015713986786841428,
      "median": 0.6864468855000001,
      "user": 0.36189352,
      "system": 1.2936359600000003,
      "min": 0.6767242635,
      "max": 0.7317261255,
      "times": [
        0.6804516415,
        0.6767242635,
        0.6864038505000001,
        0.6813807185,
        0.6859751915000001,
        0.6864899205,
        0.6990174685,
        0.6875163995,
        0.7317261255,
        0.6946099005
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 725.4 ± 19.4 703.8 766.4 6.47 ± 0.18
pacquet@main 711.8 ± 12.2 696.0 737.3 6.35 ± 0.11
pnpr@HEAD 112.1 ± 0.6 111.1 113.2 1.00
pnpr@main 118.5 ± 28.0 110.8 249.6 1.06 ± 0.25
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7253934999800001,
      "stddev": 0.01939360037505428,
      "median": 0.7213638713800001,
      "user": 0.6787718,
      "system": 0.16117917999999998,
      "min": 0.7038231423800001,
      "max": 0.7664313813800001,
      "times": [
        0.7038231423800001,
        0.7113051113800001,
        0.7239285363800001,
        0.7515339613800001,
        0.7664313813800001,
        0.71912900438,
        0.7235987383800001,
        0.7277044723800001,
        0.7111836173800001,
        0.7152970343800001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.7118370981800001,
      "stddev": 0.012210768933700272,
      "median": 0.7082076298800001,
      "user": 0.6696978999999998,
      "system": 0.15525728,
      "min": 0.6959624073800001,
      "max": 0.7373356663800001,
      "times": [
        0.7056243473800001,
        0.70257904538,
        0.6959624073800001,
        0.7086834093800001,
        0.71086993738,
        0.7258454293800001,
        0.7186319753800001,
        0.7373356663800001,
        0.7077318503800001,
        0.7051069133800001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11208668583833335,
      "stddev": 0.0005946166461595222,
      "median": 0.11198269488000001,
      "user": 0.027835374999999996,
      "system": 0.02342688833333334,
      "min": 0.11107018638,
      "max": 0.11321926438,
      "times": [
        0.11166380338,
        0.11279218838,
        0.11184489738,
        0.11202805338,
        0.11161694238,
        0.11321926438,
        0.11107018638,
        0.11178441538,
        0.11243491838,
        0.11279213838,
        0.11177829638,
        0.11135030938,
        0.11209520538000001,
        0.11113141838,
        0.11285429338,
        0.11151482838,
        0.11246958138,
        0.11206857538,
        0.11243675138,
        0.11302783538,
        0.11179728538,
        0.11193733638,
        0.11173906738,
        0.11263286838
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.11849011979666664,
      "stddev": 0.02796737818631637,
      "median": 0.11260520888,
      "user": 0.029301000000000004,
      "system": 0.022546846666666665,
      "min": 0.11077748638,
      "max": 0.24959864537999998,
      "times": [
        0.11102487738,
        0.11297875038,
        0.11276754138,
        0.11214126538,
        0.11189388138,
        0.11170595738,
        0.11244683738,
        0.11283616038,
        0.11285920338,
        0.11077748638,
        0.11253902938,
        0.11339519338,
        0.11703733938,
        0.11528865538,
        0.11260242438,
        0.11278813538,
        0.11260799338000001,
        0.11198229738,
        0.11170090238,
        0.11155479138,
        0.24959864537999998,
        0.11653383738,
        0.11302986138,
        0.11167180838
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.918 ± 0.117 6.711 7.119 1.42 ± 0.03
pacquet@main 6.918 ± 0.139 6.772 7.181 1.42 ± 0.04
pnpr@HEAD 4.941 ± 0.100 4.743 5.079 1.01 ± 0.03
pnpr@main 4.885 ± 0.080 4.787 5.023 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.918297195879999,
      "stddev": 0.11710655765108625,
      "median": 6.950470730779999,
      "user": 4.19744016,
      "system": 3.6697252199999992,
      "min": 6.71072303528,
      "max": 7.11901167728,
      "times": [
        6.97319606728,
        7.11901167728,
        6.8392534202799995,
        6.99948200328,
        6.9767524412799995,
        6.97378713928,
        6.7958026692799995,
        6.86721811128,
        6.71072303528,
        6.92774539428
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.917501079180001,
      "stddev": 0.13896432221887417,
      "median": 6.874128628779999,
      "user": 4.127026760000001,
      "system": 3.6894824199999996,
      "min": 6.77231592228,
      "max": 7.181192107279999,
      "times": [
        6.83373175028,
        6.852489009279999,
        6.83489003228,
        7.181192107279999,
        6.90785123628,
        7.13804441828,
        6.96000501128,
        6.77231592228,
        6.89576824828,
        6.79872305628
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.94073205668,
      "stddev": 0.09980576115571188,
      "median": 4.954405102779999,
      "user": 2.8915503599999997,
      "system": 3.1343194199999997,
      "min": 4.742720923279999,
      "max": 5.07864290528,
      "times": [
        5.04617400228,
        4.97321964328,
        4.936204077279999,
        4.91730920028,
        4.82124062928,
        4.742720923279999,
        5.07864290528,
        4.99616686028,
        4.97260612828,
        4.92303619728
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.88475187498,
      "stddev": 0.08026552333100233,
      "median": 4.87103237828,
      "user": 2.8679316599999995,
      "system": 3.1330787199999994,
      "min": 4.78709393928,
      "max": 5.02288145828,
      "times": [
        4.79057330628,
        4.8306189242799995,
        5.02288145828,
        4.78709393928,
        4.8607676262799995,
        4.88129713028,
        4.930619324279999,
        5.0030384112799995,
        4.85504078428,
        4.88558784528
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12932
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
4,311.06 ms
(+0.61%)Baseline: 4,285.08 ms
5,142.09 ms
(83.84%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,191.33 ms
(+5.29%)Baseline: 3,031.07 ms
3,637.29 ms
(87.74%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,427.34 ms
(+5.08%)Baseline: 1,358.29 ms
1,629.94 ms
(87.57%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
725.39 ms
(+12.81%)Baseline: 643.00 ms
771.60 ms
(94.01%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,099.04 ms
(-0.66%)Baseline: 4,126.34 ms
4,951.60 ms
(82.78%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,918.30 ms
(-4.50%)Baseline: 7,244.29 ms
8,693.15 ms
(79.58%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
668.48 ms
(+4.02%)Baseline: 642.64 ms
771.16 ms
(86.68%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12932
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
2,156.41 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
683.29 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
691.51 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
112.09 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,172.39 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,940.73 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
737.20 ms
🐰 View full continuous benchmarking report in Bencher

When deduplicating a missing peer onto the workspace's preferred
versions, hoistPeers matched candidates against '*' unless the wanted
range was an exact version. In a multi-importer workspace,
allPreferredVersions aggregates versions from every importer, so a peer
declared as ^1.0.0 inside one importer's closure could be auto-installed
as a 2.x resolved for another importer, silently producing a peer graph
that mixes incompatible majors. This survived pnpm#12847 (which
fixed the single-importer case in resolvePeers) and is independent of
the pnpm#12921 deadlock fix: the wrong version is chosen upstream
of peer resolution, during peer hoisting.

Both stacks now dedupe onto the highest preferred version that
satisfies the wanted range and fall back to resolving the range from
the registry when no candidate satisfies it. Non-semver specifiers
(workspace:, npm: aliases, dist-tags) keep the dedupe-to-highest
behavior.

Fixing this exposed a pacquet-only divergence the old behavior masked:
resolve_peers indexed a node's children into ParentRefs only by their
install alias, so an npm-alias child could never provide a peer under
its real package name below the importer level, and the binding fell
through to the importer-level hoisted entry. Descent-time children are
now indexed by both alias and real name, matching resolvePeers.ts.

Measured on the multi-importer reproduction: 46 poisoned snapshots on
pnpm 11.11.0, 0 with this change, in both the TypeScript CLI and
pacquet.

Signed-off-by: C. Spencer Beggs <[email protected]>
The perfectionist::macro-trailing-comma dylint check rejects a
multi-line macro invocation without a trailing comma; the local
pre-push hook skips dylint when cargo-dylint is not installed, so CI
caught it.

Signed-off-by: C. Spencer Beggs <[email protected]>
On a fresh install, a missing peer that a workspace-root dependency
provides is hoisted to that dependency's own specifier (the
workspaceRootDeps branch of hoistPeers), so the peer dedupes onto the
package the root dependency brings in. On a re-resolve with an existing
lockfile, root dependencies reused from the lockfile skip full
resolution: their addresses carry no normalizedBareSpecifier (or they
produce no address at all), so hoistPeers fell through to the
preferred-versions branch and could pick a different version than the
fresh install of the same manifest. With the range-respecting hoist
this stopped being coincidentally identical and produced a lockfile
that differed between the two flows — and diverged from the Rust port,
whose peers-dry-run sees providers regardless of lockfile reuse and
already behaved like the fresh install in both flows.

The hoist's root-dep table is now built with a fallback to the
importer's wanted specifiers, covering lockfile-reused dependencies.
Its entry type is narrowed to HoistableRootDep { alias, pkgName,
normalizedBareSpecifier } — the exact fields hoistPeers reads, and the
same shape as the Rust port's WorkspaceRootDep.

The Rust port gets a regression test pinning the shared expectation
(adding a dependent to an existing lockfile binds the same peer
provider as a fresh install); the TypeScript expectation is restored to
the pre-existing aliased-providers test it had temporarily changed.

Signed-off-by: C. Spencer Beggs <[email protected]>
…to-install

With autoInstallPeers off (the dedupe-peer-dependents hoist), a semver
peer range that no preferred version satisfies fell through to the
dedupe-to-highest branch and could still hoist a version the range
rejects. Leave the peer missing instead — the ordinary missing-peer
warning applies. Raised by CodeRabbit on pnpm#12932.

Signed-off-by: C. Spencer Beggs <[email protected]>
Rust CI / Test / ubuntu hit the optimistic-repeat-install mtime race
tracked in pnpm#12730 (stale_pin_dedupe); no rerun rights on the
failed job, so an empty commit retriggers the run.

Signed-off-by: C. Spencer Beggs <[email protected]>
Copilot AI review requested due to automatic review settings July 11, 2026 08:16

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

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (2) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Remediation recommended

1. Missing trailing comma in params 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The multi-line getHoistableRootDeps parameter list omits a trailing comma after the last
parameter, violating the required TypeScript trailing-comma style and increasing diff churn when
adding parameters.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R514-517]

+function getHoistableRootDeps (
+  rootImporter: ImporterToResolve | undefined,
+  rootPkgAddresses: PkgAddressOrLink[]
+): HoistableRootDep[] {
Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs including
parameter lists. The getHoistableRootDeps signature spans multiple lines but the last parameter
line does not end with a comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[514-517]

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 multi-line function parameter list lacks a trailing comma after the last parameter, violating the project's trailing-comma requirement for TypeScript multi-line constructs.

## Issue Context
This is in the new `function getHoistableRootDeps` declaration.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[514-517]

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


2. Missing trailing comma in call 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The multi-line getHoistableRootDeps(...) call omits a trailing comma after the last argument,
violating the required TypeScript trailing-comma style and creating noisier diffs on future edits.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R407-410]

+    workspaceRootDeps = getHoistableRootDeps(
+      importers[rootImporterIndex],
+      pkgAddressesByImportersWithoutPeers[rootImporterIndex]?.pkgAddresses ?? []
+    )
Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs. The
getHoistableRootDeps( invocation spans multiple lines but its last argument line does not end with
a comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[407-410]

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 multi-line function call lacks a trailing comma after the last argument, violating the project's trailing-comma requirement for TypeScript multi-line constructs.

## Issue Context
This is in the new `workspaceRootDeps = getHoistableRootDeps(...)` call.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[407-410]

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


3. Peer walk extra allocations 🐞 Bug ➹ Performance
Description
In pacquet’s resolve_peers walker, the PR now loads each child’s package and clones its real name
for every child edge before checking whether the child is peer-relevant. This adds avoidable HashMap
lookups and string allocations on a hot traversal path, and also recomputes the child’s real name
twice for peer-relevant children (once in the loop, once inside insert_parent_ref).
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[R889-907]

        let mut child_parent_refs = parent_parent_refs.clone();
        let mut new_parent_refs = ParentRefs::new();
        for (alias, child_node_id) in &children_map {
-            if !self.tree.all_peer_dep_names.contains(alias) {
-                continue;
-            }
            let Some(child_tree) = self.tree.dependencies_tree.get(child_node_id) else { continue };
            let Some(child_pkg) = self.tree.packages.get(&child_tree.resolved_package_id) else {
                continue;
            };
+            // Match by the install alias and by the real package name, so
+            // an npm-alias child (`peer-c1@npm:@pnpm.e2e/[email protected]`) can
+            // provide the peer declared under its real name.
+            let (child_real_name, _) = pkg_name_version(&child_pkg.result);
+            if !self.tree.all_peer_dep_names.contains(alias)
+                && !self.tree.all_peer_dep_names.contains(&child_real_name)
+            {
+                continue;
+            }
            insert_parent_ref(
                &mut new_parent_refs,
                alias,
Evidence
The new child loop computes child_real_name via pkg_name_version before filtering, which clones
strings; then insert_parent_ref recomputes pkg_name_version again for the same child. The helper
itself returns owned Strings, so this is real allocation work per edge and is now done even for
non-peer-relevant children.

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[887-912]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[90-96]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[2539-2566]

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

### Issue description
`Walker::walk_node` now performs `dependencies_tree.get` + `packages.get` + `pkg_name_version` for **every** child, even when the child cannot possibly contribute to peer resolution. It also calls `pkg_name_version` twice per peer-relevant child (in the loop and again inside `insert_parent_ref`), causing redundant string cloning.

### Issue Context
This loop runs during dependency tree traversal; extra per-edge work can compound on large graphs. The PR’s new behavior (matching by install alias and real package name) is correct, but can be implemented with less overhead.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[887-912]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[90-96]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[2539-2566]

### Suggested implementation direction
1. Re-introduce a cheap early check:
  - If `all_peer_dep_names.contains(alias)` is true, proceed to load `child_tree`/`child_pkg` and insert.
  - Only if alias is **not** peer-relevant, then load the child package to compute/check the real name.
2. Avoid cloning strings just to test membership:
  - Prefer borrowing `&str` from `child_pkg.result.name_ver` when available (or other non-allocating accessors), instead of calling `pkg_name_version` which returns owned `String`s.
3. Avoid double `pkg_name_version` evaluation:
  - Either pass the precomputed real name into `insert_parent_ref`, or refactor `insert_parent_ref` to accept the already-extracted real name/version (or a lightweight struct) so it doesn’t recompute and clone again.

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



Informational

4. Extra root-deps allocations 🐞 Bug ➹ Performance ⭐ New
Description
getHoistableRootDeps() builds multiple intermediate collections (Map → Array → Set) even though it
only needs fast alias lookup and a covered-alias set, adding avoidable allocations on the install
resolution path for large workspace roots.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R518-537]

+  const wantedSpecifierByAlias = new Map<string, string>()
+  for (const wantedDep of rootImporter?.wantedDependencies ?? []) {
+    if (wantedDep.alias && wantedDep.bareSpecifier) {
+      wantedSpecifierByAlias.set(wantedDep.alias, wantedDep.bareSpecifier)
+    }
+  }
+  const rootDeps: HoistableRootDep[] = rootPkgAddresses.map((pkgAddress) => ({
+    alias: pkgAddress.alias,
+    pkgName: pkgAddress.pkg.name,
+    normalizedBareSpecifier: pkgAddress.normalizedBareSpecifier ?? wantedSpecifierByAlias.get(pkgAddress.alias),
+  }))
+  const coveredAliases = new Set(rootDeps.map(({ alias }) => alias))
+  for (const [alias, bareSpecifier] of wantedSpecifierByAlias) {
+    if (coveredAliases.has(alias)) continue
+    rootDeps.push({
+      alias,
+      pkgName: unwrapPackageName(alias, bareSpecifier).pkgName,
+      normalizedBareSpecifier: bareSpecifier,
+    })
+  }
Evidence
The cited code shows the new helper creating a Map of wanted specifiers, then building rootDeps,
then building coveredAliases from a second pass over rootDeps, and then looping the Map again.
The call site shows it runs during resolveRootDependencies() when workspace-root peer resolution
is enabled (install resolution path).

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[404-418]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[506-539]
pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts[250-290]

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

### Issue description
`getHoistableRootDeps()` currently constructs `wantedSpecifierByAlias` (Map), then creates `rootDeps` (Array), then creates `coveredAliases` via `new Set(rootDeps.map(...))`, and finally iterates the Map again to push missing aliases. This is extra iteration and allocation on the dependency-resolution hot path.

### Issue Context
This helper is called from `resolveRootDependencies()` when `resolvePeersFromWorkspaceRoot` is enabled, i.e. during install resolution.

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[514-539]

### Suggested approach
- Build `coveredAliases` incrementally while building `rootDeps` (single pass).
- Consider avoiding the `Map` entirely by building a plain object/Map only if needed for lookups, or by precomputing wanted specifiers into a `Map` and also collecting uncovered aliases without the additional `Set(rootDeps.map(...))` pass.
- Keep behavior identical (same resulting `HoistableRootDep[]`).

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

Results up to commit 8bd4f3d


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


Remediation recommended
1. Peer walk extra allocations 🐞 Bug ➹ Performance
Description
In pacquet’s resolve_peers walker, the PR now loads each child’s package and clones its real name
for every child edge before checking whether the child is peer-relevant. This adds avoidable HashMap
lookups and string allocations on a hot traversal path, and also recomputes the child’s real name
twice for peer-relevant children (once in the loop, once inside insert_parent_ref).
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[R889-907]

        let mut child_parent_refs = parent_parent_refs.clone();
        let mut new_parent_refs = ParentRefs::new();
        for (alias, child_node_id) in &children_map {
-            if !self.tree.all_peer_dep_names.contains(alias) {
-                continue;
-            }
            let Some(child_tree) = self.tree.dependencies_tree.get(child_node_id) else { continue };
            let Some(child_pkg) = self.tree.packages.get(&child_tree.resolved_package_id) else {
                continue;
            };
+            // Match by the install alias and by the real package name, so
+            // an npm-alias child (`peer-c1@npm:@pnpm.e2e/[email protected]`) can
+            // provide the peer declared under its real name.
+            let (child_real_name, _) = pkg_name_version(&child_pkg.result);
+            if !self.tree.all_peer_dep_names.contains(alias)
+                && !self.tree.all_peer_dep_names.contains(&child_real_name)
+            {
+                continue;
+            }
            insert_parent_ref(
                &mut new_parent_refs,
                alias,
Evidence
The new child loop computes child_real_name via pkg_name_version before filtering, which clones
strings; then insert_parent_ref recomputes pkg_name_version again for the same child. The helper
itself returns owned Strings, so this is real allocation work per edge and is now done even for
non-peer-relevant children.

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[887-912]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[90-96]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[2539-2566]

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

### Issue description
`Walker::walk_node` now performs `dependencies_tree.get` + `packages.get` + `pkg_name_version` for **every** child, even when the child cannot possibly contribute to peer resolution. It also calls `pkg_name_version` twice per peer-relevant child (in the loop and again inside `insert_parent_ref`), causing redundant string cloning.

### Issue Context
This loop runs during dependency tree traversal; extra per-edge work can compound on large graphs. The PR’s new behavior (matching by install alias and real package name) is correct, but can be implemented with less overhead.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[887-912]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[90-96]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[2539-2566]

### Suggested implementation direction
1. Re-introduce a cheap early check:
  - If `all_peer_dep_names.contains(alias)` is true, proceed to load `child_tree`/`child_pkg` and insert.
  - Only if alias is **not** peer-relevant, then load the child package to compute/check the real name.
2. Avoid cloning strings just to test membership:
  - Prefer borrowing `&str` from `child_pkg.result.name_ver` when available (or other non-allocating accessors), instead of calling `pkg_name_version` which returns owned `String`s.
3. Avoid double `pkg_name_version` evaluation:
  - Either pass the precomputed real name into `insert_parent_ref`, or refactor `insert_parent_ref` to accept the already-extracted real name/version (or a lightweight struct) so it doesn’t recompute and clone again.

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

…cks into named helpers

The workspace-root-deps construction in resolveRootDependencies moves
into getHoistableRootDeps, whose doc comment carries the lockfile-reuse
fallback rationale. The alias-or-real-name peer check duplicated at the
importer level and at descent time in resolve_peers.rs becomes a single
Walker::is_peer_relevant method; it also short-circuits before
pkg_name_version's allocations when the alias alone matches. No behavior
change in either stack.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 11, 2026 08:41

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 ea6b790

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

Safe to merge. The change is well-scoped, both stacks are updated together, and the regression tests cover the fixed cases directly.

The deduplication logic change is a deliberate behavior break for lockfiles that previously relied on maxSatisfying(versions, '*') for non-exact peer ranges — existing tests were updated to match the corrected expectations. The getHoistableRootDeps helper introduces a new code path for the lockfile-reuse case exercised only by the new e2e test. Both are high-confidence fixes with clear regression coverage, but the behavior change to the else branch is subtle and touches core resolution logic in both stacks.

resolveDependencies.ts (getHoistableRootDeps) deserves a second look: when a root dep is reused from the lockfile its fallback normalizedBareSpecifier is the raw wanted range rather than the exact locked version, which causes re-resolution against the lockfile rather than pinning. This is the intended design but differs subtly from a fully-resolved address entry.

Reviews (1): Last reviewed commit: "refactor(resolver): extract the root-dep..." | Re-trigger Greptile

@zkochan
zkochan merged commit 252f15e into pnpm:main Jul 11, 2026
31 of 32 checks passed
zkochan added a commit to zkochan/bit that referenced this pull request Jul 12, 2026
Carries the merged readPackage resolvedDir hook (pnpm/pnpm#12936) plus the
hoisted-peer range fix (pnpm/pnpm#12932). The resolvedDir hook resolves the
injected workspace-sibling failures under BIT_FEATURES=deps-graph — the
deps-graph e2e suite drops from 3 failing to 1. The remaining failure is the
separate lockfile resolution-reuse gap, not the manifest-injection path.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants