Skip to content

perf(resolver): reuse cached metadata when the lockfile decides a range - #16460

Merged
zkochan merged 2 commits into
pnpm:mainfrom
jamenh:jhuang7/auto-dedupe-registry-revalidation
Oct 1, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
jamenh:jhuang7/auto-dedupe-registry-revalidation

Conversation

@jamenh

@jamenh jamenh commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Related to #16458. This PR fixes the registry revalidation part. #16461 fixes the no-op re-resolution.

A range pick can skip registry revalidation when the lockfile preferences prove that the cached packument already gives the answer: the stable cached-range proof from #13980. That proof missed three common cases. As a result, autoDedupe re-picks, and installs in workspaces that set minimumReleaseAge, revalidated packuments for picks the lockfile already decided:

  • Several locked versions satisfy the range, and one of them outranks the others. The proof required exactly one exact selector at the lockfile weight.
  • minimumReleaseAge is set. The proof was off even for names that minimumReleaseAgeExclude lists without a version, which the picker already treats as having no cutoff.
  • A direct dependency kept at its locked version. It carries a single weight-1 selector (fix: preserve locked direct dependencies during workspace resolution #16424), which the proof did not recognize.

Changes:

  • The proof. dominant_lockfile_version now builds the proof in one pass from every exact selector the range admits, at any positive weight.

    • The highest-weighted selector wins only if its guaranteed weight beats everything a range or tag selector could give another version.
    • Every other exact selector must stay below that weight, even with all tag weight added, so a tie never qualifies.
  • Release-age exemption. PackagePickPolicy::release_age_applies_to treats a name that minimumReleaseAgeExclude lists without versions as unrestricted. Five checks now use it:

    • the stable-range proof;
    • the in-memory unverified guard;
    • the shortcut for a young mirror without an ETag;
    • the publishedBy mtime shortcut;
    • the release-age metadata upgrade.

    An exclusion that names versions still revalidates.

  • One updated test. add_reuses_shared_packument_state_for_every_selector_path now expects one fetch. The package is exempt from minimumReleaseAge, so the install reuses the young mirror its selectors wrote.

The resolved output does not change. Only the number of requests does.

Benchmarks

Measured on main at bb11485b0, on a Mac M4, online with a warm metadata cache. Lockfiles were byte-identical across builds.

Reproduction repository: 20 alternating runs, median.

Scenario main this PR
README update 3.11 s 2.79 s (−10%)
README update, --auto-dedupe 2.64 s 2.42 s (−8%)
No-op, --auto-dedupe 2.61 s 2.28 s (−12%)

Our private monorepo: 3 runs, median.

Scenario main this PR
11 range bumps 34.9 s 29.6 s (−15%)
11 range bumps, --auto-dedupe 60.4 s 44.9 s (−26%)
No-op, --auto-dedupe 56.7 s 42.9 s (−24%)

Trade-off

As in #13980, the proof covers versions published after the packument was cached, so only an unpublish can change the answer later.

pnpm v11

This is a v12 performance change, not a shared bug fix: the resolved output is identical, and only the number of conditional metadata requests drops. The TypeScript resolver keeps the single-version and minimumReleaseAge limits in canReuseStableCachedRange (pnpm11/resolving/npm-resolver/src/pickPackage.ts) and getDominantLockfileVersion (pnpm11/resolving/npm-resolver/src/dominantLockfileVersion.ts). Most of the gain depends on v12-only behavior: autoDedupe, and the locked direct-dependency selector from #16424.

Squash Commit Body

The stable cached-range proof from pnpm/pnpm#13980 lets a range pick skip
registry revalidation when the preferred versions prove that no version
missing from the cached packument can win. It only fired for exactly one
exact selector at the lockfile weight, and not at all under
minimumReleaseAge. autoDedupe reopens every package with several locked
versions, and a workspace that sets minimumReleaseAge usually excludes its
own scopes, so most of its re-picks paid a conditional request.

Prove the pick from every exact selector the range admits, at any
positive weight. The winner is the one with the highest guaranteed
weight, its own selector plus every range it satisfies. That weight must
exceed what range and tag selectors could give any other version, and
every other exact selector must stay below it with every tag's weight
added, so a tie never qualifies. A version published after the packument
was cached can then not change the winner. With a single exact selector
at the lockfile weight this is the previous proof; the winner may now
also outrank other locked versions. The proof also covers the lone plain
selector of a direct dependency kept at its locked version
(pnpm/pnpm#16424).

Treat a package that minimumReleaseAgeExclude lists without versions as
unrestricted by the cutoff, since the picker ignores the cutoff for it. One
helper now answers this for the stable-range proof, the unverified
in-memory cache guard, the fresh ETag-less mirror shortcut, the publishedBy
mtime shortcut and the release-age metadata upgrade. An exclusion that
names versions still revalidates. An add test counted the install's
refetch of such a package's packument; the young mirror its selectors wrote
now answers the install, so the test expects one fetch.

As in pnpm/pnpm#13980, the proof covers versions published after the
packument was cached, so only an unpublish can change the answer later.

The TypeScript resolver has the same single-version and minimumReleaseAge
limits in its stable cached-range proof. They are not changed here.

Related to pnpm/pnpm#16458

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. (A v12 performance change; see "pnpm v11" above.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Summary by CodeRabbit

  • Bug Fixes
    • pnpm install now reuses cached registry metadata more often when the lockfile determines which version satisfies a range, reducing unnecessary registry requests.
    • Release-age settings now work more consistently with package-wide and version-specific exclusions, including when selecting versions from cached metadata.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 98501fc9-82fa-4a47-bb72-79639c422b37

📥 Commits

Reviewing files that changed from the base of the PR and between 1e37e14 and e096eb0.

📒 Files selected for processing (4)
  • pnpm/crates/config/src/version_policy.rs
  • pnpm/crates/config/src/version_policy/tests.rs
  • pnpm/crates/resolving-npm-resolver/src/pick_package.rs
  • pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs

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: fc496680-430d-4662-a56b-61d96e05c9be

📥 Commits

Reviewing files that changed from the base of the PR and between f50dacd and 2086f8e.

📒 Files selected for processing (3)
  • .changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md
  • pnpm/crates/resolving-npm-resolver/src/pick_package/tests/stable_range_mirror.rs
  • pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md

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


📝 Walkthrough

Walkthrough

The resolver evaluates multiple lockfile selectors when identifying stable cached range picks. It also checks package-specific release-age policy when deciding whether a cached packument can provide a stable pick or requires a registry request.

Changes

Cached metadata reuse

Layer / File(s) Summary
Prove stable cached versions
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs, pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs, pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/tests/*
The selector analysis evaluates satisfying exact versions against movable range and tag weights. Cached range selection checks that the normal picker selects the highest qualifying lockfile version. Tests cover selector weights and competing candidates.
Apply release-age policy to cached picks
pnpm/crates/resolving-npm-resolver/src/pick_package/*, pnpm/crates/resolving-npm-resolver/src/pick_package/tests/*, pnpm/crates/package-manager/src/add/tests/installation.rs, .changeset/*
The resolver checks whether release-age policy applies to a package when evaluating cached range picks. Tests cover mirror reuse, registry requests, and installation request counts. The changeset describes registry metadata reuse for specified lockfile and minimumReleaseAgeExclude cases.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PackagePicker
  participant PackagePickPolicy
  participant Mirror
  participant Registry
  PackagePicker->>PackagePickPolicy: Check release-age applicability for package
  PackagePicker->>Mirror: Read cached packument
  alt Policy does not apply
    Mirror-->>PackagePicker: Return cached packument for selection
  else Policy applies
    PackagePicker->>Registry: Request packument
    Registry-->>PackagePicker: Return packument response
  end
Loading

Possibly related PRs

  • pnpm/pnpm#13214: Both changes handle minimumReleaseAge policy exceptions in the Rust npm resolver. That PR threads a policy-filtered latest value; this PR centralizes the package applicability check and uses it in cached metadata and release-age upgrade logic.

Suggested labels: product: pacquet

Merge Risk: ⚪ Minimal · up to 2086f

Cached metadata reuse preserves release-age checks for nonexempt packages while allowing package-wide exemptions. No actionable merge-blocking risk remains, subject to normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 2086f

Version-selection and release-age safeguards remain in place. However, additional private-registry resolutions can now succeed from previously cached metadata without detecting revoked access. The exposure is limited to an existing cache namespace; whether this behavior is permitted needs clarification.

Retained concerns

  • Low · security · inferred: The broadened dominance proof admits additional online private-registry range picks that return cached metadata before contacting the registry. A caller able to reproduce the existing descriptor namespace may therefore continue resolving previously cached metadata after access is revoked. The fast path predates this PR, but its eligibility expands. This is an inferred authorization-lifecycle concern, not evidence of cross-namespace disclosure or access to uncached package data; the intended revocation policy remains unspecified.
Security review details

Security Blast Radius

  • inferred — The identified authorization uncertainty is bounded to metadata already present in a reproducible private descriptor namespace for the selected registry and package. The inspected scope construction does not establish cross-descriptor exposure, new credentials, or access to uncached packages.

Security Findings and Attack Paths

  • inferred — A caller with access to an existing descriptor-scoped mirror and newly qualifying selector preferences can receive an online range-resolution result without a registry request. If that descriptor's access has been revoked, the fast return cannot observe the denial. Whether this violates the intended cached-access contract remains unresolved.

Trust Boundaries and Controls

  • observed — Private routes reject disk fallback after an access-denied fetch. The private-401 test exercises that protection without qualifying selectors. It does not cover the dominant-cache return before fetching. The separate fresh-unvalidated mirror shortcut is explicitly restricted to public scope.

Resilience and Maintainability Implications

  • observed — Fast-path cache promotion is skipped during dry runs. Fetches are serialized by cache key, and a waiting caller discards its earlier disk snapshot and rechecks memory after acquiring the permit. These preserve recovery ordering; concurrent scheduling behavior was not executed during this review.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

Reuse cached registry metadata for lockfile-decided ranges

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Avoid registry revalidation when weighted lockfile selectors prove a cached range pick cannot
 change.
• Treat packages wholly excluded from minimum release age as unrestricted across cache-reuse checks.
• Add regression coverage for request counts, selector ties, and release-age exclusions.
Diagram

graph TD
  A["Range pick"] --> B{"Release age applies?"} -->|No| C{"Selectors dominate?"} -->|Yes| D{"Cached pick agrees?"} -->|Yes| E["Reuse metadata"]
  B -->|Yes| F["Existing fallback"]
  C -->|No| F
  D -->|No| F
Loading
High-Level Assessment

Extending the existing stable-range proof is the best fit: it reduces requests without changing the picker or resolved versions. Always revalidating preserves correctness but misses the performance goal; a freshness-only shortcut cannot prove that an older packument still gives the same answer.

Files changed (14) +588 / -225

Enhancement (5) +120 / -106
pick_package.rsWire in multi-version dominance proof +1/-1

Wire in multi-version dominance proof

• Replaces the single-version proof import with the new multi-version function used by cache-pick paths.

pnpm/crates/resolving-npm-resolver/src/pick_package.rs

mirror_pick.rsReuse mirrors for proven range picks and age exclusions +9/-13

Reuse mirrors for proven range picks and age exclusions

• Uses multi-version dominance to qualify stable mirror picks. Applies the shared release-age eligibility check to stable ranges, young mirrors without ETags, and the publishedBy mtime shortcut.

pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs

version_pick.rsAllow safe in-memory picks for age-excluded packages +1/-1

Allow safe in-memory picks for age-excluded packages

• Updates the unverified in-memory pick guard to permit stable range reuse when minimum release age does not apply to the package.

pnpm/crates/resolving-npm-resolver/src/pick_package/version_pick.rs

pick_package_from_meta.rsValidate picks against all dominant versions +13/-8

Validate picks against all dominant versions

• Requires the cached packument to contain every proven winner and the normal picker to select the highest one. This extends stable cached picks beyond a single dominant selector.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs

preferred_versions.rsProve dominance across weighted exact selectors +96/-83

Prove dominance across weighted exact selectors

• Replaces the sole-lockfile-version proof with one that evaluates all in-range exact selectors at positive weights. It bounds competing range and tag weights and rejects ties whose order a tag could change.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs

Refactor (2) +16 / -8
options.rsCentralize release-age applicability +14/-1

Centralize release-age applicability

• Adds a policy method that identifies when a minimum-release-age cutoff applies to a package. A name-only exclusion disables the cutoff; a version-scoped exclusion does not.

pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs

release_age_upgrade.rsShare exclusion logic for metadata upgrades +2/-7

Share exclusion logic for metadata upgrades

• Uses the centralized release-age check to avoid upgrading metadata for wholly excluded packages while retaining upgrades where the cutoff applies.

pnpm/crates/resolving-npm-resolver/src/pick_package/release_age_upgrade.rs

Tests (6) +447 / -111
installation.rsExpect one fetch across selector paths and install +6/-3

Expect one fetch across selector paths and install

• Updates the shared-packument integration test to expect one request instead of two. The follow-up install now reuses the young mirror for a package excluded from minimum release age.

pnpm/crates/package-manager/src/add/tests/installation.rs

tests.rsRegister stable-range mirror tests +1/-0

Register stable-range mirror tests

• Adds the new resolver-level test module to the pick-package suite.

pnpm/crates/resolving-npm-resolver/src/pick_package/tests.rs

stable_range_mirror.rsTest mirror reuse and registry request counts +183/-0

Test mirror reuse and registry request counts

• Adds two-pick tests for multiple locked versions, a plain direct-dependency selector, and release-age exclusions. Checks that age-restricted cases still fetch while eligible disk and in-memory metadata can be reused.

pnpm/crates/resolving-npm-resolver/src/pick_package/tests/stable_range_mirror.rs

version_selection.rsExpose mirror test helpers to sibling module +6/-2

Expose mirror test helpers to sibling module

• Makes the public-context and mirror-mtime helpers available to the new stable-range mirror tests.

pnpm/crates/resolving-npm-resolver/src/pick_package/tests/version_selection.rs

tests.rsMove stable-range tests into dedicated module +2/-106

Move stable-range tests into dedicated module

• Registers a focused stable cached-range test module and removes the corresponding inline tests from this file.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/tests.rs

stable_cached_range.rsCover selector dominance and unsafe ties +249/-0

Cover selector dominance and unsafe ties

• Retains the earlier proof cases and adds coverage for multiple winners, unequal weights, missing cached winners, plain selectors, and competing tags. It also checks ties affected by the latest tag or deprecation.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/tests/stable_cached_range.rs

Documentation (1) +5 / -0
reuse-cached-metadata-for-several-locked-versions.mdDocument reduced metadata requests +5/-0

Document reduced metadata requests

• Adds a pacquet patch changeset describing cache reuse for multiple locked versions, retained direct dependencies, and whole-package release-age exclusions.

.changeset/reuse-cached-metadata-for-several-locked-versions.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. A moved latest tag leaves installs stale ✓ Resolved
Description
dominant_lockfile_versions treats tied locked versions as settled when there are no explicit tag
selectors, although the normal picker can break the tie using the packument’s latest tag and
deprecation metadata. If either changes on the registry after the packument is cached,
dominant_version_pick and unverified_pick_is_safe can return the cached winner without
revalidation even though a fresh fetch would select another tied version, including in the
multi-version case reopened by autoDedupe.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[R60-61]

+    let order_is_settled = winners.len() == 1 || movable.tags == 0;
+    (top > movable.total && others_stay_below && order_is_settled).then(|| {
Relevance

●●● Strong

Recent cache-correctness precedents are accepted; stale tag and deprecation metadata directly
undermine the proof.

PR-#16438
PR-#15099

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The proof admits multiple winners when movable.tags == 0 and checks the expected winner only
against cached metadata. In contrast, preferred_max_pick uses the packument’s latest tag within
the top group, and non_deprecated_pick can move away from a deprecated winner when the group has
another member. Because the mirror path returns before a conditional request, a registry-side retag
or deprecation change is not observed.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[50-66]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[366-390]
.changeset/reuse-cached-metadata-for-several-locked-versions.md[5-5]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[366-389]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[414-434]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[113-132]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[482-496]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[340-369]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[477-497]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[106-130]
Skill: review-code

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 stable cached-range proof accepts tied locked versions even though changes to the registry’s `latest` tag or deprecation metadata can change which tied version the normal picker selects. The mirror can therefore return a stale pick without revalidation.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[50-66]
- pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[477-497]
- pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/tests/stable_cached_range.rs[202-210]

## Recommended Fix
Require `winners.len() == 1` for the stable-cache proof, unless tied picks can otherwise be proved independent of mutable `latest` and deprecation metadata. Let tied groups use normal conditional revalidation, which can still receive a 304 response. Add regressions comparing cached and fresh packuments where `latest` moves between tied winners and where the fresh packument deprecates the highest tied winner; assert that the pick revalidates.

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



Remediation recommended

2. Updates retain removed package versions 🐞 Bug ≡ Correctness
Description
range_pick_is_stable now admits name-wide release-age exclusions without checking
refresh_metadata, allowing dominant_version_pick to return an old mirror entry during a targeted
update. If another dependency supplies a dominant exact selector and the registry has since removed
that version from its packument, the update can keep selecting it instead of fetching metadata and
picking an available version.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[205]

+            && !opts.policy.release_age_applies_to(&spec.name)
Relevance

●●● Strong

Recent precedent accepted preventing targeted updates from reusing fresh mirrors; refresh metadata
must bypass this shortcut.

PR-#15879

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Targeted updates set refresh_metadata; preferred selectors can still be supplied by another edge.
The changed exclusion check now lets those requests enter the dominant mirror shortcut, which
returns before the fetch path. The in-memory unverified guard has the same newly broadened
condition.

pnpm/crates/resolving-resolver-base/src/resolve.rs[429-434]
pnpm/crates/resolving-npm-resolver/src/npm_resolver/guarded_pick.rs[53-75]
pnpm/crates/resolving-npm-resolver/src/preferred_overlay.rs[13-27]
pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs[108-119]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[111-132]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[194-209]
pnpm/crates/resolving-npm-resolver/src/pick_package/version_pick.rs[24-38]

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

## Issue description
A name-wide release-age exclusion now enables the stable-range mirror and in-memory shortcuts during a targeted update, even when that update requires refreshed registry metadata. A version removed from the registry can remain selected from the stale cache.
## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[194-209]
- pnpm/crates/resolving-npm-resolver/src/pick_package/version_pick.rs[24-38]
## Recommended Fix
Make both stable-range cache shortcuts fall through to registry revalidation when `opts.request.refresh_metadata` is true. Add a regression test with a name-wide exclusion, a dominant preferred version present only in the stale mirror, and a refreshed packument that omits it.

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

Dismiss ↗ | View ↗


3. Large exclusion lists slow installs ✓ Resolved
Description
release_age_applies_to calls PackageVersionPolicy::matches just to check for a name-wide
exemption, but that method scans every rule and allocates merged version lists for matching
version-scoped rules. When minimumReleaseAge is enabled with a large exclusion policy, the new
calls repeat that work across resolver cache and mirror fast paths for each package pick.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs[R115-116]

+                self.published_by_exclude.map(|policy| policy.matches(name)),
+                Some(PolicyMatch::AnyVersion),
Relevance

●●● Strong

Performance findings targeting repeated scans and allocations are accepted, especially in resolver
fast paths.

PR-#15099
PR-#13686

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new helper invokes matches at each call site. That method iterates the policy rules and
constructs a Vec and HashSet for matching version-scoped entries, although the helper discards
that result; the mirror and cache-pick paths can invoke the helper more than once per package.

pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs[112-118]
pnpm/crates/config/src/version_policy.rs[264-286]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[195-229]
pnpm/crates/resolving-npm-resolver/src/pick_package/version_pick.rs[28-39]

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 release-age fast-path guard evaluates and allocates the full version-policy match repeatedly when it only needs to know whether a name-wide exemption exists.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs[112-118]
- pnpm/crates/config/src/version_policy.rs[264-286]

## Recommended Fix
Add an allocation-free name-wide exemption query to `PackageVersionPolicy` and use it in `release_age_applies_to`. Avoid repeating the same policy lookup within a package pick where practical.

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


4. Release note bundles distinct cache fixes ✓ Resolved
Description
The changeset’s second sentence combines the locked-version proof cases with the separate
minimumReleaseAgeExclude change in one entry. Readers cannot distinguish the resolver change from
the release-age exemption when using the note to track which behavior changed.
Code

.changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md[5]

+`pnpm install` sends fewer registry metadata requests when the lockfile already decides which version a range resolves to. This now covers ranges where one locked version outranks the other locked versions they satisfy, direct dependencies kept at their locked version, and packages that `minimumReleaseAgeExclude` lists without a version [#16458](https://github.com/pnpm/pnpm/issues/16458).
Relevance

●●● Strong

Recent changeset reviews consistently accept splitting compound sentences that combine distinct
user-visible behaviors.

PR-#16427
PR-#16203
PR-#16437

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 3058304 requires each changeset sentence to describe one logical change. The second
sentence on line 5 enumerates changes to locked-version selection and release-age exemption
together.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md[5-5]

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 changeset combines the locked-version proof cases and the release-age exemption in one sentence.

## Fix Focus Areas
- .changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md[5-5]

## Recommended Fix
Give the locked-version cases and the release-age exemption separate, direct sentences describing their observable effect on registry requests.

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


View medium (2)
5. Version 11 repeats registry requests 📘 Rule violation ⌂ Architecture
Description
Rust’s range_pick_is_stable now permits name-wide release-age exclusions, and
dominant_lockfile_versions accepts several winning locked versions, but pnpm v11’s corresponding
paths still reject both cases. Given the same warm mirror, v11 continues to revalidate ranges that
v12 now serves from cache; the PR has no v11 regression coverage or note deferring that
implementation.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[205]

+            && !opts.policy.release_age_applies_to(&spec.name)
Relevance

●●● Strong

Recent accepted findings require Rust and pnpm11 behavior alignment for shared resolver bugs and
release-policy semantics.

PR-#15099
PR-#14175

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed Rust guard allows an excluded package through the stable-range path, while its new proof
can accept multiple locked winners. The TypeScript guard still requires publishedBy to be absent,
and its proof requires a sole locked winner, so the request-count fix is not present in v11.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[201-207]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[50-66]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[55-65]
pnpm11/resolving/npm-resolver/src/dominantLockfileVersion.ts[36-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
The Rust resolver now avoids registry revalidation for excluded release-age ranges and several winning locked versions, but the corresponding TypeScript resolver still revalidates them without a documented deferral.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[205-205]
- pnpm11/resolving/npm-resolver/src/pickPackage.ts[55-65]
- pnpm11/resolving/npm-resolver/src/dominantLockfileVersion.ts[36-75]

## Recommended Fix
Apply equivalent safe cache-reuse conditions and regression tests in pnpm v11, or explicitly document in the PR description that the v11 implementation is deferred.

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

Dismiss ↗ | View ↗


6. Large workspaces resolve more slowly 🐞 Bug ➹ Performance
Description
exact_selector_weights calls guaranteed_weight for every satisfying exact selector, and each
call rescans all selectors, making the new proof quadratic in selector count. On the mirror path,
dominant_version_pick runs that proof once directly and again through
pick_stable_cached_range_version, multiplying the work for packages with many locked versions.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[108]

+            exact.push((selector.clone(), guaranteed_weight(version_range, selectors, selector)?));
Relevance

●● Moderate

Quadratic proof cost is plausible, but no close precedent establishes rejecting this
resolver-specific optimization concern.

PR-#14175

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The per-candidate call at line 108 enters a full selector scan, producing O(E × S) work for E
eligible exact selectors and S total selectors. The mirror calls the proof before loading metadata
and calls a helper that repeats it; the preferred-selector overlay can aggregate locked versions for
a package.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[98-133]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[106-125]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[477-489]
pnpm/crates/resolving-npm-resolver/src/preferred_overlay.rs[39-66]

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 range proof repeatedly scans the selector map for each exact candidate and is calculated twice on an eligible mirror pick. This adds quadratic work to a resolution fast path for packages with many preferred selectors.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[98-133]
- pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[106-125]
- pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[477-497]

## Recommended Fix
Calculate candidate weights without rescanning every selector for each candidate, and pass the resulting proof to the cached-pick check so the mirror path does not recompute it. Add a selector-count scaling test or benchmark.

ⓘ 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): 63 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/node-semver-rs (sha: 3d74d6b7) — View relationship
Review mode: ⚖️ Balanced: This behavioral change alters release-age policy decisions and resolver metadata-revalidation shortcuts, creating real performance and correctness risk despite the small, localized patch.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit e096eb0

Results up to commit 02fc715 🧠 Deep


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


Remediation recommended
1. Version 11 repeats registry requests 📘 Rule violation ⌂ Architecture
Description
Rust’s range_pick_is_stable now permits name-wide release-age exclusions, and
dominant_lockfile_versions accepts several winning locked versions, but pnpm v11’s corresponding
paths still reject both cases. Given the same warm mirror, v11 continues to revalidate ranges that
v12 now serves from cache; the PR has no v11 regression coverage or note deferring that
implementation.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[205]

+            && !opts.policy.release_age_applies_to(&spec.name)
Relevance

●●● Strong

Recent accepted findings require Rust and pnpm11 behavior alignment for shared resolver bugs and
release-policy semantics.

PR-#15099
PR-#14175

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed Rust guard allows an excluded package through the stable-range path, while its new proof
can accept multiple locked winners. The TypeScript guard still requires publishedBy to be absent,
and its proof requires a sole locked winner, so the request-count fix is not present in v11.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[201-207]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta/preferred_versions.rs[50-66]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[55-65]
pnpm11/resolving/npm-resolver/src/dominantLockfileVersion.ts[36-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
The Rust resolver now avoids registry revalidation for excluded release-age ranges and several winning locked versions, but the corresponding TypeScript resolver still revalidates them without a documented deferral.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[205-205]
- pnpm11/resolving/npm-resolver/src/pickPackage.ts[55-65]
- pnpm11/resolving/npm-resolver/src/dominantLockfileVersion.ts[36-75]

## Recommended Fix
Apply equivalent safe cache-reuse conditions and regression tests in pnpm v11, or explicitly document in the PR description that the v11 implementation is deferred.

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

Dismiss ↗ | View ↗


Results up to commit f50dacd 🧠 Deep


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


Remediation recommended
1. Release note bundles distinct cache fixes ✓ Resolved
Description
The changeset’s second sentence combines the locked-version proof cases with the separate
minimumReleaseAgeExclude change in one entry. Readers cannot distinguish the resolver change from
the release-age exemption when using the note to track which behavior changed.
Code

.changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md[5]

+`pnpm install` sends fewer registry metadata requests when the lockfile already decides which version a range resolves to. This now covers ranges where one locked version outranks the other locked versions they satisfy, direct dependencies kept at their locked version, and packages that `minimumReleaseAgeExclude` lists without a version [#16458](https://github.com/pnpm/pnpm/issues/16458).
Relevance

●●● Strong

Recent changeset reviews consistently accept splitting compound sentences that combine distinct
user-visible behaviors.

PR-#16427
PR-#16203
PR-#16437

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 3058304 requires each changeset sentence to describe one logical change. The second
sentence on line 5 enumerates changes to locked-version selection and release-age exemption
together.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md[5-5]

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 changeset combines the locked-version proof cases and the release-age exemption in one sentence.

## Fix Focus Areas
- .changeset/reuse-cached-metadata-when-the-lockfile-decides-a-range.md[5-5]

## Recommended Fix
Give the locked-version cases and the release-age exemption separate, direct sentences describing their observable effect on registry requests.

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


Results up to commit 2086f8e ⚖️ Balanced


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


Remediation recommended
1. Updates retain removed package versions 🐞 Bug ≡ Correctness
Description
range_pick_is_stable now admits name-wide release-age exclusions without checking
refresh_metadata, allowing dominant_version_pick to return an old mirror entry during a targeted
update. If another dependency supplies a dominant exact selector and the registry has since removed
that version from its packument, the update can keep selecting it instead of fetching metadata and
picking an available version.
Code

pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[205]

+            && !opts.policy.release_age_applies_to(&spec.name)
Relevance

●●● Strong

Recent precedent accepted preventing targeted updates from reusing fresh mirrors; refresh metadata
must bypass this shortcut.

PR-#15879

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Targeted updates set refresh_metadata; preferred selectors can still be supplied by another edge.
The changed exclusion check now lets those requests enter the dominant mirror shortcut, which
returns before the fetch path. The in-memory unverified guard has the same newly broadened
condition.

pnpm/crates/resolving-resolver-base/src/resolve.rs[429-434]
pnpm/crates/resolving-npm-resolver/src/npm_resolver/guarded_pick.rs[53-75]
pnpm/crates/resolving-npm-resolver/src/preferred_overlay.rs[13-27]
pnpm/crates/resolving-npm-resolver/src/pick_package/options.rs[108-119]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[111-132]
pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[194-209]
pnpm/crates/resolving-npm-resolver/src/pick_package/version_pick.rs[24-38]

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

## Issue description
A name-wide release-age exclusion now enables the stable-range mirror and in-memory shortcuts during a targeted update, even when that update requires refreshed registry metadata. A version removed from the registry can remain selected from the stale cache.
## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/pick_package/mirror_pick.rs[194-209]
- pnpm/crates/resolving-npm-resolver/src/pick_package/version_pick.rs[24-38]
## Recommended Fix
Make both stable-range cache shortcuts fall through to registry revalidation when `opts.request.refresh_metadata` is true. Add a regression test with a name-wide exclusion, a dominant preferred version present only in the stale mirror, and a refreshed packument that omits it.

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

Dismiss ↗ | View ↗


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 02fc715

@codecov-commenter

codecov-commenter commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.17%. Comparing base (ef38d07) to head (e096eb0).

Files with missing lines Patch % Lines
...r/src/pick_package_from_meta/preferred_versions.rs 96.42% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16460   +/-   ##
=======================================
  Coverage   92.17%   92.17%           
=======================================
  Files        1519     1520    +1     
  Lines      204884   204843   -41     
=======================================
- Hits       188856   188821   -35     
+ Misses      16028    16022    -6     

☔ 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 added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 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 2297.62 ms 2401.11 ms 4.5% 114.88 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1434.65 ms 1324.43 ms -7.7% 71.73 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 266.89 ms 360.22 ms 35.0% 13.34 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pnpr 258.61 ms 287.59 ms 11.2% 12.93 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 8.88 ms 9.40 ms 5.8% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 9.84 ms 8.61 ms -12.4% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 9.45 ms 9.35 ms -1.1% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 9.34 ms 8.00 ms -14.3% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2632.53 ms 2730.19 ms 3.7% 131.63 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1704.64 ms 1541.69 ms -9.6% 85.23 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 487.82 ms 554.95 ms 13.8% 24.39 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 307.95 ms 313.40 ms 1.8% 15.40 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1635.56 ms 1626.30 ms -0.6% 81.78 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 289.48 ms 290.42 ms 0.3% 14.47 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 217.71 ms 225.43 ms 3.5% 10.89 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 91.75 ms 92.19 ms 0.5% 4.59 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 222.26 ms 216.87 ms -2.4% 11.11 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 268.93 ms 266.26 ms -1.0% 13.45 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4602.89 ms 4600.23 ms -0.1% 230.14 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3674.50 ms 3607.51 ms -1.8% 183.72 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 141.72 ms 140.24 ms -1.0% 7.09 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 148.63 ms 153.07 ms 3.0% 7.43 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: e096eb0f7f95

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares 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.417 ± 0.124 2.279 2.685 1.77 ± 0.13
pacquet@main 2.331 ± 0.097 2.254 2.588 1.71 ± 0.12
pnpr@HEAD 1.366 ± 0.074 1.299 1.501 1.00
pnpr@main 1.463 ± 0.131 1.329 1.711 1.07 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4167960289,
      "stddev": 0.12395775915897268,
      "median": 2.4011063198,
      "user": 1.3372650400000001,
      "system": 1.4245713000000002,
      "min": 2.2791030828000003,
      "max": 2.6847047398
    },
    {
      "command": "pacquet@main",
      "mean": 2.3305670285,
      "stddev": 0.09723981369859927,
      "median": 2.2976182568,
      "user": 1.3476891400000004,
      "system": 1.3026820999999997,
      "min": 2.2544438408,
      "max": 2.5880230898
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.3663563887000003,
      "stddev": 0.07390854484507375,
      "median": 1.3244309178,
      "user": 1.15231494,
      "system": 1.2322098999999997,
      "min": 1.2985640398,
      "max": 1.5007318078000003
    },
    {
      "command": "pnpr@main",
      "mean": 1.4631281899000002,
      "stddev": 0.1307650375669981,
      "median": 1.4346495883000001,
      "user": 1.37342214,
      "system": 1.4102655,
      "min": 1.3293130488,
      "max": 1.7114791898000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 331.7 ± 57.1 247.0 384.7 1.26 ± 0.25
pacquet@main 267.8 ± 11.1 245.6 288.0 1.01 ± 0.10
pnpr@HEAD 285.9 ± 12.2 267.3 308.2 1.08 ± 0.11
pnpr@main 264.0 ± 24.4 237.5 328.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.3317425153800001,
      "stddev": 0.05709928122213641,
      "median": 0.36022251538000005,
      "user": 0.38359108,
      "system": 0.7761435799999999,
      "min": 0.24698151138000002,
      "max": 0.3847371733800001
    },
    {
      "command": "pacquet@main",
      "mean": 0.26783901928000003,
      "stddev": 0.011107324187312232,
      "median": 0.26688887188,
      "user": 0.31040448,
      "system": 0.6373967799999999,
      "min": 0.24559235838000001,
      "max": 0.28797066438
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28586053698,
      "stddev": 0.012231780980653514,
      "median": 0.28759459338000004,
      "user": 0.30845488000000004,
      "system": 0.6253026799999999,
      "min": 0.26730825938,
      "max": 0.30819113138000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.2639655523800001,
      "stddev": 0.024407246217806516,
      "median": 0.25860859788,
      "user": 0.28821477999999995,
      "system": 0.5854430799999999,
      "min": 0.23751426738,
      "max": 0.32857517738
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 9.5 ± 1.3 7.4 15.7 1.08 ± 0.19
pacquet@main 8.9 ± 1.0 7.2 14.5 1.01 ± 0.16
pnpr@HEAD 8.8 ± 1.0 7.3 14.5 1.00
pnpr@main 10.0 ± 1.1 7.8 13.5 1.13 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009507567986482213,
      "stddev": 0.0012803971960509257,
      "median": 0.00939593386,
      "user": 0.005757831146245058,
      "system": 0.004599486956521738,
      "min": 0.0074004058600000006,
      "max": 0.01572514086
    },
    {
      "command": "pacquet@main",
      "mean": 0.008885784781348325,
      "stddev": 0.0009827945503263261,
      "median": 0.008883961860000001,
      "user": 0.005675703670411981,
      "system": 0.0040304636704119835,
      "min": 0.00715173886,
      "max": 0.01452464686
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.00881970454421052,
      "stddev": 0.0010159099908367414,
      "median": 0.008614785860000002,
      "user": 0.005073203467492263,
      "system": 0.004535253869969038,
      "min": 0.0073075818600000005,
      "max": 0.01447444286
    },
    {
      "command": "pnpr@main",
      "mean": 0.00995765056847458,
      "stddev": 0.0010750661869742934,
      "median": 0.00983669986,
      "user": 0.0060104942372881396,
      "system": 0.004840302372881355,
      "min": 0.007823038860000001,
      "max": 0.013471424860000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.5 ± 3.2 7.9 24.1 1.22 ± 0.44
pacquet@main 9.6 ± 1.0 7.8 13.9 1.11 ± 0.24
pnpr@HEAD 8.6 ± 1.7 6.6 15.6 1.00
pnpr@main 9.4 ± 0.9 7.3 12.9 1.09 ± 0.24
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.010450700404977375,
      "stddev": 0.003218378883946697,
      "median": 0.0093464555,
      "user": 0.0063844407239818995,
      "system": 0.004892440180995476,
      "min": 0.0079407765,
      "max": 0.024123206500000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.00957418522932331,
      "stddev": 0.0009609982947814107,
      "median": 0.009453405,
      "user": 0.005755354586466167,
      "system": 0.004724993233082708,
      "min": 0.007834516500000001,
      "max": 0.0139251045
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008588208603053437,
      "stddev": 0.0016526132479288242,
      "median": 0.0080034335,
      "user": 0.004986237557251913,
      "system": 0.0043480786259542,
      "min": 0.0066233035,
      "max": 0.0155781765
    },
    {
      "command": "pnpr@main",
      "mean": 0.009401128698347106,
      "stddev": 0.0009403562524922738,
      "median": 0.009336761,
      "user": 0.005349387768595042,
      "system": 0.004886093719008264,
      "min": 0.0073342775,
      "max": 0.0129411795
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.774 ± 0.167 2.587 3.162 1.77 ± 0.16
pacquet@main 2.636 ± 0.024 2.607 2.672 1.68 ± 0.12
pnpr@HEAD 1.569 ± 0.110 1.448 1.800 1.00
pnpr@main 1.693 ± 0.117 1.495 1.826 1.08 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.77366157166,
      "stddev": 0.16743317358895046,
      "median": 2.73019391496,
      "user": 2.55698124,
      "system": 2.02206332,
      "min": 2.58744939596,
      "max": 3.16196290296
    },
    {
      "command": "pacquet@main",
      "mean": 2.63632292366,
      "stddev": 0.024010111885453274,
      "median": 2.63253376496,
      "user": 2.28078194,
      "system": 1.71941312,
      "min": 2.60683281896,
      "max": 2.67208158596
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5690823660600002,
      "stddev": 0.10956864209170869,
      "median": 1.5416897249600001,
      "user": 1.4161890400000001,
      "system": 1.4494264200000002,
      "min": 1.4479411219600002,
      "max": 1.8003625239600003
    },
    {
      "command": "pnpr@main",
      "mean": 1.6931805477600002,
      "stddev": 0.11733709842091351,
      "median": 1.70464384896,
      "user": 1.4707457400000001,
      "system": 1.5073406199999997,
      "min": 1.49528480796,
      "max": 1.8255525139600002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 551.9 ± 67.3 428.3 627.2 1.78 ± 0.22
pacquet@main 480.5 ± 39.5 415.0 522.9 1.55 ± 0.13
pnpr@HEAD 313.9 ± 4.8 307.1 321.0 1.01 ± 0.03
pnpr@main 310.0 ± 7.9 300.1 323.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5519079572800001,
      "stddev": 0.06731311514417895,
      "median": 0.55495304948,
      "user": 0.7600780800000001,
      "system": 0.8843019,
      "min": 0.42834080298000005,
      "max": 0.62718742998
    },
    {
      "command": "pacquet@main",
      "mean": 0.48051521178000006,
      "stddev": 0.039504757065099295,
      "median": 0.48781917998,
      "user": 0.6632730800000001,
      "system": 0.7586331000000002,
      "min": 0.41495203698000005,
      "max": 0.52292008698
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31393092478000006,
      "stddev": 0.004803366389929634,
      "median": 0.31340295898000003,
      "user": 0.27085877999999997,
      "system": 0.6231688,
      "min": 0.30709027098,
      "max": 0.32104116698
    },
    {
      "command": "pnpr@main",
      "mean": 0.30997316598,
      "stddev": 0.007860140314873294,
      "median": 0.30795101198,
      "user": 0.28935138,
      "system": 0.57561,
      "min": 0.30012191498,
      "max": 0.32351414098000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.628 ± 0.024 1.586 1.680 5.67 ± 0.22
pacquet@main 1.662 ± 0.081 1.587 1.815 5.79 ± 0.35
pnpr@HEAD 0.290 ± 0.004 0.282 0.297 1.01 ± 0.04
pnpr@main 0.287 ± 0.010 0.267 0.302 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.62792002112,
      "stddev": 0.024092426498537326,
      "median": 1.62630172262,
      "user": 0.8552652399999999,
      "system": 0.8689605799999999,
      "min": 1.58626266762,
      "max": 1.68008976062
    },
    {
      "command": "pacquet@main",
      "mean": 1.6617487203199999,
      "stddev": 0.08088449364231604,
      "median": 1.63555835412,
      "user": 0.9173769399999999,
      "system": 0.9620497799999999,
      "min": 1.58657764662,
      "max": 1.8154711316199998
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28980507722000004,
      "stddev": 0.004054550373770692,
      "median": 0.29042195262000003,
      "user": 0.25432654,
      "system": 0.5796459799999999,
      "min": 0.28193569362,
      "max": 0.29743657662
    },
    {
      "command": "pnpr@main",
      "mean": 0.28721963521999994,
      "stddev": 0.010163365481983133,
      "median": 0.28948268662,
      "user": 0.24173163999999997,
      "system": 0.5720314799999999,
      "min": 0.26667137162,
      "max": 0.30167514162000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 237.7 ± 33.1 187.0 332.4 2.60 ± 0.37
pacquet@main 218.5 ± 17.2 198.4 259.4 2.39 ± 0.20
pnpr@HEAD 91.5 ± 2.2 87.1 96.0 1.00
pnpr@main 92.0 ± 3.7 87.3 102.1 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.23772051452666662,
      "stddev": 0.033063149750770016,
      "median": 0.22542881526000003,
      "user": 0.20603729333333337,
      "system": 0.08702947333333334,
      "min": 0.18699768926000002,
      "max": 0.33238360526000005
    },
    {
      "command": "pacquet@main",
      "mean": 0.21846041011714287,
      "stddev": 0.017231616498329046,
      "median": 0.21771205176000002,
      "user": 0.19760384571428566,
      "system": 0.08892926857142859,
      "min": 0.19835752826,
      "max": 0.25937673326
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09153351329225806,
      "stddev": 0.0021781231295633172,
      "median": 0.09219486326000001,
      "user": 0.03169623741935484,
      "system": 0.01382314645161291,
      "min": 0.08712830326000001,
      "max": 0.09601402626000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.09195973426000002,
      "stddev": 0.003673257531907867,
      "median": 0.09175032626,
      "user": 0.032921140645161294,
      "system": 0.013289296774193552,
      "min": 0.08733774626,
      "max": 0.10210909826
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 220.9 ± 11.3 208.8 246.1 1.00
pacquet@main 223.6 ± 8.5 212.6 241.8 1.01 ± 0.06
pnpm@HEAD 3563.0 ± 87.9 3453.5 3689.3 16.13 ± 0.92
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.22085617929333334,
      "stddev": 0.01129216653032598,
      "median": 0.21687323796000002,
      "user": 0.22603715777777778,
      "system": 0.05574241333333333,
      "min": 0.20878301896,
      "max": 0.24608394096000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.22356953107111113,
      "stddev": 0.008484613773835147,
      "median": 0.22226021196,
      "user": 0.23171782444444444,
      "system": 0.046689302222222215,
      "min": 0.21255437896,
      "max": 0.24179995796
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.56303025696,
      "stddev": 0.08790822714685348,
      "median": 3.53610401696,
      "user": 5.527619157777776,
      "system": 0.3554101911111111,
      "min": 3.4535078159599997,
      "max": 3.6893342529599997
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 259.2 ± 42.2 197.3 319.6 1.02 ± 0.24
pacquet@main 253.0 ± 42.8 195.9 314.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25916363510000007,
      "stddev": 0.042164744335098585,
      "median": 0.2662613211,
      "user": 0.1886975285714286,
      "system": 0.11110470285714287,
      "min": 0.19732735310000002,
      "max": 0.31960180410000005
    },
    {
      "command": "pacquet@main",
      "mean": 0.2529790487,
      "stddev": 0.042767317895974495,
      "median": 0.26893323560000004,
      "user": 0.2007174,
      "system": 0.10029256,
      "min": 0.1958511081,
      "max": 0.31429024510000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.622 ± 0.052 4.568 4.712 1.28 ± 0.03
pacquet@main 4.679 ± 0.205 4.471 5.019 1.29 ± 0.06
pnpr@HEAD 3.620 ± 0.068 3.547 3.753 1.00
pnpr@main 3.652 ± 0.066 3.527 3.754 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.62172947434,
      "stddev": 0.051648835087203186,
      "median": 4.60023288294,
      "user": 2.3361955599999997,
      "system": 2.1607587800000005,
      "min": 4.56758856044,
      "max": 4.71236513844
    },
    {
      "command": "pacquet@main",
      "mean": 4.67928145484,
      "stddev": 0.20516600144660893,
      "median": 4.60289489044,
      "user": 2.1815581599999994,
      "system": 2.0288361800000003,
      "min": 4.47090567244,
      "max": 5.01863462544
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.62019176704,
      "stddev": 0.06795321269889053,
      "median": 3.6075088599400003,
      "user": 2.02417946,
      "system": 1.8187206799999998,
      "min": 3.54709371644,
      "max": 3.75339205044
    },
    {
      "command": "pnpr@main",
      "mean": 3.65245138614,
      "stddev": 0.0661982845994286,
      "median": 3.67449657594,
      "user": 2.00674126,
      "system": 1.83976168,
      "min": 3.5273865084400002,
      "max": 3.75389418644
    }
  ]
}

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 141.4 ± 4.5 135.7 151.5 1.00
pacquet@main 142.3 ± 5.7 135.7 154.0 1.01 ± 0.05
pnpr@HEAD 150.8 ± 11.6 130.7 169.2 1.07 ± 0.09
pnpr@main 168.4 ± 34.7 133.2 236.1 1.19 ± 0.25
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1413594129355556,
      "stddev": 0.004532886836427837,
      "median": 0.14023775388,
      "user": 0.17665051333333334,
      "system": 0.14742406,
      "min": 0.13571843788000001,
      "max": 0.15145800988000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.1423386549355556,
      "stddev": 0.0057307922511884305,
      "median": 0.14171687588,
      "user": 0.16998712444444444,
      "system": 0.15302772666666664,
      "min": 0.13566122188000002,
      "max": 0.15402050088000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.15080019821333338,
      "stddev": 0.011601154384760951,
      "median": 0.15306576888,
      "user": 0.1790250466666667,
      "system": 0.15286572666666667,
      "min": 0.13073265688000002,
      "max": 0.16915521688000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.16840967052705885,
      "stddev": 0.0347071491790992,
      "median": 0.14863455888000002,
      "user": 0.1998615917647059,
      "system": 0.16175047176470586,
      "min": 0.13315330188000002,
      "max": 0.23609872488000003
    }
  ]
}

@jamenh
jamenh force-pushed the jhuang7/auto-dedupe-registry-revalidation branch from 02fc715 to f50dacd Compare October 1, 2026 03:05
@jamenh jamenh changed the title perf(resolver): reuse cached metadata when locked versions decide a range perf(resolver): reuse cached metadata when the lockfile decides a range Oct 1, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f50dacd

1 similar comment
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f50dacd

@jamenh
jamenh force-pushed the jhuang7/auto-dedupe-registry-revalidation branch from f50dacd to 2086f8e Compare October 1, 2026 04:24
@jamenh

jamenh commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

Re the Qodo review, as of 2086f8e:

  1. Tied winners: fixed earlier. The proof now accepts only a unique winner, so a tie never qualifies.
  2. Changeset: split into one sentence per effect. The minimumReleaseAgeExclude exemption gets its own sentence, because it also lets an excluded package reuse a young mirror that has no ETag, which has nothing to do with the lockfile.
  3. v11: this is a v12 performance change, not a fix for a bug shared with v11. The resolved output is unchanged and only the number of conditional metadata requests drops, so both versions still write the same lockfile. Most of the gain depends on v12-only behavior (autoDedupe, and the locked direct-dependency selector from fix: preserve locked direct dependencies during workspace resolution #16424). The "pnpm v11" section of the description says this.
  4. Proof cost: the proof now runs in one pass. It collects the in-range exact selectors, the ranges and the tag weight once, then adds each exact selector's satisfied range weights, and the four helpers and the struct are gone. The early call in dominant_version_pick is already on main. It is a cheap check that runs before the mirror is read from disk, so I left it.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2086f8e

1 similar comment
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2086f8e

The stable cached-range proof from pnpm#13980 lets a range pick skip
registry revalidation when the preferred versions prove that no version
missing from the cached packument can win. It only fired for exactly one
exact selector at the lockfile weight, and not at all under
minimumReleaseAge. autoDedupe reopens every package with several locked
versions, and a workspace that sets minimumReleaseAge usually excludes its
own scopes, so most of its re-picks paid a conditional request.

Prove the pick from every exact selector the range admits, at any
positive weight. The winner is the one with the highest guaranteed
weight, its own selector plus every range it satisfies. That weight must
exceed what range and tag selectors could give any other version, and
every other exact selector must stay below it with every tag's weight
added, so a tie never qualifies. A version published after the packument
was cached can then not change the winner. With a single exact selector
at the lockfile weight this is the previous proof; the winner may now
also outrank other locked versions. The proof also covers the lone plain
selector of a direct dependency kept at its locked version
(pnpm#16424).

Treat a package that minimumReleaseAgeExclude lists without versions as
unrestricted by the cutoff, since the picker ignores the cutoff for it. One
helper now answers this for the stable-range proof, the unverified
in-memory cache guard, the fresh ETag-less mirror shortcut, the publishedBy
mtime shortcut and the release-age metadata upgrade. An exclusion that
names versions still revalidates. An add test counted the install's
refetch of such a package's packument; the young mirror its selectors wrote
now answers the install, so the test expects one fetch.

As in pnpm#13980, the proof covers versions published after the
packument was cached, so only an unpublish can change the answer later.

The TypeScript resolver has the same single-version and minimumReleaseAge
limits in its stable cached-range proof. They are not changed here.

Related to pnpm#16458
@zkochan
zkochan force-pushed the jhuang7/auto-dedupe-registry-revalidation branch from 2086f8e to 1e37e14 Compare October 1, 2026 05:20
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1e37e14

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

release_age_applies_to now runs on several cache fast paths per pick.
PackageVersionPolicy::matches merges and clones the exact versions of
every matching rule, which this check never reads. Add
covers_every_version, which stops at the first bare-name or wildcard
rule that matches and allocates nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit e096eb0

@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 17e8a01 into pnpm:main Oct 1, 2026
53 checks passed
@zkochan

zkochan commented Oct 1, 2026

Copy link
Copy Markdown
Member

Review status as of e096eb0 (rebased onto current main). All checks are green. CodeRabbit reports no actionable comments on this head, and Qodo has updated its review to it. No review threads are unresolved.

Qodo findings:

  • 3. Large exclusion lists slow installs. Fixed in e096eb0. release_age_applies_to now calls a new PackageVersionPolicy::covers_every_version. It stops at the first bare-name or wildcard rule that matches and allocates nothing, where matches merged and cloned versions this check never reads. A unit test is in config/src/version_policy/tests.rs.
  • 2. Updates retain removed package versions. Declined. dominant_version_pick on main already ignores refresh_metadata for every package when minimumReleaseAge is unset. That is the trade-off perf(resolver): reuse stable cached range metadata #13980 accepted: only an unpublish can change a proven pick. This PR gives a package that minimumReleaseAgeExclude lists without a version the behavior it would have with the setting off. The picker already treats such a package that way, so the PR adds no new class of stale pick. The fresh-mirror-without-ETag shortcut, which is not covered by the proof, still checks refresh_metadata.
  • 5. v11 repeats registry requests. Declined, as the author explained above. This is a v12 performance change with identical resolved output, not a bug fix shared with v11.
  • 6. Large workspaces resolve more slowly. Stale. It refers to guaranteed_weight and exact_selector_weights, which this head no longer has. The proof now scans the selectors once. It then checks each in-range exact selector against the range selectors, which costs E × R over one package's selectors. The proof also runs a second time through pick_stable_cached_range_version, but that second call is already on main.

No work remains within the scope of this PR.


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

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants