Repository navigation
refactor(package-manager): split InstallWithFreshLockfile::run into phase modules - #13624
Conversation
…hase modules
`InstallWithFreshLockfile::run` had grown to 2103 lines — 68% of its
file — and read as one flat sequence with no boundary between the
install phases it drives. Split it into four submodules, one per phase,
leaving `run` as the orchestrator that threads state between them:
- `resolver_setup` — registries, store-index handles, and the resolver
chain with its prefetching and observing wrappers.
- `resolution_inputs` — the manifest transform chain
(`packageExtensions` + `pnpm.overrides`), the preferred-versions
seeds, the `preResolution` hook, and the lockfile reuse seed.
- `materialization_plan` — installability host, engine name, skip set.
- `linking` — prune, the hoisted and isolated linker arms, and the
module-resolution sidecars.
The resolver-chain split needs two functions rather than one:
`PrefetchContext` borrows the store handles, so the caller has to own
them before the chain that borrows them is built.
Three duplications fell out along the way:
- The store-index writer drain appeared verbatim on both the
lockfile-only and materializing paths.
- The build-then-splice pair of `build_fresh_lockfile` and
`merge_filtered_wanted_lockfile` appeared twice; both call sites are
now one `build_lockfile` call.
- The fast-override pre-pass and the per-importer resolve closure built
near-identical `ResolveOptions` literals differing only in
`project_dir` and the preferred-versions seed, now
`SharedResolveOptions::build`.
Two behavior-preserving simplifications: `needs_installability_check`
was redundant with `installability_host.is_some()` and collapsed into
it, and the `if x.is_empty() { None } else { Some(..) }` shapes around
the overrides hooks became `.filter(..).map(..)`.
No user-visible change, so nothing to mirror in the TypeScript CLI and
no changeset.
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 (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughFresh-lockfile installation is refactored into dedicated resolver, manifest, resolution, materialization, linking, and finalization modules. Filtered lockfile merging and sidecar generation are centralized. The frozen-lockfile error enum removes its ChangesFresh-lockfile installation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Installer
participant ResolverSetup
participant Resolve
participant MaterializationPlan
participant Linking
Installer->>ResolverSetup: Build resolver chain and store-index handles
Installer->>Resolve: Transform manifests and resolve workspace importers
Resolve-->>Installer: Return resolved workspace
Installer->>MaterializationPlan: Compute host, engine, and skipped snapshots
MaterializationPlan-->>Installer: Return materialization plan
Installer->>Linking: Run hoisted or isolated link phase
Linking-->>Installer: Return linker results and sidecar status
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 |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13624 +/- ##
==========================================
+ Coverage 88.01% 88.05% +0.04%
==========================================
Files 568 573 +5
Lines 98017 98389 +372
==========================================
+ Hits 86266 86637 +371
- Misses 11751 11752 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The phase split left the orchestrator repeating documentation that had moved to the callee, which is exactly what the call-site rule in AGENTS.md forbids. Remove it, and collapse the linker's redundant input types. - The 19-line `symlink_root` anchoring rationale sat at the call site and verbatim on `run_link_phase`; the call site now points at it. - The 23-line block above `collect_injected_deps` restated that function's own doc comment, and its second half restated `InstallWithFreshLockfileResult`. Only the save-ordering constraint is genuinely local, so that is all that stays, at the save. - The virtual-store-layout block restated `VirtualStoreLayout::new`, sat above `AllowBuildPolicy::from_config` rather than the layout it described, and claimed the lockfile maps are built "only when GVS is on" — which the unconditional `build_lockfile` below contradicts. - The `drop(resolver)` block re-narrated what each `drop` does; only the non-obvious part survives (deno/bun hold clones of the same `npm_resolver` `Arc`, so the chain's drop is not enough). - A "Resolve pass:" comment described the resolver-chain construction that moved into `resolver_setup`, leaving it stranded above an unrelated registry lookup. `HoistedArmInputs` and `IsolatedArmInputs` were strict subsets of `LinkPhaseInputs`, so both arms now borrow that instead, with the hoisted arm taking the one non-`Copy` field as its own argument. Comment lines 1027 -> 946, code 2545 from 2614. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The first split left the decomposition arbitrary: `linking` was a module while the resolve pass stayed inline, and two functions sat in modules that did not own their phase. A reader could not infer any rule for what became a module, which is worse than either extreme. Make the rule "one module per install phase" and hold to it: - `resolution_inputs` was a grab-bag — the read-package transform chain, the preferred-versions seeds, the reuse seed, the shared resolve options, and a post-resolve diagnostic. Split into `manifest_transforms` (the `packageExtensions` + `pnpm.overrides` chain) and `resolve` (everything the walk consumes, the walk, and the diagnostics that read its result). - `warn_stale_convergence_overrides` reads the resolve's output, so it belongs in `resolve`, not among its inputs. - The resolve pass itself moves into `resolve::run_resolve_pass`, so the phase is a module like the others rather than 130 inline lines. - `build_extra_env` is build-phase setup, not linking. It moves beside its only caller. The build phase deliberately does *not* become a module here: `install_frozen_lockfile::run_build_phase` already owns it and is shared with the frozen path, so a local wrapper would add a layer and no meaning. `run` is 921 lines, down from 2103. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.5559575648200004,
"stddev": 0.15502778822716082,
"median": 2.49970191132,
"user": 1.98811252,
"system": 1.5767062400000003,
"min": 2.42950570032,
"max": 2.86865343532,
"times": [
2.5157012133200003,
2.50546332832,
2.47680817032,
2.49394049432,
2.86865343532,
2.42950570032,
2.46225359132,
2.53260989632,
2.4560913813200003,
2.81854843732
]
},
{
"command": "pacquet@main",
"mean": 2.5770954464200004,
"stddev": 0.1305462274784839,
"median": 2.54025957182,
"user": 1.85339222,
"system": 1.49980874,
"min": 2.41605721232,
"max": 2.77143747532,
"times": [
2.54176247632,
2.49627504032,
2.45422124932,
2.77143747532,
2.76849617832,
2.49529927332,
2.53875666732,
2.56380704832,
2.41605721232,
2.72484184332
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5261318539200002,
"stddev": 0.12120396908976891,
"median": 1.4788749753200001,
"user": 1.34274212,
"system": 1.38856054,
"min": 1.3931347653200001,
"max": 1.75417946532,
"times": [
1.43525791632,
1.75417946532,
1.3931347653200001,
1.6887217433200001,
1.51323448932,
1.49335685832,
1.45055704532,
1.44223388732,
1.62624927632,
1.4643930923200001
]
},
{
"command": "pnpr@main",
"mean": 1.5780773288199998,
"stddev": 0.17661238098959356,
"median": 1.51121036882,
"user": 1.22143992,
"system": 1.30556334,
"min": 1.3883092403200001,
"max": 1.82672495332,
"times": [
1.81771714532,
1.40525036332,
1.41006294332,
1.82672495332,
1.68693674332,
1.4630823353200002,
1.7602688263200001,
1.3883092403200001,
1.50242825632,
1.51999248132
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.3456601201600001,
"stddev": 0.062411058050005096,
"median": 0.33861804596000006,
"user": 0.28440477999999997,
"system": 0.68898614,
"min": 0.28004041996000006,
"max": 0.44390521596000004,
"times": [
0.28675671296000005,
0.29869561996000005,
0.28418143696000003,
0.28004041996000006,
0.29563424696000007,
0.37854047196000007,
0.39706671896000006,
0.3822730589600001,
0.40950729896000004,
0.44390521596000004
]
},
{
"command": "pacquet@main",
"mean": 0.38926387846000005,
"stddev": 0.06852056923886538,
"median": 0.42178063396000004,
"user": 0.33102158,
"system": 0.73961474,
"min": 0.28463060796000006,
"max": 0.46031299296000006,
"times": [
0.40954916696000004,
0.46031299296000006,
0.4555828169600001,
0.43401210096000004,
0.44782645696000006,
0.43538476496000006,
0.31097622396,
0.33234848796000005,
0.32201516496000004,
0.28463060796000006
]
},
{
"command": "pnpr@HEAD",
"mean": 0.47234071896000007,
"stddev": 0.015783207028610743,
"median": 0.47065354796000003,
"user": 0.41656038000000006,
"system": 0.8080472399999999,
"min": 0.45287332696000004,
"max": 0.4994106139600001,
"times": [
0.47009370396000005,
0.48521795496000003,
0.49252480996000003,
0.45287332696000004,
0.47121339196000006,
0.4545924719600001,
0.45753756596000006,
0.4994106139600001,
0.46833934196000004,
0.47160400796000007
]
},
{
"command": "pnpr@main",
"mean": 0.41956879286,
"stddev": 0.053881542505099946,
"median": 0.43151749446000004,
"user": 0.3528734800000001,
"system": 0.75676404,
"min": 0.33694496096000004,
"max": 0.47917423896000005,
"times": [
0.43483516996000005,
0.47610918896000004,
0.47917423896000005,
0.46702726196000005,
0.41774534796000007,
0.45011501396000003,
0.42819981896000003,
0.36088741196000007,
0.33694496096000004,
0.34464951496000007
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7372128372800004,
"stddev": 0.0821070385181186,
"median": 2.72857334318,
"user": 1.8826238400000002,
"system": 1.59921684,
"min": 2.64299404918,
"max": 2.94894200918,
"times": [
2.94894200918,
2.72712101918,
2.6803974411800002,
2.64299404918,
2.69719079518,
2.7348632041800003,
2.76823400418,
2.73002566718,
2.73703072218,
2.7053294611800003
]
},
{
"command": "pacquet@main",
"mean": 2.7076576163799997,
"stddev": 0.042396161086051286,
"median": 2.68630172218,
"user": 1.77329304,
"system": 1.50493284,
"min": 2.67189106318,
"max": 2.79895224018,
"times": [
2.68147806218,
2.6803063161800003,
2.71278979718,
2.67764009618,
2.67698727718,
2.75900886518,
2.69112538218,
2.67189106318,
2.72639706418,
2.79895224018
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6710308681800001,
"stddev": 0.13144278192933093,
"median": 1.68299188218,
"user": 1.4584572399999998,
"system": 1.64641554,
"min": 1.50143627218,
"max": 1.90200882318,
"times": [
1.80368735418,
1.53662465018,
1.54530045318,
1.57762559618,
1.6426002941800002,
1.75375707818,
1.72338347018,
1.90200882318,
1.50143627218,
1.7238846901800002
]
},
{
"command": "pnpr@main",
"mean": 1.6865917684800003,
"stddev": 0.18323943563734046,
"median": 1.60093921018,
"user": 1.54774404,
"system": 1.7050310400000002,
"min": 1.5434443941800002,
"max": 2.09769510918,
"times": [
1.5434443941800002,
1.5570817161800001,
1.59256762018,
1.6313270861800002,
1.58834486018,
1.55421127218,
1.60931080018,
2.09769510918,
1.83984699118,
1.85208783518
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.81550041676,
"stddev": 0.19406808233024297,
"median": 0.91685256886,
"user": 1.08264598,
"system": 1.1249487999999999,
"min": 0.52222952686,
"max": 0.99146675286,
"times": [
0.96872551086,
0.9502795458600001,
0.93115591486,
0.97515020586,
0.99146675286,
0.90254922286,
0.79479943886,
0.52598100986,
0.52222952686,
0.59266703886
]
},
{
"command": "pacquet@main",
"mean": 0.52849150956,
"stddev": 0.045899676731028835,
"median": 0.5266642428599999,
"user": 0.73896918,
"system": 0.8335939,
"min": 0.46941216286000004,
"max": 0.63899846786,
"times": [
0.63899846786,
0.53191606286,
0.52897135686,
0.49622940686000006,
0.55549288186,
0.51419354486,
0.52435712886,
0.53210081686,
0.49324326586000006,
0.46941216286000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.38456959276,
"stddev": 0.017601176736525028,
"median": 0.38752397636,
"user": 0.29031318,
"system": 0.6282618999999999,
"min": 0.35593208286000005,
"max": 0.41090947986000004,
"times": [
0.39232856086000006,
0.37778609486000003,
0.36516931386,
0.35593208286000005,
0.38271939186000004,
0.39432002086000006,
0.39236338786,
0.41090947986000004,
0.40468845786,
0.36947913686000006
]
},
{
"command": "pnpr@main",
"mean": 0.37529609836000005,
"stddev": 0.015611668521941804,
"median": 0.37187516786,
"user": 0.25916908,
"system": 0.6379276999999999,
"min": 0.36003404586000004,
"max": 0.40249671386,
"times": [
0.39306851486000005,
0.36132858186000005,
0.36335068986,
0.36170304786,
0.36218504486,
0.38039964586,
0.36003404586000004,
0.38059947186000004,
0.38779522686000006,
0.40249671386
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9062817340399996,
"stddev": 0.03815161803988929,
"median": 1.90885360454,
"user": 1.0324249799999998,
"system": 0.9629027399999999,
"min": 1.83345038604,
"max": 1.96709734004,
"times": [
1.91345041804,
1.83345038604,
1.89343995804,
1.88125042104,
1.87718027904,
1.9213155940400002,
1.90425679104,
1.95064843404,
1.96709734004,
1.92072771904
]
},
{
"command": "pacquet@main",
"mean": 1.8684085912400001,
"stddev": 0.04702901018861531,
"median": 1.86506074104,
"user": 0.9870343799999999,
"system": 0.9075633399999999,
"min": 1.8117013500399999,
"max": 1.94397390904,
"times": [
1.94397390904,
1.92657100804,
1.8715687170400002,
1.81773830504,
1.86380183104,
1.86631965104,
1.9169031360400002,
1.83981036604,
1.8117013500399999,
1.82569763904
]
},
{
"command": "pnpr@HEAD",
"mean": 0.38757536454,
"stddev": 0.035729042606591134,
"median": 0.39233057204,
"user": 0.28042388,
"system": 0.6564714400000001,
"min": 0.32720006704,
"max": 0.43900413204,
"times": [
0.38991903703999997,
0.42683761804,
0.39474210704,
0.43900413204,
0.41650454604,
0.39877438804,
0.37587069104,
0.32720006704,
0.34416930204,
0.36273175704
]
},
{
"command": "pnpr@main",
"mean": 0.37615371134,
"stddev": 0.03394192617420747,
"median": 0.36690755754,
"user": 0.26669388,
"system": 0.6292386399999998,
"min": 0.33698288404,
"max": 0.43110963004,
"times": [
0.41591104904,
0.34289833004,
0.33698288404,
0.37970326604,
0.38630223003999997,
0.41196437003999997,
0.43110963004,
0.35298720204,
0.35411184904,
0.34956630303999997
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.22778093634571434,
"stddev": 0.020882338931621922,
"median": 0.22728983906000003,
"user": 0.21015751142857145,
"system": 0.08746779714285713,
"min": 0.19601183706000003,
"max": 0.26367732905999997,
"times": [
0.20760509206000002,
0.20897034206,
0.19601183706000003,
0.21060235306000002,
0.21515549506,
0.20897695506000002,
0.21675190106000003,
0.25189578106,
0.23782777706000002,
0.23938356606000002,
0.24421166506000003,
0.23794252306000002,
0.24992049206000003,
0.26367732905999997
]
},
{
"command": "pacquet@main",
"mean": 0.22568365889333333,
"stddev": 0.012859906870958785,
"median": 0.22478671706000003,
"user": 0.20869677333333334,
"system": 0.08655427333333332,
"min": 0.20837631406,
"max": 0.25871218306,
"times": [
0.23690870706000003,
0.25871218306,
0.21466486306000002,
0.22935356406000001,
0.22341531606,
0.22615811806000002,
0.22737365606,
0.22166135406,
0.21509196606000003,
0.22013395806000002,
0.22635390706000003,
0.20837631406
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09707522878413795,
"stddev": 0.0025688736859261732,
"median": 0.09691689706,
"user": 0.02715454344827586,
"system": 0.012038564827586206,
"min": 0.09156615506000002,
"max": 0.10222089206000001,
"times": [
0.09791585906000001,
0.09454219806000001,
0.09509987706,
0.09834078806,
0.10071135106000001,
0.09600162406000001,
0.09624181706000001,
0.10114956606000002,
0.09293564306,
0.09931942006000001,
0.09410627606000001,
0.09715712906000001,
0.09470512406,
0.09467167106,
0.09156615506000002,
0.09805976906000001,
0.09691689706,
0.09890595206000001,
0.09866304506000001,
0.09628179206000001,
0.09616622406000001,
0.09976918706000001,
0.09677975906000001,
0.09931405106,
0.09945607806000001,
0.10222089206000001,
0.09886825106000001,
0.09473032106000001,
0.09458491706000001
]
},
{
"command": "pnpr@main",
"mean": 0.09633680832666668,
"stddev": 0.002617196052777804,
"median": 0.09634824756000002,
"user": 0.027464806666666664,
"system": 0.011586308666666668,
"min": 0.09182570406000001,
"max": 0.10249556006,
"times": [
0.09249594506000001,
0.09842594806,
0.09404134406,
0.09923096406000001,
0.09492226106000001,
0.09638560806000002,
0.09957570306,
0.09819924206000001,
0.09673760006000001,
0.09382687106000001,
0.09612498606000001,
0.09517387706000001,
0.09569368506,
0.09729945806000001,
0.09561673006000002,
0.09664487606000001,
0.09239593606,
0.09323810306000001,
0.09869776006000001,
0.09261668206000001,
0.09182570406000001,
0.09524275506,
0.09731501706000001,
0.09823924706,
0.10249556006,
0.09759490506000001,
0.09631088706,
0.09474193306,
0.09757357406000002,
0.10142108706000001
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.1393688433022224,
"stddev": 0.38953763001474334,
"median": 0.96819684708,
"user": 1.0619378844444445,
"system": 0.23931165111111113,
"min": 0.80990843308,
"max": 1.91413703908,
"times": [
0.96819684708,
0.80990843308,
0.83621874308,
1.58960820408,
1.34094730208,
1.01838299308,
0.88629751808,
0.89062251008,
1.91413703908
]
},
{
"command": "pacquet@main",
"mean": 1.2730978874133334,
"stddev": 0.3709472532934086,
"median": 1.13044545608,
"user": 1.204622328888889,
"system": 0.25233265111111114,
"min": 0.92023553808,
"max": 1.92092465708,
"times": [
1.80421395708,
0.96435566508,
0.92023553808,
1.13044545608,
1.92092465708,
1.12126605508,
1.4512337500799999,
1.18142867208,
0.96377723608
]
},
{
"command": "pnpm@HEAD",
"mean": 4.951339163413334,
"stddev": 0.7765173386493833,
"median": 4.86432091308,
"user": 7.586615217777776,
"system": 0.42540553999999997,
"min": 3.8882730010800004,
"max": 6.335455646080001,
"times": [
3.8882730010800004,
4.71184673608,
4.88003210208,
4.92857194908,
4.53196417008,
6.335455646080001,
6.04652853008,
4.375059423080001,
4.86432091308
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.728351401359999,
"stddev": 0.15187201429105857,
"median": 4.76514938716,
"user": 2.5845238799999994,
"system": 1.94564142,
"min": 4.51064274516,
"max": 4.91114758216,
"times": [
4.80314220216,
4.91114758216,
4.90446989116,
4.83274098016,
4.67931523816,
4.72715657216,
4.54879827416,
4.51064274516,
4.82538125316,
4.54071927516
]
},
{
"command": "pacquet@main",
"mean": 4.71396719796,
"stddev": 0.17060435998459994,
"median": 4.68636538066,
"user": 2.30301648,
"system": 1.6398703199999995,
"min": 4.54681170716,
"max": 4.97423260416,
"times": [
4.55929965816,
4.57393075016,
4.97423260416,
4.56318109416,
4.79880001116,
4.91033175516,
4.55129584916,
4.54681170716,
4.84578369016,
4.8160048601600005
]
},
{
"command": "pnpr@HEAD",
"mean": 3.58974920726,
"stddev": 0.09850573099248322,
"median": 3.58162103666,
"user": 1.3235660800000002,
"system": 1.33265962,
"min": 3.47719274416,
"max": 3.78049724316,
"times": [
3.60430800616,
3.55893406716,
3.48773089116,
3.50395920316,
3.47719274416,
3.78049724316,
3.65715183816,
3.67833422516,
3.51766744016,
3.63171641416
]
},
{
"command": "pnpr@main",
"mean": 3.6718827120600004,
"stddev": 0.14536292484289415,
"median": 3.6163118496599997,
"user": 1.7752624799999999,
"system": 1.75556542,
"min": 3.5331676501600002,
"max": 3.92159234016,
"times": [
3.5331676501600002,
3.58936974516,
3.57450993016,
3.77693873416,
3.54394469816,
3.90552447916,
3.92159234016,
3.65439200216,
3.64325395416,
3.57613358716
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13624 |
| 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,445.10 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 337.58 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 299.24 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 89.34 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,413.04 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,467.41 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 284.44 ms |
`InstallFrozenLockfileError::InstallError` wrapped the orchestrator's own `crate::InstallError`, but nothing ever built it: no construction site, no match, and the only `From` impl for the enum is from `HoistedLinkerError`. It was the sole code-level reference from the frozen-lockfile path back up to `install.rs`. Removing it makes the dependency between the two install paths strictly one-directional — the fresh path reaches into the frozen path for the shared hoist, build, and engine helpers, and nothing points back. That matches how the TypeScript CLI already layers these: `@pnpm/installing.deps-installer` depends on `@pnpm/installing.deps-restorer`, never the reverse. No user-visible change: a variant that was never constructed could never surface an error code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Moving `build_extra_env` from `linking` to its caller left the `write_module_resolution_sidecars` doc pointing at a name no longer in scope, which failed `Rust CI / Doc` with an unresolved intra-doc link. The local gate missed it: `rm -rf target/doc` alone is not enough to force a re-render, because cargo's fingerprint still reports the doc unit fresh. `cargo clean -p <crate> --doc` is what actually reproduces CI. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PR Summary by QodoRefactor fresh-install run() into phase modules
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "refactor(package-manager): make the virt..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
pnpm/crates/package-manager/src/install_with_fresh_lockfile/linking.rs (1)
280-291: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winBorrow the anchor set instead of cloning it.
project_anchor_importer_idsis already&'a HashSet<String>, andSymlinkDirectDependencies.trusted_importer_idstakesOption<&HashSet<String>>. The clone at Line 280 allocates a new set plus oneStringper importer for no gain. Pass the borrow directly.♻️ Proposed fix to drop the clone
- let trusted_importer_ids: HashSet<String> = project_anchor_importer_ids.clone(); SymlinkDirectDependencies { config, layout, importers: &materialization_lockfile.importers, packages: materialization_lockfile.packages.as_ref(), dependency_groups: dependency_groups.iter().copied(), workspace_root: symlink_root, skipped, link_only: false, public_hoist_targets: public_hoist_targets.as_ref(), - trusted_importer_ids: Some(&trusted_importer_ids), + trusted_importer_ids: Some(project_anchor_importer_ids), extra_node_paths, }Keep the comment at Lines 275-279 above the
SymlinkDirectDependenciesconstruction, since it documents why these ids bypass the importer-key rejection.🤖 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_with_fresh_lockfile/linking.rs` around lines 280 - 291, Remove the trusted_importer_ids clone and pass project_anchor_importer_ids directly as the borrowed value to SymlinkDirectDependencies.trusted_importer_ids. Preserve the existing comment explaining why these importer IDs bypass rejection and keep the Option reference type expected by the field.Source: Coding guidelines
pnpm/crates/package-manager/src/install_with_fresh_lockfile/resolver_setup.rs (1)
152-166: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename the
tbinding to a descriptive name.
pnpm/CODE_STYLE_GUIDE.mdrequires descriptive local names. Usetarballfor the matched resolution.♻️ Proposed rename
- LockfileResolution::Tarball(t) if t.git_hosted != Some(true) => { - let integrity = t.integrity.clone()?; + LockfileResolution::Tarball(tarball) if tarball.git_hosted != Some(true) => { + let integrity = tarball.integrity.clone()?; let pkg_id = key.pkg_id(); let store_index_key = store_index_key(&integrity.to_string(), &pkg_id); Some(( pkg_id, PriorTarballEntry { integrity, store_index_key, - tarball_url: t.tarball.clone(), + tarball_url: tarball.tarball.clone(), }, )) }As per path instructions,
pnpm/CODE_STYLE_GUIDE.mdrequires "descriptive generic and local names".🤖 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_with_fresh_lockfile/resolver_setup.rs` around lines 152 - 166, Rename the matched `LockfileResolution::Tarball` binding from `t` to `tarball` in the `filter_map` match, and update all references within that arm accordingly, preserving the existing behavior.Source: Path instructions
pnpm/crates/package-manager/src/install_with_fresh_lockfile/resolve.rs (1)
287-297: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a focused test for the fast-catalog reuse branch.
The three return paths select different reuse seeds, and each one changes what the resolver reuses. The branch at Lines 287-292 is the only path that returns the fast-catalog seed:
catalogs_matchisfalsewheneverfast_catalog_seedisSome, so the final expression at Lines 294-297 can never return it. Codecov reports 2 uncovered lines in this file. Add a test that changes a catalog entry while leavingpnpm.overridesandpackageExtensionsunchanged, and assert the resolve reuses the rewritten lockfile.Note that
reusable_settings_lockfile.is_some()at Line 288 is already implied byoverride_settings_match, which is computed withis_some_andat Lines 262-264.As per path instructions, "Tests should meaningfully cover phase boundaries and uncovered branches; assess whether the reported missing coverage warrants focused regression tests."
🤖 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_with_fresh_lockfile/resolve.rs` around lines 287 - 297, Add a focused regression test for the fast-catalog reuse branch in the resolver flow around reusable_settings_lockfile and fast_catalog_seed. Keep pnpm.overrides and packageExtensions unchanged, modify a catalog entry, and assert resolution reuses the rewritten lockfile through the fast-catalog seed path. Ensure the test exercises the branch where fast_catalog_seed is Some and catalogs_match is false, covering its early return.Source: Path instructions
pnpm/crates/package-manager/src/install_with_fresh_lockfile/manifest_transforms.rs (1)
96-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBind the non-empty overrider once.
Both
overrides_hookandoverride_bare_specifierrepeat the sameas_ref().filter(...)guard. Extract the guarded reference so the shared non-empty precondition appears once.♻️ Proposed refactor
+ let non_empty_overrider = + versions_overrider.as_ref().filter(|overrider| !overrider.is_empty()); let overrides_hook: Option<ManifestHook> = - versions_overrider.as_ref().filter(|overrider| !overrider.is_empty()).map(|overrider| { + non_empty_overrider.map(|overrider| { let overrider = Arc::clone(overrider); Arc::new(move |manifest| overrider.apply_to_arc(manifest, None)) as ManifestHook }); let override_bare_specifier: Option<Arc<DependencyOverrider>> = - versions_overrider.as_ref().filter(|overrider| !overrider.is_empty()).map(|overrider| { + non_empty_overrider.map(|overrider| { let overrider = Arc::clone(overrider); Arc::new(move |name: &str, range: &str, pkg_dir: &Path| { overrider.override_for_undeclared_dependency(name, range, pkg_dir) }) as Arc<DependencyOverrider> });🤖 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_with_fresh_lockfile/manifest_transforms.rs` around lines 96 - 107, In the manifest transform setup, extract the non-empty `versions_overrider` reference once before constructing `overrides_hook` and `override_bare_specifier`, then derive both options from that shared guarded reference while preserving their existing closures and behavior.
🤖 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 `@pnpm/crates/package-manager/src/install_with_fresh_lockfile/linking.rs`:
- Around line 117-145: Update the virtual_store_only early-return branch in
run_link_phase to emit StatsMessage::Removed with prefix requester.to_owned()
and removed set to 0 before returning. Preserve the existing output construction
and ensure the isolated path maintains the same stats emission invariant as the
non-isolated flow.
- Around line 425-435: Update write_module_resolution_sidecars so PnP sidecar
generation is skipped when config.virtual_store_only is enabled. Extend the
existing early-return guard alongside write_package_map/write_pnp, or guard the
PnP branch before write_pnp_file, while preserving normal PnP writes when
virtual_store_only is false.
---
Nitpick comments:
In `@pnpm/crates/package-manager/src/install_with_fresh_lockfile/linking.rs`:
- Around line 280-291: Remove the trusted_importer_ids clone and pass
project_anchor_importer_ids directly as the borrowed value to
SymlinkDirectDependencies.trusted_importer_ids. Preserve the existing comment
explaining why these importer IDs bypass rejection and keep the Option reference
type expected by the field.
In
`@pnpm/crates/package-manager/src/install_with_fresh_lockfile/manifest_transforms.rs`:
- Around line 96-107: In the manifest transform setup, extract the non-empty
`versions_overrider` reference once before constructing `overrides_hook` and
`override_bare_specifier`, then derive both options from that shared guarded
reference while preserving their existing closures and behavior.
In `@pnpm/crates/package-manager/src/install_with_fresh_lockfile/resolve.rs`:
- Around line 287-297: Add a focused regression test for the fast-catalog reuse
branch in the resolver flow around reusable_settings_lockfile and
fast_catalog_seed. Keep pnpm.overrides and packageExtensions unchanged, modify a
catalog entry, and assert resolution reuses the rewritten lockfile through the
fast-catalog seed path. Ensure the test exercises the branch where
fast_catalog_seed is Some and catalogs_match is false, covering its early
return.
In
`@pnpm/crates/package-manager/src/install_with_fresh_lockfile/resolver_setup.rs`:
- Around line 152-166: Rename the matched `LockfileResolution::Tarball` binding
from `t` to `tarball` in the `filter_map` match, and update all references
within that arm accordingly, preserving the existing behavior.
🪄 Autofix (Beta)
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: 3bec1751-f5f7-40e0-8ca2-cbf4c4baa4aa
📒 Files selected for processing (7)
pnpm/crates/package-manager/src/install_frozen_lockfile.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/package-manager/src/install_with_fresh_lockfile/linking.rspnpm/crates/package-manager/src/install_with_fresh_lockfile/manifest_transforms.rspnpm/crates/package-manager/src/install_with_fresh_lockfile/materialization_plan.rspnpm/crates/package-manager/src/install_with_fresh_lockfile/resolve.rspnpm/crates/package-manager/src/install_with_fresh_lockfile/resolver_setup.rs
💤 Files with no reviewable changes (1)
- pnpm/crates/package-manager/src/install_frozen_lockfile.rs
PR Code Suggestions ✨Latest suggestions up to 8bcb67c Warning
Previous suggestionsSuggestions up to commit 02be09f
|
||||||||||||||||||||
…they came from Three module docs opened with "Split out of `InstallWithFreshLockfile::run`", which records refactor history rather than the module's contract — the thing `git log` is for. Each now states what the module owns and why it sits where it does in the pipeline: the resolver setup opens the store handles the resolve and install passes must share, the materialization plan feeds the skip set and engine name `CreateVirtualStore` addresses slots by, and the link phase produces the tree and hoisted roots the build phase needs. Reported by Qodo (rule 772199). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Thanks — fixed in 45c2be7. Rule 772199 was right: three module docs opened with Each header now states what the module owns and why it sits where it does in the pipeline, which is the part a reader actually needs:
Two other hits for historical phrasing in the file ( Written by an agent (Claude Code, claude-opus-5). |
…decision `run_link_phase` tested `virtual_store_only` twice — once to skip the pre-link reconciliation, then again to return early — so a reader had to hold both to see the first was subsumed by the second. CodeRabbit read the pair as a missing `pnpm:stats` `removed` emit. Return at the top instead. The reconciliation gate drops to `!is_hoisted` and there is one place stating that nothing in the link phase runs under `virtual_store_only`. Behavior is unchanged: the emit was already skipped on that path before this commit, and on the original code before the phase split. Also from the same review: - `trusted_importer_ids` cloned a set purely to hand out a borrow the field already accepts. - `LockfileResolution::Tarball(t)` used a single-letter binding, which `CODE_STYLE_GUIDE.md` rules out. - `overrides_hook` and `override_bare_specifier` repeated the same non-empty guard; it is bound once as `active_overrider`. - The catalog-seed branch tested `reusable_settings_lockfile.is_some()` alongside `override_settings_match`, which is computed with `is_some_and` and so already implies it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Worked through the CodeRabbit findings — 4 applied, 2 declined, both declines verified against the pre-refactor code ( Applied
DeclinedSkip PnP sidecar writes when
The suggested "mirror the package-map guard" isn't quite the right parallel either: That said — I don't think this is settled. Whether Not applied: test for the fast-catalog reuse branchCorrect that the branch is uncovered and that only the middle return can yield the catalog seed. But those lines and their coverage predate this PR — the file changed, the coverage didn't. Writing a catalog-mutation integration test is worthwhile and orthogonal to a behavior-preserving refactor; I'd rather do it separately than grow this PR. Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit 8bcb67c |
Picks up the install-module decomposition (#13640 and #13624), the headless-install extraction (#13637), the PnP-loader fix for virtual-store-only installs (#13636), and a dependency bump (#13631). `build_workspace_state` moved out of `install.rs` into the new `install/workspace_state.rs`, and its two call sites moved into `install/apply_materialization.rs` and `install/prepare_modules_state.rs`. This branch's `Sys: Clock` seam and the `::<Host>` turbofish are re-applied at those new homes. # Conflicts: # pnpm/crates/package-manager/src/install.rs
Summary
InstallWithFreshLockfile::runhad grown to 2103 lines — 68% of its file — and read as one flat sequence with no boundary between the install phases it drives. This gives the fresh-install path a module per phase, leavingrunas the orchestrator that threads state between them.runis now 921 lines. No user-visible change: pure internal refactor of the pacquet fresh-install path.Architecture
One module per install phase, in pipeline order:
resolver_setupmanifest_transformspackageExtensions(compat DB + user) andpnpm.overridesresolveResolveOptions,preResolutionhook, lockfile reuse seed, the workspace walk, and the diagnostics that read its resultmaterialization_planlinkingTwo phases deliberately stay in the orchestrator rather than becoming modules:
install_frozen_lockfile::run_build_phase, shared with the frozen path. A local wrapper would add a layer and no meaning.CreateVirtualStore/run_build_phaseinvocations are single calls with option literals. Relocating a struct literal behind a new 20-field input type does not make it clearer.The resolver-chain split needs two functions rather than one:
PrefetchContextborrows the store handles, so the caller has to own them before the chain that borrows them is built.Duplication removed
build_fresh_lockfile+merge_filtered_wanted_lockfile— the same 28-line build-then-splice pair, twice; now onebuild_lockfilecall.ResolveOptions— the fast-override pre-pass and the per-importer closure built near-identical 20-line literals differing only inproject_dirand the preferred-versions seed; nowSharedResolveOptions::build.LinkPhaseInputs—HoistedArmInputsandIsolatedArmInputswere strict subsets of it.Comments
The first pass moved prose into the new modules and left it at the call sites, which the call-site rule in
AGENTS.mdforbids. That was then cleaned up, which also surfaced a pre-existing stale comment: the virtual-store-layout block claimed the lockfile maps are built "only when GVS is on", which the unconditionalbuild_lockfilebelow contradicts. Comment lines ended at 946 vs. 907 before.Net line count is up (~3.8k from 3.1k). Most of that is the input/output types the phase boundaries require — that is the cost being bought, not an accident.
Verification
cargo nextest run -p pacquet-package-manager— 857 passed, 0 failed.cargo nextest run -p pacquet-cli --test install --test hoist --test lifecycle_scripts— 138 passed.-D warnings,cargo docwithRUSTDOCFLAGS=-D warnings, dylint, typos, taplo).Squash Commit Body
Checklist
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