Repository navigation
feat: absorb an override that names a range, not just an exact version - #13792
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe fast-update paths now resolve compatible ChangesRange-aware fast override updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant getFastOverrides
participant overriddenVersion
participant Lockfile
participant PackageResolver
getFastOverrides->>overriddenVersion: resolve override against lockfile
overriddenVersion->>Lockfile: find compatible locked versions
Lockfile-->>overriddenVersion: highest matching version or null
overriddenVersion-->>getFastOverrides: resolved version
getFastOverrides->>PackageResolver: request resolved version
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoFast-update overrides: support semver ranges via highest locked match
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts (1)
161-186: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winResolve each override version once.
Lines 161 and 186 call
overriddenVersion()with the same inputs. Each call scans the lockfile packages and sorts matching versions. Store the result before the condition. Track the highest matching version during the scan.Proposed refactor
+ const newVersion = removesDependency + ? undefined + : overriddenVersion(lockfile, override.targetPkg.name, newValue) if ( override == null || override.targetPkg.bareSpecifier != null || override.converge === true || !removesDependency && ( override.parentPkg != null || - overriddenVersion(lockfile, override.targetPkg.name, newValue) == null || + newVersion == null || oldVersion != null && semver.valid(oldVersion) == null ) || @@ - ...removesDependency + ...newVersion == null ? {} : { - newVersion: overriddenVersion(lockfile, override.targetPkg.name, newValue)!, + newVersion, oldVersion, },Also applies to: 211-220
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts` around lines 161 - 186, Update the override processing flow around overriddenVersion so each override version is resolved once and reused by both validation and result construction. Refactor overriddenVersion to track the highest matching version during its lockfile scan instead of sorting all matches, and apply the same reuse pattern to the later override path noted in the comment.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts`:
- Around line 161-186: Update the override processing flow around
overriddenVersion so each override version is resolved once and reused by both
validation and result construction. Refactor overriddenVersion to track the
highest matching version during its lockfile scan instead of sorting all
matches, and apply the same reuse pattern to the later override path noted in
the comment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 879a85bc-783f-4e37-aa7b-85212c98e5cc
📒 Files selected for processing (6)
.changeset/override-range-fast-update.mdpnpm/crates/package-manager/src/fast_update_importers.rspnpm/crates/package-manager/src/fast_update_overrides.rspnpm/crates/package-manager/src/fast_update_overrides/tests.rspnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.tspnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "fix(package-manager): abort the locked-v..." | Re-trigger Greptile |
Code Review by Qodo
1. getFastOverrides has four parameters
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit d8fd61c |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13792 +/- ##
=======================================
Coverage 88.22% 88.23%
=======================================
Files 624 624
Lines 101741 101752 +11
=======================================
+ Hits 89761 89777 +16
+ Misses 11980 11975 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
An overrides entry whose value is a range bailed to the resolver in both stacks. Resolution settles such a range on whichever version the graph already holds — preferredVersions beats picking the highest published, measured the same way item 4 of the roadmap was — so the rewrite can name that version itself: the highest already-locked one satisfying the range. A range nothing locked satisfies still bails, since only the resolver can fetch a version that is not there. Everything downstream is unchanged: the plan still carries a concrete version, and the existing guards decide whether the rewrite can be expressed — including the pair that refuse to merge onto a key whose recorded snapshot or metadata would not match what the rewrite rebuilds. Parent-scoped overrides stay on the resolver. Those move one edge rather than every edge to a package, so the lockfile would have to hold both versions at once, which this rewrite cannot express. Item 6 of #13696.
The scan skipped a registry-qualified key and kept looking, so an alias holding both a named-registry entry and an ordinary one could still yield an ordinary version, where the TypeScript side refuses the rewrite outright. A registry-qualified semver pins a version only within its own registry, so an alias spanning two of them cannot be named by a plain reference either way; both stacks now decline. The scan is shared with the importers handler, so this closes the same gap for a changed dependency range as for an override. The two helper doc comments lose their branch-by-branch narration and keep the reason a range maps to an already-locked version.
d8fd61c to
1cce600
Compare
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Code review by qodo was updated up to the latest commit 1cce600 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Item 6 of #13696, the range half. Parent-scoped overrides stay on the resolver — see below.
An overrides entry whose value is a range (
"foo": "^1.1.0") bailed in both stacks; only exact versions were rewritten. Measured what resolution does with such a range, the same way item 4 was measured: with[email protected]and[email protected]locked and1.3.0also published, adding the override resolves to 1.2.0 —preferredVersionsmakes the resolver reuse a version the graph already holds rather than the highest published. So the rewrite can name that version itself: the highest already-locked one satisfying the range. A range nothing locked satisfies still bails, since only the resolver can fetch a version that is not there.Everything downstream is untouched — the plan still carries a concrete version, and the existing guards decide whether the rewrite is expressible. Worth noting for review: a range that resolves to an already-locked version necessarily lands on the merge path (its key exists), where two pre-existing guards refuse the rewrite unless the rebuilt snapshot and package metadata equal what the lockfile already records. That is the right conservatism and I have not touched it; it does mean this widening only pays off when the target version's recorded entry agrees with what a resolution would rebuild, which for a registry package it normally does.
Parent-scoped overrides (
parent>child) are deliberately left out. They move a single edge rather than every edge to a package, so the lockfile would have to hold the old and new versions simultaneously and split the dependents between them.build_replacement_planmaps one old key to one new key and cannot express that; supporting it is a different change, not a relaxed guard.Tested at the handler level in both stacks — the layer where these tests already live — asserting which version the range resolves to, that an unsatisfiable range bails before any resolution, and that exact overrides still name the version given. Both stacks break-tested.
Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
pnpm.overridesversion ranges now update the existing lockfile using the highest matching locked version.Bug Fixes
Tests