Skip to content

fix(resolving-deps-resolver): hoist peers against the workspace root's deps - #13343

Merged
zkochan merged 6 commits into
mainfrom
fix-hoist-peers-from-workspace-root
Jul 25, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix-hoist-peers-from-workspace-root

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Two peer-resolution defects found while validating vercel/next.js for #13305. Both are pacquet-only divergences from the TypeScript CLI — hoist_peers.rs is otherwise a faithful port of hoistPeers / getHoistableOptionalPeers, so there is no counterpart TypeScript change to land alongside this.

1. resolvePeersFromWorkspaceRoot read the wrong importer's dependencies. The hoist picker was fed self.direct — the deps of whichever importer was being resolved — instead of the workspace root's. A project that doesn't declare the peer itself therefore saw no candidate and resolved a second copy from the registry. The field doc admitted it ("Single-importer pacquet treats the importer as the root"), left over from before the multi-importer orchestrator existed; WorkspaceResolveOptions already documented the intended behavior correctly.

In next.js, whose overrides pin react/react-dom/react-is/scheduler to one canary build, bench/heavy-npm-deps (which declares @mantine/core, lucide-react, next and no react) pulled in a second [email protected] and bound the canary react-dom to it — violating that package's exact peer pin react: 19.3.0-canary-28cd4bb0-20260723, which is the runtime-breaking combination the pin exists to prevent. 38 references in the resolved lockfile, zero in pnpm 11's.

2. The optional-peer picker accepted prereleases the declared range rejects. get_hoistable_optional_peers used the prerelease-tolerant helper where the TypeScript counterpart uses a bare semver.satisfies. ts-jest declares @jest/transform and jest-util as optional peers with ^29.0.0 || ^30.0.0; with a jest 30 prerelease elsewhere in the graph (dragged in by overrides: { jest-snapshot: 30.0.0-alpha.6 }) they bound to 30.0.0-alpha.6 — outside the declared range under strict semver — while jest itself stayed on 29.7.0.

Effect on the next.js lockfile

Full re-resolution, both stacks run back to back on the same tree:

before after
pnpm-lock.yaml diff vs pnpm 11 638 lines 445
package keys resolved by one stack only [email protected] none — the sets are identical
[email protected] references 38 0
ts-jest peer suffix 30-alpha transform + jest-util matches pnpm 11 exactly

The remaining 445 lines are a separate, unrelated resolve_peers provider-selection difference around postcss, discussed on #13320; nothing is violated on either side there and it is not touched here.

Not in this PR

  • Required-peer prerelease leniency — hoist_peers is lenient in a different way to getHoistableOptionalPeers: pacquet strips the prerelease tag and retries against the base version, while TypeScript passes includePrerelease: true, which does not lower the range's bound. The two agree when the prerelease sits inside the range's span and disagree at the lower bound. Not implicated in any repository validated so far, and the Rust node-semver crate exposes no includePrerelease, so it needs real semver work. Filed as pnpm 12 auto-installs a required peer as a prerelease its declared range rejects (base-strip vs includePrerelease) #13341.

  • An aliased git workspace-root dependency still can't satisfy a peer by its real package name. A git resolution reports neither name_ver nor a manifest before the hoist loop runs, so it is matched by alias only. Pre-existing — the previous code skipped such deps entirely, matching neither — and a missed deduplication rather than an incorrect graph. Filed as An aliased git workspace-root dependency can't satisfy a peer by its real package name #13351.

Related to #13320, found via #13305.

Squash Commit Body

`resolvePeersFromWorkspaceRoot` is meant to let any project satisfy a
missing peer from the workspace root's dependencies. The picker was fed
`self.direct` — the deps of whichever importer was being resolved — so a
project that didn't declare the peer itself saw no candidate and resolved
a second copy from the registry. The field doc said as much
("Single-importer pacquet treats the importer as the root"), left over
from before the multi-importer orchestrator existed.

`resolve_workspace` now builds the root importer's list once, after the
phase-1 init barrier, and shares it with every importer's hoist rounds;
computing it once also matches pnpm, where the root's own hoisted peers
never become root-dep candidates for the importers hoisted after it. An
importer set without the root leaves the list empty, mirroring pnpm's
absent-root-importer case.

`build_workspace_root_deps` also needed pnpm's two specifier sources to
be of any use: the resolver reports `normalized_bare_specifier` only for
specs that needed normalizing, so a plain "19.2.0" arrived as `None` and
the picker skipped the root dep entirely. Fall back to the declared
specifier, and include deps the resolver couldn't name at resolution
time (git / tarball / local), matching `getHoistableRootDeps`.

Separately, `get_hoistable_optional_peers` now checks ranges with plain
semver instead of the prerelease-tolerant helper, matching the bare
`semver.satisfies` in `getHoistableOptionalPeers`. A prerelease is not a
stand-in for a range that didn't ask for one: `ts-jest` declares
`@jest/transform` and `jest-util` as optional peers with
`^29.0.0 || ^30.0.0`, and a jest 30 prerelease elsewhere in the graph
was binding them to `30.0.0-alpha.6` while `jest` itself stayed on 29.

Both were found resolving vercel/next.js, whose `overrides` pin `react`
to one canary build: pnpm 12 produced a second `[email protected]` and paired
it with the canary `react-dom`, violating that package's exact peer pin.
The remaining required-peer prerelease divergence is pnpm/pnpm#13341.

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.

    Rust-only: both defects are pacquet diverging from TypeScript behavior that
    is already correct, so the TypeScript CLI needs no change.
  • 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.

    non_root_importer_hoists_the_root_importers_peer_provider covers the
    workspace-root sourcing; it was verified to fail against the old behavior
    (["18.3.1", "19.2.0"] where ["19.2.0"] is expected). The optional-peer test
    that asserted the prerelease was accepted is inverted, plus a new case for a
    prerelease inside the range's span, which is the shape next.js hits and which
    a lower-bound check alone would miss.
  • Updated the documentation if needed.

    No user-facing docs change; the stale resolve_peers_from_workspace_root
    field doc that described the bug is corrected.

Verification

just ready green: 7020 tests passed, 0 failures; cargo clippy --all-targets --workspace -D warnings clean; typos, cargo fmt, cargo check clean. Pre-push gates run locally too: workspace cargo doc with RUSTDOCFLAGS=-D warnings, and cargo dylint --all clean. next.js frozen install re-checked after the change — exit 0, lockfile not rewritten, 3619 packages.


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


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

Summary by CodeRabbit

  • Bug Fixes
    • Improved workspace peer dependency resolution to reuse compatible dependencies provided by the workspace root, reducing duplicate installations.
    • Corrected optional peer handling so prerelease versions are not selected when they fall outside the declared peer range.
  • Tests
    • Added coverage for workspace-root peer reuse and prerelease rejection scenarios.

zkochan added 2 commits July 25, 2026 14:42
…s deps

`resolvePeersFromWorkspaceRoot` is meant to let any project satisfy a
missing peer from the workspace root's dependencies. The picker was fed
`self.direct` — the deps of whichever importer was being resolved — so a
project that didn't declare the peer itself saw no candidate and resolved
a second copy from the registry. The field doc said as much
("Single-importer pacquet treats the importer as the root"), left over
from before the multi-importer orchestrator existed.

`resolve_workspace` now builds the root importer's list once, after the
phase-1 init barrier, and shares it with every importer's hoist rounds;
computing it once also matches pnpm, where the root's own hoisted peers
never become root-dep candidates for the importers hoisted after it. An
importer set without the root leaves the list empty, mirroring pnpm's
absent-root-importer case.

`build_workspace_root_deps` also needed pnpm's two specifier sources to
be of any use: the resolver reports `normalized_bare_specifier` only for
specs that needed normalizing, so a plain "19.2.0" arrived as `None` and
the picker skipped the root dep entirely. Fall back to the declared
specifier, and include deps the resolver couldn't name at resolution
time (git / tarball / local), matching `getHoistableRootDeps`.

Separately, `get_hoistable_optional_peers` now checks ranges with plain
semver instead of the prerelease-tolerant helper, matching the bare
`semver.satisfies` in `getHoistableOptionalPeers`. A prerelease is not a
stand-in for a range that didn't ask for one: `ts-jest` declares
`@jest/transform` and `jest-util` as optional peers with
`^29.0.0 || ^30.0.0`, and a jest 30 prerelease elsewhere in the graph
was binding them to `30.0.0-alpha.6` while `jest` itself stayed on 29.

Both were found resolving vercel/next.js, whose `overrides` pin `react`
to one canary build: pnpm 12 produced a second `[email protected]` and paired
it with the canary `react-dom`, violating that package's exact peer pin.
The remaining required-peer prerelease divergence is #13341.

Refs #13320
The `resolve_peers_from_workspace_root` doc linked to
`ImporterHoistState::set_workspace_root_deps`, which is `pub(crate)`, so
rustdoc rejected a public item pointing at a private one under
`RUSTDOCFLAGS=-D warnings`. Point at `resolve_workspace` instead — it is
the public entry point that supplies the root's deps, which is what a
reader of the option needs to know.

Also replace a Unicode ellipsis in the `wanted_specifier_by_alias` doc
with ASCII, per `perfectionist::unicode-ellipsis-in-docs`.

Both are caught by the `pre-push` hook rather than by `just ready`.
Copilot AI review requested due to automatic review settings July 25, 2026 12:51

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

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c862d54c-e5f0-4f2b-8fb3-21ff0e6f4205

📥 Commits

Reviewing files that changed from the base of the PR and between 4f074a6 and 0e9e9c0.

📒 Files selected for processing (7)
  • .changeset/optional-peer-prerelease-strictness.md
  • .changeset/peer-hoist-reads-workspace-root-deps.md
  • 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
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
📝 Walkthrough

Walkthrough

Changes

Peer hoisting corrections

Layer / File(s) Summary
Strict optional-peer matching
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs, pnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rs
Optional peer candidates now require strict semver satisfaction across all ranges, with prerelease rejection tests.
Workspace-root dependency state
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
Importer hoist state stores shared root dependencies, uses declared alias fallbacks, and exposes the package-name helper for root dependency construction.
Workspace hoist wiring and validation
pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs, pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs, .changeset/peer-hoist-reads-workspace-root-deps.md
Workspace resolution shares the root dependency view across importers and tests selection of the root-provided peer provider.

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

Sequence Diagram(s)

sequenceDiagram
  participant WorkspaceResolver
  participant ImporterHoistState
  participant PeerHoister
  WorkspaceResolver->>ImporterHoistState: derive root direct dependencies
  WorkspaceResolver->>ImporterHoistState: share workspace_root_deps
  ImporterHoistState->>PeerHoister: hoist required peers using stored root deps
  PeerHoister-->>ImporterHoistState: select root-provided peer version
Loading

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#12267: Modifies the optional peer hoisting flow and preferred-version inputs.
  • pnpm/pnpm#13110: Also changes peer-hoisting range handling in the resolving dependency resolver.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-hoist-peers-from-workspace-root

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 use workspace-root deps and strict optional-peer semver

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Fix resolvePeersFromWorkspaceRoot to hoist peers against workspace-root direct dependencies.
• Enforce strict semver for optional-peer hoisting so prereleases don’t satisfy non-prerelease
 ranges.
• Add regression tests and a changeset documenting both peer-resolution fixes.
Diagram

graph TD
  R((Resolver)) --> W["resolve_workspace.rs"] --> S["ImporterHoistState (resolve_importer.rs)"] --> B["build_workspace_root_deps"] --> H["hoist_peers.rs"] --> O["get_hoistable_optional_peers"] --> T["Tests"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Recompute root-dep candidates per importer/round
  • ➕ No additional shared state in ImporterHoistState
  • ➕ Always reflects the latest snapshot state
  • ➖ More CPU and allocations across hoist rounds
  • ➖ Risks diverging from pnpm semantics (root’s hoisted peers becoming later candidates)
2. Model root-dep candidates as a dedicated workspace-level object
  • ➕ Clearer separation between workspace orchestration and per-importer state
  • ➕ Could centralize other workspace-scoped peer/hoist behavior later
  • ➖ More refactor churn for a targeted bug fix
  • ➖ Requires additional plumbing to thread through existing APIs

Recommendation: Keep the PR’s approach: compute the workspace-root direct-dep candidate list once after the init barrier and share it immutably with all importers. This matches pnpm’s behavior (root hoisted peers shouldn’t become candidates for later importers), avoids repeated work, and makes the workspace-root sourcing explicit and testable.

Files changed (7) +225 / -29

Bug fix (3) +119 / -26
hoist_peers.rsMake optional-peer hoist selection strict about prereleases +15/-7

Make optional-peer hoist selection strict about prereleases

• Updates optional-peer selection to require strict 'Range::satisfies' instead of prerelease-tolerant matching. Clarifies doc/comments that prereleases must not satisfy ranges that don’t include prerelease intent.

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

resolve_importer.rsStore and use shared workspace-root deps for peer hoist picking +89/-19

Store and use shared workspace-root deps for peer hoist picking

• Adds 'workspace_root_deps' to ImporterHoistState and wires it into hoist rounds so 'resolvePeersFromWorkspaceRoot' uses the root importer’s direct deps rather than the current importer’s. Also records declared wanted specifiers for fallback when the resolver provides no normalized specifier and for deps whose names are only known post-fetch.

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

resolve_workspace.rsCompute workspace-root dep candidates once and share across importers +15/-0

Compute workspace-root dep candidates once and share across importers

• After the init barrier, finds the root importer state (if present) and computes a single hoistable root-dep list, then assigns it to all importer states. Ensures filtered installs without the root disable the root short-circuit by leaving the list empty.

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

Refactor (1) +4 / -1
resolve_dependency_tree.rsExpose 'unwrap_package_name' for workspace-root dep construction +4/-1

Expose 'unwrap_package_name' for workspace-root dep construction

• Changes 'unwrap_package_name' visibility to 'pub(crate)' so other modules can reuse consistent alias/package-name parsing when building workspace-root dependency candidates.

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

Tests (2) +92 / -2
tests.rsAdjust and extend tests for optional-peer prerelease rejection +19/-2

Adjust and extend tests for optional-peer prerelease rejection

• Renames the prerelease test to reflect the new expected behavior and asserts that prereleases are rejected for non-prerelease ranges. Adds a regression test covering prereleases that lie within a range’s numeric span (e.g. '^29 || ^30' rejecting '30.0.0-alpha.*').

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

tests.rsAdd regression test: non-root importers hoist root-provided peer +73/-0

Add regression test: non-root importers hoist root-provided peer

• Adds an integration-style workspace test ensuring a non-root importer uses the root’s direct dependency as the peer provider when 'resolvePeersFromWorkspaceRoot' is enabled. Verifies it prevents resolving a second peer copy from the registry and that the peer suffix wiring reflects the single root-provided version.

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

Documentation (1) +10 / -0
peer-hoist-reads-workspace-root-deps.mdAdd changeset describing workspace-root peer hoist and optional-peer fixes +10/-0

Add changeset describing workspace-root peer hoist and optional-peer fixes

• Introduces a patch changeset for pacquet documenting two peer-resolution defects and their impact (notably Next.js and ts-jest scenarios). Serves as release notes for the restored peer-hoisting behavior.

.changeset/peer-hoist-reads-workspace-root-deps.md

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.01     10.6±0.37ms    35.3 MB/sec    1.00     10.5±0.22ms    35.5 MB/sec
packument/parse                1.00     36.5±0.59µs  1816.5 MB/sec    1.01     36.8±0.55µs  1802.9 MB/sec
tarball/download_dependency    1.00      2.8±0.11ms  1573.8 KB/sec    1.01      2.8±0.10ms  1558.5 KB/sec

The new comments claimed the shared root-dep list is empty for a
filtered install. It isn't: the install layer builds
`importer_manifests` from `selection.all_projects`, so every workspace
project — the root included — reaches `resolve_workspace` whether or not
`--filter` narrowed what gets written. The empty fallback covers an
importer set with no root at all, which is also what pnpm's unchecked
`importers[rootImporterIndex]` lookup degrades to.
@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5

This PR is not yet safe to merge because aliased root dependencies can still lose their canonical package identity and fail to provide peers across importers.

The attempted identity fix depends on name_ver or a fetched manifest, while realistically reachable non-registry resolution results can contain neither; its declaration fallback then retains only the alias, so peer requests using the package's real name still miss the root provider.

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

Reviews (4): Last reviewed commit: "docs(resolving-deps-resolver): let the t..." | Re-trigger Greptile

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Historical comment in test ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A newly added doc comment describes the prior (incorrect) implementation behavior rather than only
documenting the current invariant/contract. This violates the rule against historical/temporal
commentary in source comments.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs[R1698-1700]

+/// workspace. Sourcing the picker from the hoisting importer instead
+/// left it with no candidate, and it resolved a second `react` from the
+/// range.
Relevance

⭐⭐⭐ High

Team often accepts trimming comments to remove historical/maintenance-noise phrasing and keep
invariant-focused docs.

PR-#13172
PR-#12936

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 prohibits comments that describe historical implementations. The added
comment explicitly contrasts the intended behavior with what happened when the picker was sourced
from the hoisting importer (a past behavior explanation).

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs[1693-1700]

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

## Issue description
A new comment explains what the old behavior did (historical phrasing) instead of documenting the current behavior/contract.

## Issue Context
Comments should describe current behavior and invariants; if rationale is needed, phrase it as current constraints or as a conditional consequence ("if X, then Y") rather than "used to"/"instead" descriptions.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs[1693-1700]

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


2. Root spec resolved wrong dir ✓ Resolved 🐞 Bug ⛨ Security
Description
build_workspace_root_deps now falls back to the workspace root manifest’s declared
bare_specifier (and even adds declared-only entries) and that specifier is reused to hoist peers
in non-root importers. For project-dir-relative local specifiers (e.g. link:/file: relative
paths), this can resolve to a different filesystem path (or fail) because local resolution is
performed relative to the hoisting importer’s project_dir.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R744-774]

fn build_workspace_root_deps(
    direct: &[DirectDep],
    snapshot: &ResolvedTree,
+    declared: &BTreeMap<String, String>,
) -> Vec<WorkspaceRootDep> {
    let mut out = Vec::with_capacity(direct.len());
+    let mut named = HashSet::new();
    for dep in direct {
        let Some(pkg) = snapshot.packages.get(&dep.id) else { continue };
-        // `name_ver` is `None` for resolvers that learn the name from
-        // the manifest only after the fetch (git / tarball / local).
-        // Workspace-root short-circuit needs the resolution-time real
-        // name, so skip those — they fall through to the
-        // preferred-versions arm of `hoist_peers` instead.
        let Some(name_ver) = pkg.result.name_ver.as_ref() else { continue };
+        named.insert(dep.alias.as_str());
        out.push(WorkspaceRootDep {
            alias: dep.alias.clone(),
            pkg_name: name_ver.name.to_string(),
-            normalized_bare_specifier: pkg.result.normalized_bare_specifier.clone(),
+            normalized_bare_specifier: pkg
+                .result
+                .normalized_bare_specifier
+                .clone()
+                .or_else(|| declared.get(&dep.alias).cloned()),
+        });
+    }
+    for (alias, bare_specifier) in declared {
+        if named.contains(alias.as_str()) {
+            continue;
+        }
+        let (pkg_name, _) = unwrap_package_name(alias, bare_specifier);
+        out.push(WorkspaceRootDep {
+            alias: alias.clone(),
+            pkg_name: pkg_name.to_string(),
+            normalized_bare_specifier: Some(bare_specifier.clone()),
        });
Relevance

⭐⭐ Medium

Potential local-specifier path bug is plausible but no close accept/reject precedent for this
hoist-peers pattern.

PR-#13006
PR-#12924

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR now includes declared-only deps in workspace_root_deps and stores
normalized_bare_specifier: Some(bare_specifier.clone()), then shares that root-deps vector across
all importers and feeds it into hoist_peers, which adds the specifier into the hoisting importer’s
wanted deps. Local dependency parsing resolves relative paths against the *current* importer’s
project_dir, so using a root-relative local specifier string in a different importer can resolve
to a different filesystem location.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[734-777]
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[517-555]
pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs[275-289]
pnpm/crates/resolving-local-resolver/src/parse_bare_specifier.rs[136-153]

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

### Issue description
Workspace-root peer hoisting now reuses the root importer’s declared `bare_specifier` as the specifier to install a missing peer in *other* importers. For local/path-based specifiers (notably `link:`/`file:` with relative paths, and path-shaped specifiers without an explicit scheme), the same string is interpreted relative to each importer’s `project_dir`, so reusing the root’s string can resolve the peer provider from a different on-disk location than the root intended (or fail to resolve).

### Issue Context
- Root deps are computed once and shared across all importers.
- `build_workspace_root_deps` now uses `declared` as a fallback and also adds declared entries that didn’t make it into the named/resolved set.
- The local resolver resolves relative paths against the current importer’s `project_dir`, so a relative `link:../x` means different targets in different importers.

### Fix options (pick one)
1) **Make local specifiers importer-independent before sharing**: when building `workspace_root_deps`, detect local/path-based specifiers and rewrite them to an absolute (or lockfile-root-relative) form computed using the *root* importer’s `project_dir` / `lockfile_dir`.
2) **Conservatively disable root short-circuit for path-dependent specifiers**: if a root dep’s specifier is local/path-based and relative, store `normalized_bare_specifier: None` so it won’t be used as a cross-importer short-circuit.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[421-434]
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[734-777]
- pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs[275-289]

### Tests to add/adjust
Add a workspace test where the root provides a peer via a relative `link:`/`file:` spec and a non-root importer hoists that peer; assert the resolved provider points to the intended root path (or that the short-circuit is intentionally skipped, depending on the chosen fix).

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



Informational

3. pnpm missing from changeset 📘 Rule violation § Compliance
Description
The new changeset front-matter only lists pacquet and does not include a pnpm entry. This
violates the changeset requirement to explicitly declare the pnpm package and its bump type.
Code

.changeset/peer-hoist-reads-workspace-root-deps.md[R1-3]

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

⭐ Low

Exact precedent: team repeatedly rejected adding pnpm entry to pacquet-only changesets.

PR-#12981
PR-#12991
PR-#13304

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires newly added/modified changesets to include an explicit pnpm entry
with a valid bump type. The added changeset front-matter contains only "pacquet": patch.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/peer-hoist-reads-workspace-root-deps.md[1-3]

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

## Issue description
The new changeset file is missing a `pnpm` entry in its front-matter.

## Issue Context
Compliance requires that each added/modified changeset explicitly declares the `pnpm` package with a valid bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/peer-hoist-reads-workspace-root-deps.md[1-3]

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


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.06%. Comparing base (8e00149) to head (0e9e9c0).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
.../crates/resolving-deps-resolver/src/hoist_peers.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13343      +/-   ##
==========================================
+ Coverage   87.04%   87.06%   +0.01%     
==========================================
  Files         532      535       +3     
  Lines       91589    91884     +295     
==========================================
+ Hits        79723    79996     +273     
- Misses      11866    11888      +22     

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

🧹 Nitpick comments (2)
.changeset/peer-hoist-reads-workspace-root-deps.md (1)

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

Split into two changesets — one logical change per changeset.

The frontmatter/package choice (pacquet: patch, no pnpm) is correct for a Rust-only fix. However, the body itself enumerates "Two fixes to peer hoisting" that are unrelated bugs (workspace-root dependency matching vs. optional-peer prerelease strictness). Per the review guide's one-logical-change-per-changeset rule, these should be two separate changeset files so each fix has its own changelog entry and bump.

As per path instructions, "If user-visible behavior changed, ensure a changeset exists and is accurate; follow the one logical change per changeset rule."

🤖 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 @.changeset/peer-hoist-reads-workspace-root-deps.md around lines 1 - 11,
Split the changeset’s “Two fixes to peer hoisting” into two separate changeset
files: one describing workspace-root dependency matching and one describing
optional-peer prerelease range enforcement. Preserve the existing pacquet patch
frontmatter for each file, and give each fix its own focused changelog entry.

Source: Path instructions

pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs (1)

162-173: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Hoist range parsing out of the per-version loop.

ranges is invariant across the selectors loop, but range.parse::<Range>() re-parses every range string for every candidate version. Parse once per peer_name and reuse.

♻️ Proposed refactor
     for (peer_name, ranges) in all_missing_optional_peers {
         let Some(selectors) = all_preferred_versions.get(peer_name) else { continue };
+        let Ok(parsed_ranges) =
+            ranges.iter().map(|range| range.parse::<Range>()).collect::<Result<Vec<_>, _>>()
+        else {
+            continue;
+        };
         let mut max_satisfying_version: Option<Version> = None;
         for (version_str, entry) in selectors {
             ...
             let Ok(version) = version_str.parse::<Version>() else { continue };
-            if !ranges
-                .iter()
-                .all(|range| range.parse::<Range>().is_ok_and(|parsed| parsed.satisfies(&version)))
-            {
+            if !parsed_ranges.iter().all(|parsed| parsed.satisfies(&version)) {
                 continue;
             }

As per path instructions, "performance second—avoid extra hot-path work in resolver/hoisting loops."

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

In `@pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs` around lines 162 -
173, Parse all entries in ranges once before the selectors/per-version loop for
each peer_name, store the successfully parsed Range values or the resulting
invalid state, and reuse them in the strict prerelease compatibility check.
Update the condition around parsed.satisfies(&version) to avoid calling
range.parse::<Range>() for each candidate version while preserving the existing
behavior for invalid ranges.

Source: Path instructions

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

Nitpick comments:
In @.changeset/peer-hoist-reads-workspace-root-deps.md:
- Around line 1-11: Split the changeset’s “Two fixes to peer hoisting” into two
separate changeset files: one describing workspace-root dependency matching and
one describing optional-peer prerelease range enforcement. Preserve the existing
pacquet patch frontmatter for each file, and give each fix its own focused
changelog entry.

In `@pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs`:
- Around line 162-173: Parse all entries in ranges once before the
selectors/per-version loop for each peer_name, store the successfully parsed
Range values or the resulting invalid state, and reuse them in the strict
prerelease compatibility check. Update the condition around
parsed.satisfies(&version) to avoid calling range.parse::<Range>() for each
candidate version while preserving the existing behavior for invalid ranges.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 140ffc08-b106-4b3f-b3f6-2f1ca9be0dc4

📥 Commits

Reviewing files that changed from the base of the PR and between f7e1fee and 4f074a6.

📒 Files selected for processing (7)
  • .changeset/peer-hoist-reads-workspace-root-deps.md
  • 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_dependency_tree.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
@zkochan zkochan added the rust Pull requests that update rust code label Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 4f074a6e45ec

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.608 ± 0.175 2.375 2.817 1.77 ± 0.23
pacquet@main 2.603 ± 0.159 2.397 2.804 1.76 ± 0.22
pnpr@HEAD 1.529 ± 0.124 1.353 1.683 1.04 ± 0.14
pnpr@main 1.476 ± 0.165 1.353 1.806 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6083106423599998,
      "stddev": 0.17510884675285984,
      "median": 2.65357597726,
      "user": 1.5492072199999998,
      "system": 1.3072948000000002,
      "min": 2.37455780226,
      "max": 2.81669234426,
      "times": [
        2.79366459926,
        2.42330947126,
        2.37455780226,
        2.8113698872599997,
        2.6603411652599998,
        2.3957231642599996,
        2.67289313526,
        2.81669234426,
        2.64681078926,
        2.48774406526
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.60269222596,
      "stddev": 0.1590040262716171,
      "median": 2.63345508926,
      "user": 1.5564852199999997,
      "system": 1.2789442000000002,
      "min": 2.3974736272599997,
      "max": 2.80350666326,
      "times": [
        2.7693675822599997,
        2.39961053626,
        2.70387566526,
        2.3974736272599997,
        2.7368168432599997,
        2.51301380926,
        2.56303451326,
        2.80350666326,
        2.70448246026,
        2.4357405592599997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5285854117600002,
      "stddev": 0.12385586040507172,
      "median": 1.5309569232600002,
      "user": 1.0666534199999997,
      "system": 1.1534630000000001,
      "min": 1.35303725426,
      "max": 1.6828799862600001,
      "times": [
        1.36590926026,
        1.4823348872600002,
        1.6823440202600002,
        1.62571019926,
        1.5137923582600001,
        1.4137920752600002,
        1.6179325882600002,
        1.54812148826,
        1.35303725426,
        1.6828799862600001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.47639371836,
      "stddev": 0.1647420432584678,
      "median": 1.3903641907600002,
      "user": 1.05049182,
      "system": 1.1201190000000003,
      "min": 1.35337160026,
      "max": 1.80563790026,
      "times": [
        1.80563790026,
        1.38657347426,
        1.7315993092600002,
        1.3941549072600001,
        1.36186044526,
        1.3681685482600001,
        1.35337160026,
        1.43003673826,
        1.5486621522600001,
        1.38387210826
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 259.3 ± 5.9 247.2 268.7 1.00 ± 0.03
pacquet@main 258.2 ± 3.6 252.8 263.3 1.00
pnpr@HEAD 274.5 ± 5.1 266.2 279.6 1.06 ± 0.02
pnpr@main 272.1 ± 5.5 263.3 278.7 1.05 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25929840628,
      "stddev": 0.005891407615713493,
      "median": 0.25856139058000005,
      "user": 0.20576378,
      "system": 0.5442762799999998,
      "min": 0.24716059358,
      "max": 0.26865918358,
      "times": [
        0.25822031058,
        0.25786950258,
        0.25890247058000004,
        0.25599306258000004,
        0.26865918358,
        0.25786038558,
        0.26598467658,
        0.26333309258000004,
        0.25900078458000003,
        0.24716059358
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25823384558,
      "stddev": 0.0036169356567114473,
      "median": 0.25709654708,
      "user": 0.20497378,
      "system": 0.54829168,
      "min": 0.25276814258,
      "max": 0.26333293058,
      "times": [
        0.25809879158000004,
        0.26333293058,
        0.25609430258,
        0.25276814258,
        0.26143413858000003,
        0.25487111658,
        0.26185248458,
        0.25607164958,
        0.25598832258000004,
        0.26182657658
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27452019258,
      "stddev": 0.005102417253160948,
      "median": 0.27585239658000005,
      "user": 0.20216837999999995,
      "system": 0.5565167799999999,
      "min": 0.26618025258,
      "max": 0.27960260158,
      "times": [
        0.27572173158,
        0.27843882858,
        0.26718706158,
        0.27516172058,
        0.27863210158,
        0.26618025258,
        0.26921702958,
        0.27960260158,
        0.27598306158,
        0.27907753658
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27210190818,
      "stddev": 0.0054823866620347965,
      "median": 0.27289608108,
      "user": 0.22311737999999998,
      "system": 0.53256818,
      "min": 0.26327349858000004,
      "max": 0.27867124458000003,
      "times": [
        0.27743781058,
        0.27726574758,
        0.26327349858000004,
        0.27867124458000003,
        0.27207650358,
        0.27581185158,
        0.27371565858,
        0.27082378358000003,
        0.26522689458000004,
        0.26671608858
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.775 ± 0.016 2.759 2.804 1.84 ± 0.17
pacquet@main 2.769 ± 0.021 2.740 2.812 1.84 ± 0.17
pnpr@HEAD 1.569 ± 0.133 1.459 1.857 1.04 ± 0.13
pnpr@main 1.507 ± 0.140 1.424 1.876 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.77548688732,
      "stddev": 0.015733715972184432,
      "median": 2.77182208222,
      "user": 1.6770056199999999,
      "system": 1.3589731400000002,
      "min": 2.75900813422,
      "max": 2.80409662422,
      "times": [
        2.7994576332200003,
        2.7690849172200003,
        2.75900813422,
        2.76212436922,
        2.77455924722,
        2.7831323772200003,
        2.80409662422,
        2.76244342022,
        2.77614591722,
        2.76481623322
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.76899744242,
      "stddev": 0.020958197993800606,
      "median": 2.76382250822,
      "user": 1.6428493199999998,
      "system": 1.3214772399999997,
      "min": 2.7396541982200002,
      "max": 2.8118351502200003,
      "times": [
        2.8118351502200003,
        2.7894171342200003,
        2.75964723522,
        2.74822773222,
        2.78104186022,
        2.7396541982200002,
        2.7735416012200003,
        2.76298255222,
        2.76466246422,
        2.7589644962200004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5691270637200003,
      "stddev": 0.1325700432068971,
      "median": 1.52139721672,
      "user": 0.99835662,
      "system": 1.2233228399999998,
      "min": 1.4594873532200001,
      "max": 1.8572986952200001,
      "times": [
        1.4594873532200001,
        1.46826978422,
        1.6298500112200003,
        1.5192047072200001,
        1.7203906372200002,
        1.4695682922200002,
        1.46092469922,
        1.5826867312200001,
        1.8572986952200001,
        1.52358972622
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.50735592312,
      "stddev": 0.13987031500315797,
      "median": 1.45503846472,
      "user": 1.0042584199999998,
      "system": 1.1801632399999997,
      "min": 1.4235951422200002,
      "max": 1.87576349922,
      "times": [
        1.4358177582200002,
        1.45821998622,
        1.46339477222,
        1.60922014922,
        1.47714288922,
        1.87576349922,
        1.44997763622,
        1.4235951422200002,
        1.4518569432200001,
        1.42857045522
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 591.2 ± 17.8 569.2 619.8 1.93 ± 0.08
pacquet@main 581.3 ± 20.7 548.2 608.5 1.90 ± 0.09
pnpr@HEAD 308.1 ± 8.1 296.7 320.8 1.01 ± 0.04
pnpr@main 305.7 ± 8.7 292.6 323.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5912106543000001,
      "stddev": 0.017778711520689335,
      "median": 0.5930408989,
      "user": 0.70880146,
      "system": 0.6880293,
      "min": 0.5692096659,
      "max": 0.6197833629,
      "times": [
        0.6012415959,
        0.5881477859,
        0.6005151029,
        0.5979340119000001,
        0.6097590609,
        0.6197833629,
        0.5694666979,
        0.5697198929,
        0.5863293659000001,
        0.5692096659
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5813338671,
      "stddev": 0.020654960815233648,
      "median": 0.5795167079000001,
      "user": 0.6850136599999999,
      "system": 0.6771957999999999,
      "min": 0.5482315579,
      "max": 0.6085207789,
      "times": [
        0.5482315579,
        0.5605376999,
        0.5619478839000001,
        0.5776064449,
        0.5814269709000001,
        0.6085207789,
        0.6081044679000001,
        0.5966582999,
        0.5951994829,
        0.5751050839
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3080604715,
      "stddev": 0.008129087173836464,
      "median": 0.3099473449,
      "user": 0.19051785999999998,
      "system": 0.5473629999999998,
      "min": 0.2966833149,
      "max": 0.3207679409,
      "times": [
        0.3019121929,
        0.3104901129,
        0.3157217159,
        0.3207679409,
        0.3146912739,
        0.3114266889,
        0.3094045769,
        0.2979784739,
        0.2966833149,
        0.3015284239
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.3057180546,
      "stddev": 0.008708408726627384,
      "median": 0.30437386040000003,
      "user": 0.19889905999999996,
      "system": 0.5389698999999999,
      "min": 0.2925867699,
      "max": 0.3239291109,
      "times": [
        0.3239291109,
        0.3026116639,
        0.2985036389,
        0.3051441749,
        0.3036035459,
        0.3121258419,
        0.3117013049,
        0.2999415269,
        0.2925867699,
        0.3070329679
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.906 ± 0.010 1.887 1.921 6.26 ± 0.17
pacquet@main 1.900 ± 0.011 1.885 1.917 6.24 ± 0.17
pnpr@HEAD 0.309 ± 0.006 0.298 0.319 1.02 ± 0.03
pnpr@main 0.304 ± 0.008 0.295 0.321 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.90595493558,
      "stddev": 0.010407899397435744,
      "median": 1.9079260792800001,
      "user": 0.9418970199999999,
      "system": 0.7573024599999998,
      "min": 1.88726633128,
      "max": 1.92105137328,
      "times": [
        1.91042612428,
        1.8963832332800001,
        1.90453811928,
        1.91574733428,
        1.92105137328,
        1.88726633128,
        1.9054260342800002,
        1.9112268352800001,
        1.8950708102800002,
        1.91241316028
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.8998030719800003,
      "stddev": 0.011295542952924297,
      "median": 1.89809957028,
      "user": 0.9141751199999998,
      "system": 0.77224106,
      "min": 1.88469077928,
      "max": 1.91739062828,
      "times": [
        1.91739062828,
        1.9068795302800001,
        1.9100171352800002,
        1.91178358028,
        1.8948536132800002,
        1.89165896128,
        1.8924928352800001,
        1.90134552728,
        1.88469077928,
        1.8869181292800001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30941421588000007,
      "stddev": 0.0060236130383600475,
      "median": 0.30878610978,
      "user": 0.19249162,
      "system": 0.55367306,
      "min": 0.29788203028,
      "max": 0.31895400928,
      "times": [
        0.31020843228,
        0.30804781928,
        0.30513955428,
        0.31047421028,
        0.29788203028,
        0.31895400928,
        0.30855053228,
        0.31817662028,
        0.30768726328,
        0.30902168728
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30435015428000006,
      "stddev": 0.008030403921684517,
      "median": 0.30208238878,
      "user": 0.20014852,
      "system": 0.52842966,
      "min": 0.29455585928,
      "max": 0.32110145728,
      "times": [
        0.29455585928,
        0.30741559428,
        0.30933110728,
        0.31136124628,
        0.30004604928,
        0.30054045628,
        0.29802302428,
        0.29750242728,
        0.32110145728,
        0.30362432128
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 360.7 ± 7.2 353.2 379.4 4.15 ± 0.11
pacquet@main 358.4 ± 7.8 348.2 373.9 4.12 ± 0.11
pnpr@HEAD 86.9 ± 1.4 83.7 90.3 1.00
pnpr@main 87.3 ± 1.4 82.9 90.1 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.36066094170000007,
      "stddev": 0.007175114127795322,
      "median": 0.35894997390000005,
      "user": 0.3581003399999999,
      "system": 0.04986728,
      "min": 0.35322279040000004,
      "max": 0.37939803240000003,
      "times": [
        0.35322279040000004,
        0.35735959040000004,
        0.3626702734,
        0.35831361040000004,
        0.3627310174,
        0.3568539114,
        0.3597868044,
        0.3566870494,
        0.3595863374,
        0.37939803240000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.3584066589,
      "stddev": 0.007826609257762773,
      "median": 0.3579526784,
      "user": 0.35098253999999995,
      "system": 0.05636728,
      "min": 0.3481851704,
      "max": 0.37388476940000004,
      "times": [
        0.3613745924,
        0.35453076440000003,
        0.3481851704,
        0.3539450954,
        0.37388476940000004,
        0.3528365664,
        0.3502170424,
        0.3630399064,
        0.36382295540000004,
        0.3622297264
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08694687294545456,
      "stddev": 0.001407621298332183,
      "median": 0.08708309840000002,
      "user": 0.021265643030303025,
      "system": 0.008639042424242425,
      "min": 0.0837417294,
      "max": 0.09033949540000001,
      "times": [
        0.08460833640000001,
        0.0854456454,
        0.08769454540000002,
        0.08478374440000001,
        0.08896132140000002,
        0.08732709540000001,
        0.08690684740000001,
        0.09033949540000001,
        0.08739644640000001,
        0.08615709140000001,
        0.08627295740000002,
        0.0837417294,
        0.08672455440000001,
        0.08421460640000002,
        0.0889274074,
        0.08543751140000001,
        0.08675408040000002,
        0.08709903840000001,
        0.08656348240000002,
        0.08812183740000001,
        0.08719094940000001,
        0.08664624940000001,
        0.08771201740000001,
        0.08696968540000001,
        0.08769256040000001,
        0.08708309840000002,
        0.08797189540000001,
        0.08640993640000001,
        0.08872783240000001,
        0.08711679040000002,
        0.08677576240000001,
        0.08834791040000001,
        0.08712434540000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08727912509696972,
      "stddev": 0.0013756504745851023,
      "median": 0.08723963240000002,
      "user": 0.019348097575757568,
      "system": 0.010511016969696968,
      "min": 0.08293650940000001,
      "max": 0.09011424440000002,
      "times": [
        0.0865900534,
        0.08720425540000001,
        0.0867483004,
        0.08698051440000001,
        0.08731559440000002,
        0.08674138640000001,
        0.08799522940000001,
        0.08686265340000002,
        0.08629047140000001,
        0.0878499664,
        0.08773724540000001,
        0.08723963240000002,
        0.08762442240000001,
        0.08761138040000001,
        0.08665747940000001,
        0.08844463240000001,
        0.08585901140000002,
        0.09011424440000002,
        0.08598999640000002,
        0.08965508240000002,
        0.08293650940000001,
        0.08971349340000001,
        0.08718652140000001,
        0.08928144240000001,
        0.08542718140000001,
        0.08605658240000001,
        0.08807406740000001,
        0.08698889040000002,
        0.0875228734,
        0.08770204840000001,
        0.08581599140000001,
        0.08788338840000001,
        0.08811058640000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.568 ± 0.184 4.424 4.887 1.30 ± 0.06
pacquet@main 4.555 ± 0.122 4.432 4.833 1.30 ± 0.04
pnpr@HEAD 3.508 ± 0.060 3.449 3.625 1.00
pnpr@main 3.530 ± 0.104 3.445 3.783 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.5684311406600004,
      "stddev": 0.18420619732072963,
      "median": 4.47643089056,
      "user": 1.7186855399999998,
      "system": 1.3915841800000002,
      "min": 4.42426982706,
      "max": 4.88688314606,
      "times": [
        4.52975982606,
        4.88688314606,
        4.47694222506,
        4.42640918906,
        4.43044371806,
        4.79217580406,
        4.47591955606,
        4.42426982706,
        4.43364280006,
        4.80786531506
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.55508626356,
      "stddev": 0.12221232578932759,
      "median": 4.53487258356,
      "user": 1.70282424,
      "system": 1.40170838,
      "min": 4.43218436306,
      "max": 4.83340494506,
      "times": [
        4.83340494506,
        4.60656315006,
        4.43218436306,
        4.51089758706,
        4.54384191606,
        4.45054456506,
        4.65715342506,
        4.43292376506,
        4.52590325106,
        4.55744566806
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.50814166396,
      "stddev": 0.059986157080731406,
      "median": 3.48334564556,
      "user": 1.2111172399999997,
      "system": 1.2131207800000001,
      "min": 3.44941184006,
      "max": 3.62484348906,
      "times": [
        3.54434295606,
        3.47465840706,
        3.49203288406,
        3.45328343506,
        3.45711613406,
        3.62484348906,
        3.44941184006,
        3.53012179506,
        3.58145034606,
        3.47415535306
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5297990327599997,
      "stddev": 0.10380668883729854,
      "median": 3.48905366956,
      "user": 1.1734773400000003,
      "system": 1.2447521799999999,
      "min": 3.44477291706,
      "max": 3.78258796306,
      "times": [
        3.44477291706,
        3.48231205606,
        3.49579528306,
        3.62181513606,
        3.5684803930599998,
        3.46435354406,
        3.46727134806,
        3.78258796306,
        3.47258679006,
        3.49801489706
      ]
    }
  ]
}

…ifest

Review follow-ups on the workspace-root peer-hoist fix.

The picker matches a root dep by alias *and* by real package name, and
`build_workspace_root_deps` dropped every dep whose name the resolver
couldn't report. Local, tarball and directory resolutions all leave
`name_ver` unset — `ResolveResult::name_ver`'s own doc nominates the
fetched manifest as the canonical name for exactly those protocols — so
read it from there, the same fallback `deprecated_pkg_name_ver` already
uses. A git resolution reports no manifest until after the fetch, which
is past the point the picker runs, so those stay matched by alias alone.

Naming those resolutions has a consequence of its own: it would let a
`link:` / `file:` / `workspace:` specifier become a candidate, and such a
specifier resolves against the consuming project's directory, so handing
the root's copy to another importer would reach a different path or
nothing at all. Every candidate specifier now passes through
`cross_importer_specifier`, which rejects that prefix set — the same one
`project_relative_cache_scope` uses to decide a resolution is
project-scoped. Local resolutions were never candidates before this
series, since they always report `name_ver: None`, so the gate restores
that invariant rather than narrowing anything that used to work.

Also parse each optional peer's ranges once instead of once per candidate
version, and split the changeset in two so each fix carries its own
release note.

Related to #13320.
@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13343
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,759.01 ms
(-1.07%)Baseline: 2,788.78 ms
3,346.53 ms
(82.44%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,887.27 ms
(-3.61%)Baseline: 1,958.03 ms
2,349.63 ms
(80.32%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
569.21 ms
(-10.39%)Baseline: 635.20 ms
762.24 ms
(74.68%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
353.22 ms
(-9.72%)Baseline: 391.26 ms
469.51 ms
(75.23%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,374.56 ms
(-0.70%)Baseline: 2,391.37 ms
2,869.65 ms
(82.75%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,424.27 ms
(-1.48%)Baseline: 4,490.56 ms
5,388.67 ms
(82.10%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
247.16 ms
(-6.52%)Baseline: 264.40 ms
317.28 ms
(77.90%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13343
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,459.49 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
297.88 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
296.68 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
83.74 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,353.04 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,449.41 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
266.18 ms
🐰 View full continuous benchmarking report in Bencher

Copilot AI review requested due to automatic review settings July 25, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Both applied in 774f9c449e.

Split the changeset. Done — peer-hoist-reads-workspace-root-deps.md now covers only the workspace-root sourcing, and optional-peer-prerelease-strictness.md covers the optional-peer range enforcement. Two unrelated bugs, two release notes.

Hoist range parsing out of the per-version loop. Done, as proposed. Worth noting for the record that the rewrite is behavior-preserving including for invalid input: previously an unparseable range made is_ok_and false for every candidate, so max_satisfying_version stayed None and the peer got no entry; now the collect::<Result<…>> bails on the peer directly, which reaches the same outcome without the per-version reparse. That also matches the TypeScript side, where semver.satisfies returns false for a malformed range rather than throwing.


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

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Thanks — two of the three are valid and fixed in 774f9c449e; the third I'm declining, with reasoning.

1. Historical comment in test — fixed

Right, and it's a repo convention I should have caught myself: AGENTS.md puts it as "Do not record past implementation shape, refactor history, or 'the previous code did X' framing." Rephrased as the conditional consequence you suggested:

/// workspace: if the picker were sourced from the hoisting importer, it
/// would find no candidate there and resolve a second `react` from the
/// range.

2. Root spec resolved wrong dir — valid, fixed with your option 2

Confirmed reachable, and I took the conservative option: a link: / file: / workspace: specifier is no longer offered as a cross-importer peer provider. The prefix set is the same one project_relative_cache_scope already uses to decide that a resolution is project-dir-scoped, so the two agree on what "resolves relative to the consuming project" means.

One correction to the analysis, which narrows where this actually bit: the local resolver sets normalized_bare_specifier: Some(...) on every arm, so the .or_else(declared) fallback never saw a local specifier — those deps already carried their own, before this PR. The reachable path was the new declared-only loop, entered when a dep has neither name_ver nor a manifest: the local-tarball arm and the lockfile-pinned-directory arm both return manifest: None, so a root "dep": "file:./vendor/x.tgz" did land there and could be handed to another importer. Both fallbacks are now behind the same guard.

Test: a_project_relative_root_dep_is_not_offered_as_a_peer_provider — a root file: dep whose name can't be resolved, and a non-root importer whose peer must resolve normally instead of inheriting the path.

3. pnpm missing from changeset — declining

This one contradicts the repo's documented rule. AGENTS.md:

Do not add "pnpm" to a Rust-only changeset: in changesets, pnpm always means the TypeScript CLI package. A changeset whose implementation is Rust-only and targets pacquet must omit "pnpm".

This PR is Rust-only — no TypeScript package changes — so "pacquet": patch alone is correct. Your own note on the finding agrees ("Exact precedent: team repeatedly rejected adding pnpm entry to pacquet-only changesets", ⭐ Low), so compliance rule 713436 looks like it needs the Rust-only carve-out encoded.


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

`project_relative_cache_scope` is a private function in a private
module, so the link had nothing to resolve to and `Rust CI / Doc` failed
it under `-D rustdoc::broken-intra-doc-links`. Name it in backticks
instead — the reference is for a reader following the convention across
the two call sites, not a navigable API link.
Copilot AI review requested due to automatic review settings July 25, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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

kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…s deps (pnpm#13343)

`resolvePeersFromWorkspaceRoot` is meant to let any project satisfy a
missing peer from the workspace root's dependencies. The picker was fed
`self.direct` — the deps of whichever importer was being resolved — so a
project that didn't declare the peer itself saw no candidate and resolved
a second copy from the registry. The field doc said as much
("Single-importer pacquet treats the importer as the root"), left over
from before the multi-importer orchestrator existed.

`resolve_workspace` now builds the root importer's list once, after the
phase-1 init barrier, and shares it with every importer's hoist rounds;
computing it once also matches pnpm, where the root's own hoisted peers
never become root-dep candidates for the importers hoisted after it. An
importer set without the root leaves the list empty, mirroring pnpm's
absent-root-importer case.

`build_workspace_root_deps` also needed pnpm's two specifier sources to
be of any use: the resolver reports `normalized_bare_specifier` only for
specs that needed normalizing, so a plain "19.2.0" arrived as `None` and
the picker skipped the root dep entirely. Fall back to the declared
specifier, and include deps the resolver couldn't name at resolution
time (git / tarball / local), matching `getHoistableRootDeps`.

Separately, `get_hoistable_optional_peers` now checks ranges with plain
semver instead of the prerelease-tolerant helper, matching the bare
`semver.satisfies` in `getHoistableOptionalPeers`. A prerelease is not a
stand-in for a range that didn't ask for one: `ts-jest` declares
`@jest/transform` and `jest-util` as optional peers with
`^29.0.0 || ^30.0.0`, and a jest 30 prerelease elsewhere in the graph
was binding them to `30.0.0-alpha.6` while `jest` itself stayed on 29.

Both were found resolving vercel/next.js, whose `overrides` pin `react`
to one canary build: pnpm 12 produced a second `[email protected]` and paired
it with the canary `react-dom`, violating that package's exact peer pin.
The remaining required-peer prerelease divergence is pnpm#13341.

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants