Repository navigation
Conversation
Occurrences of one package race for the children-ownership claim. A worse-ranked occurrence that arrives while the claim is vacant walks the package's children and records them, resolved under its own level's preferred-versions overlay; when the deterministically better-placed occurrence claims afterwards it kept those children, because the overlay was left out of the recorded resolution context. Which occurrence got there first is thread timing, so identical inputs produced different lockfiles run to run (issue #13685). Record the overlay projected down to the names the package's child edges look up — the whole of the overlay a child's version pick can read — as part of that context. A later owner then keeps the recording only when its own level offers those edges the same versions, and walks them again otherwise, so the children settle on the ranked owner's answer. The re-walk stays bounded: it stops descending wherever the projections agree, unlike the full re-walk on every claim win reverted in #13574. Verified on the issue's `@teambit/bit` repro (offline, warm cache): 8 identical resolves produced 2 distinct lockfiles before and 8 identical ones after, at ~25% more resolve time on that graph (4.4s -> 5.4s), half of it the projection and half the added walks. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe resolver now includes preferred-version overlays in recorded-child reuse matching. Child traversal derives overlay views before reuse checks. Regression tests cover concurrent traversal and deterministic child pinning. ChangesDeterministic dependency resolution
Estimated code review effort: 4 (Complex) | ~45 minutes Assessment against linked issues
Sequence Diagram(s)sequenceDiagram
participant Occurrence
participant ChildSpecResolver
participant OverlayView
participant RecordedChildren
participant DependencyWalker
Occurrence->>ChildSpecResolver: prepare child specs
Occurrence->>OverlayView: derive preferred versions
Occurrence->>RecordedChildren: compare recorded context
RecordedChildren-->>Occurrence: reuse or rewalk
Occurrence->>DependencyWalker: resolve child edges when context differs
Possibly related PRs
Suggested labels: ✨ 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 QodoFix resolver nondeterminism by scoping recorded children to owner overlay
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "test(resolver): order the contested-chil..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pnpm/crates/resolving-deps-resolver/src/tests.rs (1)
446-448: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReplace
dbg!witheprintln!before the assertion.
dbg!prints on every run, including passing runs, and adds file and line noise. The code style guide asks for logging complex values witheprintln!before a non-equality assertion so the failure output is readable.♻️ Proposed change
- dbg!(shared_children); + eprintln!("SHARED CHILDREN:\n{shared_children:#?}\n"); assert_eq!(shared_children.len(), 1);Based on learnings, pnpm Rust tests log rendered values with
eprintln!before the assertion rather than usingdbg!. As per path instructions, pnpm/CODE_STYLE_GUIDE.md states "log complex values before non-equality assertions".🤖 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/resolving-deps-resolver/src/tests.rs` around lines 446 - 448, In the test around shared_children, replace the dbg!(shared_children) diagnostic with an eprintln! that renders the value before the existing assertions. Keep the assertions and their order unchanged.Sources: Path instructions, Learnings
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs (1)
533-546: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThe new
overlay_viewequality term has no deterministic test guarding it.produces_same_children_asgained a fourth comparison term, but the unit test never variesoverlay_view, and the only test that exercises the term end to end depends on a 50 ms wall-clock sleep to create the race. If the interleaving does not occur on a loaded machine, both tests still pass with the term removed.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs#L533-L546: add aRecordedChildrenContextcase with a non-emptyoverlay_viewand assertrecorded_children_matchreturnsfalse, alongside the existing shadow-set, update-policy, and snapshot-key cases.pnpm/crates/resolving-deps-resolver/src/tests.rs#L329-L330: confirmdeeper_occurrences_children_are_rewalked_by_the_ownerfails on the pre-fix commit, and make the intended interleaving observable so a run that misses the race fails instead of passing silently.As per path instructions, REVIEW_GUIDE.md requires "a meaningful regression test that fails without the fix".
🤖 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/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs` around lines 533 - 546, The equality test around recorded_children_match must explicitly vary overlay_view and assert a non-empty overlay view returns false; update pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs:533-546 alongside the existing context-mismatch cases. Strengthen deeper_occurrences_children_are_rewalked_by_the_owner at pnpm/crates/resolving-deps-resolver/src/tests.rs:329-330 so the intended interleaving is deterministic and the test fails when the overlay_view comparison is removed, rather than relying on a wall-clock sleep that can miss the race.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs`:
- Around line 533-546: The equality test around recorded_children_match must
explicitly vary overlay_view and assert a non-empty overlay view returns false;
update
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs:533-546
alongside the existing context-mismatch cases. Strengthen
deeper_occurrences_children_are_rewalked_by_the_owner at
pnpm/crates/resolving-deps-resolver/src/tests.rs:329-330 so the intended
interleaving is deterministic and the test fails when the overlay_view
comparison is removed, rather than relying on a wall-clock sleep that can miss
the race.
In `@pnpm/crates/resolving-deps-resolver/src/tests.rs`:
- Around line 446-448: In the test around shared_children, replace the
dbg!(shared_children) diagnostic with an eprintln! that renders the value before
the existing assertions. Keep the assertions and their order unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5023c73d-7bb7-4758-8d73-5e293283c50e
📒 Files selected for processing (6)
.changeset/deterministic-contested-children.mdpnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rspnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rspnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rspnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rspnpm/crates/resolving-deps-resolver/src/tests.rs
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13830 +/- ##
========================================
Coverage 88.22% 88.23%
========================================
Files 625 625
Lines 102636 102839 +203
========================================
+ Hits 90555 90744 +189
- Misses 12081 12095 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`start_paused` advances the clock only once the runtime has nothing else to run, so the delayed branch resumes after the other one has walked and recorded rather than after a wall-clock margin that CI load can eat. Drops the `dbg!` the scalar assertions do not need, and the scenario prose the table and the assertions already carry. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Review round-up for the four findings, addressed in 53b81fc where they were actionable. 1. Sleep-based test flakiness / 2. Changeset omits a 3. Overlay-view overhead — real, measured, and disclosed. The projection is roughly half the ~23 % resolve-time cost reported in the PR description (measured by computing it and excluding it from the comparison); the other half is the added walks, which are the fix. 4. Not cross-synced with the TypeScript CLI — intended. Children ownership, the claim ranking and Written by an agent (Claude Code, claude-opus-5[1m]). |
|
Code review by qodo was updated up to the latest commit 53b81fc |
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.5339454574599998,
"stddev": 0.17203408434716716,
"median": 2.4713777954599996,
"user": 1.5761179999999997,
"system": 1.289505,
"min": 2.36853909446,
"max": 2.78105032646,
"times": [
2.75590214146,
2.78105032646,
2.3874220454599997,
2.37301162246,
2.4966942524599998,
2.36853909446,
2.71002382346,
2.36880894246,
2.6519409874599997,
2.44606133846
]
},
{
"command": "pacquet@main",
"mean": 2.4963724172600004,
"stddev": 0.16753073104349217,
"median": 2.40886257296,
"user": 1.5386581,
"system": 1.327722,
"min": 2.3554866134599997,
"max": 2.7841854094599996,
"times": [
2.44176983246,
2.52394852546,
2.7092577834599996,
2.68032838146,
2.3554866134599997,
2.3590406434599998,
2.7841854094599996,
2.37438915146,
2.35936251846,
2.37595531346
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6087128493600003,
"stddev": 0.16615709471527895,
"median": 1.66013765596,
"user": 1.0397523999999998,
"system": 1.1427956000000001,
"min": 1.35768748746,
"max": 1.8153267374600002,
"times": [
1.54428064846,
1.35768748746,
1.8153267374600002,
1.7242149344600002,
1.7452637454600002,
1.6877114964600002,
1.45955390446,
1.75115465646,
1.63256381546,
1.3693710674600001
]
},
{
"command": "pnpr@main",
"mean": 1.5228488988600002,
"stddev": 0.15075448064055888,
"median": 1.53836727446,
"user": 1.0600473999999998,
"system": 1.1401763999999999,
"min": 1.35716782146,
"max": 1.69939793946,
"times": [
1.69208889246,
1.69939793946,
1.36349141646,
1.6688575894600002,
1.38193341746,
1.62913648446,
1.45992222746,
1.61681232146,
1.35716782146,
1.35968087846
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25006593378,
"stddev": 0.009420415448721891,
"median": 0.24974034418000002,
"user": 0.21310120000000002,
"system": 0.5006881199999998,
"min": 0.23490004118000002,
"max": 0.26349399618,
"times": [
0.25935803618000003,
0.25258294918,
0.26117806518000003,
0.26349399618,
0.25099366318000005,
0.23905906318000003,
0.24421887718000002,
0.23490004118000002,
0.24638762118000002,
0.24848702518000002
]
},
{
"command": "pacquet@main",
"mean": 0.25438328008,
"stddev": 0.008243793112528229,
"median": 0.25416925418,
"user": 0.21111899999999997,
"system": 0.52170202,
"min": 0.23976714318000003,
"max": 0.26996275718,
"times": [
0.25484426718000003,
0.25850353018000005,
0.25100593618,
0.25349424118,
0.26064578618,
0.25294992918000003,
0.26996275718,
0.25707331518000004,
0.24558589518,
0.23976714318000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27190073318,
"stddev": 0.0042143044725916545,
"median": 0.27150253468,
"user": 0.22925209999999993,
"system": 0.5364195199999999,
"min": 0.26695721218,
"max": 0.27838332718000003,
"times": [
0.27743265918000004,
0.27277046218,
0.27838332718000003,
0.26695721218,
0.26834662118,
0.26728081018000005,
0.27023460718000003,
0.27357545418,
0.27536278218000004,
0.26866339618
]
},
{
"command": "pnpr@main",
"mean": 0.27106303838,
"stddev": 0.007682695557502602,
"median": 0.27251224668000007,
"user": 0.24755209999999997,
"system": 0.50781842,
"min": 0.25384464818,
"max": 0.28223934018,
"times": [
0.27890776118000005,
0.28223934018,
0.26693479018000005,
0.27296634018000004,
0.27333552318000004,
0.27360655218,
0.27205815318000004,
0.26787697918000003,
0.25384464818,
0.26886029618
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6333278610599997,
"stddev": 0.026472149152065493,
"median": 2.63453906426,
"user": 1.67102534,
"system": 1.3862373000000001,
"min": 2.59195024426,
"max": 2.67575876226,
"times": [
2.59195024426,
2.67575876226,
2.6175117812599997,
2.63611012026,
2.66819934026,
2.65049934026,
2.63296800826,
2.63706445226,
2.61744534026,
2.60577122126
]
},
{
"command": "pacquet@main",
"mean": 2.62995339916,
"stddev": 0.025442692645939905,
"median": 2.63036725226,
"user": 1.66351464,
"system": 1.4187459,
"min": 2.59064509726,
"max": 2.67861492226,
"times": [
2.63681446326,
2.64266114626,
2.60220392026,
2.62392004126,
2.59064509726,
2.61180807126,
2.67861492226,
2.62313180126,
2.63865199426,
2.65108253426
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6296185314600002,
"stddev": 0.14872385400558355,
"median": 1.60672225026,
"user": 1.2395896400000002,
"system": 1.3211539,
"min": 1.45738062226,
"max": 1.83063772426,
"times": [
1.52527049526,
1.78558410426,
1.83063772426,
1.49007346026,
1.6821977112600002,
1.45738062226,
1.53124678926,
1.81452396326,
1.47900310326,
1.70026734126
]
},
{
"command": "pnpr@main",
"mean": 1.69339986106,
"stddev": 0.18103216658863416,
"median": 1.69770301426,
"user": 1.30889254,
"system": 1.4038252999999998,
"min": 1.46463253226,
"max": 1.9268436152600001,
"times": [
1.60619028226,
1.48358267426,
1.76858117026,
1.8530127032600001,
1.89802545826,
1.62682485826,
1.46463253226,
1.9268436152600001,
1.82021932026,
1.48608599626
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.46473960546000004,
"stddev": 0.018425281636722933,
"median": 0.47027861796000003,
"user": 0.6231472600000001,
"system": 0.74372312,
"min": 0.43056423046000003,
"max": 0.48455796346,
"times": [
0.47436256346,
0.43056423046000003,
0.46619467246,
0.48455796346,
0.47778130446,
0.46475287346,
0.47781093146000003,
0.47985520046,
0.45317298446,
0.43834333046
]
},
{
"command": "pacquet@main",
"mean": 0.4503873435600001,
"stddev": 0.029661806576752485,
"median": 0.44551099396000005,
"user": 0.6439779599999998,
"system": 0.70080652,
"min": 0.41676938946000003,
"max": 0.51022511246,
"times": [
0.41676938946000003,
0.42514623346,
0.41956545146,
0.45946546446000003,
0.45075388146,
0.46400369746000003,
0.51022511246,
0.48236885146,
0.43530724746,
0.44026810646000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.38265519016,
"stddev": 0.042306559241195314,
"median": 0.37271991946,
"user": 0.27611775999999993,
"system": 0.6261218199999999,
"min": 0.33227323646,
"max": 0.43354886546,
"times": [
0.33444992346,
0.33227323646,
0.43354886546,
0.34141437546,
0.36238377046,
0.42790852246,
0.43139601146,
0.42177209646,
0.38305606846,
0.35834903146
]
},
{
"command": "pnpr@main",
"mean": 0.40757264326,
"stddev": 0.033961488402325275,
"median": 0.39539481346,
"user": 0.30059295999999996,
"system": 0.68108232,
"min": 0.36505166146,
"max": 0.45806582546,
"times": [
0.40124437046,
0.37153884646,
0.38595031346,
0.42320358546000003,
0.38637594346,
0.36505166146,
0.45806582546,
0.45123042546000003,
0.38954525646,
0.44352020446
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.0056795422,
"stddev": 0.10666234515643902,
"median": 2.0223720136,
"user": 1.31304834,
"system": 1.0468677,
"min": 1.8269657326000002,
"max": 2.1433950846,
"times": [
2.0761511946,
2.0115949616,
1.8898148296000001,
1.8269657326000002,
1.8990404166000001,
1.9714044036000002,
2.0807565746,
2.1245231586,
2.1433950846,
2.0331490656
]
},
{
"command": "pacquet@main",
"mean": 2.1296623129,
"stddev": 0.0586180994677484,
"median": 2.1238430261000003,
"user": 1.5242204400000001,
"system": 1.1976730999999998,
"min": 2.0697359446,
"max": 2.2023363906,
"times": [
2.0710070226,
2.1661439916000003,
2.1856767296,
2.2021284896,
2.0697359446,
2.0722394566,
2.2023363906,
2.1627485956,
2.0796690516,
2.0849374566
]
},
{
"command": "pnpr@HEAD",
"mean": 0.4611739952999999,
"stddev": 0.06448237755195685,
"median": 0.44120495260000003,
"user": 0.35408683999999996,
"system": 0.7239488,
"min": 0.4049021516,
"max": 0.6162339056,
"times": [
0.4328968526,
0.4224313976,
0.4410855336,
0.4049021516,
0.4480040576,
0.4413243716,
0.6162339056,
0.4460783306,
0.5343846906,
0.4243986616
]
},
{
"command": "pnpr@main",
"mean": 0.42748727459999997,
"stddev": 0.013773306000124429,
"median": 0.4309431536,
"user": 0.34115503999999996,
"system": 0.7081543,
"min": 0.4051283066,
"max": 0.4431725226,
"times": [
0.4214839476,
0.4431725226,
0.4367252346,
0.4051283066,
0.4063021516,
0.4389966406,
0.4306824136,
0.4312038936,
0.4409683426,
0.4202092926
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.34720542812,
"stddev": 0.04264255191107285,
"median": 0.34068091662,
"user": 0.33576409999999995,
"system": 0.10527388,
"min": 0.28441902862,
"max": 0.41379628962000004,
"times": [
0.28441902862,
0.39687774362000006,
0.38336906962,
0.34717809462000004,
0.30865280462,
0.30940240262,
0.32332944062,
0.41379628962000004,
0.33418373862,
0.37084566862
]
},
{
"command": "pacquet@main",
"mean": 0.37076713962,
"stddev": 0.034351530312290574,
"median": 0.36630893662,
"user": 0.3552194,
"system": 0.11300878,
"min": 0.32811512962,
"max": 0.44095318862000005,
"times": [
0.38574481262000004,
0.32811512962,
0.36227875662000003,
0.36603000262,
0.33434144462000004,
0.33748536862,
0.44095318862000005,
0.36658787062000003,
0.38566567362000004,
0.40046914862000005
]
},
{
"command": "pnpr@HEAD",
"mean": 0.1288316033342857,
"stddev": 0.006557388805911507,
"median": 0.12819852062,
"user": 0.04312465238095237,
"system": 0.02162233238095238,
"min": 0.11650943462000002,
"max": 0.14210766662000002,
"times": [
0.13285975362000002,
0.13457969962000002,
0.12785215962000002,
0.13663909362,
0.13416950462000002,
0.12486664162000002,
0.12403020062000002,
0.11650943462000002,
0.12681888862000001,
0.12295696462000001,
0.13300449662000002,
0.14210766662000002,
0.13184734262,
0.12352804662000001,
0.12317522462000001,
0.13203191962000002,
0.12313888562000001,
0.12819852062,
0.11816997262000001,
0.13255213762,
0.13642711562
]
},
{
"command": "pnpr@main",
"mean": 0.12206334146615384,
"stddev": 0.007616015416981321,
"median": 0.12418074812000002,
"user": 0.0412920076923077,
"system": 0.016677303076923073,
"min": 0.10527538262000001,
"max": 0.13397596162,
"times": [
0.10702879562,
0.10527538262000001,
0.12417355962000001,
0.11086923062000001,
0.12566858762000002,
0.13397596162,
0.12407866162000002,
0.12029158762000002,
0.12877596362000002,
0.11284915962000001,
0.12440282062000002,
0.12148184362000002,
0.12436403762,
0.11636060462000002,
0.12811365062000002,
0.11252587162000001,
0.13256946962000002,
0.12436513962000001,
0.13053464762,
0.12224685162000001,
0.12604775062,
0.12917479362,
0.11791704862,
0.12418793662000001,
0.11722326462000002,
0.12914425662
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.6487654686355557,
"stddev": 0.31105035217684074,
"median": 1.6011321870800002,
"user": 1.6629376688888888,
"system": 0.2534747711111111,
"min": 1.1737954800800001,
"max": 2.26325672208,
"times": [
1.1737954800800001,
1.4134561630800002,
2.26325672208,
1.8401019810800001,
1.5376195640800001,
1.46605694008,
1.75449200108,
1.6011321870800002,
1.7889781790800001
]
},
{
"command": "pacquet@main",
"mean": 1.4598063016355556,
"stddev": 0.21662167287612394,
"median": 1.42182799908,
"user": 1.482655891111111,
"system": 0.24857210444444444,
"min": 1.2304011810800002,
"max": 1.8541599180800001,
"times": [
1.8541599180800001,
1.6747505030800003,
1.61939792708,
1.4868348500800002,
1.2834507880800001,
1.2304011810800002,
1.29593168308,
1.27150186508,
1.42182799908
]
},
{
"command": "pnpm@HEAD",
"mean": 5.823309111191111,
"stddev": 0.47691304872976437,
"median": 5.83420219908,
"user": 8.926150557777778,
"system": 0.48045577111111104,
"min": 5.17044929508,
"max": 6.48227241008,
"times": [
5.83420219908,
5.68556210008,
5.17044929508,
6.32465290708,
5.8591537780800005,
6.48227241008,
6.28438001708,
5.59643810508,
5.17267118908
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.9266563661,
"stddev": 0.2846297536434879,
"median": 4.8990537317000005,
"user": 2.91363934,
"system": 2.09453886,
"min": 4.5152032107,
"max": 5.5423304187,
"times": [
5.5423304187,
4.9015714207,
4.8965360427,
4.8016417197,
4.8876727217,
5.0231323607,
5.0330796557,
5.0814990747,
4.5838970357,
4.5152032107
]
},
{
"command": "pacquet@main",
"mean": 4.5610279143,
"stddev": 0.18909618689923138,
"median": 4.4539463781999995,
"user": 1.77082434,
"system": 1.38004696,
"min": 4.4204300357,
"max": 4.8638031417,
"times": [
4.4575957237,
4.4387666317,
4.4300777287,
4.4737863787,
4.4204300357,
4.8520630287,
4.8638031417,
4.4416319237,
4.4502970327,
4.7818275177
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5425512194,
"stddev": 0.08349798645052497,
"median": 3.5211080877,
"user": 1.1782311399999998,
"system": 1.20683006,
"min": 3.4497905737,
"max": 3.6848208487000003,
"times": [
3.4705942747,
3.4964845507,
3.5073414567,
3.6848208487000003,
3.4497905737,
3.5355880097,
3.4669502197,
3.5348747187000003,
3.6586153717,
3.6204521697
]
},
{
"command": "pnpr@main",
"mean": 3.5320939873,
"stddev": 0.062548488607984,
"median": 3.5169285662,
"user": 1.20545934,
"system": 1.22309896,
"min": 3.4590347007,
"max": 3.6426279187,
"times": [
3.6426279187,
3.6051823147,
3.4877431607,
3.4750829977,
3.4590347007,
3.5357206777,
3.4770567657,
3.5698631557000002,
3.5704917267000003,
3.4981364547
]
}
]
} |
Summary
Closes #13685.
Resolving the same project twice could produce different
pnpm-lock.yamlfiles. Occurrences of one package race for the children-ownership claim: a worse-ranked occurrence that arrives while the claim is vacant walks the package's children and records them, resolved under its own level's preferred-versions overlay. When the deterministically better-placed occurrence claims afterwards,recorded_children_matchwaved it through — the overlay was deliberately left out ofRecordedChildrenContext— so whichever occurrence's walk got there first decided the lockfile.#13714 fixed the neighbouring half of this (a re-recording now stales the other occurrences' realized children) and explicitly left the
recorded_children_matchearly return, the arrival-order dependence itself, untouched. This PR closes that.The recorded context now carries the overlay projected down to the names the package's child edges look the overlay up under (alias, plus the
npm:/jsr:target name — the same namesresolve_node_seedputs in the per-wanted resolve cache key). That projection is the whole of the overlay chain a child edge's version pick can read, so:Comparing the overlay chains instead would mean requiring identical parents, which racing occurrences never have. The re-walk stays bounded — it stops descending wherever the projections agree — unlike the full re-walk on every claim win that #13574 reverted for exponential blowup.
Verified on the issue's
@teambit/[email protected]repro (single importer,nodeLinker: hoisted,autoInstallPeers,dedupePeerDependents,peersSuffixMaxLength: 1000; offline, warm cache), repeatedrm -rf node_modules pnpm-lock.yaml && pnpm install --lockfile-only --ignore-scripts --offline:mainclassnamesandlodashflips from the issue)Repeat installs against the resulting lockfile are byte-stable, so the lockfile-reuse path does not churn. Storing the projections is not measurable in peak RSS.
The ~25% resolve-time cost on that graph splits about evenly between computing the projection (paid on every owner walk) and the added walks (the fix itself) — measured by running with the projection computed but excluded from the comparison. A follow-up could thread the projection out of the seed phase, which already computes the same per-child views for the resolve cache key, instead of recomputing it. All of this is on a deliberately pathological graph (~20k packages, peer-heavy,
peersSuffixMaxLength: 1000).Known residual: an occurrence only re-walks the children it records, so a subtree that stays lazy at every level below a matching projection is not re-checked against the owner's overlay. Closing that needs the projections of a whole subtree, not one level; the repro is deterministic across every run measured here.
Not mirrored in the TypeScript CLI: children ownership, the claim ranking and
children_by_idare pacquet's own machinery, with no counterpart inresolveDependencies.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[1m]).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests