Skip to content

perf: let pnpm add skip resolution for an already-locked version - #13807

Merged
zkochan merged 2 commits into
mainfrom
fix-13798
Aug 11, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-13798

Conversation

@zkochan

@zkochan zkochan commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #13798.

pnpm remove skips resolution when the lockfile already proves the outcome (#13698, #13712). Its twin did not: pnpm add <pkg>@<version> re-resolved the whole graph even when the requested version was one the lockfile already held — the common case of promoting a transitive dependency to a direct one, or adding to a second workspace package what a first one already depends on. Reproducing the issue's measurement, add @pnpm.e2e/[email protected] onto a project that locks that exact version transitively requested three packages, including the unrelated @pnpm.e2e/pkg-with-1-dep. It now requests none.

Which version the new edge gets is the rule #13779 established and measured: resolution reuses the already-locked version it would dedupe onto rather than fetching a higher one, because preferredVersions biases it toward what the graph already holds. Confirmed rather than assumed, as every item of #13696 asks: two tests run the same pnpm add through the fast path and through forceFullResolution and compare both the written lockfile and the written manifest.

Where it plugs in. #13803 taught the importers handler to write a whole new project's entry from locked versions; this adds the neighbouring case — a new alias inside an importer that already records others — and reuses that change's guards rather than restating them. So a range several locked versions satisfy under resolutionMode: time-based or lowest-direct keeps the resolver (those pick the low end, and only for a run that leaves the manifest alone), and so does a plain range on a workspace project's name, which linkWorkspacePackages may turn into a link. One guard is new: a lockfile carrying time declines, because time records a publish date per direct dependency and is only pruned on save, never extended, so a package promoted into that position would be missing the date a resolution records.

The manifest edit cannot be applied in place the way uninstallSome's is. The resolution path reads the project manifest to tell a new dependency from a re-added one (isNew, which decides whether resolution may reuse a locked subtree) and reads it again to pick the range style it saves (prevSpecifier). So tryAddLockedVersions stages the edit on copies, hands those to the fast update and to its freshness gates, and the context takes them only once the rewrite commits. A fallback to resolution therefore still sees exactly the manifests on disk. The same staging is what tryFrozenInstall is gated on: without a committed edit it must not take the frozen-like install, or pnpm add would leave the requested dependency uninstalled.

The range the manifest saves has to be the one the resolver would have written, or the next frozen install rejects the importer entry. That is the npm resolver's calcRange, extracted as calcVersionRange into @pnpm/pkg-manifest.utils (which already owns versionWithRangeSpecStyle) along with the inferRangeSpecStyle it needs; the resolver keeps calling it. pnpm add foo@^1.0.0 against a locked 1.2.0 therefore saves ^1.2.0, not ^1.0.0 — matching what a resolution writes, as the byte-identity test asserts.

The narrow cut is a plain registry specifier, as the issue proposed. A satisfying locked version is necessary but not sufficient; everything else keeps the resolver: a dist tag or a bare name (which means latest), an npm: alias, workspace:/catalog:/git/tarball, --save-peer, --save-catalog / a catalogMode other than manual, a package an override names (the override rewrites both what resolves and the range saved for it), a peer-only manifest entry, and a version nothing in the lockfile satisfies.

pacquet needed almost nothing, because pacquet add already pins the manifest before the install runs (prepare_manifest): may_fast_update_lockfile admits InstallSome, and add stops forcing preferFrozenLockfile off. pacquet update is also InstallSome and keeps its explicit Some(false), so it is unaffected. One difference remains and is not a behavior difference: pacquet's manifest pin still fetches the packument to resolve the selector, so only the install-side resolution is skipped there.

Squash Commit Body

pnpm remove already skips resolution when the lockfile proves the
outcome; its twin did not. `pnpm add <pkg>@<version>` re-resolved the
whole graph even when the requested version was one the lockfile
already held — promoting a transitive dependency to a direct one, or
adding to a second workspace package what a first one already depends
on.

The rule is the one pnpm/pnpm#13779 established: resolution reuses the
already-locked version it would dedupe onto rather than fetching a
higher one, because preferredVersions biases it toward what the graph
already holds. The importers handler now records a brand-new importer
edge at that version, under the group the manifest declares, alongside
the whole-new-project entry pnpm/pnpm#13803 added. It reuses that
change's guards: a range several locked versions satisfy under
`resolutionMode: time-based` or `lowest-direct` keeps the resolver,
since those pick the low end and only for a run that leaves the
manifest alone, and so does a plain range on a workspace project's
name, which may resolve to a link instead. A lockfile carrying `time`
keeps it too: `time` records a publish date per direct dependency and
is only pruned on save, never extended, so a package promoted into
that position would be missing the one a resolution records.

`installSome` cannot edit the manifests in place the way
`uninstallSome` does — the resolution path reads them to tell a new
dependency from a re-added one, and reads them again to pick the range
style it saves — so the edit is staged on copies, handed to the fast
update and its freshness gates, and the context takes it only once the
rewrite commits. The range a selector saves is computed with the
resolver's own rule, extracted as `calcVersionRange` in
`@pnpm/pkg-manifest.utils` alongside the `inferRangeSpecStyle` it needs.

pacquet needed only the gate: `add` already pins the manifest before
the install runs, so `may_fast_update_lockfile` admits `InstallSome`
and `add` stops forcing `preferFrozenLockfile` off. `update` is also
`InstallSome` and keeps its explicit opt-out, so it is unaffected. Its
manifest pin still consults the registry packument; only the
install-side resolution is skipped.

The narrow cut is a plain registry specifier. A dist tag, an alias, a
`workspace:`/`catalog:`/git/tarball specifier, `--save-peer`, a
`catalogMode` other than `manual`, an overridden package, and a version
nothing locked satisfies all keep the resolver.

Closes pnpm/pnpm#13798.

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

Summary by CodeRabbit

  • New Features

    • pnpm add can now reuse compatible versions already recorded in the lockfile, avoiding unnecessary package resolution.
    • Added support for fast lockfile updates when adding eligible dependencies, including workspace scenarios.
    • Dependency range formatting is now preserved or inferred more consistently.
  • Bug Fixes

    • Improved handling of optional dependencies, resolution modes, ambiguous versions, and frozen lockfile updates.
    • Unsupported requests continue to use full dependency resolution.

Copilot AI lite review requested due to automatic review settings August 11, 2026 02:49

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 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

pnpm add can reuse compatible versions already present in the lockfile. The TypeScript and Rust package-manager paths now stage manifest changes, update importer entries, preserve resolution-mode rules, and fall back to resolution for unsupported or unsatisfied requests.

Changes

Locked add fast path

Layer / File(s) Summary
Range and manifest contracts
pnpm11/pkg-manifest/utils/*, pnpm11/resolving/npm-resolver/*, pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts, .changeset/add-command-fast-path.md
Centralizes range-style inference and version-range calculation. Exports manifest mutation helpers and updates resolver imports.
TypeScript manifest staging and commit
pnpm11/installing/deps-installer/src/install/index.ts, pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts, pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts
Stages compatible lockfile-backed additions for installSome, validates fast-update freshness, and commits manifest changes after a successful rewrite.
TypeScript importer and graph updates
pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts
Adds importer edges from compatible locked versions, applies resolution-mode-aware selection, and updates optional flags.
Rust fast update path
pnpm/crates/package-manager/src/*, pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs
Allows add mutations in the fast path, adds compatible importer edges, rejects unsupported or ambiguous matches, and tests reuse versus resolution fallback.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant AddCommand
  participant FastUpdate
  participant Lockfile
  participant Resolver
  User->>AddCommand: pnpm add dependency
  AddCommand->>FastUpdate: stage manifest addition
  FastUpdate->>Lockfile: find compatible locked version
  alt compatible version exists
    Lockfile-->>FastUpdate: locked version and package metadata
    FastUpdate-->>AddCommand: updated manifest and importer
  else no compatible version
    FastUpdate->>Resolver: resolve requested selector
    Resolver-->>AddCommand: resolved dependency graph
  end
Loading

Assessment against linked issues

Objective Addressed Explanation
Reuse the highest satisfying locked version for eligible pnpm add requests [#13798] ✅
Fall back to resolution when no locked version satisfies the request [#13798] ✅
Support manifest and importer updates across TypeScript and Rust paths [#13798] ✅
Reject unsupported selectors and special dependency modes [#13798] ✅

Possibly related issues

  • #13696 — Covers the same fast-path implementation for compatible lockfile versions and installSome mutations.

Possibly related PRs

  • pnpm/pnpm#13779 — Establishes compatible locked-version selection and resolution-mode behavior reused by this change.
  • pnpm/pnpm#13766 — Provides the fast-update installation flow extended here for dependency additions.
  • pnpm/pnpm#13712 — Implements related manifest and lockfile mutation staging.

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

Suggested reviewers: qodo-code-review

✨ 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 fix-13798

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

perf: skip pnpm add resolution when requested version is already locked

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Reuse already-locked versions for pnpm add when the lockfile proves the outcome.
• Stage installSome manifest edits for fast updates; commit only after rewrite succeeds.
• Add parity tests to ensure fast-path output matches full resolution output.
Diagram

graph TD
A["pnpm add"] --> B["deps-installer mutateModules"] --> C{"Lockfile-only add?"}
B --> G["pkg-manifest.utils calcVersionRange"]
C -->|"yes"| D["Fast update importers"] --> E[("pnpm-lock.yaml")]
C -->|"no"| F["Full resolver"] --> E
subgraph Legend
  direction LR
  _svc["Component"] ~~~ _dec{"Decision"} ~~~ _db[("Lockfile")]
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Targeted single-package resolution (instead of full graph)
  • ➕ Could cover more selector types (dist-tags, aliases) without full re-resolution
  • ➕ Keeps correctness by consulting resolver policy where needed
  • ➖ Introduces a new “partial resolution” mode with extra complexity and caching semantics
  • ➖ May still require registry calls, reducing performance gains
2. Always run resolver but avoid fetching when lockfile satisfies
  • ➕ Single pipeline; less chance of fast/slow divergence
  • ➕ No need for additional lockfile-only correctness gates
  • ➖ Still pays resolver/graph-building cost, which is the main regression being fixed
  • ➖ Harder to guarantee zero package requests in the promotion-to-direct scenario
3. Broaden lockfile-only add to more specifier forms
  • ➕ More cases benefit from fast path
  • ➕ Less work for common workspace scenarios
  • ➖ Dist-tags, aliases, workspace protocols, catalogs, and overrides require policy/lookup not derivable from lockfile alone
  • ➖ Higher risk of mismatches vs full resolution

Recommendation: Keep the current narrow fast path (plain registry semver selector satisfied by an already-locked version) with explicit fallbacks for ambiguous or policy-driven cases (workspace linking, overrides, catalogs, dist-tags, publish-date time, lowest-direct/time-based ambiguity). The approach yields the intended performance win while the added parity tests meaningfully reduce behavioral divergence risk.

Files changed (26) +1097 / -91 · 2 not counted

Enhancement (9) +489 / -54
add.rsAllow 'add' to use prefer-frozen fast update path +8/-10

Allow 'add' to use prefer-frozen fast update path

• Stops forcing 'prefer_frozen_lockfile: false' so 'add' can benefit from fast lockfile update when the manifest edit is absorbable. Preserves fallback behavior when freshness gates fail.

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

fast_update_importers.rsAdd new importer edges from locked versions in fast update +127/-22

Add new importer edges from locked versions in fast update

• Implements adding missing importer edges by selecting the version resolution would pick from existing lockfile packages, with safety checks for workspace links, peer/registry-qualified keys, publish-date 'time', and lowest-direct ambiguity. Tracks optional-flag staleness when non-optional edges are added.

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

install.rsPermit fast lockfile update for InstallSome +6/-2

Permit fast lockfile update for InstallSome

• Updates mutation eligibility so 'InstallSome' (used by 'add') can participate in fast lockfile updates when drift is limited and the lockfile can absorb it.

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

index.tsStage and commit add manifest edits for fast updates +68/-6

Stage and commit add manifest edits for fast updates

• Integrates 'tryAddLockedVersions' to stage 'installSome' manifest edits on copies and only commit them after a successful fast lockfile rewrite. Gates frozen-like installs on the manifest-commit flag to avoid leaving requested dependencies uninstalled.

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

tryAddLockedVersions.tsImplement lockfile-only manifest edits for 'pnpm add' +160/-0

Implement lockfile-only manifest edits for 'pnpm add'

• Adds a helper that derives the manifest entry to save from the lockfile alone for plain registry semver selectors with a satisfying locked version. Declines cases requiring resolver policy (dist-tags, aliases/protocols, workspace linking, overrides, catalogs, peer-only saves) and uses 'calcVersionRange' for resolver-identical saved ranges.

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

tryFastUpdateImporters.tsFast-update importer additions from locked versions +89/-14

Fast-update importer additions from locked versions

• Enhances importer fast update to insert new edges when manifests add a dependency and the lockfile already contains a suitable version. Adds guards for workspace linking, lockfile 'time' publish-date completeness, and lowest-direct ambiguity; exports the selection helper for reuse.

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

index.tsExport 'inferRangeSpecStyle' +1/-0

Export 'inferRangeSpecStyle'

• Exposes 'inferRangeSpecStyle' from '@pnpm/pkg-manifest.utils' so other packages can consume it without depending on npm-resolver internals.

pnpm11/pkg-manifest/utils/src/index.ts

inferRangeSpecStyle.tsAdd shared range-style inference helper not counted

Add shared range-style inference helper

• Introduces 'inferRangeSpecStyle' based on 'semver-utils' parsing, handling protocol-prefixed selectors and explicitly ignoring 'catalog:' references to avoid misinterpreting catalog names as version pins.

pnpm11/pkg-manifest/utils/src/inferRangeSpecStyle.ts

rangeSpecStyle.tsExtract resolver saved-range algorithm as 'calcVersionRange' +30/-0

Extract resolver saved-range algorithm as 'calcVersionRange'

• Adds 'calcVersionRange' to compute the exact manifest range that should be saved for a resolved version, matching resolver behavior (including exact pinning for prereleases and style precedence).

pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts

Refactor (9) +70 / -30
fast_update_compose.rsPass workspace manifests and resolution mode into importers drift detection +2/-0

Pass workspace manifests and resolution mode into importers drift detection

• Extends fast-update composition to provide project manifests and whether resolution picks lowest direct version, enabling safer lockfile-only edge absorption decisions.

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

fast_update_lockfile.rsGeneralize optional-flag recomputation trigger +6/-4

Generalize optional-flag recomputation trigger

• Renames the edits flag to 'optional_flags_are_stale' and triggers recomputation when edges move across optional or when non-optional additions invalidate reachability-derived optional flags.

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

fast_update_overrides.rsUse resolver-aligned locked-version selection helper +4/-1

Use resolver-aligned locked-version selection helper

• Switches override handling to the renamed 'locked_version_resolution_would_pick' helper and documents why lowest-direct modes are irrelevant for overrides.

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

fast_update_settings.rsExport directory/workspace detection helpers +10/-2

Export directory/workspace detection helpers

• Exports and documents 'is_directory_dependency' and 'workspace_package_names' so other fast-update code can reject workspace-link scenarios without resolver involvement.

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

selfUpdate.tsRepoint range-style inference import +2/-2

Repoint range-style inference import

• Moves 'inferRangeSpecStyle' import to '@pnpm/pkg-manifest.utils' after extraction, leaving behavior unchanged.

pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts

tryComposeFastUpdates.tsPropagate workspacePackages and resolution mode; rename optional flag edit +15/-5

Propagate workspacePackages and resolution mode; rename optional flag edit

• Extends fast-update composition options to pass workspace package data and whether resolution picks lowest direct versions. Renames 'movedAcrossOptional' to 'optionalFlagsAreStale' and uses it to trigger optional-flag recomputation.

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

tryFastUpdateSettings.tsExport 'isDirectoryDependency' for fast-path gating +6/-1

Export 'isDirectoryDependency' for fast-path gating

• Exports and documents directory-dependency detection so fast paths can reject workspace-link cases reliably.

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

updateProjectManifestObject.tsSplit manifest edit application from logging +18/-5

Split manifest edit application from logging

• Extracts 'applyPackageSpecs' so callers can stage edits without logging until they commit, while keeping 'updateProjectManifestObject' behavior the same for committed edits.

pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts

index.tsUse shared 'calcVersionRange' and 'inferRangeSpecStyle' +7/-10

Use shared 'calcVersionRange' and 'inferRangeSpecStyle'

• Replaces resolver-local range-style inference and 'calcRange' logic with shared utilities from '@pnpm/pkg-manifest.utils', keeping resolver output consistent with the new add fast path.

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

Tests (4) +524 / -2
lockfile_resolution_reuse.rsCLI tests for add resolution skipping +97/-0

CLI tests for add resolution skipping

• Adds Rust integration tests asserting 'add <pkg>@<locked-version>' prints the skipped-resolution message and only updates importer edges. Adds a companion test that a non-locked version still triggers resolution.

pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs

tests.rsUnit tests for importer-edge additions and fallback gates +139/-2

Unit tests for importer-edge additions and fallback gates

• Adds coverage for adding at highest locked satisfying version, optional flag invalidation behavior, and rejection cases (no satisfying locked version, workspace project name, lowest-direct ambiguity, and lockfile 'time').

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

lockedAddFastUpdate.tsJest tests for lockfile-only add parity and fallbacks +288/-0

Jest tests for lockfile-only add parity and fallbacks

• Adds tests verifying that adding an already-locked dependency requests zero packages and that fast-path-written manifest/lockfile match full resolution output. Adds fallback tests for unsatisfied versions and dist-tag adds, plus unit tests for edge-add semantics and rejection conditions.

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

inferRangeSpecStyle.test.tsAdd tests for 'inferRangeSpecStyle' not counted

Add tests for 'inferRangeSpecStyle'

• Adds Jest tests covering major/minor/patch/exact/none inference, invalid ranges, protocol-prefixed specs, scoped names, and catalog-reference exclusion.

pnpm11/pkg-manifest/utils/test/inferRangeSpecStyle.test.ts

Documentation (1) +9 / -0
add-command-fast-path.mdDocument 'pnpm add' lockfile-only fast path +9/-0

Document 'pnpm add' lockfile-only fast path

• Adds a changeset describing the new behavior: 'pnpm add' skips resolution when the requested version is already in 'pnpm-lock.yaml'. Lists specifier/flag cases that still force full resolution.

.changeset/add-command-fast-path.md

Other (3) +5 / -5
pnpm-lock.yamlLockfile refresh for dependency moves +3/-3

Lockfile refresh for dependency moves

• Updates importer entries to reflect dependency adjustments (e.g., 'semver-utils' moved to pkg-manifest utils).

pnpm-lock.yaml

package.jsonAdd 'semver-utils' to pkg-manifest utils +2/-1

Add 'semver-utils' to pkg-manifest utils

• Adds 'semver-utils' dependency to support the extracted 'inferRangeSpecStyle' implementation.

pnpm11/pkg-manifest/utils/package.json

package.jsonRemove 'semver-utils' from npm-resolver +0/-1

Remove 'semver-utils' from npm-resolver

• Drops 'semver-utils' dependency from npm-resolver after moving related logic to pkg-manifest utils.

pnpm11/resolving/npm-resolver/package.json

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     12.1±0.15ms    31.0 MB/sec    1.05     12.6±0.42ms    29.6 MB/sec
packument/parse                                  1.00     40.2±0.61µs  1649.9 MB/sec    1.03     41.6±0.53µs  1596.4 MB/sec
tarball/download_dependency                      1.00      2.9±0.14ms  1489.0 KB/sec    1.08      3.1±0.33ms  1383.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   178.0±13.62ms 89.9 KElem/sec    1.11    197.7±5.00ms 80.9 KElem/sec
workspace_resolution/hoist_heavy                 1.04   266.2±11.05ms        ? ?/sec    1.00    255.2±3.73ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Aug 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.23%. Comparing base (1d5741b) to head (e3eb808).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rates/package-manager/src/fast_update_importers.rs 94.91% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13807   +/-   ##
=======================================
  Coverage   88.22%   88.23%           
=======================================
  Files         625      625           
  Lines      102628   102708   +80     
=======================================
+ Hits        90545    90623   +78     
- Misses      12083    12085    +2     

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

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (2) 📜 Skill insights (0)

Grey Divider


Action required

1. Lowest-direct pick unsound ✗ Dismissed 🐞 Bug ≡ Correctness ⭐ New
Description
locked_version_resolution_would_pick() can still return a single satisfying locked version when
resolution_picks_lowest is true, but lowest-direct/time-based resolve direct deps to the
lowest *published* satisfying version, which cannot be inferred from the lockfile if the lockfile
only contains a higher satisfying version. This can make the fast-update path write an importer edge
that differs from what a full resolution would produce under these modes.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R337-340]

+        if resolution_picks_lowest && highest.is_some() {
+            return None;
+        }
+        if highest.as_ref().is_none_or(|best| version > best) {
Relevance

●● Moderate

Conservative fallback change; team sometimes adds fast-path safety guards, but has also rejected
similar extra-guard proposals.

PR-#13482
PR-#13779

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The configuration explicitly defines lowest-direct/time-based as selecting the *lowest satisfying*
direct dependency version, which requires registry knowledge and is not derivable from just “what is
already locked”. The current implementation only bails out after encountering a second satisfying
locked version, meaning it may incorrectly accept a single satisfying locked version as the
resolution outcome.

pnpm/crates/package-manager/src/fast_update_importers.rs[319-345]
pnpm/crates/config/src/lib.rs[666-673]
pnpm/crates/cli/tests/suite/install.rs[1464-1498]

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

## Issue description
`locked_version_resolution_would_pick()` treats `resolution_picks_lowest` as ambiguous only when **multiple locked versions** satisfy the range. However, in `resolutionMode: lowest-direct`/`time-based`, the resolver is required to pick the **lowest published satisfying** version for direct dependencies, which may be lower than any version currently present in the lockfile. Therefore, even when exactly one locked version satisfies a range, the lockfile does not prove it is the correct pick.

## Issue Context
This affects the fast lockfile update path that tries to avoid full resolution. Under lowest-direct/time-based, reusing a locked satisfying version can select a higher version than full resolution would.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[319-345]

## Suggested fix
- When `resolution_picks_lowest == true`, do **not** return a version for non-exact semver ranges (i.e., return `None` to force full resolution), unless you can prove the specifier pins an exact version.
- Add a regression test for `lowest-direct` where the lockfile contains only a higher satisfying version but a lower satisfying published version exists (or otherwise simulate this condition) and ensure the fast-update path is rejected.

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



Remediation recommended

2. Fragile depPath slicing ✓ Resolved 🐞 Bug ☼ Reliability
Description
lockedVersionOfTransitiveDep() derives the “locked version” by slicing the raw packages depPath key
after ${name}@, but pnpm depPaths may legally include suffixes like ([email protected]) so the sliced
result may not be a version string. This makes the test latent-flaky/fixture-sensitive because it
can build an invalid selector and stop asserting the intended fast-path behavior.
Code

pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[R243-246]

+  const prefix = `${TRANSITIVE_DEP}@`
+  const depPath = Object.keys(lockfile.packages).find((key) => key.startsWith(prefix))
+  expect(depPath).toBeDefined()
+  return depPath!.slice(prefix.length)
Relevance

●●● Strong

Team frequently accepts test hardening to avoid latent flakiness/fixture sensitivity; this is a
small, reliability-focused fix.

PR-#13777
PR-#12762

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper currently assumes packages keys are always name@<version> and slices the key to
obtain a version; however other tests in this repo show packages keys can include peer suffixes
like ([email protected]), which would make the sliced substring not be a valid version.

pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[237-247]
pnpm11/installing/deps-installer/test/install/composedFastUpdate.ts[95-102]

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

## Issue description
`lockedVersionOfTransitiveDep()` extracts a version by string-slicing a `packages` depPath key. pnpm depPaths can be peer/patch suffixed (e.g. `[email protected]([email protected])`), so the slice result can be non-semver, which can make this test fail spuriously or stop testing what it intends.

## Issue Context
This helper is used to build the selector passed to `mutateModulesInSingleProject()` and to assert on the written lockfile, so it must return a *plain* version string.

## Fix Focus Areas
- pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[242-247]

## Suggested fix
Replace the prefix/slice logic with depPath parsing:
- Iterate over `Object.entries(lockfile.packages)`.
- For each depPath, parse it using the repo’s dep-path utilities (e.g. `@pnpm/deps.path` parsing helpers) or lockfile utilities to extract `{ name, version, peerDepGraphHash }`.
- Select the entry where `name === TRANSITIVE_DEP`, `peerDepGraphHash` is empty (no peer suffix), and `semver.valid(version)` is truthy.
- Return that `version` (not the raw depPath substring).
- Keep the `expect(...).toBeDefined()`-style assertion, but assert on the parsed version (and optionally that there is exactly one matching plain entry).

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


3. Unsafe lockfile key writes 🐞 Bug ⛨ Security
Description
The new fast-update add path writes dependency aliases into plain-object lockfile maps via bracket
assignment, which is unsafe for special keys on normal objects and is inconsistent with the manifest
writer’s explicit prototype-pollution hardening. Even though CLI/manifest validation should reject
most dangerous keys, this is a fragile trust boundary for attacker-controlled lockfiles/manifests
and is easy to harden.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R181-184]

+  const target = importer[targetGroup] ??= {}
+  target[alias] = wanted
+  importer.specifiers[alias] = specifier
+  // A path that does not run through `optionalDependencies` clears the
Relevance

●●● Strong

Repo has recent accepted hardening against prototype-pollution/unsafe key access; likely to require
safe map writes.

PR-#12558
PR-#13762

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new fast-update path mutates lockfile importer maps with target[alias] = wanted /
importer.specifiers[alias] = specifier on a {}-backed map, while the manifest update code
explicitly avoids prototype edge-cases by using Object.defineProperty for dependency aliases.
Tests also construct lockfile importer maps as plain object literals, making this behavior
applicable to real in-memory lockfile shapes.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[155-187]
pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts[108-120]
pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[265-273]
pnpm11/resolving/parse-wanted-dependency/src/index.ts[15-33]

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 fast-update importer add path writes user-controlled dependency aliases into lockfile importer dictionaries using plain object literals (`{}`) and bracket assignment. This is inconsistent with the manifest update code’s explicit hardening against prototype edge-cases, and can be hardened cheaply.

## Issue Context
- The new code path creates/updates lockfile importer maps when a dependency is *newly added* during fast update.
- The manifest writer already uses `Object.defineProperty` to avoid special-key behavior.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[155-187]
- pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts[108-120]

### Suggested fix approach
- When creating new importer group maps, use `Object.create(null)` instead of `{}`.
- When inserting keys into `importer.specifiers` and dependency group maps, use a small helper that does `Object.defineProperty(..., { enumerable: true, writable: true, configurable: true })` (mirroring `defineDepEntry`).
- Where you check existence, prefer `Object.hasOwn(obj, alias)` over `obj[alias] != null` to avoid prototype-chain surprises.

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


4. Missing trailing commas in params 📘 Rule violation ⚙ Maintainability
Description
Several new multi-line TypeScript function signatures omit trailing commas on the last parameter,
violating the project's TypeScript trailing-comma requirement and increasing diff noise when
adding/reordering parameters.
Code

pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts[R39-42]

+    bareSpecifier?: string
+    defaultRangeSpecStyle?: RangeSpecStyle
+  }
+): string {
Relevance

●●● Strong

Trailing-comma formatting issues in multi-line TS signatures have been accepted before; matches repo
style enforcement.

PR-#13779
PR-#13792

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs.
calcVersionRange(...) and other new multi-line function signatures are formatted across multiple
lines but do not include a trailing comma after the last parameter.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts[35-42]
pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[78-81]

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 TypeScript parameter lists introduced/modified in this PR are missing trailing commas after the last parameter.

## Issue Context
The repo compliance checklist requires trailing commas in TypeScript multi-line constructs to keep formatting consistent and reduce diff churn.

## Fix Focus Areas
- pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts[35-42]
- pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[78-81]
- pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[114-118]

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


View review recommended (3)
5. Comment says "as before" ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A newly added comment uses historical phrasing (as before) instead of describing the current
behavior directly, which can become misleading over time.
Code

pnpm/crates/package-manager/src/add.rs[R247-250]

+            // `prepare_manifest` just made. It only absorbs an addition the
+            // lockfile already holds a satisfying version for; anything else
+            // fails the freshness gate and re-resolves as before.
+            prefer_frozen_lockfile: None,
Relevance

●● Moderate

Mixed precedent: some temporal-comment rewrites accepted, but similar “as always/as before” reword
requests were rejected.

PR-#13727
PR-#13712
PR-#13792

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids comments that describe behavior in terms of past implementations.
The updated comment explicitly says the flow "re-resolves as before" instead of stating the current
outcome (e.g., "triggers full resolution").

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/add.rs[245-250]

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 new/modified comment references prior behavior using historical phrasing ("as before").

## Issue Context
Inline comments should describe current behavior and invariants, not compare to previous implementations.

## Fix Focus Areas
- pnpm/crates/package-manager/src/add.rs[245-250]

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


6. workspace_package_names takes PathBuf 📘 Rule violation ⚙ Maintainability
Description
workspace_package_names() accepts a tuple containing an owned PathBuf even though it only reads
manifest names, potentially forcing more specific/owned data than needed at call sites.
Code

pnpm/crates/package-manager/src/fast_update_settings.rs[R222-224]

+pub(crate) fn workspace_package_names(
+    manifests: &[(PathBuf, &PackageManifest)],
+) -> HashSet<String> {
Relevance

●● Moderate

No close precedent found for changing PathBuf params to borrowed types; could be seen as churn
without clear benefit.

PR-#13762
PR-#13482

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2254729 requires preferring borrowed/general parameter types over owned/specific
ones when no ownership is needed. workspace_package_names() takes PathBuf in its input tuple but
only reads manifest.value().get("name"), so the path component is unnecessary and overly specific.

Rule 2254729: Prefer general borrowed parameter types (&str, &Path) over owned or specific types when no extra copies are required
pnpm/crates/package-manager/src/fast_update_settings.rs[222-234]

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 Rust function signature takes `PathBuf` (via `&[(PathBuf, &PackageManifest)]`) despite only needing read-only access to manifest data.

## Issue Context
Prefer general borrowed types (e.g., `&Path`) or avoid carrying owned path values in parameters when they are not used.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_settings.rs[222-234]

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


7. Rust picker allocates Vec ✓ Resolved 🐞 Bug ➹ Performance
Description
locked_version_resolution_would_pick() now allocates a Vec and clones all satisfying versions before
taking max, even when only the maximum is needed. This adds avoidable allocations/cloning on the
fast-update path for large lockfiles or frequently-changing importers.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R316-319]

+    let mut satisfying: Vec<Version> = Vec::new();
    for key in packages?.keys() {
        if &key.name != alias {
            continue;
Relevance

●● Moderate

Perf micro-optimizations sometimes accepted, but similar allocation-avoidance refactors have also
been rejected; no exact match.

PR-#13762
PR-#13698

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The current implementation allocates Vec<Version> and pushes version.clone() for every
satisfying lockfile entry, then calls into_iter().max(). This replaces a previously streaming
selection approach with extra allocation/cloning overhead.

pnpm/crates/package-manager/src/fast_update_importers.rs[310-333]

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

## Issue description
`locked_version_resolution_would_pick()` collects all satisfying versions into a `Vec` and clones each one, then computes `max()`. This is unnecessary in the common case (when `resolution_picks_lowest` is false), and even in lowest-picks mode you can short-circuit once more than one satisfying version is observed.

## Issue Context
This function is used by the lockfile fast-update pipeline during importer drift replay (including the new add-edge absorb path), so it should avoid avoidable allocation pressure.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[310-333]

### Suggested fix approach
- Replace `Vec<Version>` with streaming tracking:
 - Track `best: Option<Version>` and `count_satisfying: u8` (or `usize`).
 - For each satisfying version: increment count; update best if greater.
 - If `resolution_picks_lowest` and `count_satisfying > 1`, return `None` early.
- This preserves behavior while avoiding allocations and unnecessary cloning.

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



Informational

8. Changeset omits fast-path gates ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The changeset describes the fast path mostly in terms of “a satisfying locked version exists”, but
the implementation also intentionally disables the fast path under additional configurations (e.g.
non-manual catalog mode / ignoreCurrentSpecifiers, and lowest-direct/time-based modes when
multiple locked versions satisfy). This can mislead users into expecting resolution to be skipped in
cases where it will still do a full resolve.
Code

.changeset/add-command-fast-path.md[9]

+`pnpm add` no longer re-resolves the dependency graph when `pnpm-lock.yaml` already holds a version satisfying the request — promoting a transitive dependency to a direct one, or adding to a second workspace package what a first one already depends on, now only saves the dependency in `package.json` and records its importer entry. The install still falls back to a full resolution for anything else: a dist tag, an alias, a `workspace:`/`catalog:`/git/tarball specifier, `--save-peer`, an overridden package, or a version nothing in the lockfile satisfies.
Relevance

●●● Strong

Team often updates changesets to match exact behavior/skip conditions and avoid overpromising in
release notes.

PR-#13403
PR-#11362
PR-#13785

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The release-note lists some fallback cases, but the new implementation explicitly returns null
(forcing full resolution) in additional situations unrelated to whether a satisfying locked version
exists; and the locked-version picker refuses to decide in lowest-direct/time-based semantics when
the lockfile has multiple satisfying versions.

.changeset/add-command-fast-path.md[1-9]
pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[70-93]
pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[114-143]
pnpm/crates/package-manager/src/fast_update_importers.rs[307-341]

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 implies the new `pnpm add` fast path is triggered whenever the lockfile contains a satisfying version, but the implementation also has other eligibility gates that force fallback to full resolution.

## Issue Context
This is user-facing release-note text; when the fast path doesn’t apply, users may assume a regression or misconfiguration.

## Fix Focus Areas
- .changeset/add-command-fast-path.md[9-9]

Update the sentence to clarify that a satisfying locked version is **necessary but not sufficient**, and mention the most user-visible additional exclusions (e.g. catalog-mode rewrite/ignore-current-specifiers; lowest-direct/time-based when multiple locked versions satisfy).

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


Grey Divider

Context
✅ Compliance rules (platform): 26 rules

Grey Divider

Tip of the day
💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous review results

Review updated until commit e3eb808

Results up to commit 7576174 ⚖️ Balanced


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


Remediation recommended
1. Unsafe lockfile key writes 🐞 Bug ⛨ Security
Description
The new fast-update add path writes dependency aliases into plain-object lockfile maps via bracket
assignment, which is unsafe for special keys on normal objects and is inconsistent with the manifest
writer’s explicit prototype-pollution hardening. Even though CLI/manifest validation should reject
most dangerous keys, this is a fragile trust boundary for attacker-controlled lockfiles/manifests
and is easy to harden.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R181-184]

+  const target = importer[targetGroup] ??= {}
+  target[alias] = wanted
+  importer.specifiers[alias] = specifier
+  // A path that does not run through `optionalDependencies` clears the
Relevance

●●● Strong

Repo has recent accepted hardening against prototype-pollution/unsafe key access; likely to require
safe map writes.

PR-#12558
PR-#13762

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new fast-update path mutates lockfile importer maps with target[alias] = wanted /
importer.specifiers[alias] = specifier on a {}-backed map, while the manifest update code
explicitly avoids prototype edge-cases by using Object.defineProperty for dependency aliases.
Tests also construct lockfile importer maps as plain object literals, making this behavior
applicable to real in-memory lockfile shapes.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[155-187]
pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts[108-120]
pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[265-273]
pnpm11/resolving/parse-wanted-dependency/src/index.ts[15-33]

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 fast-update importer add path writes user-controlled dependency aliases into lockfile importer dictionaries using plain object literals (`{}`) and bracket assignment. This is inconsistent with the manifest update code’s explicit hardening against prototype edge-cases, and can be hardened cheaply.

## Issue Context
- The new code path creates/updates lockfile importer maps when a dependency is *newly added* during fast update.
- The manifest writer already uses `Object.defineProperty` to avoid special-key behavior.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[155-187]
- pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts[108-120]

### Suggested fix approach
- When creating new importer group maps, use `Object.create(null)` instead of `{}`.
- When inserting keys into `importer.specifiers` and dependency group maps, use a small helper that does `Object.defineProperty(..., { enumerable: true, writable: true, configurable: true })` (mirroring `defineDepEntry`).
- Where you check existence, prefer `Object.hasOwn(obj, alias)` over `obj[alias] != null` to avoid prototype-chain surprises.

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


2. Missing trailing commas in params 📘 Rule violation ⚙ Maintainability
Description
Several new multi-line TypeScript function signatures omit trailing commas on the last parameter,
violating the project's TypeScript trailing-comma requirement and increasing diff noise when
adding/reordering parameters.
Code

pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts[R39-42]

+    bareSpecifier?: string
+    defaultRangeSpecStyle?: RangeSpecStyle
+  }
+): string {
Relevance

●●● Strong

Trailing-comma formatting issues in multi-line TS signatures have been accepted before; matches repo
style enforcement.

PR-#13779
PR-#13792

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs.
calcVersionRange(...) and other new multi-line function signatures are formatted across multiple
lines but do not include a trailing comma after the last parameter.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts[35-42]
pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[78-81]

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 TypeScript parameter lists introduced/modified in this PR are missing trailing commas after the last parameter.

## Issue Context
The repo compliance checklist requires trailing commas in TypeScript multi-line constructs to keep formatting consistent and reduce diff churn.

## Fix Focus Areas
- pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts[35-42]
- pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[78-81]
- pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[114-118]

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


3. Rust picker allocates Vec ✓ Resolved 🐞 Bug ➹ Performance
Description
locked_version_resolution_would_pick() now allocates a Vec and clones all satisfying versions before
taking max, even when only the maximum is needed. This adds avoidable allocations/cloning on the
fast-update path for large lockfiles or frequently-changing importers.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R316-319]

+    let mut satisfying: Vec<Version> = Vec::new();
    for key in packages?.keys() {
        if &key.name != alias {
            continue;
Relevance

●● Moderate

Perf micro-optimizations sometimes accepted, but similar allocation-avoidance refactors have also
been rejected; no exact match.

PR-#13762
PR-#13698

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The current implementation allocates Vec<Version> and pushes version.clone() for every
satisfying lockfile entry, then calls into_iter().max(). This replaces a previously streaming
selection approach with extra allocation/cloning overhead.

pnpm/crates/package-manager/src/fast_update_importers.rs[310-333]

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

## Issue description
`locked_version_resolution_would_pick()` collects all satisfying versions into a `Vec` and clones each one, then computes `max()`. This is unnecessary in the common case (when `resolution_picks_lowest` is false), and even in lowest-picks mode you can short-circuit once more than one satisfying version is observed.

## Issue Context
This function is used by the lockfile fast-update pipeline during importer drift replay (including the new add-edge absorb path), so it should avoid avoidable allocation pressure.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[310-333]

### Suggested fix approach
- Replace `Vec<Version>` with streaming tracking:
 - Track `best: Option<Version>` and `count_satisfying: u8` (or `usize`).
 - For each satisfying version: increment count; update best if greater.
 - If `resolution_picks_lowest` and `count_satisfying > 1`, return `None` early.
- This preserves behavior while avoiding allocations and unnecessary cloning.

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


View review recommended (2)
4. Comment says "as before" ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A newly added comment uses historical phrasing (as before) instead of describing the current
behavior directly, which can become misleading over time.
Code

pnpm/crates/package-manager/src/add.rs[R247-250]

+            // `prepare_manifest` just made. It only absorbs an addition the
+            // lockfile already holds a satisfying version for; anything else
+            // fails the freshness gate and re-resolves as before.
+            prefer_frozen_lockfile: None,
Relevance

●● Moderate

Mixed precedent: some temporal-comment rewrites accepted, but similar “as always/as before” reword
requests were rejected.

PR-#13727
PR-#13712
PR-#13792

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids comments that describe behavior in terms of past implementations.
The updated comment explicitly says the flow "re-resolves as before" instead of stating the current
outcome (e.g., "triggers full resolution").

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/package-manager/src/add.rs[245-250]

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 new/modified comment references prior behavior using historical phrasing ("as before").

## Issue Context
Inline comments should describe current behavior and invariants, not compare to previous implementations.

## Fix Focus Areas
- pnpm/crates/package-manager/src/add.rs[245-250]

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


5. workspace_package_names takes PathBuf 📘 Rule violation ⚙ Maintainability
Description
workspace_package_names() accepts a tuple containing an owned PathBuf even though it only reads
manifest names, potentially forcing more specific/owned data than needed at call sites.
Code

pnpm/crates/package-manager/src/fast_update_settings.rs[R222-224]

+pub(crate) fn workspace_package_names(
+    manifests: &[(PathBuf, &PackageManifest)],
+) -> HashSet<String> {
Relevance

●● Moderate

No close precedent found for changing PathBuf params to borrowed types; could be seen as churn
without clear benefit.

PR-#13762
PR-#13482

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2254729 requires preferring borrowed/general parameter types over owned/specific
ones when no ownership is needed. workspace_package_names() takes PathBuf in its input tuple but
only reads manifest.value().get("name"), so the path component is unnecessary and overly specific.

Rule 2254729: Prefer general borrowed parameter types (&str, &Path) over owned or specific types when no extra copies are required
pnpm/crates/package-manager/src/fast_update_settings.rs[222-234]

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 Rust function signature takes `PathBuf` (via `&[(PathBuf, &PackageManifest)]`) despite only needing read-only access to manifest data.

## Issue Context
Prefer general borrowed types (e.g., `&Path`) or avoid carrying owned path values in parameters when they are not used.

## Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_settings.rs[222-234]

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


Results up to commit 5051f4d ⚖️ Balanced


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


Informational
1. Changeset omits fast-path gates ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The changeset describes the fast path mostly in terms of “a satisfying locked version exists”, but
the implementation also intentionally disables the fast path under additional configurations (e.g.
non-manual catalog mode / ignoreCurrentSpecifiers, and lowest-direct/time-based modes when
multiple locked versions satisfy). This can mislead users into expecting resolution to be skipped in
cases where it will still do a full resolve.
Code

.changeset/add-command-fast-path.md[9]

+`pnpm add` no longer re-resolves the dependency graph when `pnpm-lock.yaml` already holds a version satisfying the request — promoting a transitive dependency to a direct one, or adding to a second workspace package what a first one already depends on, now only saves the dependency in `package.json` and records its importer entry. The install still falls back to a full resolution for anything else: a dist tag, an alias, a `workspace:`/`catalog:`/git/tarball specifier, `--save-peer`, an overridden package, or a version nothing in the lockfile satisfies.
Relevance

●●● Strong

Team often updates changesets to match exact behavior/skip conditions and avoid overpromising in
release notes.

PR-#13403
PR-#11362
PR-#13785

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The release-note lists some fallback cases, but the new implementation explicitly returns null
(forcing full resolution) in additional situations unrelated to whether a satisfying locked version
exists; and the locked-version picker refuses to decide in lowest-direct/time-based semantics when
the lockfile has multiple satisfying versions.

.changeset/add-command-fast-path.md[1-9]
pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[70-93]
pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts[114-143]
pnpm/crates/package-manager/src/fast_update_importers.rs[307-341]

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 implies the new `pnpm add` fast path is triggered whenever the lockfile contains a satisfying version, but the implementation also has other eligibility gates that force fallback to full resolution.

## Issue Context
This is user-facing release-note text; when the fast path doesn’t apply, users may assume a regression or misconfiguration.

## Fix Focus Areas
- .changeset/add-command-fast-path.md[9-9]

Update the sentence to clarify that a satisfying locked version is **necessary but not sufficient**, and mention the most user-visible additional exclusions (e.g. catalog-mode rewrite/ignore-current-specifiers; lowest-direct/time-based when multiple locked versions satisfy).

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


Results up to commit 509d22d ⚖️ Balanced


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


Remediation recommended
1. Fragile depPath slicing ✓ Resolved 🐞 Bug ☼ Reliability
Description
lockedVersionOfTransitiveDep() derives the “locked version” by slicing the raw packages depPath key
after ${name}@, but pnpm depPaths may legally include suffixes like ([email protected]) so the sliced
result may not be a version string. This makes the test latent-flaky/fixture-sensitive because it
can build an invalid selector and stop asserting the intended fast-path behavior.
Code

pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[R243-246]

+  const prefix = `${TRANSITIVE_DEP}@`
+  const depPath = Object.keys(lockfile.packages).find((key) => key.startsWith(prefix))
+  expect(depPath).toBeDefined()
+  return depPath!.slice(prefix.length)
Relevance

●●● Strong

Team frequently accepts test hardening to avoid latent flakiness/fixture sensitivity; this is a
small, reliability-focused fix.

PR-#13777
PR-#12762

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper currently assumes packages keys are always name@<version> and slices the key to
obtain a version; however other tests in this repo show packages keys can include peer suffixes
like ([email protected]), which would make the sliced substring not be a valid version.

pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[237-247]
pnpm11/installing/deps-installer/test/install/composedFastUpdate.ts[95-102]

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

## Issue description
`lockedVersionOfTransitiveDep()` extracts a version by string-slicing a `packages` depPath key. pnpm depPaths can be peer/patch suffixed (e.g. `[email protected]([email protected])`), so the slice result can be non-semver, which can make this test fail spuriously or stop testing what it intends.

## Issue Context
This helper is used to build the selector passed to `mutateModulesInSingleProject()` and to assert on the written lockfile, so it must return a *plain* version string.

## Fix Focus Areas
- pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts[242-247]

## Suggested fix
Replace the prefix/slice logic with depPath parsing:
- Iterate over `Object.entries(lockfile.packages)`.
- For each depPath, parse it using the repo’s dep-path utilities (e.g. `@pnpm/deps.path` parsing helpers) or lockfile utilities to extract `{ name, version, peerDepGraphHash }`.
- Select the entry where `name === TRANSITIVE_DEP`, `peerDepGraphHash` is empty (no peer suffix), and `semver.valid(version)` is truthy.
- Return that `version` (not the raw depPath substring).
- Keep the `expect(...).toBeDefined()`-style assertion, but assert on the parsed version (and optionally that there is exactly one matching plain entry).

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

@greptile-apps

greptile-apps Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Reviews (6): Last reviewed commit: "test: await the composed fast update, wh..." | Re-trigger Greptile

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

Actionable comments posted: 4

🧹 Nitpick comments (6)
pnpm11/pkg-manifest/utils/test/inferRangeSpecStyle.test.ts (1)

32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add the case parameters to the test title.

Every case shares the title inferRangeSpecStyle(). When one case fails, the report does not say which specifier failed. test.each supports printf placeholders in the title.

♻️ Proposed change
-])('inferRangeSpecStyle()', (spec, expectedResult) => {
+])('inferRangeSpecStyle(%p) === %p', (spec, expectedResult) => {
   expect(inferRangeSpecStyle(spec)).toEqual(expectedResult)
 })
🤖 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/pkg-manifest/utils/test/inferRangeSpecStyle.test.ts` at line 32,
Update the test.each title for inferRangeSpecStyle() to include the spec and
expectedResult parameters using supported printf placeholders, so each generated
test name identifies its inputs while preserving the existing test cases.
pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs (2)

1625-1629: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Log the command output before asserting on it.

Both assertions test a contains on multi-line stdout. On failure the panic message shows only the static reason. The reader cannot see what the command actually printed.

♻️ Proposed change
+    let stdout = String::from_utf8_lossy(&assert.get_output().stdout).into_owned();
+    eprintln!("STDOUT:\n{stdout}\n");
     assert!(
-        String::from_utf8_lossy(&assert.get_output().stdout)
-            .contains("Lockfile is up to date, resolution step is skipped"),
+        stdout.contains("Lockfile is up to date, resolution step is skipped"),
         "adding an already-locked version needs no resolution",
     );

Apply the same change to the negative assertion at Lines 1675-1679.

As per path instructions, pnpm/CODE_STYLE_GUIDE.md states to "log complex assertion values with dbg! or multiline output with eprintln!".

Also applies to: 1675-1679

🤖 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 `@pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs` around lines 1625 -
1629, Add an eprintln! of the captured command stdout immediately before both
multi-line stdout contains assertions in the lockfile resolution reuse test,
including the positive and negative assertions. Keep the existing assertion
conditions and failure messages unchanged.

Source: Path instructions


1600-1616: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the duplicated fixture setup.

Both tests repeat the same 17 lines: create the workspace with a mocked registry, write the same package.json, append trustLockfile: true to pnpm-workspace.yaml, and run install. This file already uses helpers such as write_two_member_workspace for shared setup.

Extract one helper that returns the CommandTempCwd parts, then let each test differ only in the add argument and its assertions.

Also applies to: 1653-1669

🤖 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 `@pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs` around lines 1600 -
1616, Extract the repeated trusted-lockfile fixture setup into a shared helper
near the affected tests, reusing the existing workspace and package-writing
conventions. Have the helper return the needed CommandTempCwd parts, including
the mocked registry handle, and perform the workspace initialization,
package.json write, trustLockfile update, and install setup once. Update both
tests to call the helper and differ only in their add argument and assertions.
pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts (1)

53-61: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document that applyPackageSpecs mutates its argument.

applyPackageSpecs edits packageManifest in place and also returns it. The current doc comment does not state the mutation. A new caller can pass a live project manifest and change it unintentionally. tryAddLockedVersions avoids this only because it passes clone(...).

Add one sentence to the doc comment that states the argument is mutated.

🤖 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/pkg-manifest/utils/src/updateProjectManifestObject.ts` around lines 53
- 61, Add a sentence to the JSDoc for applyPackageSpecs explicitly stating that
it mutates the supplied packageManifest argument in place while returning it. Do
not change the implementation or surrounding documentation.
pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts (1)

121-130: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The test name claims highest-version selection, but only one satisfying version exists.

lockfile() records a single [email protected]. The assertion therefore passes whether the helper takes the maximum or the only element. Add a second satisfying version so the test covers the sort(semver.rcompare)[0] branch in lockedVersionResolutionWouldPick.

♻️ Proposed change to cover the selection branch
 test('a new dependency is added at the highest locked version satisfying it', () => {
   const subject = lockfile()
+  subject.packages!['[email protected]' as DepPath] = { resolution: { integrity: 'sha512-child-2' } }
 
   expect(tryFastUpdateImporters(subject, [
     project({ dependencies: { foo: '^1.0.0', bar: '^2.0.0', child: '^3.0.0' } }),
   ])).toBe(true)
   const importer = subject.importers['.' as ProjectId]
-  expect(importer.dependencies).toStrictEqual({ foo: '1.1.0', bar: '2.0.0', child: '3.0.0' })
+  expect(importer.dependencies).toStrictEqual({ foo: '1.1.0', bar: '2.0.0', child: '3.1.0' })
   expect(importer.specifiers.child).toBe('^3.0.0')
 })
🤖 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/test/install/lockedAddFastUpdate.ts` around
lines 121 - 130, Update the test case using lockfile() and
tryFastUpdateImporters so the child dependency has at least two locked versions
satisfying ^3.0.0, including 3.0.0 and a higher version, then assert the higher
version is selected. Keep the existing test name and specifier assertion so it
explicitly exercises the highest-version branch in
lockedVersionResolutionWouldPick.
pnpm/crates/package-manager/src/install.rs (1)

212-219: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

Document the update gate in may_fast_update_lockfile. pacquet update <selector> and pacquet update --latest set prefer_frozen_lockfile: Some(false), so they still resolve through the registry. State this invariant in the doc comment.

🤖 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 `@pnpm/crates/package-manager/src/install.rs` around lines 212 - 219, Update
the doc comment for ProjectMutation::may_fast_update_lockfile to explicitly
state that pacquet update <selector> and pacquet update --latest set
prefer_frozen_lockfile to Some(false) and therefore still resolve through the
registry; leave the method’s logic unchanged.
🤖 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.

Inline comments:
In @.changeset/add-command-fast-path.md:
- Line 9: Update the release note sentence in add-command-fast-path.md to state
that pnpm add reuses a locked version when it satisfies the requested plain
registry range, rather than only when the requested version exactly matches.
Also state that the command updates both the package manifest and the lockfile
importer entry, while preserving the existing full-resolution fallback
conditions.

In `@pnpm/crates/package-manager/src/fast_update_importers.rs`:
- Around line 202-214: Update add_importer_edge to check importer.specifiers
when importer_dependency(importer, alias) is absent, returning false if the
alias already has a recorded specifier. Preserve the existing
directory-dependency guard and defer this lockfile shape to the resolver,
matching TypeScript addImporterEdge behavior.

In `@pnpm/crates/package-manager/src/fast_update_importers/tests.rs`:
- Around line 1146-1161: Strengthen
adds_a_dependency_at_the_highest_locked_version_satisfying_it by adding a
[email protected] entry to the parsed lockfile’s packages, plus its snapshots record
if required for rewriting, using the sibling test’s setup and default resolution
mode. Update the assertion to expect version 3.1.0 while preserving the ^3.0.0
specifier.

In `@pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts`:
- Around line 105-108: Update the installSome handling around added.set in
tryAddLockedVersions so duplicate rootDir entries are detected before
overwriting an existing staged manifest; when a rootDir has already been added,
return null rather than merging or replacing it. Preserve the existing manifest
construction for unique rootDir values.

---

Nitpick comments:
In `@pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs`:
- Around line 1625-1629: Add an eprintln! of the captured command stdout
immediately before both multi-line stdout contains assertions in the lockfile
resolution reuse test, including the positive and negative assertions. Keep the
existing assertion conditions and failure messages unchanged.
- Around line 1600-1616: Extract the repeated trusted-lockfile fixture setup
into a shared helper near the affected tests, reusing the existing workspace and
package-writing conventions. Have the helper return the needed CommandTempCwd
parts, including the mocked registry handle, and perform the workspace
initialization, package.json write, trustLockfile update, and install setup
once. Update both tests to call the helper and differ only in their add argument
and assertions.

In `@pnpm/crates/package-manager/src/install.rs`:
- Around line 212-219: Update the doc comment for
ProjectMutation::may_fast_update_lockfile to explicitly state that pacquet
update <selector> and pacquet update --latest set prefer_frozen_lockfile to
Some(false) and therefore still resolve through the registry; leave the method’s
logic unchanged.

In `@pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts`:
- Around line 121-130: Update the test case using lockfile() and
tryFastUpdateImporters so the child dependency has at least two locked versions
satisfying ^3.0.0, including 3.0.0 and a higher version, then assert the higher
version is selected. Keep the existing test name and specifier assertion so it
explicitly exercises the highest-version branch in
lockedVersionResolutionWouldPick.

In `@pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts`:
- Around line 53-61: Add a sentence to the JSDoc for applyPackageSpecs
explicitly stating that it mutates the supplied packageManifest argument in
place while returning it. Do not change the implementation or surrounding
documentation.

In `@pnpm11/pkg-manifest/utils/test/inferRangeSpecStyle.test.ts`:
- Line 32: Update the test.each title for inferRangeSpecStyle() to include the
spec and expectedResult parameters using supported printf placeholders, so each
generated test name identifies its inputs while preserving the existing test
cases.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c489eb2f-5333-4f94-beb3-e7e643dd680f

📥 Commits

Reviewing files that changed from the base of the PR and between ac97bc1 and 7576174.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (25)
  • .changeset/add-command-fast-path.md
  • pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs
  • pnpm/crates/package-manager/src/add.rs
  • pnpm/crates/package-manager/src/fast_update_compose.rs
  • pnpm/crates/package-manager/src/fast_update_importers.rs
  • pnpm/crates/package-manager/src/fast_update_importers/tests.rs
  • pnpm/crates/package-manager/src/fast_update_lockfile.rs
  • pnpm/crates/package-manager/src/fast_update_overrides.rs
  • pnpm/crates/package-manager/src/fast_update_settings.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts
  • pnpm11/installing/deps-installer/src/install/index.ts
  • pnpm11/installing/deps-installer/src/install/tryAddLockedVersions.ts
  • pnpm11/installing/deps-installer/src/install/tryComposeFastUpdates.ts
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateSettings.ts
  • pnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.ts
  • pnpm11/pkg-manifest/utils/package.json
  • pnpm11/pkg-manifest/utils/src/index.ts
  • pnpm11/pkg-manifest/utils/src/inferRangeSpecStyle.ts
  • pnpm11/pkg-manifest/utils/src/rangeSpecStyle.ts
  • pnpm11/pkg-manifest/utils/src/updateProjectManifestObject.ts
  • pnpm11/pkg-manifest/utils/test/inferRangeSpecStyle.test.ts
  • pnpm11/resolving/npm-resolver/package.json
  • pnpm11/resolving/npm-resolver/src/index.ts
💤 Files with no reviewable changes (1)
  • pnpm11/resolving/npm-resolver/package.json

Comment thread .changeset/add-command-fast-path.md Resolved
@blacksmith-sh

This comment has been minimized.

zkochan added a commit that referenced this pull request Aug 11, 2026
Review findings on #13807:

- pacquet absorbed an importer that records a specifier for an alias no
  dependency group points at, which the TypeScript handler defers to the
  resolver. Give it the same guard.
- Both stacks' "highest locked version" tests locked a single version of
  the added package, so they passed under any selection rule. Lock a
  second one and assert the higher.
- Guard `tryAddLockedVersions` against two `installSome` mutations for
  the same project: each stages onto a fresh copy of the context
  manifest, so the second would discard the first's edits. It joins the
  cases the function answers with `null`.
- Say in the changeset that a satisfying version is enough, not an exact
  one, and that `package.json` is written too.
- Trim the prose the guards and their tests already state.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2026 03:07

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.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 11, 2026
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 11, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5051f4d

@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 11, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: e3eb80813527

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.519 ± 0.163 2.388 2.812 1.63 ± 0.21
pacquet@main 2.603 ± 0.110 2.436 2.756 1.68 ± 0.20
pnpr@HEAD 1.598 ± 0.140 1.417 1.765 1.03 ± 0.15
pnpr@main 1.546 ± 0.170 1.387 1.825 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.51866219012,
      "stddev": 0.16294201646500092,
      "median": 2.43252155252,
      "user": 1.7754532399999998,
      "system": 1.4875262399999998,
      "min": 2.38799342552,
      "max": 2.81187387252,
      "times": [
        2.38799342552,
        2.41723482752,
        2.81187387252,
        2.7308451385200003,
        2.48362572452,
        2.70150728552,
        2.39012374052,
        2.42534935152,
        2.3983747815200003,
        2.4396937535200003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.6032005548200003,
      "stddev": 0.11046292883329911,
      "median": 2.6171166555200003,
      "user": 2.19947014,
      "system": 1.70565844,
      "min": 2.43638248252,
      "max": 2.75589370952,
      "times": [
        2.66150097452,
        2.53157636952,
        2.49806382952,
        2.59210018552,
        2.43638248252,
        2.49432507152,
        2.75589370952,
        2.64213312552,
        2.67272601152,
        2.74730378852
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.59849882922,
      "stddev": 0.14005862325249752,
      "median": 1.5875206135200002,
      "user": 1.43640474,
      "system": 1.43540454,
      "min": 1.41663107852,
      "max": 1.76482348852,
      "times": [
        1.5010412985200001,
        1.7530080365200003,
        1.7292626265200002,
        1.4631803415200002,
        1.50483931652,
        1.7194539085200002,
        1.67020191052,
        1.76482348852,
        1.46254628652,
        1.41663107852
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5457968762200003,
      "stddev": 0.16988881099901387,
      "median": 1.47245031452,
      "user": 1.28313864,
      "system": 1.38881734,
      "min": 1.38661993052,
      "max": 1.82476232452,
      "times": [
        1.44950449052,
        1.63668826752,
        1.42105302852,
        1.38948039452,
        1.82476232452,
        1.49539613852,
        1.41564155952,
        1.6211592755200002,
        1.38661993052,
        1.81766335252
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 272.7 ± 6.6 265.2 281.6 1.00
pacquet@main 274.3 ± 7.2 260.5 282.2 1.01 ± 0.04
pnpr@HEAD 311.7 ± 28.6 283.3 362.3 1.14 ± 0.11
pnpr@main 289.8 ± 11.5 270.2 310.5 1.06 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.27270137978000003,
      "stddev": 0.006558602214202254,
      "median": 0.27276405118,
      "user": 0.23855684,
      "system": 0.55732426,
      "min": 0.26523375718000003,
      "max": 0.28163412318000003,
      "times": [
        0.27636714418,
        0.27147545218,
        0.28163412318000003,
        0.26725510818000003,
        0.26555883918,
        0.26562412318,
        0.26523375718000003,
        0.27957138318,
        0.27405265018,
        0.28024121718
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.27433712627999995,
      "stddev": 0.007154936044217053,
      "median": 0.27630466168,
      "user": 0.24204414000000002,
      "system": 0.55553146,
      "min": 0.26053605218000003,
      "max": 0.28216800918,
      "times": [
        0.27928555518000003,
        0.27018456918,
        0.26439683918,
        0.26053605218000003,
        0.27898235318000003,
        0.27468513318000004,
        0.28052342818000003,
        0.27571573718000003,
        0.28216800918,
        0.27689358618000004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31170789028,
      "stddev": 0.02855263481303549,
      "median": 0.30009139468,
      "user": 0.26502864,
      "system": 0.5900440600000001,
      "min": 0.28332850618,
      "max": 0.36229751518000003,
      "times": [
        0.28935051818,
        0.28714277618,
        0.30062265618,
        0.28567675318,
        0.28332850618,
        0.36229751518000003,
        0.34356786918000004,
        0.33586898618,
        0.32966318918000004,
        0.29956013318
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28975795118000003,
      "stddev": 0.01149807145666236,
      "median": 0.29282870918000004,
      "user": 0.25523384,
      "system": 0.55437466,
      "min": 0.27019716418,
      "max": 0.31050629718,
      "times": [
        0.28336966318,
        0.27019716418,
        0.31050629718,
        0.29832284118,
        0.29463352718,
        0.29309226118000004,
        0.27588592718,
        0.28581328018,
        0.29256515718000004,
        0.29319339318000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.702 ± 0.054 2.635 2.828 1.63 ± 0.11
pacquet@main 2.669 ± 0.017 2.644 2.693 1.61 ± 0.11
pnpr@HEAD 1.662 ± 0.110 1.545 1.861 1.00
pnpr@main 1.683 ± 0.174 1.495 1.905 1.01 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7022598871800003,
      "stddev": 0.05364033075531242,
      "median": 2.68273256278,
      "user": 1.8307464199999999,
      "system": 1.5698398199999999,
      "min": 2.63462940928,
      "max": 2.8275456122800002,
      "times": [
        2.6819893172800002,
        2.7318096022800002,
        2.67671349128,
        2.6935516922800002,
        2.6834758082800003,
        2.7437616412800003,
        2.6733443502800003,
        2.63462940928,
        2.6757779472800003,
        2.8275456122800002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.6693097959800003,
      "stddev": 0.016979225463644977,
      "median": 2.6741612862800004,
      "user": 1.7995424200000003,
      "system": 1.4624911200000001,
      "min": 2.64415513628,
      "max": 2.69286844428,
      "times": [
        2.69286844428,
        2.64415513628,
        2.65151249528,
        2.6792329502800003,
        2.65427271828,
        2.65451596828,
        2.66908962228,
        2.68081557128,
        2.68001361028,
        2.6866214432800004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6619513816799998,
      "stddev": 0.10960964520826846,
      "median": 1.63952225828,
      "user": 1.33795872,
      "system": 1.4548001199999998,
      "min": 1.54451351528,
      "max": 1.86106970428,
      "times": [
        1.86106970428,
        1.73054125128,
        1.77154793228,
        1.5524487602800001,
        1.65238642228,
        1.54451351528,
        1.62665809428,
        1.58700658628,
        1.55033518728,
        1.74300636328
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6827870295800005,
      "stddev": 0.17361507779247493,
      "median": 1.65205340178,
      "user": 1.4066654200000002,
      "system": 1.46042232,
      "min": 1.4953600302799999,
      "max": 1.90540841528,
      "times": [
        1.71194174928,
        1.7721413912800001,
        1.90540841528,
        1.49554570028,
        1.53372910228,
        1.88348516828,
        1.53282495628,
        1.4953600302799999,
        1.5921650542799999,
        1.90526872828
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 507.2 ± 30.7 469.8 556.4 1.49 ± 0.11
pacquet@main 465.5 ± 33.7 413.6 544.4 1.37 ± 0.12
pnpr@HEAD 339.4 ± 15.6 321.4 364.7 1.00
pnpr@main 342.1 ± 14.6 322.6 368.8 1.01 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.50722305274,
      "stddev": 0.030684587493781258,
      "median": 0.50064588074,
      "user": 0.7042884399999999,
      "system": 0.8135435400000001,
      "min": 0.46977072124,
      "max": 0.55637840324,
      "times": [
        0.48939960824000006,
        0.52357954224,
        0.54743643924,
        0.4772383652400001,
        0.47689818524000005,
        0.55637840324,
        0.46977072124,
        0.53023750124,
        0.49766419524000005,
        0.50362756624
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.46552133984,
      "stddev": 0.03370218460340222,
      "median": 0.46430220324000004,
      "user": 0.6453424400000001,
      "system": 0.73797434,
      "min": 0.41360826224,
      "max": 0.54444224524,
      "times": [
        0.46218227724000005,
        0.46637741424000007,
        0.47890440524000005,
        0.46222699224,
        0.44489508324000004,
        0.54444224524,
        0.44079044724000005,
        0.41360826224,
        0.47199880924000004,
        0.46978746224000006
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33943788044,
      "stddev": 0.015586445517511113,
      "median": 0.33635381924,
      "user": 0.25278113999999996,
      "system": 0.5731055399999999,
      "min": 0.32144778224000004,
      "max": 0.36472337224000007,
      "times": [
        0.36109856024000003,
        0.33673579924,
        0.33597183924,
        0.36472337224000007,
        0.34016250924,
        0.35402790224,
        0.32433442524000006,
        0.32144778224000004,
        0.33174274824000005,
        0.32413386624
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.34214015084000005,
      "stddev": 0.014569595733707095,
      "median": 0.34072700224,
      "user": 0.27515723999999997,
      "system": 0.5608342399999999,
      "min": 0.32264247624000003,
      "max": 0.36878740124000003,
      "times": [
        0.36878740124000003,
        0.35269280724,
        0.32894919224,
        0.34006991424000005,
        0.34059443224,
        0.32264247624000003,
        0.32486131724000006,
        0.34085957224,
        0.34497304524000005,
        0.35697135024000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.786 ± 0.029 1.733 1.810 5.84 ± 0.23
pacquet@main 1.750 ± 0.033 1.715 1.819 5.72 ± 0.23
pnpr@HEAD 0.308 ± 0.008 0.295 0.323 1.01 ± 0.04
pnpr@main 0.306 ± 0.011 0.291 0.320 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7862697094600002,
      "stddev": 0.02917801099343878,
      "median": 1.7986364940600001,
      "user": 0.8956269399999999,
      "system": 0.84579766,
      "min": 1.73281852056,
      "max": 1.81010401156,
      "times": [
        1.7917787395600002,
        1.80593176656,
        1.80364462456,
        1.81010401156,
        1.80936779956,
        1.79362836356,
        1.8089686605600002,
        1.76399193956,
        1.73281852056,
        1.74246266856
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.74954437156,
      "stddev": 0.03254219869824845,
      "median": 1.7423627910600001,
      "user": 0.82344844,
      "system": 0.7635277599999999,
      "min": 1.7150758055600002,
      "max": 1.8190859055600002,
      "times": [
        1.8190859055600002,
        1.7836103735600002,
        1.7622896455600001,
        1.73881833956,
        1.75433004756,
        1.73896060656,
        1.7457649755600002,
        1.72218674956,
        1.7150758055600002,
        1.7153212665600002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30799849096000004,
      "stddev": 0.0076819341752788215,
      "median": 0.30890672206,
      "user": 0.23335734000000002,
      "system": 0.5152458599999999,
      "min": 0.29506126456,
      "max": 0.32281476756,
      "times": [
        0.30975420756,
        0.30805923656,
        0.31108237056,
        0.32281476756,
        0.31314982956,
        0.30651577056,
        0.29506126456,
        0.29837837056,
        0.30534910156,
        0.30981999056
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30594137146,
      "stddev": 0.010918604290818095,
      "median": 0.30867234256,
      "user": 0.19819634000000003,
      "system": 0.5341418599999999,
      "min": 0.29123672856,
      "max": 0.32038333356,
      "times": [
        0.31394096456,
        0.30641137456,
        0.29287064456,
        0.31308660056,
        0.29977749456,
        0.29123672856,
        0.29316972556,
        0.31760353756,
        0.32038333356,
        0.31093331056
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 210.3 ± 14.8 193.3 245.1 2.40 ± 0.17
pacquet@main 207.0 ± 16.6 181.6 235.7 2.36 ± 0.19
pnpr@HEAD 87.6 ± 1.5 84.9 92.1 1.00
pnpr@main 95.3 ± 10.1 85.0 121.8 1.09 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.21027752096461544,
      "stddev": 0.014777859143817388,
      "median": 0.20771921558000003,
      "user": 0.17243675538461536,
      "system": 0.05439778307692308,
      "min": 0.19326931258000002,
      "max": 0.24509510558000003,
      "times": [
        0.21827570658000003,
        0.20730119858,
        0.21359842358000003,
        0.19871828058000002,
        0.20270420258000002,
        0.23200364158000003,
        0.19785723958,
        0.20771921558000003,
        0.24509510558000003,
        0.19326931258000002,
        0.19613242158000002,
        0.21283939458,
        0.20809362958000002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.20699044478000003,
      "stddev": 0.016600510095137792,
      "median": 0.21042918658,
      "user": 0.17171807333333333,
      "system": 0.06359899333333334,
      "min": 0.18156462858000003,
      "max": 0.23571183158000003,
      "times": [
        0.18413737158000001,
        0.21462403358,
        0.23571183158000003,
        0.23186467858,
        0.20203328058000003,
        0.21087419358,
        0.19655864458000002,
        0.21150896958,
        0.20066882158000002,
        0.18156462858000003,
        0.21042918658,
        0.21470921358000003,
        0.22744896658000002,
        0.19116468958000002,
        0.19155816158000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08761346083806451,
      "stddev": 0.001504559307261209,
      "median": 0.08726867158,
      "user": 0.02127949483870968,
      "system": 0.00950744064516129,
      "min": 0.08490348958,
      "max": 0.09205700758,
      "times": [
        0.09043384058,
        0.08684806957999999,
        0.08790330657999999,
        0.08588536858,
        0.08840585258,
        0.08890161658,
        0.08902038958,
        0.08719444258,
        0.08695543257999999,
        0.08781332758,
        0.08527704258,
        0.08693923158,
        0.09038332557999999,
        0.08601232757999999,
        0.09205700758,
        0.08731219358,
        0.08685962158,
        0.08606459558,
        0.08707130957999999,
        0.08835712258,
        0.08669290857999999,
        0.08690695058,
        0.08726867158,
        0.08742936458,
        0.08830443158,
        0.08678535258,
        0.08808248358,
        0.08853652858,
        0.08490348958,
        0.08820090658,
        0.08721077358
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09532848048909089,
      "stddev": 0.010129207185822484,
      "median": 0.09275223558,
      "user": 0.023387443030303028,
      "system": 0.013863041818181817,
      "min": 0.08495443458,
      "max": 0.12184448258,
      "times": [
        0.08667533458,
        0.08738620258,
        0.08656055958,
        0.08743090658,
        0.08786748958,
        0.08495443458,
        0.09104438958,
        0.09112234658,
        0.08588165158,
        0.08703103358,
        0.08671270558,
        0.08718699858,
        0.08615384258,
        0.09257440958,
        0.09653493658,
        0.09289765858,
        0.09826843858,
        0.09275223558,
        0.09466584658,
        0.09630567358,
        0.09962419257999999,
        0.09281641558,
        0.09695531657999999,
        0.10754069558,
        0.11259427858,
        0.12184448258,
        0.12098335058,
        0.11560378358,
        0.10603290558,
        0.09362901558,
        0.09497565058,
        0.09185544658,
        0.09137722758
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 924.1 ± 137.7 649.4 1078.2 1.00
pacquet@main 1025.1 ± 250.6 624.3 1251.5 1.11 ± 0.32
pnpm@HEAD 2980.9 ± 118.6 2901.4 3248.6 3.23 ± 0.50
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.9240803459422224,
      "stddev": 0.1376932548886593,
      "median": 0.9715556657200001,
      "user": 0.9034005022222222,
      "system": 0.15064172888888888,
      "min": 0.64941152772,
      "max": 1.07824320972,
      "times": [
        0.79991327172,
        0.8240340607200001,
        1.01275601672,
        1.07824320972,
        0.9715556657200001,
        0.96426828572,
        0.98448754072,
        1.0320535347200002,
        0.64941152772
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.025056807831111,
      "stddev": 0.2505854634603914,
      "median": 1.13538716472,
      "user": 0.9765866133333334,
      "system": 0.1683169511111111,
      "min": 0.62427050872,
      "max": 1.2514789827200001,
      "times": [
        0.71326143672,
        0.62427050872,
        1.2514789827200001,
        1.2209834537200002,
        0.7702093237200001,
        1.13538716472,
        1.0746677477200002,
        1.19420602372,
        1.2410466287200002
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 2.9808501428311107,
      "stddev": 0.1186302809678731,
      "median": 2.93779324572,
      "user": 4.589670724444444,
      "system": 0.2592289511111111,
      "min": 2.90138778372,
      "max": 3.24856692072,
      "times": [
        3.24856692072,
        2.90866800472,
        2.94424788172,
        2.91992293972,
        2.90138778372,
        2.91012781372,
        2.94801349372,
        2.93779324572,
        3.10892320172
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.581 ± 0.161 4.443 4.857 1.31 ± 0.05
pacquet@main 4.433 ± 0.023 4.407 4.487 1.27 ± 0.01
pnpr@HEAD 3.513 ± 0.062 3.453 3.640 1.01 ± 0.02
pnpr@main 3.485 ± 0.026 3.454 3.528 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.580851237319999,
      "stddev": 0.1608524510301697,
      "median": 4.51469077672,
      "user": 1.78325742,
      "system": 1.4077256,
      "min": 4.4426015987200005,
      "max": 4.85650699272,
      "times": [
        4.4426015987200005,
        4.44485013272,
        4.56697303472,
        4.66741216372,
        4.85650699272,
        4.826611857720001,
        4.46240851872,
        4.45612040172,
        4.63909692972,
        4.44593074272
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.43315112592,
      "stddev": 0.02335035066829045,
      "median": 4.43099741222,
      "user": 1.7467876199999999,
      "system": 1.3230004000000002,
      "min": 4.40749689272,
      "max": 4.48685140972,
      "times": [
        4.48685140972,
        4.4530060137200005,
        4.41756842772,
        4.4347421037200006,
        4.43917817172,
        4.41974156172,
        4.40749689272,
        4.41093185372,
        4.429179893720001,
        4.43281493072
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5127292037200006,
      "stddev": 0.061554963443723285,
      "median": 3.4794187582200005,
      "user": 1.1988124199999999,
      "system": 1.1989782999999998,
      "min": 3.45331510872,
      "max": 3.64006461572,
      "times": [
        3.54398511672,
        3.4653816727200004,
        3.4744600077200003,
        3.45331510872,
        3.64006461572,
        3.5882973927200004,
        3.47430930372,
        3.4767241917200002,
        3.52864130272,
        3.4821133247200002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.4847314722200005,
      "stddev": 0.025764822179249466,
      "median": 3.48257155322,
      "user": 1.17470302,
      "system": 1.2323210000000002,
      "min": 3.4541333287200002,
      "max": 3.5278479337200004,
      "times": [
        3.46665374672,
        3.50256103372,
        3.51391190672,
        3.45886114972,
        3.49718943072,
        3.49454228972,
        3.4541333287200002,
        3.5278479337200004,
        3.4610130857200003,
        3.47060081672
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13807
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,634.63 ms
(-2.94%)Baseline: 2,714.51 ms
3,257.41 ms
(80.88%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,732.82 ms
(-4.85%)Baseline: 1,821.07 ms
2,185.29 ms
(79.29%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
469.77 ms
(-0.61%)Baseline: 472.63 ms
567.16 ms
(82.83%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
193.27 ms
(-18.15%)Baseline: 236.14 ms
283.36 ms
(68.21%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,387.99 ms
(-3.00%)Baseline: 2,461.73 ms
2,954.07 ms
(80.84%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,442.60 ms
(-2.46%)Baseline: 4,554.69 ms
5,465.62 ms
(81.28%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
265.23 ms
(-11.41%)Baseline: 299.40 ms
359.28 ms
(73.82%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
649.41 ms
(-12.60%)Baseline: 743.03 ms
891.63 ms
(72.83%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13807
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,544.51 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
295.06 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
321.45 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.90 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,416.63 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,453.32 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
283.33 ms
🐰 View full continuous benchmarking report in Bencher

Copilot AI review requested due to automatic review settings August 11, 2026 03:49
@greptile-apps
greptile-apps Bot dismissed their stale review August 11, 2026 03:49

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.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 11, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 509d22d

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 11, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 17016d4

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

Copilot AI review requested due to automatic review settings August 11, 2026 11:31
@greptile-apps
greptile-apps Bot dismissed their stale review August 11, 2026 11:31

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.

@zkochan

zkochan commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Rebased onto main (5571fa2), now that #13803 has landed.

The overlap resolved in its favour, so the diff shrank a lot: tryComposeFastUpdates.ts, tryFastUpdateSettings.ts, fast_update_compose.rs, fast_update_lockfile.rs, fast_update_overrides.rs, and fast_update_settings.rs are out of it entirely. What is left in the shared handler is the one branch this PR needs — a new alias inside an importer that already records others, next to 13803's new-project entry — reusing its resolutionPicksLowest and isDirectoryDependency guards and its lockedVersionResolutionWouldPick rather than restating them. The branch history is squashed to one commit, since the intermediate commits were review fixes to code 13803 has now replaced.

Two things came out of the merge and are folded in: resolutionPicksLowest was being computed twice in index.ts (13803 inline at the compose call, mine as a const), so it is now the one const used in both places; and the picker kept my early-return form as well as 13803's counting form, so it keeps 13803's.

Locally on the rebased tree: full pnpm run compile and cargo clippy --deny warnings clean, and cargo nextest run -p pacquet-package-manager -p pacquet-cli green at 3135 tests. The deps-installer install suite is green except misc.ts's "update a package when installing with a dist-tag", which passes in isolation — it is the shared registry-mock latest tag race (its log shows the first add already resolved to ^100.1.0), and @beta is not a semver range, so this PR's path declines before reaching it.


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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 11, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 37c6eb6

@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 and others added 2 commits August 11, 2026 13:52
pnpm remove already skips resolution when the lockfile proves the
outcome; its twin did not. `pnpm add <pkg>@<version>` re-resolved the
whole graph even when the requested version was one the lockfile
already held — promoting a transitive dependency to a direct one, or
adding to a second workspace package what a first one already depends
on.

The rule is the one #13779 established: resolution reuses the
already-locked version it would dedupe onto rather than fetching a
higher one, because preferredVersions biases it toward what the graph
already holds. The importers handler now records a brand-new importer
edge at that version, under the group the manifest declares, alongside
the whole-new-project entry #13803 added. It reuses that
change's guards: a range several locked versions satisfy under
`resolutionMode: time-based` or `lowest-direct` keeps the resolver,
since those pick the low end and only for a run that leaves the
manifest alone, and so does a plain range on a workspace project's
name, which may resolve to a link instead. A lockfile carrying `time`
keeps it too: `time` records a publish date per direct dependency and
is only pruned on save, never extended, so a package promoted into
that position would be missing the one a resolution records.

`installSome` cannot edit the manifests in place the way
`uninstallSome` does — the resolution path reads them to tell a new
dependency from a re-added one, and reads them again to pick the range
style it saves — so the edit is staged on copies, handed to the fast
update and its freshness gates, and the context takes it only once the
rewrite commits. The range a selector saves is computed with the
resolver's own rule, extracted as `calcVersionRange` in
`@pnpm/pkg-manifest.utils` alongside the `inferRangeSpecStyle` it needs.

pacquet needed only the gate: `add` already pins the manifest before
the install runs, so `may_fast_update_lockfile` admits `InstallSome`
and `add` stops forcing `preferFrozenLockfile` off. `update` is also
`InstallSome` and keeps its explicit opt-out, so it is unaffected. Its
manifest pin still consults the registry packument; only the
install-side resolution is skipped.

The narrow cut is a plain registry specifier. A dist tag, an alias, a
`workspace:`/`catalog:`/git/tarball specifier, `--save-peer`, a
`catalogMode` other than `manual`, an overridden package, and a version
nothing locked satisfies all keep the resolver.

Closes #13798.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`tryComposeFastUpdates` returns a promise since #13804 made it
compose the catalogs and overrides rewrites, so the added tests were
asserting on the promise object rather than on its result.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2026 11:58
@greptile-apps
greptile-apps Bot dismissed their stale review August 11, 2026 11:58

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.

Copilot AI review requested due to automatic review settings August 11, 2026 11:58

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 Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@qodo-code-review

Copy link
Copy Markdown

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

@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 f100948 into main Aug 11, 2026
37 checks passed
@zkochan
zkochan deleted the fix-13798 branch August 11, 2026 12:32
zkochan added a commit that referenced this pull request Aug 12, 2026
…hange

The first cut withheld the lockfile pin and skipped the frozen shortcut for
any `add <pkg>@<version>`, which defeated the resolution reuse added in
#13807: adding a version the lockfile already holds resolved the
graph again instead of reporting the lockfile up to date.

The trigger is now the case that needs it — the dependency resolves through
a catalog entry that covers the wanted version but is recorded at a
different one. An add that isn't cataloged, whose entry already resolves to
the wanted version, or whose entry excludes it, keeps every pin and the
frozen shortcut. The predicates behind that decision are the ones the
catalog-mode gate already uses, so the two agree by construction.

The withheld pin is also bounded to direct dependencies now: a catalog entry
governs those, and transitive occurrences of the same package have no reason
to lose their resolutions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

Fast lockfile update for pnpm add when the requested version is already locked

3 participants