Skip to content

fix(resolving-deps-resolver): apply overrides and the workspace root's pin to hoisted peers - #13369

Merged
zkochan merged 7 commits into
mainfrom
fix-13320-2
Jul 25, 2026
Merged

zkochan merged 7 commits into
mainfrom
fix-13320-2

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Two peer-hoisting fixes from #13320, both landed in the TypeScript CLI and pacquet together.

1. overrides now reach auto-installed peers. An override only ever rewrote dependencies declared in a manifest, because it is applied through the read-package hook. A peer nobody declares — installed because autoInstallPeers is on — has no manifest to rewrite, so it resolved against its declared peer range instead and could pull in a second copy of the very package the override pinned:

// package.json        { "dependencies": { "lucide-react": "0.383.0" } }
// pnpm-workspace.yaml overrides: { react: npm:[email protected] }

Before: [email protected]. After: [email protected], on both stacks (verified byte-identical lockfiles).

The required-peer picker now consults the override set before the workspace-root short-circuit and before allPreferredVersions. Parent-scoped overrides (parent>child) do not apply — there is no parent manifest to match — and a convergence override ("pkg@") applies only when its version satisfies the peer range, exactly as for a declared edge.

An override redirects a hoist; it never creates one. With autoInstallPeers off (dedupePeerDependents keeps hoisting active), hoisting only deduplicates a package the graph or the workspace root already provides, so a peer nothing provides stays uninstalled even when an override names it. A link: / file: override target is resolved relative to the importer the peer is hoisted into, so the importer's specifier stays portable instead of recording an absolute path.

2. The optional-peer hoist now respects the workspace root's specifier. resolvePeersFromWorkspaceRoot (on by default) makes the workspace root's own specifier decide which version a missing required peer is installed at. getHoistableOptionalPeers ignored it entirely and always took the highest version present anywhere in the graph. The root specifier is read through getPeerVersionRange, so a workspace: range or an npm: alias bounds the candidates too; one with no version body leaves them unbounded.

On vercel/next.js, [email protected] declares postcss as an optional peer through peerDependenciesMeta alone — so it arrives with range * — and the three importers that depend on webpack and declare no postcss got [email protected] hoisted, in a workspace whose root pins postcss: 8.5.10. Each of those importers then also hoisted [email protected] for the required postcss peer of the cssnano it had just hoisted, so which of the two won the postcss alias came down to ordering.

Measured on vercel/next.js@dcf242a1 with both stacks run back to back — full re-resolution, same tree:

before after
pnpm-lock.yaml diff, TS vs pacquet 718 lines 138 lines
snapshots: keys only in one stack 36 TS / 4 pacquet 0 TS / 3 pacquet
importer blocks that differ 4 0
[email protected] references, TS lockfile 98 2

The 3 remaining pacquet-only keys ([email protected], @2.32.0, @napi-rs/[email protected]) are cases where pacquet keeps a second instance the TypeScript CLI deduplicates. Separate issue, not touched here.

Related to #13320.

Squash Commit Body

Two peer-hoisting fixes, in both the TypeScript CLI and pacquet.

overrides now govern peers pnpm auto-installs. Overrides are applied by
the read-package hook, which only sees manifests; a peer nobody declares
never passes through one, so it resolved against its declared peer range
and could introduce a second copy of the package the override pinned.
The required-peer picker now consults the override set first. The
per-edge lookup that backs the hook is factored out and shared, so the
two paths cannot drift: hooks/read-package-hook exports
createDependencyOverrider, and pacquet's VersionsOverrider grows
override_for_undeclared_dependency. Parent-scoped overrides cannot apply
(no parent manifest), and a convergence override still applies only when
its version satisfies the edge's range. The convergence collector does
not see these edges — a range no manifest declares would skew the
staleness verdict. An override redirects a hoist rather than
creating one: without autoInstallPeers, a peer neither the graph nor the
workspace root provides stays uninstalled. The overrider is handed the
directory of the importer the peer is hoisted into, so a link: / file:
target stays relative to it.

getHoistableOptionalPeers now bounds its candidates by the workspace
root's own specifier for the package, the same input hoistPeers
short-circuits on. It previously maximised over every version in the
graph, so an optional peer declared as `*` — the shape
peerDependenciesMeta produces — pulled the newest version any importer
had resolved into a sibling that declares nothing, next to the version
the root pins. The alias-then-package-name precedence for finding that
root dependency is now one helper shared by both pickers, and the root's
specifier is read through getPeerVersionRange so a workspace: range or an
npm: alias bounds the candidates as well.

Measured on vercel/next.js: the lockfile diff between the two stacks
drops from 718 to 138 lines, the two stacks' resolved package key sets
and every importer block now match, and the only remaining difference is
three snapshot instances pacquet does not deduplicate.

Related to pnpm/pnpm#13320.

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-opus-5).

Summary by CodeRabbit

  • Bug Fixes
    • Auto-installed optional peer dependencies now respect the workspace root’s allowed versions, preventing conflicting duplicate installs.
    • Overrides are applied consistently to auto-installed peers, including local/link targets, hoist redirection for deduplication, and - to remove unwanted edges.
  • Documentation
    • Clarified that overrides also apply to peers automatically installed via autoInstallPeers.
  • Tests
    • Expanded coverage for override-driven peer hoisting and workspace-root version bounding behavior (including cases with and without version info).

…s pin to hoisted peers

Two peer-hoisting fixes, in both the TypeScript CLI and pacquet.

overrides now govern peers pnpm auto-installs. Overrides are applied by
the read-package hook, which only sees manifests; a peer nobody declares
never passes through one, so it resolved against its declared peer range
and could introduce a second copy of the package the override pinned.
The required-peer picker now consults the override set first. The
per-edge lookup that backs the hook is factored out and shared, so the
two paths cannot drift: hooks/read-package-hook exports
createDependencyOverrider, and pacquet's VersionsOverrider grows
override_for_undeclared_dependency. Parent-scoped overrides cannot apply
(no parent manifest), and a convergence override still applies only when
its version satisfies the edge's range. The convergence collector does
not see these edges — a range no manifest declares would skew the
staleness verdict.

getHoistableOptionalPeers now bounds its candidates by the workspace
root's own specifier for the package, the same input hoistPeers
short-circuits on. It previously maximised over every version in the
graph, so an optional peer declared as `*` — the shape
peerDependenciesMeta produces — pulled the newest version any importer
had resolved into a sibling that declares nothing, next to the version
the root pins. The alias-then-package-name precedence for finding that
root dependency is now one helper shared by both pickers.

Measured on vercel/next.js: the lockfile diff between the two stacks
drops from 718 to 138 lines, the two stacks' resolved package key sets
and every importer block now match, and the only remaining difference is
three snapshot instances pacquet does not deduplicate.

Related to #13320.

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

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

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes thread dependency-edge overrides through TypeScript and Rust resolution paths. Required peer hoisting now supports rewritten or removed specifiers, while optional peer selection respects compatible workspace-root dependency ranges.

Changes

Peer resolution behavior

Layer / File(s) Summary
Dependency override provider
pnpm11/hooks/read-package-hook/src/..., pnpm11/hooks/read-package-hook/test/...
Adds reusable override resolution for generic, convergence, local-target, and removal cases, with tests.
TypeScript resolver wiring
pnpm11/installing/deps-installer/..., pnpm11/installing/deps-resolver/...
Threads overrideBareSpecifier through dependency resolution and applies workspace-root ranges during peer hoisting.
Rust hoisting contracts and selection
pnpm/crates/resolving-deps-resolver/src/...
Adds the Rust override hook, deterministic workspace-root matching, and optional-peer filtering by root ranges.
Rust override integration
pnpm/crates/package-manager/src/...
Resolves overrides for undeclared dependency edges and passes them into fresh-lockfile importer resolution.
Behavior changesets
.changeset/*
Documents patch releases and updated auto-installed peer and workspace-root hoisting behavior.

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

Sequence Diagram(s)

sequenceDiagram
  participant Installer
  participant OverrideProvider
  participant DependencyResolver
  participant PeerHoister
  participant WorkspaceRoot
  Installer->>OverrideProvider: create bare-specifier override
  Installer->>DependencyResolver: resolve dependencies with override hook
  DependencyResolver->>PeerHoister: hoist required and optional peers
  PeerHoister->>WorkspaceRoot: read root dependency range
  WorkspaceRoot-->>PeerHoister: return allowed range
  PeerHoister-->>DependencyResolver: return overridden and bounded peer results
Loading

Possibly related issues

Possibly related PRs

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

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13320-2

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 peer hoisting to honor overrides and workspace-root pins

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Apply overrides when auto-installing missing peers to prevent duplicate versions.
• Bound optional-peer hoisting by the workspace root’s own specifier when enabled.
• Add shared override helpers and regression tests across Rust (pacquet) and TypeScript (pnpm).
Diagram

graph TD
  OVR{{"overrides"}} --> RPH["read-package-hook"] --> OVRDR["Dependency overrider"] --> HOIST["peer hoisting"] --> LOCK[("lockfile / graph")]
  ROOT{{"workspace root deps"}} --> HOIST --> PREF[("preferred versions")]

  subgraph Legend
    direction LR
    _cfg{{"Config"}} ~~~ _mod["Module"] ~~~ _data[("Data")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Synthetic manifest rewrite for auto-installed peers
  • ➕ Reuses the existing read-package hook pipeline end-to-end
  • ➕ Avoids introducing a second override application path
  • ➖ Artificial manifests are easy to get subtly wrong (scope, dir, peer semantics)
  • ➖ Harder to reason about parent-scoped overrides and convergence range recording
2. Apply overrides only at final resolution / lockfile write stage
  • ➕ Centralizes override effects in one place
  • ➕ Minimizes changes to hoisting heuristics
  • ➖ Too late to influence peer selection/hoisting decisions; duplicates may already exist
  • ➖ Can create surprising graph shapes if selection and rewrite disagree
3. Always maximize optional peers, then post-filter by root constraints
  • ➕ Keeps the optional-peer picker simple
  • ➕ Might preserve more dedup opportunities in non-root mode
  • ➖ Still risks non-determinism/alias contention before filtering
  • ➖ Does extra work and can retain the wrong instance if ordering matters

Recommendation: The PR’s approach is the best trade-off: it makes the required-peer picker consult overrides before the workspace-root short-circuit, and it constrains optional-peer hoisting using the same root-deps signal already used for required peers. Factoring override selection into shared helpers (TS) and a dedicated method (Rust) reduces drift risk while keeping convergence-range recording correct (only for declared edges).

Files changed (20) +469 / -78

Enhancement (2) +3 / -1
lib.rsExport DependencyOverrider type from resolver crate +2/-1

Export DependencyOverrider type from resolver crate

• Re-exports the new 'DependencyOverrider' so downstream crates can pass override callbacks into resolution/hoisting.

pnpm/crates/resolving-deps-resolver/src/lib.rs

index.tsExport createDependencyOverrider from hooks package +1/-0

Export createDependencyOverrider from hooks package

• Re-exports the new dependency-level overrider factory and its type for downstream consumers.

pnpm11/hooks/read-package-hook/src/index.ts

Bug fix (10) +255 / -68
install_with_fresh_lockfile.rsPlumb override resolver into dependency resolution options +14/-2

Plumb override resolver into dependency resolution options

• Introduces an 'override_bare_specifier' callback (built from 'VersionsOverrider') and passes it into 'ResolveImporterOptions' so hoisted peers can consult overrides even without a manifest edge.

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

overrides.rsAdd override lookup for undeclared (auto-installed) dependency edges +27/-0

Add override lookup for undeclared (auto-installed) dependency edges

• Adds 'override_for_undeclared_dependency()' to apply generic and convergence overrides to edges with no declaring manifest (auto-installed peers), explicitly excluding parent-scoped overrides and keeping convergence-range recording accurate.

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

hoist_peers.rsHonor overrides and workspace-root bounds during peer hoisting +45/-12

Honor overrides and workspace-root bounds during peer hoisting

• Adds a 'DependencyOverrider' hook for missing required peers (including support for dropping peers via '"-"') and applies it before workspace-root short-circuiting. Updates optional-peer hoisting to filter candidate versions by the workspace root’s specifier (when available) and factors out stable root-dep selection logic.

pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs

resolve_importer.rsThread override callback through importer hoist state +17/-2

Thread override callback through importer hoist state

• Extends 'ResolveImporterOptions' and 'ImporterHoistState' to carry an optional override callback into 'hoist_peers'. When resolving peers from workspace root, also passes workspace-root deps into the optional-peer picker so it respects the root’s constraints.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs

createVersionsOverrider.tsFactor override selection and add createDependencyOverrider() API +102/-43

Factor override selection and add createDependencyOverrider() API

• Refactors override splitting/selection into shared helpers and adds 'createDependencyOverrider()' for resolving overrides on a single dependency edge without a manifest (auto-installed peers). Keeps convergence override semantics (only apply when pinned version satisfies the declared range) and separates convergence-range recording from bare-specifier selection.

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts

getPeerDependencyIssues.tsPass dependency overrider into peer-issues resolution +2/-1

Pass dependency overrider into peer-issues resolution

• Plumbs 'overrideBareSpecifier' into dependency resolution when computing peer dependency issues, ensuring the peer graph matches install behavior under overrides.

pnpm11/installing/deps-installer/src/getPeerDependencyIssues.ts

index.tsPass dependency overrider into install resolution context +2/-0

Pass dependency overrider into install resolution context

• Provides 'overrideBareSpecifier' to the resolver using 'createDependencyOverrider(parsedOverrides, lockfileDir)', enabling override-aware hoisting for auto-installed peers during installs.

pnpm11/installing/deps-installer/src/install/index.ts

hoistPeers.tsApply overrides before root short-circuit; bound optional peers by root range +41/-7

Apply overrides before root short-circuit; bound optional peers by root range

• Adds an optional 'overrideBareSpecifier' callback for required peer picks (including dropping peers with ''-''). Updates optional-peer hoisting to optionally constrain candidate versions by the workspace root’s specifier and introduces stable root-dep selection logic shared with required peers.

pnpm11/installing/deps-resolver/src/hoistPeers.ts

resolveDependencies.tsThread overrideBareSpecifier and root deps into optional-peer hoisting +3/-1

Thread overrideBareSpecifier and root deps into optional-peer hoisting

• Extends 'ResolutionContext' to include 'overrideBareSpecifier', passes it into 'hoistPeers', and updates 'getHoistableOptionalPeers' calls to provide 'workspaceRootDeps' so optional peers respect the root’s pinned range.

pnpm11/installing/deps-resolver/src/resolveDependencies.ts

resolveDependencyTree.tsExpose overrideBareSpecifier option through dependency tree resolution +2/-0

Expose overrideBareSpecifier option through dependency tree resolution

• Adds 'overrideBareSpecifier' to 'ResolveDependenciesOptions' and forwards it into the resolution context so hoisting logic can apply overrides consistently.

pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts

Tests (6) +195 / -9
tests.rsTests for undeclared-dependency override selection semantics +38/-0

Tests for undeclared-dependency override selection semantics

• Adds unit tests covering generic overrides, ignoring parent-scoped overrides, and convergence overrides only applying when the pinned version satisfies the peer range.

pnpm/crates/package-manager/src/overrides/tests.rs

tests.rsRegression tests for override-aware required peers and root-bounded optional peers +78/-7

Regression tests for override-aware required peers and root-bounded optional peers

• Updates helper options to include the new overrider, adjusts optional-peer tests for the new function signature, and adds new tests asserting overridden required peers, dropped peers, and workspace-root-bounded optional-peer selection.

pnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rs

tests.rsUpdate importer option defaults for new override field +1/-0

Update importer option defaults for new override field

• Adds 'override_bare_specifier: None' to test option builders to match the expanded 'ResolveImporterOptions' struct.

pnpm/crates/resolving-deps-resolver/src/resolve_importer/tests.rs

tests.rsUpdate workspace importer options for new override field +1/-0

Update workspace importer options for new override field

• Adds 'override_bare_specifier: None' to workspace test helpers to keep compilation and defaults consistent with the new resolution option.

pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs

createVersionOverrider.test.tsAdd tests for createDependencyOverrider() behavior +31/-2

Add tests for createDependencyOverrider() behavior

• Adds Jest tests confirming generic overrides apply, parent-scoped overrides are ignored (no manifest parent), and convergence overrides apply only when satisfying the edge’s range.

pnpm11/hooks/read-package-hook/test/createVersionOverrider.test.ts

hoistPeers.test.tsRegression tests for override-aware peer hoisting and root-bounded optional peers +46/-0

Regression tests for override-aware peer hoisting and root-bounded optional peers

• Adds tests verifying required peers honor overrides (including peer removal) and optional peers with '*' stay within the workspace root’s pinned range when provided.

pnpm11/installing/deps-resolver/test/hoistPeers.test.ts

Documentation (2) +16 / -0
optional-peer-hoist-respects-workspace-root.mdChangeset: optional peer hoist respects workspace-root pin +7/-0

Changeset: optional peer hoist respects workspace-root pin

• Adds a release note describing the fix where hoisted optional peers no longer violate the workspace root’s version range when resolving peers from workspace root.

.changeset/optional-peer-hoist-respects-workspace-root.md

overrides-reach-auto-installed-peers.mdChangeset: overrides apply to auto-installed peers +9/-0

Changeset: overrides apply to auto-installed peers

• Adds a release note documenting that 'overrides' now affect peers installed via 'autoInstallPeers', preventing duplicate versions when an override pins a package.

.changeset/overrides-reach-auto-installed-peers.md

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The new follow-up fixes appear sound, but the outstanding Pacquet workspace-root range loss should be resolved before merging.

Pacquet still removes versioned workspace: root specifiers while constructing the root dependency inputs, leaving optional-peer selection unable to enforce that root range; the other previously reported override and scheme-parsing defects are fixed at current HEAD.

Files Needing Attention: pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs

Reviews (7): Last reviewed commit: "perf(read-package-hook): skip the overri..." | Re-trigger Greptile

@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.1±0.32ms    33.7 MB/sec    1.04     11.6±0.04ms    32.4 MB/sec
packument/parse                1.00     37.1±0.08µs  1789.7 MB/sec    1.00     37.2±0.21µs  1785.2 MB/sec
tarball/download_dependency    1.04      2.3±0.10ms  1861.0 KB/sec    1.00      2.2±0.07ms  1940.2 KB/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. TS root pin can be skipped ✓ Resolved 🐞 Bug ≡ Correctness
Description
In pnpm’s peer-hoisting resolver, workspace-root dependency selection can return a pkgName/pkg_name
match even when its normalizedBareSpecifier/normalized_bare_specifier is missing, causing
hoistPeers/hoist_peers and getHoistableOptionalPeers to miss a valid root specifier for the same
package. This leaves optional/peer hoisting unbounded by the workspace root’s intended pin,
undermining the PR’s new “root specifier bounds hoisting” behavior.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R30-35]

+    const rootBareSpecifier = findWorkspaceRootDep(opts.workspaceRootDeps, peerName)?.normalizedBareSpecifier
+    // Without autoInstallPeers, hoisting only deduplicates a package the graph
+    // or the workspace root already provides. An override redirects such a
+    // hoist; it must never create one, or disabling autoInstallPeers would
+    // still install a peer nobody depends on.
+    if (!opts.autoInstallPeers && !rootBareSpecifier && !opts.allPreferredVersions![peerName]) continue
Relevance

⭐⭐⭐ High

Team often accepts resolver correctness fixes around alias/pkg-name matching to avoid missing
intended pins.

PR-#12558

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper (findWorkspaceRootDep/find_workspace_root_dep) only guards normalizedBareSpecifier for
alias matches, but its pkg-name fallback returns the lexicographically-first alias without filtering
out entries where the normalized specifier is undefined/None, even though WorkspaceRootDep documents
that normalized_bare_specifier: None should mean “not a candidate.” Because the optional-peer
bounding logic depends on the presence of that normalized specifier, returning a None/undefined
entry can cause callers to miss another workspace-root entry for the same package that does have a
usable specifier and thus fail to apply the intended workspace-root bound.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[6-11]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[30-35]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[105-114]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[140-149]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[12-25]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[67-76]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[223-239]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[182-185]

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

## Issue description
`findWorkspaceRootDep` / `find_workspace_root_dep` can select a workspace-root dep entry via the pkgName/pkg_name fallback whose `normalizedBareSpecifier` / `normalized_bare_specifier` is missing (even though such entries are documented/treated as “not a candidate”), despite another entry for the same package having a defined specifier. Callers then treat the workspace root as not bounding that peer (including optional peers), which undermines the PR’s new behavior that uses the workspace root’s specifier to constrain hoisting.

## Issue Context
The PR introduces/relies on workspace-root specifiers to bound or short-circuit peer (and optional-peer) selection; however, the pkg-name fallback currently picks the lexicographically-first alias regardless of whether a normalized specifier exists, so the bounding logic can be skipped even when a valid root specifier is available for the same package.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[140-149]
- pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[223-239]

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



Remediation recommended

2. Eager override preprocessing 🐞 Bug ➹ Performance ⭐ New
Description
createDependencyOverrider() always calls splitOverrides() (which builds per-override localTarget
data) even when it will immediately return undefined for override sets that can’t affect undeclared
edges (e.g. parent-scoped-only overrides). This adds avoidable CPU/allocation overhead in
install/peer-issue setup paths for large override sets.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R43-45]

+): DependencyOverrider | undefined {
+  const { genericVersionOverrides, convergeVersions } = splitOverrides(overrides, rootDir)
+  if (genericVersionOverrides.length === 0 && convergeVersions.size === 0) return undefined
Relevance

⭐⭐⭐ High

Team often accepts skipping unnecessary work/allocations on hot paths via early guards and gating
heavy preprocessing.

PR-#12491
PR-#12777
PR-#12538

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The overrider tries to return undefined for sets that can’t affect undeclared dependencies, but it
still performs the full split/mapping work first; splitOverrides() constructs localTarget for
every explicit override regardless of whether createDependencyOverrider() will discard the result.

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[40-55]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[79-96]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[106-118]
pnpm11/hooks/read-package-hook/test/createVersionOverrider.test.ts[922-927]

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

### Issue description
`createDependencyOverrider()` calls `splitOverrides()` unconditionally, but then may return `undefined` when the override set cannot ever claim an undeclared dependency (notably: parent-scoped-only overrides). `splitOverrides()` eagerly maps every explicit override to add `localTarget` (via `createLocalTarget()`), so the function still does unnecessary preprocessing in precisely the cases it intends to optimize.

### Issue Context
This is setup-time overhead (not per-peer), but it can still be noticeable for large override sets and repeated construction in install/peer-issue code paths.

### Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[40-55]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[79-96]

### Suggested fix approach
- Add a cheap pre-scan in `createDependencyOverrider()` to detect whether **any** override could apply to an undeclared edge (i.e., any `converge === true` OR any explicit override with `parentPkg == null`). If none, return `undefined` **before** calling `splitOverrides()`.
- Alternatively, refactor `splitOverrides()` to first partition into parent-scoped vs generic vs converge without building `localTarget`, and only then map the needed subset to attach `localTarget`.

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


3. Empty override callback overhead 🐞 Bug ➹ Performance
Description
In the TypeScript resolver, hoistPeers() now calls overrideBareSpecifier for each missing required
peer whenever autoInstallPeers is enabled or a workspace-root pin exists; since callers always pass
createDependencyOverrider(...), this adds avoidable per-peer work even when there are no overrides
configured. The created overrider currently allocates via .filter() in pickVersionOverride() on
every invocation, which is in the dependency-resolution hot path.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R31-38]

+    // An override redirects a hoist; it must never create one, or disabling
+    // autoInstallPeers would still install a peer nobody depends on. Only the
+    // workspace root's own dependency hoists a peer that autoInstallPeers is
+    // not asking for, so that is the one hoist an override still governs here;
+    // the deduplication below installs nothing new either way.
+    const overridden = opts.autoInstallPeers || rootBareSpecifier
+      ? opts.overrideBareSpecifier?.(peerName, range)
+      : undefined
Relevance

⭐⭐⭐ High

Team often accepts hot-path allocation/extra-call reductions; similar perf suggestions merged in
deps-resolver/package-requester.

PR-#12491
PR-#11373

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The focused hunk adds a per-peer override callback invocation. Current wiring constructs and passes
an overrider unconditionally during install/peer-issues computation, and that overrider always
executes pickVersionOverride(), which allocates arrays via .filter() each time it runs.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[29-44]
pnpm11/installing/deps-installer/src/install/index.ts[1585-1591]
pnpm11/installing/deps-installer/src/getPeerDependencyIssues.ts[74-86]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-49]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-242]

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

### Issue description
`hoistPeers()` now consults `opts.overrideBareSpecifier` per missing peer. Callers currently always pass an overrider created by `createDependencyOverrider(...)`, even when the parsed overrides set is empty, so each missing peer incurs extra callback overhead (including allocations from `.filter()` calls).

### Issue Context
This is a performance-only issue on a hot path (dependency resolution / peer-hoist loop). Rust already avoids this cost by not constructing/passing an overrider when the override set is empty; TS should mirror that fast path.

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[31-38]

### Suggested fix
- Make `createDependencyOverrider()` return `undefined` (or a cheap constant no-op) when `overrides` contains no generic overrides and `convergeVersions.size === 0`.
- Update call sites to pass `overrideBareSpecifier` only when non-empty (e.g. `overrideBareSpecifier: overrides.length ? createDependencyOverrider(...) : undefined`).
- Optionally: inside `createDependencyOverrider`, avoid calling `pickVersionOverride` when both override lists are empty to prevent per-call `.filter()` allocations.

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


4. Root dep sort hot-path ✓ Resolved 🐞 Bug ➹ Performance
Description
In pnpm11, findWorkspaceRootDep() filters workspaceRootDeps into a new array on every call and,
on the pkgName fallback path, allocates again and sorts to pick the smallest alias. Because it’s
called inside the hoistPeers() loop (and also from getHoistableOptionalPeers()), this adds
repeated allocation and conditional O(k log k) work on the dependency-resolution hot path.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R146-150]

+  const candidates = workspaceRootDeps.filter((rootDep) => rootDep.normalizedBareSpecifier)
+  return candidates.find((rootDep) => rootDep.alias === peerName) ??
+    candidates
+      .filter((rootDep) => rootDep.pkgName === peerName)
+      .sort((rootDep1, rootDep2) => lexCompare(rootDep1.alias, rootDep2.alias))[0]
Relevance

⭐⭐⭐ High

Repo has accepted deps-resolver hot-path perf fixes reducing allocations/quadratic work; this is a
small deterministic optimization.

PR-#12491
PR-#11373

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper performs an eager filter() allocation and then a fallback filter().sort() selection.
It is called inside the required-peer hoisting loop, so this work repeats for each missing peer, and
the same helper is also used when selecting hoistable optional peers.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[29-36]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[111-121]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[142-151]

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

### Issue description
`findWorkspaceRootDep()` currently builds intermediate arrays and uses `.sort(...)[0]` to pick the lexicographically-first alias among pkgName matches. This runs in peer-hoisting loops and adds avoidable allocations and conditional sorting work.

### Issue Context
This helper is invoked per missing required peer in `hoistPeers()` and per missing optional peer in `getHoistableOptionalPeers()`. The current implementation:
- allocates `candidates` via `filter()` every call
- if no alias match is found, allocates again and sorts to find the minimum alias

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[142-151]

### Suggested fix
Rewrite `findWorkspaceRootDep()` as a single pass over `workspaceRootDeps`:
- skip entries without `normalizedBareSpecifier`
- if `alias === peerName`, return immediately
- otherwise, track the best pkgName match by keeping the current minimum `alias` (via `lexCompare`) without sorting

Optionally, if profiling shows it matters, consider building an index/map once per resolution rather than rescanning per peer.

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


View more (1)
5. Local override path leaks ✓ Resolved 🐞 Bug ⛨ Security
Description
Auto-installed peers now consult overrides without an importer/package directory, so relative
link:/file: overrides can fall back to an absolute filesystem path (non-portable; can leak host
paths into lockfiles). In pnpm11 this path is also not normalized when absolute, which can produce
backslashes on Windows and break the expected link:/file: forward-slash form.
Code

pnpm/crates/package-manager/src/overrides.rs[R385-392]

+        if let Some(chosen) = self.choose_override(&[], dep_name, dep_spec) {
+            if chosen.inner.new_bare_specifier == "-" {
+                return Some("-".to_string());
+            }
+            return Some(chosen.local_target.as_ref().map_or_else(
+                || chosen.inner.new_bare_specifier.clone(),
+                |target| resolve_local_override_spec(target, None),
+            ));
Relevance

⭐⭐⭐ High

Analogous bug accepted: relative local/path specifiers without base-dir can leak/duplicate; team
fixed similar cross-importer issue.

PR-#13343

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new override path for undeclared/auto-installed peers explicitly renders local overrides without
directory context, and both implementations’ local-override renderers return absolute paths when
that context is missing. This can propagate into the hoisted-peer dependency specifier used during
resolution (and ultimately lockfile output), making results machine-dependent.

pnpm/crates/package-manager/src/overrides.rs[371-396]
pnpm/crates/package-manager/src/overrides.rs[560-576]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[58-76]
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[509-526]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-49]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[242-252]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[13-36]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[405-470]
PR-#13343

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

### Issue description
Auto-installed peers now apply overrides via a new “dependency overrider” path, but that path does not receive the importer/package directory. For local overrides (`link:`/`file:`) this causes the resolver to emit an absolute path (Rust) or an absolute, non-normalized path (pnpm11 TS), which is non-portable and can leak machine-specific filesystem layout into lockfiles.

### Issue Context
- Rust: `override_for_undeclared_dependency()` renders local overrides via `resolve_local_override_spec(target, None)`, and `resolve_local_override_spec(..., None)` emits the normalized **absolute** path.
- pnpm11 TS: `createDependencyOverrider()` supports an optional `dir`, but `hoistPeers()` calls `overrideBareSpecifier(peerName, range)` with no `dir`, so `resolveLocalOverride(..., undefined)` returns `absolutePath` (and does not `normalize-path` it).

### Fix Focus Areas
- pnpm/crates/package-manager/src/overrides.rs[371-396]
- pnpm/crates/package-manager/src/overrides.rs[560-576]
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[509-526]
- pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[33-47]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-49]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[242-252]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[13-36]
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[405-465]

### Suggested direction
1) **Rust**: extend the overrider API to accept an optional `pkg_dir` (or importer project dir) and pass `Some(&self.project_dir)` from `resolve_importer` when hoisting missing peers. Then call `resolve_local_override_spec(target, Some(pkg_dir))` so relative local overrides stay relative and stable.
2) **pnpm11 TS**: when calling `hoistPeers` per importer, wrap `ctx.overrideBareSpecifier` to pass the importer dir: `(name, range) => ctx.overrideBareSpecifier?.(name, range, options.dir)`; alternatively change the `overrideBareSpecifier` signature in the resolver context/hoistPeers to accept `dir`.
3) Additionally, make `resolveLocalOverride` normalize the absolute-path branch (e.g. `normalizePath(absolutePath)`) as a defense-in-depth so Windows doesn’t emit backslashes if an absolute path is ever returned.

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



Informational

6. pickVersionOverride has four parameters ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
pickVersionOverride is declared with 4 positional parameters, exceeding the 3-parameter limit and
making call sites harder to read and maintain. This should be refactored to take a single options
object (or otherwise reduce parameter count).
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R230-235]

+function pickVersionOverride (
+  versionOverrides: VersionOverrideWithParent[],
+  genericVersionOverrides: VersionOverride[],
+  name: string,
+  bareSpecifier: string
+): VersionOverride | undefined {
Relevance

⭐ Low

3-parameter TS limit refactor suggestions were previously rejected for analogous override helper
functions.

PR-#12876

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713433 limits TypeScript functions to 3 parameters or fewer. The new
pickVersionOverride declaration introduces 4 parameters (versionOverrides,
genericVersionOverrides, name, bareSpecifier).

Rule 713433: Limit TypeScript functions to three parameters or fewer
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-235]

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

## Issue description
`pickVersionOverride` takes 4 positional parameters, violating the 3-parameter limit.

## Issue Context
This helper is used from multiple call sites (`createDependencyOverrider`, `overrideDeps`) and can be made clearer/safer by switching to a single options parameter.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[41-48]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[158-160]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-240]

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


7. Missing trailing commas in params 📘 Rule violation ⚙ Maintainability
Description
Several multi-line TypeScript parameter lists added/modified in this PR omit the trailing comma
after the last parameter. This violates the trailing-comma requirement and increases diff noise in
future edits.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R35-38]

+export function createDependencyOverrider (
+  overrides: VersionOverrideWithoutRawSelector[],
+  rootDir: string
+): DependencyOverrider {
Relevance

⭐ Low

Trailing-comma rule enforcement was previously rejected for this same file/pattern.

PR-#12876
PR-#13288

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TS constructs. The updated function
signatures (e.g., createDependencyOverrider and getHoistableOptionalPeers) place parameters on
separate lines but do not include a trailing comma after the final parameter.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-38]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[91-95]

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

## Issue description
Multi-line TypeScript parameter lists are missing trailing commas on the last parameter.

## Issue Context
The repo requires trailing commas for multi-line TS constructs to reduce diff churn when adding/reordering parameters.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-38]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[51-55]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[182-187]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[198-202]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[220-224]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-235]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[91-95]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[133-136]

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

Results up to commit 822f7ee ⚖️ Balanced


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


Remediation recommended
1. Local override path leaks ✓ Resolved 🐞 Bug ⛨ Security
Description
Auto-installed peers now consult overrides without an importer/package directory, so relative
link:/file: overrides can fall back to an absolute filesystem path (non-portable; can leak host
paths into lockfiles). In pnpm11 this path is also not normalized when absolute, which can produce
backslashes on Windows and break the expected link:/file: forward-slash form.
Code

pnpm/crates/package-manager/src/overrides.rs[R385-392]

+        if let Some(chosen) = self.choose_override(&[], dep_name, dep_spec) {
+            if chosen.inner.new_bare_specifier == "-" {
+                return Some("-".to_string());
+            }
+            return Some(chosen.local_target.as_ref().map_or_else(
+                || chosen.inner.new_bare_specifier.clone(),
+                |target| resolve_local_override_spec(target, None),
+            ));
Relevance

⭐⭐⭐ High

Analogous bug accepted: relative local/path specifiers without base-dir can leak/duplicate; team
fixed similar cross-importer issue.

PR-#13343

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new override path for undeclared/auto-installed peers explicitly renders local overrides without
directory context, and both implementations’ local-override renderers return absolute paths when
that context is missing. This can propagate into the hoisted-peer dependency specifier used during
resolution (and ultimately lockfile output), making results machine-dependent.

pnpm/crates/package-manager/src/overrides.rs[371-396]
pnpm/crates/package-manager/src/overrides.rs[560-576]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[58-76]
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[509-526]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-49]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[242-252]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[13-36]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[405-470]
PR-#13343

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

### Issue description
Auto-installed peers now apply overrides via a new “dependency overrider” path, but that path does not receive the importer/package directory. For local overrides (`link:`/`file:`) this causes the resolver to emit an absolute path (Rust) or an absolute, non-normalized path (pnpm11 TS), which is non-portable and can leak machine-specific filesystem layout into lockfiles.

### Issue Context
- Rust: `override_for_undeclared_dependency()` renders local overrides via `resolve_local_override_spec(target, None)`, and `resolve_local_override_spec(..., None)` emits the normalized **absolute** path.
- pnpm11 TS: `createDependencyOverrider()` supports an optional `dir`, but `hoistPeers()` calls `overrideBareSpecifier(peerName, range)` with no `dir`, so `resolveLocalOverride(..., undefined)` returns `absolutePath` (and does not `normalize-path` it).

### Fix Focus Areas
- pnpm/crates/package-manager/src/overrides.rs[371-396]
- pnpm/crates/package-manager/src/overrides.rs[560-576]
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[509-526]
- pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[33-47]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-49]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[242-252]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[13-36]
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[405-465]

### Suggested direction
1) **Rust**: extend the overrider API to accept an optional `pkg_dir` (or importer project dir) and pass `Some(&self.project_dir)` from `resolve_importer` when hoisting missing peers. Then call `resolve_local_override_spec(target, Some(pkg_dir))` so relative local overrides stay relative and stable.
2) **pnpm11 TS**: when calling `hoistPeers` per importer, wrap `ctx.overrideBareSpecifier` to pass the importer dir: `(name, range) => ctx.overrideBareSpecifier?.(name, range, options.dir)`; alternatively change the `overrideBareSpecifier` signature in the resolver context/hoistPeers to accept `dir`.
3) Additionally, make `resolveLocalOverride` normalize the absolute-path branch (e.g. `normalizePath(absolutePath)`) as a defense-in-depth so Windows doesn’t emit backslashes if an absolute path is ever returned.

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



Informational
2. Missing trailing commas in params 📘 Rule violation ⚙ Maintainability
Description
Several multi-line TypeScript parameter lists added/modified in this PR omit the trailing comma
after the last parameter. This violates the trailing-comma requirement and increases diff noise in
future edits.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R35-38]

+export function createDependencyOverrider (
+  overrides: VersionOverrideWithoutRawSelector[],
+  rootDir: string
+): DependencyOverrider {
Relevance

⭐ Low

Trailing-comma rule enforcement was previously rejected for this same file/pattern.

PR-#12876
PR-#13288

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TS constructs. The updated function
signatures (e.g., createDependencyOverrider and getHoistableOptionalPeers) place parameters on
separate lines but do not include a trailing comma after the final parameter.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-38]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[91-95]

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

## Issue description
Multi-line TypeScript parameter lists are missing trailing commas on the last parameter.

## Issue Context
The repo requires trailing commas for multi-line TS constructs to reduce diff churn when adding/reordering parameters.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-38]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[51-55]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[182-187]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[198-202]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[220-224]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-235]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[91-95]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[133-136]

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


3. pickVersionOverride has four parameters ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
pickVersionOverride is declared with 4 positional parameters, exceeding the 3-parameter limit and
making call sites harder to read and maintain. This should be refactored to take a single options
object (or otherwise reduce parameter count).
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R230-235]

+function pickVersionOverride (
+  versionOverrides: VersionOverrideWithParent[],
+  genericVersionOverrides: VersionOverride[],
+  name: string,
+  bareSpecifier: string
+): VersionOverride | undefined {
Relevance

⭐ Low

3-parameter TS limit refactor suggestions were previously rejected for analogous override helper
functions.

PR-#12876

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713433 limits TypeScript functions to 3 parameters or fewer. The new
pickVersionOverride declaration introduces 4 parameters (versionOverrides,
genericVersionOverrides, name, bareSpecifier).

Rule 713433: Limit TypeScript functions to three parameters or fewer
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-235]

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

## Issue description
`pickVersionOverride` takes 4 positional parameters, violating the 3-parameter limit.

## Issue Context
This helper is used from multiple call sites (`createDependencyOverrider`, `overrideDeps`) and can be made clearer/safer by switching to a single options parameter.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[41-48]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[158-160]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-240]

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


Results up to commit 92e60bc ⚖️ Balanced


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


Action required
1. TS root pin can be skipped ✓ Resolved 🐞 Bug ≡ Correctness
Description
In pnpm’s peer-hoisting resolver, workspace-root dependency selection can return a pkgName/pkg_name
match even when its normalizedBareSpecifier/normalized_bare_specifier is missing, causing
hoistPeers/hoist_peers and getHoistableOptionalPeers to miss a valid root specifier for the same
package. This leaves optional/peer hoisting unbounded by the workspace root’s intended pin,
undermining the PR’s new “root specifier bounds hoisting” behavior.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R30-35]

+    const rootBareSpecifier = findWorkspaceRootDep(opts.workspaceRootDeps, peerName)?.normalizedBareSpecifier
+    // Without autoInstallPeers, hoisting only deduplicates a package the graph
+    // or the workspace root already provides. An override redirects such a
+    // hoist; it must never create one, or disabling autoInstallPeers would
+    // still install a peer nobody depends on.
+    if (!opts.autoInstallPeers && !rootBareSpecifier && !opts.allPreferredVersions![peerName]) continue
Relevance

⭐⭐⭐ High

Team often accepts resolver correctness fixes around alias/pkg-name matching to avoid missing
intended pins.

PR-#12558

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper (findWorkspaceRootDep/find_workspace_root_dep) only guards normalizedBareSpecifier for
alias matches, but its pkg-name fallback returns the lexicographically-first alias without filtering
out entries where the normalized specifier is undefined/None, even though WorkspaceRootDep documents
that normalized_bare_specifier: None should mean “not a candidate.” Because the optional-peer
bounding logic depends on the presence of that normalized specifier, returning a None/undefined
entry can cause callers to miss another workspace-root entry for the same package that does have a
usable specifier and thus fail to apply the intended workspace-root bound.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[6-11]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[30-35]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[105-114]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[140-149]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[12-25]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[67-76]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[223-239]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[182-185]

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

## Issue description
`findWorkspaceRootDep` / `find_workspace_root_dep` can select a workspace-root dep entry via the pkgName/pkg_name fallback whose `normalizedBareSpecifier` / `normalized_bare_specifier` is missing (even though such entries are documented/treated as “not a candidate”), despite another entry for the same package having a defined specifier. Callers then treat the workspace root as not bounding that peer (including optional peers), which undermines the PR’s new behavior that uses the workspace root’s specifier to constrain hoisting.

## Issue Context
The PR introduces/relies on workspace-root specifiers to bound or short-circuit peer (and optional-peer) selection; however, the pkg-name fallback currently picks the lexicographically-first alias regardless of whether a normalized specifier exists, so the bounding logic can be skipped even when a valid root specifier is available for the same package.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[140-149]
- pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[223-239]

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


Results up to commit 94ba9db ⚖️ Balanced


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


Remediation recommended
1. Root dep sort hot-path ✓ Resolved 🐞 Bug ➹ Performance
Description
In pnpm11, findWorkspaceRootDep() filters workspaceRootDeps into a new array on every call and,
on the pkgName fallback path, allocates again and sorts to pick the smallest alias. Because it’s
called inside the hoistPeers() loop (and also from getHoistableOptionalPeers()), this adds
repeated allocation and conditional O(k log k) work on the dependency-resolution hot path.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R146-150]

+  const candidates = workspaceRootDeps.filter((rootDep) => rootDep.normalizedBareSpecifier)
+  return candidates.find((rootDep) => rootDep.alias === peerName) ??
+    candidates
+      .filter((rootDep) => rootDep.pkgName === peerName)
+      .sort((rootDep1, rootDep2) => lexCompare(rootDep1.alias, rootDep2.alias))[0]
Relevance

⭐⭐⭐ High

Repo has accepted deps-resolver hot-path perf fixes reducing allocations/quadratic work; this is a
small deterministic optimization.

PR-#12491
PR-#11373

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper performs an eager filter() allocation and then a fallback filter().sort() selection.
It is called inside the required-peer hoisting loop, so this work repeats for each missing peer, and
the same helper is also used when selecting hoistable optional peers.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[29-36]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[111-121]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[142-151]

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

### Issue description
`findWorkspaceRootDep()` currently builds intermediate arrays and uses `.sort(...)[0]` to pick the lexicographically-first alias among pkgName matches. This runs in peer-hoisting loops and adds avoidable allocations and conditional sorting work.

### Issue Context
This helper is invoked per missing required peer in `hoistPeers()` and per missing optional peer in `getHoistableOptionalPeers()`. The current implementation:
- allocates `candidates` via `filter()` every call
- if no alias match is found, allocates again and sorts to find the minimum alias

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[142-151]

### Suggested fix
Rewrite `findWorkspaceRootDep()` as a single pass over `workspaceRootDeps`:
- skip entries without `normalizedBareSpecifier`
- if `alias === peerName`, return immediately
- otherwise, track the best pkgName match by keeping the current minimum `alias` (via `lexCompare`) without sorting

Optionally, if profiling shows it matters, consider building an index/map once per resolution rather than rescanning per peer.

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


Results up to commit 8c0f036 ⚖️ Balanced


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


Remediation recommended
1. Empty override callback overhead 🐞 Bug ➹ Performance
Description
In the TypeScript resolver, hoistPeers() now calls overrideBareSpecifier for each missing required
peer whenever autoInstallPeers is enabled or a workspace-root pin exists; since callers always pass
createDependencyOverrider(...), this adds avoidable per-peer work even when there are no overrides
configured. The created overrider currently allocates via .filter() in pickVersionOverride() on
every invocation, which is in the dependency-resolution hot path.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R31-38]

+    // An override redirects a hoist; it must never create one, or disabling
+    // autoInstallPeers would still install a peer nobody depends on. Only the
+    // workspace root's own dependency hoists a peer that autoInstallPeers is
+    // not asking for, so that is the one hoist an override still governs here;
+    // the deduplication below installs nothing new either way.
+    const overridden = opts.autoInstallPeers || rootBareSpecifier
+      ? opts.overrideBareSpecifier?.(peerName, range)
+      : undefined
Relevance

⭐⭐⭐ High

Team often accepts hot-path allocation/extra-call reductions; similar perf suggestions merged in
deps-resolver/package-requester.

PR-#12491
PR-#11373

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The focused hunk adds a per-peer override callback invocation. Current wiring constructs and passes
an overrider unconditionally during install/peer-issues computation, and that overrider always
executes pickVersionOverride(), which allocates arrays via .filter() each time it runs.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[29-44]
pnpm11/installing/deps-installer/src/install/index.ts[1585-1591]
pnpm11/installing/deps-installer/src/getPeerDependencyIssues.ts[74-86]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[35-49]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[230-242]

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

### Issue description
`hoistPeers()` now consults `opts.overrideBareSpecifier` per missing peer. Callers currently always pass an overrider created by `createDependencyOverrider(...)`, even when the parsed overrides set is empty, so each missing peer incurs extra callback overhead (including allocations from `.filter()` calls).

### Issue Context
This is a performance-only issue on a hot path (dependency resolution / peer-hoist loop). Rust already avoids this cost by not constructing/passing an overrider when the override set is empty; TS should mirror that fast path.

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[31-38]

### Suggested fix
- Make `createDependencyOverrider()` return `undefined` (or a cheap constant no-op) when `overrides` contains no generic overrides and `convergeVersions.size === 0`.
- Update call sites to pass `overrideBareSpecifier` only when non-empty (e.g. `overrideBareSpecifier: overrides.length ? createDependencyOverrider(...) : undefined`).
- Optionally: inside `createDependencyOverrider`, avoid calling `pickVersionOverride` when both override lists are empty to prevent per-call `.filter()` allocations.

ⓘ 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 91.04478% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.22%. Comparing base (a1e3225) to head (ac9a648).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...es/resolving-deps-resolver/src/resolve_importer.rs 70.00% 3 Missing ⚠️
...package-manager/src/install_with_fresh_lockfile.rs 80.00% 2 Missing ⚠️
pnpm/crates/package-manager/src/overrides.rs 94.11% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13369   +/-   ##
=======================================
  Coverage   87.21%   87.22%           
=======================================
  Files         536      536           
  Lines       92034    92114   +80     
=======================================
+ Hits        80269    80347   +78     
- Misses      11765    11767    +2     

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

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

Inline comments:
In @.changeset/overrides-reach-auto-installed-peers.md:
- Line 9: Update the changeset description to qualify that override behavior for
auto-installed peers is limited: parent-scoped overrides do not affect
undeclared peers, and convergence overrides apply only when compatible. Keep the
existing example and behavior description, adding only a brief clarification
that not every override applies to every auto-installed peer.
- Around line 2-6: Update the changeset entries for
`@pnpm/hooks.read-package-hook`, `@pnpm/installing.deps-resolver`,
`@pnpm/installing.deps-installer`, pacquet, and pnpm from minor to patch, since
this change only fixes auto-installed peer override backfilling and introduces
no public API change.

In `@pnpm11/installing/deps-resolver/src/hoistPeers.ts`:
- Around line 105-106: Update the rootRange calculation near rootBareSpecifier
to pass the workspace protocol specifier through getPeerVersionRange() before
semver.validRange(), ensuring workspace:^ ranges produce a usable bound for
optional peer hoisting. Add a regression test covering a workspace: peer range
and confirming an incompatible newer major is not hoisted.
🪄 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: 29d89c38-4b52-48ac-ae7e-c670858f0ab2

📥 Commits

Reviewing files that changed from the base of the PR and between d01230b and 822f7ee.

📒 Files selected for processing (20)
  • .changeset/optional-peer-hoist-respects-workspace-root.md
  • .changeset/overrides-reach-auto-installed-peers.md
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/overrides.rs
  • pnpm/crates/package-manager/src/overrides/tests.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/lib.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts
  • pnpm11/hooks/read-package-hook/src/index.ts
  • pnpm11/hooks/read-package-hook/test/createVersionOverrider.test.ts
  • pnpm11/installing/deps-installer/src/getPeerDependencyIssues.ts
  • pnpm11/installing/deps-installer/src/install/index.ts
  • pnpm11/installing/deps-resolver/src/hoistPeers.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts
  • pnpm11/installing/deps-resolver/test/hoistPeers.test.ts

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: ac9a6480015b

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.533 ± 0.175 2.358 2.792 1.70 ± 0.17
pacquet@main 2.534 ± 0.165 2.342 2.764 1.70 ± 0.17
pnpr@HEAD 1.549 ± 0.186 1.350 1.785 1.04 ± 0.15
pnpr@main 1.490 ± 0.111 1.374 1.662 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.53344676752,
      "stddev": 0.17503746488706864,
      "median": 2.48891119852,
      "user": 1.51484688,
      "system": 1.31771886,
      "min": 2.35756924802,
      "max": 2.7919532680200003,
      "times": [
        2.71991140702,
        2.37528181902,
        2.42550666002,
        2.65439209702,
        2.37316560502,
        2.7919532680200003,
        2.55231573702,
        2.36091039802,
        2.35756924802,
        2.72346143602
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5337454253200002,
      "stddev": 0.16466081036830385,
      "median": 2.54898039252,
      "user": 1.51125438,
      "system": 1.2861051599999997,
      "min": 2.34159798002,
      "max": 2.7643683980200002,
      "times": [
        2.75916418302,
        2.63166211902,
        2.36436342402,
        2.7643683980200002,
        2.53531264902,
        2.63626254902,
        2.35484934502,
        2.56264813602,
        2.38722547002,
        2.34159798002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5485666961200002,
      "stddev": 0.18566053787570078,
      "median": 1.53171422452,
      "user": 1.0667137800000002,
      "system": 1.13206126,
      "min": 1.3497587850200001,
      "max": 1.78454681902,
      "times": [
        1.61113224002,
        1.3497587850200001,
        1.75740816302,
        1.45229620902,
        1.3768136850200001,
        1.63331566002,
        1.35055028202,
        1.38531717302,
        1.78454681902,
        1.7845279450200002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.49029383202,
      "stddev": 0.11083011913530623,
      "median": 1.46120289502,
      "user": 1.03471638,
      "system": 1.18208056,
      "min": 1.37360173702,
      "max": 1.66183069602,
      "times": [
        1.3834657510200001,
        1.66183069602,
        1.4096906630200001,
        1.37360173702,
        1.4440164750200002,
        1.39621952502,
        1.64798793602,
        1.47838931502,
        1.60637855002,
        1.5013576720200001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 260.4 ± 4.4 254.3 269.9 1.01 ± 0.04
pacquet@main 258.7 ± 9.1 249.9 275.7 1.00
pnpr@HEAD 271.9 ± 4.3 264.0 279.6 1.05 ± 0.04
pnpr@main 270.4 ± 6.6 256.9 279.5 1.05 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26036897752000004,
      "stddev": 0.004438356513567172,
      "median": 0.25987877812000004,
      "user": 0.22052524000000004,
      "system": 0.5355572599999999,
      "min": 0.25429433162000004,
      "max": 0.26990110762,
      "times": [
        0.26349338862000005,
        0.25989119662000004,
        0.25656215762,
        0.26029177962000005,
        0.25986635962000004,
        0.26990110762,
        0.25658866662,
        0.25429433162000004,
        0.25935476662,
        0.26344602062000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.2587050946200001,
      "stddev": 0.009118637114051965,
      "median": 0.25469112812000005,
      "user": 0.21014863999999997,
      "system": 0.5257750600000001,
      "min": 0.24993609762,
      "max": 0.27571750262000005,
      "times": [
        0.27275606462,
        0.26402187262000004,
        0.27571750262000005,
        0.25474811462,
        0.25260169962,
        0.25834335562000005,
        0.25463414162000003,
        0.25156473062,
        0.24993609762,
        0.25272736662000006
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27192443572,
      "stddev": 0.004324511533619233,
      "median": 0.27120146212000007,
      "user": 0.22348193999999996,
      "system": 0.54332236,
      "min": 0.26399779062,
      "max": 0.27955593662000006,
      "times": [
        0.27165592662000004,
        0.27590131862000006,
        0.27032998762000005,
        0.27417408062000004,
        0.27955593662000006,
        0.27074699762000004,
        0.26866406262000003,
        0.27452424862,
        0.26969400762,
        0.26399779062
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27039701962,
      "stddev": 0.00664223716927327,
      "median": 0.27227904312000006,
      "user": 0.21109583999999998,
      "system": 0.5381364599999999,
      "min": 0.25694830862,
      "max": 0.27946199062000004,
      "times": [
        0.27409819662,
        0.27946199062000004,
        0.26516227862,
        0.27188023862000005,
        0.27267784762,
        0.27532510362,
        0.26726668462000003,
        0.25694830862,
        0.26550620562000005,
        0.27564334162000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.783 ± 0.019 2.752 2.812 1.82 ± 0.15
pacquet@main 2.765 ± 0.021 2.722 2.790 1.81 ± 0.15
pnpr@HEAD 1.554 ± 0.145 1.438 1.801 1.02 ± 0.13
pnpr@main 1.526 ± 0.126 1.435 1.795 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.78305815744,
      "stddev": 0.019318863657989703,
      "median": 2.78410015224,
      "user": 1.6549562799999997,
      "system": 1.3795323999999998,
      "min": 2.75203264624,
      "max": 2.8116117432400003,
      "times": [
        2.79027135824,
        2.75203264624,
        2.76089326224,
        2.7758342482400002,
        2.79209877324,
        2.80464423624,
        2.79697224524,
        2.7779289462400003,
        2.7682941152400002,
        2.8116117432400003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7646594162400002,
      "stddev": 0.02146479480215544,
      "median": 2.7664335822400004,
      "user": 1.71397618,
      "system": 1.2790126,
      "min": 2.72203028724,
      "max": 2.79040540924,
      "times": [
        2.72203028724,
        2.77776955624,
        2.76154904524,
        2.76198725924,
        2.77087990524,
        2.73623011924,
        2.79040540924,
        2.78344824324,
        2.76130526724,
        2.78098907024
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.55391081654,
      "stddev": 0.1448644993264488,
      "median": 1.4843545252400001,
      "user": 1.04209548,
      "system": 1.1545903,
      "min": 1.4381529052400002,
      "max": 1.8009606902400002,
      "times": [
        1.50038702624,
        1.72817550824,
        1.5161314572400002,
        1.4381529052400002,
        1.4457342232400001,
        1.45272622324,
        1.74797277524,
        1.4405453322400001,
        1.4683220242400001,
        1.8009606902400002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.52641239644,
      "stddev": 0.12555039441330423,
      "median": 1.4620653857400001,
      "user": 1.00461568,
      "system": 1.1860534,
      "min": 1.43457992024,
      "max": 1.7948168632400001,
      "times": [
        1.43457992024,
        1.4429186012400002,
        1.4721574722400002,
        1.5816539092400002,
        1.45197329924,
        1.7948168632400001,
        1.5099584942400002,
        1.6937593482400002,
        1.44708113424,
        1.4352249222400002
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 603.0 ± 8.9 591.7 618.3 2.00 ± 0.05
pacquet@main 588.0 ± 16.2 566.1 614.3 1.95 ± 0.07
pnpr@HEAD 302.0 ± 6.0 293.0 313.6 1.00
pnpr@main 303.4 ± 5.4 295.1 313.1 1.00 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.60295828988,
      "stddev": 0.008874817805939366,
      "median": 0.60207593368,
      "user": 0.7420359999999999,
      "system": 0.6662763600000001,
      "min": 0.59167527718,
      "max": 0.61830043018,
      "times": [
        0.59301473818,
        0.6122418991799999,
        0.60709745618,
        0.60422469418,
        0.59761006618,
        0.61830043018,
        0.59551730018,
        0.59167527718,
        0.59992717318,
        0.60997386418
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.58800870378,
      "stddev": 0.01616860157424987,
      "median": 0.58615282318,
      "user": 0.7097576999999999,
      "system": 0.68592516,
      "min": 0.56613472318,
      "max": 0.61427984018,
      "times": [
        0.57214607618,
        0.59269974318,
        0.59780490218,
        0.58921620318,
        0.61066323018,
        0.61427984018,
        0.58308944318,
        0.58117794918,
        0.57287492718,
        0.56613472318
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30201193278000005,
      "stddev": 0.006025418434571227,
      "median": 0.30234757668,
      "user": 0.19662459999999998,
      "system": 0.52518686,
      "min": 0.29304213418,
      "max": 0.31361146118000005,
      "times": [
        0.30419258118000003,
        0.30270905118,
        0.29377497318,
        0.30174732318,
        0.30675802518,
        0.30198610218000005,
        0.31361146118000005,
        0.30384791318000004,
        0.29304213418,
        0.29844976318000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30342395398000005,
      "stddev": 0.005442859039459716,
      "median": 0.30323682468,
      "user": 0.19580919999999996,
      "system": 0.54036366,
      "min": 0.29508266118000004,
      "max": 0.31309911818,
      "times": [
        0.30302991618,
        0.30497484218000004,
        0.30898196618,
        0.29899810418,
        0.29508266118000004,
        0.29748020018000004,
        0.30208249318,
        0.31309911818,
        0.30706650518,
        0.30344373318
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.913 ± 0.011 1.894 1.930 6.48 ± 0.18
pacquet@main 1.904 ± 0.010 1.895 1.922 6.45 ± 0.18
pnpr@HEAD 0.295 ± 0.008 0.282 0.308 1.00
pnpr@main 0.306 ± 0.006 0.296 0.316 1.04 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.91267382222,
      "stddev": 0.010658533012920074,
      "median": 1.91057593192,
      "user": 0.89408854,
      "system": 0.79035756,
      "min": 1.8940877979200001,
      "max": 1.93026904892,
      "times": [
        1.93026904892,
        1.92545884492,
        1.9105313769199999,
        1.90965827492,
        1.8940877979200001,
        1.92221979492,
        1.90623919692,
        1.90536842392,
        1.91062048692,
        1.91228497592
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.90361530442,
      "stddev": 0.00958367286507265,
      "median": 1.89959644942,
      "user": 0.94397374,
      "system": 0.7652455600000001,
      "min": 1.89506974392,
      "max": 1.9219580779199998,
      "times": [
        1.91692143092,
        1.89599781892,
        1.9106822129199998,
        1.90002602192,
        1.90317587292,
        1.89506974392,
        1.89688630892,
        1.8991668769199999,
        1.8962686789199998,
        1.9219580779199998
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29535741212,
      "stddev": 0.007885676877366885,
      "median": 0.29521171492,
      "user": 0.19287604,
      "system": 0.49993745999999994,
      "min": 0.28214547292000003,
      "max": 0.30839140092,
      "times": [
        0.29696095292,
        0.29053343092,
        0.29208598992,
        0.29408553792000003,
        0.28933084092,
        0.28214547292000003,
        0.29633789192,
        0.29658675992,
        0.30839140092,
        0.30711584292
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30644883072,
      "stddev": 0.0062859882176956,
      "median": 0.30558621742000003,
      "user": 0.20176203999999998,
      "system": 0.53902566,
      "min": 0.29552896092000003,
      "max": 0.31575621492,
      "times": [
        0.30434107592,
        0.30832317192,
        0.30665830292,
        0.29552896092000003,
        0.31222824292,
        0.30025669892,
        0.30451413192,
        0.30304031192,
        0.31384119492,
        0.31575621492
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 358.3 ± 6.2 345.3 365.3 4.10 ± 0.08
pacquet@main 344.6 ± 8.0 336.3 364.0 3.95 ± 0.10
pnpr@HEAD 87.3 ± 0.9 84.6 89.0 1.00
pnpr@main 87.5 ± 1.7 83.0 91.5 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35825434678,
      "stddev": 0.006219176199411607,
      "median": 0.36008380718,
      "user": 0.34771539999999995,
      "system": 0.061521059999999995,
      "min": 0.34534523118,
      "max": 0.36533287418,
      "times": [
        0.34534523118,
        0.36181234618,
        0.35914398018,
        0.35873018218,
        0.36533287418,
        0.36102363418,
        0.35266151418,
        0.36366409618,
        0.36231641418,
        0.35251319518
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.34461403618,
      "stddev": 0.00801291982789606,
      "median": 0.34306985918,
      "user": 0.3359444,
      "system": 0.05263456,
      "min": 0.33631555818000003,
      "max": 0.36398961918,
      "times": [
        0.34220410718,
        0.33742602518,
        0.33631555818000003,
        0.35164295018,
        0.34416200718,
        0.34204933518,
        0.34419235518,
        0.34393561118,
        0.34022279318,
        0.36398961918
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08729064415058822,
      "stddev": 0.0009163633267236468,
      "median": 0.08737724318000001,
      "user": 0.020161699999999998,
      "system": 0.00926032588235294,
      "min": 0.08462448918,
      "max": 0.08896460118,
      "times": [
        0.08462448918,
        0.08722970618,
        0.08839142018,
        0.08678186518,
        0.08774808118,
        0.08667936218,
        0.08814016818,
        0.08667825918000001,
        0.08811921918,
        0.08828037118,
        0.08543514018000001,
        0.08819523518,
        0.08688740718,
        0.08697542318,
        0.08823631218,
        0.08695963318,
        0.08714704618,
        0.08768172118,
        0.08787138718,
        0.08667131018,
        0.08724200318,
        0.08730101518,
        0.08783241418,
        0.08834910518,
        0.08729338018,
        0.08585603918,
        0.08759358518,
        0.08755682518,
        0.08779767818,
        0.08755904918,
        0.08745347118,
        0.08636831218,
        0.08896460118,
        0.08598086418
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08751389590727274,
      "stddev": 0.0016924030792995805,
      "median": 0.08728909218,
      "user": 0.02155118484848485,
      "system": 0.007998736969696968,
      "min": 0.08300612218,
      "max": 0.09150910418000001,
      "times": [
        0.08698352718,
        0.08562679818,
        0.08300612218,
        0.08672037318,
        0.08818212118,
        0.08702819218,
        0.08712712718,
        0.08775609018,
        0.08632383918,
        0.08854024518,
        0.08708487918,
        0.08689752618,
        0.09069901218,
        0.08540846718,
        0.08656857818000001,
        0.08737676718000001,
        0.08747141518,
        0.08732086218,
        0.08728909218,
        0.08809636018,
        0.08704332018000001,
        0.08840843618000001,
        0.08659850318000001,
        0.08665367718,
        0.08707771518,
        0.08784546818,
        0.09150910418000001,
        0.08800713218,
        0.08859789218,
        0.08479824118,
        0.08986619718,
        0.08923428918,
        0.09081119318
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.541 ± 0.116 4.419 4.738 1.30 ± 0.04
pacquet@main 4.553 ± 0.119 4.445 4.744 1.31 ± 0.04
pnpr@HEAD 3.484 ± 0.047 3.442 3.603 1.00
pnpr@main 3.566 ± 0.094 3.458 3.733 1.02 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.541350862220001,
      "stddev": 0.11648866141404093,
      "median": 4.52875018332,
      "user": 1.6852215000000001,
      "system": 1.35258498,
      "min": 4.41877995132,
      "max": 4.73849362032,
      "times": [
        4.52076025532,
        4.43361998432,
        4.73849362032,
        4.732072001320001,
        4.43673282632,
        4.57288860632,
        4.53674011132,
        4.41877995132,
        4.4564150513200005,
        4.56700621432
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.55337530652,
      "stddev": 0.11905616318417774,
      "median": 4.478065393820001,
      "user": 1.6710694999999998,
      "system": 1.40270368,
      "min": 4.44547021232,
      "max": 4.743764773320001,
      "times": [
        4.70899418832,
        4.468341945320001,
        4.46760161432,
        4.44547021232,
        4.45485536032,
        4.68317588732,
        4.4877888423200005,
        4.46805970532,
        4.743764773320001,
        4.6057005363200005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.48442023562,
      "stddev": 0.04711376351785575,
      "median": 3.4727364968199996,
      "user": 1.2068772999999997,
      "system": 1.23298858,
      "min": 3.44232092132,
      "max": 3.6029396283199997,
      "times": [
        3.4715981923199997,
        3.4738748013199996,
        3.4983910153199997,
        3.45751280032,
        3.6029396283199997,
        3.48607960832,
        3.44232092132,
        3.44727035232,
        3.5101235253199996,
        3.4540915113199997
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5656472551199996,
      "stddev": 0.09371512211768679,
      "median": 3.5552541263199995,
      "user": 1.1298814,
      "system": 1.2753853800000001,
      "min": 3.4579254473199996,
      "max": 3.7329236933199996,
      "times": [
        3.7329236933199996,
        3.50954757232,
        3.4579254473199996,
        3.47822755132,
        3.58050603832,
        3.68094407532,
        3.63842799232,
        3.55482122832,
        3.4674619283199997,
        3.5556870243199996
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13369
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,752.03 ms
(+0.57%)Baseline: 2,736.35 ms
3,283.62 ms
(83.81%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,894.09 ms
(+0.17%)Baseline: 1,890.81 ms
2,268.97 ms
(83.48%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
591.68 ms
(+3.18%)Baseline: 573.43 ms
688.11 ms
(85.99%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
345.35 ms
(-0.09%)Baseline: 345.66 ms
414.79 ms
(83.26%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,357.57 ms
(-0.27%)Baseline: 2,363.96 ms
2,836.75 ms
(83.11%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,418.78 ms
(-0.22%)Baseline: 4,428.69 ms
5,314.43 ms
(83.15%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
254.29 ms
(+3.16%)Baseline: 246.52 ms
295.82 ms
(85.96%)
🐰 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/13369
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,438.15 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
282.15 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
293.04 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.62 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,349.76 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,442.32 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
264.00 ms
🐰 View full continuous benchmarking report in Bencher

…r mandate

Three follow-ups from review of the peer-hoisting fixes, in both stacks.

An override must redirect a hoist, never create one. With
autoInstallPeers off, hoisting only deduplicates a package the graph or
the workspace root already provides; consulting the overrides ahead of
those checks let an override install a peer that appears nowhere in the
workspace, in a configuration that asks for no peer to be auto-installed.
The picker now skips a peer nothing provides before it looks at the
override set.

The overrider learns the directory of the importer the peer is hoisted
into, so a `link:` / `file:` override target stays relative to it. Called
without a directory, the local-override renderer falls back to the
absolute path, which would write this machine's filesystem layout into
the importer's specifier in the lockfile.

getHoistableOptionalPeers reads the workspace root's specifier through
getPeerVersionRange, so a `workspace:` range or an `npm:` alias bounds
the candidates as well; parsed raw, both yield no range and left the
candidates unbounded, which is the shape the fix set out to bound.

Also: pickVersionOverride takes its two override sets as one object, and
the changeset bumps the packages that only gained wiring as patch.
Related to #13320.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

…into one helper

The package directory argument repeated at every call site pushed each
assertion onto several lines, which the perfectionist trailing-comma rule
then rejected.

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

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

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Addressing the Qodo findings, all in 7f4bc57:

1. Local override target on an undeclared peer (valid, fixed). The overrider now receives the directory of the importer the peer is hoisted into, so a link: / file: override stays relative to it instead of falling back to the absolute path. On the TypeScript side resolveRootDependencies binds ctx.overrideBareSpecifier to options.prefix per importer; on the pacquet side DependencyOverrider takes the package directory and override_for_undeclared_dependency passes it to resolve_local_override_spec. Tests: resolves a local override relative to the directory of the package that gets the dependency (TS) and override_for_undeclared_dependency_resolves_a_local_target_relative_to_the_package_dir + passes_the_importer_directory_to_the_overrider (Rust).

2. pickVersionOverride parameter count (valid, fixed). It now takes the two override sets as one options object, so it is down to three parameters.

3. Trailing commas in multi-line parameter lists (not applied). This repo's ESLint config sets @stylistic/comma-dangle to functions: 'never' — a trailing comma after the last parameter is a lint error here, so the suggested edit would fail pnpm run lint. The always-multiline requirement applies to arrays, objects, imports, and exports, which the changed code follows.


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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pnpm/crates/package-manager/src/overrides/tests.rs (1)

27-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the restatement comment.

It only narrates the helper and its fixed fixture path, rather than documenting a non-obvious invariant. As per coding guidelines, “comments should explain only non-obvious reasons or invariants.”

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

In `@pnpm/crates/package-manager/src/overrides/tests.rs` around lines 27 - 28,
Remove the restatement doc comment above
VersionsOverrider::override_for_undeclared_dependency in the test fixture,
leaving the helper and its behavior unchanged.

Sources: Coding guidelines, 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.

Nitpick comments:
In `@pnpm/crates/package-manager/src/overrides/tests.rs`:
- Around line 27-28: Remove the restatement doc comment above
VersionsOverrider::override_for_undeclared_dependency in the test fixture,
leaving the helper and its behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a167b6e7-66a3-4262-b7ef-21024c7e6ada

📥 Commits

Reviewing files that changed from the base of the PR and between 822f7ee and 92e60bc.

📒 Files selected for processing (13)
  • .changeset/overrides-reach-auto-installed-peers.md
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/overrides.rs
  • pnpm/crates/package-manager/src/overrides/tests.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_importer.rs
  • pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts
  • pnpm11/hooks/read-package-hook/test/createVersionOverrider.test.ts
  • pnpm11/installing/deps-resolver/src/hoistPeers.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts
  • pnpm11/installing/deps-resolver/test/hoistPeers.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • .changeset/overrides-reach-auto-installed-peers.md
  • pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts
  • pnpm/crates/package-manager/src/overrides.rs
  • pnpm11/installing/deps-resolver/src/hoistPeers.ts
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
  • pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts

@zkochan
zkochan merged commit 71a4934 into main Jul 25, 2026
36 checks passed
@zkochan
zkochan deleted the fix-13320-2 branch July 25, 2026 18:37
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…s pin to hoisted peers (pnpm#13369)

Two peer-hoisting fixes, in both the TypeScript CLI and pacquet.

overrides now govern peers pnpm auto-installs. Overrides are applied by
the read-package hook, which only sees manifests; a peer nobody declares
never passes through one, so it resolved against its declared peer range
and could introduce a second copy of the package the override pinned.
The required-peer picker now consults the override set first. The
per-edge lookup that backs the hook is factored out and shared, so the
two paths cannot drift: hooks/read-package-hook exports
createDependencyOverrider, and pacquet's VersionsOverrider grows
override_for_undeclared_dependency. Parent-scoped overrides cannot apply
(no parent manifest), and a convergence override still applies only when
its version satisfies the edge's range. The convergence collector does
not see these edges — a range no manifest declares would skew the
staleness verdict. An override redirects a hoist rather than
creating one: without autoInstallPeers, a peer neither the graph nor the
workspace root provides stays uninstalled. The overrider is handed the
directory of the importer the peer is hoisted into, so a link: / file:
target stays relative to it.

getHoistableOptionalPeers now bounds its candidates by the workspace
root's own specifier for the package, the same input hoistPeers
short-circuits on. It previously maximised over every version in the
graph, so an optional peer declared as `*` — the shape
peerDependenciesMeta produces — pulled the newest version any importer
had resolved into a sibling that declares nothing, next to the version
the root pins. The alias-then-package-name precedence for finding that
root dependency is now one helper shared by both pickers, and the root's
specifier is read through getPeerVersionRange so a workspace: range or an
npm: alias bounds the candidates as well.

Measured on vercel/next.js: the lockfile diff between the two stacks
drops from 718 to 138 lines, the two stacks' resolved package key sets
and every importer block now match, and the only remaining difference is
three snapshot instances pacquet does not deduplicate.

Related to pnpm#13320.
zkochan added a commit that referenced this pull request Aug 31, 2026
…ejects (#13869)

getHoistableOptionalPeers bounds its candidates by the workspace root's own
specifier for the package, so the root decides the version an optional peer
is hoisted at. A specifier disjoint from the declared peer range bounded the
candidates down to none: nothing was hoisted, and the importer then fell back
to the root's version through resolvePeersFromWorkspaceRoot, which is the very
version the peer range rejects. A root pinning date-fns 2.30.0 gave an
importer @base-ui/react([email protected]) for an optional date-fns@^4.0.0 peer
while [email protected] sat in the graph, and pnpm peers check then reported that
resolution as unmet.

The root's specifier is now consulted only when it overlaps every range
recorded for the peer. An overlapping pin still bounds the candidates as
before, so the hoisting corrected in #13369 stays; a disjoint one is
dropped and the picker maximizes over the graph again.

Fixes #13867

---------

Co-authored-by: Zoltan Kochan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants