Skip to content

feat(peers): accept scheme-carrying specifiers in peerDependencies - #13110

Merged
zkochan merged 3 commits into
mainfrom
accept-scheme-peer-specifiers
Jul 17, 2026
Merged

zkochan merged 3 commits into
mainfrom
accept-scheme-peer-specifiers

Conversation

@zkochan

@zkochan zkochan commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

Summary

peerDependencies rejected any value that was not a semver range or a workspace:/catalog: spec, throwing ERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION. This blocked named-registry specifiers like work:5.x.x in peers, even though they work fine in dependencies/devDependencies (Closes #13095).

This PR accepts any specifier that carries a scheme — a named-registry spec (<registry>:<version>), an npm: alias, or a file:/git/URL spec. During resolution the peer is matched against the semver range the specifier carries (work:5.x.x → 5.x.x, npm:bar@^5 → ^5), or against * when it carries no version, while the original specifier still selects the package to auto-install. Bare name@version values (no scheme, not valid semver) are still rejected, since they are almost always a mistake.

A shared getPeerVersionRange/get_peer_version_range helper extracts the comparable range at every point a peer is matched: the satisfaction check, the hoistPeers auto-install selection (so a scheme peer dedupes onto a compatible version instead of the highest one in the tree), and the peers checker. Validation is relaxed via isAcceptablePeerSpec/is_acceptable_peer_spec. The original specifier is preserved wherever a missing peer is actually fetched, so auto-install still resolves from the right source.

TypeScript: new helpers in @pnpm/deps.peer-range; validatePeerDependencies, both resolvePeers match sites, hoistPeers, and the peers-checker route through them.

Rust (parity): new shared peer_range module in resolving-resolver-base (which also absorbs the two duplicated is_valid_peer_range copies); resolve_peers, hoist_peers, and the pnpm peers command use it. MissingPeer carries the extracted range for matching/display and the original specifier for the hoist source, so warnings show the same normalized range as the TypeScript CLI while auto-install still fetches from the right source.

Squash Commit Body

peerDependencies previously rejected any value that was not a semver range or a
`workspace:`/`catalog:` spec with ERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION.
This blocked named-registry specifiers (`<registry>:<version>`), which are
otherwise usable in dependencies/devDependencies (pnpm/pnpm#13095).

Accept any specifier that carries a scheme (named-registry, `npm:`, `file:`,
git/URL). A shared getPeerVersionRange helper extracts the comparable range
everywhere a peer is matched — the satisfaction check, the hoistPeers
auto-install selection, and the peers checker — matching `work:5.x.x` as
`5.x.x` and `npm:bar@^5` as `^5`, or `*` when no version is carried, while the
original specifier still selects the package to auto-install. isAcceptablePeerSpec
relaxes validation while still rejecting bare `name@version` typos.

The same change lands in the Rust port: a shared `peer_range` module in
resolving-resolver-base (which also absorbs the two duplicated
`is_valid_peer_range` copies), resolve_peers, hoist_peers, and the `pnpm peers`
command. MissingPeer carries the extracted range for matching/display and the
original specifier for the hoist source, so both stacks show the same warning
text and auto-install from the right source.

Closes pnpm/pnpm#13095.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pnpm/ port.
  • Added a changeset.
  • Added or updated tests.

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

Summary by CodeRabbit

  • New Features
    • Peer dependencies now accept scheme-based specifiers (for example named registries, npm: aliases, local file: sources, and Git/URL-style specs), enabling better matching and auto-install when configured.
    • Peer range handling is now normalized from these specifiers for more accurate compatibility checks and peer hoisting, including || unions.
  • Bug Fixes
    • Peer validation and issue reporting were improved so matching uses the extracted version range while package selection still follows the original spec.
    • Continued rejection of bare name@version peer values with the existing validation error.
  • Tests
    • Added coverage for named-registry (work:) peer specs and related hoisting/matching scenarios.

peerDependencies previously rejected any value that was not a semver range
or a `workspace:`/`catalog:` spec with
ERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION. This blocked named-registry
specifiers (`<registry>:<version>`), which are otherwise usable in
dependencies/devDependencies (#13095).

Accept any specifier that carries a scheme (named-registry, `npm:`, `file:`,
git/URL). During resolution the peer is matched against the semver range the
specifier carries — `work:5.x.x` is checked as `5.x.x`, `npm:bar@^5` as `^5` —
or against `*` when it carries no version, while the original specifier still
selects the package to auto-install. The install source was already preserved
in both stacks, so only the validator and the satisfaction check needed to
change: a new shared `getPeerVersionRange` helper extracts the comparable range
at the match sites, and `isAcceptablePeerSpec` relaxes validation while still
rejecting bare `name@version` typos.

The same change lands in the Rust port: a shared `peer_range` module in
resolving-resolver-base (which also absorbs the two duplicated
`is_valid_peer_range` copies), the resolve_peers satisfaction check, and the
`pnpm peers` command. Because the Rust peer path reuses one field for both the
hoist source and the unmet-peer display, an unmet named-registry peer's warning
shows the raw specifier there rather than the extracted range; resolution
behavior is identical.

Closes #13095.
Copilot AI review requested due to automatic review settings July 17, 2026 18:18

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

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 656a4873-67e2-44d8-b513-4fb2a04c3f34

📥 Commits

Reviewing files that changed from the base of the PR and between 2ea26bb and 3bc9685.

📒 Files selected for processing (6)
  • pnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rs
  • pnpm/crates/resolving-resolver-base/src/peer_range.rs
  • pnpm/crates/resolving-resolver-base/src/peer_range/tests.rs
  • pnpm11/deps/peer-range/src/index.ts
  • pnpm11/installing/deps-resolver/test/getPeerVersionRange.test.ts
  • pnpm11/installing/deps-resolver/test/hoistPeers.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • pnpm11/installing/deps-resolver/test/hoistPeers.test.ts
  • pnpm11/installing/deps-resolver/test/getPeerVersionRange.test.ts
  • pnpm/crates/resolving-resolver-base/src/peer_range/tests.rs
  • pnpm11/deps/peer-range/src/index.ts
  • pnpm/crates/resolving-resolver-base/src/peer_range.rs

📝 Walkthrough

Walkthrough

Peer dependency handling now accepts scheme-bearing specifiers, derives comparable semver ranges for matching, preserves invalid bare name@version rejection, and shares the behavior across TypeScript and Rust implementations with added tests.

Changes

Peer Scheme Support

Layer / File(s) Summary
Shared peer range helpers
pnpm/crates/resolving-resolver-base/src/*, pnpm11/deps/peer-range/src/*, pnpm/**/peer_range/tests.rs, pnpm11/installing/deps-resolver/test/getPeerVersionRange.test.ts
Adds shared validation and normalization for semver, workspace/catalog, named-registry, npm, file, and git-style peer specifications.
TypeScript validation and resolution
pnpm11/deps/inspection/peers-checker/*, pnpm11/installing/deps-resolver/src/*, pnpm11/installing/deps-installer/test/install/*, pnpm11/installing/deps-resolver/test/*, .changeset/peer-scheme-specifiers.md
TypeScript installation and inspection paths accept scheme-bearing peer specs and use extracted ranges for satisfaction checks and issue reporting.
Rust peer resolution integration
pnpm/crates/resolving-deps-resolver/*, pnpm/crates/cli/src/cli_args/peers.rs, pnpm/crates/package-manager/src/*, pnpm/crates/napi/src/install/tests.rs
Rust peer resolution, hoisting, CLI checks, and package-manager validation use normalized ranges and preserve raw specifiers for propagation and installation decisions.

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

Sequence Diagram(s)

sequenceDiagram
  participant Manifest as peerDependencies manifest
  participant Validator as validatePeerDependencies
  participant RangeHelper as getPeerVersionRange
  participant Resolver as peer resolver
  participant Hoister as hoistPeers
  Manifest->>Validator: scheme-bearing peer specifier
  Validator->>RangeHelper: normalize accepted specifier
  RangeHelper->>Resolver: semver-comparable range
  Resolver->>Hoister: raw specifier and normalized wanted range
  Hoister->>Resolver: satisfying preferred peer or raw specifier
Loading

Assessment against linked issues

Objective Addressed Explanation
Accept named registry alias specifiers in peerDependencies [#13095] ✅

Possibly related issues

  • pnpm/pnpm#11633 — The changes add named-registry peer-specifier handling across Rust resolution and peer validation paths.

Possibly related PRs

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

Suggested reviewers: copilot, spencerbeggs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch accept-scheme-peer-specifiers

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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

Accept scheme-carrying peerDependency specifiers (named registry, npm:, file/git/URL)

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Allow scheme-carrying peerDependency specs (named registry, npm:, file/git/URL) instead of
 erroring.
• Match peers against an extracted semver range while preserving original spec for auto-install.
• Add parity Rust implementation and tests across resolver, peers-checker, and CLI behavior.
Diagram

graph TD
  A["package.json peerDependencies"] --> B["Peer spec validation (TS/Rust)"] --> C["Peer-range helper (getPeerVersionRange)"] --> D["Peer satisfaction check (resolvePeers/resolve_peers)"] --> E[("pnpm-lock / snapshots")] --> F["Reporting & tooling (peers-checker / pnpm peers)"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use a full dependency-spec parser for schemes and range extraction
  • ➕ More robust handling of edge cases (multiple ':' segments, uncommon URL forms)
  • ➕ Single source of truth for spec parsing across the codebase
  • ➖ Higher implementation complexity and potential behavior changes vs current minimal diff
  • ➖ May require aligning TS and Rust parsing libraries/semantics
2. Accept any non-semver peer spec (even without a scheme) but warn
  • ➕ Maximum compatibility; avoids rejecting unusual but intentional specs
  • ➕ Reduces need for users to learn scheme requirements
  • ➖ Would permit common typos like name@version silently, increasing misconfigurations
  • ➖ Harder to provide clear correctness guarantees for peer matching

Recommendation: The chosen approach is the best tradeoff: it unblocks real-world specs (named registries, npm:, file/git/URL) while keeping a strict guardrail against bare name@version mistakes. The shared getPeerVersionRange/get_peer_version_range helper also keeps the satisfaction logic consistent across TS and Rust. If future edge cases appear, consider migrating the helper’s internal parsing to the existing wanted-dependency/spec parser to further harden correctness.

Files changed (21) +604 / -200

Enhancement (7) +126 / -15
peers.rsUse extracted peer range when checking peers in Rust CLI +10/-7

Use extracted peer range when checking peers in Rust CLI

• Routes peer satisfaction checks through get_peer_version_range so scheme-carrying peer specs are matched via their semver body. Keeps the raw spec available for issue reporting/auto-install selection.

pnpm/crates/cli/src/cli_args/peers.rs

resolve_peers.rsMatch peers using get_peer_version_range in Rust resolver +8/-2

Match peers using get_peer_version_range in Rust resolver

• Introduces a separate range_for_satisfies derived from the raw peer specifier so named-registry and npm: aliases match by their semver payload. Preserves raw spec (minus workspace: stripping) for auto-install/missing-peer reporting.

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

peer_range.rsIntroduce Rust peer_range helpers (validation + desugaring) +57/-0

Introduce Rust peer_range helpers (validation + desugaring)

• Adds shared Rust helpers that (1) validate strict peer ranges, (2) accept any scheme-carrying peer spec at install time, and (3) extract the comparable semver range (or '*') for satisfaction checks.

pnpm/crates/resolving-resolver-base/src/peer_range.rs

checkPeerDependencies.tsUse getPeerVersionRange in peers-checker satisfaction logic +3/-1

Use getPeerVersionRange in peers-checker satisfaction logic

• Changes peer snapshot iteration to desugar raw peer specifiers into comparable ranges before checking satisfaction, matching resolver behavior.

pnpm11/deps/inspection/peers-checker/src/checkPeerDependencies.ts

index.tsAdd isAcceptablePeerSpec and getPeerVersionRange helpers (TS) +42/-0

Add isAcceptablePeerSpec and getPeerVersionRange helpers (TS)

• Introduces an install-time acceptance predicate for scheme-carrying specs and a shared extractor that converts scheme specs into comparable semver ranges (or '*') for matching.

pnpm11/deps/peer-range/src/index.ts

resolvePeers.tsMatch peers using getPeerVersionRange in TS resolver +3/-2

Match peers using getPeerVersionRange in TS resolver

• Replaces workspace:-only stripping with getPeerVersionRange at peer satisfaction sites so named registries, npm: aliases, and opaque specs behave correctly.

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

validatePeerDependencies.tsRelax peerDependencies validation to accept scheme-carrying specs +3/-3

Relax peerDependencies validation to accept scheme-carrying specs

• Switches from isValidPeerRange to isAcceptablePeerSpec, expanding accepted inputs while keeping a clear error/hint for bare name@version typos.

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

Refactor (3) +5 / -14
overrides.rsDeduplicate peer range validation by importing shared helper +1/-6

Deduplicate peer range validation by importing shared helper

• Removes a local is_valid_peer_range implementation and reuses the shared resolver-base version to keep behavior consistent.

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

update_project_manifest_object.rsReuse shared peer range validation helper +2/-8

Reuse shared peer range validation helper

• Drops the local is_valid_peer_range helper and imports the shared resolver-base version, reducing duplication and aligning semantics.

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

lib.rsExport shared peer-range utilities from resolver-base +2/-0

Export shared peer-range utilities from resolver-base

• Adds the new peer_range module and re-exports is_valid_peer_range, is_acceptable_peer_spec, and get_peer_version_range for reuse across crates.

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

Tests (6) +202 / -37
tests.rsAdd Rust tests for named-registry peer matching +59/-0

Add Rust tests for named-registry peer matching

• Adds coverage proving that peers declared as work:^1.0.0 are satisfied via extracted range, and that unmet extracted ranges report bad peer issues.

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

tests.rsUnit tests for Rust peer_range helpers +61/-0

Unit tests for Rust peer_range helpers

• Covers valid peer range detection, acceptable peer spec relaxation, name@version typo rejection, and range extraction/fallback behavior.

pnpm/crates/resolving-resolver-base/src/peer_range/tests.rs

autoInstallPeers.tsTest auto-install behavior for scheme-carrying peer specifiers +15/-0

Test auto-install behavior for scheme-carrying peer specifiers

• Adds an integration test ensuring npm: alias peers are accepted and auto-installed when autoInstallPeers is enabled.

pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts

validatePeerDependencies.tsUpdate invalid peer spec test to use bare name@version typo +4/-4

Update invalid peer spec test to use bare name@version typo

• Adjusts validation tests so the rejected case is [email protected] (no scheme, not a semver range) rather than link:foo, aligning with the new acceptance rules.

pnpm11/installing/deps-installer/test/install/validatePeerDependencies.ts

getPeerVersionRange.test.tsAdd TS tests for peer range acceptance and extraction +55/-0

Add TS tests for peer range acceptance and extraction

• Adds unit tests for isValidPeerRange vs isAcceptablePeerSpec, workspace stripping, named-registry/npm extraction, and '*' fallback for non-comparable specs.

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

validatePeerDependencies.test.tsUpdate validation tests to accept scheme-carrying specs +8/-33

Update validation tests to accept scheme-carrying specs

• Replaces prior 'forbids file/link schemes' cases with a positive test confirming named-registry, npm:, file/link, and git/URL peer specs are accepted.

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

Documentation (1) +9 / -0
peer-scheme-specifiers.mdChangeset documenting scheme-carrying peer spec support +9/-0

Changeset documenting scheme-carrying peer spec support

• Adds release notes describing the newly accepted peerDependencies specifier forms and how matching is performed (extracted semver range vs raw spec).

.changeset/peer-scheme-specifiers.md

Other (4) +262 / -134
pnpm-lock.yamlLockfile refresh plus new workspace link to deps.peer-range +257/-134

Lockfile refresh plus new workspace link to deps.peer-range

• Updates several catalog dependency versions as part of a lockfile refresh. Also adds @pnpm/deps.peer-range as a workspace dependency for peers-checker-related packages.

pnpm-lock.yaml

Cargo.tomlAdd node-semver dependency for shared peer-range module +1/-0

Add node-semver dependency for shared peer-range module

• Introduces node-semver as a workspace dependency so resolving-resolver-base can parse/validate ranges centrally.

pnpm/crates/resolving-resolver-base/Cargo.toml

package.jsonAdd deps.peer-range dependency to peers-checker +1/-0

Add deps.peer-range dependency to peers-checker

• Adds @pnpm/deps.peer-range so peers-checker can use the same extraction logic as the resolver.

pnpm11/deps/inspection/peers-checker/package.json

tsconfig.jsonWire peer-range workspace project into peers-checker TS config +3/-0

Wire peer-range workspace project into peers-checker TS config

• Adds the peer-range workspace path reference to ensure local builds/typechecking resolve the new dependency correctly.

pnpm11/deps/inspection/peers-checker/tsconfig.json

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     15.0±1.08ms    25.0 MB/sec    1.20     18.0±2.50ms    20.8 MB/sec
packument/parse                1.03     50.0±5.09µs  1327.1 MB/sec    1.00     48.3±1.84µs  1373.3 MB/sec
tarball/download_dependency    1.00      3.3±0.44ms  1322.7 KB/sec    1.17      3.8±0.73ms  1132.3 KB/sec

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
pnpm/crates/cli/src/cli_args/peers.rs (1)

256-317: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve the original peer specifier for wanted_range in warnings.

The CLI peer inspection logic overwrites the raw peer specifier with the normalized range (e.g., yielding ^5 instead of npm:bar@^5). Consequently, the unmet-peer warnings display the normalized string rather than the original user-supplied specifier. As per path instructions, Pacquet must maintain strict behavioral parity with the TypeScript CLI for any user-visible behavior, including unmet-peer warning text.

Both of these sites share this root cause and should split the range into a matching range and a satisfiability range, identical to the approach used in resolve_peers.rs:

  • pnpm/crates/cli/src/cli_args/peers.rs#L256-L317: In check_linked_package_peers, retain the original specifier (stripping only workspace:) for wanted_range and use the normalized range solely for the satisfies check.
  • pnpm/crates/cli/src/cli_args/peers.rs#L404-L471: Apply the same separation in walk_snapshot.
🛠️ Proposed fixes for both sites

For check_linked_package_peers (around line 256):

-    for (peer_name, peer_range_val) in peer_deps {
-        let Some(peer_range) = peer_range_val.as_str() else { continue };
-        let peer_range = get_peer_version_range(peer_range);
+    for (peer_name, peer_range_val) in peer_deps {
+        let Some(raw_peer_range) = peer_range_val.as_str() else { continue };
+        let range_for_match = raw_peer_range.strip_prefix("workspace:").unwrap_or(raw_peer_range);
+        let range_for_satisfies = get_peer_version_range(raw_peer_range);
         let is_optional = manifest
             .value()
             .get("peerDependenciesMeta")
             .and_then(|meta_map| meta_map.get(peer_name))
             .and_then(|peer_meta| peer_meta.get("optional"))
             .and_then(serde_json::Value::as_bool)
             .unwrap_or(false);

         let Ok(peer_pkg_name) = peer_name.parse::<PkgName>() else { continue };
         let resolved_ref = importer
             .dependencies
             .as_ref()
             .and_then(|deps| deps.get(&peer_pkg_name))
             .or_else(|| {
                 importer.dev_dependencies.as_ref().and_then(|deps| deps.get(&peer_pkg_name))
             })
             .or_else(|| {
                 importer.optional_dependencies.as_ref().and_then(|deps| deps.get(&peer_pkg_name))
             });

         match resolved_ref {
             Some(spec) => {
                 if let Some(ver_peer) = spec.version.ver_peer() {
                     let version_str = ver_peer.version().to_string();
-                    if !satisfies(&version_str, &peer_range) {
+                    if !satisfies(&version_str, &range_for_satisfies) {
                         issues.bad.entry(peer_name.clone()).or_default().push(BadPeerIssue {
                             parents: current_parents.clone(),
                             optional: is_optional,
-                            wanted_range: peer_range.clone(),
+                            wanted_range: range_for_match.to_string(),
                             found_version: version_str,
                             resolved_from: Vec::new(),
                         });
                     }
                 } else if let Some(link_target) = spec.version.as_link_target() {
                     let found_version =
                         resolve_link_version(&importer_dir, lockfile_dir, link_target)
                             .unwrap_or_else(|| format!("link:{link_target}"));
-                    if !satisfies(&found_version, &peer_range) {
+                    if !satisfies(&found_version, &range_for_satisfies) {
                         issues.bad.entry(peer_name.clone()).or_default().push(BadPeerIssue {
                             parents: current_parents.clone(),
                             optional: is_optional,
-                            wanted_range: peer_range.clone(),
+                            wanted_range: range_for_match.to_string(),
                             found_version,
                             resolved_from: Vec::new(),
                         });
                     }
                 }
             }
             None => {
                 if !is_optional {
                     issues.missing.entry(peer_name.clone()).or_default().push(MissingPeerIssue {
                         parents: current_parents.clone(),
                         optional: is_optional,
-                        wanted_range: peer_range.clone(),
+                        wanted_range: range_for_match.to_string(),
                     });
                 }
             }
         }
     }

For walk_snapshot (around line 404):

-            for (peer_name, peer_range) in peers {
-                let peer_range = get_peer_version_range(peer_range);
+            for (peer_name, raw_peer_range) in peers {
+                let range_for_match = raw_peer_range.strip_prefix("workspace:").unwrap_or(raw_peer_range);
+                let range_for_satisfies = get_peer_version_range(raw_peer_range);
                 let is_optional = meta
                     .peer_dependencies_meta
                     .as_ref()
                     .and_then(|meta_map| meta_map.get(peer_name))
                     .is_some_and(|peer_meta| peer_meta.optional);

                 let Ok(peer_pkg_name) = peer_name.parse::<PkgName>() else { continue };
                 let resolved_ref = snapshot.and_then(|snapshot_entry| {
                     snapshot_entry
                         .dependencies
                         .as_ref()
                         .and_then(|deps| deps.get(&peer_pkg_name))
                         .or_else(|| {
                             snapshot_entry
                                 .optional_dependencies
                                 .as_ref()
                                 .and_then(|deps| deps.get(&peer_pkg_name))
                         })
                 });

                 match resolved_ref {
                     Some(dep_ref) => {
                         if let Some(ver_peer) = dep_ref.ver_peer() {
                             let version_str = ver_peer.version().to_string();
-                            if !satisfies(&version_str, &peer_range) {
+                            if !satisfies(&version_str, &range_for_satisfies) {
                                 issues.bad.entry(peer_name.clone()).or_default().push(
                                     BadPeerIssue {
                                         parents: current_parents.clone(),
                                         optional: is_optional,
-                                        wanted_range: peer_range.clone(),
+                                        wanted_range: range_for_match.to_string(),
                                         found_version: version_str,
                                         resolved_from: Vec::new(),
                                     },
                                 );
                             }
                         } else if let Some(link_target) = dep_ref.as_link_target() {
                             let found_version =
                                 resolve_link_version(lockfile_dir, lockfile_dir, link_target)
                                     .unwrap_or_else(|| format!("link:{link_target}"));
-                            if !satisfies(&found_version, &peer_range) {
+                            if !satisfies(&found_version, &range_for_satisfies) {
                                 issues.bad.entry(peer_name.clone()).or_default().push(
                                     BadPeerIssue {
                                         parents: current_parents.clone(),
                                         optional: is_optional,
-                                        wanted_range: peer_range.clone(),
+                                        wanted_range: range_for_match.to_string(),
                                         found_version,
                                         resolved_from: Vec::new(),
                                     },
                                 );
                             }
                         }
                     }
                     None => {
                         if !is_optional {
                             issues.missing.entry(peer_name.clone()).or_default().push(
                                 MissingPeerIssue {
                                     parents: current_parents.clone(),
                                     optional: is_optional,
-                                    wanted_range: peer_range.clone(),
+                                    wanted_range: range_for_match.to_string(),
                                 },
                             );
                         }
                     }
                 }
             }
🤖 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/cli/src/cli_args/peers.rs` around lines 256 - 317, The peer
inspection logic must preserve the original user-supplied specifier for warning
fields while using a normalized range only for satisfaction checks. In
check_linked_package_peers at pnpm/crates/cli/src/cli_args/peers.rs#L256-L317,
retain the specifier after stripping only workspace: for wanted_range and create
a separate normalized range for satisfies; apply the same separation in
walk_snapshot at pnpm/crates/cli/src/cli_args/peers.rs#L404-L471.

Source: Path instructions

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

Outside diff comments:
In `@pnpm/crates/cli/src/cli_args/peers.rs`:
- Around line 256-317: The peer inspection logic must preserve the original
user-supplied specifier for warning fields while using a normalized range only
for satisfaction checks. In check_linked_package_peers at
pnpm/crates/cli/src/cli_args/peers.rs#L256-L317, retain the specifier after
stripping only workspace: for wanted_range and create a separate normalized
range for satisfies; apply the same separation in walk_snapshot at
pnpm/crates/cli/src/cli_args/peers.rs#L404-L471.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b62a4fc7-b86f-45cb-944b-6963745399ba

📥 Commits

Reviewing files that changed from the base of the PR and between 053fab2 and 26ef5fd.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (20)
  • .changeset/peer-scheme-specifiers.md
  • pnpm/crates/cli/src/cli_args/peers.rs
  • pnpm/crates/package-manager/src/overrides.rs
  • pnpm/crates/package-manager/src/update_project_manifest_object.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
  • pnpm/crates/resolving-resolver-base/Cargo.toml
  • pnpm/crates/resolving-resolver-base/src/lib.rs
  • pnpm/crates/resolving-resolver-base/src/peer_range.rs
  • pnpm/crates/resolving-resolver-base/src/peer_range/tests.rs
  • pnpm11/deps/inspection/peers-checker/package.json
  • pnpm11/deps/inspection/peers-checker/src/checkPeerDependencies.ts
  • pnpm11/deps/inspection/peers-checker/tsconfig.json
  • pnpm11/deps/peer-range/src/index.ts
  • pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts
  • pnpm11/installing/deps-installer/test/install/validatePeerDependencies.ts
  • pnpm11/installing/deps-resolver/src/resolvePeers.ts
  • pnpm11/installing/deps-resolver/src/validatePeerDependencies.ts
  • pnpm11/installing/deps-resolver/test/getPeerVersionRange.test.ts
  • pnpm11/installing/deps-resolver/test/validatePeerDependencies.test.ts

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

greptile-apps Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — additive change guarded by a well-tested shared helper in both stacks.

The core logic is encapsulated in a single helper mirrored identically in TypeScript and Rust. Every peer-matching site routes through it consistently. No existing behaviour is broken.

No files require special attention.

Reviews (3): Last reviewed commit: "fix(peers): reduce a merged union of sch..." | Re-trigger Greptile

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Scheme OR breaks matching ✓ Resolved 🐞 Bug ≡ Correctness
Description
partition_missing_peers() now merges required peer specs using MissingPeer.raw_range, so
multi-consumer peers can become ||-joined scheme strings like work:^1.0.0 || work:^2.0.0. The
peer-range extractor then fails to parse the body and falls back to *, letting hoist_peers()
select the highest preferred version even if it satisfies neither original range (reintroducing
incompatible-major auto-installs).
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R610-618]

+        // Hoisting a missing required peer fetches it, so it needs the original
+        // specifier with its scheme preserved (`work:5.x.x`); hoist_peers reduces
+        // it to a comparable range itself. The optional path below dedupes onto
+        // an already-present version, so it uses the display range instead.
        let required_ranges: Vec<&str> = entries
            .iter()
            .filter(|entry| !entry.optional)
-            .map(|entry| entry.wanted_range.as_str())
+            .map(|entry| entry.raw_range.as_str())
            .collect();
Evidence
The required-peer merge now collects raw_range values and may ||-join them (when configured).
raw_range is explicitly scheme-preserving, while get_peer_version_range only extracts a semver
body from a single leading scheme:; if the scheme: appears again later in a ||-joined string,
extraction fails and returns *, which makes hoist_peers pick the highest preferred version
regardless of the original constraints.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[599-638]
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[642-665]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[1269-1306]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[87-116]
pnpm/crates/resolving-resolver-base/src/peer_range.rs[38-54]

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

## Issue description
Required missing-peer ranges are merged using `MissingPeer.raw_range` (scheme-preserving). When there are multiple required declarations for the same peer and `auto_install_peers_from_highest_match` is enabled, `merge_ranges()` produces `||`-joined **raw scheme specifiers** (e.g. `work:^1.0.0 || work:^2.0.0`). The range extractor (`get_peer_version_range`) can only extract a comparable semver range from a single scheme prefix; when a later `||` segment contains another scheme, extraction fails and falls back to `*`, allowing `hoist_peers()` to pick the highest preferred version even if it violates all declared constraints.

## Issue Context
You now carry both:
- `wanted_range`: the comparable semver range (via `get_peer_version_range`)
- `raw_range`: the install source specifier

Merging logic for **compatibility** should be based on `wanted_range`, while the **install source** should be selected deterministically (or treated as a conflict if multiple incompatible raw sources exist) rather than concatenated into a single `||` string that breaks extraction.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[610-663]
- pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[87-116]
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[38-53]

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


2. Hoist misreads scheme ranges ✓ Resolved 🐞 Bug ≡ Correctness
Description
When auto-installing/hoisting missing peers, hoistPeers() uses the raw peer specifier (e.g.
work:^1.0.0) for semver checks, so scheme-carrying peers are treated as non-semver and the chosen
preferred version may not satisfy the extracted semver body. This can auto-install an incompatible
peer (and in some cases drop the intended scheme source) even though the peer satisfaction check was
updated to compare against getPeerVersionRange().
Code

pnpm11/installing/deps-resolver/src/resolvePeers.ts[R1229-1233]

  for (const [peerName, { version, optional }] of Object.entries(ctx.resolvedPackage.peerDependencies)) {
-    const peerVersionRange = version.replace(/^workspace:/, '')
+    const peerVersionRange = getPeerVersionRange(version)

    const resolved = ctx.parentPkgs[peerName]
    const optionalPeer = optional === true
Evidence
resolvePeers() now derives peerVersionRange via getPeerVersionRange(version) but still records
missing peers with the raw version string; the auto-install path (resolveRootDependencies →
hoistPeers) then applies semver logic to that raw specifier, which will fail semver parsing for
scheme-carrying forms.

pnpm11/installing/deps-resolver/src/resolvePeers.ts[1227-1267]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[387-473]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[12-75]

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()` currently decides whether a missing peer's `range` is semver by running `semver.validRange(range)` on the **raw** peer specifier. With this PR, peers like `work:^1.0.0`/`npm:bar@^5` are valid inputs, but they will always be treated as non-semver in `hoistPeers()`, bypassing range-aware selection and allowing an auto-installed version that does not satisfy the extracted semver range.

### Issue Context
- `resolvePeers()` now uses `getPeerVersionRange(version)` for satisfaction checks, but still stores the missing peer's `range` as the raw `version` string for later auto-install.
- `resolveRootDependencies()` calls `hoistPeers()` with these raw ranges when `autoInstallPeers` is enabled.

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolvePeers.ts[1228-1267]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[19-75]
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[387-473]

### Suggested fix
1. In `hoistPeers()`, compute a comparable range for semver logic, e.g. `const rangeForMatch = getPeerVersionRange(range)`.
2. Use `rangeForMatch` (not `range`) for `semver.validRange(...)` and `semver.maxSatisfying(...)` decisions.
3. Preserve the original raw specifier (including scheme) when actually setting `dependencies[peerName]` if the PR contract requires scheme to drive auto-installation; at minimum, avoid selecting a preferred version unless it satisfies `rangeForMatch`.

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



Remediation recommended

3. Catalog substring bypass 🐞 Bug ☼ Reliability
Description
getPeerVersionRange() returns the input unchanged whenever it contains workspace:/catalog:
anywhere, so an opaque spec like https://example.com/x.tgz#catalog: will not be desugared to *
and will be compared as a non-semver range. This contradicts the intended behavior (“opaque specs
become *”) and can cause false peer-mismatch warnings or failed resolutions in both TS and Rust
parity helpers.
Code

pnpm11/deps/peer-range/src/index.ts[R36-39]

+export function getPeerVersionRange (version: string): string {
+  if (isValidPeerRange(version)) {
+    return version.replace(/^workspace:/, '')
+  }
Evidence
The early return in getPeerVersionRange() is gated by isValidPeerRange(), which currently uses
substring checks for workspace:/catalog:; the Rust parity helper mirrors the same
contains(...) logic and early return.

pnpm11/deps/peer-range/src/index.ts[3-48]
pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-54]

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

### Issue description
`isValidPeerRange()` treats any string containing `workspace:` or `catalog:` as a valid peer range, and `getPeerVersionRange()` short-circuits on that predicate. For scheme/URL specifiers that incidentally contain those substrings (e.g. URL fragments like `#catalog:`), `getPeerVersionRange()` returns the opaque spec unchanged instead of `*`.

### Issue Context
The helper’s contract (per docs/tests) is that non-semver opaque specs (git/file/URL) should become `*` for satisfaction checks.

### Fix Focus Areas
- pnpm11/deps/peer-range/src/index.ts[3-48]
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-54]

### Suggested fix
In both TS and Rust helpers:
1. Detect and handle leading scheme specifiers (e.g. `^[a-zA-Z][a-zA-Z0-9+.-]*:`) **before** the `isValidPeerRange()` short-circuit.
2. Narrow `isValidPeerRange()` so `workspace:`/`catalog:` only count when they are actual protocol tokens (start of string or a well-defined range-expression segment), not arbitrary substrings inside URLs/paths.
This ensures opaque specs are reliably desugared to `*` as intended.

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


4. Colon-based peer acceptance 🐞 Bug ☼ Reliability
Description
isAcceptablePeerSpec() accepts any value that merely contains :, so malformed strings that are
not dependency specifiers (or valid peer ranges) can pass validation. These values can then fail
later during dependency parsing/resolution, producing confusing runtime errors instead of a clear
validation failure.
Code

pnpm11/deps/peer-range/src/index.ts[R22-24]

+export function isAcceptablePeerSpec (version: string): boolean {
+  return isValidPeerRange(version) || version.includes(':')
+}
Evidence
The TS and Rust helpers implement acceptance as isValidPeerRange(...) || contains(':'), and TS
project validation uses this helper directly for peerDependencies.

pnpm11/deps/peer-range/src/index.ts[3-47]
pnpm11/installing/deps-resolver/src/validatePeerDependencies.ts[10-24]
pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-27]

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

### Issue description
The new peer spec validator considers `version.includes(':')` sufficient to classify a value as a scheme-carrying specifier. This accepts many malformed inputs (e.g. stray colons, Windows drive paths, whitespace-delimited strings) that are not valid dependency specifiers.

### Issue Context
Both the TypeScript and Rust parity helpers use the same `contains(':')` rule, so the validation looseness is duplicated.

### Fix Focus Areas
- pnpm11/deps/peer-range/src/index.ts[3-24]
- pnpm11/installing/deps-resolver/src/validatePeerDependencies.ts[10-24]
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-27]

### Suggested fix
Replace the `includes(':')` heuristic with a stricter check, e.g.:
- Require a valid leading scheme: `/^[a-zA-Z][a-zA-Z0-9+.-]*:/` (and optionally reject whitespace before the colon).
- Optionally whitelist known schemes (`npm:`, `file:`, `link:`, `git+...:`, `https?:`) and named-registry aliases.
This keeps the intended feature while preventing obviously invalid values from passing validation.

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



Informational

5. Valid union gets normalized 🐞 Bug ⚙ Maintainability ⭐ New
Description
get_peer_version_range() splits on the substring "||" before checking whether the full input is
already a valid peer range, so a valid semver union like ^1.0.0||^2.0.0 will be re-serialized as
^1.0.0 || ^2.0.0 (trimmed + spaced) instead of being returned byte-for-byte unchanged. This
contradicts the documented/tested “plain semver union is returned unchanged” expectation and can
create string-level inconsistencies in diagnostics/caching even though semver meaning is typically
unchanged.
Code

pnpm/crates/resolving-resolver-base/src/peer_range.rs[R42-48]

+    if version.contains("||") {
+        return version
+            .split("||")
+            .map(|part| get_peer_version_range(part.trim()))
+            .collect::<Vec<_>>()
+            .join(" || ");
+    }
Evidence
The Rust helper’s union branch runs before validating the whole string as a peer range, and the TS
helper mirrors this ordering; meanwhile the tests explicitly assert/describe that plain semver
unions are returned unchanged, but only cover already-spaced unions.

pnpm/crates/resolving-resolver-base/src/peer_range.rs[36-51]
pnpm11/deps/peer-range/src/index.ts[34-45]
pnpm/crates/resolving-resolver-base/src/peer_range/tests.rs[62-70]
pnpm11/installing/deps-resolver/test/getPeerVersionRange.test.ts[56-63]

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

### Issue description
`get_peer_version_range` (and the mirrored TS helper) processes `||` unions before checking whether the whole input is already a valid peer range, which causes valid semver unions to be normalized (trimmed + forced `" || "` spacing) despite docs/tests stating valid ranges are returned unchanged.

### Issue Context
This is most visible when the input union omits spaces (e.g. `^1.0.0||^2.0.0`). Semver semantics usually don’t change, but exact-string output can.

### Fix Focus Areas
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[36-51]
- pnpm11/deps/peer-range/src/index.ts[34-45]
- pnpm/crates/resolving-resolver-base/src/peer_range/tests.rs[62-70]
- pnpm11/installing/deps-resolver/test/getPeerVersionRange.test.ts[56-63]

### Suggested fix
1. Move the `is_valid_peer_range(version)` / `isValidPeerRange(version)` check before the `version.contains("||")` / `version.includes('||')` branch.
2. Add a test case asserting exact preservation for a no-whitespace valid union (e.g. `^1.0.0||^2.0.0`) if byte-for-byte stability is desired; otherwise, update the doc/test comment to say “semantically unchanged” rather than “returned unchanged.”

ⓘ 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 3bc9685

Results up to commit 26ef5fd


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


Action required
1. Hoist misreads scheme ranges ✓ Resolved 🐞 Bug ≡ Correctness
Description
When auto-installing/hoisting missing peers, hoistPeers() uses the raw peer specifier (e.g.
work:^1.0.0) for semver checks, so scheme-carrying peers are treated as non-semver and the chosen
preferred version may not satisfy the extracted semver body. This can auto-install an incompatible
peer (and in some cases drop the intended scheme source) even though the peer satisfaction check was
updated to compare against getPeerVersionRange().
Code

pnpm11/installing/deps-resolver/src/resolvePeers.ts[R1229-1233]

  for (const [peerName, { version, optional }] of Object.entries(ctx.resolvedPackage.peerDependencies)) {
-    const peerVersionRange = version.replace(/^workspace:/, '')
+    const peerVersionRange = getPeerVersionRange(version)

    const resolved = ctx.parentPkgs[peerName]
    const optionalPeer = optional === true
Evidence
resolvePeers() now derives peerVersionRange via getPeerVersionRange(version) but still records
missing peers with the raw version string; the auto-install path (resolveRootDependencies →
hoistPeers) then applies semver logic to that raw specifier, which will fail semver parsing for
scheme-carrying forms.

pnpm11/installing/deps-resolver/src/resolvePeers.ts[1227-1267]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[387-473]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[12-75]

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()` currently decides whether a missing peer's `range` is semver by running `semver.validRange(range)` on the **raw** peer specifier. With this PR, peers like `work:^1.0.0`/`npm:bar@^5` are valid inputs, but they will always be treated as non-semver in `hoistPeers()`, bypassing range-aware selection and allowing an auto-installed version that does not satisfy the extracted semver range.

### Issue Context
- `resolvePeers()` now uses `getPeerVersionRange(version)` for satisfaction checks, but still stores the missing peer's `range` as the raw `version` string for later auto-install.
- `resolveRootDependencies()` calls `hoistPeers()` with these raw ranges when `autoInstallPeers` is enabled.

### Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolvePeers.ts[1228-1267]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[19-75]
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[387-473]

### Suggested fix
1. In `hoistPeers()`, compute a comparable range for semver logic, e.g. `const rangeForMatch = getPeerVersionRange(range)`.
2. Use `rangeForMatch` (not `range`) for `semver.validRange(...)` and `semver.maxSatisfying(...)` decisions.
3. Preserve the original raw specifier (including scheme) when actually setting `dependencies[peerName]` if the PR contract requires scheme to drive auto-installation; at minimum, avoid selecting a preferred version unless it satisfies `rangeForMatch`.

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



Remediation recommended
2. Catalog substring bypass 🐞 Bug ☼ Reliability
Description
getPeerVersionRange() returns the input unchanged whenever it contains workspace:/catalog:
anywhere, so an opaque spec like https://example.com/x.tgz#catalog: will not be desugared to *
and will be compared as a non-semver range. This contradicts the intended behavior (“opaque specs
become *”) and can cause false peer-mismatch warnings or failed resolutions in both TS and Rust
parity helpers.
Code

pnpm11/deps/peer-range/src/index.ts[R36-39]

+export function getPeerVersionRange (version: string): string {
+  if (isValidPeerRange(version)) {
+    return version.replace(/^workspace:/, '')
+  }
Evidence
The early return in getPeerVersionRange() is gated by isValidPeerRange(), which currently uses
substring checks for workspace:/catalog:; the Rust parity helper mirrors the same
contains(...) logic and early return.

pnpm11/deps/peer-range/src/index.ts[3-48]
pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-54]

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

### Issue description
`isValidPeerRange()` treats any string containing `workspace:` or `catalog:` as a valid peer range, and `getPeerVersionRange()` short-circuits on that predicate. For scheme/URL specifiers that incidentally contain those substrings (e.g. URL fragments like `#catalog:`), `getPeerVersionRange()` returns the opaque spec unchanged instead of `*`.

### Issue Context
The helper’s contract (per docs/tests) is that non-semver opaque specs (git/file/URL) should become `*` for satisfaction checks.

### Fix Focus Areas
- pnpm11/deps/peer-range/src/index.ts[3-48]
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-54]

### Suggested fix
In both TS and Rust helpers:
1. Detect and handle leading scheme specifiers (e.g. `^[a-zA-Z][a-zA-Z0-9+.-]*:`) **before** the `isValidPeerRange()` short-circuit.
2. Narrow `isValidPeerRange()` so `workspace:`/`catalog:` only count when they are actual protocol tokens (start of string or a well-defined range-expression segment), not arbitrary substrings inside URLs/paths.
This ensures opaque specs are reliably desugared to `*` as intended.

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


3. Colon-based peer acceptance 🐞 Bug ☼ Reliability
Description
isAcceptablePeerSpec() accepts any value that merely contains :, so malformed strings that are
not dependency specifiers (or valid peer ranges) can pass validation. These values can then fail
later during dependency parsing/resolution, producing confusing runtime errors instead of a clear
validation failure.
Code

pnpm11/deps/peer-range/src/index.ts[R22-24]

+export function isAcceptablePeerSpec (version: string): boolean {
+  return isValidPeerRange(version) || version.includes(':')
+}
Evidence
The TS and Rust helpers implement acceptance as isValidPeerRange(...) || contains(':'), and TS
project validation uses this helper directly for peerDependencies.

pnpm11/deps/peer-range/src/index.ts[3-47]
pnpm11/installing/deps-resolver/src/validatePeerDependencies.ts[10-24]
pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-27]

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

### Issue description
The new peer spec validator considers `version.includes(':')` sufficient to classify a value as a scheme-carrying specifier. This accepts many malformed inputs (e.g. stray colons, Windows drive paths, whitespace-delimited strings) that are not valid dependency specifiers.

### Issue Context
Both the TypeScript and Rust parity helpers use the same `contains(':')` rule, so the validation looseness is duplicated.

### Fix Focus Areas
- pnpm11/deps/peer-range/src/index.ts[3-24]
- pnpm11/installing/deps-resolver/src/validatePeerDependencies.ts[10-24]
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[13-27]

### Suggested fix
Replace the `includes(':')` heuristic with a stricter check, e.g.:
- Require a valid leading scheme: `/^[a-zA-Z][a-zA-Z0-9+.-]*:/` (and optionally reject whitespace before the colon).
- Optionally whitelist known schemes (`npm:`, `file:`, `link:`, `git+...:`, `https?:`) and named-registry aliases.
This keeps the intended feature while preventing obviously invalid values from passing validation.

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


Results up to commit 2ea26bb


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


Action required
1. Scheme OR breaks matching ✓ Resolved 🐞 Bug ≡ Correctness
Description
partition_missing_peers() now merges required peer specs using MissingPeer.raw_range, so
multi-consumer peers can become ||-joined scheme strings like work:^1.0.0 || work:^2.0.0. The
peer-range extractor then fails to parse the body and falls back to *, letting hoist_peers()
select the highest preferred version even if it satisfies neither original range (reintroducing
incompatible-major auto-installs).
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R610-618]

+        // Hoisting a missing required peer fetches it, so it needs the original
+        // specifier with its scheme preserved (`work:5.x.x`); hoist_peers reduces
+        // it to a comparable range itself. The optional path below dedupes onto
+        // an already-present version, so it uses the display range instead.
        let required_ranges: Vec<&str> = entries
            .iter()
            .filter(|entry| !entry.optional)
-            .map(|entry| entry.wanted_range.as_str())
+            .map(|entry| entry.raw_range.as_str())
            .collect();
Evidence
The required-peer merge now collects raw_range values and may ||-join them (when configured).
raw_range is explicitly scheme-preserving, while get_peer_version_range only extracts a semver
body from a single leading scheme:; if the scheme: appears again later in a ||-joined string,
extraction fails and returns *, which makes hoist_peers pick the highest preferred version
regardless of the original constraints.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[599-638]
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[642-665]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[1269-1306]
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[87-116]
pnpm/crates/resolving-resolver-base/src/peer_range.rs[38-54]

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

## Issue description
Required missing-peer ranges are merged using `MissingPeer.raw_range` (scheme-preserving). When there are multiple required declarations for the same peer and `auto_install_peers_from_highest_match` is enabled, `merge_ranges()` produces `||`-joined **raw scheme specifiers** (e.g. `work:^1.0.0 || work:^2.0.0`). The range extractor (`get_peer_version_range`) can only extract a comparable semver range from a single scheme prefix; when a later `||` segment contains another scheme, extraction fails and falls back to `*`, allowing `hoist_peers()` to pick the highest preferred version even if it violates all declared constraints.

## Issue Context
You now carry both:
- `wanted_range`: the comparable semver range (via `get_peer_version_range`)
- `raw_range`: the install source specifier

Merging logic for **compatibility** should be based on `wanted_range`, while the **install source** should be selected deterministically (or treated as a conflict if multiple incompatible raw sources exist) rather than concatenated into a single `||` string that breaks extraction.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[610-663]
- pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs[87-116]
- pnpm/crates/resolving-resolver-base/src/peer_range.rs[38-53]

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


Qodo Logo

@codecov-commenter

codecov-commenter commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.59184% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.48%. Comparing base (2719b33) to head (3bc9685).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/peers.rs 0.00% 9 Missing ⚠️
...m/crates/resolving-resolver-base/src/peer_range.rs 96.55% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13110   +/-   ##
=======================================
  Coverage   85.48%   85.48%           
=======================================
  Files         502      503    +1     
  Lines       80820    80888   +68     
=======================================
+ Hits        69092    69151   +59     
- Misses      11728    11737    +9     

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

@qodo-code-review

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 3bc9685

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Separate matching and install specifiers

Separate the merged comparable range from the raw install specifier to prevent
invalid specifiers from being passed to the resolver.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs [614-637]

 let required_ranges: Vec<&str> = entries
     .iter()
     .filter(|entry| !entry.optional)
-    .map(|entry| entry.raw_range.as_str())
+    .map(|entry| entry.wanted_range.as_str())
     .collect();
+let raw_specifier = entries
+    .iter()
+    .find(|entry| !entry.optional)
+    .map(|entry| entry.raw_range.clone());
 ...
-if let Some(range) = merge_ranges(&required_ranges, auto_install_peers_from_highest_match) {
-    missing_required.insert(peer_name.clone(), MissingPeerInfo { range });
+if let (Some(range), Some(raw_specifier)) = (
+    merge_ranges(&required_ranges, auto_install_peers_from_highest_match),
+    raw_specifier,
+) {
+    missing_required.insert(
+        peer_name.clone(),
+        MissingPeerInfo { range, raw_specifier },
+    );
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: Merging raw source specifiers with || creates invalid specifiers that crash the resolver during fallback auto-installation.

Medium
Keep opaque sources range-free

Limit semver range extraction to non-opaque schemes (like npm:) to avoid false
range matches.

pnpm11/deps/peer-range/src/index.ts [46-53]

 const colon = version.indexOf(':')
 if (colon > 0) {
+  const scheme = version.slice(0, colon)
   const body = version.slice(colon + 1)
+  const opaqueSchemes = new Set(['file', 'link', 'git', 'git+ssh', 'git+https', 'http', 'https'])
+  if (opaqueSchemes.has(scheme)) return '*'
   if (validRange(body) != null) return body
   const at = body.lastIndexOf('@')
   if (at > 0 && validRange(body.slice(at + 1)) != null) return body.slice(at + 1)
 }
 return '*'
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: Excluding opaque schemes from @ extraction prevents unintentional semver extraction from valid file or git URLs that happen to contain an @ followed by a version-like string.

Low
Reject malformed scheme specifiers

Improve the structural validation of scheme specifiers in isAcceptablePeerSpec.

pnpm11/deps/peer-range/src/index.ts [22-24]

 export function isAcceptablePeerSpec (version: string): boolean {
-  return isValidPeerRange(version) || version.includes(':')
+  if (isValidPeerRange(version)) return true
+  const colon = version.indexOf(':')
+  if (colon <= 0 || colon === version.length - 1) return false
+  const scheme = version.slice(0, colon)
+  return !scheme.includes('/') && !scheme.includes('@') && !scheme.includes(' ')
 }
  • Apply / Chat
Suggestion importance[1-10]: 4

__

Why: Adding stricter validation for isAcceptablePeerSpec helps catch malformed input earlier and produces clearer error messages.

Low
  • More

Previous suggestions

Suggestions up to commit 2ea26bb
CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid extracting ranges from URLs

Restrict semver extraction from @ specifically to the npm: scheme to prevent
misinterpreting URLs or file paths.

pnpm11/deps/peer-range/src/index.ts [40-46]

 const colon = version.indexOf(':')
 if (colon > 0) {
+  const scheme = version.slice(0, colon)
   const body = version.slice(colon + 1)
   if (validRange(body) != null) return body
-  const at = body.lastIndexOf('@')
-  if (at > 0 && validRange(body.slice(at + 1)) != null) return body.slice(at + 1)
+  if (scheme === 'npm') {
+    const at = body.lastIndexOf('@')
+    if (at > 0 && validRange(body.slice(at + 1)) != null) return body.slice(at + 1)
+  }
 }
Suggestion importance[1-10]: 8

__

Why: It correctly identifies an edge case where file paths or URLs containing @<version> would mistakenly trigger the semver extraction, causing false peer conflicts.

Medium
General
Reject malformed scheme specifiers

Enhance the scheme validation by using a regex to ensure the string preceding
the colon is a syntactically valid protocol scheme.

pnpm11/deps/peer-range/src/index.ts [22-24]

 export function isAcceptablePeerSpec (version: string): boolean {
-  return isValidPeerRange(version) || version.includes(':')
+  if (isValidPeerRange(version)) return true
+  const colon = version.indexOf(':')
+  if (colon <= 0) return false
+  const scheme = version.slice(0, colon)
+  return /^[a-z][a-z0-9+.-]*$/i.test(scheme)
 }
Suggestion importance[1-10]: 7

__

Why: Validating the protocol scheme provides a tighter upfront validation, ensuring that malformed peer dependency specs throw the correct dedicated error instead of failing opaquely during resolution.

Medium
Suggestions up to commit 26ef5fd
CategorySuggestion                                                                                                                                    Impact
High-level
Update overrides for scheme-carrying peers

Replace usages of is_valid_peer_range with is_acceptable_peer_spec in
update_project_manifest_object.rs and overrides.rs to properly handle
scheme-carrying peer dependencies. Additionally, ensure that overrides.rs uses
get_peer_version_range to extract comparable semver ranges for accurate
intersections.

Examples:

pnpm/crates/package-manager/src/overrides.rs [20]
use pacquet_resolving_resolver_base::is_valid_peer_range;
pnpm/crates/package-manager/src/update_project_manifest_object.rs [4]
use pacquet_resolving_resolver_base::is_valid_peer_range;

Solution Walkthrough:

Before:

// In pnpm/crates/package-manager/src/overrides.rs
use pacquet_resolving_resolver_base::is_valid_peer_range;

fn matches_target(target: &PackageSelector, dep_name: &str, dep_spec: &str) -> bool {
    // Fails for `work:5.x.x`
    if !is_valid_peer_range(dep_spec) {
        return false; 
    }
    // Semver intersection fails on raw specs like `work:5.x.x`
}

// In pnpm/crates/package-manager/src/update_project_manifest_object.rs
use pacquet_resolving_resolver_base::is_valid_peer_range;
// Uses `is_valid_peer_range(version)` to determine if a version is a valid peer range

After:

// In pnpm/crates/package-manager/src/overrides.rs
use pacquet_resolving_resolver_base::{is_acceptable_peer_spec, get_peer_version_range};

fn matches_target(target: &PackageSelector, dep_name: &str, dep_spec: &str) -> bool {
    if !is_acceptable_peer_spec(dep_spec) {
        return false; 
    }
    let comparable_range = get_peer_version_range(dep_spec);
    // Semver intersection using `comparable_range`
}

// In pnpm/crates/package-manager/src/update_project_manifest_object.rs
use pacquet_resolving_resolver_base::is_acceptable_peer_spec;
// Use `is_acceptable_peer_spec(version)` to determine if a version is a valid peer range
Suggestion importance[1-10]: 8

__

Why: The suggestion accurately identifies that the Rust port missed updating manifest mutation and overrides to support the newly allowed scheme-carrying peer dependencies, preventing features like pnpm add --peer work:5.x.x from working correctly.

Medium
General
Use the extracted semver range for peer issues

Use the extracted semver range (range_for_satisfies) for the wanted_range field
when reporting missing or bad peer dependencies.

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs [1288-1305]

             if !self.missing_issue_suppressed(ancestor_pkg_ids, peer_name) {
                 self.issues.missing.entry(peer_name.to_string()).or_default().push(
                     MissingPeer {
                         parents: parents_from_chain(chain, pkg_name),
-                        wanted_range: range_for_match.to_string(),
+                        wanted_range: range_for_satisfies.clone(),
                     },
                 );
             }
         }
         Some(parent) => {
             if !satisfies_with_prereleases(&parent.version, &range_for_satisfies) {
                 self.issues.bad.entry(peer_name.to_string()).or_default().push(
                     PeerDependencyIssue {
-                        wanted_range: range_for_match.to_string(),
+                        wanted_range: range_for_satisfies.clone(),
                         found_version: parent.version.clone(),
                         resolved_from: parent.resolved_from.clone(),
                     },
                 );
             }
Suggestion importance[1-10]: 7

__

Why: Aligning the wanted_range with range_for_satisfies ensures consistency with the TypeScript implementation and accurately reflects the evaluated semver range in diagnostics.

Medium
Possible issue
Validate peer spec before normalization

Validate the original peer specifier with isAcceptablePeerSpec and throw an
error for invalid formats before normalizing.

pnpm11/deps/inspection/peers-checker/src/checkPeerDependencies.ts [94-95]

+import { isAcceptablePeerSpec, getPeerVersionRange } from '@pnpm/deps.peer-range'
+...
 for (const [peerName, rawPeerRange] of Object.entries(pkgSnapshot.peerDependencies)) {
+  if (!isAcceptablePeerSpec(rawPeerRange)) {
+    throw new PnpmError(
+      'ERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION',
+      `The peerDependencies field named '${peerName}' has an invalid value: '${rawPeerRange}'`
+    )
+  }
   const peerRange = getPeerVersionRange(rawPeerRange)
Suggestion importance[1-10]: 1

__

Why: The peers-checker is primarily a diagnostic tool for reading existing lockfiles; throwing a hard error for older or malformed lockfiles is overly aggressive, given that the installation step already performs this validation.

Low

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 3bc9685372d5

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.732 ± 0.121 2.547 2.887 1.69 ± 0.19
pacquet@main 2.685 ± 0.177 2.516 2.953 1.66 ± 0.20
pnpr@HEAD 1.621 ± 0.166 1.433 1.960 1.00
pnpr@main 1.634 ± 0.182 1.402 1.850 1.01 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7323579811400003,
      "stddev": 0.12094310857902475,
      "median": 2.7550466186400002,
      "user": 2.4666629599999994,
      "system": 1.9128493199999999,
      "min": 2.54704546114,
      "max": 2.88742354314,
      "times": [
        2.8672931311400003,
        2.78515477714,
        2.61179278814,
        2.88742354314,
        2.7552903731400002,
        2.68445953714,
        2.54704546114,
        2.58513455914,
        2.75480286414,
        2.8451827771400002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.68466768454,
      "stddev": 0.17677081895958813,
      "median": 2.61804698714,
      "user": 2.29580916,
      "system": 1.8055637199999999,
      "min": 2.51586238914,
      "max": 2.9533006531400003,
      "times": [
        2.9533006531400003,
        2.51908780114,
        2.51586238914,
        2.58274106814,
        2.72348029014,
        2.54429872514,
        2.86839718914,
        2.54308272314,
        2.6533529061400003,
        2.9430731001400003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6210008470400001,
      "stddev": 0.16621795408106185,
      "median": 1.59434122814,
      "user": 1.5767195599999995,
      "system": 1.6445133199999997,
      "min": 1.43268348114,
      "max": 1.9600089251400001,
      "times": [
        1.43268348114,
        1.9600089251400001,
        1.71671503814,
        1.7826681311400001,
        1.62803048414,
        1.46612863014,
        1.45607221014,
        1.66467692114,
        1.56065197214,
        1.54237267714
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.63420046934,
      "stddev": 0.1822356050670201,
      "median": 1.68988286814,
      "user": 1.4266048599999999,
      "system": 1.37799382,
      "min": 1.4024194091400002,
      "max": 1.85002986014,
      "times": [
        1.4163978941400002,
        1.81852330114,
        1.49561994914,
        1.85002986014,
        1.68643032014,
        1.69333541614,
        1.4024194091400002,
        1.8378849881400001,
        1.71591365514,
        1.42544990014
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 301.7 ± 15.4 265.7 316.8 1.05 ± 0.06
pacquet@main 288.6 ± 9.6 280.0 306.0 1.00
pnpr@HEAD 302.4 ± 9.7 288.4 317.5 1.05 ± 0.05
pnpr@main 289.7 ± 11.3 274.3 302.6 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.30173176148,
      "stddev": 0.015350514274628822,
      "median": 0.30552118818,
      "user": 0.26298538,
      "system": 0.6208575,
      "min": 0.26572955168,
      "max": 0.31684042468,
      "times": [
        0.31684042468,
        0.30615229768,
        0.31615489368000005,
        0.30489007868,
        0.30898428668000005,
        0.31190698568,
        0.29463032968,
        0.30260336868000004,
        0.28942539768000003,
        0.26572955168
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.28861584858,
      "stddev": 0.009601838659003077,
      "median": 0.28477771768000004,
      "user": 0.24138527999999998,
      "system": 0.5852305,
      "min": 0.28004315268,
      "max": 0.30600043168,
      "times": [
        0.28162257068,
        0.28690391568,
        0.28125014868000003,
        0.28265151968,
        0.29780355168000006,
        0.30600043168,
        0.30155843868000004,
        0.28093839168,
        0.28004315268,
        0.28738636468
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30243794458,
      "stddev": 0.009723863868651438,
      "median": 0.30203067418,
      "user": 0.25773308,
      "system": 0.5743026999999999,
      "min": 0.28843811768000005,
      "max": 0.31752134768,
      "times": [
        0.31752134768,
        0.30683050668,
        0.31195679868000004,
        0.31020196068000006,
        0.29716832268000004,
        0.30795034768,
        0.29723084168,
        0.29092339268,
        0.29615780968000005,
        0.28843811768000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28970980318000006,
      "stddev": 0.011252056757960484,
      "median": 0.29445082618,
      "user": 0.24959188000000002,
      "system": 0.5600362999999999,
      "min": 0.27427263568000004,
      "max": 0.30259337868,
      "times": [
        0.27635981968,
        0.29276147668,
        0.30259337868,
        0.30061146368,
        0.29863686268,
        0.28366195368,
        0.29614017568,
        0.27498235268000004,
        0.27427263568000004,
        0.29707791268000006
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.899 ± 0.040 2.849 2.985 1.77 ± 0.16
pacquet@main 2.986 ± 0.156 2.790 3.250 1.83 ± 0.19
pnpr@HEAD 1.669 ± 0.124 1.486 1.851 1.02 ± 0.12
pnpr@main 1.633 ± 0.145 1.425 1.834 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.89851813904,
      "stddev": 0.04021406533951971,
      "median": 2.88802505594,
      "user": 2.10983884,
      "system": 1.5897243199999997,
      "min": 2.84902992694,
      "max": 2.98500222594,
      "times": [
        2.90761096794,
        2.84902992694,
        2.91645871594,
        2.88242646694,
        2.8847200009400003,
        2.9344531749400002,
        2.8913301109400003,
        2.98500222594,
        2.88210379794,
        2.8520460019400002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.98629923334,
      "stddev": 0.15567761848592124,
      "median": 2.98591780744,
      "user": 2.3097749399999996,
      "system": 1.70723992,
      "min": 2.78964424194,
      "max": 3.2498694249400004,
      "times": [
        3.1549083699400002,
        3.2498694249400004,
        3.11794859094,
        2.9620041449400003,
        2.99556898894,
        2.9998628429400003,
        2.78964424194,
        2.80944770894,
        2.8074713939400002,
        2.97626662594
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.66908488734,
      "stddev": 0.12415861924768427,
      "median": 1.69744235044,
      "user": 1.3066591399999998,
      "system": 1.3429772199999999,
      "min": 1.48635564294,
      "max": 1.8508218649400001,
      "times": [
        1.8508218649400001,
        1.76360985894,
        1.57786007994,
        1.72931567794,
        1.48635564294,
        1.53133971394,
        1.7994546229400001,
        1.5572067109399998,
        1.72332918494,
        1.67155551594
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.63330220454,
      "stddev": 0.1449010918200467,
      "median": 1.5872186744399999,
      "user": 1.24594414,
      "system": 1.3549614199999997,
      "min": 1.42509074494,
      "max": 1.83447911094,
      "times": [
        1.59621126994,
        1.50051134594,
        1.57822607894,
        1.80701929094,
        1.51689530694,
        1.72834214394,
        1.42509074494,
        1.55657292494,
        1.78967382794,
        1.83447911094
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 677.0 ± 36.7 613.4 754.5 1.93 ± 0.16
pacquet@main 729.6 ± 61.3 647.6 821.7 2.08 ± 0.22
pnpr@HEAD 350.9 ± 22.3 324.9 400.5 1.00
pnpr@main 378.6 ± 27.0 333.5 430.5 1.08 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.67702776856,
      "stddev": 0.036729111896296324,
      "median": 0.67278727656,
      "user": 0.8509315200000002,
      "system": 0.7284222400000001,
      "min": 0.6134421665600001,
      "max": 0.75451508556,
      "times": [
        0.65765819956,
        0.65263596256,
        0.69456268056,
        0.75451508556,
        0.66523893956,
        0.69570666856,
        0.66576106256,
        0.6134421665600001,
        0.69094342956,
        0.67981349056
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.72957220936,
      "stddev": 0.061305232194072704,
      "median": 0.71559986856,
      "user": 0.93170202,
      "system": 0.7680675399999999,
      "min": 0.64759637356,
      "max": 0.8216620705600001,
      "times": [
        0.66008524556,
        0.74839129256,
        0.81310476056,
        0.69202394556,
        0.70327590456,
        0.72792383256,
        0.8216620705600001,
        0.69551603856,
        0.64759637356,
        0.78614262956
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.35090706776,
      "stddev": 0.022287806784466024,
      "median": 0.34409414356000007,
      "user": 0.23812521999999997,
      "system": 0.6219555400000001,
      "min": 0.32486473856000003,
      "max": 0.40047291156000003,
      "times": [
        0.32486473856000003,
        0.33231601156000007,
        0.34369228656000006,
        0.33765776156000005,
        0.33964798156000003,
        0.34449600056000007,
        0.35185344856000006,
        0.37309887356000004,
        0.40047291156000003,
        0.36097066356000007
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.37864602256,
      "stddev": 0.027026623606568965,
      "median": 0.37653074756000005,
      "user": 0.27848561999999993,
      "system": 0.65999854,
      "min": 0.33353581056000003,
      "max": 0.43052918356000003,
      "times": [
        0.33353581056000003,
        0.37963335056,
        0.37709237156000003,
        0.37235937056000007,
        0.43052918356000003,
        0.41107012556000005,
        0.37596912356000006,
        0.38086275856000007,
        0.37348708556000004,
        0.35192104556000003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.170 ± 0.113 1.992 2.326 5.82 ± 0.37
pacquet@main 2.074 ± 0.055 1.971 2.149 5.56 ± 0.25
pnpr@HEAD 0.373 ± 0.014 0.346 0.391 1.00
pnpr@main 0.384 ± 0.010 0.370 0.397 1.03 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.1696830962,
      "stddev": 0.11318974385605704,
      "median": 2.1641391089,
      "user": 1.42048214,
      "system": 1.02886926,
      "min": 1.9924287359000001,
      "max": 2.3263004209000004,
      "times": [
        2.2504198649,
        2.0384522459000003,
        2.1580462299,
        1.9924287359000001,
        2.0706516179000003,
        2.1702319879000003,
        2.3072003699000003,
        2.3263004209000004,
        2.2454429429,
        2.1376565459
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.0741826374000003,
      "stddev": 0.054894207440338606,
      "median": 2.0901464204,
      "user": 1.26467634,
      "system": 0.9499261599999999,
      "min": 1.9709035339,
      "max": 2.1487875669000003,
      "times": [
        2.0897730409000004,
        2.1487875669000003,
        2.0550304949,
        2.0905197999,
        2.1201996009000004,
        2.0534898599000004,
        2.0969014459000004,
        2.0013980529000004,
        1.9709035339,
        2.1148229779000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.37274671,
      "stddev": 0.013542949291876048,
      "median": 0.3720917234,
      "user": 0.27998574,
      "system": 0.6584798599999999,
      "min": 0.34618398990000004,
      "max": 0.3912043289,
      "times": [
        0.3726848319,
        0.38865871090000004,
        0.3840630889,
        0.3690198629,
        0.3912043289,
        0.3714986149,
        0.34618398990000004,
        0.3772429929,
        0.3661813829,
        0.3607292959
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.3838292818,
      "stddev": 0.010350332412843215,
      "median": 0.3833855719,
      "user": 0.26708104,
      "system": 0.67006386,
      "min": 0.3703653489,
      "max": 0.3974927829,
      "times": [
        0.3775021429,
        0.3892690009,
        0.3755958579,
        0.39247361090000005,
        0.39059981990000003,
        0.3974927829,
        0.39632461090000004,
        0.37338725590000005,
        0.3703653489,
        0.37528238690000004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 537.5 ± 30.0 486.1 581.4 5.84 ± 0.41
pacquet@main 496.5 ± 43.8 433.5 588.2 5.39 ± 0.53
pnpr@HEAD 92.1 ± 4.0 85.5 101.9 1.00
pnpr@main 93.2 ± 8.1 83.0 123.2 1.01 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.53748165926,
      "stddev": 0.02996346203926205,
      "median": 0.53727719626,
      "user": 0.53077718,
      "system": 0.08434504000000001,
      "min": 0.48605482726,
      "max": 0.58141529326,
      "times": [
        0.55370372926,
        0.51194758326,
        0.5638715252600001,
        0.56644490526,
        0.52751864326,
        0.58141529326,
        0.52828473626,
        0.50930569326,
        0.54626965626,
        0.48605482726
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.49651289886,
      "stddev": 0.04376149730265559,
      "median": 0.48775953576,
      "user": 0.48763758,
      "system": 0.08001304,
      "min": 0.43348812526,
      "max": 0.58818508226,
      "times": [
        0.43348812526,
        0.45424994826,
        0.47271649526,
        0.53425833626,
        0.58818508226,
        0.52177236126,
        0.50316214326,
        0.48389088926,
        0.49162818226,
        0.48177742526
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09205960358258065,
      "stddev": 0.004028171963126653,
      "median": 0.09107025126000001,
      "user": 0.020886541290322583,
      "system": 0.013095070967741937,
      "min": 0.08553045026,
      "max": 0.10187128926000001,
      "times": [
        0.09115549126000001,
        0.09402975026,
        0.09752777426,
        0.09717529826,
        0.09282518826000001,
        0.09761418526000001,
        0.09348293926000001,
        0.08749703626000001,
        0.09702423526000001,
        0.09036546326,
        0.08989944426,
        0.08921850126000001,
        0.10187128926000001,
        0.08763861326000001,
        0.09021117126,
        0.09107025126000001,
        0.09050305226000001,
        0.08967444026,
        0.09145890426,
        0.09048635026,
        0.08893935426,
        0.08676036826000001,
        0.09409657526000001,
        0.08553045026,
        0.08633415426,
        0.09005269326000001,
        0.09894571526000001,
        0.09481645226,
        0.09011206526000001,
        0.09643765926,
        0.09109284426000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09315353839793106,
      "stddev": 0.008094015951588642,
      "median": 0.09124997926,
      "user": 0.022524000689655172,
      "system": 0.012131836551724137,
      "min": 0.08296874026,
      "max": 0.12317492426000001,
      "times": [
        0.09551130226000001,
        0.08809386126,
        0.08658494726,
        0.09651719826,
        0.12317492426000001,
        0.09874629926,
        0.09673250426,
        0.09522023326000001,
        0.10029023926000001,
        0.08608580526000001,
        0.08591253926,
        0.09362441626000001,
        0.08766707726,
        0.09124997926,
        0.09446684426,
        0.11160391526,
        0.09473086126000001,
        0.08797923526000001,
        0.09005752226000001,
        0.08296874026,
        0.08695642726000001,
        0.08842915326,
        0.09172628726000001,
        0.09026561426,
        0.09543627126000001,
        0.08878452326000001,
        0.09412496926000001,
        0.08969588126000001,
        0.08881504126
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.683 ± 0.159 4.555 5.008 1.30 ± 0.07
pacquet@main 4.703 ± 0.160 4.522 5.026 1.31 ± 0.07
pnpr@HEAD 3.601 ± 0.115 3.496 3.894 1.00 ± 0.05
pnpr@main 3.599 ± 0.138 3.470 3.920 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.6834814818799995,
      "stddev": 0.15894748142828638,
      "median": 4.61046999978,
      "user": 2.4417923200000002,
      "system": 1.7719701999999997,
      "min": 4.55470798878,
      "max": 5.00841460978,
      "times": [
        4.58680605978,
        4.58537723778,
        5.00841460978,
        4.55470798878,
        4.56826421078,
        4.62218625878,
        4.59875374078,
        4.77758993878,
        4.90678501878,
        4.6259297547800005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.70345142628,
      "stddev": 0.15976255573473389,
      "median": 4.64525128878,
      "user": 2.3168361200000005,
      "system": 1.7706003,
      "min": 4.52222465878,
      "max": 5.02623056178,
      "times": [
        5.02623056178,
        4.58882081878,
        4.52222465878,
        4.65112457478,
        4.60939890178,
        4.59926978778,
        4.88483507078,
        4.841618377780001,
        4.63937800278,
        4.67161350778
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.60067045308,
      "stddev": 0.11546024856551722,
      "median": 3.57778811328,
      "user": 1.53661742,
      "system": 1.4977740000000002,
      "min": 3.49553137078,
      "max": 3.89444882078,
      "times": [
        3.55926636378,
        3.59278573878,
        3.5117584717800003,
        3.68160217578,
        3.58638390778,
        3.57277783878,
        3.52935145478,
        3.49553137078,
        3.58279838778,
        3.89444882078
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5986844921800007,
      "stddev": 0.13831520512142517,
      "median": 3.57469179428,
      "user": 1.3710725199999998,
      "system": 1.4124843999999999,
      "min": 3.47031829878,
      "max": 3.91969447078,
      "times": [
        3.7084937367800004,
        3.91969447078,
        3.6317783507800003,
        3.53251210278,
        3.50201511278,
        3.47948784678,
        3.62867300578,
        3.49700051078,
        3.47031829878,
        3.61687148578
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13110
Testbedpacquet

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
isolated-linker.fresh-resolve.hot-cache.offlineLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
537.48 ms
(+20.26%)Baseline: 446.93 ms
536.32 ms
(100.22%)

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,898.52 ms
(-2.00%)Baseline: 2,957.82 ms
3,549.38 ms
(81.66%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,169.68 ms
(+2.59%)Baseline: 2,114.87 ms
2,537.85 ms
(85.49%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
677.03 ms
(-9.47%)Baseline: 747.86 ms
897.43 ms
(75.44%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
🚨 view alert (🔔)
537.48 ms
(+20.26%)Baseline: 446.93 ms
536.32 ms
(100.22%)

isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,732.36 ms
(+1.24%)Baseline: 2,698.80 ms
3,238.56 ms
(84.37%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,683.48 ms
(-2.38%)Baseline: 4,797.47 ms
5,756.96 ms
(81.35%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
301.73 ms
(+1.08%)Baseline: 298.50 ms
358.20 ms
(84.24%)
🐰 View full continuous benchmarking report in Bencher

…ning text

Two follow-ups from review of the scheme-specifier peer support.

hoistPeers decided whether a missing peer's range was semver by testing the raw
specifier, so a scheme-carrying peer (work:^1.0.0, npm:bar@^5) was treated as
non-semver and deduped onto the highest already-resolved version regardless of
its range — auto-installing a version the peer rejects. Run the semver decision
through getPeerVersionRange, keeping the raw specifier for the fallback that
fetches the package, so scheme peers dedupe onto a compatible version when one
exists and otherwise resolve from their original source. Fixed in both stacks.

The Rust resolver reused one field for both the auto-install (hoist) source and
the unmet-peer warning text, so it displayed the raw specifier while the
TypeScript CLI displayed the extracted range. Split them: MissingPeer now
carries wanted_range (the extracted range, for matching and display) and
raw_range (the original specifier, read by the importer hoist loop), so both
stacks show the same normalized range in warnings while auto-install still
fetches from the right source.
Copilot AI review requested due to automatic review settings July 17, 2026 20:44

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 17, 2026

Copy link
Copy Markdown
Member Author

Follow-up pushed in 2ea26bb addressing the automated review:

Qodo (hoistPeers range-awareness): fixed — the auto-install selection now reduces scheme specifiers to a comparable range via getPeerVersionRange, keeping the original specifier for the fetch fallback. Both stacks, with tests. (Replied on the thread.)

CodeRabbit (pnpm peers shows the normalized range in peers.rs): the premise was that this diverges from the TypeScript CLI, but the TS peers checker (checkPeerDependencies.ts) normalizes the same way, so those two are already in parity — normalizing is intentional. A peer warning only fires on a range mismatch, and in that case the mismatching version never came from the scheme source, so displaying ^5 rather than npm:bar@^5 is the accurate thing to show.

The real inconsistency was the opposite: Rust resolve_peers still showed the raw specifier in install-time warnings because it reused one field for both the hoist source and the display text. That's now split — MissingPeer carries wanted_range (the extracted range, for matching and display) and raw_range (the original specifier, read only by the hoist loop) — so all four warning sites across both stacks show the same normalized range while auto-install still fetches from the right source.


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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2ea26bb

…e range

When several consumers require the same peer with different scheme specifiers
and auto-install-peers-from-highest-match is enabled, the ranges are merged
into a `||` union of the raw specs (`work:^1.0.0 || work:^2.0.0`).
getPeerVersionRange could not parse that and fell back to `*`, so the hoist
picker selected the highest preferred version even when it satisfied none of
the declared ranges.

Handle a `||` union in getPeerVersionRange by reducing each alternative to its
version body, yielding a comparable semver union (`^1.0.0 || ^2.0.0`). The
union is checked before the valid-range short-circuit, because node-semver
leniently parses a union whose alternatives carry a scheme while the JS semver
does not — doing the split first keeps both stacks identical. Fixed in the
shared helper in both stacks, with unit tests and a hoist regression test that
a version satisfying none of the merged ranges is not chosen.
Copilot AI review requested due to automatic review settings July 17, 2026 21:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 3bc9685

@zkochan
zkochan merged commit 76f5886 into main Jul 17, 2026
33 of 35 checks passed
@zkochan
zkochan deleted the accept-scheme-peer-specifiers branch July 17, 2026 21:47
@blacksmith-sh

blacksmith-sh Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
test/dlx.e2e.ts (260.027 s)/dlx.e2e.ts (260.027 s) View Logs

Fix with Codesmith
Need help on this PR? Tag /codesmith with what you need.

@dasa dasa mentioned this pull request Jul 28, 2026
2 of 4 tasks
@qodo-code-review qodo-code-review Bot mentioned this pull request Sep 2, 2026
4 tasks done
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.

npm: named registry specifiers cannot be used in peerDependencies

3 participants