Repository navigation
fix(peers): reuse cached owner during finalization - #14451
Conversation
PR Summary by QodoReuse cached peer owners when finalizing cyclic alias graphs
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
🚧 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; 7 remain after this review. 📝 WalkthroughWalkthroughThe resolver now tracks the fully walked owner of cached peer resolutions and canonicalizes reused node IDs during final dependency-path generation. Unit and hoisted-linker tests cover cyclic npm aliases and frozen lockfile replay. A patch changeset documents the fix. ChangesCyclic peer cache resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR corrects cached peer-owner canonicalization for cyclic aliased dependency graphs and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Walker
participant PeerCache
participant Finalizer
participant FrozenInstall
Walker->>PeerCache: cache peer verdict with owner node
PeerCache-->>Walker: reuse verdict and owner node
Walker->>Finalizer: finalize reused occurrence
Finalizer->>Finalizer: resolve through cache owner
Finalizer-->>FrozenInstall: emit canonical depPath
FrozenInstall->>FrozenInstall: replay lockfile
Assessment against linked issues
Possibly related PRs
Suggested labels: ✨ 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 |
Code Review by Qodo
1.
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "fix(peers): detect peer cycles through c..." | Re-trigger Greptile |
|
Code review by qodo was updated up to the latest commit 256bc20 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14451 +/- ##
=======================================
Coverage 88.85% 88.86%
=======================================
Files 703 703
Lines 125944 125961 +17
=======================================
+ Hits 111912 111930 +18
+ Misses 14032 14031 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.50629971546,
"stddev": 0.07025781956413735,
"median": 2.50609283436,
"user": 1.64276266,
"system": 1.46583856,
"min": 2.41011848836,
"max": 2.64374059036
},
{
"command": "pacquet@main",
"mean": 2.41633426246,
"stddev": 0.09543833663945228,
"median": 2.38142806136,
"user": 1.51638546,
"system": 1.3553886599999996,
"min": 2.33676443636,
"max": 2.57674597636
},
{
"command": "pnpr@HEAD",
"mean": 1.39718851616,
"stddev": 0.12362489166177061,
"median": 1.34568249786,
"user": 1.07492776,
"system": 1.2210029599999999,
"min": 1.28097889336,
"max": 1.59821113936
},
{
"command": "pnpr@main",
"mean": 1.36079976146,
"stddev": 0.09324873129475636,
"median": 1.31079875836,
"user": 1.09557016,
"system": 1.2299318600000002,
"min": 1.28468933836,
"max": 1.52946948136
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.20634661436000004,
"stddev": 0.0053104402266169,
"median": 0.20518953176000002,
"user": 0.20798634,
"system": 0.5021170999999999,
"min": 0.20033308426000002,
"max": 0.21567170226000001
},
{
"command": "pacquet@main",
"mean": 0.21140679986000005,
"stddev": 0.011220234149849705,
"median": 0.21138861576,
"user": 0.22074633999999996,
"system": 0.49950610000000006,
"min": 0.18893174626000003,
"max": 0.23044777626000001
},
{
"command": "pnpr@HEAD",
"mean": 0.23060278006000004,
"stddev": 0.00561561584392017,
"median": 0.23084098326000002,
"user": 0.20656864000000003,
"system": 0.5257783999999999,
"min": 0.22235802526000004,
"max": 0.24201559726000002
},
{
"command": "pnpr@main",
"mean": 0.22899358606000003,
"stddev": 0.00809483558782477,
"median": 0.22677006426000001,
"user": 0.22598264,
"system": 0.5117603,
"min": 0.22110933426,
"max": 0.24866811526000002
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.0062225705594936625,
"stddev": 0.00039816496530175097,
"median": 0.0062068936,
"user": 0.0038476194936708846,
"system": 0.0027906058227848106,
"min": 0.0053672006,
"max": 0.0082701926
},
{
"command": "pacquet@main",
"mean": 0.006044007533842237,
"stddev": 0.0005709415817077386,
"median": 0.0059427196,
"user": 0.0036769968956742965,
"system": 0.0027259765903307875,
"min": 0.0053211656,
"max": 0.0097065636
},
{
"command": "pnpr@HEAD",
"mean": 0.006720908298005699,
"stddev": 0.00040121645645441813,
"median": 0.0067025636,
"user": 0.004111098176638174,
"system": 0.0030686162393162397,
"min": 0.0056937936,
"max": 0.0086355066
},
{
"command": "pnpr@main",
"mean": 0.006766900853846149,
"stddev": 0.00046276992273528453,
"median": 0.0067010201,
"user": 0.0040369215384615355,
"system": 0.003179250769230769,
"min": 0.0056724626,
"max": 0.0086424096
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.006509937644561401,
"stddev": 0.0003579333392562921,
"median": 0.00648917532,
"user": 0.0038976540350877187,
"system": 0.0029655527485380104,
"min": 0.00583784882,
"max": 0.008751700820000001
},
{
"command": "pacquet@main",
"mean": 0.006623379090270268,
"stddev": 0.00047865948718181224,
"median": 0.00653351382,
"user": 0.0040457216816816854,
"system": 0.0029624066066066047,
"min": 0.00581584782,
"max": 0.00889843482
},
{
"command": "pnpr@HEAD",
"mean": 0.007082899905808583,
"stddev": 0.0005147715307971659,
"median": 0.0070253348200000005,
"user": 0.00412775287128713,
"system": 0.0034090195379537975,
"min": 0.00560913082,
"max": 0.009290660820000001
},
{
"command": "pnpr@main",
"mean": 0.00716835213730769,
"stddev": 0.00040984829101321774,
"median": 0.00715053982,
"user": 0.004191716282051283,
"system": 0.0034240334615384615,
"min": 0.0061988958200000005,
"max": 0.009218494820000001
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.67861695824,
"stddev": 0.013724443495553598,
"median": 2.6839212254400002,
"user": 1.54311462,
"system": 1.2864601599999999,
"min": 2.65459665844,
"max": 2.69491880144
},
{
"command": "pacquet@main",
"mean": 2.6729818939400003,
"stddev": 0.014380505329682275,
"median": 2.67286323794,
"user": 1.56280472,
"system": 1.2550714599999995,
"min": 2.64478941244,
"max": 2.69373895944
},
{
"command": "pnpr@HEAD",
"mean": 1.5057276700400002,
"stddev": 0.14545268918965706,
"median": 1.4523939934399999,
"user": 1.07196312,
"system": 1.20835786,
"min": 1.37102916244,
"max": 1.72715436644
},
{
"command": "pnpr@main",
"mean": 1.5116951443399997,
"stddev": 0.10277304644539963,
"median": 1.49810551844,
"user": 1.0040600200000003,
"system": 1.23418466,
"min": 1.38555662744,
"max": 1.74227749844
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35071265536000007,
"stddev": 0.017668343164440166,
"median": 0.34261798686,
"user": 0.39792204,
"system": 0.5775071599999999,
"min": 0.33062287336000007,
"max": 0.37348483936000004
},
{
"command": "pacquet@main",
"mean": 0.36646245006000006,
"stddev": 0.012268861331738053,
"median": 0.3668862163600001,
"user": 0.40858064,
"system": 0.59826856,
"min": 0.34524328336000004,
"max": 0.38756035736000005
},
{
"command": "pnpr@HEAD",
"mean": 0.25122054556000006,
"stddev": 0.0070038556056158385,
"median": 0.25330519636000004,
"user": 0.16926734,
"system": 0.4422680600000001,
"min": 0.24236703736,
"max": 0.26001735536000004
},
{
"command": "pnpr@main",
"mean": 0.25330995466000006,
"stddev": 0.008687529836617813,
"median": 0.25198714136000006,
"user": 0.16133544,
"system": 0.46364365999999996,
"min": 0.24217006936000002,
"max": 0.27091642036
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.80533407556,
"stddev": 0.017838867399611887,
"median": 1.80679854716,
"user": 0.6350571599999999,
"system": 0.6703059,
"min": 1.7829485656600002,
"max": 1.8324576086600002
},
{
"command": "pacquet@main",
"mean": 1.81806409786,
"stddev": 0.011986703803389405,
"median": 1.8178738116600002,
"user": 0.6344464599999999,
"system": 0.6797273,
"min": 1.79945556066,
"max": 1.8431705946599999
},
{
"command": "pnpr@HEAD",
"mean": 0.28103942216,
"stddev": 0.01867375840021756,
"median": 0.28003719566,
"user": 0.20441476,
"system": 0.4796055,
"min": 0.25937706266,
"max": 0.31887062766
},
{
"command": "pnpr@main",
"mean": 0.28071969576,
"stddev": 0.018512204488740143,
"median": 0.27642503166,
"user": 0.19281726000000002,
"system": 0.5157205,
"min": 0.25958451066,
"max": 0.31373788766
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24707546980545458,
"stddev": 0.016038350505696054,
"median": 0.24753328826,
"user": 0.21066942545454548,
"system": 0.057526374545454534,
"min": 0.22393762826,
"max": 0.27686793226000006
},
{
"command": "pacquet@main",
"mean": 0.24314840692666664,
"stddev": 0.018167081704059652,
"median": 0.24018318326,
"user": 0.21263213,
"system": 0.06687191999999999,
"min": 0.21825269326000002,
"max": 0.28262949026000006
},
{
"command": "pnpr@HEAD",
"mean": 0.09844689515285716,
"stddev": 0.002510642800672492,
"median": 0.09754811426000001,
"user": 0.03589723714285714,
"system": 0.013926705714285713,
"min": 0.09437100526000002,
"max": 0.10398308926000001
},
{
"command": "pnpr@main",
"mean": 0.09722905501862068,
"stddev": 0.0018767698393916392,
"median": 0.09730224826000002,
"user": 0.033509638620689654,
"system": 0.014978713103448275,
"min": 0.09238060526000001,
"max": 0.10167295926000001
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5868620322111112,
"stddev": 0.13455796108366264,
"median": 0.5873842661,
"user": 0.5802898133333333,
"system": 0.12439363777777775,
"min": 0.3452437751,
"max": 0.7790639021000001
},
{
"command": "pacquet@main",
"mean": 0.6889125655444445,
"stddev": 0.12623394369740526,
"median": 0.7271944471,
"user": 0.6804747022222223,
"system": 0.13646663777777776,
"min": 0.4989314121,
"max": 0.8861505081000001
},
{
"command": "pnpm@HEAD",
"mean": 2.9734550237666664,
"stddev": 0.12774290037303918,
"median": 2.8997235061,
"user": 4.54586448,
"system": 0.27217285999999996,
"min": 2.8445186301,
"max": 3.1619568231
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.54951115844,
"stddev": 0.17477407778814344,
"median": 4.47565874644,
"user": 1.9044407799999998,
"system": 1.6614404,
"min": 4.3911579304399995,
"max": 4.88778704644
},
{
"command": "pacquet@main",
"mean": 4.553210502640001,
"stddev": 0.17683202320189784,
"median": 4.46256355044,
"user": 1.72388098,
"system": 1.6046333000000002,
"min": 4.40302687144,
"max": 4.84267884644
},
{
"command": "pnpr@HEAD",
"mean": 3.4801185658400002,
"stddev": 0.08199602232939032,
"median": 3.4710149069400003,
"user": 1.2529960800000002,
"system": 1.3962157,
"min": 3.36602015944,
"max": 3.6006072804400002
},
{
"command": "pnpr@main",
"mean": 3.4460400685400012,
"stddev": 0.126251444751017,
"median": 3.38493084144,
"user": 1.31191048,
"system": 1.4196629,
"min": 3.3537833754400004,
"max": 3.7442150624400004
}
]
}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. Comparable to that scenario head-to-head.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.1677188168258823,
"stddev": 0.021905752102728968,
"median": 0.16210677712,
"user": 0.22491334705882354,
"system": 0.1939771764705882,
"min": 0.14375212812,
"max": 0.21599251312
},
{
"command": "pacquet@main",
"mean": 0.17633478905749997,
"stddev": 0.015717320502457117,
"median": 0.17055596711999998,
"user": 0.22303751249999998,
"system": 0.21158425000000003,
"min": 0.15521357512,
"max": 0.21151119112
},
{
"command": "pnpr@HEAD",
"mean": 0.17860143865333333,
"stddev": 0.011517575718225264,
"median": 0.17357857212,
"user": 0.22087363333333332,
"system": 0.19668726666666664,
"min": 0.16652207412,
"max": 0.20455142512
},
{
"command": "pnpr@main",
"mean": 0.17478437578666667,
"stddev": 0.007296704039090895,
"median": 0.17676516511999998,
"user": 0.2162609666666667,
"system": 0.1913983999999999,
"min": 0.16267275812,
"max": 0.18371462412
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/14451 |
| 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) |
|---|---|---|
| gvs-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 166.52 ms |
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,371.03 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 259.38 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 242.37 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 94.37 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,280.98 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,366.02 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 222.36 ms |
| isolated-linker.repeat-install.cold-cache.hot-store | 📈 view plot | 5.61 ms |
| isolated-linker.repeat-install.hot-cache.hot-store | 📈 view plot | 5.69 ms |
Track the fully walked occurrence that produced each peer-cache entry. Treat every cache hit as the same semantic node during final depPath and SCC lookup, while preserving aliases on dependency edges. This prevents finalization from writing references to peer-qualified snapshots that were never emitted. Closes pnpm#14449.
The finalizer canonicalized a cache-hit occurrence to its owner when it looked up peer-graph SCCs, but still built the SCC table from raw occurrence ids. A peer edge that targets the hit occurrence therefore landed in a different component than the owner, so the cycle was not collapsed and the lockfile key depended on the order of the direct dependencies. Build the SCC table over cache owners, assert that an owner is never a cache hit itself, and cover the walk order in which the hit occurrence is the peer target. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01ALFhydtRaoShFmsRNUsFcQ
256bc20 to
48d92a3
Compare
|
Code review by qodo was updated up to the latest commit 48d92a3 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Summary
resolvePeers.tsrecordspeersCacheOwnerByNodeIdand a cache hit awaits the owner'sdepPathpromise, so the hit inherits the owner's final depPath. pacquet's post-walk finalizer lacked that step.Fixes #14449.
Reproduction: zhsama/pnpm12-hoisted-cyclic-alias-peer-repro
Design
A peer-cache hit is a claim that the reused occurrence has the same peer-resolution semantics as the occurrence that produced the cache entry. The finalizer must therefore use the same semantic node identity. If an occurrence requires a distinct long-form peer key, the cache match is invalid and it must be fully walked instead.
PeersCacheItemnow carries its producer NodeId. A cache hit recordsoccurrence -> owner, and final depPath construction, graph edge rendering, and SCC comparisons resolve through that owner. The occurrence remains distinct in the dependency tree, and aliases remain on dependency edges; only final peer-graph identity is shared.This fixes the producer/consumer mismatch directly rather than removing the existing lockfile fallback or adding another production validation pass. The end-to-end frozen replay test guards the observable closure invariant.
Validation
node pnpm/scripts/run-rust-tests.mjs --no-fail-fast -j 8: 9793 passed, 5 skipped, 0 failed.Squash Commit Body
Checklist
pacquetpatch changeset.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests