Skip to content

feat: absorb an override that names a range, not just an exact version - #13792

Merged
zkochan merged 2 commits into
mainfrom
override-forms
Aug 10, 2026
Merged

zkochan merged 2 commits into
mainfrom
override-forms

Conversation

@zkochan

@zkochan zkochan commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

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 and 1.3.0 also published, adding the override resolves to 1.2.0 — preferredVersions makes 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_plan maps 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

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 pnpm/pnpm#13696.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • 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.

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


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

Summary by CodeRabbit

  • New Features

    • Compatible pnpm.overrides version ranges now update the existing lockfile using the highest matching locked version.
    • Exact version overrides and dependency removals continue to work as before.
  • Bug Fixes

    • Incompatible or unsupported override ranges safely fall back without re-resolving dependencies.
    • Ambiguous package aliases across registries are now rejected during fast updates.
  • Tests

    • Added coverage for compatible and incompatible ranges, exact versions, multiple locked versions, and registry-specific aliases.

Copilot AI lite review requested due to automatic review settings August 10, 2026 22:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: aafdec59-7faf-4a3b-b2e6-0e56ea9fff73

📥 Commits

Reviewing files that changed from the base of the PR and between d8fd61c and 1cce600.

📒 Files selected for processing (2)
  • pnpm/crates/package-manager/src/fast_update_importers.rs
  • pnpm/crates/package-manager/src/fast_update_importers/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/package-manager/src/fast_update_importers/tests.rs
  • pnpm/crates/package-manager/src/fast_update_importers.rs

📝 Walkthrough

Walkthrough

The fast-update paths now resolve compatible pnpm.overrides ranges to the highest matching version already in the lockfile. Exact versions remain supported. Ambiguous registry-qualified references are rejected, with Rust and TypeScript test coverage.

Changes

Range-aware fast override updates

Layer / File(s) Summary
Importer key validation
pnpm/crates/package-manager/src/fast_update_importers.rs, pnpm/crates/package-manager/src/fast_update_importers/tests.rs
Importer lookup rejects peer-suffixed and registry-qualified keys. A regression test covers aliases present under multiple registries.
Rust override range resolution
pnpm/crates/package-manager/src/fast_update_overrides.rs, pnpm/crates/package-manager/src/fast_update_overrides/tests.rs
Rust override handling selects exact versions directly or the highest compatible locked version for ranges. Tests cover matching and unmatched ranges.
TypeScript fast-update integration
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts, pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts, .changeset/override-range-fast-update.md
TypeScript override handling resolves targets against the lockfile and stores the selected version. Tests cover matching ranges, unmatched ranges, and exact versions. A patch changeset documents the behavior.

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

Possibly related PRs

  • pnpm/pnpm#13464: Extends fast override-update logic in the same Rust and TypeScript paths.
  • pnpm/pnpm#13477: Adds compatible range resolution to the fast-update override machinery.
  • pnpm/pnpm#13779: Modifies the same locked-version reuse helper used by fast updates.

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

Suggested reviewers: greptile-apps

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
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch override-forms

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

Fast-update overrides: support semver ranges via highest locked match

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Allow fast lockfile rewrites for pnpm.overrides values that are semver ranges.
• Map a range to the highest already-locked version that satisfies it; otherwise fall back.
• Add handler-level tests in both Rust and pnpm11 stacks for range and exact overrides.
Diagram

graph TD
O["pnpm.overrides change"] --> E["Fast update entry"] --> V["Compute overriddenVersion"] --> D{"Locked version satisfies?"}
D -->|"yes"| P["Build rewrite plan"] --> A["Apply fast rewrite"] --> L["Lockfile updated"]
D -->|"no"| R[["Fallback to resolver"]]
subgraph Legend
  direction LR
  _s["Step"] ~~~ _d{"Decision"} ~~~ _f[["Fallback"]]
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Always fall back to resolver for range overrides
  • ➕ Simplest logic; no need to scan/interpret lockfile contents
  • ➕ Avoids any mismatch between fast-path assumptions and resolver behavior
  • ➖ Misses the optimization goal; triggers full resolution even when a suitable locked version exists
  • ➖ Slower for common “range but already locked” scenarios
2. Query registry/metadata to pick highest published satisfying range
  • ➕ More closely matches a naive “highest satisfying” expectation
  • ➕ Works even when no locked version satisfies the range
  • ➖ Requires network/metadata fetches and introduces new failure modes
  • ➖ Still may not match pnpm resolver behavior when preferredVersions influences selection
  • ➖ Expands scope well beyond a fast, local rewrite
3. Teach the replacement plan to represent parent-scoped (`parent>child`) splits
  • ➕ Would unlock fast updates for parent-scoped overrides too
  • ➕ More expressive model for edge-level rewrites
  • ➖ Significant design change: would require representing coexistence of old/new versions and dependent partitioning
  • ➖ Higher risk and complexity than the current targeted enhancement

Recommendation: Keep the current approach: resolve ranges only when a satisfying version is already locked, selecting the highest such version to mirror resolver behavior under preferredVersions. This maintains a deterministic, offline fast-path and correctly bails when expressing the rewrite would require fetching or more complex edge-splitting (notably parent-scoped overrides).

Files changed (6) +248 / -6

Enhancement (2) +64 / -5
fast_update_overrides.rsSupport range-valued overrides by mapping to a locked version +25/-2

Support range-valued overrides by mapping to a locked version

• Introduces 'overridden_version' to interpret override values as either exact versions or semver ranges. For ranges, it selects the highest already-locked version satisfying the range and bails when none match, keeping downstream rewrite planning unchanged.

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

tryFastUpdateOverrides.tsCompute concrete override version for ranges in pnpm11 fast path +39/-3

Compute concrete override version for ranges in pnpm11 fast path

• Extends fast override detection to accept semver ranges by computing the target version from existing lockfile packages. Refuses the fast path when the range matches nothing locked or when ambiguous peer/registry-qualified entries would require guessing.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts

Refactor (1) +1 / -1
fast_update_importers.rsExpose locked-version selection helper for reuse +1/-1

Expose locked-version selection helper for reuse

• Changes 'highest_locked_version_satisfying' visibility to 'pub(crate)' so other fast-update modules can reuse the same logic for determining a concrete version from a range.

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

Tests (2) +176 / -0
tests.rsAdd Rust tests for range override selection and bailout +95/-0

Add Rust tests for range override selection and bailout

• Adds fixtures and tests to confirm a range override resolves to the highest satisfying locked version, and that an unsatisfiable range returns 'None' without calling the resolver.

pnpm/crates/package-manager/src/fast_update_overrides/tests.rs

overrideRangeFastUpdate.tsAdd pnpm11 tests for range overrides resolving to locked versions +81/-0

Add pnpm11 tests for range overrides resolving to locked versions

• Adds Jest tests to assert the version requested during resolution for a range override matches the highest satisfying locked version, that unsatisfiable ranges bail before any resolution, and that exact overrides still behave unchanged.

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

Documentation (1) +7 / -0
override-range-fast-update.mdAdd changeset for range override fast-update behavior +7/-0

Add changeset for range override fast-update behavior

• Documents that semver range overrides can now be applied via in-place lockfile updates when a matching locked version exists, instead of forcing a full dependency re-resolution.

.changeset/override-range-fast-update.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts (1)

161-186: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Resolve 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

📥 Commits

Reviewing files that changed from the base of the PR and between d0ed0dd and bb0d95f.

📒 Files selected for processing (6)
  • .changeset/override-range-fast-update.md
  • pnpm/crates/package-manager/src/fast_update_importers.rs
  • pnpm/crates/package-manager/src/fast_update_overrides.rs
  • pnpm/crates/package-manager/src/fast_update_overrides/tests.rs
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts
  • pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts

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

greptile-apps Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "fix(package-manager): abort the locked-v..." | Re-trigger Greptile

@qodo-code-review

qodo-code-review Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (5) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. getFastOverrides has four parameters 📘 Rule violation ⚙ Maintainability ⭐ New
Description
getFastOverrides() was modified to take 4 positional parameters, exceeding the 3-parameter limit
required for TypeScript functions. This increases call-site complexity and makes future changes
harder to maintain.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R136-139]

+  lockfile: LockfileObject,
  oldOverrides: Record<string, string>,
  newOverrides: Record<string, string>,
  parsedOverrides: VersionOverride[]
Relevance

●●● Strong

Same file previously accepted refactor: 4 params → options object to meet 3-parameter limit.

PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713433 limits TypeScript functions to three parameters or fewer. The updated
getFastOverrides() signature includes lockfile, oldOverrides, newOverrides, and
parsedOverrides (4 parameters).

Rule 713433: Limit TypeScript functions to three parameters or fewer
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[135-140]

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

## Issue description
`getFastOverrides()` now takes 4 positional parameters, which violates the 3-parameter limit requirement.

## Issue Context
This is a modified TypeScript function in the fast update path; prefer a single options object (or otherwise reduce parameter count) to keep call sites clear and extensible.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[135-140]

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


2. Wrong preferredVersions rationale 🐞 Bug ⚙ Maintainability
Description
New comments claim the range-to-version decision is caused by preferredVersions, but both
implementations choose the version by scanning the lockfile directly (and the TS fast path even
invokes resolution with an empty preferredVersions). This misdocuments the mechanism and can
mislead future maintainers—especially since preferredVersions can be policy-driven (e.g.
vulnerability audit) in other install flows.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R197-199]

+ * A range names the highest already-locked version satisfying it, because
+ * `preferredVersions` makes the resolver reuse a version the graph already
+ * holds rather than the highest published.
Relevance

●●● Strong

Team commonly accepts fixes that make docs/comments match actual behavior; misleading rationale
likely corrected.

PR-#12292

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The TS comment claims preferredVersions drives reuse, but the TS implementation selects from
lockfile.packages and later resolves with an empty preferredVersions, showing the comment’s
mechanism claim is inaccurate; the Rust comment similarly cites preferredVersions although the
helper only consults the lockfile.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[194-218]
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[312-327]
pnpm/crates/package-manager/src/fast_update_overrides.rs[174-189]
pnpm11/installing/commands/src/installDeps.ts[296-306]

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 doc comments for `overriddenVersion` (TS) and `overridden_version` (Rust) attribute the range→version mapping to `preferredVersions`. However, the actual implementation selects the version by scanning the lockfile and does not consult `preferredVersions` at all; additionally, the TS fast-update resolution call uses an empty `preferredVersions` object.

This is misleading documentation that can cause incorrect assumptions when modifying resolver behavior or policy-driven version selection.

### Issue Context
- TS `overriddenVersion()` selects the highest satisfying version from `lockfile.packages`.
- TS `resolveNewManifests()` calls `requestPackage` with `preferredVersions: Object.create(null)`.
- Rust `overridden_version()` delegates to `highest_locked_version_satisfying()` with only lockfile/name/range.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[194-200]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[312-327]
- pnpm/crates/package-manager/src/fast_update_overrides.rs[174-188]

### Suggested change
Update the comments to describe the actual mechanism, e.g. “We pick the highest version already present in the lockfile that satisfies the range,” and avoid citing `preferredVersions` as the direct cause unless you also thread and use it explicitly (and document the exact conditions under which it affects selection).

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


3. pre-existing machinery comment 📘 Rule violation ⚙ Maintainability
Description
A newly added comment references historical implementation state (pre-existing machinery) instead
of describing current behavior. This makes the comment stale-prone and violates the guideline to
avoid historical phrasing in code comments.
Code

pnpm/crates/package-manager/src/fast_update_overrides/tests.rs[R536-538]

+/// Records the version each resolution asks for. The rewrite that follows
+/// is the pre-existing machinery; what this pins is the version the range
+/// maps to.
Relevance

●●● Strong

Team has accepted rewriting comments to avoid historical/"used to" phrasing and reduce drift-prone
narration.

PR-#13383

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 772199 forbids historical phrasing in comments. The added doc comment explicitly references
historical context (pre-existing machinery) rather than stating the current behavior being tested.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/fast_update_overrides/tests.rs[536-538]

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 comment uses historical phrasing (`pre-existing machinery`) rather than describing current behavior/intent.

## Issue Context
Comments should explain the current code contract/intent without referring to earlier implementations.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_overrides/tests.rs[536-538]

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


View review recommended (1)
4. Duplicate range version scans 🐞 Bug ➹ Performance
Description
For eligible range overrides, getFastOverrides() calls overriddenVersion() twice for the same
(name,value), causing two full traversals of lockfile.packages and repeated semver checks. On large
lockfiles this adds avoidable work to a hot lockfile-handling fast path and can become a CPU/latency
regression when multiple overrides change.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R186-189]

+          newVersion: overriddenVersion(lockfile, override.targetPkg.name, newValue)!,
+          oldVersion,
+        },
    })
Relevance

●● Moderate

Perf concern seems reasonable, but similar “avoid repeated scans” optimizations in fast-path code
were previously rejected as premature.

PR-#13600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The diff shows overriddenVersion() is invoked in the eligibility guard and then invoked again to
populate newVersion, meaning the lockfile scan/sort work happens twice for the same override when
the value is a range. REVIEW_GUIDE flags lockfile handling as a hot path where repeated scans should
be avoided.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[155-189]
REVIEW_GUIDE.md[115-127]

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

### Issue description
`getFastOverrides()` computes `overriddenVersion(lockfile, name, newValue)` more than once for the same override (once in the eligibility check and again while building the `FastOverride`). For range values, this re-scans the full `lockfile.packages` map twice.

### Issue Context
This PR broadens the fast-update eligibility to ranges, so the range->concrete-version mapping can now run in common override edits.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[150-190]

### Suggested fix
- Compute `const resolved = removesDependency ? null : overriddenVersion(lockfile, override.targetPkg.name, newValue)` once per selector.
- Use `resolved` in both the guard (`resolved == null`) and the pushed object (`newVersion: resolved`).
- (Optional) If multiple selectors could share the same `(name,value)`, add a small memoization map keyed by `${name}\0${value}`.

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



Informational

5. Missing trailing comma parameters 📘 Rule violation ⚙ Maintainability ⭐ New
Description
Multi-line TypeScript function parameter lists were added/modified without trailing commas on the
last parameter. This breaks the required trailing-comma style and creates noisier diffs on future
edits.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R202-205]

+  lockfile: LockfileObject,
+  name: string,
+  value: string
+): string | null {
Relevance

● Weak

Direct precedent: trailing-comma rule suggestion for getFastOverrides params in this file was
rejected.

PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas for multi-line TypeScript parameter lists. Both
getFastOverrides(...) and overriddenVersion(...) are multi-line signatures where the last
parameter line does not end with a comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[135-140]
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[201-205]

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

## Issue description
Multi-line function signatures are missing trailing commas for the last parameter.

## Issue Context
The repo requires trailing commas in multi-line TypeScript constructs to reduce diff churn.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[135-140]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[201-205]

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


6. overriddenVersion() JSDoc lacks contract 📘 Rule violation ⚙ Maintainability
Description
The new/edited JSDoc describes resolver rationale but omits key contract details (return value
guarantees and null/edge-case behavior), making the function easy to misuse and the comment
stale-prone. This violates the requirement that JSDoc document preconditions/postconditions and edge
cases rather than narrate implementation details.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R197-199]

+ * A range names the highest already-locked version satisfying it, because
+ * `preferredVersions` makes the resolver reuse a version the graph already
+ * holds rather than the highest published.
Relevance

● Weak

Similar “expand JSDoc contract vs rationale” suggestions were rejected; team avoids contract-heavy
docs to reduce drift.

PR-#13133
PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713430 requires new/modified JSDoc to document the function contract
(preconditions, postconditions, and edge cases). The edited JSDoc lines describe internal rationale
about preferredVersions but do not state the key behavioral guarantees and null cases that
callers must rely on.

Rule 713430: JSDoc must document function contracts, not re-describe implementation
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[194-205]

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

## Issue description
`overriddenVersion()` has JSDoc that explains *why* the range picks a locked version, but it doesn't clearly document the function contract (what it returns, when it returns `null`, and what inputs are accepted).

## Issue Context
This helper is part of a fast-path lockfile rewrite and is easy to call incorrectly unless the JSDoc spells out its preconditions (valid semver/range), postconditions (returns a concrete version string), and edge cases (e.g., registry-qualified/peer-suffixed locked entries cause a bail, no locked version satisfies returns `null`).

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[197-199]

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


7. Range selection sorts unnecessarily 🐞 Bug ➹ Performance
Description
overriddenVersion() collects all satisfying versions into an array, sorts it, and also re-parses
depPath even though nameVerFromPkgSnapshot already parsed it. This adds avoidable O(V log V) time
and extra parsing/allocations when selecting the max satisfying locked version.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R212-220]

+  for (const [depPath, snapshot] of Object.entries(lockfile.packages ?? {})) {
+    const parsed = nameVerFromPkgSnapshot(depPath, snapshot)
+    if (parsed.name !== name || parsed.nonSemverVersion != null) continue
+    if (parsed.registryName != null || dp.parseDepPath(depPath).peerDepGraphHash !== '') return null
+    if (semver.valid(parsed.version) != null && semver.satisfies(parsed.version, value)) {
+      versions.push(parsed.version)
+    }
+  }
+  return versions.sort(semver.rcompare)[0] ?? null
Relevance

● Weak

Very similar micro-optimization (avoid Set/sort and extra depPath parse in loop) was explicitly
rejected previously.

PR-#13779

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new helper builds an array of versions and sorts it to pick the highest, and it calls
dp.parseDepPath() inside the loop. nameVerFromPkgSnapshot() already parses depPath via
dp.parse() and returns peerDepGraphHash, so the extra parse is redundant and the sort is
unnecessary for a max selection.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[204-221]
pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[14-25]

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

### Issue description
`overriddenVersion()` currently:
- pushes every satisfying version into an array,
- sorts the array to pick the maximum,
- and calls `dp.parseDepPath(depPath)` even though `nameVerFromPkgSnapshot()` already parses `depPath` and exposes `peerDepGraphHash`.

This is more work than needed; selecting the maximum can be done in one pass with O(1) extra space.

### Issue Context
This helper runs on the fast-update path for override edits (now including ranges), so it should minimize full-lockfile work.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[204-221]
- pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[14-25]

### Suggested fix
- Replace the `versions: string[]` + `sort()` with a single `let best: string | null = null` and update it when a candidate satisfies.
- Replace `dp.parseDepPath(depPath).peerDepGraphHash !== ''` with a check against the already-parsed `parsed.peerDepGraphHash`.
- Keep the existing conservative fallback when encountering registry-qualified entries or peer-suffixed variants.

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


View optional (1)
8. makeLockfile declared before use 📘 Rule violation ⚙ Maintainability
Description
In overrideRangeFastUpdate.ts, helper function declarations appear before any in-file usage,
violating the required declaration-after-first-usage ordering. This reduces consistency with the
codebase’s hoisting-based style guideline.
Code

pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[16]

+function makeLockfile (): LockfileObject {
Relevance

● Weak

Same “declare helper functions after first usage” ordering request in deps-installer tests was
rejected before.

PR-#13689

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 713432 requires top-level function declarations to appear after at least one usage in the same
file. makeLockfile() is declared at line 16 but first used later at line 58, so the declaration
precedes its first usage.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[16-16]
pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[58-58]

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 TypeScript test file declares top-level helper functions before their first usage in the same file, which violates the project rule that such functions should be declared only after first use.

## Issue Context
This rule relies on function hoisting and is enforced for consistency across TS/TSX files.

## Fix Focus Areas
- pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[16-53]
- pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[55-80]

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


Grey Divider

Context used
✅ Compliance rules (platform): 26 rules

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous review results

Review updated until commit 1cce600 ⚖️ Balanced

Results up to commit bb0d95f ⚖️ Balanced


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


Remediation recommended
1. pre-existing machinery comment 📘 Rule violation ⚙ Maintainability
Description
A newly added comment references historical implementation state (pre-existing machinery) instead
of describing current behavior. This makes the comment stale-prone and violates the guideline to
avoid historical phrasing in code comments.
Code

pnpm/crates/package-manager/src/fast_update_overrides/tests.rs[R536-538]

+/// Records the version each resolution asks for. The rewrite that follows
+/// is the pre-existing machinery; what this pins is the version the range
+/// maps to.
Relevance

●●● Strong

Team has accepted rewriting comments to avoid historical/"used to" phrasing and reduce drift-prone
narration.

PR-#13383

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 772199 forbids historical phrasing in comments. The added doc comment explicitly references
historical context (pre-existing machinery) rather than stating the current behavior being tested.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/fast_update_overrides/tests.rs[536-538]

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 comment uses historical phrasing (`pre-existing machinery`) rather than describing current behavior/intent.

## Issue Context
Comments should explain the current code contract/intent without referring to earlier implementations.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_overrides/tests.rs[536-538]

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


2. Duplicate range version scans 🐞 Bug ➹ Performance
Description
For eligible range overrides, getFastOverrides() calls overriddenVersion() twice for the same
(name,value), causing two full traversals of lockfile.packages and repeated semver checks. On large
lockfiles this adds avoidable work to a hot lockfile-handling fast path and can become a CPU/latency
regression when multiple overrides change.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R186-189]

+          newVersion: overriddenVersion(lockfile, override.targetPkg.name, newValue)!,
+          oldVersion,
+        },
    })
Relevance

●● Moderate

Perf concern seems reasonable, but similar “avoid repeated scans” optimizations in fast-path code
were previously rejected as premature.

PR-#13600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The diff shows overriddenVersion() is invoked in the eligibility guard and then invoked again to
populate newVersion, meaning the lockfile scan/sort work happens twice for the same override when
the value is a range. REVIEW_GUIDE flags lockfile handling as a hot path where repeated scans should
be avoided.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[155-189]
REVIEW_GUIDE.md[115-127]

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

### Issue description
`getFastOverrides()` computes `overriddenVersion(lockfile, name, newValue)` more than once for the same override (once in the eligibility check and again while building the `FastOverride`). For range values, this re-scans the full `lockfile.packages` map twice.

### Issue Context
This PR broadens the fast-update eligibility to ranges, so the range->concrete-version mapping can now run in common override edits.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[150-190]

### Suggested fix
- Compute `const resolved = removesDependency ? null : overriddenVersion(lockfile, override.targetPkg.name, newValue)` once per selector.
- Use `resolved` in both the guard (`resolved == null`) and the pushed object (`newVersion: resolved`).
- (Optional) If multiple selectors could share the same `(name,value)`, add a small memoization map keyed by `${name}\0${value}`.

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



Informational
3. makeLockfile declared before use 📘 Rule violation ⚙ Maintainability
Description
In overrideRangeFastUpdate.ts, helper function declarations appear before any in-file usage,
violating the required declaration-after-first-usage ordering. This reduces consistency with the
codebase’s hoisting-based style guideline.
Code

pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[16]

+function makeLockfile (): LockfileObject {
Relevance

● Weak

Same “declare helper functions after first usage” ordering request in deps-installer tests was
rejected before.

PR-#13689

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 713432 requires top-level function declarations to appear after at least one usage in the same
file. makeLockfile() is declared at line 16 but first used later at line 58, so the declaration
precedes its first usage.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[16-16]
pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[58-58]

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 TypeScript test file declares top-level helper functions before their first usage in the same file, which violates the project rule that such functions should be declared only after first use.

## Issue Context
This rule relies on function hoisting and is enforced for consistency across TS/TSX files.

## Fix Focus Areas
- pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[16-53]
- pnpm11/installing/deps-installer/test/install/overrideRangeFastUpdate.ts[55-80]

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


4. Range selection sorts unnecessarily 🐞 Bug ➹ Performance
Description
overriddenVersion() collects all satisfying versions into an array, sorts it, and also re-parses
depPath even though nameVerFromPkgSnapshot already parsed it. This adds avoidable O(V log V) time
and extra parsing/allocations when selecting the max satisfying locked version.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R212-220]

+  for (const [depPath, snapshot] of Object.entries(lockfile.packages ?? {})) {
+    const parsed = nameVerFromPkgSnapshot(depPath, snapshot)
+    if (parsed.name !== name || parsed.nonSemverVersion != null) continue
+    if (parsed.registryName != null || dp.parseDepPath(depPath).peerDepGraphHash !== '') return null
+    if (semver.valid(parsed.version) != null && semver.satisfies(parsed.version, value)) {
+      versions.push(parsed.version)
+    }
+  }
+  return versions.sort(semver.rcompare)[0] ?? null
Relevance

● Weak

Very similar micro-optimization (avoid Set/sort and extra depPath parse in loop) was explicitly
rejected previously.

PR-#13779

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new helper builds an array of versions and sorts it to pick the highest, and it calls
dp.parseDepPath() inside the loop. nameVerFromPkgSnapshot() already parses depPath via
dp.parse() and returns peerDepGraphHash, so the extra parse is redundant and the sort is
unnecessary for a max selection.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[204-221]
pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[14-25]

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

### Issue description
`overriddenVersion()` currently:
- pushes every satisfying version into an array,
- sorts the array to pick the maximum,
- and calls `dp.parseDepPath(depPath)` even though `nameVerFromPkgSnapshot()` already parses `depPath` and exposes `peerDepGraphHash`.

This is more work than needed; selecting the maximum can be done in one pass with O(1) extra space.

### Issue Context
This helper runs on the fast-update path for override edits (now including ranges), so it should minimize full-lockfile work.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[204-221]
- pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[14-25]

### Suggested fix
- Replace the `versions: string[]` + `sort()` with a single `let best: string | null = null` and update it when a candidate satisfies.
- Replace `dp.parseDepPath(depPath).peerDepGraphHash !== ''` with a check against the already-parsed `parsed.peerDepGraphHash`.
- Keep the existing conservative fallback when encountering registry-qualified entries or peer-suffixed variants.

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


Results up to commit d8fd61c ⚖️ Balanced


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


Remediation recommended
1. Wrong preferredVersions rationale 🐞 Bug ⚙ Maintainability
Description
New comments claim the range-to-version decision is caused by preferredVersions, but both
implementations choose the version by scanning the lockfile directly (and the TS fast path even
invokes resolution with an empty preferredVersions). This misdocuments the mechanism and can
mislead future maintainers—especially since preferredVersions can be policy-driven (e.g.
vulnerability audit) in other install flows.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R197-199]

+ * A range names the highest already-locked version satisfying it, because
+ * `preferredVersions` makes the resolver reuse a version the graph already
+ * holds rather than the highest published.
Relevance

●●● Strong

Team commonly accepts fixes that make docs/comments match actual behavior; misleading rationale
likely corrected.

PR-#12292

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The TS comment claims preferredVersions drives reuse, but the TS implementation selects from
lockfile.packages and later resolves with an empty preferredVersions, showing the comment’s
mechanism claim is inaccurate; the Rust comment similarly cites preferredVersions although the
helper only consults the lockfile.

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[194-218]
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[312-327]
pnpm/crates/package-manager/src/fast_update_overrides.rs[174-189]
pnpm11/installing/commands/src/installDeps.ts[296-306]

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 doc comments for `overriddenVersion` (TS) and `overridden_version` (Rust) attribute the range→version mapping to `preferredVersions`. However, the actual implementation selects the version by scanning the lockfile and does not consult `preferredVersions` at all; additionally, the TS fast-update resolution call uses an empty `preferredVersions` object.

This is misleading documentation that can cause incorrect assumptions when modifying resolver behavior or policy-driven version selection.

### Issue Context
- TS `overriddenVersion()` selects the highest satisfying version from `lockfile.packages`.
- TS `resolveNewManifests()` calls `requestPackage` with `preferredVersions: Object.create(null)`.
- Rust `overridden_version()` delegates to `highest_locked_version_satisfying()` with only lockfile/name/range.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[194-200]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[312-327]
- pnpm/crates/package-manager/src/fast_update_overrides.rs[174-188]

### Suggested change
Update the comments to describe the actual mechanism, e.g. “We pick the highest version already present in the lockfile that satisfies the range,” and avoid citing `preferredVersions` as the direct cause unless you also thread and use it explicitly (and document the exact conditions under which it affects selection).

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



Informational
2. overriddenVersion() JSDoc lacks contract 📘 Rule violation ⚙ Maintainability
Description
The new/edited JSDoc describes resolver rationale but omits key contract details (return value
guarantees and null/edge-case behavior), making the function easy to misuse and the comment
stale-prone. This violates the requirement that JSDoc document preconditions/postconditions and edge
cases rather than narrate implementation details.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[R197-199]

+ * A range names the highest already-locked version satisfying it, because
+ * `preferredVersions` makes the resolver reuse a version the graph already
+ * holds rather than the highest published.
Relevance

● Weak

Similar “expand JSDoc contract vs rationale” suggestions were rejected; team avoids contract-heavy
docs to reduce drift.

PR-#13133
PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713430 requires new/modified JSDoc to document the function contract
(preconditions, postconditions, and edge cases). The edited JSDoc lines describe internal rationale
about preferredVersions but do not state the key behavioral guarantees and null cases that
callers must rely on.

Rule 713430: JSDoc must document function contracts, not re-describe implementation
pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[194-205]

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

## Issue description
`overriddenVersion()` has JSDoc that explains *why* the range picks a locked version, but it doesn't clearly document the function contract (what it returns, when it returns `null`, and what inputs are accepted).

## Issue Context
This helper is part of a fast-path lockfile rewrite and is easy to call incorrectly unless the JSDoc spells out its preconditions (valid semver/range), postconditions (returns a concrete version string), and edge cases (e.g., registry-qualified/peer-suffixed locked entries cause a bail, no locked version satisfies returns `null`).

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateOverrides.ts[197-199]

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


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 commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.52     20.1±3.59ms    18.7 MB/sec    1.00     13.2±0.21ms    28.4 MB/sec
packument/parse                                  1.13     54.2±7.03µs  1222.8 MB/sec    1.00     47.9±2.30µs  1384.0 MB/sec
tarball/download_dependency                      1.50      6.0±0.75ms   728.8 KB/sec    1.00      4.0±0.80ms  1096.5 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.26   316.6±10.48ms 50.5 KElem/sec    1.00   250.8±17.32ms 63.8 KElem/sec
workspace_resolution/hoist_heavy                 1.74   444.3±14.26ms        ? ?/sec    1.00    255.9±3.01ms        ? ?/sec

Copilot AI review requested due to automatic review settings August 10, 2026 22:33

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[bot]
greptile-apps Bot previously approved these changes Aug 10, 2026
@qodo-code-review

Copy link
Copy Markdown

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

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

@codecov-commenter

codecov-commenter commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.23%. Comparing base (b11f8f8) to head (1cce600).

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

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.
Copilot AI review requested due to automatic review settings August 10, 2026 22:52
@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 22:52

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

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

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

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants