Skip to content

fix(npm-resolver): align the stable-range shortcuts with pnpm v12 - #17072

Merged
zkochan merged 2 commits into
mainfrom
fix-v11-route-parity
Oct 17, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-v11-route-parity

Conversation

@zkochan

@zkochan zkochan commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

v11 only. This aligns v11's stable-range mirror shortcuts with v12's range_pick_is_stable. #17064 left the last two v11/v12 route differences as they were, and this PR closes them. Follow-up to pnpm/tasks#146.

The shortcuts are the dominant lockfile version and the fresh mirror without an ETag.

Packages excluded from minimumReleaseAge. This is a user-visible change. v11 ruled the shortcuts out whenever minimumReleaseAge was set, so a package in minimumReleaseAgeExclude always asked the registry. v12 rules them out only where the release age applies. Now v11 does too.

Offline and prefer-offline picks. These picks read the mirror first. When that read could not pick, v11 went on to try these shortcuts on the same mirror. v12 does not. Now v11 doesn't either. No result changes, because the shortcuts only re-read a mirror that already gave no pick.

Hot path. The exclusion check is a policy lookup, so it runs last, and only when every cheap condition passes. decideMirrorShortcuts reports the answer it computed (releaseAgeApplies), and mirrorWrittenAfter takes that answer. So a pick asks the policy at most once. v12 asks twice in the same case.

Tests.

  • metaCache.test.ts has a new test: a package excluded from minimumReleaseAge, with a dominant lockfile version, resolves from a backdated mirror without a registry request. It failed before the change.
  • route.test.ts adds table rows for the excluded package, another package excluded, offline, prefer-offline, the reported releaseAgeApplies, and mirrorWrittenAfter taking the given answer without asking again.
  • The full npm-resolver suite passes: 617 tests.

Squash Commit Body

The stable-range mirror shortcuts (the dominant lockfile version and the
fresh ETag-less mirror) now hold the same conditions as v12's
`range_pick_is_stable`:

- `minimumReleaseAge` rules them out only for a package it applies to.
  A package in `minimumReleaseAgeExclude` keeps them, so its range
  resolves from the mirror when the lockfile version dominates, instead
  of asking the registry.
- An offline or prefer-offline pick never tries them. Such a pick reads
  the mirror first, and the shortcuts only re-read the mirror that read
  could not pick from.

`decideMirrorShortcuts` reports the release-age answer it computed, and
`mirrorWrittenAfter` takes it, so a pick asks the exclusion policy at
most once.

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 a changeset (pnpm changeset) if this PR changes any published
    package.
  • Added or updated tests.

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

  • Bug Fixes
    • Packages excluded from minimum release-age checks can reuse a version already recorded in the lockfile when it satisfies the package range, avoiding an unnecessary registry lookup.
    • Release-age filtering continues to apply to packages that are not excluded. When minimum release age is not configured, package resolution remains unchanged.
    • Offline and prefer-offline range resolution does not use the stable range shortcuts.

The stable-range mirror shortcuts (the dominant lockfile version and the
fresh ETag-less mirror) now hold the same conditions as v12's
`range_pick_is_stable`:

- `minimumReleaseAge` rules them out only for a package it applies to.
  A package in `minimumReleaseAgeExclude` keeps them, so its range
  resolves from the mirror when the lockfile version dominates, instead
  of asking the registry.
- An offline or prefer-offline pick never tries them. Such a pick reads
  the mirror first, and the shortcuts only re-read the mirror that read
  could not pick from.

`decideMirrorShortcuts` reports the release-age answer it computed, and
`mirrorWrittenAfter` takes it, so a pick asks the exclusion policy at
most once.

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: db5026c2-48af-476c-948a-ce46a33921d4
📥 Commits

Reviewing files that changed from the base of the PR and between 71a363b and 537203a.

📒 Files selected for processing: 1
  • pnpm11/resolving/npm-resolver/src/route.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • pnpm11/resolving/npm-resolver/src/route.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 resolver now applies release-age filtering only when it applies to the package. Excluded packages can retain stable range shortcuts, and the package picker passes the computed policy result to mirror cutoff handling.

Changes: Release-age exclusion and mirror reuse

Layer / File(s) Summary
Range shortcut policy
pnpm11/resolving/npm-resolver/src/route.ts, pnpm11/resolving/npm-resolver/test/route.test.ts
Range shortcut eligibility now excludes offline and prefer-offline requests. An excluded package can retain stable range shortcuts. Route tests cover applicability results, shortcut selection, and reuse of the computed result.
Mirror cutoff reuse
pnpm11/resolving/npm-resolver/src/pickPackage.ts, pnpm11/resolving/npm-resolver/test/metaCache.test.ts, .changeset/release-age-exclude-reuses-mirror.md
The package picker passes release-age applicability to mirror cutoff handling. A regression test checks that an excluded package can select a preferred lockfile version without fetching metadata. The changeset declares patch releases for @pnpm/resolving.npm-resolver and pnpm.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: product: pnpm@11

Merge Risk: ⚪ Minimal · up to 53720

The change keeps the stable-range mirror shortcuts available for packages that are excluded from minimum release age, and skips them for offline picks. No actionable merge-blocking risk was found.

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

@zkochan
zkochan marked this pull request as ready for review October 17, 2026 23:01
@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 23:01

@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

Align pnpm v11 stable-range mirror shortcuts with v12

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Let packages excluded from minimum release age reuse eligible cached metadata instead of
 contacting the registry.
• Skip redundant range shortcuts after offline or prefer-offline mirror reads.
• Reuse the release-age policy decision and add routing and resolver regression tests.
Diagram

graph TD
  Request["Package pick"] --> First{"Mirror first?"} -->|yes| Mirror["Mirror pick"] -->|no pick| Policy{"Stable range?"} -->|yes| Shortcuts["Range shortcuts"] -->|miss| Cutoff["Cutoff mirror"] -->|miss| Registry["Registry fetch"]
  First -->|no| Policy
  Policy -->|no| Cutoff
Loading
High-Level Assessment

Keep the eligibility decision in the existing route policy and pass its release-age result to the later cutoff check. This aligns the two mirror paths without duplicating the exclusion lookup or introducing a separate routing mechanism.

Files changed (5) +107 / -14

Bug fix (2) +32 / -9
pickPackage.tsPass the release-age decision to the cutoff mirror read +6/-3

Pass the release-age decision to the cutoff mirror read

• Threads the shortcut decision's release-age result into the later mirror cutoff check, avoiding another exclusion-policy lookup when that result is known.

pnpm11/resolving/npm-resolver/src/pickPackage.ts

route.tsAlign stable-range shortcut eligibility with release-age exclusions +26/-6

Align stable-range shortcut eligibility with release-age exclusions

• Allows range shortcuts for packages excluded from the release-age cutoff and disables them after offline or prefer-offline mirror reads. Reports the computed release-age result for reuse by the cutoff check while preserving a standalone cutoff API.

pnpm11/resolving/npm-resolver/src/route.ts

Tests (2) +69 / -5
metaCache.test.tsVerify an excluded package resolves from an old mirror +31/-0

Verify an excluded package resolves from an old mirror

• Adds a resolver regression test showing that an excluded package with a dominant lockfile version resolves from backdated cached metadata without fetching from the registry.

pnpm11/resolving/npm-resolver/test/metaCache.test.ts

route.test.tsCover shortcut routing and release-age decision reuse +38/-5

Cover shortcut routing and release-age decision reuse

• Extends route tests for excluded and non-excluded packages, offline modes, and reported release-age decisions. Verifies that the cutoff check accepts an already-computed answer without calling the exclusion policy again.

pnpm11/resolving/npm-resolver/test/route.test.ts

Documentation (1) +6 / -0
release-age-exclude-reuses-mirror.mdDocument cached resolution for release-age exclusions +6/-0

Document cached resolution for release-age exclusions

• Adds patch changesets for pnpm and the npm resolver. Describes when excluded packages can resolve from cached metadata without a registry request.

.changeset/release-age-exclude-reuses-mirror.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Resolver speedup lacks measurements 📜 Skill insight ➹ Performance
Description
The resolver now computes the release-age policy once and passes the result through the mirror
shortcut path, but the PR provides no numeric before-and-after measurement for this claimed hot-path
optimization. The change affects range resolution with release-age settings, so its runtime benefit
and any added overhead are unquantified across the common resolver path.
Code

pnpm11/resolving/npm-resolver/src/route.ts[R61-67]

+  const releaseAgeApplies = isRangePickWithoutFreshMetadataOptions(inputs) ? releaseAgeAppliesTo(inputs) : undefined
+  const stableRange = releaseAgeApplies === false
  return {
    exactVersion: spec.type === 'version' && !opts.includeLatestTag && !opts.updateChecksums,
    dominantLockfileVersion: stableRange,
    unvalidatedMirror: stableRange && opts.refreshMetadata !== true,
+    releaseAgeApplies,
Evidence
The PR description explicitly calls this logic a hot-path change and claims that the policy lookup
occurs at most once, while the supplied diff contains only behavioral tests and no numeric
before/after benchmark results.

pnpm11/resolving/npm-resolver/src/route.ts[61-67]
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 PR describes a hot-path optimization that avoids repeated release-age policy lookups, but supplies no numeric performance evidence.

## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/route.ts[61-67]
- pnpm11/resolving/npm-resolver/src/route.ts[100-104]

## Recommended Fix
Add representative benchmark results with multiple runs and variance for range resolution with and without `minimumReleaseAge`, including realistic package counts and warm and cold metadata-cache cases. Record the before and after timings in the PR or an appropriate benchmark artifact.

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

Dismiss ↗ | View ↗



Informational

2. Cutoff docs omit policy override ✓ Resolved
Description
mirrorWrittenAfter now accepts releaseAgeApplies, but its JSDoc documents only the cutoff and
does not describe the override or its default policy lookup. Callers that pass false suppress the
cutoff even when publishedBy is set, while callers that omit the argument invoke the exclusion
policy, so the function's observable contract is unclear to maintainers.
Code

pnpm11/resolving/npm-resolver/src/route.ts[R100-104]

+export function mirrorWrittenAfter (
+  inputs: RouteInputs,
+  releaseAgeApplies: boolean = releaseAgeAppliesTo(inputs)
+): Date | undefined {
+  return releaseAgeApplies ? inputs.opts.publishedBy : undefined
Relevance

● Weak

Recent resolver precedents rejected expanding JSDoc to enumerate newly added parameter behavior.

PR-#17044
PR-#15324

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The modified function signature adds an optional policy result and changes the function's behavior,
but the adjacent JSDoc does not describe that parameter or the distinction between supplied and
defaulted values. This does not satisfy the contract-focused documentation requirement.

Rule 713430: JSDoc must document function contracts, not re-describe implementation
pnpm11/resolving/npm-resolver/src/route.ts[95-104]

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 modified `mirrorWrittenAfter` function has JSDoc that does not document its new `releaseAgeApplies` parameter, the default policy lookup, or how `true` and `false` affect the returned cutoff.

## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/route.ts[95-104]

## Recommended Fix
Update the JSDoc to describe the `RouteInputs` preconditions, the optional `releaseAgeApplies` override, the default behavior when it is omitted, the `undefined` result when release age does not apply, and the fact that passing the computed value avoids re-evaluating the exclusion policy.

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


Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
✅ Compliance rules (platform): 55 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Behavioral resolver and policy changes affect user-visible resolution and performance.
✅ 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 537203a

Results up to commit 71a363b ⚖️ Balanced


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


Remediation recommended
1. Resolver speedup lacks measurements 📜 Skill insight ➹ Performance
Description
The resolver now computes the release-age policy once and passes the result through the mirror
shortcut path, but the PR provides no numeric before-and-after measurement for this claimed hot-path
optimization. The change affects range resolution with release-age settings, so its runtime benefit
and any added overhead are unquantified across the common resolver path.
Code

pnpm11/resolving/npm-resolver/src/route.ts[R61-67]

+  const releaseAgeApplies = isRangePickWithoutFreshMetadataOptions(inputs) ? releaseAgeAppliesTo(inputs) : undefined
+  const stableRange = releaseAgeApplies === false
  return {
    exactVersion: spec.type === 'version' && !opts.includeLatestTag && !opts.updateChecksums,
    dominantLockfileVersion: stableRange,
    unvalidatedMirror: stableRange && opts.refreshMetadata !== true,
+    releaseAgeApplies,
Evidence
The PR description explicitly calls this logic a hot-path change and claims that the policy lookup
occurs at most once, while the supplied diff contains only behavioral tests and no numeric
before/after benchmark results.

pnpm11/resolving/npm-resolver/src/route.ts[61-67]
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 PR describes a hot-path optimization that avoids repeated release-age policy lookups, but supplies no numeric performance evidence.

## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/route.ts[61-67]
- pnpm11/resolving/npm-resolver/src/route.ts[100-104]

## Recommended Fix
Add representative benchmark results with multiple runs and variance for range resolution with and without `minimumReleaseAge`, including realistic package counts and warm and cold metadata-cache cases. Record the before and after timings in the PR or an appropriate benchmark artifact.

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

Dismiss ↗ | View ↗



Informational
2. Cutoff docs omit policy override ✓ Resolved
Description
mirrorWrittenAfter now accepts releaseAgeApplies, but its JSDoc documents only the cutoff and
does not describe the override or its default policy lookup. Callers that pass false suppress the
cutoff even when publishedBy is set, while callers that omit the argument invoke the exclusion
policy, so the function's observable contract is unclear to maintainers.
Code

pnpm11/resolving/npm-resolver/src/route.ts[R100-104]

+export function mirrorWrittenAfter (
+  inputs: RouteInputs,
+  releaseAgeApplies: boolean = releaseAgeAppliesTo(inputs)
+): Date | undefined {
+  return releaseAgeApplies ? inputs.opts.publishedBy : undefined
Relevance

● Weak

Recent resolver precedents rejected expanding JSDoc to enumerate newly added parameter behavior.

PR-#17044
PR-#15324

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The modified function signature adds an optional policy result and changes the function's behavior,
but the adjacent JSDoc does not describe that parameter or the distinction between supplied and
defaulted values. This does not satisfy the contract-focused documentation requirement.

Rule 713430: JSDoc must document function contracts, not re-describe implementation
pnpm11/resolving/npm-resolver/src/route.ts[95-104]

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 modified `mirrorWrittenAfter` function has JSDoc that does not document its new `releaseAgeApplies` parameter, the default policy lookup, or how `true` and `false` affect the returned cutoff.

## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/route.ts[95-104]

## Recommended Fix
Update the JSDoc to describe the `RouteInputs` preconditions, the optional `releaseAgeApplies` override, the default behavior when it is omitted, the `undefined` result when release age does not apply, and the fact that passing the computed value avoids re-evaluating the exclusion policy.

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

Copilot AI balanced review requested due to automatic review settings October 17, 2026 23:11
@zkochan

zkochan commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Qodo findings:

  1. Resolver speedup lacks measurements. Declined. The PR claims no speedup. Passing releaseAgeApplies through only keeps the new shortcut check from adding a second exclusion lookup to the pick. Before this PR, mirrorWrittenAfter asked the policy once per range pick under minimumReleaseAge. Now decideMirrorShortcuts asks once and mirrorWrittenAfter reuses the answer, so the count is unchanged. A test pins that: takes the answer the shortcuts already have.
  2. Cutoff docs omit policy override. Fixed in 537203a. The doc comment now names the argument and says the policy is asked only when it is undefined.

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

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.

@qodo-code-review

Copy link
Copy Markdown

Qodo findings:

  1. Resolver speedup lacks measurements. Declined. The PR claims no speedup. Passing releaseAgeApplies through only keeps the new shortcut check from adding a second exclusion lookup to the pick. Before this PR, mirrorWrittenAfter asked the policy once per range pick under minimumReleaseAge. Now decideMirrorShortcuts asks once and mirrorWrittenAfter reuses the answer, so the count is unchanged. A test pins that: takes the answer the shortcuts already have.
  2. Cutoff docs omit policy override. Fixed in 537203a. The doc comment now names the argument and says the policy is asked only when it is undefined.

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

Your distinction is valid: finding 1 concerns missing numeric benchmark evidence, not an incorrect claim that the exclusion policy is evaluated twice. The implementation and test support the claim that the policy lookup remains at one evaluation per applicable range pick, but the PR still provides no before/after performance measurements. The finding therefore remains open unless explicitly dismissed.

finding 2 is marked implemented. The documentation fix in 537203a87d addresses the reported contract gap by documenting the override and default policy lookup. The associated rule can be managed here: https://app.qodo.ai/rules/713430?state=active

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 537203a

@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 4636eac into main Oct 17, 2026
38 checks passed
@zkochan
zkochan deleted the fix-v11-route-parity branch October 17, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants