Repository navigation
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesLocked add fast path
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
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by Qodoperf: skip pnpm add resolution when requested version is already locked
AI Description
Diagram
High-Level Assessment
Files changed (26)
|
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Confidence Score: 5/5The 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (6)
pnpm11/pkg-manifest/utils/test/inferRangeSpecStyle.test.ts (1)
32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd 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.eachsupports 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 winLog the command output before asserting on it.
Both assertions test a
containson 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.mdstates to "log complex assertion values withdbg!or multiline output witheprintln!".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 valueExtract the duplicated fixture setup.
Both tests repeat the same 17 lines: create the workspace with a mocked registry, write the same
package.json, appendtrustLockfile: truetopnpm-workspace.yaml, and runinstall. This file already uses helpers such aswrite_two_member_workspacefor shared setup.Extract one helper that returns the
CommandTempCwdparts, then let each test differ only in theaddargument 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 valueDocument that
applyPackageSpecsmutates its argument.
applyPackageSpecseditspackageManifestin 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.tryAddLockedVersionsavoids this only because it passesclone(...).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 winThe 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 thesort(semver.rcompare)[0]branch inlockedVersionResolutionWouldPick.♻️ 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 valueDocument the update gate in
may_fast_update_lockfile.pacquet update <selector>andpacquet update --latestsetprefer_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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (25)
.changeset/add-command-fast-path.mdpnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rspnpm/crates/package-manager/src/add.rspnpm/crates/package-manager/src/fast_update_compose.rspnpm/crates/package-manager/src/fast_update_importers.rspnpm/crates/package-manager/src/fast_update_importers/tests.rspnpm/crates/package-manager/src/fast_update_lockfile.rspnpm/crates/package-manager/src/fast_update_overrides.rspnpm/crates/package-manager/src/fast_update_settings.rspnpm/crates/package-manager/src/install.rspnpm11/engine/pm/commands/src/self-updater/selfUpdate.tspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/src/install/tryAddLockedVersions.tspnpm11/installing/deps-installer/src/install/tryComposeFastUpdates.tspnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.tspnpm11/installing/deps-installer/src/install/tryFastUpdateSettings.tspnpm11/installing/deps-installer/test/install/lockedAddFastUpdate.tspnpm11/pkg-manifest/utils/package.jsonpnpm11/pkg-manifest/utils/src/index.tspnpm11/pkg-manifest/utils/src/inferRangeSpecStyle.tspnpm11/pkg-manifest/utils/src/rangeSpecStyle.tspnpm11/pkg-manifest/utils/src/updateProjectManifestObject.tspnpm11/pkg-manifest/utils/test/inferRangeSpecStyle.test.tspnpm11/resolving/npm-resolver/package.jsonpnpm11/resolving/npm-resolver/src/index.ts
💤 Files with no reviewable changes (1)
- pnpm11/resolving/npm-resolver/package.json
This comment has been minimized.
This comment has been minimized.
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]>
|
Code review by qodo was updated up to the latest commit 5051f4d |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Integrated-Benchmark Report (Linux)Commit: 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
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
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
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
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
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
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
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
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
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13807 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,544.51 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 295.06 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 321.45 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.90 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,416.63 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,453.32 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 283.33 ms |
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Code review by qodo was updated up to the latest commit 509d22d |
|
Code review by qodo was updated up to the latest commit 17016d4 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Rebased onto The overlap resolved in its favour, so the diff shrank a lot: Two things came out of the merge and are folded in: Locally on the rebased tree: full Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit 37c6eb6 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
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]>
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Code review by qodo was updated up to the latest commit e3eb808 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…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]>
Summary
Closes #13798.
pnpm removeskips 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
preferredVersionsbiases it toward what the graph already holds. Confirmed rather than assumed, as every item of #13696 asks: two tests run the samepnpm addthrough the fast path and throughforceFullResolutionand 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-basedorlowest-directkeeps 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, whichlinkWorkspacePackagesmay turn into a link. One guard is new: a lockfile carryingtimedeclines, becausetimerecords 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). SotryAddLockedVersionsstages 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 whattryFrozenInstallis gated on: without a committed edit it must not take the frozen-like install, orpnpm addwould 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 ascalcVersionRangeinto@pnpm/pkg-manifest.utils(which already ownsversionWithRangeSpecStyle) along with theinferRangeSpecStyleit needs; the resolver keeps calling it.pnpm add foo@^1.0.0against a locked1.2.0therefore 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), annpm:alias,workspace:/catalog:/git/tarball,--save-peer,--save-catalog/ acatalogModeother thanmanual, 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 addalready pins the manifest before the install runs (prepare_manifest):may_fast_update_lockfileadmitsInstallSome, andaddstops forcingpreferFrozenLockfileoff.pacquet updateis alsoInstallSomeand keeps its explicitSome(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
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Summary by CodeRabbit
New Features
pnpm addcan now reuse compatible versions already recorded in the lockfile, avoiding unnecessary package resolution.Bug Fixes