Repository navigation
fix(deps-restorer): re-import a slot when a custom integrity changes - #15673
Conversation
A custom resolver can hand back a new integrity for the same name@version, and `shouldRefreshResolution` lets it do so on a later install. pnpm wrote the new integrity to the lockfile but kept the old files in node_modules and reported "Already up to date". Later installs, frozen ones included, then saw nothing to fix. `LockfileResolution::integrity` returns `None` for custom resolutions, because their integrity belongs to the custom fetcher rather than to the built-in verification. `integrity_equal` compared integrities only through that accessor, so both the plan-time check (`current_entry_unchanged`) and the link-time check (`package_content_changed`) saw `None == None` and kept the slot. `integrity_equal` now also compares the `integrity` field a custom resolution records. Built-in verification still treats it as opaque. This matches pnpm v11, whose `isIntegrityEqual` reads the `integrity` field of any resolution. Closes pnpm#15670
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe install reuse check now compares custom resolution integrity values. Unit and regression tests cover matching and changed values, including re-importing an updated package on a repeat install. ChangesCustom resolution integrity
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix · Severity of issue fixed: Medium Assessment against linked issues
Suggested labels: Merge Risk: ⚪ Minimal · up to Changing a custom resolution’s integrity is covered by the re-import regression test. No merge-blocking issue is identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change makes repeat installs replace stale custom-resolver packages in the ordinary virtual store. It does not give custom resolvers new authority, but the global virtual store remains outside the fix, and failure recovery is not fully verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
✨ Finishing Touches🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15673 +/- ##
=======================================
Coverage 91.92% 91.92%
=======================================
Files 1456 1456
Lines 196611 196617 +6
=======================================
+ Hits 180731 180737 +6
Misses 15880 15880 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
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; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.47593164608,
"stddev": 0.15743758617484147,
"median": 2.4882894115800003,
"user": 1.4003424,
"system": 1.4456324399999998,
"min": 2.2727878055799997,
"max": 2.69476552158
},
{
"command": "pacquet@main",
"mean": 2.45346105308,
"stddev": 0.12867001855316385,
"median": 2.46329815458,
"user": 1.5031510999999997,
"system": 1.5332633400000002,
"min": 2.30362124458,
"max": 2.71045100958
},
{
"command": "pnpr@HEAD",
"mean": 1.50679253168,
"stddev": 0.09599492964152721,
"median": 1.48950752408,
"user": 1.4571123,
"system": 1.49324354,
"min": 1.36706423258,
"max": 1.63746133858
},
{
"command": "pnpr@main",
"mean": 1.49898522368,
"stddev": 0.15184624548608183,
"median": 1.46856847908,
"user": 1.3829278999999997,
"system": 1.40025954,
"min": 1.3366687315799999,
"max": 1.6910371195799998
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.22171916090000005,
"stddev": 0.02049964929928917,
"median": 0.2180909286,
"user": 0.24036648,
"system": 0.51755358,
"min": 0.2013234691,
"max": 0.26724183510000005
},
{
"command": "pacquet@main",
"mean": 0.2274901169,
"stddev": 0.009734402646047849,
"median": 0.22586743010000002,
"user": 0.23051648,
"system": 0.5393306800000001,
"min": 0.2173993881,
"max": 0.24621337010000002
},
{
"command": "pnpr@HEAD",
"mean": 0.34302989790000005,
"stddev": 0.04014537168053926,
"median": 0.35612102060000006,
"user": 0.36624638,
"system": 0.7076221799999999,
"min": 0.25835834010000003,
"max": 0.38520113810000006
},
{
"command": "pnpr@main",
"mean": 0.35993734800000005,
"stddev": 0.017087998241562992,
"median": 0.3598063951,
"user": 0.39940237999999995,
"system": 0.73502678,
"min": 0.33381561810000004,
"max": 0.3985536311
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.010614091483565886,
"stddev": 0.0017328974364114963,
"median": 0.01036340422,
"user": 0.005988577674418605,
"system": 0.005184891937984494,
"min": 0.00793383772,
"max": 0.01695212972
},
{
"command": "pacquet@main",
"mean": 0.009789558301280787,
"stddev": 0.001214419852601643,
"median": 0.00977416272,
"user": 0.005547926896551724,
"system": 0.004783954285714284,
"min": 0.00769009072,
"max": 0.01354642472
},
{
"command": "pnpr@HEAD",
"mean": 0.008890096634590743,
"stddev": 0.001033777729904503,
"median": 0.00862711872,
"user": 0.004852801850533807,
"system": 0.004514296797153023,
"min": 0.007447243720000001,
"max": 0.01560504072
},
{
"command": "pnpr@main",
"mean": 0.01028043445400674,
"stddev": 0.0012450765178239208,
"median": 0.01008824672,
"user": 0.00603774693602694,
"system": 0.004803269225589224,
"min": 0.00788582972,
"max": 0.01496150972
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.01052636826567901,
"stddev": 0.0010383097635110878,
"median": 0.01047955292,
"user": 0.005920888395061728,
"system": 0.005128559506172836,
"min": 0.00810435192,
"max": 0.015426117920000001
},
{
"command": "pacquet@main",
"mean": 0.010657260535740745,
"stddev": 0.0005789833398250528,
"median": 0.010629198420000001,
"user": 0.006073831296296293,
"system": 0.005135232777777776,
"min": 0.00939281392,
"max": 0.013060970920000001
},
{
"command": "pnpr@HEAD",
"mean": 0.010425692120000003,
"stddev": 0.00077044913335065,
"median": 0.01035063692,
"user": 0.006244731111111108,
"system": 0.004716262577777779,
"min": 0.00841833992,
"max": 0.013485694920000001
},
{
"command": "pnpr@main",
"mean": 0.011001978490212769,
"stddev": 0.0009436775983935819,
"median": 0.01094284992,
"user": 0.0061096046808510615,
"system": 0.00544823404255319,
"min": 0.00871755992,
"max": 0.014427210920000001
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.89534281482,
"stddev": 0.25502300442246845,
"median": 2.8216612599200004,
"user": 2.8625346799999996,
"system": 2.21297166,
"min": 2.6110126169200005,
"max": 3.28782792392
},
{
"command": "pacquet@main",
"mean": 3.20813990762,
"stddev": 0.11114603786633546,
"median": 3.18482101492,
"user": 3.5281058799999996,
"system": 2.65120646,
"min": 3.0402092039200004,
"max": 3.4167091279200004
},
{
"command": "pnpr@HEAD",
"mean": 1.66786048262,
"stddev": 0.14121851508103223,
"median": 1.72587008042,
"user": 1.50002698,
"system": 1.5715554600000001,
"min": 1.41754279992,
"max": 1.83972347592
},
{
"command": "pnpr@main",
"mean": 1.48849226132,
"stddev": 0.12107917252994159,
"median": 1.4257674654199999,
"user": 1.0751513799999999,
"system": 1.19911606,
"min": 1.37901754692,
"max": 1.70369729692
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6562939755000001,
"stddev": 0.06671645314953781,
"median": 0.6365347633,
"user": 0.9800030600000001,
"system": 1.0059826199999997,
"min": 0.5729091858,
"max": 0.7692332188000001
},
{
"command": "pacquet@main",
"mean": 0.6041276543,
"stddev": 0.08608865658540452,
"median": 0.6010006218,
"user": 0.8997422599999998,
"system": 0.9376969199999999,
"min": 0.5000100468,
"max": 0.7253271138
},
{
"command": "pnpr@HEAD",
"mean": 0.3313471539,
"stddev": 0.019579300220213026,
"median": 0.3253681708,
"user": 0.29505386,
"system": 0.64451112,
"min": 0.3078675278,
"max": 0.3731241398
},
{
"command": "pnpr@main",
"mean": 0.34483286840000005,
"stddev": 0.022695911265141127,
"median": 0.3416302603,
"user": 0.29486635999999994,
"system": 0.65047452,
"min": 0.3105448118,
"max": 0.3917912448
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7389878712200002,
"stddev": 0.11498501036237171,
"median": 1.6932819328200002,
"user": 1.11366962,
"system": 0.9606422199999999,
"min": 1.63697062532,
"max": 1.94171396332
},
{
"command": "pacquet@main",
"mean": 1.8101772414200004,
"stddev": 0.10990604954887855,
"median": 1.8008288273200002,
"user": 1.17805692,
"system": 0.9895770199999999,
"min": 1.67764354132,
"max": 2.0351244633200003
},
{
"command": "pnpr@HEAD",
"mean": 0.33425034062000003,
"stddev": 0.041331785797748,
"median": 0.32899435382,
"user": 0.27807272,
"system": 0.61462892,
"min": 0.30079315632000003,
"max": 0.43851801632000004
},
{
"command": "pnpr@main",
"mean": 0.29803658772,
"stddev": 0.014677028298495593,
"median": 0.29733479681999997,
"user": 0.24441671999999998,
"system": 0.5595847199999999,
"min": 0.27979573032,
"max": 0.32675733732
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2347541271942857,
"stddev": 0.022763872265975475,
"median": 0.24075271148,
"user": 0.2485412828571429,
"system": 0.07679297142857142,
"min": 0.20095937348,
"max": 0.27422745548
},
{
"command": "pacquet@main",
"mean": 0.22228008647999997,
"stddev": 0.018319625926412158,
"median": 0.21887731548,
"user": 0.22803579384615386,
"system": 0.07198424615384615,
"min": 0.20279351348000002,
"max": 0.25599122448
},
{
"command": "pnpr@HEAD",
"mean": 0.09695099728645162,
"stddev": 0.0038547967405248183,
"median": 0.09653065048,
"user": 0.035296962580645165,
"system": 0.017557238709677417,
"min": 0.09009348348,
"max": 0.10453351248000001
},
{
"command": "pnpr@main",
"mean": 0.10337963893161292,
"stddev": 0.007821541807260437,
"median": 0.10479179048,
"user": 0.04150322064516129,
"system": 0.018980322580645165,
"min": 0.08973595848,
"max": 0.11638032948
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6467494778955555,
"stddev": 0.08497054799196817,
"median": 0.61114858934,
"user": 0.6558067244444444,
"system": 0.15298904666666666,
"min": 0.5357267733400001,
"max": 0.7911471303400001
},
{
"command": "pacquet@main",
"mean": 0.6876953420066667,
"stddev": 0.03728519419517316,
"median": 0.6929067613400001,
"user": 0.7065830577777777,
"system": 0.15151093555555553,
"min": 0.61765180834,
"max": 0.7316962193400001
},
{
"command": "pnpm@HEAD",
"mean": 3.159302889784445,
"stddev": 0.38345127161637843,
"median": 3.0500649613400004,
"user": 4.916583946666666,
"system": 0.23021137999999997,
"min": 2.77917741734,
"max": 4.102057680340001
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2376362867654545,
"stddev": 0.010255119625441199,
"median": 0.23516609022,
"user": 0.20129270363636367,
"system": 0.0878165,
"min": 0.21949378022000002,
"max": 0.25161624122
},
{
"command": "pacquet@main",
"mean": 0.23983292598923084,
"stddev": 0.010400983447667224,
"median": 0.23859931622000002,
"user": 0.20425626307692304,
"system": 0.09395573076923076,
"min": 0.22181793822,
"max": 0.25761175522
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.55022733812,
"stddev": 0.14194118154579885,
"median": 4.4827424446199995,
"user": 1.7902799799999998,
"system": 2.03977074,
"min": 4.41547188662,
"max": 4.81545035062
},
{
"command": "pacquet@main",
"mean": 4.610536171520001,
"stddev": 0.18302780015922737,
"median": 4.53062767462,
"user": 1.8445445799999998,
"system": 1.9961910399999998,
"min": 4.42430444662,
"max": 4.87554091962
},
{
"command": "pnpr@HEAD",
"mean": 3.56187730152,
"stddev": 0.13607828162567098,
"median": 3.52671361612,
"user": 1.67903618,
"system": 1.8228559399999995,
"min": 3.43179836362,
"max": 3.77983017262
},
{
"command": "pnpr@main",
"mean": 3.5494603851199997,
"stddev": 0.11192686536746942,
"median": 3.5328863131199997,
"user": 1.7116444799999997,
"system": 1.8518724399999997,
"min": 3.41955440062,
"max": 3.81700932162
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.17029209431111111,
"stddev": 0.02908784710969632,
"median": 0.17026499170000003,
"user": 0.2133881377777777,
"system": 0.16307329999999998,
"min": 0.12690152970000002,
"max": 0.22771606770000002
},
{
"command": "pacquet@main",
"mean": 0.22196614070000004,
"stddev": 0.019736583113306398,
"median": 0.21498160270000002,
"user": 0.25862606,
"system": 0.2217866,
"min": 0.19991252470000004,
"max": 0.25399095870000005
},
{
"command": "pnpr@HEAD",
"mean": 0.13981786686666667,
"stddev": 0.008811133611877853,
"median": 0.14369580820000002,
"user": 0.16955991555555555,
"system": 0.13726163333333333,
"min": 0.12282096370000001,
"max": 0.14985050470000003
},
{
"command": "pnpr@main",
"mean": 0.13853861396315792,
"stddev": 0.007527383915389166,
"median": 0.1376956957,
"user": 0.15576762315789475,
"system": 0.13917703684210525,
"min": 0.12592156470000002,
"max": 0.15150388970000003
}
]
} |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Qualify the changeset to note that global virtual store mode remains unsupported.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes pnpm v12 stale virtual-store slots when a custom resolver changes package integrity.
Changes:
- Compare custom resolution integrities during slot reuse.
- Add unit and end-to-end regression tests.
- Add a
pacquetpatch changeset.
| File | Description |
|---|---|
pnpm/crates/deps-restorer/src/create_virtual_store/tests/integrity.rs |
Adds unit coverage for custom integrity comparison. |
pnpm/crates/deps-restorer/src/create_virtual_store/cache_keys.rs |
Detects changed custom integrities. |
pnpm/crates/cli/tests/suite/custom_resolvers.rs |
Verifies re-fetching and re-importing end to end. |
.changeset/custom-resolution-integrity-reimports.md |
Documents the user-facing fix. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks for the contribution |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
The global virtual store named a custom resolution's slot after the bare package id, because create_full_pkg_id only read LockfileResolution::integrity(), which is None for every custom resolution. A custom resolver that records a new integrity for the same name@version therefore kept its old slot, and node_modules kept the old files under enableGlobalVirtualStore. The slot id now uses the custom resolver's integrity string, or a hash of the whole resolution when it has none, as pnpm 11's createFullPkgId does. The side-effects dep graph shares the same helper, so its key for a custom resolution with an integrity matches pnpm 11 too. LockfileResolution::custom_integrity() replaces the private helper in cache_keys.rs and the CustomResolution::integrity() accessor, so the reuse check and both slot ids read the value the same way. The changeset from pnpm#15673 said GVS installs still kept the old files. It is not released yet, so it now covers both layouts. Co-Authored-By: Claude Opus 5.5 <[email protected]>

Summary
Closes #15670
A custom resolver can return a new
integrityfor the samename@version, andshouldRefreshResolutionlets it do so on a later install. pnpm 12 wrote the new integrity to the lockfile but never called the custom fetcher. It kept the old files innode_modulesand printed "Already up to date". pnpm 11 re-fetches in the same situation.Root cause.
LockfileResolution::integrity()returnsNoneforCustomresolutions, because their integrity belongs to the custom fetcher rather than to the built-in verification.integrity_equalindeps-restorer/src/create_virtual_store/cache_keys.rscompared integrities only through that accessor. Two checks decide whether an existing virtual-store slot can be reused:current_entry_unchanged(plan pass) andpackage_content_changed(link pass). Both callintegrity_equal, so both sawNone == Noneand kept the stale slot.Fix.
integrity_equalnow also compares theintegrityfield a custom resolution records. Built-in verification still treats custom integrity as opaque, andLockfileResolution::integrity()is unchanged. This matches pnpm 11'sisIntegrityEqual(pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts), which reads theintegrityfield of any resolution.This is a v12-only bug, so there is no v11 change.
Not covered here:
enableGlobalVirtualStore: true, the stale slot is still kept. The GVS slot path comes fromcreate_full_pkg_id(virtual_store_layout/graph_hash.rs), which falls back to the bare package id whenintegrity()isNone. A changed custom integrity therefore maps to the same slot. pnpm 11'screateFullPkgIduses the customintegritythere, so this is a separate parity gap. Fixing it changes on-disk GVS slot paths, so I kept it out of this PR.shouldRefreshResolutionsilently under the defaultoptimisticRepeatInstall: true, where pnpm 11 warns. That is a separate change and is not included.Testing
V1after the second install, and 11.28.0 installsV2. A debug build of this branch installsV2.custom_resolvers::changed_custom_resolution_integrity_re_imports_the_packagemirrors the issue's script. It fails onmain(left: "V1", right: "V2") and passes with the fix.integrity_equal_compares_custom_resolution_integrities. It fails without the fix and passes with it.pnpm test:rust-affected: 5254 passed.pnpm check:rust,pnpm lint:rust,typos, and the pinned rustfmt all pass.cargo dylintwas not run locally.This PR was written with the help of an AI agent (Claude Code).
Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
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-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
pnpm installnow re-fetches a package when a custom resolver reports a changed integrity value, updating the package files innode_modulesto match. WhenenableGlobalVirtualStoreis enabled, the previous files are retained.