Repository navigation
feat(pacquet): reconcile an existing node_modules on repeat installs (Stage 1) - #13151
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughRepeat installs now reconcile existing ChangesRepeat-install reconciliation
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ 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 |
PR Summary by Qodopacquet: reconcile existing node_modules on repeat installs (Stage 1)
AI Description
Diagram
High-Level Assessment
Files changed (28)
|
Micro-Benchmark ResultsLinux |
Confidence Score: 5/5This PR is safe to merge. The new pruning pass is conservative and self-healing — over-removal of a still-wanted entry is immediately corrected by the link pass that follows, and remove_direct_dep_link is idempotent on missing symlinks. The Lockfile::is_empty fix correctly adds dev and optional dependency maps to the emptiness check, preventing dev-only installs from deleting their current lockfile. The PruneStaleModules logic is sound: the name+version comparison correctly identifies stale links, the confined_modules_dir guard prevents workspace escapes, and the idempotent removal function handles double-removal from PruneStaleModules and prune_direct_deps_excluded_by_groups gracefully. The frozen_tree_intact probe is correctly guarded by the same let Some(modules) = modules_manifest extraction that surrounds it. All installs_only sites (add, remove, update, install, napi) are set correctly per upstream validateModules semantics. No files require special attention. Reviews (5): Last reviewed commit: "fix(pacquet): fail the frozen tree probe..." | Re-trigger Greptile |
Code Review by Qodo
1.
|
PR Code Suggestions ✨Latest suggestions up to 05da049 Warning
Previous suggestionsSuggestions up to commit c98800f
Suggestions up to commit 4a653fb
Suggestions up to commit ce2fa5c
Suggestions up to commit 6f165a4
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs (1)
622-624: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRedundant
.modules.yaml-adjacent lockfile reload now thatcurrent_lockfileis threaded in.
current_lockfileis now a field loaded once by the caller (Install::run_inner,Lockfile::load_current_from_virtual_store_dir) and threaded into this struct. However, the (unchanged)preResolutionhook block further down still does its ownLockfile::load_current_from_virtual_store_dir(&config.virtual_store_dir).ok().flatten()and binds it to a local also namedcurrent_lockfile, shadowing the new field for the rest of that block. This now duplicates the disk read+parse this same install already performed, and additionally swallows load errors (.ok()) that the outer field's load already surfaces as a typedInstallError.Since the block runs after this field is destructured and before any lockfile-affecting mutation, it should be safe to drop the re-load and reuse the outer
current_lockfilebinding directly.♻️ Proposed fix
if let Some(ref hook) = pnpmfile_hook { let wanted_lockfile_json = wanted_lockfile.map_or_else( || serde_json::json!({}), |lf| serde_json::to_value(lf).unwrap_or_else(|_| serde_json::json!({})), ); - let current_lockfile = - Lockfile::load_current_from_virtual_store_dir(&config.virtual_store_dir) - .ok() - .flatten(); let exists_current_lockfile = current_lockfile.is_some(); let current_lockfile_json = current_lockfile.map_or_else( || serde_json::json!({}), |lf| serde_json::to_value(lf).unwrap_or_else(|_| serde_json::json!({})), );🤖 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.rs` around lines 622 - 624, Remove the inner Lockfile::load_current_from_virtual_store_dir call and its shadowing current_lockfile binding in the preResolution hook block. Reuse the current_lockfile field already threaded through Install::run_inner and the surrounding struct destructuring, preserving the existing hook behavior and error propagation.
🤖 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.rs`:
- Around line 2593-2617: Update modules_layout_consistent_with() to compare
hoist_pattern and public_hoist_pattern through normalized_pattern(), treating
None and empty lists as equivalent. Keep the resulting mismatch behavior aligned
with check_modules_settings_diff() so add/remove surfaces the corresponding
HoistPatternDiff or PublicHoistPatternDiff instead of recreating node_modules.
---
Nitpick comments:
In `@pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs`:
- Around line 622-624: Remove the inner
Lockfile::load_current_from_virtual_store_dir call and its shadowing
current_lockfile binding in the preResolution hook block. Reuse the
current_lockfile field already threaded through Install::run_inner and the
surrounding struct destructuring, preserving the existing hook behavior and
error propagation.
🪄 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: b3dd7857-8afd-4724-b2b7-dc38194182c7
📒 Files selected for processing (28)
.changeset/reconcile-existing-node-modules-on-repeat-install.mdpnpm/crates/cli/src/cli_args/dedupe.rspnpm/crates/cli/src/cli_args/deploy.rspnpm/crates/cli/src/cli_args/fetch.rspnpm/crates/cli/src/cli_args/import.rspnpm/crates/cli/src/cli_args/install.rspnpm/crates/cli/src/cli_args/link.rspnpm/crates/cli/src/cli_args/prune.rspnpm/crates/cli/src/cli_args/rebuild.rspnpm/crates/cli/src/cli_args/unlink.rspnpm/crates/cli/tests/hoist.rspnpm/crates/cli/tests/hoisted_node_linker.rspnpm/crates/cli/tests/repeat_install.rspnpm/crates/lockfile/src/lib.rspnpm/crates/napi/src/install.rspnpm/crates/package-manager/src/add.rspnpm/crates/package-manager/src/create_virtual_store.rspnpm/crates/package-manager/src/install.rspnpm/crates/package-manager/src/install/tests.rspnpm/crates/package-manager/src/install_frozen_lockfile.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/package-manager/src/lib.rspnpm/crates/package-manager/src/prune_direct_deps.rspnpm/crates/package-manager/src/prune_stale_modules.rspnpm/crates/package-manager/src/remove.rspnpm/crates/package-manager/src/update.rspnpm/plans/TEST_PORTING.mdpnpr/crates/pnpr/src/resolver/resolve.rs
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. 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.4935469137800004,
"stddev": 0.1740131089816011,
"median": 2.42193447558,
"user": 1.47683164,
"system": 1.27026656,
"min": 2.33634530558,
"max": 2.7867031255800003,
"times": [
2.34063313858,
2.33634530558,
2.7867031255800003,
2.47106083258,
2.3520541545800002,
2.37280811858,
2.54316789758,
2.7137450275800004,
2.67061070658,
2.34834083058
]
},
{
"command": "pacquet@main",
"mean": 2.50644262668,
"stddev": 0.17045356563027725,
"median": 2.4115449905800004,
"user": 1.50486704,
"system": 1.2400813599999998,
"min": 2.34282535158,
"max": 2.74955509258,
"times": [
2.71258324958,
2.42464592358,
2.35471246258,
2.39227822358,
2.3984440575800003,
2.74955509258,
2.74246299258,
2.37140509658,
2.34282535158,
2.57551381658
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5250639881799999,
"stddev": 0.14326701662232952,
"median": 1.47263064658,
"user": 1.0594889399999998,
"system": 1.1130507600000004,
"min": 1.36877026558,
"max": 1.78083676358,
"times": [
1.44297327658,
1.6620141855800001,
1.78083676358,
1.50228801658,
1.37036548058,
1.6842259035800002,
1.43503404358,
1.42981237858,
1.5743195675800001,
1.36877026558
]
},
{
"command": "pnpr@main",
"mean": 1.4857289115800003,
"stddev": 0.15367580911972173,
"median": 1.4476626715800003,
"user": 1.0401842399999999,
"system": 1.10459146,
"min": 1.3414854205800002,
"max": 1.7507909275800002,
"times": [
1.58635314458,
1.5334751515800003,
1.35833788458,
1.36185019158,
1.6791772735800001,
1.35458457458,
1.3414854205800002,
1.54477343358,
1.3464611135800002,
1.7507909275800002
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24523851487999998,
"stddev": 0.0038612800455147694,
"median": 0.24421535798000002,
"user": 0.19643908,
"system": 0.50638506,
"min": 0.24114779898000002,
"max": 0.25341515598000003,
"times": [
0.24114779898000002,
0.24265907598000003,
0.24966530298,
0.24259524698,
0.24665797798000003,
0.24536690698000002,
0.24306380898000002,
0.24202941098000003,
0.24578446298,
0.25341515598000003
]
},
{
"command": "pacquet@main",
"mean": 0.24699029468000006,
"stddev": 0.005427673480379725,
"median": 0.24725247898000002,
"user": 0.19622637999999998,
"system": 0.50922746,
"min": 0.23680378698000001,
"max": 0.25365837398,
"times": [
0.23680378698000001,
0.25365837398,
0.24652888598000003,
0.24883229498,
0.25299108798000003,
0.24146370498000003,
0.24504607198000003,
0.24797607198000002,
0.25269226498,
0.24391040298000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26399836788000003,
"stddev": 0.006527590757263423,
"median": 0.26478642848,
"user": 0.20789697999999998,
"system": 0.5350426599999999,
"min": 0.25204550698,
"max": 0.27167471498,
"times": [
0.25511024898,
0.25204550698,
0.26083376898000005,
0.26476890998,
0.26707874998000003,
0.26944281198000003,
0.27116869398000004,
0.26480394698000004,
0.26305632598,
0.27167471498
]
},
{
"command": "pnpr@main",
"mean": 0.25832593078,
"stddev": 0.005960485691488778,
"median": 0.25787116948,
"user": 0.19532248,
"system": 0.5143006599999999,
"min": 0.24867569298000003,
"max": 0.26540988798000004,
"times": [
0.26320464498,
0.26404212198000004,
0.25783367898000004,
0.26540988798000004,
0.24867569298000003,
0.25150101398,
0.25790865998,
0.25581615998,
0.25376755198,
0.26509989498000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.683691950400001,
"stddev": 0.024011806819090018,
"median": 2.6937416086,
"user": 1.5685487999999999,
"system": 1.2660024599999997,
"min": 2.6367593271,
"max": 2.7080425921,
"times": [
2.6551827821000002,
2.6367593271,
2.6734727971000005,
2.6974435501,
2.7024025691,
2.6900396671,
2.6692968721000003,
2.7042528031,
2.7080425921,
2.7000265441
]
},
{
"command": "pacquet@main",
"mean": 2.7066425364000004,
"stddev": 0.015259073835909765,
"median": 2.7062596276000006,
"user": 1.6037095000000001,
"system": 1.2196746600000001,
"min": 2.6756499461,
"max": 2.7301206401,
"times": [
2.7150327951000004,
2.7301206401,
2.7222196521,
2.6967408251,
2.7139122891000005,
2.7041596071000003,
2.7053577901000003,
2.6960703541,
2.7071614651000004,
2.6756499461
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6010091142,
"stddev": 0.1306868684851154,
"median": 1.5870852841,
"user": 0.9550661,
"system": 1.14594036,
"min": 1.4016645901,
"max": 1.8059939271,
"times": [
1.5261245181,
1.4016645901,
1.5355103411,
1.5829527271000001,
1.6027983130999999,
1.5912178411,
1.7416397151,
1.7554053791000002,
1.8059939271,
1.4667837901
]
},
{
"command": "pnpr@main",
"mean": 1.5325524009,
"stddev": 0.11488406054267612,
"median": 1.5314985741,
"user": 0.9496684999999998,
"system": 1.1455877599999997,
"min": 1.3933711031,
"max": 1.7121510731,
"times": [
1.6714339311,
1.7121510731,
1.4103107800999999,
1.4482184951000001,
1.4190512580999999,
1.5683265241,
1.3933711031,
1.6061469601,
1.4946706241,
1.6018432601
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5457994786000001,
"stddev": 0.010804463519925525,
"median": 0.5482586215,
"user": 0.67270834,
"system": 0.6528913199999999,
"min": 0.5285337265000001,
"max": 0.5585038365000001,
"times": [
0.5371930645,
0.5488216715,
0.5476955715,
0.5401854965000001,
0.5582642845000001,
0.5509789635000001,
0.5585038365000001,
0.5558141135000001,
0.5320040575000001,
0.5285337265000001
]
},
{
"command": "pacquet@main",
"mean": 0.5353171479000001,
"stddev": 0.013809018037092953,
"median": 0.5397608970000001,
"user": 0.65034524,
"system": 0.66456532,
"min": 0.5125356635000001,
"max": 0.5501437495000001,
"times": [
0.5183043005000001,
0.5125356635000001,
0.5421784885,
0.5331956095000001,
0.5462764005,
0.5373433055000001,
0.5494061915000001,
0.5198478975,
0.5501437495000001,
0.5439398725000001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.2878246743,
"stddev": 0.005519617895755877,
"median": 0.2872418745,
"user": 0.17285563999999998,
"system": 0.5156295199999998,
"min": 0.27804399150000003,
"max": 0.2943414475,
"times": [
0.2924699045,
0.2930547855,
0.2879848035,
0.2841773865,
0.2840290265,
0.27804399150000003,
0.28354846250000004,
0.2943414475,
0.2864989455,
0.2940979895
]
},
{
"command": "pnpr@main",
"mean": 0.2896324884,
"stddev": 0.009519584491612401,
"median": 0.28787187550000004,
"user": 0.19651463999999996,
"system": 0.49261811999999994,
"min": 0.2770104265,
"max": 0.3068649295,
"times": [
0.2891362605,
0.3068649295,
0.30159607250000003,
0.2860789065,
0.27972358350000004,
0.2866613825,
0.2969992495,
0.2831717045,
0.2770104265,
0.2890823685
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.84107593522,
"stddev": 0.011404991539498147,
"median": 1.8389739342200002,
"user": 0.8811794199999999,
"system": 0.71894762,
"min": 1.8219575247200002,
"max": 1.85894278072,
"times": [
1.85894278072,
1.8219575247200002,
1.85066649272,
1.83528741272,
1.83460386472,
1.84253548072,
1.83980301572,
1.8381448527200002,
1.83249273072,
1.85632519672
]
},
{
"command": "pacquet@main",
"mean": 1.82724213512,
"stddev": 0.015947116377162795,
"median": 1.82381766522,
"user": 0.8651168200000001,
"system": 0.71346932,
"min": 1.80311458072,
"max": 1.85577834572,
"times": [
1.83714246572,
1.83062957172,
1.85577834572,
1.82211249472,
1.82305064072,
1.82458468972,
1.8471501897200002,
1.8163306867200002,
1.80311458072,
1.8125276857200001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29670110892000007,
"stddev": 0.007084018627412933,
"median": 0.29893900272000007,
"user": 0.16630591999999997,
"system": 0.5384275199999999,
"min": 0.28411691372000003,
"max": 0.30523577972000004,
"times": [
0.30385924672000003,
0.29898674172000006,
0.28411691372000003,
0.29889126372,
0.29989107672000004,
0.30523577972000004,
0.29266128072,
0.30245348072000006,
0.29374703672,
0.28716826872
]
},
{
"command": "pnpr@main",
"mean": 0.28943733442,
"stddev": 0.0060411236064779675,
"median": 0.28853367422000004,
"user": 0.17650401999999996,
"system": 0.5275986199999999,
"min": 0.28000374872000006,
"max": 0.30037623972000005,
"times": [
0.28000374872000006,
0.30037623972000005,
0.28835605472000003,
0.29384091372000004,
0.28415221972000004,
0.28574156272,
0.28566647072,
0.28871129372000004,
0.29210512472000005,
0.29541971572000003
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.31563968666000003,
"stddev": 0.007889613677522347,
"median": 0.31325592426000004,
"user": 0.30740292,
"system": 0.055175260000000004,
"min": 0.30558547726,
"max": 0.33072053026000003,
"times": [
0.31711717826,
0.32324322526000004,
0.33072053026000003,
0.32332424926000003,
0.30558547726,
0.31020410626,
0.30923306826,
0.31187163726,
0.31464021126,
0.31045718326000005
]
},
{
"command": "pacquet@main",
"mean": 0.32258871996000005,
"stddev": 0.011972697033719124,
"median": 0.31838572676,
"user": 0.31235102,
"system": 0.05690115999999999,
"min": 0.30845814826,
"max": 0.34218652626,
"times": [
0.30845814826,
0.34218652626,
0.33527338426000003,
0.31121915826,
0.31915571726,
0.31176442426,
0.32781847426000005,
0.31597256126,
0.33642306926000004,
0.31761573626
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08523327172875002,
"stddev": 0.0025377083567357105,
"median": 0.08579584076,
"user": 0.020394913750000004,
"system": 0.00768361125,
"min": 0.08119901826,
"max": 0.09033775126000002,
"times": [
0.08884418826000001,
0.08588021426,
0.08841297626000001,
0.08681387426,
0.08771270526000001,
0.08424885226,
0.08208436626000001,
0.08224459726000001,
0.08199875426000001,
0.08567540926000002,
0.08534136026000001,
0.08119901826,
0.08217632826000001,
0.08384334826,
0.08233273326000001,
0.08209413326000001,
0.08905907226000001,
0.08640114626,
0.08615130526,
0.09033775126000002,
0.08706392326000001,
0.08588976326000002,
0.08769215826000001,
0.08661105226000002,
0.08648005326000001,
0.08434477326,
0.08758287226000001,
0.08636550926000001,
0.08571146726000001,
0.08177867926000001,
0.08315581326,
0.08193649626
]
},
{
"command": "pnpr@main",
"mean": 0.0843403500478788,
"stddev": 0.0019347205742625635,
"median": 0.08495844926000001,
"user": 0.020642668484848484,
"system": 0.007121420000000001,
"min": 0.08146223226,
"max": 0.08789518026000001,
"times": [
0.08568826426000001,
0.08336929626,
0.08146223226,
0.08276594926000001,
0.08173518826000001,
0.08180437826,
0.08201191926000001,
0.08531456926000001,
0.08760920026,
0.08691443326,
0.08789518026000001,
0.08779920026000002,
0.08521173626,
0.08246541326000001,
0.08399564526000002,
0.08495714626,
0.08518079826000001,
0.08605128726000001,
0.08556641326000002,
0.08263044326,
0.08553533526000001,
0.08495844926000001,
0.08265273626000001,
0.08200485526000001,
0.08214987926,
0.08220045326000001,
0.08351539126,
0.08593716226,
0.08522281626000001,
0.08592949726000002,
0.08544882226000002,
0.08227407226000001,
0.08497338726
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.50046742136,
"stddev": 0.13046523023848708,
"median": 4.4421863864599995,
"user": 1.6379898599999998,
"system": 1.36838748,
"min": 4.4136440314600005,
"max": 4.78138012146,
"times": [
4.69378669946,
4.43774185946,
4.4136440314600005,
4.41750405246,
4.44663091346,
4.45450189846,
4.52061116746,
4.78138012146,
4.41852378446,
4.42034968546
]
},
{
"command": "pacquet@main",
"mean": 4.59594144116,
"stddev": 0.18542377540223798,
"median": 4.51003902496,
"user": 1.65883416,
"system": 1.3072936800000001,
"min": 4.41966443346,
"max": 4.87366406246,
"times": [
4.81857098846,
4.42057113146,
4.67998203646,
4.87366406246,
4.43188032646,
4.48601102646,
4.82875670546,
4.5340670234600005,
4.41966443346,
4.46624667746
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5713305010599994,
"stddev": 0.12937755295407236,
"median": 3.53278866346,
"user": 1.1701977599999998,
"system": 1.21516628,
"min": 3.4388244764600002,
"max": 3.79713846746,
"times": [
3.51699432846,
3.79713846746,
3.48909696346,
3.4819043344600002,
3.54858299846,
3.4388244764600002,
3.77119675646,
3.44807753746,
3.55770749846,
3.66378164946
]
},
{
"command": "pnpr@main",
"mean": 3.50486435376,
"stddev": 0.1006128733369873,
"median": 3.47073501696,
"user": 1.13916176,
"system": 1.2184818800000001,
"min": 3.4388947984600002,
"max": 3.77760982846,
"times": [
3.45890045746,
3.44933458646,
3.77760982846,
3.47323689546,
3.46823313846,
3.4435802244600002,
3.4388947984600002,
3.5226854104600003,
3.52721563546,
3.48895256246
]
}
]
} |
|
| Branch | pr/13151 |
| 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,401.66 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 284.12 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 278.04 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 81.20 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,368.77 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,438.82 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 252.05 ms |
6f165a4 to
ce2fa5c
Compare
|
Code review by qodo was updated up to the latest commit ce2fa5c |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13151 +/- ##
==========================================
+ Coverage 85.85% 85.91% +0.05%
==========================================
Files 505 506 +1
Lines 84029 84353 +324
==========================================
+ Hits 72147 72474 +327
+ Misses 11882 11879 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Code review by qodo was updated up to the latest commit 7408f66 |
Summary
Stage 1 of #13146: pacquet now reconciles an existing
node_moduleson repeat installs — the port of the removal half of pnpm'smodules-cleanerprune, plus the repair and validation semantics that were blocking 27 test ports.Engine (new
PruneStaleModulespass + fixes it surfaced):pnpm:rootremoved; orphaned snapshots' hoisted aliases are unlinked via the persisted.modules.yamlmap so the next hoist pass can claim the slots. The unique orphan-package count feeds onepnpm:statsremovedper install (replacing the placeholder inCreateVirtualStorethat predated a pruning pipeline). Orphan virtual-store directories stay the modules cache, swept only by the throttledprune_virtual_storepass — same as upstream'spruneVirtualStoregate.pnpm add/pnpm removenow fail withERR_PNPM_HOIST_PATTERN_DIFF/ERR_PNPM_PUBLIC_HOIST_PATTERN_DIFF/ERR_PNPM_VIRTUAL_STORE_DIR_MAX_LENGTH_DIFFagainst a drifted modules dir instead of silently recreating it; plain installs keep recreating (newinstalls_onlyflag = upstreaminstallsOnly/forceNewModules).pnpm:_broken_node_modules— pnpm's headless-repair semantics. Under GVS/hoisted linker the probe covers the importer links only.Lockfile::is_emptynow inspects all three group maps: upstream'sisEmptyLockfilereadsspecifiers, which its in-memory model populates for every group; pacquet's v9-inline model leaves it empty, so a dev-only install misread as empty and deleted its current lockfile.add/update flows.Test ports (all passing; each verified to fail against a deliberately broken implementation before landing):
hoist.rs: 16known_failuresstubs promoted to real ports (repeat-install map preservation, remove/rehoist/prune, alias hoisting, pattern-diff errors, workspace frozen replay and per-project update, combined public+private patterns).hoisted_node_linker.rs: all 6 manifest-mutation stubs promoted.repeat_install.rs: headless repair, no-inner-lockfile repeat, outer/inner lockfile divergence, non-prod-then-all include growth, dirty-tree reuse with a wiped store.TEST_PORTING.mdcheckboxes updated (24 entries ticked); the two peer-hoist stubs now carry their real blocker (a registry-mock fixture gap, not partial install).Parity note: Rust-only — every behavior here already exists in the TypeScript CLI; the changeset targets
pacquetonly.Remaining Stage-1 items (follow-ups, tracked in #13146):
install --forcestubs (#13142) and per-edgeengineStrict(#13143); direct-dep bin precedence andextendNodePathstubs; the two--filterstubs (Stage 2 dependency);misc.tsnpm-created-node_modulesrewrite and thepackageImportMethod=copycorrupted-state repair; the peer-hoist fixture pair.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting. — Rust-only: every behavior already exists in the TypeScript CLI (this is the pacquet side catching up).pnpm changeset) if this PR changes any published package.pnpm/plans/TEST_PORTING.mdcheckboxes.Written by an agent (Claude Code, claude-fable-5).
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
node_modulesmore reliably, removing stale direct links and hoisted aliases and repairing missing packages.pnpm add/pnpm removenow surface clearer errors when hoist or virtual-store settings drift unexpectedly.Improvements
Documentation
node_modulesreconciliation behavior.