Repository navigation
refactor(package-manager): decompose install modules - #13640
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:
📝 WalkthroughWalkthroughThe PR extracts the Rust install pipeline into dedicated modules for workspace state, lockfile freshness, module integrity, materialization phases, and execution orchestration. It adds package-tree filtering and normalized Git diffs to the patching crate with structured errors and filesystem validation. ChangesInstall pipeline modularization
Patch commit diff support
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
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 QodoRefactor package-manager: split install.rs into focused internal modules
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. False purge signal
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (12): Last reviewed commit: "fix(deps-installer): report refused purg..." | Re-trigger Greptile |
PR Code Suggestions ✨Latest suggestions up to 17ea32f Warning
Previous suggestionsSuggestions up to commit bc8803d
Suggestions up to commit a31e252
Suggestions up to commit 5f872ec
Suggestions up to commit 7e30cd7
Suggestions up to commit 5d76ef0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
🧹 Nitpick comments (3)
pnpm/crates/package-manager/src/install/run.rs (1)
658-667: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMove the
hoisted_locationsnote next to the tuple it documents.Lines 658-667 describe "the third tuple element", but the tuple is destructured at lines 1159-1164, about 490 lines below. Keep the dispatch-priority comment here and place the
hoisted_locationsparagraph directly above thelet (hoisted_dependencies, hoisted_locations, install_skipped, fresh_lockfile)binding.🤖 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/run.rs` around lines 658 - 667, Move the comment describing the third tuple element, hoisted_locations, from the dispatch-priority section to immediately above the let binding that destructures hoisted_dependencies, hoisted_locations, install_skipped, and fresh_lockfile. Keep the dispatch-priority comment in its current location and preserve the hoisted_locations wording.pnpm/crates/package-manager/src/install/modules_state.rs (1)
45-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRe-attach the doc and comment blocks the module split left behind. The decomposition moved functions into new modules but carried several doc blocks across boundaries without re-attaching them to the item they describe. The result is truncated text, duplicated paragraphs, function contracts attached to option structs, and one intra-doc link that no longer resolves. The fix at each site is the same: re-attach, deduplicate, or requalify the comment.
pnpm/crates/package-manager/src/install/modules_state.rs#L45-L70: split the block — lines 45-57 documentmodules_layout_consistent_with(line 264, currently undocumented); lines 58-69 documentfrozen_tree_intact.pnpm/crates/package-manager/src/install/workspace_state.rs#L22-L24: delete the truncated fragment ending in "same workspace discovery, same"; keep only the sentence describingUpToDateWorkspace.pnpm/crates/package-manager/src/install/workspace_state.rs#L448-L462: merge the two paragraphs that both describe the name/version index, the unnamed-project skip, and the0.0.0version fallback.pnpm/crates/package-manager/src/install/lockfile_freshness.rs#L133-L149: move the gate description fromCheckLockfileSettingsDriftOptionsontocheck_lockfile_settings_drift; keep thepnpmfile_checksumfield note on the struct.pnpm/crates/package-manager/src/install/modules_state.rs#L269-L281: keep one statement of thevirtualStoreOnlyrationale instead of two.pnpm/crates/package-manager/src/install/lifecycle.rs#L9-L18: qualify the link as[super::build_workspace_packages_map], since the symbol now lives inworkspace_state.rs.pnpm/crates/package-manager/src/install/run.rs#L658-L667: move thehoisted_locationsparagraph next to the tuple binding at lines 1159-1164.As per coding guidelines, "Use rustdoc comments for public API contracts and regular comments for implementation rationale" and comments must not "merely restate code, repeat callee documentation, describe removed implementation history, or narrate the function body".
🤖 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/modules_state.rs` around lines 45 - 70, Reattach and clean up the split documentation without changing behavior: in pnpm/crates/package-manager/src/install/modules_state.rs#L45-L70, assign the first block to modules_layout_consistent_with and the remainder to frozen_tree_intact; remove the duplicate virtualStoreOnly rationale at `#L269-L281`. In workspace_state.rs#L22-L24, remove the truncated fragment, and merge duplicate name/version-index paragraphs at `#L448-L462`. In lockfile_freshness.rs#L133-L149, move the gate documentation to check_lockfile_settings_drift while retaining the pnpmfile_checksum field note on CheckLockfileSettingsDriftOptions. In lifecycle.rs#L9-L18, qualify the link as super::build_workspace_packages_map. In run.rs#L658-L667, move the hoisted_locations documentation beside its tuple binding at `#L1159-L1164`; keep rustdoc for API contracts and regular comments for implementation rationale.Source: Coding guidelines
pnpm/crates/patching/src/commit/tests.rs (1)
311-325: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the unused
created_dirscounter.
CreateDirErrorFs::created_dirsis incremented increate_dir_allbut no test reads it. The only construction site is Line 140, which sets it to0. Delete the field to remove the dead state and theCellimport.♻️ Proposed cleanup
struct CreateDirErrorFs { fail_on: &'static str, - created_dirs: Cell<usize>, } impl PatchCommitFs for CreateDirErrorFs { fn symlink_metadata(&self, path: &Path) -> io::Result<fs::Metadata> { fs::symlink_metadata(path) } fn create_dir_all(&self, path: &Path) -> io::Result<()> { if path.ends_with(self.fail_on) { return Err(io::Error::new(io::ErrorKind::PermissionDenied, "blocked create_dir_all")); } - self.created_dirs.set(self.created_dirs.get() + 1); fs::create_dir_all(path) }Then update the construction site and the import:
- &CreateDirErrorFs { fail_on: "lib", created_dirs: Cell::new(0) }, + &CreateDirErrorFs { fail_on: "lib" },-use std::{cell::Cell, fs, io, path::Path}; +use std::{fs, io, path::Path};🤖 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/patching/src/commit/tests.rs` around lines 311 - 325, Remove the unused created_dirs field and its increment from CreateDirErrorFs, then update its construction site to stop initializing that field and remove the now-unused Cell import.
🤖 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/package-manager/src/install/modules_state.rs`:
- Around line 45-70: Reattach and clean up the split documentation without
changing behavior: in
pnpm/crates/package-manager/src/install/modules_state.rs#L45-L70, assign the
first block to modules_layout_consistent_with and the remainder to
frozen_tree_intact; remove the duplicate virtualStoreOnly rationale at
`#L269-L281`. In workspace_state.rs#L22-L24, remove the truncated fragment, and
merge duplicate name/version-index paragraphs at `#L448-L462`. In
lockfile_freshness.rs#L133-L149, move the gate documentation to
check_lockfile_settings_drift while retaining the pnpmfile_checksum field note
on CheckLockfileSettingsDriftOptions. In lifecycle.rs#L9-L18, qualify the link
as super::build_workspace_packages_map. In run.rs#L658-L667, move the
hoisted_locations documentation beside its tuple binding at `#L1159-L1164`; keep
rustdoc for API contracts and regular comments for implementation rationale.
In `@pnpm/crates/package-manager/src/install/run.rs`:
- Around line 658-667: Move the comment describing the third tuple element,
hoisted_locations, from the dispatch-priority section to immediately above the
let binding that destructures hoisted_dependencies, hoisted_locations,
install_skipped, and fresh_lockfile. Keep the dispatch-priority comment in its
current location and preserve the hoisted_locations wording.
In `@pnpm/crates/patching/src/commit/tests.rs`:
- Around line 311-325: Remove the unused created_dirs field and its increment
from CreateDirErrorFs, then update its construction site to stop initializing
that field and remove the now-unused Cell import.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 899dbe2e-4cb4-45b4-8496-c3cd6baae4e0
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (12)
pnpm/crates/package-manager/src/install.rspnpm/crates/package-manager/src/install/lifecycle.rspnpm/crates/package-manager/src/install/lockfile_freshness.rspnpm/crates/package-manager/src/install/modules_state.rspnpm/crates/package-manager/src/install/run.rspnpm/crates/package-manager/src/install/tests.rspnpm/crates/package-manager/src/install/workspace_state.rspnpm/crates/package-manager/src/lib.rspnpm/crates/patching/Cargo.tomlpnpm/crates/patching/src/commit.rspnpm/crates/patching/src/commit/tests.rspnpm/crates/patching/src/lib.rs
|
Code review by qodo was updated up to the latest commit 6794e7b |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13640 +/- ##
==========================================
+ Coverage 88.05% 88.10% +0.05%
==========================================
Files 574 582 +8
Lines 98386 98821 +435
==========================================
+ Hits 86633 87068 +435
Misses 11753 11753 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Code review by qodo was updated up to the latest commit 8a3d32b |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/package-manager/src/install/run.rs (1)
934-934: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBoth new phase-input structs borrow
prefixas&Stringinstead of&str. The extraction created two input structs that carry the reporter prefix. Both declare&'a String, which narrows the accepted type for no benefit. Every use is a clone, ato_owned, or a&strargument. The pnpm Rust code style guide requires the broadest suitable borrowed type.
pnpm/crates/package-manager/src/install/run.rs#L934-L934: changeprefix: &'a Stringtoprefix: &'a strinPrepareModulesStateInputs.pnpm/crates/package-manager/src/install/run.rs#L1340-L1340: changeprefix: &'a Stringtoprefix: &'a strinMaterializationInputs, and confirm therequesterfields at Lines 1530 and 1603 accept&str.Call sites pass
&prefixfrom an ownedString, so deref coercion keeps them unchanged.As per coding guidelines: "Choose owned versus borrowed parameters to minimize copies and prefer the broadest suitable borrowed types, such as
&Pathover&PathBufand&strover&String."🤖 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/run.rs` at line 934, Update the prefix fields in PrepareModulesStateInputs at pnpm/crates/package-manager/src/install/run.rs:934-934 and MaterializationInputs at pnpm/crates/package-manager/src/install/run.rs:1340-1340 from &String to &str. Confirm the requester fields at lines 1530 and 1603 accept &str, while leaving existing call sites unchanged.Source: Coding guidelines
🤖 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/package-manager/src/install/run.rs`:
- Line 934: Update the prefix fields in PrepareModulesStateInputs at
pnpm/crates/package-manager/src/install/run.rs:934-934 and MaterializationInputs
at pnpm/crates/package-manager/src/install/run.rs:1340-1340 from &String to
&str. Confirm the requester fields at lines 1530 and 1603 accept &str, while
leaving existing call sites unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c460d212-28d1-4c21-8807-3d28e6553be5
📒 Files selected for processing (1)
pnpm/crates/package-manager/src/install/run.rs
|
Code review by qodo was updated up to the latest commit 57d7e61 |
|
Code review by qodo was updated up to the latest commit c1eabcc |
|
Addressed the latest Qodo review in commit
Validation passed: the focused TypeScript suite (10 tests), the Rust approval-builds suite (16 tests), and Written by an agent (Codex, GPT-5.6). |
|
Code review by qodo was updated up to the latest commit a31e252 |
|
Code review by qodo was updated up to the latest commit bc8803d |
|
Code review by qodo was updated up to the latest commit 17ea32f |
|
Found 1 test failure on Blacksmith runners: Failure
|
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.jsonScenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.jsonScenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.jsonScenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.jsonScenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.jsonScenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.jsonScenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.jsonScenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json |
|
| Project | pnpm's project |
| Branch | pr/13640 |
| 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,468.69 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 327.08 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 303.04 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 90.73 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,443.95 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,681.61 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 386.02 ms |
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
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light.png)
Summary
Decompose pacquet's 4,583-line package-manager
install.rsinto focused internal modules for the install coordinator, lockfile freshness, modules state, lifecycle execution, and workspace state. The public install module is now about 800 lines, and no new crate or duplicate implementation is introduced. Split the install coordinator’s former roughly 1,900-linerun_innerinto typed phases;run_inneris now about 900 lines. Move the regular install phases intoprepare_modules_state.rs,materialize.rs, andapply_materialization.rs, matching the phase-per-module structure ofinstall_with_fresh_lockfile/. Decompose post-materialization work by ownership into resolve-only completion, materialized-state selection, project linking, modules-state commit, project lifecycle execution, workspace-state update, and final reporting.Move
patch_commit.rsunchanged into the existingpacquet-patchingcrate, where package filtering and diff generation belong. Keeppatch.rsin package-manager because it coordinates lockfile selection, fetching, and package materialization.Most changes are internal Rust refactors. Review-driven fixes also prevent both the TypeScript and Rust installers from purging project files when
modulesDirresolves to the project root, and ensure the Rust installer writes blocked-build approval scaffolding to the discovered workspace manifest when per-project lockfiles are enabled.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.Written by an agent (Codex, GPT-5.6).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Bug Fixes
Tests