Repository navigation
refactor(deps-restorer): split create_virtual_store, and fix stale file: dependency copies - #13649
Conversation
…rtition `CreateVirtualStore::run` was 794 lines, two thirds of its file, and read as one sequence with no boundary between the decisions it makes. Extract the two largest phases into modules, leaving `run` at 517: - `snapshot_plan` — which snapshots this install must materialize and which the current-lockfile check leaves alone, plus the store-index cache key each is looked up by. The asymmetry is worth a name: survivors take the strict key derivation because a malformed resolution must fail before the warm batch starts, while skipped snapshots take a lenient pass because a per-snapshot error there costs only a prefetch row. - `partition` — the warm/cold split and the store-index rows the build and bin phases read. Skipped snapshots are walked here too: they have no link work, but dropping their side-effects rows would make the build phase re-run approved scripts on every warm reinstall. `SnapshotWithCacheKey` was a type alias local to `run`; it moves to module scope so both phases can name it. Pure moves. No behaviour change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
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:
📝 WalkthroughWalkthrough
ChangesVirtual store installation flow
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CreateVirtualStoreRun
participant plan_snapshots
participant partition_snapshots
participant ColdFetch
participant CreateVirtualDirBySnapshot
CreateVirtualStoreRun->>plan_snapshots: plan snapshots and cache keys
CreateVirtualStoreRun->>partition_snapshots: partition prefetched snapshots
partition_snapshots-->>CreateVirtualStoreRun: warm and cold batches plus metadata
CreateVirtualStoreRun->>ColdFetch: fetch CAS paths for cold entries
CreateVirtualStoreRun->>CreateVirtualDirBySnapshot: materialize slot with source mutability
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(deps-restorer): extract snapshot planning and prefetch partitioning
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Confidence Score: 5/5The PR appears safe to merge because no eligible blocking failure remains in the follow-up review scope. No blocking failure remains. Reviews (6): Last reviewed commit: "test(cli): guard the hoisted linker's di..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (5)
pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs (3)
71-103: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the PR-relative wording from these comments.
Line 76 says "Installability skip (this PR)" and Line 85 says "Current-lockfile skip (main <…/pull/442>)". Both anchor the comment to the change history rather than to the invariant. After this refactor lands, "this PR" no longer identifies anything. State the two skip reasons and their consequences without the history references.
♻️ Proposed wording change
- // 1. **Installability skip (this PR)** — `SkippedSnapshots` + // 1. **Installability skip** — `SkippedSnapshots` @@ - // 2. **Current-lockfile skip (main <https://github.com/pnpm/pacquet/pull/442>)** — the previous + // 2. **Current-lockfile skip** — the previous🤖 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/deps-restorer/src/create_virtual_store/snapshot_plan.rs` around lines 71 - 103, Update the explanatory comments in the per-snapshot skip pass to remove the PR-relative references “this PR” and “main <…/pull/442>”. Describe the two skip reasons and their consequences directly in terms of installability constraints and current-lockfile reuse, without mentioning change history.Source: Path instructions
209-210: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse the imported
HashSet.Line 16 already imports
HashSet. Line 209 qualifies it asstd::collections::HashSet, which is inconsistent withmarker_probe_keysandmarker_rebuildsat Lines 104-105.♻️ Proposed fix
- let survivor_keys: std::collections::HashSet<&PackageKey> = - snapshot_entries.iter().map(|(k, _, _)| *k).collect(); + let survivor_keys: HashSet<&PackageKey> = + snapshot_entries.iter().map(|(k, _, _)| *k).collect();🤖 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/deps-restorer/src/create_virtual_store/snapshot_plan.rs` around lines 209 - 210, Update the survivor_keys declaration in the snapshot planning logic to use the already imported HashSet directly, matching the style of marker_probe_keys and marker_rebuilds; keep the existing type and collection logic unchanged.
18-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider importing
AllowBuildPolicyand passingSnapshotPlanInputsby value.Every field of
SnapshotPlanInputsisCopy, soplan_snapshotscopies all of them out of the reference at Line 59. Taking the struct by value removes the redundant indirection. Also,crate::AllowBuildPolicyis the only type referenced by inline path here, whileSkippedSnapshotsandVirtualStoreLayoutare imported at Line 11. Explicit imports are the documented convention for this crate.♻️ Proposed consistency tweak
-use crate::{SkippedSnapshots, VirtualStoreLayout}; +use crate::{AllowBuildPolicy, SkippedSnapshots, VirtualStoreLayout}; @@ - pub allow_build_policy: &'a crate::AllowBuildPolicy, + pub allow_build_policy: &'a AllowBuildPolicy,🤖 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/deps-restorer/src/create_virtual_store/snapshot_plan.rs` around lines 18 - 32, Update SnapshotPlanInputs and plan_snapshots to pass the inputs struct by value instead of by reference, preserving the existing field usage. Import AllowBuildPolicy alongside the existing VirtualStoreLayout and SkippedSnapshots imports, then use the imported type in the allow_build_policy field declaration rather than the inline crate path.Source: Path instructions
pnpm/crates/deps-restorer/src/create_virtual_store/partition.rs (1)
19-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftConsider a named struct instead of the five-field
WarmEntrytuple.
WarmEntrycarries two scalar fields of different meaning,&'a strandbool, in adjacent positions. The three consumers increate_virtual_store.rsat Lines 443, 481, and 497 destructure it positionally, so a field reorder compiles silently in some combinations. A struct with named fields removes that risk and makes the doc comment at Lines 17-18 unnecessary.🤖 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/deps-restorer/src/create_virtual_store/partition.rs` around lines 19 - 25, The five-field WarmEntry tuple is vulnerable to positional misuse and should become a named struct. Define a WarmEntry struct with fields corresponding to the existing package key, snapshot entry, paths map, string, and boolean values, then update all three consumers in create_virtual_store.rs to construct and access these named fields; remove the now-unnecessary tuple doc comment while preserving behavior.pnpm/crates/deps-restorer/src/create_virtual_store.rs (1)
76-80: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReduce
SnapshotWithCacheKeyvisibility topub(super).
snapshot_planandpartitionimport the alias throughsuper::{...}, which gives child modules access without exposing it to unrelated crate modules. If the alias should remain crate-scoped, document that visibility outside the type definition.🤖 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/deps-restorer/src/create_virtual_store.rs` around lines 76 - 80, Reduce the visibility of the SnapshotWithCacheKey type alias from pub(crate) to pub(super), since snapshot_plan and partition access it through their parent module and no unrelated crate modules need it.
🤖 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/deps-restorer/src/create_virtual_store/partition.rs`:
- Around line 120-166: Extract the duplicated store-index row logic into a
shared helper near the surrounding partition code, accepting the snapshot key,
optional cache key, prefetch data, marker rebuild set, and the three mutable
destination maps. Centralize the manifest, marker-gated side-effects, and
requires-build updates there, evaluating the optional cache key once, then
replace both the skipped-entry and snapshot-entry blocks with calls to the
helper while preserving their existing inputs and behavior.
- Around line 64-89: The comments are detached from the code they explain. In
pnpm/crates/deps-restorer/src/create_virtual_store/partition.rs lines 64-89,
retain only the partition criterion and move the rayon-versus-tokio rationale
and benchmark details beside the warm-batch link_slots_parallel call in
create_virtual_store.rs; at lines 90-94, delete or rewrite the “no explicit
alias” paragraph to reflect the existing WarmEntry alias; in
pnpm/crates/deps-restorer/src/create_virtual_store.rs lines 367-381, move the
snapshot-walking and cache-key-derivation rationale beside the relevant logic in
snapshot_plan.rs while keeping only the sort-and-dedup explanation for lines
405-411.
In `@pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs`:
- Around line 56-58: Add an external unit-test module for plan_snapshots
covering the directory-resolution carve-out, missing-slot BrokenModules reporter
emission, and marker-rebuild set population. Use tempfile::TempDir for slot
probes and a recording Reporter to assert emitted missing-slot events, while
constructing inputs that exercise the snapshot_deps_equal and integrity_equal
gates as needed.
---
Nitpick comments:
In `@pnpm/crates/deps-restorer/src/create_virtual_store.rs`:
- Around line 76-80: Reduce the visibility of the SnapshotWithCacheKey type
alias from pub(crate) to pub(super), since snapshot_plan and partition access it
through their parent module and no unrelated crate modules need it.
In `@pnpm/crates/deps-restorer/src/create_virtual_store/partition.rs`:
- Around line 19-25: The five-field WarmEntry tuple is vulnerable to positional
misuse and should become a named struct. Define a WarmEntry struct with fields
corresponding to the existing package key, snapshot entry, paths map, string,
and boolean values, then update all three consumers in create_virtual_store.rs
to construct and access these named fields; remove the now-unnecessary tuple doc
comment while preserving behavior.
In `@pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs`:
- Around line 71-103: Update the explanatory comments in the per-snapshot skip
pass to remove the PR-relative references “this PR” and “main <…/pull/442>”.
Describe the two skip reasons and their consequences directly in terms of
installability constraints and current-lockfile reuse, without mentioning change
history.
- Around line 209-210: Update the survivor_keys declaration in the snapshot
planning logic to use the already imported HashSet directly, matching the style
of marker_probe_keys and marker_rebuilds; keep the existing type and collection
logic unchanged.
- Around line 18-32: Update SnapshotPlanInputs and plan_snapshots to pass the
inputs struct by value instead of by reference, preserving the existing field
usage. Import AllowBuildPolicy alongside the existing VirtualStoreLayout and
SkippedSnapshots imports, then use the imported type in the allow_build_policy
field declaration rather than the inline crate path.
🪄 Autofix
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: b5dbd4aa-56df-49c3-891d-787898f3e11b
📒 Files selected for processing (3)
pnpm/crates/deps-restorer/src/create_virtual_store.rspnpm/crates/deps-restorer/src/create_virtual_store/partition.rspnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs
Code Review by Qodo
1. Wasted lockfile equality scan
|
Micro-Benchmark ResultsLinux |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13649 +/- ##
=======================================
Coverage 88.08% 88.09%
=======================================
Files 582 584 +2
Lines 98601 98677 +76
=======================================
+ Hits 86853 86929 +76
Misses 11748 11748 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The extracted phases carried long blocks narrating what the code does, including scenarios the suite already pins: the two skip reasons (`skip_failing_optional_dependencies`, `repeat_install`, `hoisting_skips_broken_symlink_for_skipped_optional`), the abort-on-malformed-lockfile path (`install/tests.rs` asserts `MissingPackageMetadata`), and the peer-variant manifest keying. A test is a better record of behaviour than prose: it cannot drift. Those blocks shrink to the parts no test carries — the ordering constraint that the skip pass must precede cache-key derivation, why the slot probe goes through `layout.slot_dir` under GVS, and why the skipped entries are built as a parallel `Vec`. Kept in full: the rayon-versus-tokio profiling numbers, which are the only record of why the warm batch is shaped that way and which no test asserts. Comment lines 108 -> 57 in `snapshot_plan` and 78 -> 44 in `partition`, with the code unchanged in both. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Caught by `perfectionist::unicode-ellipsis-in-comments`.
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs (1)
71-74: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect the directory-resolution comment.
Lines 105-109 return
truefrom thefilter, so directory snapshots remain insurvivors. Lines 139-144 then derive their cache keys. The comment incorrectly states that these snapshots are dropped before cache-key derivation. Remove that claim and document the actual invariant: directory snapshots bypass the current-lockfile skip so the cold path re-walks mutable local sources.🤖 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/deps-restorer/src/create_virtual_store/snapshot_plan.rs` around lines 71 - 74, Update the ordering comment near the snapshot filtering logic to remove the incorrect claim that directory-backed snapshots are dropped before cache-key derivation. Document instead that directory snapshots bypass the current-lockfile skip, allowing the cold path to re-walk mutable local sources before cache-key derivation.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs (1)
1202-1202: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUpdate the
host_nodecontract comment.Lines 1199-1201 describe a
(node_detected, node_version)tuple. Line 1202 exposesHostNodeinstead. Update the comment to describeHostNode, or remove the field-level comment if the type documentation is sufficient.As per coding guidelines, “Use rustdoc comments for public API contracts and regular comments for implementation rationale.”
🤖 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/deps-restorer/src/install_frozen_lockfile.rs` at line 1202, Update the documentation associated with the public host_node field to describe its actual Option<&HostNode> contract instead of the outdated (node_detected, node_version) tuple. Use a rustdoc comment for this public API documentation, or remove the field-level comment if HostNode’s existing type documentation fully covers it.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/deps-restorer/src/create_virtual_store/snapshot_plan.rs`:
- Around line 71-74: Update the ordering comment near the snapshot filtering
logic to remove the incorrect claim that directory-backed snapshots are dropped
before cache-key derivation. Document instead that directory snapshots bypass
the current-lockfile skip, allowing the cold path to re-walk mutable local
sources before cache-key derivation.
In `@pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs`:
- Line 1202: Update the documentation associated with the public host_node field
to describe its actual Option<&HostNode> contract instead of the outdated
(node_detected, node_version) tuple. Use a rustdoc comment for this public API
documentation, or remove the field-level comment if HostNode’s existing type
documentation fully covers it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c6ad2476-8804-4c6b-bf1a-5e7ac19a3260
📒 Files selected for processing (6)
pnpm/crates/deps-restorer/src/create_virtual_store/partition.rspnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rspnpm/crates/deps-restorer/src/install_frozen_lockfile.rspnpm/crates/deps-restorer/src/linking.rspnpm/crates/deps-restorer/src/materialization_plan.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm/crates/deps-restorer/src/create_virtual_store/partition.rs
The skip-pass comment said the ordering exists so directory-backed snapshots are not "tripped by `snapshot_cache_key`'s `UnsupportedResolution`". `snapshot_cache_key` cannot produce that variant — it lives in `install_package_by_snapshot` and is raised at install time — and its only failure is `MissingPackageMetadata`, via `ok_or_else`. Its `Directory` arm returns `Ok(None)`. Removed rather than reworded: the strict-versus-lenient distinction the ordering actually serves is already stated on `plan_snapshots`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Code review by qodo was updated up to the latest commit 1bc5dc6 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
pnpm's `file:` is a copy taken at install time, not a symlink like `link:`, so each install has to retake the copy — the source is mutable by definition and can change with nothing in the lockfile moving. A second install left the first install's copy in place instead. Two gates had to give way, each independently sufficient to cause it: - `prepare_modules_state`'s optimistic repeat-install short-circuit concluded the tree was current from an equal lockfile plus existence probes, and returned before materialization ran at all. Directory resolutions now disqualify the short-circuit. The TypeScript CLI has no gate at this level; it always runs headless and lets `lockfileToDepGraph` decide per package, where `depIsPresent` is hard-gated on `!isDirectoryDep`. - `import_indexed_dir`'s completion-marker check then treated the existing slot as complete. That check is correct for CAS entries, which are immutable by key, but a directory resolution's file map points at mutable source, so those slots now take the `force` / `stage_and_swap` path that already served interrupted builds. `keep_modules_dir` preserves the child links. `create_virtual_store`'s cold capture becomes a named struct so the resolution kind rides along to the link pass instead of widening a positional tuple. Found while checking whether the directory carve-out in `plan_snapshots` could be pinned by a test instead of described in a comment. It could not — the carve-out was unreachable on the very install it existed to serve. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
file: dependency copies
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/deps-restorer/src/install_package_by_snapshot.rs`:
- Line 639: Update the source_is_mutable assignment in the package snapshot
installation flow to match the effective resolution used by fetching,
referencing resolution rather than metadata.resolution. Add a regression test
covering a custom fetcher that delegates to LockfileResolution::Directory and
verifies changed directory contents are re-copied on the next install.
🪄 Autofix
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: c06c12f2-91d6-46c9-a8a7-86ea67545528
📒 Files selected for processing (8)
.changeset/directory-dep-recopy.mdpnpm/crates/cli/tests/repeat_install.rspnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rspnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot/tests.rspnpm/crates/deps-restorer/src/create_virtual_store.rspnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rspnpm/crates/deps-restorer/src/install_package_by_snapshot.rspnpm/crates/package-manager/src/install/prepare_modules_state.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs
|
Code review by qodo was updated up to the latest commit d17121a |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
A custom fetcher's `delegate` can resolve to a directory, so reading the lockfile's own resolution missed the case where the file map points at mutable source but the lockfile entry does not say so. The installer now reports it from the effective resolution, which is the only place that knows, and returns it alongside the CAS map as `InstalledPackage`. The cold batch reads it from there rather than re-deriving it from metadata it cannot see through. Also folds the two identical store-index row collections in `partition_snapshots` into one `IndexRows::absorb`, so a skipped snapshot and a survivor cannot diverge in what they contribute. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit bdd956f |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pnpm/crates/deps-restorer/src/create_virtual_store/partition.rs (1)
80-81: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the loop narration.
Line 80 and Line 81 only describe the loop that follows. Delete this comment. The cache-key comment below explains a reporter contract and should remain.
As per coding guidelines, comments must not merely restate code or narrate function bodies.
🤖 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/deps-restorer/src/create_virtual_store/partition.rs` around lines 80 - 81, Remove the loop-narration comment immediately before the second-pass survivor loop in the partitioning logic, while preserving the cache-key contract comment that follows it.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.
Inline comments:
In `@pnpm/crates/deps-restorer/src/install_package_by_snapshot.rs`:
- Line 292: Update the rustdoc for the run method returning InstalledPackage to
describe the InstalledPackage result, including its source_is_mutable metadata,
instead of documenting a raw CAS file map. Revise the linker-specific
descriptions to match the current return contract while preserving the existing
behavior details.
- Line 669: Update the hoisted install flow in create_virtual_store.rs to retain
source_is_mutable alongside cas_paths in cas_paths_by_pkg_id. In
link_hoisted_modules(), use that flag for directory resolutions and call
import_indexed_dir() with force enabled and keep_modules_dir enabled so file:
packages are rebuilt rather than reusing the prior install’s copy.
---
Nitpick comments:
In `@pnpm/crates/deps-restorer/src/create_virtual_store/partition.rs`:
- Around line 80-81: Remove the loop-narration comment immediately before the
second-pass survivor loop in the partitioning logic, while preserving the
cache-key contract comment that follows it.
🪄 Autofix
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: 0e099e2e-fcde-47da-a9df-a5dd3319cf96
📒 Files selected for processing (4)
pnpm/crates/deps-restorer/src/create_virtual_store.rspnpm/crates/deps-restorer/src/create_virtual_store/partition.rspnpm/crates/deps-restorer/src/install_package_by_snapshot.rspnpm/crates/deps-restorer/src/install_package_by_snapshot/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm/crates/deps-restorer/src/create_virtual_store.rs
The hoisted linker imports straight into the flat `node_modules/` rather than into a virtual-store slot, so it needs its own guard that a `file:` dependency's copy is retaken when the source moves. Verified to fail without the repeat-install gate carve-out. Also corrects `InstallPackageBySnapshot::run`'s return contract, which still described a bare CAS map. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 2420d85 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7559751566999995,
"stddev": 0.19633731164921187,
"median": 2.8649785719,
"user": 2.19357276,
"system": 1.7716785800000003,
"min": 2.4723309904,
"max": 2.9569778834,
"times": [
2.8392758734,
2.9006201944,
2.5311456974,
2.9569778834,
2.6170074164,
2.9363652134,
2.8987298254,
2.5166172024,
2.8906812704,
2.4723309904
]
},
{
"command": "pacquet@main",
"mean": 2.6889365047,
"stddev": 0.22533571361367666,
"median": 2.6252055159000003,
"user": 2.1790255600000004,
"system": 1.76703908,
"min": 2.3950862304,
"max": 3.0653842384,
"times": [
2.7825341064,
2.9405453834,
2.6330461654,
2.5499900114,
3.0653842384,
2.6173648664,
2.5517030894,
2.9115680314,
2.3950862304,
2.4421429244
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5279711293999998,
"stddev": 0.16132970709760908,
"median": 1.4773799213999999,
"user": 1.1448684599999996,
"system": 1.19381738,
"min": 1.3681786674,
"max": 1.8062206144,
"times": [
1.8062206144,
1.3821152684,
1.3681786674,
1.6471282783999999,
1.3898521614,
1.7060100234,
1.4748346574,
1.3722862004,
1.6531602374,
1.4799251854
]
},
{
"command": "pnpr@main",
"mean": 1.5252425966,
"stddev": 0.13168772735780035,
"median": 1.5376672948999999,
"user": 1.1689528599999999,
"system": 1.23243248,
"min": 1.3596301444,
"max": 1.7673302554,
"times": [
1.4860260344,
1.5532448604,
1.7673302554,
1.5916739544,
1.3822958004,
1.6365433174000001,
1.5220897294,
1.5903302304,
1.3596301444,
1.3632616394000001
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.32268490848,
"stddev": 0.056629216708196366,
"median": 0.30512055567999996,
"user": 0.27174807999999995,
"system": 0.59281442,
"min": 0.27118611968,
"max": 0.42373058468,
"times": [
0.29881765868,
0.42373058468,
0.42226605368000003,
0.33872800468,
0.31142345268,
0.27999547668,
0.28536684268,
0.27118611968,
0.27946805268,
0.31586683868
]
},
{
"command": "pacquet@main",
"mean": 0.44204864788,
"stddev": 0.190556359408575,
"median": 0.39145990468,
"user": 0.36746488,
"system": 0.7198073199999999,
"min": 0.27250220068000003,
"max": 0.86374730968,
"times": [
0.28484252468,
0.29154086068,
0.27250220068000003,
0.37197552968,
0.42286122468000004,
0.41094427968,
0.32607040368,
0.51532933768,
0.86374730968,
0.66067280768
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29874372298,
"stddev": 0.02002424244835711,
"median": 0.29340470418,
"user": 0.24988547999999997,
"system": 0.5483649199999998,
"min": 0.27867062868000003,
"max": 0.34323062168,
"times": [
0.29955835568,
0.32062178168,
0.28001187668,
0.34323062168,
0.28857112268,
0.30497844168,
0.29142256668,
0.29538684168,
0.27867062868000003,
0.28498499268
]
},
{
"command": "pnpr@main",
"mean": 0.29182862608,
"stddev": 0.0178942770141207,
"median": 0.28617575868,
"user": 0.23700997999999998,
"system": 0.5691888199999998,
"min": 0.26255575968,
"max": 0.32045965668,
"times": [
0.30919444068,
0.31549670068,
0.32045965668,
0.28507282368000003,
0.28706199468,
0.27888211168,
0.28391971968,
0.29035353068,
0.28528952268,
0.26255575968
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7257002666599996,
"stddev": 0.07106612859198326,
"median": 2.70528184256,
"user": 1.8295808999999998,
"system": 1.5016443799999997,
"min": 2.64893869706,
"max": 2.88690069506,
"times": [
2.66743440806,
2.72730564206,
2.68160610906,
2.68059070406,
2.64893869706,
2.68325804306,
2.73965696906,
2.77962415406,
2.76168724506,
2.88690069506
]
},
{
"command": "pacquet@main",
"mean": 3.05591200276,
"stddev": 0.1923838247446465,
"median": 3.0105202050599997,
"user": 2.4933509000000003,
"system": 2.1217961799999996,
"min": 2.80526569906,
"max": 3.4260286830599997,
"times": [
2.95831075306,
2.80526569906,
2.83630764606,
2.9705443040599997,
3.15424025706,
3.0504961060599998,
3.26519316006,
2.96099818306,
3.13173523606,
3.4260286830599997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.7492241269600002,
"stddev": 0.12861883484866615,
"median": 1.76117623206,
"user": 1.6584949000000002,
"system": 1.80696098,
"min": 1.56552109906,
"max": 1.91530744406,
"times": [
1.8744104960599999,
1.7541420690599998,
1.56552109906,
1.89010007706,
1.62937215506,
1.76821039506,
1.57475583106,
1.91530744406,
1.81768845106,
1.7027332520599998
]
},
{
"command": "pnpr@main",
"mean": 1.80693084836,
"stddev": 0.1342030415135326,
"median": 1.80872637656,
"user": 1.5620068999999996,
"system": 1.6178863799999998,
"min": 1.60577684806,
"max": 2.0172598270599997,
"times": [
1.60577684806,
1.9009368600599998,
1.80841292106,
1.88929249906,
1.9334567860599998,
1.77715001806,
1.8090398320599999,
1.6192330740599998,
2.0172598270599997,
1.7087498180599998
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7457948900000001,
"stddev": 0.11776178145988614,
"median": 0.7109085242,
"user": 1.0556451999999998,
"system": 1.01189548,
"min": 0.6040450797,
"max": 0.9289433087000001,
"times": [
0.9289433087000001,
0.6040450797,
0.7123767177,
0.6999067857,
0.6495949287,
0.8870386817,
0.8821775777,
0.7730937217,
0.6113317677,
0.7094403307
]
},
{
"command": "pacquet@main",
"mean": 0.6099498139999999,
"stddev": 0.06309680580597242,
"median": 0.5976489017,
"user": 0.8766128999999999,
"system": 0.9006437799999999,
"min": 0.5328406727,
"max": 0.6880243437,
"times": [
0.5482422897,
0.5687351077,
0.5519033337,
0.6265626957,
0.6853196147,
0.6880243437,
0.6665039587,
0.6690349107,
0.5623312127,
0.5328406727
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3941090911,
"stddev": 0.01711602261074671,
"median": 0.3896505742,
"user": 0.29830439999999997,
"system": 0.67206918,
"min": 0.3774225697,
"max": 0.4361338727,
"times": [
0.3990756737,
0.3941780607,
0.4361338727,
0.3835989537,
0.3774225697,
0.4041931927,
0.3851230877,
0.3962448877,
0.3812915937,
0.3838290187
]
},
{
"command": "pnpr@main",
"mean": 0.416271781,
"stddev": 0.04778036963556326,
"median": 0.4151841027,
"user": 0.3238929,
"system": 0.67674958,
"min": 0.3442790037,
"max": 0.4878737857,
"times": [
0.43213166470000003,
0.4029001237,
0.4005742077,
0.3894531007,
0.4356624597,
0.4878737857,
0.4855739707,
0.4274680817,
0.3442790037,
0.3568014117
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.925931524,
"stddev": 0.08297881529116775,
"median": 1.91187355,
"user": 1.04408024,
"system": 0.9569534200000002,
"min": 1.8060466560000001,
"max": 2.051299008,
"times": [
2.018794927,
1.964282123,
2.051299008,
2.013381291,
1.895991533,
1.84817917,
1.856839758,
1.8060466560000001,
1.927755567,
1.8767452070000001
]
},
{
"command": "pacquet@main",
"mean": 1.9964899839,
"stddev": 0.11318769619289909,
"median": 1.963119495,
"user": 1.2171953399999997,
"system": 1.01250362,
"min": 1.894376077,
"max": 2.2521943120000003,
"times": [
1.894913449,
1.948793641,
1.894376077,
1.92980341,
1.9774453490000001,
1.9174048339999998,
1.984322315,
2.102561975,
2.2521943120000003,
2.0630844770000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.38769732000000007,
"stddev": 0.02073043036572916,
"median": 0.3933006845,
"user": 0.28395364,
"system": 0.65760432,
"min": 0.34044476700000004,
"max": 0.40982776400000004,
"times": [
0.394529531,
0.392071838,
0.391233697,
0.399295758,
0.39669218900000003,
0.375170805,
0.40745257500000004,
0.370254276,
0.34044476700000004,
0.40982776400000004
]
},
{
"command": "pnpr@main",
"mean": 0.4024408255,
"stddev": 0.017642716586654096,
"median": 0.39862946600000004,
"user": 0.30563783999999994,
"system": 0.66044932,
"min": 0.36899665600000003,
"max": 0.430832422,
"times": [
0.39965921200000004,
0.39855276700000003,
0.398679585,
0.419016025,
0.422366832,
0.39214075800000003,
0.36899665600000003,
0.430832422,
0.39857934700000003,
0.395584651
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.41978077368,
"stddev": 0.09414342152981887,
"median": 0.42906712968,
"user": 0.38213162,
"system": 0.14885140000000002,
"min": 0.29638972118,
"max": 0.55019222018,
"times": [
0.29638972118,
0.30687726418,
0.34727395218,
0.40611947218,
0.33972800718,
0.47417444418,
0.54198419418,
0.48305367418,
0.55019222018,
0.45201478718
]
},
{
"command": "pacquet@main",
"mean": 0.36951423818,
"stddev": 0.07288311668802797,
"median": 0.34793492368,
"user": 0.33612352,
"system": 0.13356819999999997,
"min": 0.30402902317999997,
"max": 0.55837612818,
"times": [
0.38647703118,
0.55837612818,
0.31930686518,
0.39265122118,
0.35212242318,
0.33778161618,
0.34374742418,
0.30402902317999997,
0.32035214718,
0.38029850218
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10688190970173914,
"stddev": 0.009215362744567199,
"median": 0.10357991218000001,
"user": 0.02811474608695651,
"system": 0.018149347826086955,
"min": 0.09465872218,
"max": 0.13051357018,
"times": [
0.11942305018,
0.10357991218000001,
0.10608777018000001,
0.10444118518,
0.10129635718,
0.12638384418,
0.10305854918,
0.09765903018000001,
0.10324953918,
0.09933992818000001,
0.10008999318,
0.09986654118,
0.10615676018,
0.10272796518,
0.09465872218,
0.10165060418,
0.10138413218,
0.10715671418,
0.10541412018,
0.11683012218000001,
0.11816621118000001,
0.13051357018,
0.10914930118
]
},
{
"command": "pnpr@main",
"mean": 0.10383634134000001,
"stddev": 0.00948712241451233,
"median": 0.09984713518,
"user": 0.03131215999999999,
"system": 0.01251892,
"min": 0.09344435318000001,
"max": 0.12671348518,
"times": [
0.11025869218,
0.10667328418000001,
0.12671348518,
0.10855057218000001,
0.09956450118,
0.09832079718,
0.10252531418000001,
0.09585007918,
0.09455458718000001,
0.09702774918000001,
0.09609601218000001,
0.09674922418000001,
0.09688181418000001,
0.11085323518000001,
0.11482724618000001,
0.10237657318000001,
0.09858424318,
0.12090927218000001,
0.12368832118,
0.10030218218,
0.09785492918000001,
0.09488424918,
0.09984713518,
0.10857068118,
0.09344435318000001
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.1890435457155557,
"stddev": 0.4656695603885629,
"median": 1.10346749416,
"user": 1.1049339022222222,
"system": 0.16693735555555553,
"min": 0.78187738216,
"max": 2.32102359316,
"times": [
0.78187738216,
2.32102359316,
0.93723116416,
1.14026670416,
1.10346749416,
1.40784392916,
1.14019081016,
0.80261893816,
1.06687189616
]
},
{
"command": "pacquet@main",
"mean": 1.1888866619377778,
"stddev": 0.27550873473550086,
"median": 1.2392970541600001,
"user": 1.1469566799999997,
"system": 0.19689313333333333,
"min": 0.77775739416,
"max": 1.6055936731600002,
"times": [
1.6055936731600002,
1.4624863111600002,
1.2392970541600001,
0.98728392216,
1.39259992916,
0.77775739416,
0.9157881451600001,
1.27943665316,
1.03973687516
]
},
{
"command": "pnpm@HEAD",
"mean": 4.457262886382223,
"stddev": 0.2680369598450006,
"median": 4.54653992116,
"user": 6.885893013333334,
"system": 0.3435811333333333,
"min": 4.0820182781600005,
"max": 4.906027408160001,
"times": [
4.54653992116,
4.0820182781600005,
4.272982569160001,
4.671791793160001,
4.6191737471600005,
4.16585667316,
4.30009224816,
4.906027408160001,
4.55088333916
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.8687511819800005,
"stddev": 0.2185948366123539,
"median": 4.77123362378,
"user": 2.8569922599999997,
"system": 2.0580833199999997,
"min": 4.63218078078,
"max": 5.33074944178,
"times": [
4.75997936878,
5.10450193778,
4.71771386878,
4.92921325778,
4.63218078078,
4.78248787878,
4.68973749878,
4.75369520078,
5.33074944178,
4.98725258578
]
},
{
"command": "pacquet@main",
"mean": 4.7604138997800005,
"stddev": 0.14647656178020263,
"median": 4.72203641628,
"user": 2.68090706,
"system": 1.90494722,
"min": 4.60575466178,
"max": 5.03686494778,
"times": [
4.97570329878,
4.70129029378,
4.60575466178,
4.66063690278,
4.8379296707799995,
4.74278253878,
4.628705399779999,
5.03686494778,
4.66462890278,
4.74984238078
]
},
{
"command": "pnpr@HEAD",
"mean": 3.6227619783800002,
"stddev": 0.11285499903389314,
"median": 3.5741603802799995,
"user": 1.47948316,
"system": 1.4247926200000003,
"min": 3.51382456778,
"max": 3.84610915578,
"times": [
3.58781110678,
3.74069248978,
3.70784431578,
3.67047491778,
3.52087097578,
3.84610915578,
3.51382456778,
3.5300396457799996,
3.54944295478,
3.5605096537799996
]
},
{
"command": "pnpr@main",
"mean": 3.6576971710799997,
"stddev": 0.07906734114162674,
"median": 3.6466138897800002,
"user": 1.7709819599999999,
"system": 1.6838358199999999,
"min": 3.54522725478,
"max": 3.77958366878,
"times": [
3.7373123757799998,
3.5904237637799996,
3.65511697678,
3.63423505978,
3.5601668967799998,
3.54522725478,
3.63811080278,
3.77958366878,
3.7123662887799997,
3.7244286227799996
]
}
]
} |
Picks up sixteen commits, most of them module splits: the optimistic repeat-install check (#13661), the frozen install and its build phase (#13659, #13662), `create_virtual_store` (#13649), the tarball crate root (#13652), and the audit command (#13657). Also the move to the `rc` lane and pacquet 12.0.0-rc.0 (#13666, #13667). #13661 split `optimistic_repeat_install.rs` into per-concern modules, moving one of this branch's two `build_workspace_state::<Host>` call sites into the new `deps_status.rs`. The turbofish is re-applied at both of its new homes. # Conflicts: # pnpm/crates/package-manager/src/optimistic_repeat_install.rs
Summary
Started as a decomposition of
create_virtual_store::run(794 → 517 lines) intosnapshot_plan.rsandpartition.rs, then applied the "logic covered by tests needs no comment" rule to the extracted modules (comments 108 → 57 and 78 → 44, code unchanged).Checking whether the remaining comments could be replaced by tests turned up a bug. One of them described the directory carve-out in
plan_snapshots— the invariant that afile:dependency's slot must be re-materialized on every install. Writing that test showed the carve-out was unreachable on exactly the install it existed to serve.file:dependencies were never re-copied when their source changed. pnpm'sfile:is a copy taken at install time, not a symlink likelink:, so each install must retake it; the source is mutable and can change with nothing in the lockfile moving. Verified against the TypeScript CLI, which does re-copy.Two independent gates caused it:
prepare_modules_state's optimistic repeat-install short-circuit concluded the tree was current from an equal lockfile plus existence probes, returning before materialization ran. The TypeScript CLI has no gate at this level — it always runs headless and decides per package inlockfileToDepGraph, wheredepIsPresentis hard-gated on!isDirectoryDep.import_indexed_dir's completion-marker check then treated the existing slot as complete. Correct for CAS entries (immutable by key), wrong for a directory resolution, whose file map points at mutable source.Also removed a factually wrong comment claiming
snapshot_cache_keycan raiseUnsupportedResolution— that variant lives ininstall_package_by_snapshot, and theDirectoryarm returnsOk(None).Squash Commit Body
Split
create_virtual_store::runinto per-phase submodules, and fixfile:dependencies not being re-copied when their source directory changed. Both the optimistic repeat-install short-circuit and the import completion-marker check treated an unchanged lockfile as evidence that a mutable-source slot was current.Checklist
a_directory_dependency_is_recopied_when_its_source_changes, verified to fail against each of the two gates independentlypacquet, patch — Rust-only)cargo clippy,cargo doc --document-private-items,cargo dylint --allclean; 3259 tests passWritten by an agent (Claude Code, claude-opus-5).
Summary by CodeRabbit
file:dependencies are copied with their latest contents.