Repository navigation
fix(resolver): process workspace importers in project-id order - #13895
Conversation
Children-owner claims rank by importer position, the hoist rounds run sequentially in list order, and shared canonical back-edge occurrences bind whichever importer's walk realizes them first — so the caller's importer listing order leaked into ownership, the first-walk missing scope, every auto-install decision, and cycle back-edge bindings (#13846). Both resolve_workspace and resolve_peers_workspace now sort importers by id up front, making the output a function of the importer set alone; per-importer options are still built in the caller's order first, so positional options callbacks keep lining up. An explicit reversed `packages` listing of the 5-importer bit fixture now produces a byte-identical lockfile, and both bit fixtures are byte-identical to the unsorted resolver's output — production callers already supply id-sorted importers, so this only pins what discovery order made incidental. Two tests that pinned a non-root importer walking before the root are re-pinned: deprecation attribution keys the first occurrence by id order, and the ownership-handover fixture routes the shared subtree through the peer-hoist round, which is the only way a handover can reach a root-first walk. Co-Authored-By: Claude Fable 5 <[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 (5)
📝 WalkthroughWalkthroughThe resolver now sorts workspace importers by ID before workspace and peer dependency processing. Tests verify stable graph keys, peer-cycle back-edge bindings, deprecation attribution, and lockfile results across importer input orders. ChangesImporter-order resolution invariance
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to The Rust v12 resolver now produces lockfiles and peer graphs independently of workspace importer listing order, while v11 intentionally keeps its existing behavior. The supplied tests and checks pass, so no actionable merge-blocking risk remains beyond normal review. Sequence Diagram(s)sequenceDiagram
participant WorkspaceResolver
participant PeerResolver
participant DependencyGraph
WorkspaceResolver->>PeerResolver: pass importers in ID order
PeerResolver->>DependencyGraph: resolve peers and reconstruct dependency paths
DependencyGraph-->>PeerResolver: return deterministic graph keys and cycle bindings
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 QodoCanonicalize workspace resolution by sorting importers by project id
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. Changeset missing pnpm entry
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13895 +/- ##
=======================================
Coverage 88.31% 88.31%
=======================================
Files 628 628
Lines 103990 103999 +9
=======================================
+ Hits 91835 91846 +11
+ Misses 12155 12153 -2 ☔ 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.68449869562,
"stddev": 0.12699167251521903,
"median": 2.63965398772,
"user": 2.3483153399999996,
"system": 1.9807446399999997,
"min": 2.56421849372,
"max": 2.95460435172,
"times": [
2.61146021072,
2.59363278172,
2.60311794372,
2.56421849372,
2.70914612872,
2.59612051272,
2.66784776472,
2.95460435172,
2.85411382272,
2.69072494572
]
},
{
"command": "pacquet@main",
"mean": 2.7484524711199994,
"stddev": 0.16314709006267344,
"median": 2.65673485672,
"user": 2.2257044400000003,
"system": 1.94907334,
"min": 2.5736727947199998,
"max": 2.97927522472,
"times": [
2.91611315472,
2.90084004072,
2.65225881072,
2.66121090272,
2.58069891172,
2.6408916687199997,
2.93878246272,
2.64078073972,
2.97927522472,
2.5736727947199998
]
},
{
"command": "pnpr@HEAD",
"mean": 1.63046199232,
"stddev": 0.17678861063744739,
"median": 1.57325258572,
"user": 1.47323734,
"system": 1.5405630399999999,
"min": 1.43454977172,
"max": 1.85795086272,
"times": [
1.59616516072,
1.5503400107199998,
1.44178019472,
1.82068524772,
1.43454977172,
1.84750770572,
1.78217138072,
1.47381148372,
1.85795086272,
1.49965810472
]
},
{
"command": "pnpr@main",
"mean": 1.67788122982,
"stddev": 0.17653336826688645,
"median": 1.6894340367199998,
"user": 1.50819274,
"system": 1.64626564,
"min": 1.4828422507199999,
"max": 1.91346714272,
"times": [
1.60673861872,
1.83532123072,
1.84030640172,
1.4892037867199999,
1.4828422507199999,
1.8342789607199999,
1.4959948917199999,
1.50852955972,
1.91346714272,
1.77212945472
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.34305651041999996,
"stddev": 0.009419812026702452,
"median": 0.34137895922,
"user": 0.26986005999999996,
"system": 0.6444894999999999,
"min": 0.33203293922,
"max": 0.36259644222000004,
"times": [
0.35540565722,
0.34281062522,
0.33778464622,
0.34446289522,
0.34184170222,
0.33203293922,
0.34091621622,
0.36259644222000004,
0.33343196422,
0.33928201622000004
]
},
{
"command": "pacquet@main",
"mean": 0.34675594162,
"stddev": 0.018271904663299886,
"median": 0.33666142622000006,
"user": 0.26946795999999995,
"system": 0.6767272999999999,
"min": 0.33068780822,
"max": 0.38813719022000004,
"times": [
0.33353281822,
0.33650692922000003,
0.33681592322000004,
0.35196994322,
0.33552716622,
0.33524278922,
0.35502640322,
0.38813719022000004,
0.36411244522,
0.33068780822
]
},
{
"command": "pnpr@HEAD",
"mean": 0.36066735072000006,
"stddev": 0.013599688171136964,
"median": 0.36304944422,
"user": 0.26732825999999993,
"system": 0.6572508,
"min": 0.33915825722000004,
"max": 0.38172682322,
"times": [
0.33915825722000004,
0.35065790522,
0.36438289322,
0.38172682322,
0.37697314822,
0.36804312522,
0.36268535422000003,
0.36341353422,
0.35602262022000003,
0.34360984622
]
},
{
"command": "pnpr@main",
"mean": 0.35400624131999997,
"stddev": 0.012910424391821496,
"median": 0.35498431922,
"user": 0.28221145999999997,
"system": 0.6530462,
"min": 0.32426860422000003,
"max": 0.37789646422,
"times": [
0.35670652122,
0.35003604322000004,
0.37789646422,
0.35300499422000003,
0.32426860422000003,
0.35447009722,
0.35408183622,
0.35697011722,
0.35549854122,
0.35712919422
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.85383519768,
"stddev": 0.023575182730014316,
"median": 2.85772886348,
"user": 1.8943112599999998,
"system": 1.8518040399999998,
"min": 2.81841534498,
"max": 2.8946537129800003,
"times": [
2.81841534498,
2.8946537129800003,
2.8234682809800002,
2.8568939439800003,
2.8789708649800003,
2.83572315898,
2.84834376998,
2.86440511798,
2.85856378298,
2.8589139989800003
]
},
{
"command": "pacquet@main",
"mean": 2.8634331028800006,
"stddev": 0.06569134428028547,
"median": 2.83714623998,
"user": 1.9872652599999996,
"system": 1.7907077399999998,
"min": 2.81067441198,
"max": 3.0251963719800004,
"times": [
2.8317789619800005,
2.8126457459800003,
2.81067441198,
2.8296947129800003,
2.83895485598,
2.91775014898,
2.8459737999800003,
2.83533762398,
2.88632439498,
3.0251963719800004
]
},
{
"command": "pnpr@HEAD",
"mean": 1.7886373677800003,
"stddev": 0.1227513294968571,
"median": 1.7332654719799998,
"user": 1.6271007599999998,
"system": 1.7977135399999997,
"min": 1.63481459298,
"max": 1.97820741298,
"times": [
1.7013805659799999,
1.94371544798,
1.97820741298,
1.74935907398,
1.63481459298,
1.78625235698,
1.71290842098,
1.7171718699799998,
1.71228195898,
1.95028197698
]
},
{
"command": "pnpr@main",
"mean": 1.8177894495799998,
"stddev": 0.1838242097905827,
"median": 1.79478623048,
"user": 1.63661416,
"system": 1.8157325399999997,
"min": 1.55044626098,
"max": 2.07848717998,
"times": [
1.79589070598,
2.05218895298,
1.7371442659799998,
1.79368175498,
1.91907457998,
1.55044626098,
1.60515938798,
2.07848717998,
1.6701753279799998,
1.9756460789799999
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7071434776200001,
"stddev": 0.07875161292579914,
"median": 0.7170630267200001,
"user": 0.9205304,
"system": 1.1623177400000002,
"min": 0.5930175132200001,
"max": 0.8508221052200001,
"times": [
0.74472403222,
0.7313698512200001,
0.7775711542200001,
0.6978171822200001,
0.5930175132200001,
0.7212704282200001,
0.6245959292200001,
0.7128556252200001,
0.8508221052200001,
0.6173909552200001
]
},
{
"command": "pacquet@main",
"mean": 0.67246714402,
"stddev": 0.06468656776988821,
"median": 0.6641948212200001,
"user": 0.9368055,
"system": 1.0773678400000002,
"min": 0.5644235092200001,
"max": 0.8109435542200001,
"times": [
0.5644235092200001,
0.69778291522,
0.8109435542200001,
0.6666863462200001,
0.65376306922,
0.66170329622,
0.6097800412200001,
0.7033114972200001,
0.6591039192200001,
0.69717329222
]
},
{
"command": "pnpr@HEAD",
"mean": 0.39541864772000007,
"stddev": 0.01776010415993772,
"median": 0.38636028272000006,
"user": 0.23891819999999994,
"system": 0.69146464,
"min": 0.38141922322000005,
"max": 0.43041832522000006,
"times": [
0.43041832522000006,
0.41960041822000005,
0.40849744522000003,
0.3936860152200001,
0.38258906522,
0.38256774322000003,
0.38760243422000007,
0.38511813122000005,
0.38141922322000005,
0.38268767622000005
]
},
{
"command": "pnpr@main",
"mean": 0.37550454732,
"stddev": 0.00870726438613025,
"median": 0.37179789122000007,
"user": 0.24059399999999997,
"system": 0.6346534399999999,
"min": 0.36495930322000003,
"max": 0.38846772422000003,
"times": [
0.38837628122000006,
0.37652631122,
0.36915707522,
0.37299920422000005,
0.37037127422000005,
0.36495930322000003,
0.37059657822000003,
0.3850431522200001,
0.36854856922000007,
0.38846772422000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.0124803628000003,
"stddev": 0.09240969318128713,
"median": 2.003667084,
"user": 0.9934095199999999,
"system": 1.0382014800000001,
"min": 1.930863869,
"max": 2.252567817,
"times": [
1.9664873729999999,
2.048002625,
2.252567817,
2.01402291,
1.951322673,
2.0134291920000003,
1.940773001,
1.995460308,
2.01187386,
1.930863869
]
},
{
"command": "pacquet@main",
"mean": 1.9713691285000003,
"stddev": 0.03085076202728358,
"median": 1.9723868685,
"user": 0.9582366200000001,
"system": 0.97358578,
"min": 1.925781767,
"max": 2.0259356470000003,
"times": [
1.969834119,
2.002968627,
1.965893189,
1.984202585,
2.0259356470000003,
1.927626153,
1.981838799,
1.925781767,
1.9749396179999998,
1.954670781
]
},
{
"command": "pnpr@HEAD",
"mean": 0.38180927130000003,
"stddev": 0.011210628598279872,
"median": 0.38442088100000005,
"user": 0.24119861999999997,
"system": 0.65288548,
"min": 0.357420155,
"max": 0.395674055,
"times": [
0.387110991,
0.381730771,
0.357420155,
0.37520689100000004,
0.387676008,
0.39192598600000006,
0.372340769,
0.38846583100000004,
0.38054125600000005,
0.395674055
]
},
{
"command": "pnpr@main",
"mean": 0.38484832650000006,
"stddev": 0.013608320372305688,
"median": 0.380087253,
"user": 0.23992431999999994,
"system": 0.6556905799999999,
"min": 0.373851774,
"max": 0.41877304400000004,
"times": [
0.37938963900000006,
0.37657968100000005,
0.37687827200000007,
0.385165338,
0.37747401500000005,
0.373851774,
0.39731923100000005,
0.41877304400000004,
0.38226740400000003,
0.380784867
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2918507493,
"stddev": 0.03415099316846303,
"median": 0.28509412170000004,
"user": 0.23970718,
"system": 0.09192938,
"min": 0.24946750920000002,
"max": 0.37558612420000004,
"times": [
0.2856147612,
0.37558612420000004,
0.26711535620000004,
0.27586075820000006,
0.29869114620000004,
0.24946750920000002,
0.29247314920000006,
0.28457348220000006,
0.2762950282,
0.31283017820000003
]
},
{
"command": "pacquet@main",
"mean": 0.31483236670000003,
"stddev": 0.04458631394305016,
"median": 0.3075617197,
"user": 0.26770818,
"system": 0.11262697999999997,
"min": 0.26086788120000004,
"max": 0.39283435820000007,
"times": [
0.30654165720000004,
0.3460617012,
0.30858178220000004,
0.29227342720000005,
0.33066280220000005,
0.39283435820000007,
0.26086788120000004,
0.2795500322,
0.3693578652,
0.26159216020000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10411785216000002,
"stddev": 0.0063173406972005805,
"median": 0.1019495722,
"user": 0.02749406,
"system": 0.01732324,
"min": 0.0956520802,
"max": 0.11656071220000001,
"times": [
0.11252606920000001,
0.1043234172,
0.0987480502,
0.09910229620000001,
0.0987148332,
0.1097526562,
0.1131734862,
0.1102460162,
0.11286945520000001,
0.11017742320000001,
0.11656071220000001,
0.11092315520000001,
0.10698737420000001,
0.10109507020000001,
0.10524111720000001,
0.10013500720000001,
0.09896920320000001,
0.0956520802,
0.09596270920000001,
0.0957940082,
0.10023290320000001,
0.0978433672,
0.10497394620000002,
0.1019495722,
0.10099237520000001
]
},
{
"command": "pnpr@main",
"mean": 0.10611987419999998,
"stddev": 0.00760858159604852,
"median": 0.1048615392,
"user": 0.02941622166666666,
"system": 0.017217404999999998,
"min": 0.09532605420000001,
"max": 0.1286567482,
"times": [
0.11450114420000002,
0.1078076262,
0.10183682420000001,
0.10608418320000002,
0.09827776120000001,
0.10674418420000001,
0.1286567482,
0.11882435420000001,
0.10724191120000001,
0.1002113012,
0.10584205020000001,
0.11417374120000001,
0.09864017820000001,
0.09532605420000001,
0.09651548420000002,
0.1038810282,
0.1037101212,
0.10125559120000001,
0.1031697272,
0.11184572420000001,
0.10821423120000001,
0.1107506862,
0.10264780720000001,
0.10071851820000001
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6641485802600001,
"stddev": 0.10529359183736432,
"median": 0.68309904126,
"user": 0.6377907222222222,
"system": 0.15812254222222222,
"min": 0.53297768026,
"max": 0.86623680426,
"times": [
0.86623680426,
0.7189433872600001,
0.70804453826,
0.58023134326,
0.7051718662600001,
0.53642583426,
0.6462067272600001,
0.53297768026,
0.68309904126
]
},
{
"command": "pacquet@main",
"mean": 0.7450895399266666,
"stddev": 0.14021799362037507,
"median": 0.79070814426,
"user": 0.7244798333333331,
"system": 0.18312976444444443,
"min": 0.5545715452600001,
"max": 0.9470186312600001,
"times": [
0.56378202726,
0.5545715452600001,
0.90365223526,
0.9470186312600001,
0.63678373326,
0.80846097526,
0.79070814426,
0.79687840826,
0.70395015926
]
},
{
"command": "pnpm@HEAD",
"mean": 4.600272732593333,
"stddev": 0.409609215562517,
"median": 4.56922921826,
"user": 6.654746277777777,
"system": 0.4644225422222223,
"min": 3.9467296802600003,
"max": 5.29189086926,
"times": [
4.46130097126,
4.53954851326,
5.29189086926,
4.81394861126,
4.10084015726,
4.88001457126,
4.79895200126,
3.9467296802600003,
4.56922921826
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 5.06174277608,
"stddev": 0.12023802709380539,
"median": 5.06700359968,
"user": 3.1946765800000003,
"system": 2.5563873999999998,
"min": 4.813499847679999,
"max": 5.261243158679999,
"times": [
5.05153120468,
4.9367939086799995,
5.08090794368,
5.12570155268,
5.053099255679999,
5.261243158679999,
5.12019068268,
5.130387338679999,
5.04407286768,
4.813499847679999
]
},
{
"command": "pacquet@main",
"mean": 5.167408430979999,
"stddev": 0.17566654262130174,
"median": 5.16003556068,
"user": 3.3231267800000004,
"system": 2.7434738999999997,
"min": 4.903834907679999,
"max": 5.44652121868,
"times": [
4.914150354679999,
5.18371315968,
4.903834907679999,
5.33581476768,
5.06475017768,
5.2574505586799996,
5.13635796168,
5.44652121868,
5.134185598679999,
5.29730560468
]
},
{
"command": "pnpr@HEAD",
"mean": 4.132443196679999,
"stddev": 0.12286411581544408,
"median": 4.118444780679999,
"user": 2.23781868,
"system": 2.4819123000000003,
"min": 3.90933845868,
"max": 4.3122760396799995,
"times": [
4.3122760396799995,
4.10432973868,
4.20874252168,
4.132559822679999,
4.06685478668,
4.23461164868,
4.259668327679999,
4.0167719026799995,
4.0792787196799996,
3.90933845868
]
},
{
"command": "pnpr@main",
"mean": 3.93475598858,
"stddev": 0.08326908229152867,
"median": 3.92000808618,
"user": 2.08412648,
"system": 2.2389829,
"min": 3.83984445068,
"max": 4.053361164679999,
"times": [
3.84624282468,
3.86918375168,
4.01464216668,
3.85639368568,
3.83984445068,
4.053361164679999,
3.9017759716800002,
4.03665535668,
3.93824020068,
3.99122031268
]
}
]
} |
Bencher alert: baseline drift, not a regressionThe single alert (
Written by an agent (Claude Code, claude-fable-5). |
Summary
Closes the two follow-ups recorded on #13866: the resolved graph and lockfile are now a function of the workspace's project set, independent of the order projects are listed or discovered.
Both
resolve_workspaceandresolve_peers_workspacesort importers by project id up front. That one ordering decision canonicalizes everything downstream that was first-writer-wins: children-owner claims (ranked by importer position), the auto-install hoist loop's first-walk missing scope, deprecation-warning attribution, and which context first realizes a shared cycle back-edge occurrence. Per-importer options are still built in the caller's listing order before the sort, so positional options callbacks keep lining up.Validation:
packageslisting of the 5-importer bit fixture produces a byte-identical lockfile — the residual importer-order axis of Lockfile is not reproducible: four identical installs produce four different lockfiles #13846.0d5c2ec7c0, 5-importer6565464007), at unchanged speed and memory (ws resolve 0.73 s / 0.60 GB) — production callers already supply id-sorted importers, so the sort only pins what discovery order made incidental.backedge_bindings_do_not_depend_on_importer_order(peers level) anddeprecation_attribution_does_not_depend_on_importer_listing_order(workspace level).An earlier design (binding back-edge occurrences at bare workspace-root context) was measured and rejected: +18.6% lockfile on the 5-importer fixture. The id-sort achieves the same invariance at zero output change.
Not mirrored in the TypeScript CLI: this hardens v12's canonical-resolution guarantee (#13866); the v11 TypeScript CLI keeps v11 semantics.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting. (v12-only: hardens the canonical-resolution guarantee introduced in feat(resolver)!: break dependency cycles canonically #13866.)Written by an agent (Claude Code, claude-fable-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests