Skip to content

refactor(deps-resolver): pick hoisted peer providers through one tiered rule - #17023

Merged
zkochan merged 2 commits into
mainfrom
refactor/peer-provider-picker
Oct 17, 2026
Merged

zkochan merged 2 commits into
mainfrom
refactor/peer-provider-picker

Conversation

@zkochan

@zkochan zkochan commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

First step of pnpm/tasks#143 (related, not closing it). The maintainer chose to scope this to step 1 of the issue's design: one owner for the hoist-time peer provider pick.

  • pnpm v12: hoist_peers.rs becomes peer_provider.rs. The required and optional pickers both go through highest_provider_version, which takes ProviderTiers and a range check. Each picker now differs only in those two inputs.
  • pnpm v11: hoistPeers.ts gets the same pickProviderVersion(selectors, { tiers, qualifies }) shape.

The picks do not change. No changeset, because nothing a user can see changes.

Steps 2 to 4 of pnpm/tasks#143 are still open: lockfile pins as a tie-break input, recorded peer bindings, and the freshness, optional and deploy consumers. One more thing for a maintainer: pnpm v11's optional picker has no lockfile tiers, but pnpm v12's has had them since #14895 and #16443. I did not check whether v11 needs them, and this PR leaves that difference as it is.

Squash Commit Body

The required and optional peer hoists each carried their own "highest
qualifying version" loop and their own idea of which versions to try
first. Both now go through one function that takes an ordered list of
version tiers and a range check:

- required: the versions this run resolved, then every version;
  includePrerelease against the one wanted range.
- optional: locked and resolved, then resolved, then locked, then every
  version; strict against every recorded range and the root's range.

In pnpm v12 the hoist module moves to `peer_provider.rs` and the tiers
become a `ProviderTiers` type, replacing `optional_peer_version_tiers`.
pnpm v11's `hoistPeers.ts` gets the same `pickProviderVersion` shape.
The picks do not change, except that among equal versions that differ
only in build metadata, the v12 optional picker now keeps the first
selector, like the required one.

This is the first step of pnpm/tasks#143. The pickers are now one place
that later steps can grow into the single peer-provider owner.
pnpm v11's optional picker still has no lockfile tiers. That is a
parity difference this change keeps as it is.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added or updated tests. (The existing picker tests are switched to ProviderTiers. They pass unchanged: 467 deps-resolver tests and 73 package-manager peer tests in v12, 228 deps-resolver tests in v11.)

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

🤖 Generated with Claude Code


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

Summary by CodeRabbit

  • Improvements
    • Peer dependency resolution selects the highest version that satisfies the requested range, prioritizing versions resolved during the current install.
    • Required peer ranges include prerelease versions. If no preferred version satisfies a required range, automatic peer installation uses the requested range; otherwise, the peer remains missing.
    • Optional peers are selected only when they satisfy all applicable peer ranges, including workspace-root constraints, and meet candidate acceptance criteria.

…ed rule

The required and optional peer hoists each carried their own "highest
qualifying version" loop and their own idea of which versions to try
first. Both now go through one function that takes an ordered list of
version tiers and a range check:

- required: the versions this run resolved, then every version;
  includePrerelease against the one wanted range.
- optional: locked and resolved, then resolved, then locked, then every
  version; strict against every recorded range and the root's range.

In pnpm v12 the hoist module moves to `peer_provider.rs` and the tiers
become a `ProviderTiers` type, replacing `optional_peer_version_tiers`.
pnpm v11's `hoistPeers.ts` gets the same `pickProviderVersion` shape.
The picks do not change, except that among equal versions that differ
only in build metadata, the v12 optional picker now keeps the first
selector, like the required one.

This is the first step of pnpm/tasks#143. The pickers are now one place
that later steps can grow into the single peer-provider owner.
pnpm v11's optional picker still has no lockfile tiers. That is a
parity difference this change keeps as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83794cb1-086e-4df8-b74b-8f9992b717e5
📥 Commits

Reviewing files that changed from the base of the PR and between e7c6fb0 and 096a5c3.

📒 Files selected for processing: 2
  • pnpm/crates/resolving-deps-resolver/src/peer_provider.rs
  • pnpm11/installing/deps-resolver/src/hoistPeers.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The Rust and pnpm 11 resolvers update required- and optional-peer version selection. The Rust resolver renames hoist_peers to peer_provider and represents optional provider tiers with ProviderTiers.

Changes: Peer provider selection

Layer / File(s) Summary
Rust provider selection
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs, pnpm/crates/resolving-deps-resolver/src/peer_provider/tests.rs
Required-peer selection uses range checks and shared highest-version selection. Optional-peer selection uses ProviderTiers and checks candidate versions against applicable ranges and the acceptance predicate. Tests construct provider tiers with ProviderTiers::optional.
Rust tier integration
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs, pnpm/crates/resolving-deps-resolver/src/lib.rs, pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs, pnpm/crates/resolving-deps-resolver/src/resolve_importer/hoist_rounds.rs, pnpm/plans/TEST_PORTING.md
The tree context constructs ProviderTiers. Resolver exports and imports, plus the test-port reference, use the peer_provider module name.
pnpm 11 provider selection
pnpm11/installing/deps-resolver/src/hoistPeers.ts
Required-peer selection uses shared version selection and handles auto-install when no version satisfies a semver range. Optional-peer selection applies root-range, peer-range, and candidate-acceptance checks.

Priority: ⬇️ Low

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

Change: Refactor

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

Suggested reviewers: altaywtf, officialaritro

Merge Risk: ⚪ Minimal · up to 096a5

No actionable merge-blocking issue was established; this change is ready for normal checks.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov-commenter

codecov-commenter commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.54%. Comparing base (086165d) to head (096a5c3).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rates/resolving-deps-resolver/src/peer_provider.rs 98.97% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17023   +/-   ##
=======================================
  Coverage   92.53%   92.54%           
=======================================
  Files        1775     1775           
  Lines      228551   228519   -32     
=======================================
- Hits       211490   211478   -12     
+ Misses      17061    17041   -20     

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

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

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.06     12.4±0.03ms    30.2 MB/sec    1.00     11.7±0.03ms    32.1 MB/sec
packument/parse                                  1.00     40.9±0.09µs  1621.8 MB/sec    1.02     41.6±0.07µs  1594.8 MB/sec
tarball/download_dependency                      1.03      3.5±0.09ms  1236.4 KB/sec    1.00      3.4±0.09ms  1278.7 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    187.5±1.52ms 85.3 KElem/sec    1.00    188.1±1.84ms 85.1 KElem/sec
version_pick/repeated_ranges_file                1.02      4.3±0.04ms  7.2 KElem/sec    1.00      4.3±0.06ms  7.3 KElem/sec
version_pick/repeated_ranges_raw                 1.02      4.3±0.03ms  7.2 KElem/sec    1.00      4.3±0.04ms  7.3 KElem/sec
workspace_resolution/hoist_heavy                 1.00    203.6±0.42ms        ? ?/sec    1.01    205.4±1.37ms        ? ?/sec
workspace_sort/chained_projects                  1.01     14.4±0.40ms        ? ?/sec    1.00     14.2±0.82ms        ? ?/sec

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2318.30 ms 2320.41 ms 0.1% 115.92 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1489.92 ms 1358.86 ms -8.8% 74.50 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 234.05 ms 219.32 ms -6.3% 11.70 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 251.62 ms 246.55 ms -2.0% 12.58 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 8.08 ms 8.14 ms 0.7% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 12.96 ms 12.15 ms -6.3% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 8.13 ms 7.89 ms -3.0% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 11.82 ms 15.42 ms 30.5% 2.00 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-cold-store pacquet 2482.40 ms 2492.46 ms 0.4% 124.12 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1541.71 ms 1578.15 ms 2.4% 77.09 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 440.62 ms 446.02 ms 1.2% 22.03 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 291.19 ms 294.28 ms 1.1% 14.56 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1602.40 ms 1618.87 ms 1.0% 80.12 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 273.93 ms 285.91 ms 4.4% 13.70 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 365.72 ms 227.75 ms -37.7% 18.29 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 91.01 ms 108.82 ms 19.6% 4.55 ms Inconclusive (overlapping samples)
isolated-peer-heavy-resolve-hot-cache-offline pacquet 208.48 ms 214.83 ms 3.0% 10.42 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 191.36 ms 196.58 ms 2.7% 9.57 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 82.34 ms 81.11 ms -1.5% 4.12 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4456.81 ms 4407.03 ms -1.1% 222.84 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3515.83 ms 3447.10 ms -2.0% 175.79 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 112.04 ms 111.83 ms -0.2% 5.60 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 206.81 ms 122.52 ms -40.8% 10.34 ms Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1126.99 ms 1130.64 ms 0.3% 56.35 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 096a5c33b377

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked and injected workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.358 ± 0.106 2.262 2.574 1.64 ± 0.19
pacquet@main 2.361 ± 0.122 2.248 2.587 1.65 ± 0.19
pnpr@HEAD 1.435 ± 0.151 1.286 1.675 1.00
pnpr@main 1.502 ± 0.139 1.290 1.670 1.05 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.35777829842,
      "stddev": 0.10563919728286195,
      "median": 2.32040937932,
      "user": 1.3478356799999998,
      "system": 1.2572318999999998,
      "min": 2.26241253932,
      "max": 2.57416258032
    },
    {
      "command": "pacquet@main",
      "mean": 2.3612500647200005,
      "stddev": 0.12161113696520466,
      "median": 2.31830040582,
      "user": 1.3392406799999999,
      "system": 1.2472933,
      "min": 2.24823850732,
      "max": 2.5870670433200003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.43452382972,
      "stddev": 0.15130808974081222,
      "median": 1.35885885982,
      "user": 1.2686907800000002,
      "system": 1.1200314,
      "min": 1.28649363532,
      "max": 1.67535332232
    },
    {
      "command": "pnpr@main",
      "mean": 1.5016209824199998,
      "stddev": 0.13878160347564555,
      "median": 1.48992427032,
      "user": 1.22950058,
      "system": 1.1944727,
      "min": 1.2903145923200001,
      "max": 1.6701539913199999
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 222.6 ± 11.2 210.4 241.0 1.00
pacquet@main 235.4 ± 10.1 223.9 257.8 1.06 ± 0.07
pnpr@HEAD 248.1 ± 7.5 236.8 260.3 1.11 ± 0.07
pnpr@main 249.7 ± 13.6 230.4 276.9 1.12 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.22262449757999997,
      "stddev": 0.011177118439721594,
      "median": 0.21931574308000001,
      "user": 0.25524304,
      "system": 0.51876036,
      "min": 0.21042206008,
      "max": 0.24100347108
    },
    {
      "command": "pacquet@main",
      "mean": 0.23538103727999998,
      "stddev": 0.010125581343390602,
      "median": 0.23405182108,
      "user": 0.25612083999999996,
      "system": 0.5778565600000001,
      "min": 0.22390234708,
      "max": 0.25783977908
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.24809652588000003,
      "stddev": 0.007471863914346505,
      "median": 0.24655361508,
      "user": 0.26636363999999996,
      "system": 0.58592756,
      "min": 0.23681500108,
      "max": 0.26030823008
    },
    {
      "command": "pnpr@main",
      "mean": 0.24972102488,
      "stddev": 0.013600215144006706,
      "median": 0.25161786858,
      "user": 0.25045003999999993,
      "system": 0.5934887600000001,
      "min": 0.23037319508,
      "max": 0.27685227008
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 8.2 ± 0.4 7.1 9.5 1.00 ± 0.09
pacquet@main 8.2 ± 0.6 6.9 11.7 1.00
pnpr@HEAD 11.7 ± 3.7 6.9 20.2 1.44 ± 0.46
pnpr@main 12.9 ± 1.9 8.5 18.7 1.58 ± 0.26
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.008178163765367404,
      "stddev": 0.0003893022410698308,
      "median": 0.00814279612,
      "user": 0.00488716185303514,
      "system": 0.004137635015974443,
      "min": 0.00713475012,
      "max": 0.009471495120000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.00815485011382716,
      "stddev": 0.0005817669505363993,
      "median": 0.008083930120000003,
      "user": 0.004826971234567903,
      "system": 0.004127351851851852,
      "min": 0.00692268212,
      "max": 0.011678384120000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.011720834041686744,
      "stddev": 0.0036585552714049024,
      "median": 0.01214597362,
      "user": 0.00689954891566265,
      "system": 0.005812864759036146,
      "min": 0.00693911312,
      "max": 0.02016374812
    },
    {
      "command": "pnpr@main",
      "mean": 0.012884042306813191,
      "stddev": 0.0018755475934302955,
      "median": 0.012958014620000001,
      "user": 0.007444292527472525,
      "system": 0.006326887912087914,
      "min": 0.008479109120000002,
      "max": 0.01870723012
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 7.9 ± 0.4 7.1 11.4 1.00
pacquet@main 8.2 ± 0.4 7.2 11.2 1.03 ± 0.08
pnpr@HEAD 14.6 ± 3.1 7.5 20.7 1.85 ± 0.41
pnpr@main 11.7 ± 3.7 7.5 21.0 1.47 ± 0.47
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.00792674160896104,
      "stddev": 0.00044355970217200327,
      "median": 0.007885924820000001,
      "user": 0.004664089220779218,
      "system": 0.003951134025974026,
      "min": 0.00708227582,
      "max": 0.01140717382
    },
    {
      "command": "pacquet@main",
      "mean": 0.008163847129608543,
      "stddev": 0.00039556910348858713,
      "median": 0.00813047482,
      "user": 0.004960780640569394,
      "system": 0.00397014896797153,
      "min": 0.00720431482,
      "max": 0.011211144820000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.014642106276747413,
      "stddev": 0.003119080586149275,
      "median": 0.01542112582,
      "user": 0.008091549619377171,
      "system": 0.007707326712802769,
      "min": 0.007463531820000001,
      "max": 0.020663864820000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.01166160480113208,
      "stddev": 0.003704802671295294,
      "median": 0.01181929682,
      "user": 0.00675558515723271,
      "system": 0.005929101509433962,
      "min": 0.00752503782,
      "max": 0.020983905820000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.530 ± 0.093 2.469 2.731 1.67 ± 0.13
pacquet@main 2.493 ± 0.026 2.475 2.556 1.64 ± 0.11
pnpr@HEAD 1.560 ± 0.090 1.411 1.711 1.03 ± 0.09
pnpr@main 1.518 ± 0.100 1.384 1.669 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5304572178599996,
      "stddev": 0.09259746207532144,
      "median": 2.49246439186,
      "user": 1.8475951599999998,
      "system": 1.68202726,
      "min": 2.46935130436,
      "max": 2.7312887193599997
    },
    {
      "command": "pacquet@main",
      "mean": 2.49340332566,
      "stddev": 0.025817682884720534,
      "median": 2.48239704386,
      "user": 1.7360680599999998,
      "system": 1.6027146600000002,
      "min": 2.4750993863599997,
      "max": 2.55642320536
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.55997344756,
      "stddev": 0.0899580883707028,
      "median": 1.57815457736,
      "user": 1.12688916,
      "system": 1.33985756,
      "min": 1.4111705113600002,
      "max": 1.7108946963600002
    },
    {
      "command": "pnpr@main",
      "mean": 1.5175311264600002,
      "stddev": 0.09993013926517365,
      "median": 1.54171184486,
      "user": 1.1297801599999997,
      "system": 1.2122362599999998,
      "min": 1.3840093723600002,
      "max": 1.66864797536
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 443.7 ± 17.2 413.7 469.6 1.53 ± 0.09
pacquet@main 491.7 ± 112.3 415.2 717.9 1.69 ± 0.39
pnpr@HEAD 290.3 ± 12.7 271.6 303.7 1.00
pnpr@main 290.4 ± 6.3 280.7 299.7 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.44374639477999994,
      "stddev": 0.017191860133139072,
      "median": 0.44602296828,
      "user": 0.6051140399999999,
      "system": 0.7669510399999999,
      "min": 0.41373603728,
      "max": 0.46957792228
    },
    {
      "command": "pacquet@main",
      "mean": 0.49167361247999997,
      "stddev": 0.11231034016728741,
      "median": 0.44062371678,
      "user": 0.71522134,
      "system": 0.8452609399999998,
      "min": 0.41524829628000004,
      "max": 0.71791763228
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29031244757999997,
      "stddev": 0.012651703972971742,
      "median": 0.29427802078,
      "user": 0.23842984,
      "system": 0.5625314400000001,
      "min": 0.27157418128,
      "max": 0.30365585328
    },
    {
      "command": "pnpr@main",
      "mean": 0.29040995438000006,
      "stddev": 0.006314423525393498,
      "median": 0.29118665128,
      "user": 0.24607683999999996,
      "system": 0.58254934,
      "min": 0.28067570228,
      "max": 0.29970860128
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.675 ± 0.109 1.590 1.908 6.13 ± 0.45
pacquet@main 1.602 ± 0.022 1.554 1.634 5.86 ± 0.22
pnpr@HEAD 0.315 ± 0.069 0.273 0.491 1.15 ± 0.25
pnpr@main 0.273 ± 0.010 0.259 0.289 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.6747806831000003,
      "stddev": 0.10901627632861541,
      "median": 1.6188684230000001,
      "user": 1.00120316,
      "system": 1.0010624799999999,
      "min": 1.5898945560000002,
      "max": 1.9079650550000002
    },
    {
      "command": "pacquet@main",
      "mean": 1.6018132652000001,
      "stddev": 0.022428057864442668,
      "median": 1.6024038910000002,
      "user": 0.86550896,
      "system": 0.88099328,
      "min": 1.554265132,
      "max": 1.634125217
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31546585160000007,
      "stddev": 0.06851955605198373,
      "median": 0.2859050795,
      "user": 0.28119995999999997,
      "system": 0.5897648799999999,
      "min": 0.272732177,
      "max": 0.49061177000000006
    },
    {
      "command": "pnpr@main",
      "mean": 0.2734289149000001,
      "stddev": 0.009516957778796532,
      "median": 0.273925081,
      "user": 0.23276276,
      "system": 0.49352887999999995,
      "min": 0.259239855,
      "max": 0.28878712000000006
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 233.3 ± 28.0 206.8 314.4 2.57 ± 0.31
pacquet@main 367.8 ± 7.9 359.1 382.0 4.05 ± 0.13
pnpr@HEAD 108.9 ± 17.2 91.8 136.9 1.20 ± 0.19
pnpr@main 90.8 ± 2.1 86.2 94.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.23330988612,
      "stddev": 0.02802201090902933,
      "median": 0.22774663912,
      "user": 0.20672461333333333,
      "system": 0.08824813999999999,
      "min": 0.20676536762,
      "max": 0.31441144362000006
    },
    {
      "command": "pacquet@main",
      "mean": 0.36780216792000003,
      "stddev": 0.00787555361197573,
      "median": 0.36571725312000003,
      "user": 0.36858097999999995,
      "system": 0.14283624,
      "min": 0.35911377662000005,
      "max": 0.38199648262
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10886467631565219,
      "stddev": 0.017174863409762757,
      "median": 0.10882183562000002,
      "user": 0.04554312782608696,
      "system": 0.019665031304347828,
      "min": 0.09176358262,
      "max": 0.13689617362
    },
    {
      "command": "pnpr@main",
      "mean": 0.09082091397483873,
      "stddev": 0.002112291515602262,
      "median": 0.09100567962000002,
      "user": 0.03469110258064516,
      "system": 0.011781607741935485,
      "min": 0.08618189662,
      "max": 0.09490957762
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 212.8 ± 11.3 194.1 227.5 1.01 ± 0.06
pacquet@main 210.2 ± 7.1 200.5 221.9 1.00
pnpm@HEAD 3329.1 ± 72.2 3192.9 3417.0 15.84 ± 0.64
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.21276186763333335,
      "stddev": 0.011334206817052385,
      "median": 0.2148336733,
      "user": 0.21436924666666665,
      "system": 0.05415977777777778,
      "min": 0.1940680713,
      "max": 0.2274792713
    },
    {
      "command": "pacquet@main",
      "mean": 0.21017469874444447,
      "stddev": 0.007138368126283509,
      "median": 0.2084822203,
      "user": 0.2097339133333333,
      "system": 0.055942222222222227,
      "min": 0.2005201643,
      "max": 0.22186439230000002
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.3291035711888894,
      "stddev": 0.07221966068452929,
      "median": 3.3363839743000003,
      "user": 5.087060135555556,
      "system": 0.36926411111111107,
      "min": 3.1929453243,
      "max": 3.4169527103000004
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 197.7 ± 3.9 193.0 204.6 1.04 ± 0.04
pacquet@main 190.3 ± 5.4 183.3 203.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.19769384093333334,
      "stddev": 0.00385377375436569,
      "median": 0.1965842978,
      "user": 0.15345736,
      "system": 0.08297451333333333,
      "min": 0.1929674168,
      "max": 0.2045514568
    },
    {
      "command": "pacquet@main",
      "mean": 0.19029703122857142,
      "stddev": 0.005390976100308193,
      "median": 0.1913570643,
      "user": 0.15565288857142856,
      "system": 0.06901475142857143,
      "min": 0.1832598018,
      "max": 0.2031251578
    }
  ]
}

Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 80.5 ± 3.7 73.1 91.5 1.00
pacquet@main 82.5 ± 4.1 72.5 91.9 1.03 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.08048419592594594,
      "stddev": 0.003723798741305808,
      "median": 0.08111132398000001,
      "user": 0.02619696378378378,
      "system": 0.06045322594594595,
      "min": 0.07308528398000001,
      "max": 0.09152485498000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.082504753355,
      "stddev": 0.00413792407817766,
      "median": 0.08234125198,
      "user": 0.030817054999999996,
      "system": 0.05814937375000001,
      "min": 0.07246847298000002,
      "max": 0.09189245598000001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.497 ± 0.183 4.337 4.809 1.29 ± 0.06
pacquet@main 4.482 ± 0.131 4.345 4.687 1.29 ± 0.05
pnpr@HEAD 3.480 ± 0.097 3.392 3.703 1.00
pnpr@main 3.564 ± 0.139 3.394 3.812 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.496725140160001,
      "stddev": 0.1831408034779877,
      "median": 4.407025618960001,
      "user": 1.48149526,
      "system": 1.6081551399999998,
      "min": 4.33708822896,
      "max": 4.809246793960001
    },
    {
      "command": "pacquet@main",
      "mean": 4.48197654306,
      "stddev": 0.13099383546563712,
      "median": 4.45681455196,
      "user": 1.4106472600000002,
      "system": 1.4372818400000003,
      "min": 4.345286741960001,
      "max": 4.6869955269600005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.48012458656,
      "stddev": 0.09690164747256197,
      "median": 3.4471026699599996,
      "user": 1.31568256,
      "system": 1.36413364,
      "min": 3.3924963299599997,
      "max": 3.70332776496
    },
    {
      "command": "pnpr@main",
      "mean": 3.5641332819599993,
      "stddev": 0.138585652653277,
      "median": 3.51583280346,
      "user": 1.31658186,
      "system": 1.34647594,
      "min": 3.39421188496,
      "max": 3.81191432296
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 112.5 ± 3.9 105.8 122.2 1.00
pacquet@main 113.2 ± 4.4 107.3 120.7 1.01 ± 0.05
pnpr@HEAD 122.6 ± 2.6 118.9 130.0 1.09 ± 0.04
pnpr@main 205.8 ± 28.7 134.4 252.6 1.83 ± 0.26
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.11254955879043478,
      "stddev": 0.003924103110715356,
      "median": 0.11183199866,
      "user": 0.14625147304347824,
      "system": 0.11558973652173911,
      "min": 0.10578757266000001,
      "max": 0.12224985766
    },
    {
      "command": "pacquet@main",
      "mean": 0.11320212305130435,
      "stddev": 0.004377593894566178,
      "median": 0.11203836566,
      "user": 0.13996490782608692,
      "system": 0.11769104086956522,
      "min": 0.10725213666000001,
      "max": 0.12067635866000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.12262184718380953,
      "stddev": 0.0025800237210065694,
      "median": 0.12252353066,
      "user": 0.1467658933333333,
      "system": 0.11727854190476193,
      "min": 0.11890399666000001,
      "max": 0.12999061266000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.20577275739684212,
      "stddev": 0.02870065102088621,
      "median": 0.20681294866000002,
      "user": 0.23536613894736844,
      "system": 0.18583167473684206,
      "min": 0.13441102266000002,
      "max": 0.25263260366
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.130 ± 0.016 1.108 1.150 1.00 ± 0.02
pacquet@main 1.129 ± 0.012 1.113 1.154 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.1302333214400004,
      "stddev": 0.015597141875196115,
      "median": 1.13063950424,
      "user": 0.51931018,
      "system": 0.20110109999999998,
      "min": 1.10760137074,
      "max": 1.14968078174
    },
    {
      "command": "pacquet@main",
      "mean": 1.1287782387400003,
      "stddev": 0.012362670654500856,
      "median": 1.12698784874,
      "user": 0.50966438,
      "system": 0.2051259,
      "min": 1.1130613977400001,
      "max": 1.1538222397400002
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review October 17, 2026 09:34
@zkochan

zkochan commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

Copilot AI balanced review requested due to automatic review settings October 17, 2026 09:35

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Unify tiered peer-provider selection in pnpm v11 and v12

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Route required and optional peer hoists through one tiered provider picker in both versions.
• Preserve each picker's version priorities and range rules, including the existing v11/v12
 optional-tier difference.
• Move v12 picker tests and update their references after renaming the module.
Diagram

graph TD
  A["Importer hoist"] --> B{"Peer kind"}
  B -->|required| C["Resolved tiers"] -->|prerelease range| E["Shared picker"] --> F["Hoisted dependencies"]
  B -->|optional| D["Locked resolved tiers"] -->|strict ranges| E
  G["Preferred selectors"] --> E
Loading
High-Level Assessment

A shared picker with caller-supplied tiers and qualification rules is the right scope for this step: it removes duplicate selection loops without forcing required and optional peers to share different range semantics. Keep the v11 optional lockfile-tier difference for a separately validated parity change.

Files changed (8) +248 / -255

Refactor (6) +235 / -246
lib.rsRegister the renamed peer-provider module +4/-4

Register the renamed peer-provider module

• Replaces the hoist-peers module declaration and re-export source with peer_provider. The public hoisting exports remain available.

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

peer_provider.rsCentralize Rust peer-provider selection +157/-172

Centralize Rust peer-provider selection

• Introduces ProviderTiers and a highest-qualifying-version picker used by required and optional hoists. Retains their separate tier priorities and range checks; equal optional versions differing only in build metadata now keep the first selector.

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

tree_ctx.rsReturn typed optional-provider tiers +7/-4

Return typed optional-provider tiers

• Builds ProviderTiers from locked and resolved versions instead of returning raw sets. The tier priorities remain unchanged.

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

resolve_importer.rsImport hoisting functions from peer_provider +2/-2

Import hoisting functions from peer_provider

• Redirects importer orchestration imports to the renamed Rust module.

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

hoist_rounds.rsUpdate hoist-round specifier import +1/-1

Update hoist-round specifier import

• Imports the optional-peer specifier helper from peer_provider after the module rename.

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

hoistPeers.tsShare the v11 required and optional version picker +64/-63

Share the v11 required and optional version picker

• Adds a tier-aware provider picker and routes both hoist paths through it while retaining their respective range checks. Required peers still demote lockfile-only versions; optional peers still have no lockfile tiers in v11.

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

Tests (1) +12 / -8
tests.rsAdapt picker tests to ProviderTiers +12/-8

Adapt picker tests to ProviderTiers

• Moves the existing hoisting tests with the renamed module and constructs optional preferences through ProviderTiers. The test expectations are unchanged.

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

Documentation (1) +1 / -1
TEST_PORTING.mdCorrect the ported-test location +1/-1

Correct the ported-test location

• Points the test-porting record to peer_provider/tests.rs.

pnpm/plans/TEST_PORTING.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. v11 and v12 can bind different providers 📎 Requirement gap ≡ Correctness
Description
The v11 optional picker calls pickProviderVersion without any lockfile-derived tiers, while v12
builds ProviderTiers::optional from locked and resolved versions. When a compatible locked
provider competes with a newly resolved provider, the two release lines can bind different providers
and produce divergent peer lockfile output.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R219-222]

+    const maxSatisfyingVersion = pickProviderVersion(allPreferredVersions[missingOptionalPeerName], {
+      qualifies: (version) => (rootRange == null || semver.satisfies(version, rootRange)) &&
+        ranges.every(range => semver.satisfies(version, range)) &&
+        acceptsCandidate(missingOptionalPeerName, version),
Relevance

●● Moderate

Parity concern is credible, but the PR explicitly scopes this step to shared picker structure and
preserves v11 differences.

PR-#16707

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3800841 requires consistent peer-provider decisions and lockfile output between v11
and v12. The changed v11 optional path invokes pickProviderVersion with only a range predicate,
whereas the v12 implementation explicitly constructs ordered locked and resolved tiers, so the two
paths retain different provider-selection inputs.

Make peer provider binding consistent across resolution paths
pnpm11/installing/deps-resolver/src/hoistPeers.ts[212-222]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[205-220]

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 v11 optional peer picker has no lockfile-derived provider tiers, while the v12 picker prioritizes locked-and-resolved, resolved, and locked providers. This can produce different peer bindings and lockfile output for the same input across the two supported release lines.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[212-222]
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[205-220]

## Recommended Fix
Thread the v11 lockfile-only or equivalent provider metadata into the optional peer picker and pass ordered tiers to `pickProviderVersion` using the same precedence as v12. Add parity tests that exercise a compatible locked provider alongside a newly resolved provider and assert identical provider selection and lockfile output in both implementations.

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

Dismiss ↗ | View ↗


2. Peer hoists validate excluded versions ✓ Resolved
Description
pickHighestVersion calls semver.valid before the tier predicate can reject a selector, so a
tiered pass validates versions it cannot pick. When a required peer has lockfile-only versions, each
hoist round can validate those excluded versions in the first pass and again in the unrestricted
fallback.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R152-154]

+  for (const [version, selector] of Object.entries(selectors)) {
+    if (getSelectorType(selector) !== 'version' || semver.valid(version) == null || !qualifies(version)) continue
+    if (highest == null || semver.gt(version, highest)) {
Relevance

●● Moderate

The performance concern is plausible, but no close precedent establishes acceptance for reordering
these checks.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new tier pass wraps membership in qualifies, but pickHighestVersion invokes semver.valid
before qualifies. If the tier finds no pick, the picker scans the selectors again without a tier;
required-peer hoisting itself repeats until convergence.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[129-157]
pnpm11/installing/deps-resolver/src/resolveRootDependencies.ts[97-116]

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 tiered required-peer pass validates selector versions before checking whether they belong to its tier, adding avoidable work to repeated hoist rounds.

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

## Recommended Fix
Apply the cheap selector-type and tier-membership checks before semver validation. Preserve validation for candidates that reach range checking or version comparison, and retain the unrestricted fallback.

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



Informational

3. Optional peer picker runs provider acceptance check more often ✓ Resolved
Description
In v11's getHoistableOptionalPeers, acceptsCandidate is now invoked inside the qualifies
callback passed to pickProviderVersion/pickHighestVersion, so it runs for every candidate
version that passes the range checks, not only for the current best as before. The old
findMaxSatisfyingVersion only called acceptsCandidate after a version already beat the running
maximum; each extra call can trigger building the peer-range lookup (getPeerRanges) and, for
lockfile-only candidates, the one-time index over the entire wanted lockfile.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R219-222]

+    const maxSatisfyingVersion = pickProviderVersion(allPreferredVersions[missingOptionalPeerName], {
+      qualifies: (version) => (rootRange == null || semver.satisfies(version, rootRange)) &&
+        ranges.every(range => semver.satisfies(version, range)) &&
+        acceptsCandidate(missingOptionalPeerName, version),
Relevance

●●● Strong

Recent resolver history accepts concrete hot-path reductions and avoids repeated candidate work.

PR-#16474
PR-#14841

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Old code: acceptsCandidate was only called inside the if guarding `satisfiesAllRanges &&
(!maxSatisfyingVersion || semver.gt(version, maxSatisfyingVersion))`, i.e. only for a new running
maximum. New code calls it unconditionally for every version satisfying ranges, inside the
qualifies closure passed to pickProviderVersion, which pickHighestVersion evaluates for every
candidate regardless of whether it would become the new best.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[219-223]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-158]

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

## Issue description
`getHoistableOptionalPeers` now runs `acceptsCandidate` for every version selector that passes the range checks, instead of only for the current running maximum as the pre-refactor `findMaxSatisfyingVersion` did. This adds extra calls on a path that can rebuild peer-range lookups and index the wanted lockfile.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[219-223]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-158]

## Recommended Fix
Split `pickHighestVersion`/`pickProviderVersion` so a cheap `qualifies` check (ranges) is evaluated first to find a candidate running maximum, and a separate, more expensive `accepts` callback (like `acceptsCandidate`) is only invoked once a version becomes the new best, matching the previous call pattern.

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


4. Hoist loop copies resolved-version set every call ✓ Resolved
Description
ProviderTiers::required clones the resolved_versions set and its strings even though the picker
only checks membership, replacing the previous borrowed filter. preferred_version_specifier
invokes it for each missing required peer in every hoist round after the resolved sets have already
been built, so the repeated copying grows with each peer’s resolved-version count.
Code

pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[R198-203]

+    /// The versions this run `resolved`. A version only the wanted
+    /// lockfile holds is a weight whose provider has moved on, so it must
+    /// not outrank one this run resolved.
+    fn required(resolved: Option<&HashSet<String>>) -> Self {
+        Self(resolved.cloned().into_iter().collect())
    }
-    let mut parts: Vec<String> = Vec::new();
-    if let Some(highest) = max_satisfying_any(&versions) {
-        parts.push(highest.to_string());
Relevance

● Weak

Recent matching precedent rejected repeated resolved-version allocations in this hoist path.

PR-#16474

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The previous preferred_version_specifier implementation used
versions.iter().copied().filter(|version| resolved.contains(*version)) to check the borrowed set
without copying it. The new ProviderTiers::required uses resolved.cloned().into_iter().collect()
to allocate a set of cloned strings; the importer first constructs resolved sets for missing peers,
then calls the picker for each peer in each hoist round, where the picker only performs membership
checks against those sets.

pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[139-150]
pnpm/crates/resolving-deps-resolver/src/resolve_importer/hoist_rounds.rs[181-202]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[74-83]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[197-202]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[242-258]

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-peer selection clones each resolved-version set and its strings despite only needing membership checks. This adds repeated allocation for each missing required peer in every hoist round.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[139-150]
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[195-203]
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[237-258]

## Recommended Fix
Represent the required tier with a borrowed set, such as by letting `ProviderTiers` hold references or passing a slice of borrowed sets to `highest_provider_version`. Avoid cloning resolved versions during required-tier construction, keep optional tiers owned where their construction requires ownership, and preserve the existing tier order.

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


5. Published resolver changes lack release notes 📘 Rule violation § Compliance
Description
The PR changes the published @pnpm/installing.deps-resolver implementation but adds no changeset
entry for the affected package. The new provider-selection helper changes distributed TypeScript
package code, so release metadata is missing for the next published artifact.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R139-142]

+function pickProviderVersion (
+  selectors: VersionSelectors,
+  { tiers = [], qualifies }: { tiers?: Array<Set<string>>, qualifies: (version: string) => boolean }
+): string | undefined {
Relevance

● Weak

A recent missing-changeset finding for a published package was explicitly rejected.

PR-#16440

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed TypeScript file introduces the new provider-selection helper, while its package manifest
identifies @pnpm/installing.deps-resolver as a publishable package with a package version and
publish metadata. The PR diff contains no added changeset file for this affected published package,
violating the requirement for release metadata.

Rule 713441: Require changeset files for changes affecting published packages
pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-142]
pnpm11/installing/deps-resolver/package.json[1-24]

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 PR modifies the published `@pnpm/installing.deps-resolver` package but does not add a changeset naming the affected package and its semantic version bump.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-142]
- pnpm11/installing/deps-resolver/package.json[1-3]

## Recommended Fix
Add a new markdown file under `.changeset/` with front matter naming `@pnpm/installing.deps-resolver` and an appropriate patch bump, then describe the internal provider-selection refactor and its unchanged user-visible behavior.

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

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 66 rules
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/node-semver-rs (sha: 3d74d6b7) — View relationship
Review mode: Auto: ⚖️ Balanced: Behavioral resolver changes affect peer selection correctness and performance across versions.
✅ Fix-loop round: fix loop

Grey Divider

Tip of the day
💡 Did you know, you can see how risky a PR is at a glance with blast radius labels

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 096a5c3

Results up to commit e7c6fb0 🧠 Deep


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


Remediation recommended
1. v11 and v12 can bind different providers 📎 Requirement gap ≡ Correctness
Description
The v11 optional picker calls pickProviderVersion without any lockfile-derived tiers, while v12
builds ProviderTiers::optional from locked and resolved versions. When a compatible locked
provider competes with a newly resolved provider, the two release lines can bind different providers
and produce divergent peer lockfile output.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R219-222]

+    const maxSatisfyingVersion = pickProviderVersion(allPreferredVersions[missingOptionalPeerName], {
+      qualifies: (version) => (rootRange == null || semver.satisfies(version, rootRange)) &&
+        ranges.every(range => semver.satisfies(version, range)) &&
+        acceptsCandidate(missingOptionalPeerName, version),
Relevance

●● Moderate

Parity concern is credible, but the PR explicitly scopes this step to shared picker structure and
preserves v11 differences.

PR-#16707

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3800841 requires consistent peer-provider decisions and lockfile output between v11
and v12. The changed v11 optional path invokes pickProviderVersion with only a range predicate,
whereas the v12 implementation explicitly constructs ordered locked and resolved tiers, so the two
paths retain different provider-selection inputs.

Make peer provider binding consistent across resolution paths
pnpm11/installing/deps-resolver/src/hoistPeers.ts[212-222]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[205-220]

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 v11 optional peer picker has no lockfile-derived provider tiers, while the v12 picker prioritizes locked-and-resolved, resolved, and locked providers. This can produce different peer bindings and lockfile output for the same input across the two supported release lines.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[212-222]
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[205-220]

## Recommended Fix
Thread the v11 lockfile-only or equivalent provider metadata into the optional peer picker and pass ordered tiers to `pickProviderVersion` using the same precedence as v12. Add parity tests that exercise a compatible locked provider alongside a newly resolved provider and assert identical provider selection and lockfile output in both implementations.

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

Dismiss ↗ | View ↗


2. Peer hoists validate excluded versions ✓ Resolved
Description
pickHighestVersion calls semver.valid before the tier predicate can reject a selector, so a
tiered pass validates versions it cannot pick. When a required peer has lockfile-only versions, each
hoist round can validate those excluded versions in the first pass and again in the unrestricted
fallback.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R152-154]

+  for (const [version, selector] of Object.entries(selectors)) {
+    if (getSelectorType(selector) !== 'version' || semver.valid(version) == null || !qualifies(version)) continue
+    if (highest == null || semver.gt(version, highest)) {
Relevance

●● Moderate

The performance concern is plausible, but no close precedent establishes acceptance for reordering
these checks.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new tier pass wraps membership in qualifies, but pickHighestVersion invokes semver.valid
before qualifies. If the tier finds no pick, the picker scans the selectors again without a tier;
required-peer hoisting itself repeats until convergence.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[129-157]
pnpm11/installing/deps-resolver/src/resolveRootDependencies.ts[97-116]

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 tiered required-peer pass validates selector versions before checking whether they belong to its tier, adding avoidable work to repeated hoist rounds.

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

## Recommended Fix
Apply the cheap selector-type and tier-membership checks before semver validation. Preserve validation for candidates that reach range checking or version comparison, and retain the unrestricted fallback.

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



Informational
3. Optional peer picker runs provider acceptance check more often ✓ Resolved
Description
In v11's getHoistableOptionalPeers, acceptsCandidate is now invoked inside the qualifies
callback passed to pickProviderVersion/pickHighestVersion, so it runs for every candidate
version that passes the range checks, not only for the current best as before. The old
findMaxSatisfyingVersion only called acceptsCandidate after a version already beat the running
maximum; each extra call can trigger building the peer-range lookup (getPeerRanges) and, for
lockfile-only candidates, the one-time index over the entire wanted lockfile.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R219-222]

+    const maxSatisfyingVersion = pickProviderVersion(allPreferredVersions[missingOptionalPeerName], {
+      qualifies: (version) => (rootRange == null || semver.satisfies(version, rootRange)) &&
+        ranges.every(range => semver.satisfies(version, range)) &&
+        acceptsCandidate(missingOptionalPeerName, version),
Relevance

●●● Strong

Recent resolver history accepts concrete hot-path reductions and avoids repeated candidate work.

PR-#16474
PR-#14841

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Old code: acceptsCandidate was only called inside the if guarding `satisfiesAllRanges &&
(!maxSatisfyingVersion || semver.gt(version, maxSatisfyingVersion))`, i.e. only for a new running
maximum. New code calls it unconditionally for every version satisfying ranges, inside the
qualifies closure passed to pickProviderVersion, which pickHighestVersion evaluates for every
candidate regardless of whether it would become the new best.

pnpm11/installing/deps-resolver/src/hoistPeers.ts[219-223]
pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-158]

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

## Issue description
`getHoistableOptionalPeers` now runs `acceptsCandidate` for every version selector that passes the range checks, instead of only for the current running maximum as the pre-refactor `findMaxSatisfyingVersion` did. This adds extra calls on a path that can rebuild peer-range lookups and index the wanted lockfile.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[219-223]
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-158]

## Recommended Fix
Split `pickHighestVersion`/`pickProviderVersion` so a cheap `qualifies` check (ranges) is evaluated first to find a candidate running maximum, and a separate, more expensive `accepts` callback (like `acceptsCandidate`) is only invoked once a version becomes the new best, matching the previous call pattern.

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


4. Published resolver changes lack release notes 📘 Rule violation § Compliance
Description
The PR changes the published @pnpm/installing.deps-resolver implementation but adds no changeset
entry for the affected package. The new provider-selection helper changes distributed TypeScript
package code, so release metadata is missing for the next published artifact.
Code

pnpm11/installing/deps-resolver/src/hoistPeers.ts[R139-142]

+function pickProviderVersion (
+  selectors: VersionSelectors,
+  { tiers = [], qualifies }: { tiers?: Array<Set<string>>, qualifies: (version: string) => boolean }
+): string | undefined {
Relevance

● Weak

A recent missing-changeset finding for a published package was explicitly rejected.

PR-#16440

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed TypeScript file introduces the new provider-selection helper, while its package manifest
identifies @pnpm/installing.deps-resolver as a publishable package with a package version and
publish metadata. The PR diff contains no added changeset file for this affected published package,
violating the requirement for release metadata.

Rule 713441: Require changeset files for changes affecting published packages
pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-142]
pnpm11/installing/deps-resolver/package.json[1-24]

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 PR modifies the published `@pnpm/installing.deps-resolver` package but does not add a changeset naming the affected package and its semantic version bump.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/hoistPeers.ts[139-142]
- pnpm11/installing/deps-resolver/package.json[1-3]

## Recommended Fix
Add a new markdown file under `.changeset/` with front matter naming `@pnpm/installing.deps-resolver` and an appropriate patch bump, then describe the internal provider-selection refactor and its unchanged user-visible behavior.

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

Dismiss ↗ | View ↗


5. Hoist loop copies resolved-version set every call ✓ Resolved
Description
ProviderTiers::required clones the resolved_versions set and its strings even though the picker
only checks membership, replacing the previous borrowed filter. preferred_version_specifier
invokes it for each missing required peer in every hoist round after the resolved sets have already
been built, so the repeated copying grows with each peer’s resolved-version count.
Code

pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[R198-203]

+    /// The versions this run `resolved`. A version only the wanted
+    /// lockfile holds is a weight whose provider has moved on, so it must
+    /// not outrank one this run resolved.
+    fn required(resolved: Option<&HashSet<String>>) -> Self {
+        Self(resolved.cloned().into_iter().collect())
    }
-    let mut parts: Vec<String> = Vec::new();
-    if let Some(highest) = max_satisfying_any(&versions) {
-        parts.push(highest.to_string());
Relevance

● Weak

Recent matching precedent rejected repeated resolved-version allocations in this hoist path.

PR-#16474

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The previous preferred_version_specifier implementation used
versions.iter().copied().filter(|version| resolved.contains(*version)) to check the borrowed set
without copying it. The new ProviderTiers::required uses resolved.cloned().into_iter().collect()
to allocate a set of cloned strings; the importer first constructs resolved sets for missing peers,
then calls the picker for each peer in each hoist round, where the picker only performs membership
checks against those sets.

pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[139-150]
pnpm/crates/resolving-deps-resolver/src/resolve_importer/hoist_rounds.rs[181-202]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[74-83]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[197-202]
pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[242-258]

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-peer selection clones each resolved-version set and its strings despite only needing membership checks. This adds repeated allocation for each missing required peer in every hoist round.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[139-150]
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[195-203]
- pnpm/crates/resolving-deps-resolver/src/peer_provider.rs[237-258]

## Recommended Fix
Represent the required tier with a borrowed set, such as by letting `ProviderTiers` hold references or passing a slice of borrowed sets to `highest_provider_version`. Avoid cloning resolved versions during required-tier construction, keep optional tiers owned where their construction requires ownership, and preserve the existing tier order.

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


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 17, 2026
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

- pnpm v12 borrows the run-resolved set for the required tier, without cloning it.
- pnpm v11 checks tier membership before validating a version.
- pnpm v11 calls acceptsCandidate only for a version that would become the new highest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 09:53

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.

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@zkochan

zkochan commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Replies to the Qodo review of e7c6fb0:

  1. v11/v12 optional-tier parity: not acting. This PR keeps the picks the same on purpose, and the difference is called out in the description for a separately tested change under Decide peer provider binding in one place tasks#143.
  2. semver.valid before the tier check: fixed in 096a5c3. Tier membership is now checked first.
  3. acceptsCandidate called more often: fixed in 096a5c3. qualifies now runs only for a version that would become the new highest, as before the refactor.
  4. Missing changeset: not acting. This is an internal refactor with no user-visible change, so there is no release note to write.
  5. Required tier clones the resolved set: fixed in 096a5c3. highest_provider_version takes borrowed tiers, and the required pick passes resolved_versions as is.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 096a5c3

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan
zkochan merged commit d71dd6c into main Oct 17, 2026
70 checks passed
@zkochan
zkochan deleted the refactor/peer-provider-picker branch October 17, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants