Repository navigation
refactor(deps-restorer): extract headless install - #13637
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (70)
📝 WalkthroughWalkthroughThe PR adds the ChangesDependency restorer extraction
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 |
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (5): Last reviewed commit: "refactor(deps-restorer): align crate nam..." | Re-trigger Greptile |
PR Summary by Qodorefactor(deps-preparer): extract headless install into internal crate
AI Description
Diagram
High-Level Assessment
Files changed (31)
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. API surface unintentionally widened
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (20)
pnpm/crates/deps-preparer/src/link_root_component_members/tests.rs (1)
375-381: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
pacquet_fs::symlink_dirfor the pre-existing Windows link.
pacquet-fsfalls back to a junction when true directory symlinks fail due toSeCreateSymbolicLinkPrivilege, while this test uses rawstd::os::windows::fs::symlink_dir, which can fail on Windows CI.pacquet-fsis already declared for this crate, and production deps-preparer code uses the same helper for directory links.🤖 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-preparer/src/link_root_component_members/tests.rs` around lines 375 - 381, Update the Windows branch of the preexisting link setup in the test to call pacquet_fs::symlink_dir instead of std::os::windows::fs::symlink_dir, preserving the existing source and destination paths and Unix behavior.Source: Coding guidelines
pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs (1)
811-811: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd
#[must_use]here for consistency.This diff adds
#[must_use]tounverified_fetch_is_allowed(line 785) andhost_platform_selector(line 799).runtime_platform_selectoris the same shape: a pure function whose only effect is the returnedPlatformSelector. Discarding its result is always a bug.♻️ Proposed change
+#[must_use] pub fn runtime_platform_selector( supported: Option<&pacquet_package_is_installable::SupportedArchitectures>, ) -> PlatformSelector {🤖 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-preparer/src/install_package_by_snapshot.rs` at line 811, Add the #[must_use] attribute to the runtime_platform_selector function, matching the existing annotations on unverified_fetch_is_allowed and host_platform_selector so callers cannot silently discard its PlatformSelector result.pnpm/crates/deps-preparer/src/install_package_from_registry/tests.rs (1)
27-178: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the exhaustive
Configliteral withConfig::new()plus overrides.
create_configspells out roughly 145 fields, and about 40 of them areDefault::default(). Every new field onpacquet_config::Configbreaks this file. Sibling test modules in this crate already use the cheaper pattern:create_virtual_store/tests.rscallsConfig::new()and then assigns only the fields under test. Adopting that here removes the whole literal, removes the need for the file-levelclippy::default_trait_accessexpectation at lines 1-4, and keeps the fixture stable acrossConfigchanges.Set only what these tests depend on:
store_dir,modules_dir,virtual_store_dir,cache_dir,registry, andsymlink/hoistifConfig::new()does not already default them to the values asserted here.♻️ Sketch of the replacement
fn create_config( store_dir: &Path, modules_dir: &Path, virtual_store_dir: &Path, cache_dir: &Path, ) -> Config { let mut config = Config::new(); config.store_dir = StoreDir::new(store_dir); config.modules_dir = modules_dir.to_path_buf(); config.virtual_store_dir = virtual_store_dir.to_path_buf(); config.global_virtual_store_dir = virtual_store_dir.to_path_buf(); config.cache_dir = cache_dir.to_path_buf(); config.symlink = false; config }Verify each remaining assertion still holds against
Config::new()'s defaults before dropping a field.🤖 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-preparer/src/install_package_from_registry/tests.rs` around lines 27 - 178, Replace the exhaustive Config literal in create_config with Config::new() and override only the fixture-dependent fields: store_dir, modules_dir, virtual_store_dir, global_virtual_store_dir, cache_dir, registry, and symlink/hoist when needed to preserve assertions. Remove the file-level clippy::default_trait_access allowance if it is no longer used, and verify the tests retain their expected defaults.Source: Path instructions
pnpm/crates/deps-preparer/src/install_package_by_snapshot/tests.rs (1)
520-546: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse one helper for the three mem-cache installs.
These three
InstallPackageBySnapshotliterals differ only intarball_mem_cache. This file already definesrun_snapshot_install_with_picker(lines 754-799) for exactly this purpose on the fetcher tests. Extract a sibling helper that takestarball_mem_cache: Option<&Arc<MemCache>>and returns theResult, so a future field added toInstallPackageBySnapshotneeds one edit instead of three.Also applies to: 598-621, 673-696
🤖 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-preparer/src/install_package_by_snapshot/tests.rs` around lines 520 - 546, The three mem-cache install tests duplicate the full InstallPackageBySnapshot construction. Extract a sibling helper near run_snapshot_install_with_picker that accepts tarball_mem_cache: Option<&Arc<MemCache>> and returns the install Result, centralizing the shared fields; update the install sites around the referenced blocks to call it with each cache variant.pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs (1)
19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueKeep the concurrency probe surface inside
pacquet-deps-preparer. The probe,LinkConcurrencyGuard, and thelink_concurrency_probefields are only used for intra-crate tests, including the tests submodule, sopub(crate)is clearer here.
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs:19: makeLinkConcurrencyProbepub(crate).pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:297: make#[cfg(test)] mod testsusepub(crate) mod tests.pnpm/crates/deps-preparer/src/create_virtual_store.rs:183-185: make the public fieldpub(crate) link_concurrency_probeinside the existing#[cfg(test)]block.pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:77-78: make the public field for this type matchpub(crate)too.🤖 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-preparer/src/create_virtual_dir_by_snapshot/tests.rs` at line 19, Restrict the concurrency probe test surface to crate visibility: make LinkConcurrencyProbe in pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs:19 pub(crate), change tests to pub(crate) mod tests in pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:297, and make the link_concurrency_probe fields pub(crate) in pnpm/crates/deps-preparer/src/create_virtual_store.rs:183-185, pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:77-78, and pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs:135.pnpm/crates/deps-preparer/src/install_frozen_lockfile.rs (1)
1722-1725: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider a typed error instead of
expectnow thatrun_hoisted_linkeris public.
run_hoisted_linkeris nowpub, sopackage-managerand any future caller can passcas_paths_by_pkg_id: None. Line 1725 turns that into a panic. The in-repo caller guards the value, so this is not currently reachable. AHoistedLinkerErrorvariant would keep the newly public boundary on the typed-diagnostic path.As per coding guidelines, pnpm/CODE_STYLE_GUIDE.md asks the new public
deps-preparerAPI to "use typed error enums with proper propagation, avoid unnecessaryunwrap".♻️ Proposed refactor
pub enum HoistedLinkerError { #[diagnostic(transparent)] HoistedDepGraph(#[error(source)] HoistedDepGraphError), + #[display("hoisted linking requires the CAS path index produced by CreateVirtualStore")] + #[diagnostic(code(ERR_PNPM_PACKAGE_MANAGER_MISSING_CAS_PATHS))] + MissingCasPaths,- let cas_index = cas_paths_by_pkg_id.expect("hoisted CreateVirtualStore populates cas_paths"); + let cas_index = cas_paths_by_pkg_id.ok_or(HoistedLinkerError::MissingCasPaths)?;🤖 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-preparer/src/install_frozen_lockfile.rs` around lines 1722 - 1725, Replace the expect in the public run_hoisted_linker flow with a dedicated HoistedLinkerError variant for missing cas_paths_by_pkg_id, and propagate it through the existing Result-based error path. Preserve the current linker behavior for Some values and the no-op handling for installs without snapshots.Source: Path instructions
pnpm/crates/deps-preparer/src/graph_sequencer/tests.rs (1)
95-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename
self_loop_not_safe_flag; the name contradicts the assertion.The test asserts
result.safeis true for a length-1 self-loop, but the name reads as "not safe". A reader who scans test names concludes the opposite of the pinned behavior, and a later change could "fix" the assertion to match the name. Name it after the behavior it pins.♻️ Proposed rename
-fn self_loop_not_safe_flag() { +fn self_loop_does_not_clear_safe_flag() {🤖 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-preparer/src/graph_sequencer/tests.rs` around lines 95 - 104, Rename the test function self_loop_not_safe_flag to a name that clearly states that a length-1 self-loop is considered safe, while preserving its existing assertions and behavior.pnpm/crates/deps-preparer/src/import_indexed_dir/tests.rs (1)
484-487: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect the doc comment; the test does not cover staging-name uniqueness.
The comment states that two staging paths produced back-to-back in the same process must differ, so concurrent rayon workers do not collide on the rename target. The test imports into two different targets (
pkg-aandpkg-b), whose staging paths already differ by target path. It never exercises two staging names derived for the same target. Describe what the test verifies: two concurrent force imports into separate targets both complete and clear stale files.♻️ Proposed comment fix
-/// Two staging paths produced back-to-back in the same process must -/// differ — otherwise concurrent rayon workers would collide on the -/// rename target. Uses the function indirectly via two force re-installs -/// in parallel. +/// Two force re-imports running in parallel against separate targets +/// must both complete and clear their stale files. Staging-name +/// uniqueness for a single target is not covered here.🤖 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-preparer/src/import_indexed_dir/tests.rs` around lines 484 - 487, Correct the doc comment above the test to describe its actual coverage: concurrent force imports into separate targets (pkg-a and pkg-b) both complete successfully and clear stale files. Remove the unsupported claim about back-to-back staging-path uniqueness and rayon rename-target collisions.pnpm/crates/deps-preparer/src/deps_graph/tests.rs (1)
47-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the full
full_pkg_id, not just its prefix.The test name states the integrity is used verbatim, but the assertion only checks the prefix
@scope/[email protected]:sha512-. It passes even if the integrity body is truncated or rewritten after that prefix.full_pkg_idfeeds side-effects cache keys and global-virtual-store slot digests, so a change in integrity rendering moves store paths. Compare the whole string so the test enforces the contract its name claims.♻️ Proposed tightening
let graph = build_deps_graph(&snapshots, &packages); let node = graph.get(&pkg).expect("graph node"); - let expected_prefix = "`@scope/foo`@1.0.0:sha512-"; - assert!( - node.full_pkg_id.starts_with(expected_prefix), - "expected full_pkg_id to start with `{expected_prefix}`, got `{}`", - node.full_pkg_id, - ); + let expected = format!("`@scope/foo`@1.0.0:{}", integrity()); + assert_eq!(node.full_pkg_id, expected); }🤖 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-preparer/src/deps_graph/tests.rs` around lines 47 - 61, Update the test registry_resolution_full_pkg_id_uses_integrity_verbatim to assert node.full_pkg_id equals the complete expected package ID, including the exact integrity value produced by registry_metadata(), rather than checking only a prefix. Preserve the existing package and graph setup while ensuring truncated or rewritten integrity content causes the test to fail.pnpm/crates/deps-preparer/src/build_modules.rs (1)
264-265: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNarrow
normalize_build_dep_pathtopub(crate).
normalize_build_dep_pathis only callable from outsidedeps_preparerbecause ofpub mod build_modules;pluspub use build_modules::*;, but the only current callers are insidedeps-preparer. No Rust package-manager code uses it, so export it to the crate's public API only if a caller is intentionally required.🤖 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-preparer/src/build_modules.rs` around lines 264 - 265, Change normalize_build_dep_path from public to pub(crate) so it is available only within the deps-preparer crate. Keep the existing implementation and callers unchanged, and do not expose it through the crate’s public re-exports.pnpm/crates/deps-preparer/src/hoisted_dep_graph.rs (1)
479-500: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify the node update in
fill_children.Line 486 indexes
graph[&dir], so the key is proven present. Theif let Some(node) = graph.get_mut(&dir)guard on line 495 can never take theNonebranch. A direct&mutbinding states the invariant and drops the dead branch.♻️ Proposed simplification
let snapshot = lockfile.snapshots.as_ref().and_then(|m| m.get(&pkg_key)); let children = compute_children(snapshot, pkg_locations); - if let Some(node) = graph.get_mut(&dir) { - node.children = children; - } + graph.get_mut(&dir).expect("dir came from graph.keys()").children = children;🤖 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-preparer/src/hoisted_dep_graph.rs` around lines 479 - 500, In fill_children, replace the conditional graph.get_mut(&dir) update with a direct mutable binding, since each dir comes from graph.keys() and is guaranteed to exist. Assign the computed children directly through that binding while preserving the existing child computation.pnpm/crates/deps-preparer/src/hoisted_dep_graph/tests.rs (2)
1-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMerge the two import blocks into one.
Lines 1-11 and lines 96-102 both import from
super,pacquet_lockfile, andstd::collections. The style guide asks for merged explicit imports. Move the second block into the first so each module is imported once.As per coding guidelines: "Prefer ... merged explicit imports".
Also applies to: 96-102
🤖 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-preparer/src/hoisted_dep_graph/tests.rs` around lines 1 - 11, Merge the duplicate imports in the test module into the existing top-level import block. Combine all symbols from the later super, pacquet_lockfile, and std::collections imports with their corresponding first-block imports, leaving each module imported exactly once and preserving explicit import style.Source: Path instructions
176-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the empty-
Lockfileliteral into a fixture helper.Three tests repeat the same 13-field
Lockfileliteral, differing only inpackagesandsnapshots. A helper such asempty_lockfile(packages, snapshots)removes the duplication and keeps future field additions to one site.Also applies to: 595-607, 633-645
🤖 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-preparer/src/hoisted_dep_graph/tests.rs` around lines 176 - 188, Extract the repeated empty Lockfile construction into an empty_lockfile helper accepting packages and snapshots, and initialize all shared fields there. Update the three affected tests to call the helper with their respective packages and snapshots values while preserving the existing test behavior.pnpm/crates/deps-preparer/src/virtual_store_layout.rs (1)
371-381: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueImport
BTreeMapinstead of writing the full path inline.Line 40 already imports
std::collections::{HashMap, HashSet}. Thecollect_injected_depssignature and body spell outstd::collections::BTreeMapfive times. AddBTreeMapto that import and shorten the occurrences.As per coding guidelines: "Prefer ... merged explicit imports".
♻️ Proposed change
use std::{ - collections::{HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet}, path::{Path, PathBuf}, };skipped: &crate::SkippedSnapshots, - hoisted_locations: Option<&std::collections::BTreeMap<String, Vec<String>>>, -) -> std::collections::BTreeMap<String, Vec<String>> { - let mut injected: std::collections::BTreeMap<String, Vec<String>> = - std::collections::BTreeMap::new(); + hoisted_locations: Option<&BTreeMap<String, Vec<String>>>, +) -> BTreeMap<String, Vec<String>> { + let mut injected: BTreeMap<String, Vec<String>> = BTreeMap::new();🤖 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-preparer/src/virtual_store_layout.rs` around lines 371 - 381, Add BTreeMap to the existing std::collections import in collect_injected_deps and replace every fully qualified std::collections::BTreeMap reference in its signature and body with BTreeMap, without changing behavior.Source: Path instructions
pnpm/crates/deps-preparer/src/hoisting_limits/tests.rs (1)
42-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a test for the no-root-importer case.
get_hoisting_limitsonly emits the.@entry when a root importer is present (root_presentatpnpm/crates/deps-preparer/src/hoisting_limits.rsline 54). That branch is documented as upstream parity behavior, and no test covers it. A test with onlypackages/fooinimportersunderDependenciesmode should assert that.@is absent and that the per-importer key is still emitted.🤖 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-preparer/src/hoisting_limits/tests.rs` around lines 42 - 65, Add a test alongside dependencies_mode_borders_each_importer using only the “packages/foo” importer and HoistingLimits::Dependencies. Assert get_hoisting_limits omits the ".@" entry while still emitting the "packages%2Ffoo@workspace:packages/foo" key with its expected dependency set.pnpm/crates/deps-preparer/src/hoisting_limits.rs (1)
22-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider an exhaustive
matchonmodeinstead of twomatches!guards.
get_hoisting_limitstestsmodetwice withmatches!. Ifpacquet_config::HoistingLimitsgains a variant, that variant silently takes theWorkspacesbehavior. An exhaustivematchonmodemakes the compiler flag the new variant.🤖 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-preparer/src/hoisting_limits.rs` around lines 22 - 52, Update get_hoisting_limits to use an exhaustive match on mode instead of the two matches!(mode, ...) guards. Preserve the existing early return for HoistingLimits::None and dependency-specific importer-border behavior, while ensuring any future HoistingLimits variant causes a compile-time exhaustiveness error rather than defaulting to workspace behavior.pnpm/crates/deps-preparer/src/virtual_store_layout/tests.rs (1)
68-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse
package_metadatafor the inlinePackageMetadataliterals.Line 27 defines
package_metadata(resolution, version)and line 800 definesregistry_metadata(lead). Six more sites still spell out all twelve fields ofPackageMetadata, and every one sets the same nine fields toNone. A new field onPackageMetadatathen requires six edits. Route these sites throughpackage_metadatawith a registry resolution.As per coding guidelines: "Keep the change focused, avoid duplicated helpers".
♻️ Example for the first site
let mut packages = HashMap::new(); packages.insert( key.clone(), - PackageMetadata { - resolution: LockfileResolution::Registry(RegistryResolution { - integrity: "sha512-AAAA...AAAA" - .parse() - .expect("parse integrity"), - }), - version: None, - engines: None, - cpu: None, - os: None, - libc: None, - deprecated: None, - has_bin: None, - prepare: None, - bundled_dependencies: None, - peer_dependencies: None, - peer_dependencies_meta: None, - }, + package_metadata(registry_resolution("A"), None), );Add a small
registry_resolution(lead: &str) -> LockfileResolutionhelper next toregistry_metadata, which can then be expressed aspackage_metadata(registry_resolution(lead), None).Also applies to: 122-142, 168-188, 225-245, 346-366, 419-440
🤖 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-preparer/src/virtual_store_layout/tests.rs` around lines 68 - 88, Replace the six inline twelve-field PackageMetadata literals in the affected tests with package_metadata calls, passing a registry LockfileResolution and the existing version value (or None). Add one shared registry_resolution(lead: &str) -> LockfileResolution helper beside registry_metadata, and reuse it at each site without introducing additional duplicated helpers.Source: Path instructions
pnpm/crates/deps-preparer/src/package_map/tests.rs (1)
80-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLog the rendered package map before the comparison.
This assertion compares a large structured value. Bind the actual JSON and emit it with
eprintln!beforeassert_eq!. This keeps regression output readable.Proposed change
- assert_eq!( - serde_json::to_value(&package_map).expect("serialize package map"), + let actual = serde_json::to_value(&package_map).expect("serialize package map"); + eprintln!("PACKAGE MAP:\n{actual}\n"); + assert_eq!( + actual,As per path instructions, log complex values before non-equality assertions. Based on learnings, emit the rendered value with
eprintln!using{}formatting before the assertion.🤖 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-preparer/src/package_map/tests.rs` around lines 80 - 131, In the package map test, bind the rendered JSON value from serde_json::to_value(&package_map) to a local variable, print it with eprintln! using {} formatting immediately before assert_eq!, and compare that variable against the expected JSON.Sources: Path instructions, Learnings
pnpm/crates/deps-preparer/src/package_map.rs (1)
13-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the exported
deps-preparerAPI contracts.These items now cross crate boundaries but lack rustdoc contracts. Document path bases, side effects, errors, and required caller invariants. For
remove_direct_dep_link, state that callers must first confine the modules directory.
pnpm/crates/deps-preparer/src/package_map.rs#L13-L21: Document the filename and serialized package-map records.pnpm/crates/deps-preparer/src/package_map.rs#L36-L36: Document path bases and layout requirements.pnpm/crates/deps-preparer/src/package_map.rs#L47-L54: Document hoisted-map inputs and package-map write behavior.pnpm/crates/deps-preparer/src/package_map.rs#L69-L69: Document the hoisted output target and errors.pnpm/crates/deps-preparer/src/package_map.rs#L86-L86: Document lockfile-map semantics, including standard versus loose mode.pnpm/crates/deps-preparer/src/package_map.rs#L229-L229: Document graph-map semantics and graph-directory requirements.pnpm/crates/deps-preparer/src/pnp.rs#L17-L17: Document the.pnp.cjsoutput and write behavior.pnpm/crates/deps-preparer/src/prune_direct_deps.rs#L167-L167: Document canonical containment andNonebehavior.pnpm/crates/deps-preparer/src/prune_direct_deps.rs#L191-L192: Document selected-group ordering and output semantics.pnpm/crates/deps-preparer/src/prune_direct_deps.rs#L206-L206: Document symlink-only removal and the caller containment precondition.As per coding guidelines, use rustdoc comments for public API contracts. As per path instructions, new public
deps-preparerAPIs must document observable contracts with rustdoc intra-links.🤖 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-preparer/src/package_map.rs` around lines 13 - 21, pnpm/crates/deps-preparer/src/package_map.rs lines 13-21: add rustdoc for PACKAGE_MAP_FILENAME, PackageMap, and PackageMapPackage describing the filename and serialized records; lines 36, 47-54, 69, 86, and 229: document each public API’s path bases, layout and graph-directory requirements, hoisted and lockfile-map inputs, standard versus loose mode, output targets, write side effects, and errors using intra-links. In pnpm/crates/deps-preparer/src/pnp.rs lines 17, document the .pnp.cjs output and write behavior. In pnpm/crates/deps-preparer/src/prune_direct_deps.rs lines 167, 191-192, and 206, document canonical containment and None behavior, selected-group ordering and output semantics, and symlink-only removal; explicitly require callers to confine the modules directory before invoking remove_direct_dep_link.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-preparer/src/remove_quarantine.rs (1)
44-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the new public API contracts with rustdoc.
pnpm/crates/deps-preparer/src/remove_quarantine.rs#L44-L57: document the macOS quarantine-removal behavior and the non-macOS no-op behavior.pnpm/crates/deps-preparer/src/retry_config.rs#L8-L8: document theConfigtoRetryOptsconversion contract and timeout units.pnpm/crates/deps-preparer/src/store_init.rs#L15-L15: document that initialization is best effort and that failures only produce warnings.As per coding guidelines, “Use rustdoc comments for public API contracts.” As per path instructions, “For the new public
deps-preparerAPI, document observable contracts with rustdoc intra-links.”🤖 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-preparer/src/remove_quarantine.rs` around lines 44 - 57, Add rustdoc contracts at pnpm/crates/deps-preparer/src/remove_quarantine.rs:44-57 for remove_quarantine_from_native_binaries, covering macOS quarantine removal and the non-macOS no-op; document the Config-to-RetryOpts conversion and timeout units at pnpm/crates/deps-preparer/src/retry_config.rs:8-8; document best-effort initialization and warning-only failures at pnpm/crates/deps-preparer/src/store_init.rs:15-15, using rustdoc intra-links for referenced public API symbols.Sources: Coding guidelines, Path instructions
🤖 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-preparer/src/create_symlink_layout.rs`:
- Around line 20-25: Correct the rustdoc for virtual_node_modules_dir to state
only that the directory need not already exist; remove the inaccurate claim that
symlink_package pre-creates the parent before each link and the resulting
redundant-stat explanation. Keep the documentation focused on the public
contract, leaving implementation rationale to regular comments.
In `@pnpm/crates/deps-preparer/src/current_lockfile/tests.rs`:
- Line 1: Update the module-level documentation in the tests module to reference
all covered functions: filter_lockfile_for_current, materialization_closure,
merge_filtered_wanted_lockfile, merge_filtered_current_lockfile, and
extend_skipped_with_dependency_closure.
In `@pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs`:
- Around line 61-63: Fix the documentation sentence near the background
prefetcher description by removing the dangling “the pnpr client's” possessive
and clearly attributing TarballPrefetcher to a single owner, consistent with the
parallel create_virtual_store documentation; preserve the parallel listing with
PrefetchingResolver.
---
Nitpick comments:
In `@pnpm/crates/deps-preparer/src/build_modules.rs`:
- Around line 264-265: Change normalize_build_dep_path from public to pub(crate)
so it is available only within the deps-preparer crate. Keep the existing
implementation and callers unchanged, and do not expose it through the crate’s
public re-exports.
In `@pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs`:
- Line 19: Restrict the concurrency probe test surface to crate visibility: make
LinkConcurrencyProbe in
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs:19
pub(crate), change tests to pub(crate) mod tests in
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:297, and make
the link_concurrency_probe fields pub(crate) in
pnpm/crates/deps-preparer/src/create_virtual_store.rs:183-185,
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:77-78, and
pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs:135.
In `@pnpm/crates/deps-preparer/src/deps_graph/tests.rs`:
- Around line 47-61: Update the test
registry_resolution_full_pkg_id_uses_integrity_verbatim to assert
node.full_pkg_id equals the complete expected package ID, including the exact
integrity value produced by registry_metadata(), rather than checking only a
prefix. Preserve the existing package and graph setup while ensuring truncated
or rewritten integrity content causes the test to fail.
In `@pnpm/crates/deps-preparer/src/graph_sequencer/tests.rs`:
- Around line 95-104: Rename the test function self_loop_not_safe_flag to a name
that clearly states that a length-1 self-loop is considered safe, while
preserving its existing assertions and behavior.
In `@pnpm/crates/deps-preparer/src/hoisted_dep_graph.rs`:
- Around line 479-500: In fill_children, replace the conditional
graph.get_mut(&dir) update with a direct mutable binding, since each dir comes
from graph.keys() and is guaranteed to exist. Assign the computed children
directly through that binding while preserving the existing child computation.
In `@pnpm/crates/deps-preparer/src/hoisted_dep_graph/tests.rs`:
- Around line 1-11: Merge the duplicate imports in the test module into the
existing top-level import block. Combine all symbols from the later super,
pacquet_lockfile, and std::collections imports with their corresponding
first-block imports, leaving each module imported exactly once and preserving
explicit import style.
- Around line 176-188: Extract the repeated empty Lockfile construction into an
empty_lockfile helper accepting packages and snapshots, and initialize all
shared fields there. Update the three affected tests to call the helper with
their respective packages and snapshots values while preserving the existing
test behavior.
In `@pnpm/crates/deps-preparer/src/hoisting_limits.rs`:
- Around line 22-52: Update get_hoisting_limits to use an exhaustive match on
mode instead of the two matches!(mode, ...) guards. Preserve the existing early
return for HoistingLimits::None and dependency-specific importer-border
behavior, while ensuring any future HoistingLimits variant causes a compile-time
exhaustiveness error rather than defaulting to workspace behavior.
In `@pnpm/crates/deps-preparer/src/hoisting_limits/tests.rs`:
- Around line 42-65: Add a test alongside
dependencies_mode_borders_each_importer using only the “packages/foo” importer
and HoistingLimits::Dependencies. Assert get_hoisting_limits omits the ".@"
entry while still emitting the "packages%2Ffoo@workspace:packages/foo" key with
its expected dependency set.
In `@pnpm/crates/deps-preparer/src/import_indexed_dir/tests.rs`:
- Around line 484-487: Correct the doc comment above the test to describe its
actual coverage: concurrent force imports into separate targets (pkg-a and
pkg-b) both complete successfully and clear stale files. Remove the unsupported
claim about back-to-back staging-path uniqueness and rayon rename-target
collisions.
In `@pnpm/crates/deps-preparer/src/install_frozen_lockfile.rs`:
- Around line 1722-1725: Replace the expect in the public run_hoisted_linker
flow with a dedicated HoistedLinkerError variant for missing
cas_paths_by_pkg_id, and propagate it through the existing Result-based error
path. Preserve the current linker behavior for Some values and the no-op
handling for installs without snapshots.
In `@pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs`:
- Line 811: Add the #[must_use] attribute to the runtime_platform_selector
function, matching the existing annotations on unverified_fetch_is_allowed and
host_platform_selector so callers cannot silently discard its PlatformSelector
result.
In `@pnpm/crates/deps-preparer/src/install_package_by_snapshot/tests.rs`:
- Around line 520-546: The three mem-cache install tests duplicate the full
InstallPackageBySnapshot construction. Extract a sibling helper near
run_snapshot_install_with_picker that accepts tarball_mem_cache:
Option<&Arc<MemCache>> and returns the install Result, centralizing the shared
fields; update the install sites around the referenced blocks to call it with
each cache variant.
In `@pnpm/crates/deps-preparer/src/install_package_from_registry/tests.rs`:
- Around line 27-178: Replace the exhaustive Config literal in create_config
with Config::new() and override only the fixture-dependent fields: store_dir,
modules_dir, virtual_store_dir, global_virtual_store_dir, cache_dir, registry,
and symlink/hoist when needed to preserve assertions. Remove the file-level
clippy::default_trait_access allowance if it is no longer used, and verify the
tests retain their expected defaults.
In `@pnpm/crates/deps-preparer/src/link_root_component_members/tests.rs`:
- Around line 375-381: Update the Windows branch of the preexisting link setup
in the test to call pacquet_fs::symlink_dir instead of
std::os::windows::fs::symlink_dir, preserving the existing source and
destination paths and Unix behavior.
In `@pnpm/crates/deps-preparer/src/package_map.rs`:
- Around line 13-21: pnpm/crates/deps-preparer/src/package_map.rs lines 13-21:
add rustdoc for PACKAGE_MAP_FILENAME, PackageMap, and PackageMapPackage
describing the filename and serialized records; lines 36, 47-54, 69, 86, and
229: document each public API’s path bases, layout and graph-directory
requirements, hoisted and lockfile-map inputs, standard versus loose mode,
output targets, write side effects, and errors using intra-links. In
pnpm/crates/deps-preparer/src/pnp.rs lines 17, document the .pnp.cjs output and
write behavior. In pnpm/crates/deps-preparer/src/prune_direct_deps.rs lines 167,
191-192, and 206, document canonical containment and None behavior,
selected-group ordering and output semantics, and symlink-only removal;
explicitly require callers to confine the modules directory before invoking
remove_direct_dep_link.
In `@pnpm/crates/deps-preparer/src/package_map/tests.rs`:
- Around line 80-131: In the package map test, bind the rendered JSON value from
serde_json::to_value(&package_map) to a local variable, print it with eprintln!
using {} formatting immediately before assert_eq!, and compare that variable
against the expected JSON.
In `@pnpm/crates/deps-preparer/src/remove_quarantine.rs`:
- Around line 44-57: Add rustdoc contracts at
pnpm/crates/deps-preparer/src/remove_quarantine.rs:44-57 for
remove_quarantine_from_native_binaries, covering macOS quarantine removal and
the non-macOS no-op; document the Config-to-RetryOpts conversion and timeout
units at pnpm/crates/deps-preparer/src/retry_config.rs:8-8; document best-effort
initialization and warning-only failures at
pnpm/crates/deps-preparer/src/store_init.rs:15-15, using rustdoc intra-links for
referenced public API symbols.
In `@pnpm/crates/deps-preparer/src/virtual_store_layout.rs`:
- Around line 371-381: Add BTreeMap to the existing std::collections import in
collect_injected_deps and replace every fully qualified
std::collections::BTreeMap reference in its signature and body with BTreeMap,
without changing behavior.
In `@pnpm/crates/deps-preparer/src/virtual_store_layout/tests.rs`:
- Around line 68-88: Replace the six inline twelve-field PackageMetadata
literals in the affected tests with package_metadata calls, passing a registry
LockfileResolution and the existing version value (or None). Add one shared
registry_resolution(lead: &str) -> LockfileResolution helper beside
registry_metadata, and reuse it at each site without introducing additional
duplicated helpers.
🪄 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: a6836c74-059c-46f5-ab5a-57ba5c944845
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (70)
Cargo.tomlpnpm/crates/cli/tests/multiple_importers.rspnpm/crates/deps-preparer/Cargo.tomlpnpm/crates/deps-preparer/src/build_modules.rspnpm/crates/deps-preparer/src/build_modules/tests.rspnpm/crates/deps-preparer/src/build_sequence.rspnpm/crates/deps-preparer/src/build_sequence/tests.rspnpm/crates/deps-preparer/src/create_symlink_layout.rspnpm/crates/deps-preparer/src/create_symlink_layout/tests.rspnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rspnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rspnpm/crates/deps-preparer/src/create_virtual_store.rspnpm/crates/deps-preparer/src/create_virtual_store/tests.rspnpm/crates/deps-preparer/src/current_lockfile.rspnpm/crates/deps-preparer/src/current_lockfile/tests.rspnpm/crates/deps-preparer/src/deps_graph.rspnpm/crates/deps-preparer/src/deps_graph/tests.rspnpm/crates/deps-preparer/src/graph_sequencer.rspnpm/crates/deps-preparer/src/graph_sequencer/tests.rspnpm/crates/deps-preparer/src/hoist.rspnpm/crates/deps-preparer/src/hoist/tests.rspnpm/crates/deps-preparer/src/hoisted_dep_graph.rspnpm/crates/deps-preparer/src/hoisted_dep_graph/tests.rspnpm/crates/deps-preparer/src/hoisting_limits.rspnpm/crates/deps-preparer/src/hoisting_limits/tests.rspnpm/crates/deps-preparer/src/import_indexed_dir.rspnpm/crates/deps-preparer/src/import_indexed_dir/tests.rspnpm/crates/deps-preparer/src/install_frozen_lockfile.rspnpm/crates/deps-preparer/src/install_frozen_lockfile/tests.rspnpm/crates/deps-preparer/src/install_package_by_snapshot.rspnpm/crates/deps-preparer/src/install_package_by_snapshot/tests.rspnpm/crates/deps-preparer/src/install_package_from_registry.rspnpm/crates/deps-preparer/src/install_package_from_registry/tests.rspnpm/crates/deps-preparer/src/installability.rspnpm/crates/deps-preparer/src/installability/tests.rspnpm/crates/deps-preparer/src/lib.rspnpm/crates/deps-preparer/src/link_bins.rspnpm/crates/deps-preparer/src/link_bins/tests.rspnpm/crates/deps-preparer/src/link_file.rspnpm/crates/deps-preparer/src/link_file/tests.rspnpm/crates/deps-preparer/src/link_hoisted_modules.rspnpm/crates/deps-preparer/src/link_hoisted_modules/tests.rspnpm/crates/deps-preparer/src/link_root_component_members.rspnpm/crates/deps-preparer/src/link_root_component_members/tests.rspnpm/crates/deps-preparer/src/package_map.rspnpm/crates/deps-preparer/src/package_map/tests.rspnpm/crates/deps-preparer/src/pnp.rspnpm/crates/deps-preparer/src/prune_direct_deps.rspnpm/crates/deps-preparer/src/prune_direct_deps/tests.rspnpm/crates/deps-preparer/src/prune_stale_modules.rspnpm/crates/deps-preparer/src/remove_quarantine.rspnpm/crates/deps-preparer/src/remove_quarantine/tests.rspnpm/crates/deps-preparer/src/retry_config.rspnpm/crates/deps-preparer/src/safe_join_modules_dir.rspnpm/crates/deps-preparer/src/safe_join_modules_dir/tests.rspnpm/crates/deps-preparer/src/store_init.rspnpm/crates/deps-preparer/src/symlink_direct_dependencies.rspnpm/crates/deps-preparer/src/symlink_direct_dependencies/tests.rspnpm/crates/deps-preparer/src/symlink_package.rspnpm/crates/deps-preparer/src/validate_lockfile_paths.rspnpm/crates/deps-preparer/src/validate_lockfile_paths/tests.rspnpm/crates/deps-preparer/src/version_policy.rspnpm/crates/deps-preparer/src/virtual_store_layout.rspnpm/crates/deps-preparer/src/virtual_store_layout/tests.rspnpm/crates/package-manager/Cargo.tomlpnpm/crates/package-manager/src/install.rspnpm/crates/package-manager/src/install/tests.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/package-manager/src/lib.rspnpm/plans/TEST_PORTING.md
💤 Files with no reviewable changes (2)
- pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
- pnpm/crates/package-manager/src/install.rs
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 3
🧹 Nitpick comments (20)
pnpm/crates/deps-preparer/src/link_root_component_members/tests.rs (1)
375-381: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
pacquet_fs::symlink_dirfor the pre-existing Windows link.
pacquet-fsfalls back to a junction when true directory symlinks fail due toSeCreateSymbolicLinkPrivilege, while this test uses rawstd::os::windows::fs::symlink_dir, which can fail on Windows CI.pacquet-fsis already declared for this crate, and production deps-preparer code uses the same helper for directory links.🤖 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-preparer/src/link_root_component_members/tests.rs` around lines 375 - 381, Update the Windows branch of the preexisting link setup in the test to call pacquet_fs::symlink_dir instead of std::os::windows::fs::symlink_dir, preserving the existing source and destination paths and Unix behavior.Source: Coding guidelines
pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs (1)
811-811: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd
#[must_use]here for consistency.This diff adds
#[must_use]tounverified_fetch_is_allowed(line 785) andhost_platform_selector(line 799).runtime_platform_selectoris the same shape: a pure function whose only effect is the returnedPlatformSelector. Discarding its result is always a bug.♻️ Proposed change
+#[must_use] pub fn runtime_platform_selector( supported: Option<&pacquet_package_is_installable::SupportedArchitectures>, ) -> PlatformSelector {🤖 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-preparer/src/install_package_by_snapshot.rs` at line 811, Add the #[must_use] attribute to the runtime_platform_selector function, matching the existing annotations on unverified_fetch_is_allowed and host_platform_selector so callers cannot silently discard its PlatformSelector result.pnpm/crates/deps-preparer/src/install_package_from_registry/tests.rs (1)
27-178: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the exhaustive
Configliteral withConfig::new()plus overrides.
create_configspells out roughly 145 fields, and about 40 of them areDefault::default(). Every new field onpacquet_config::Configbreaks this file. Sibling test modules in this crate already use the cheaper pattern:create_virtual_store/tests.rscallsConfig::new()and then assigns only the fields under test. Adopting that here removes the whole literal, removes the need for the file-levelclippy::default_trait_accessexpectation at lines 1-4, and keeps the fixture stable acrossConfigchanges.Set only what these tests depend on:
store_dir,modules_dir,virtual_store_dir,cache_dir,registry, andsymlink/hoistifConfig::new()does not already default them to the values asserted here.♻️ Sketch of the replacement
fn create_config( store_dir: &Path, modules_dir: &Path, virtual_store_dir: &Path, cache_dir: &Path, ) -> Config { let mut config = Config::new(); config.store_dir = StoreDir::new(store_dir); config.modules_dir = modules_dir.to_path_buf(); config.virtual_store_dir = virtual_store_dir.to_path_buf(); config.global_virtual_store_dir = virtual_store_dir.to_path_buf(); config.cache_dir = cache_dir.to_path_buf(); config.symlink = false; config }Verify each remaining assertion still holds against
Config::new()'s defaults before dropping a field.🤖 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-preparer/src/install_package_from_registry/tests.rs` around lines 27 - 178, Replace the exhaustive Config literal in create_config with Config::new() and override only the fixture-dependent fields: store_dir, modules_dir, virtual_store_dir, global_virtual_store_dir, cache_dir, registry, and symlink/hoist when needed to preserve assertions. Remove the file-level clippy::default_trait_access allowance if it is no longer used, and verify the tests retain their expected defaults.Source: Path instructions
pnpm/crates/deps-preparer/src/install_package_by_snapshot/tests.rs (1)
520-546: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse one helper for the three mem-cache installs.
These three
InstallPackageBySnapshotliterals differ only intarball_mem_cache. This file already definesrun_snapshot_install_with_picker(lines 754-799) for exactly this purpose on the fetcher tests. Extract a sibling helper that takestarball_mem_cache: Option<&Arc<MemCache>>and returns theResult, so a future field added toInstallPackageBySnapshotneeds one edit instead of three.Also applies to: 598-621, 673-696
🤖 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-preparer/src/install_package_by_snapshot/tests.rs` around lines 520 - 546, The three mem-cache install tests duplicate the full InstallPackageBySnapshot construction. Extract a sibling helper near run_snapshot_install_with_picker that accepts tarball_mem_cache: Option<&Arc<MemCache>> and returns the install Result, centralizing the shared fields; update the install sites around the referenced blocks to call it with each cache variant.pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs (1)
19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueKeep the concurrency probe surface inside
pacquet-deps-preparer. The probe,LinkConcurrencyGuard, and thelink_concurrency_probefields are only used for intra-crate tests, including the tests submodule, sopub(crate)is clearer here.
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs:19: makeLinkConcurrencyProbepub(crate).pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:297: make#[cfg(test)] mod testsusepub(crate) mod tests.pnpm/crates/deps-preparer/src/create_virtual_store.rs:183-185: make the public fieldpub(crate) link_concurrency_probeinside the existing#[cfg(test)]block.pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:77-78: make the public field for this type matchpub(crate)too.🤖 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-preparer/src/create_virtual_dir_by_snapshot/tests.rs` at line 19, Restrict the concurrency probe test surface to crate visibility: make LinkConcurrencyProbe in pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs:19 pub(crate), change tests to pub(crate) mod tests in pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:297, and make the link_concurrency_probe fields pub(crate) in pnpm/crates/deps-preparer/src/create_virtual_store.rs:183-185, pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:77-78, and pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs:135.pnpm/crates/deps-preparer/src/install_frozen_lockfile.rs (1)
1722-1725: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider a typed error instead of
expectnow thatrun_hoisted_linkeris public.
run_hoisted_linkeris nowpub, sopackage-managerand any future caller can passcas_paths_by_pkg_id: None. Line 1725 turns that into a panic. The in-repo caller guards the value, so this is not currently reachable. AHoistedLinkerErrorvariant would keep the newly public boundary on the typed-diagnostic path.As per coding guidelines, pnpm/CODE_STYLE_GUIDE.md asks the new public
deps-preparerAPI to "use typed error enums with proper propagation, avoid unnecessaryunwrap".♻️ Proposed refactor
pub enum HoistedLinkerError { #[diagnostic(transparent)] HoistedDepGraph(#[error(source)] HoistedDepGraphError), + #[display("hoisted linking requires the CAS path index produced by CreateVirtualStore")] + #[diagnostic(code(ERR_PNPM_PACKAGE_MANAGER_MISSING_CAS_PATHS))] + MissingCasPaths,- let cas_index = cas_paths_by_pkg_id.expect("hoisted CreateVirtualStore populates cas_paths"); + let cas_index = cas_paths_by_pkg_id.ok_or(HoistedLinkerError::MissingCasPaths)?;🤖 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-preparer/src/install_frozen_lockfile.rs` around lines 1722 - 1725, Replace the expect in the public run_hoisted_linker flow with a dedicated HoistedLinkerError variant for missing cas_paths_by_pkg_id, and propagate it through the existing Result-based error path. Preserve the current linker behavior for Some values and the no-op handling for installs without snapshots.Source: Path instructions
pnpm/crates/deps-preparer/src/graph_sequencer/tests.rs (1)
95-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename
self_loop_not_safe_flag; the name contradicts the assertion.The test asserts
result.safeis true for a length-1 self-loop, but the name reads as "not safe". A reader who scans test names concludes the opposite of the pinned behavior, and a later change could "fix" the assertion to match the name. Name it after the behavior it pins.♻️ Proposed rename
-fn self_loop_not_safe_flag() { +fn self_loop_does_not_clear_safe_flag() {🤖 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-preparer/src/graph_sequencer/tests.rs` around lines 95 - 104, Rename the test function self_loop_not_safe_flag to a name that clearly states that a length-1 self-loop is considered safe, while preserving its existing assertions and behavior.pnpm/crates/deps-preparer/src/import_indexed_dir/tests.rs (1)
484-487: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect the doc comment; the test does not cover staging-name uniqueness.
The comment states that two staging paths produced back-to-back in the same process must differ, so concurrent rayon workers do not collide on the rename target. The test imports into two different targets (
pkg-aandpkg-b), whose staging paths already differ by target path. It never exercises two staging names derived for the same target. Describe what the test verifies: two concurrent force imports into separate targets both complete and clear stale files.♻️ Proposed comment fix
-/// Two staging paths produced back-to-back in the same process must -/// differ — otherwise concurrent rayon workers would collide on the -/// rename target. Uses the function indirectly via two force re-installs -/// in parallel. +/// Two force re-imports running in parallel against separate targets +/// must both complete and clear their stale files. Staging-name +/// uniqueness for a single target is not covered here.🤖 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-preparer/src/import_indexed_dir/tests.rs` around lines 484 - 487, Correct the doc comment above the test to describe its actual coverage: concurrent force imports into separate targets (pkg-a and pkg-b) both complete successfully and clear stale files. Remove the unsupported claim about back-to-back staging-path uniqueness and rayon rename-target collisions.pnpm/crates/deps-preparer/src/deps_graph/tests.rs (1)
47-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the full
full_pkg_id, not just its prefix.The test name states the integrity is used verbatim, but the assertion only checks the prefix
@scope/[email protected]:sha512-. It passes even if the integrity body is truncated or rewritten after that prefix.full_pkg_idfeeds side-effects cache keys and global-virtual-store slot digests, so a change in integrity rendering moves store paths. Compare the whole string so the test enforces the contract its name claims.♻️ Proposed tightening
let graph = build_deps_graph(&snapshots, &packages); let node = graph.get(&pkg).expect("graph node"); - let expected_prefix = "`@scope/foo`@1.0.0:sha512-"; - assert!( - node.full_pkg_id.starts_with(expected_prefix), - "expected full_pkg_id to start with `{expected_prefix}`, got `{}`", - node.full_pkg_id, - ); + let expected = format!("`@scope/foo`@1.0.0:{}", integrity()); + assert_eq!(node.full_pkg_id, expected); }🤖 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-preparer/src/deps_graph/tests.rs` around lines 47 - 61, Update the test registry_resolution_full_pkg_id_uses_integrity_verbatim to assert node.full_pkg_id equals the complete expected package ID, including the exact integrity value produced by registry_metadata(), rather than checking only a prefix. Preserve the existing package and graph setup while ensuring truncated or rewritten integrity content causes the test to fail.pnpm/crates/deps-preparer/src/build_modules.rs (1)
264-265: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNarrow
normalize_build_dep_pathtopub(crate).
normalize_build_dep_pathis only callable from outsidedeps_preparerbecause ofpub mod build_modules;pluspub use build_modules::*;, but the only current callers are insidedeps-preparer. No Rust package-manager code uses it, so export it to the crate's public API only if a caller is intentionally required.🤖 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-preparer/src/build_modules.rs` around lines 264 - 265, Change normalize_build_dep_path from public to pub(crate) so it is available only within the deps-preparer crate. Keep the existing implementation and callers unchanged, and do not expose it through the crate’s public re-exports.pnpm/crates/deps-preparer/src/hoisted_dep_graph.rs (1)
479-500: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify the node update in
fill_children.Line 486 indexes
graph[&dir], so the key is proven present. Theif let Some(node) = graph.get_mut(&dir)guard on line 495 can never take theNonebranch. A direct&mutbinding states the invariant and drops the dead branch.♻️ Proposed simplification
let snapshot = lockfile.snapshots.as_ref().and_then(|m| m.get(&pkg_key)); let children = compute_children(snapshot, pkg_locations); - if let Some(node) = graph.get_mut(&dir) { - node.children = children; - } + graph.get_mut(&dir).expect("dir came from graph.keys()").children = children;🤖 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-preparer/src/hoisted_dep_graph.rs` around lines 479 - 500, In fill_children, replace the conditional graph.get_mut(&dir) update with a direct mutable binding, since each dir comes from graph.keys() and is guaranteed to exist. Assign the computed children directly through that binding while preserving the existing child computation.pnpm/crates/deps-preparer/src/hoisted_dep_graph/tests.rs (2)
1-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMerge the two import blocks into one.
Lines 1-11 and lines 96-102 both import from
super,pacquet_lockfile, andstd::collections. The style guide asks for merged explicit imports. Move the second block into the first so each module is imported once.As per coding guidelines: "Prefer ... merged explicit imports".
Also applies to: 96-102
🤖 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-preparer/src/hoisted_dep_graph/tests.rs` around lines 1 - 11, Merge the duplicate imports in the test module into the existing top-level import block. Combine all symbols from the later super, pacquet_lockfile, and std::collections imports with their corresponding first-block imports, leaving each module imported exactly once and preserving explicit import style.Source: Path instructions
176-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the empty-
Lockfileliteral into a fixture helper.Three tests repeat the same 13-field
Lockfileliteral, differing only inpackagesandsnapshots. A helper such asempty_lockfile(packages, snapshots)removes the duplication and keeps future field additions to one site.Also applies to: 595-607, 633-645
🤖 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-preparer/src/hoisted_dep_graph/tests.rs` around lines 176 - 188, Extract the repeated empty Lockfile construction into an empty_lockfile helper accepting packages and snapshots, and initialize all shared fields there. Update the three affected tests to call the helper with their respective packages and snapshots values while preserving the existing test behavior.pnpm/crates/deps-preparer/src/virtual_store_layout.rs (1)
371-381: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueImport
BTreeMapinstead of writing the full path inline.Line 40 already imports
std::collections::{HashMap, HashSet}. Thecollect_injected_depssignature and body spell outstd::collections::BTreeMapfive times. AddBTreeMapto that import and shorten the occurrences.As per coding guidelines: "Prefer ... merged explicit imports".
♻️ Proposed change
use std::{ - collections::{HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet}, path::{Path, PathBuf}, };skipped: &crate::SkippedSnapshots, - hoisted_locations: Option<&std::collections::BTreeMap<String, Vec<String>>>, -) -> std::collections::BTreeMap<String, Vec<String>> { - let mut injected: std::collections::BTreeMap<String, Vec<String>> = - std::collections::BTreeMap::new(); + hoisted_locations: Option<&BTreeMap<String, Vec<String>>>, +) -> BTreeMap<String, Vec<String>> { + let mut injected: BTreeMap<String, Vec<String>> = BTreeMap::new();🤖 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-preparer/src/virtual_store_layout.rs` around lines 371 - 381, Add BTreeMap to the existing std::collections import in collect_injected_deps and replace every fully qualified std::collections::BTreeMap reference in its signature and body with BTreeMap, without changing behavior.Source: Path instructions
pnpm/crates/deps-preparer/src/hoisting_limits/tests.rs (1)
42-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a test for the no-root-importer case.
get_hoisting_limitsonly emits the.@entry when a root importer is present (root_presentatpnpm/crates/deps-preparer/src/hoisting_limits.rsline 54). That branch is documented as upstream parity behavior, and no test covers it. A test with onlypackages/fooinimportersunderDependenciesmode should assert that.@is absent and that the per-importer key is still emitted.🤖 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-preparer/src/hoisting_limits/tests.rs` around lines 42 - 65, Add a test alongside dependencies_mode_borders_each_importer using only the “packages/foo” importer and HoistingLimits::Dependencies. Assert get_hoisting_limits omits the ".@" entry while still emitting the "packages%2Ffoo@workspace:packages/foo" key with its expected dependency set.pnpm/crates/deps-preparer/src/hoisting_limits.rs (1)
22-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider an exhaustive
matchonmodeinstead of twomatches!guards.
get_hoisting_limitstestsmodetwice withmatches!. Ifpacquet_config::HoistingLimitsgains a variant, that variant silently takes theWorkspacesbehavior. An exhaustivematchonmodemakes the compiler flag the new variant.🤖 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-preparer/src/hoisting_limits.rs` around lines 22 - 52, Update get_hoisting_limits to use an exhaustive match on mode instead of the two matches!(mode, ...) guards. Preserve the existing early return for HoistingLimits::None and dependency-specific importer-border behavior, while ensuring any future HoistingLimits variant causes a compile-time exhaustiveness error rather than defaulting to workspace behavior.pnpm/crates/deps-preparer/src/virtual_store_layout/tests.rs (1)
68-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse
package_metadatafor the inlinePackageMetadataliterals.Line 27 defines
package_metadata(resolution, version)and line 800 definesregistry_metadata(lead). Six more sites still spell out all twelve fields ofPackageMetadata, and every one sets the same nine fields toNone. A new field onPackageMetadatathen requires six edits. Route these sites throughpackage_metadatawith a registry resolution.As per coding guidelines: "Keep the change focused, avoid duplicated helpers".
♻️ Example for the first site
let mut packages = HashMap::new(); packages.insert( key.clone(), - PackageMetadata { - resolution: LockfileResolution::Registry(RegistryResolution { - integrity: "sha512-AAAA...AAAA" - .parse() - .expect("parse integrity"), - }), - version: None, - engines: None, - cpu: None, - os: None, - libc: None, - deprecated: None, - has_bin: None, - prepare: None, - bundled_dependencies: None, - peer_dependencies: None, - peer_dependencies_meta: None, - }, + package_metadata(registry_resolution("A"), None), );Add a small
registry_resolution(lead: &str) -> LockfileResolutionhelper next toregistry_metadata, which can then be expressed aspackage_metadata(registry_resolution(lead), None).Also applies to: 122-142, 168-188, 225-245, 346-366, 419-440
🤖 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-preparer/src/virtual_store_layout/tests.rs` around lines 68 - 88, Replace the six inline twelve-field PackageMetadata literals in the affected tests with package_metadata calls, passing a registry LockfileResolution and the existing version value (or None). Add one shared registry_resolution(lead: &str) -> LockfileResolution helper beside registry_metadata, and reuse it at each site without introducing additional duplicated helpers.Source: Path instructions
pnpm/crates/deps-preparer/src/package_map/tests.rs (1)
80-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLog the rendered package map before the comparison.
This assertion compares a large structured value. Bind the actual JSON and emit it with
eprintln!beforeassert_eq!. This keeps regression output readable.Proposed change
- assert_eq!( - serde_json::to_value(&package_map).expect("serialize package map"), + let actual = serde_json::to_value(&package_map).expect("serialize package map"); + eprintln!("PACKAGE MAP:\n{actual}\n"); + assert_eq!( + actual,As per path instructions, log complex values before non-equality assertions. Based on learnings, emit the rendered value with
eprintln!using{}formatting before the assertion.🤖 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-preparer/src/package_map/tests.rs` around lines 80 - 131, In the package map test, bind the rendered JSON value from serde_json::to_value(&package_map) to a local variable, print it with eprintln! using {} formatting immediately before assert_eq!, and compare that variable against the expected JSON.Sources: Path instructions, Learnings
pnpm/crates/deps-preparer/src/package_map.rs (1)
13-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the exported
deps-preparerAPI contracts.These items now cross crate boundaries but lack rustdoc contracts. Document path bases, side effects, errors, and required caller invariants. For
remove_direct_dep_link, state that callers must first confine the modules directory.
pnpm/crates/deps-preparer/src/package_map.rs#L13-L21: Document the filename and serialized package-map records.pnpm/crates/deps-preparer/src/package_map.rs#L36-L36: Document path bases and layout requirements.pnpm/crates/deps-preparer/src/package_map.rs#L47-L54: Document hoisted-map inputs and package-map write behavior.pnpm/crates/deps-preparer/src/package_map.rs#L69-L69: Document the hoisted output target and errors.pnpm/crates/deps-preparer/src/package_map.rs#L86-L86: Document lockfile-map semantics, including standard versus loose mode.pnpm/crates/deps-preparer/src/package_map.rs#L229-L229: Document graph-map semantics and graph-directory requirements.pnpm/crates/deps-preparer/src/pnp.rs#L17-L17: Document the.pnp.cjsoutput and write behavior.pnpm/crates/deps-preparer/src/prune_direct_deps.rs#L167-L167: Document canonical containment andNonebehavior.pnpm/crates/deps-preparer/src/prune_direct_deps.rs#L191-L192: Document selected-group ordering and output semantics.pnpm/crates/deps-preparer/src/prune_direct_deps.rs#L206-L206: Document symlink-only removal and the caller containment precondition.As per coding guidelines, use rustdoc comments for public API contracts. As per path instructions, new public
deps-preparerAPIs must document observable contracts with rustdoc intra-links.🤖 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-preparer/src/package_map.rs` around lines 13 - 21, pnpm/crates/deps-preparer/src/package_map.rs lines 13-21: add rustdoc for PACKAGE_MAP_FILENAME, PackageMap, and PackageMapPackage describing the filename and serialized records; lines 36, 47-54, 69, 86, and 229: document each public API’s path bases, layout and graph-directory requirements, hoisted and lockfile-map inputs, standard versus loose mode, output targets, write side effects, and errors using intra-links. In pnpm/crates/deps-preparer/src/pnp.rs lines 17, document the .pnp.cjs output and write behavior. In pnpm/crates/deps-preparer/src/prune_direct_deps.rs lines 167, 191-192, and 206, document canonical containment and None behavior, selected-group ordering and output semantics, and symlink-only removal; explicitly require callers to confine the modules directory before invoking remove_direct_dep_link.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-preparer/src/remove_quarantine.rs (1)
44-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the new public API contracts with rustdoc.
pnpm/crates/deps-preparer/src/remove_quarantine.rs#L44-L57: document the macOS quarantine-removal behavior and the non-macOS no-op behavior.pnpm/crates/deps-preparer/src/retry_config.rs#L8-L8: document theConfigtoRetryOptsconversion contract and timeout units.pnpm/crates/deps-preparer/src/store_init.rs#L15-L15: document that initialization is best effort and that failures only produce warnings.As per coding guidelines, “Use rustdoc comments for public API contracts.” As per path instructions, “For the new public
deps-preparerAPI, document observable contracts with rustdoc intra-links.”🤖 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-preparer/src/remove_quarantine.rs` around lines 44 - 57, Add rustdoc contracts at pnpm/crates/deps-preparer/src/remove_quarantine.rs:44-57 for remove_quarantine_from_native_binaries, covering macOS quarantine removal and the non-macOS no-op; document the Config-to-RetryOpts conversion and timeout units at pnpm/crates/deps-preparer/src/retry_config.rs:8-8; document best-effort initialization and warning-only failures at pnpm/crates/deps-preparer/src/store_init.rs:15-15, using rustdoc intra-links for referenced public API symbols.Sources: Coding guidelines, Path instructions
🤖 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-preparer/src/create_symlink_layout.rs`:
- Around line 20-25: Correct the rustdoc for virtual_node_modules_dir to state
only that the directory need not already exist; remove the inaccurate claim that
symlink_package pre-creates the parent before each link and the resulting
redundant-stat explanation. Keep the documentation focused on the public
contract, leaving implementation rationale to regular comments.
In `@pnpm/crates/deps-preparer/src/current_lockfile/tests.rs`:
- Line 1: Update the module-level documentation in the tests module to reference
all covered functions: filter_lockfile_for_current, materialization_closure,
merge_filtered_wanted_lockfile, merge_filtered_current_lockfile, and
extend_skipped_with_dependency_closure.
In `@pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs`:
- Around line 61-63: Fix the documentation sentence near the background
prefetcher description by removing the dangling “the pnpr client's” possessive
and clearly attributing TarballPrefetcher to a single owner, consistent with the
parallel create_virtual_store documentation; preserve the parallel listing with
PrefetchingResolver.
---
Nitpick comments:
In `@pnpm/crates/deps-preparer/src/build_modules.rs`:
- Around line 264-265: Change normalize_build_dep_path from public to pub(crate)
so it is available only within the deps-preparer crate. Keep the existing
implementation and callers unchanged, and do not expose it through the crate’s
public re-exports.
In `@pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs`:
- Line 19: Restrict the concurrency probe test surface to crate visibility: make
LinkConcurrencyProbe in
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rs:19
pub(crate), change tests to pub(crate) mod tests in
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:297, and make
the link_concurrency_probe fields pub(crate) in
pnpm/crates/deps-preparer/src/create_virtual_store.rs:183-185,
pnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rs:77-78, and
pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs:135.
In `@pnpm/crates/deps-preparer/src/deps_graph/tests.rs`:
- Around line 47-61: Update the test
registry_resolution_full_pkg_id_uses_integrity_verbatim to assert
node.full_pkg_id equals the complete expected package ID, including the exact
integrity value produced by registry_metadata(), rather than checking only a
prefix. Preserve the existing package and graph setup while ensuring truncated
or rewritten integrity content causes the test to fail.
In `@pnpm/crates/deps-preparer/src/graph_sequencer/tests.rs`:
- Around line 95-104: Rename the test function self_loop_not_safe_flag to a name
that clearly states that a length-1 self-loop is considered safe, while
preserving its existing assertions and behavior.
In `@pnpm/crates/deps-preparer/src/hoisted_dep_graph.rs`:
- Around line 479-500: In fill_children, replace the conditional
graph.get_mut(&dir) update with a direct mutable binding, since each dir comes
from graph.keys() and is guaranteed to exist. Assign the computed children
directly through that binding while preserving the existing child computation.
In `@pnpm/crates/deps-preparer/src/hoisted_dep_graph/tests.rs`:
- Around line 1-11: Merge the duplicate imports in the test module into the
existing top-level import block. Combine all symbols from the later super,
pacquet_lockfile, and std::collections imports with their corresponding
first-block imports, leaving each module imported exactly once and preserving
explicit import style.
- Around line 176-188: Extract the repeated empty Lockfile construction into an
empty_lockfile helper accepting packages and snapshots, and initialize all
shared fields there. Update the three affected tests to call the helper with
their respective packages and snapshots values while preserving the existing
test behavior.
In `@pnpm/crates/deps-preparer/src/hoisting_limits.rs`:
- Around line 22-52: Update get_hoisting_limits to use an exhaustive match on
mode instead of the two matches!(mode, ...) guards. Preserve the existing early
return for HoistingLimits::None and dependency-specific importer-border
behavior, while ensuring any future HoistingLimits variant causes a compile-time
exhaustiveness error rather than defaulting to workspace behavior.
In `@pnpm/crates/deps-preparer/src/hoisting_limits/tests.rs`:
- Around line 42-65: Add a test alongside
dependencies_mode_borders_each_importer using only the “packages/foo” importer
and HoistingLimits::Dependencies. Assert get_hoisting_limits omits the ".@"
entry while still emitting the "packages%2Ffoo@workspace:packages/foo" key with
its expected dependency set.
In `@pnpm/crates/deps-preparer/src/import_indexed_dir/tests.rs`:
- Around line 484-487: Correct the doc comment above the test to describe its
actual coverage: concurrent force imports into separate targets (pkg-a and
pkg-b) both complete successfully and clear stale files. Remove the unsupported
claim about back-to-back staging-path uniqueness and rayon rename-target
collisions.
In `@pnpm/crates/deps-preparer/src/install_frozen_lockfile.rs`:
- Around line 1722-1725: Replace the expect in the public run_hoisted_linker
flow with a dedicated HoistedLinkerError variant for missing
cas_paths_by_pkg_id, and propagate it through the existing Result-based error
path. Preserve the current linker behavior for Some values and the no-op
handling for installs without snapshots.
In `@pnpm/crates/deps-preparer/src/install_package_by_snapshot.rs`:
- Line 811: Add the #[must_use] attribute to the runtime_platform_selector
function, matching the existing annotations on unverified_fetch_is_allowed and
host_platform_selector so callers cannot silently discard its PlatformSelector
result.
In `@pnpm/crates/deps-preparer/src/install_package_by_snapshot/tests.rs`:
- Around line 520-546: The three mem-cache install tests duplicate the full
InstallPackageBySnapshot construction. Extract a sibling helper near
run_snapshot_install_with_picker that accepts tarball_mem_cache:
Option<&Arc<MemCache>> and returns the install Result, centralizing the shared
fields; update the install sites around the referenced blocks to call it with
each cache variant.
In `@pnpm/crates/deps-preparer/src/install_package_from_registry/tests.rs`:
- Around line 27-178: Replace the exhaustive Config literal in create_config
with Config::new() and override only the fixture-dependent fields: store_dir,
modules_dir, virtual_store_dir, global_virtual_store_dir, cache_dir, registry,
and symlink/hoist when needed to preserve assertions. Remove the file-level
clippy::default_trait_access allowance if it is no longer used, and verify the
tests retain their expected defaults.
In `@pnpm/crates/deps-preparer/src/link_root_component_members/tests.rs`:
- Around line 375-381: Update the Windows branch of the preexisting link setup
in the test to call pacquet_fs::symlink_dir instead of
std::os::windows::fs::symlink_dir, preserving the existing source and
destination paths and Unix behavior.
In `@pnpm/crates/deps-preparer/src/package_map.rs`:
- Around line 13-21: pnpm/crates/deps-preparer/src/package_map.rs lines 13-21:
add rustdoc for PACKAGE_MAP_FILENAME, PackageMap, and PackageMapPackage
describing the filename and serialized records; lines 36, 47-54, 69, 86, and
229: document each public API’s path bases, layout and graph-directory
requirements, hoisted and lockfile-map inputs, standard versus loose mode,
output targets, write side effects, and errors using intra-links. In
pnpm/crates/deps-preparer/src/pnp.rs lines 17, document the .pnp.cjs output and
write behavior. In pnpm/crates/deps-preparer/src/prune_direct_deps.rs lines 167,
191-192, and 206, document canonical containment and None behavior,
selected-group ordering and output semantics, and symlink-only removal;
explicitly require callers to confine the modules directory before invoking
remove_direct_dep_link.
In `@pnpm/crates/deps-preparer/src/package_map/tests.rs`:
- Around line 80-131: In the package map test, bind the rendered JSON value from
serde_json::to_value(&package_map) to a local variable, print it with eprintln!
using {} formatting immediately before assert_eq!, and compare that variable
against the expected JSON.
In `@pnpm/crates/deps-preparer/src/remove_quarantine.rs`:
- Around line 44-57: Add rustdoc contracts at
pnpm/crates/deps-preparer/src/remove_quarantine.rs:44-57 for
remove_quarantine_from_native_binaries, covering macOS quarantine removal and
the non-macOS no-op; document the Config-to-RetryOpts conversion and timeout
units at pnpm/crates/deps-preparer/src/retry_config.rs:8-8; document best-effort
initialization and warning-only failures at
pnpm/crates/deps-preparer/src/store_init.rs:15-15, using rustdoc intra-links for
referenced public API symbols.
In `@pnpm/crates/deps-preparer/src/virtual_store_layout.rs`:
- Around line 371-381: Add BTreeMap to the existing std::collections import in
collect_injected_deps and replace every fully qualified
std::collections::BTreeMap reference in its signature and body with BTreeMap,
without changing behavior.
In `@pnpm/crates/deps-preparer/src/virtual_store_layout/tests.rs`:
- Around line 68-88: Replace the six inline twelve-field PackageMetadata
literals in the affected tests with package_metadata calls, passing a registry
LockfileResolution and the existing version value (or None). Add one shared
registry_resolution(lead: &str) -> LockfileResolution helper beside
registry_metadata, and reuse it at each site without introducing additional
duplicated helpers.
🪄 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: a6836c74-059c-46f5-ab5a-57ba5c944845
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (70)
Cargo.tomlpnpm/crates/cli/tests/multiple_importers.rspnpm/crates/deps-preparer/Cargo.tomlpnpm/crates/deps-preparer/src/build_modules.rspnpm/crates/deps-preparer/src/build_modules/tests.rspnpm/crates/deps-preparer/src/build_sequence.rspnpm/crates/deps-preparer/src/build_sequence/tests.rspnpm/crates/deps-preparer/src/create_symlink_layout.rspnpm/crates/deps-preparer/src/create_symlink_layout/tests.rspnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot.rspnpm/crates/deps-preparer/src/create_virtual_dir_by_snapshot/tests.rspnpm/crates/deps-preparer/src/create_virtual_store.rspnpm/crates/deps-preparer/src/create_virtual_store/tests.rspnpm/crates/deps-preparer/src/current_lockfile.rspnpm/crates/deps-preparer/src/current_lockfile/tests.rspnpm/crates/deps-preparer/src/deps_graph.rspnpm/crates/deps-preparer/src/deps_graph/tests.rspnpm/crates/deps-preparer/src/graph_sequencer.rspnpm/crates/deps-preparer/src/graph_sequencer/tests.rspnpm/crates/deps-preparer/src/hoist.rspnpm/crates/deps-preparer/src/hoist/tests.rspnpm/crates/deps-preparer/src/hoisted_dep_graph.rspnpm/crates/deps-preparer/src/hoisted_dep_graph/tests.rspnpm/crates/deps-preparer/src/hoisting_limits.rspnpm/crates/deps-preparer/src/hoisting_limits/tests.rspnpm/crates/deps-preparer/src/import_indexed_dir.rspnpm/crates/deps-preparer/src/import_indexed_dir/tests.rspnpm/crates/deps-preparer/src/install_frozen_lockfile.rspnpm/crates/deps-preparer/src/install_frozen_lockfile/tests.rspnpm/crates/deps-preparer/src/install_package_by_snapshot.rspnpm/crates/deps-preparer/src/install_package_by_snapshot/tests.rspnpm/crates/deps-preparer/src/install_package_from_registry.rspnpm/crates/deps-preparer/src/install_package_from_registry/tests.rspnpm/crates/deps-preparer/src/installability.rspnpm/crates/deps-preparer/src/installability/tests.rspnpm/crates/deps-preparer/src/lib.rspnpm/crates/deps-preparer/src/link_bins.rspnpm/crates/deps-preparer/src/link_bins/tests.rspnpm/crates/deps-preparer/src/link_file.rspnpm/crates/deps-preparer/src/link_file/tests.rspnpm/crates/deps-preparer/src/link_hoisted_modules.rspnpm/crates/deps-preparer/src/link_hoisted_modules/tests.rspnpm/crates/deps-preparer/src/link_root_component_members.rspnpm/crates/deps-preparer/src/link_root_component_members/tests.rspnpm/crates/deps-preparer/src/package_map.rspnpm/crates/deps-preparer/src/package_map/tests.rspnpm/crates/deps-preparer/src/pnp.rspnpm/crates/deps-preparer/src/prune_direct_deps.rspnpm/crates/deps-preparer/src/prune_direct_deps/tests.rspnpm/crates/deps-preparer/src/prune_stale_modules.rspnpm/crates/deps-preparer/src/remove_quarantine.rspnpm/crates/deps-preparer/src/remove_quarantine/tests.rspnpm/crates/deps-preparer/src/retry_config.rspnpm/crates/deps-preparer/src/safe_join_modules_dir.rspnpm/crates/deps-preparer/src/safe_join_modules_dir/tests.rspnpm/crates/deps-preparer/src/store_init.rspnpm/crates/deps-preparer/src/symlink_direct_dependencies.rspnpm/crates/deps-preparer/src/symlink_direct_dependencies/tests.rspnpm/crates/deps-preparer/src/symlink_package.rspnpm/crates/deps-preparer/src/validate_lockfile_paths.rspnpm/crates/deps-preparer/src/validate_lockfile_paths/tests.rspnpm/crates/deps-preparer/src/version_policy.rspnpm/crates/deps-preparer/src/virtual_store_layout.rspnpm/crates/deps-preparer/src/virtual_store_layout/tests.rspnpm/crates/package-manager/Cargo.tomlpnpm/crates/package-manager/src/install.rspnpm/crates/package-manager/src/install/tests.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/package-manager/src/lib.rspnpm/plans/TEST_PORTING.md
💤 Files with no reviewable changes (2)
- pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
- pnpm/crates/package-manager/src/install.rs
🛑 Comments failed to post (2)
pnpm/crates/deps-preparer/src/create_symlink_layout.rs (1)
20-25: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the parent-directory claim in the rustdoc.
The doc states that
symlink_packagecallsfs::create_dir_allon the symlink path's parent "before each link", and concludes that callers which already created the directory pay redundant stat syscalls.symlink_packagedocuments the opposite mechanism atpnpm/crates/deps-preparer/src/symlink_package.rslines 58-64:force_symlink_dirdoes not pre-create the parent. It creates the parent only after aNotFoundfailure, and avoiding the extra stat per symlink is the stated reason for that design.The observable contract is correct —
virtual_node_modules_dirdoes not have to exist. Only the mechanism and the cost note are wrong. Keeping them accurate prevents a later change from reintroducing the pre-link stat this design avoids.📝 Proposed doc fix
/// `virtual_node_modules_dir` does not have to exist — -/// `symlink_package` calls `fs::create_dir_all` on the symlink path's -/// parent before each link. Callers that already know the directory -/// exists (e.g. `CreateVirtualStore::run`, which `mkdir`s it just -/// before calling this function) just pay redundant stat syscalls, -/// which is cheap and matches pnpm's own redundant-mkdir shape. +/// `symlink_package` recovers from a missing parent by calling +/// `create_dir_all` once and reissuing the symlink syscall. Callers +/// that already know the directory exists (e.g. +/// `CreateVirtualStore::run`, which `mkdir`s it just before calling +/// this function) pay nothing extra, because there is no pre-link +/// stat on the common path.As per coding guidelines: "Use rustdoc comments for public API contracts and regular comments for implementation rationale. Do not duplicate test behavior in documentation; comments should explain only non-obvious reasons or invariants."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements./// `virtual_node_modules_dir` does not have to exist — /// `symlink_package` recovers from a missing parent by calling /// `create_dir_all` once and reissuing the symlink syscall. Callers /// that already know the directory exists (e.g. /// `CreateVirtualStore::run`, which `mkdir`s it just before calling /// this function) pay nothing extra, because there is no pre-link /// stat on the common 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/deps-preparer/src/create_symlink_layout.rs` around lines 20 - 25, Correct the rustdoc for virtual_node_modules_dir to state only that the directory need not already exist; remove the inaccurate claim that symlink_package pre-creates the parent before each link and the resulting redundant-stat explanation. Keep the documentation focused on the public contract, leaving implementation rationale to regular comments.Source: Coding guidelines
pnpm/crates/deps-preparer/src/current_lockfile/tests.rs (1)
1-1: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update the module doc to match the file scope.
The module doc names only
super::filter_lockfile_for_current. The file now also testsmaterialization_closure,merge_filtered_wanted_lockfile,merge_filtered_current_lockfile, andextend_skipped_with_dependency_closure. A reader who searches for the merge tests will not find them from this header.📝 Proposed doc fix
-//! Unit tests for [`super::filter_lockfile_for_current`]. +//! Unit tests for the current-lockfile module: [`super::filter_lockfile_for_current`], +//! [`super::materialization_closure`], [`super::merge_filtered_wanted_lockfile`], +//! [`super::merge_filtered_current_lockfile`], and +//! [`super::extend_skipped_with_dependency_closure`].📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.//! Unit tests for the current-lockfile module: [`super::filter_lockfile_for_current`], //! [`super::materialization_closure`], [`super::merge_filtered_wanted_lockfile`], //! [`super::merge_filtered_current_lockfile`], and //! [`super::extend_skipped_with_dependency_closure`].🤖 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-preparer/src/current_lockfile/tests.rs` at line 1, Update the module-level documentation in the tests module to reference all covered functions: filter_lockfile_for_current, materialization_closure, merge_filtered_wanted_lockfile, merge_filtered_current_lockfile, and extend_skipped_with_dependency_closure.
|
Code review by qodo was updated up to the latest commit 23584da |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13637 +/- ##
==========================================
- Coverage 88.05% 88.04% -0.02%
==========================================
Files 573 574 +1
Lines 98390 98386 -4
==========================================
- Hits 86642 86628 -14
- Misses 11748 11758 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6d0ff26 to
19bd9c3
Compare
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Code review by qodo was updated up to the latest commit 19bd9c3 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/deps-restorer/src/hoist.rs (1)
65-70: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winJustify the wider API surface and document
build_hoist_graph_with_max_length.
compute_hoist_plancalls this internally, andpacquet/package-managerdepends onpacquet-deps-restorerwithout importing the helper itself. Keep the helper private tocrate::hoistor mark it as a deliberate extraction API. If it remainspub, add rustdoc that states the degraded behavior for missing metadata and howvirtual_store_dir_max_lengthaffectssort_keyordering.🤖 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/hoist.rs` around lines 65 - 70, The public build_hoist_graph_with_max_length API needs justification and documentation. Prefer making build_hoist_graph_with_max_length private to crate::hoist if external callers do not require it; otherwise add rustdoc describing degraded behavior when metadata is missing and how virtual_store_dir_max_length influences sort_key ordering.Source: Coding guidelines
🧹 Nitpick comments (7)
pnpm/crates/deps-restorer/src/install_package_from_registry/tests.rs (2)
396-397: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert a symlink, not mere existence, for the second-visit link.
Path::existsfollows the link and also returnstruefor a real directory. The assertion therefore does not prove the second visit created the per-parent symlink. Use the same helper the sibling tests use.💚 Suggested assertion
let symlink_path = second_parent_dir.path().join("second-alias"); - assert!(symlink_path.exists() || symlink_path.is_symlink(), "per-parent symlink missing"); + assert!( + pacquet_testing_utils::fs::is_symlink_or_junction(&symlink_path) + .expect("inspect per-parent link"), + "per-parent symlink missing at {symlink_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/deps-restorer/src/install_package_from_registry/tests.rs` around lines 396 - 397, Update the assertion for second-alias in the relevant install-package test to use the existing symlink-specific helper used by sibling tests, ensuring it verifies the path is actually a symlink rather than merely an existing directory.
27-178: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBuild the test
ConfigfromConfig::new()instead of a full struct literal.
create_confignames about 145 fields. Sibling test modules in the same crate build their config fromConfig::new()and override only the fields they care about — seepnpm/crates/deps-restorer/src/create_virtual_store/tests.rslines 114-121 andpnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rslines 55-59. The literal here duplicates the whole config surface, so every newConfigfield breaks this file alone. The#![expect(clippy::default_trait_access)]at the top of the file exists only to support the literal.Rewrite
create_configin the same shape as the sibling modules and drop the file-levelexpect.As per coding guidelines from AGENTS.md "Code Reuse and Avoiding Duplication": before adding code, verify no helper is duplicated elsewhere.
♻️ Suggested shape
fn create_config( store_dir: &Path, modules_dir: &Path, virtual_store_dir: &Path, cache_dir: &Path, ) -> Config { - Config { - versioning: Default::default(), - // ... ~145 fields ... - config_dir: None, - } + let mut config = Config::new(); + config.store_dir = StoreDir::new(store_dir); + config.modules_dir = modules_dir.to_path_buf(); + config.virtual_store_dir = virtual_store_dir.to_path_buf(); + config.global_virtual_store_dir = virtual_store_dir.to_path_buf(); + config.cache_dir = cache_dir.to_path_buf(); + config }Add only the extra overrides the tests actually depend on, such as
registry,verify_store_integrity, andchild_concurrency.🤖 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_package_from_registry/tests.rs` around lines 27 - 178, Replace the full struct literal in create_config with Config::new(), overriding only the test-required fields such as store_dir, modules_dir, virtual_store_dir, cache_dir, registry, verify_store_integrity, and child_concurrency. Match the initialization pattern used by the sibling test modules, and remove the file-level clippy::default_trait_access expectation since it is no longer needed.Source: Path instructions
pnpm/crates/deps-restorer/src/link_file.rs (1)
30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCorrect the stated location of the downgrade statics.
Both comments say the process-global state lives inside
link_file.AUTO_STATEandCLONE_OR_COPY_STATEare declared insidetry_importat lines 210 and 237. Point the comments attry_importso a reader can find the state.📝 Suggested wording
-// These are the state *values*, not the cache itself: each mode keeps -// its own process-global `AtomicU8` (`AUTO_STATE` inside `link_file`, -// `CLONE_OR_COPY_STATE` likewise), so an `Auto` downgrade doesn't -// affect `CloneOrCopy` and vice versa. +// These are the state *values*, not the cache itself: each mode keeps +// its own process-global `AtomicU8` (`AUTO_STATE` and +// `CLONE_OR_COPY_STATE`, both declared inside `try_import`), so an +// `Auto` downgrade doesn't affect `CloneOrCopy` and vice versa.-/// pass their own `AtomicU8` and exercise the downgrade logic in -/// isolation — the production path uses a `static` declared inside -/// [`link_file`]. Only capability / cross-device style failures +/// pass their own `AtomicU8` and exercise the downgrade logic in +/// isolation — the production path uses the `AUTO_STATE` `static` +/// declared inside `try_import`. Only capability / cross-device style failuresAlso applies to: 305-312
🤖 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/link_file.rs` around lines 30 - 34, Update the comments describing AUTO_STATE and CLONE_OR_COPY_STATE to state that each process-global AtomicU8 is declared inside try_import, replacing the incorrect reference to link_file. Apply this correction to both comment blocks while preserving their explanation that the states are independent.pnpm/crates/deps-restorer/src/symlink_direct_dependencies.rs (1)
275-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCollapse the duplicated rustdoc blocks.
Each of these two items carries the contract twice. On
validate_importer_id, lines 275-282 describe rejecting keys that resolve outside the workspace root, and lines 283-288 restate the same rule with the same rejected shapes. Onimporter_root_dir, lines 377-383 explain the"."root key and POSIX resolution, and lines 384-385 restate the return value. Keep one statement of each contract.As per coding guidelines: "Use rustdoc comments for public API contracts... Do not duplicate test behavior in documentation; comments should explain only non-obvious reasons or invariants." pnpm/CODE_STYLE_GUIDE.md adds: "Do not repeat what the code already says."
📝 Suggested consolidation
/// Reject importer keys that would resolve outside the workspace root. /// /// Pnpm's lockfile spec writes importer keys as POSIX paths relative /// to the workspace root (`.` for the root, `packages/web` for a /// subproject). Anything else — an absolute POSIX path, a Windows -/// drive prefix, a `..` segment — is either malformed or hostile, so -/// surface it as a typed error rather than silently letting -/// `Path::join` produce an off-workspace path. -/// Reject a lockfile importer key that cannot be safely joined onto the -/// lockfile dir: absolute paths, Windows drive prefixes, backslash -/// separators, and `..` traversal segments. `.` (the root importer) and any -/// ordinary POSIX-relative sub-path are accepted. Callers that turn an -/// importer key into an on-disk path — via [`importer_root_dir`] — must run -/// this first when the key comes from an untrusted lockfile. +/// drive prefix, a backslash separator, a `..` segment — is either +/// malformed or hostile, so surface it as a typed error rather than +/// silently letting `Path::join` produce an off-workspace path. +/// +/// Callers that turn an importer key into an on-disk path — via +/// [`importer_root_dir`] — must run this first when the key comes from +/// an untrusted lockfile. pub fn validate_importer_id(importer_id: &str) -> Result<(), SymlinkDirectDependenciesError> {/// Resolve `importer_id` (a lockfile key) against the workspace root. /// /// Pnpm's lockfile spec uses `"."` for the root importer and /// forward-slash POSIX paths for sub-importers. Mirroring that here /// keeps lockfiles written by pacquet and pnpm interchangeable. The /// returned path is platform-native (`Path::join` handles the /// conversion on Windows). -/// The on-disk root of the project a lockfile importer ID names, relative -/// to `workspace_root` (which is normally the lockfile directory). #[must_use]Also applies to: 377-386
🤖 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/symlink_direct_dependencies.rs` around lines 275 - 288, Collapse the duplicated rustdoc comments for validate_importer_id and importer_root_dir into one concise contract per public function. Retain only the non-obvious importer-key safety invariant and the "." root/POSIX-relative path behavior; remove repeated descriptions of rejected shapes and return values without changing implementation behavior.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-restorer/src/create_virtual_store/tests.rs (1)
99-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the tolerant skip in
cold_batch_links_slots_in_parallel.The test returns early when rayon reports fewer than two threads. The concurrency assertion then never runs, and the environment problem stays invisible. Let the test fail instead, or force a two-thread rayon pool for this test so the assertion always runs.
As per coding guidelines: "Tests must not silently return early when required tools such as
git,node, ornpmare unavailable; let the test fail." pnpm/AGENTS.md states the same: "If a test cannot run without a tool, let it panic rather than silently skipping. The environment must be fixed, not the test."🤖 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/tests.rs` around lines 99 - 105, Remove the early-return guard based on rayon::current_num_threads() from cold_batch_links_slots_in_parallel so the concurrency assertion always executes. Let the test fail naturally when insufficient rayon threads are available, without silently skipping the assertion.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rs (1)
40-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider sharing the recording reporter as a crate helper.
This file repeats the same
static EVENTSplusRecordingReporterpattern five times. If the crate-level tests module is the intended boundary, put the helper once there and call it from these tests instead of duplicating it in each case.🤖 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/symlink_direct_dependencies/tests.rs` around lines 40 - 48, Move the duplicated EVENTS static and RecordingReporter implementation from the individual tests into the crate-level tests module as a shared helper. Update each affected test in the symlink direct-dependencies test module to reuse that helper while preserving the existing event-clearing and recording behavior.Source: Learnings
pnpm/crates/deps-restorer/src/link_hoisted_modules/tests.rs (1)
140-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the
removedstats payload and the orphan-confinement refusal.Two behaviors of
link_hoisted_modulesstay untested in this file:
link_hoisted_modulesemitspnpm:statsRemoved { prefix, removed }on every run (link_hoisted_modules.rslines 137-140). Every test here usesSilentReporter, so the count and prefix are never asserted. The coding guidelines require recording-fake coverage for reporter events. Sibling test files already define a recording reporter you can reuse.remove_orphansrefuses an orphan directory that is not lexically insideconfine_root(link_hoisted_modules.rslines 172-183). No test drives that branch. Add a case with aprev_graphentry outsideconfine_rootand assert the directory survives.As per coding guidelines: "Reporter
pnpm:<channel>events emitted by Rust code must match the TypeScript implementation in call site, payload, ordering, channel mapping, and recording-fake test coverage."🤖 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/link_hoisted_modules/tests.rs` around lines 140 - 180, Extend the tests around link_hoisted_modules to use the existing recording reporter and assert each run emits the pnpm:stats Removed event with the expected prefix and removal count. Add coverage for remove_orphans using a prev_graph entry whose directory is outside confine_root, and assert that directory remains intact after linking. Preserve the existing orphan removal assertions for paths within the confinement root.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/create_symlink_layout/tests.rs`:
- Around line 24-34: Update the symlink assertions in the test, including the
additional assertion block around the referenced lines, to use
pacquet_fs::read_symlink_dir instead of std::fs::read_link so junctions work on
Windows. Preserve the existing expected relative-target comparisons and
assertion behavior.
In `@pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs`:
- Line 393: Make both permission-error tests deterministic by adding a narrow
Host/Sys filesystem capability seam and injecting errors instead of relying on
mode bits: in pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs:393-393,
preserve node_modules then inject PermissionDenied from remove_dir_all; in
pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs:458-458, inject
PermissionDenied from symlink_metadata for target/node_modules. Update the
relevant test setup and Host/Sys implementations while keeping the production
filesystem behavior unchanged.
In `@pnpm/crates/deps-restorer/src/link_bins.rs`:
- Around line 684-687: Update the documentation near the fallback path in
`link_bins.rs` to remove or correct the unresolved
`crate::InstallWithFreshLockfile` link, using plain prose consistent with the
surrounding comment unless a valid import or re-export is intentionally added.
Ensure the resulting documentation resolves successfully in `cargo doc`.
In `@pnpm/crates/deps-restorer/src/prune_direct_deps/tests.rs`:
- Around line 292-293: Rename the test function
prune_direct_deps_respects_trusted_importer_allow_set to reflect that it
exercises prunable_importer_ids, not trusted_importer_ids. Add the short
rationale comment used by the sibling tests explaining this set is unrelated to
trusted importer validation.
---
Outside diff comments:
In `@pnpm/crates/deps-restorer/src/hoist.rs`:
- Around line 65-70: The public build_hoist_graph_with_max_length API needs
justification and documentation. Prefer making build_hoist_graph_with_max_length
private to crate::hoist if external callers do not require it; otherwise add
rustdoc describing degraded behavior when metadata is missing and how
virtual_store_dir_max_length influences sort_key ordering.
---
Nitpick comments:
In `@pnpm/crates/deps-restorer/src/create_virtual_store/tests.rs`:
- Around line 99-105: Remove the early-return guard based on
rayon::current_num_threads() from cold_batch_links_slots_in_parallel so the
concurrency assertion always executes. Let the test fail naturally when
insufficient rayon threads are available, without silently skipping the
assertion.
In `@pnpm/crates/deps-restorer/src/install_package_from_registry/tests.rs`:
- Around line 396-397: Update the assertion for second-alias in the relevant
install-package test to use the existing symlink-specific helper used by sibling
tests, ensuring it verifies the path is actually a symlink rather than merely an
existing directory.
- Around line 27-178: Replace the full struct literal in create_config with
Config::new(), overriding only the test-required fields such as store_dir,
modules_dir, virtual_store_dir, cache_dir, registry, verify_store_integrity, and
child_concurrency. Match the initialization pattern used by the sibling test
modules, and remove the file-level clippy::default_trait_access expectation
since it is no longer needed.
In `@pnpm/crates/deps-restorer/src/link_file.rs`:
- Around line 30-34: Update the comments describing AUTO_STATE and
CLONE_OR_COPY_STATE to state that each process-global AtomicU8 is declared
inside try_import, replacing the incorrect reference to link_file. Apply this
correction to both comment blocks while preserving their explanation that the
states are independent.
In `@pnpm/crates/deps-restorer/src/link_hoisted_modules/tests.rs`:
- Around line 140-180: Extend the tests around link_hoisted_modules to use the
existing recording reporter and assert each run emits the pnpm:stats Removed
event with the expected prefix and removal count. Add coverage for
remove_orphans using a prev_graph entry whose directory is outside confine_root,
and assert that directory remains intact after linking. Preserve the existing
orphan removal assertions for paths within the confinement root.
In `@pnpm/crates/deps-restorer/src/symlink_direct_dependencies.rs`:
- Around line 275-288: Collapse the duplicated rustdoc comments for
validate_importer_id and importer_root_dir into one concise contract per public
function. Retain only the non-obvious importer-key safety invariant and the "."
root/POSIX-relative path behavior; remove repeated descriptions of rejected
shapes and return values without changing implementation behavior.
In `@pnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rs`:
- Around line 40-48: Move the duplicated EVENTS static and RecordingReporter
implementation from the individual tests into the crate-level tests module as a
shared helper. Update each affected test in the symlink direct-dependencies test
module to reuse that helper while preserving the existing event-clearing and
recording behavior.
🪄 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: 12a0ff75-36d2-420f-af2e-2afd6eaf6f10
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (67)
Cargo.tomlpnpm/crates/cli/tests/multiple_importers.rspnpm/crates/deps-restorer/Cargo.tomlpnpm/crates/deps-restorer/src/build_modules.rspnpm/crates/deps-restorer/src/build_modules/tests.rspnpm/crates/deps-restorer/src/build_sequence.rspnpm/crates/deps-restorer/src/build_sequence/tests.rspnpm/crates/deps-restorer/src/create_symlink_layout.rspnpm/crates/deps-restorer/src/create_symlink_layout/tests.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/tests.rspnpm/crates/deps-restorer/src/current_lockfile.rspnpm/crates/deps-restorer/src/current_lockfile/tests.rspnpm/crates/deps-restorer/src/deps_graph.rspnpm/crates/deps-restorer/src/deps_graph/tests.rspnpm/crates/deps-restorer/src/graph_sequencer.rspnpm/crates/deps-restorer/src/graph_sequencer/tests.rspnpm/crates/deps-restorer/src/hoist.rspnpm/crates/deps-restorer/src/hoist/tests.rspnpm/crates/deps-restorer/src/hoisted_dep_graph.rspnpm/crates/deps-restorer/src/hoisted_dep_graph/tests.rspnpm/crates/deps-restorer/src/hoisting_limits.rspnpm/crates/deps-restorer/src/hoisting_limits/tests.rspnpm/crates/deps-restorer/src/import_indexed_dir.rspnpm/crates/deps-restorer/src/import_indexed_dir/tests.rspnpm/crates/deps-restorer/src/install_frozen_lockfile.rspnpm/crates/deps-restorer/src/install_frozen_lockfile/tests.rspnpm/crates/deps-restorer/src/install_package_by_snapshot.rspnpm/crates/deps-restorer/src/install_package_by_snapshot/tests.rspnpm/crates/deps-restorer/src/install_package_from_registry.rspnpm/crates/deps-restorer/src/install_package_from_registry/tests.rspnpm/crates/deps-restorer/src/installability.rspnpm/crates/deps-restorer/src/installability/tests.rspnpm/crates/deps-restorer/src/lib.rspnpm/crates/deps-restorer/src/link_bins.rspnpm/crates/deps-restorer/src/link_bins/tests.rspnpm/crates/deps-restorer/src/link_file.rspnpm/crates/deps-restorer/src/link_file/tests.rspnpm/crates/deps-restorer/src/link_hoisted_modules.rspnpm/crates/deps-restorer/src/link_hoisted_modules/tests.rspnpm/crates/deps-restorer/src/link_root_component_members.rspnpm/crates/deps-restorer/src/link_root_component_members/tests.rspnpm/crates/deps-restorer/src/package_map.rspnpm/crates/deps-restorer/src/package_map/tests.rspnpm/crates/deps-restorer/src/pnp.rspnpm/crates/deps-restorer/src/prune_direct_deps.rspnpm/crates/deps-restorer/src/prune_direct_deps/tests.rspnpm/crates/deps-restorer/src/prune_stale_modules.rspnpm/crates/deps-restorer/src/remove_quarantine.rspnpm/crates/deps-restorer/src/remove_quarantine/tests.rspnpm/crates/deps-restorer/src/retry_config.rspnpm/crates/deps-restorer/src/safe_join_modules_dir.rspnpm/crates/deps-restorer/src/safe_join_modules_dir/tests.rspnpm/crates/deps-restorer/src/store_init.rspnpm/crates/deps-restorer/src/symlink_direct_dependencies.rspnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rspnpm/crates/deps-restorer/src/symlink_package.rspnpm/crates/deps-restorer/src/validate_lockfile_paths.rspnpm/crates/deps-restorer/src/validate_lockfile_paths/tests.rspnpm/crates/deps-restorer/src/version_policy.rspnpm/crates/deps-restorer/src/virtual_store_layout.rspnpm/crates/deps-restorer/src/virtual_store_layout/tests.rspnpm/crates/package-manager/Cargo.tomlpnpm/crates/package-manager/src/lib.rspnpm/plans/TEST_PORTING.md
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/plans/TEST_PORTING.md
- pnpm/crates/cli/tests/multiple_importers.rs
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/deps-restorer/src/hoist.rs (1)
65-70: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winJustify the wider API surface and document
build_hoist_graph_with_max_length.
compute_hoist_plancalls this internally, andpacquet/package-managerdepends onpacquet-deps-restorerwithout importing the helper itself. Keep the helper private tocrate::hoistor mark it as a deliberate extraction API. If it remainspub, add rustdoc that states the degraded behavior for missing metadata and howvirtual_store_dir_max_lengthaffectssort_keyordering.🤖 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/hoist.rs` around lines 65 - 70, The public build_hoist_graph_with_max_length API needs justification and documentation. Prefer making build_hoist_graph_with_max_length private to crate::hoist if external callers do not require it; otherwise add rustdoc describing degraded behavior when metadata is missing and how virtual_store_dir_max_length influences sort_key ordering.Source: Coding guidelines
🧹 Nitpick comments (7)
pnpm/crates/deps-restorer/src/install_package_from_registry/tests.rs (2)
396-397: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert a symlink, not mere existence, for the second-visit link.
Path::existsfollows the link and also returnstruefor a real directory. The assertion therefore does not prove the second visit created the per-parent symlink. Use the same helper the sibling tests use.💚 Suggested assertion
let symlink_path = second_parent_dir.path().join("second-alias"); - assert!(symlink_path.exists() || symlink_path.is_symlink(), "per-parent symlink missing"); + assert!( + pacquet_testing_utils::fs::is_symlink_or_junction(&symlink_path) + .expect("inspect per-parent link"), + "per-parent symlink missing at {symlink_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/deps-restorer/src/install_package_from_registry/tests.rs` around lines 396 - 397, Update the assertion for second-alias in the relevant install-package test to use the existing symlink-specific helper used by sibling tests, ensuring it verifies the path is actually a symlink rather than merely an existing directory.
27-178: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBuild the test
ConfigfromConfig::new()instead of a full struct literal.
create_confignames about 145 fields. Sibling test modules in the same crate build their config fromConfig::new()and override only the fields they care about — seepnpm/crates/deps-restorer/src/create_virtual_store/tests.rslines 114-121 andpnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rslines 55-59. The literal here duplicates the whole config surface, so every newConfigfield breaks this file alone. The#![expect(clippy::default_trait_access)]at the top of the file exists only to support the literal.Rewrite
create_configin the same shape as the sibling modules and drop the file-levelexpect.As per coding guidelines from AGENTS.md "Code Reuse and Avoiding Duplication": before adding code, verify no helper is duplicated elsewhere.
♻️ Suggested shape
fn create_config( store_dir: &Path, modules_dir: &Path, virtual_store_dir: &Path, cache_dir: &Path, ) -> Config { - Config { - versioning: Default::default(), - // ... ~145 fields ... - config_dir: None, - } + let mut config = Config::new(); + config.store_dir = StoreDir::new(store_dir); + config.modules_dir = modules_dir.to_path_buf(); + config.virtual_store_dir = virtual_store_dir.to_path_buf(); + config.global_virtual_store_dir = virtual_store_dir.to_path_buf(); + config.cache_dir = cache_dir.to_path_buf(); + config }Add only the extra overrides the tests actually depend on, such as
registry,verify_store_integrity, andchild_concurrency.🤖 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_package_from_registry/tests.rs` around lines 27 - 178, Replace the full struct literal in create_config with Config::new(), overriding only the test-required fields such as store_dir, modules_dir, virtual_store_dir, cache_dir, registry, verify_store_integrity, and child_concurrency. Match the initialization pattern used by the sibling test modules, and remove the file-level clippy::default_trait_access expectation since it is no longer needed.Source: Path instructions
pnpm/crates/deps-restorer/src/link_file.rs (1)
30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCorrect the stated location of the downgrade statics.
Both comments say the process-global state lives inside
link_file.AUTO_STATEandCLONE_OR_COPY_STATEare declared insidetry_importat lines 210 and 237. Point the comments attry_importso a reader can find the state.📝 Suggested wording
-// These are the state *values*, not the cache itself: each mode keeps -// its own process-global `AtomicU8` (`AUTO_STATE` inside `link_file`, -// `CLONE_OR_COPY_STATE` likewise), so an `Auto` downgrade doesn't -// affect `CloneOrCopy` and vice versa. +// These are the state *values*, not the cache itself: each mode keeps +// its own process-global `AtomicU8` (`AUTO_STATE` and +// `CLONE_OR_COPY_STATE`, both declared inside `try_import`), so an +// `Auto` downgrade doesn't affect `CloneOrCopy` and vice versa.-/// pass their own `AtomicU8` and exercise the downgrade logic in -/// isolation — the production path uses a `static` declared inside -/// [`link_file`]. Only capability / cross-device style failures +/// pass their own `AtomicU8` and exercise the downgrade logic in +/// isolation — the production path uses the `AUTO_STATE` `static` +/// declared inside `try_import`. Only capability / cross-device style failuresAlso applies to: 305-312
🤖 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/link_file.rs` around lines 30 - 34, Update the comments describing AUTO_STATE and CLONE_OR_COPY_STATE to state that each process-global AtomicU8 is declared inside try_import, replacing the incorrect reference to link_file. Apply this correction to both comment blocks while preserving their explanation that the states are independent.pnpm/crates/deps-restorer/src/symlink_direct_dependencies.rs (1)
275-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCollapse the duplicated rustdoc blocks.
Each of these two items carries the contract twice. On
validate_importer_id, lines 275-282 describe rejecting keys that resolve outside the workspace root, and lines 283-288 restate the same rule with the same rejected shapes. Onimporter_root_dir, lines 377-383 explain the"."root key and POSIX resolution, and lines 384-385 restate the return value. Keep one statement of each contract.As per coding guidelines: "Use rustdoc comments for public API contracts... Do not duplicate test behavior in documentation; comments should explain only non-obvious reasons or invariants." pnpm/CODE_STYLE_GUIDE.md adds: "Do not repeat what the code already says."
📝 Suggested consolidation
/// Reject importer keys that would resolve outside the workspace root. /// /// Pnpm's lockfile spec writes importer keys as POSIX paths relative /// to the workspace root (`.` for the root, `packages/web` for a /// subproject). Anything else — an absolute POSIX path, a Windows -/// drive prefix, a `..` segment — is either malformed or hostile, so -/// surface it as a typed error rather than silently letting -/// `Path::join` produce an off-workspace path. -/// Reject a lockfile importer key that cannot be safely joined onto the -/// lockfile dir: absolute paths, Windows drive prefixes, backslash -/// separators, and `..` traversal segments. `.` (the root importer) and any -/// ordinary POSIX-relative sub-path are accepted. Callers that turn an -/// importer key into an on-disk path — via [`importer_root_dir`] — must run -/// this first when the key comes from an untrusted lockfile. +/// drive prefix, a backslash separator, a `..` segment — is either +/// malformed or hostile, so surface it as a typed error rather than +/// silently letting `Path::join` produce an off-workspace path. +/// +/// Callers that turn an importer key into an on-disk path — via +/// [`importer_root_dir`] — must run this first when the key comes from +/// an untrusted lockfile. pub fn validate_importer_id(importer_id: &str) -> Result<(), SymlinkDirectDependenciesError> {/// Resolve `importer_id` (a lockfile key) against the workspace root. /// /// Pnpm's lockfile spec uses `"."` for the root importer and /// forward-slash POSIX paths for sub-importers. Mirroring that here /// keeps lockfiles written by pacquet and pnpm interchangeable. The /// returned path is platform-native (`Path::join` handles the /// conversion on Windows). -/// The on-disk root of the project a lockfile importer ID names, relative -/// to `workspace_root` (which is normally the lockfile directory). #[must_use]Also applies to: 377-386
🤖 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/symlink_direct_dependencies.rs` around lines 275 - 288, Collapse the duplicated rustdoc comments for validate_importer_id and importer_root_dir into one concise contract per public function. Retain only the non-obvious importer-key safety invariant and the "." root/POSIX-relative path behavior; remove repeated descriptions of rejected shapes and return values without changing implementation behavior.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-restorer/src/create_virtual_store/tests.rs (1)
99-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the tolerant skip in
cold_batch_links_slots_in_parallel.The test returns early when rayon reports fewer than two threads. The concurrency assertion then never runs, and the environment problem stays invisible. Let the test fail instead, or force a two-thread rayon pool for this test so the assertion always runs.
As per coding guidelines: "Tests must not silently return early when required tools such as
git,node, ornpmare unavailable; let the test fail." pnpm/AGENTS.md states the same: "If a test cannot run without a tool, let it panic rather than silently skipping. The environment must be fixed, not the test."🤖 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/tests.rs` around lines 99 - 105, Remove the early-return guard based on rayon::current_num_threads() from cold_batch_links_slots_in_parallel so the concurrency assertion always executes. Let the test fail naturally when insufficient rayon threads are available, without silently skipping the assertion.Sources: Coding guidelines, Path instructions
pnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rs (1)
40-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider sharing the recording reporter as a crate helper.
This file repeats the same
static EVENTSplusRecordingReporterpattern five times. If the crate-level tests module is the intended boundary, put the helper once there and call it from these tests instead of duplicating it in each case.🤖 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/symlink_direct_dependencies/tests.rs` around lines 40 - 48, Move the duplicated EVENTS static and RecordingReporter implementation from the individual tests into the crate-level tests module as a shared helper. Update each affected test in the symlink direct-dependencies test module to reuse that helper while preserving the existing event-clearing and recording behavior.Source: Learnings
pnpm/crates/deps-restorer/src/link_hoisted_modules/tests.rs (1)
140-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the
removedstats payload and the orphan-confinement refusal.Two behaviors of
link_hoisted_modulesstay untested in this file:
link_hoisted_modulesemitspnpm:statsRemoved { prefix, removed }on every run (link_hoisted_modules.rslines 137-140). Every test here usesSilentReporter, so the count and prefix are never asserted. The coding guidelines require recording-fake coverage for reporter events. Sibling test files already define a recording reporter you can reuse.remove_orphansrefuses an orphan directory that is not lexically insideconfine_root(link_hoisted_modules.rslines 172-183). No test drives that branch. Add a case with aprev_graphentry outsideconfine_rootand assert the directory survives.As per coding guidelines: "Reporter
pnpm:<channel>events emitted by Rust code must match the TypeScript implementation in call site, payload, ordering, channel mapping, and recording-fake test coverage."🤖 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/link_hoisted_modules/tests.rs` around lines 140 - 180, Extend the tests around link_hoisted_modules to use the existing recording reporter and assert each run emits the pnpm:stats Removed event with the expected prefix and removal count. Add coverage for remove_orphans using a prev_graph entry whose directory is outside confine_root, and assert that directory remains intact after linking. Preserve the existing orphan removal assertions for paths within the confinement root.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/create_symlink_layout/tests.rs`:
- Around line 24-34: Update the symlink assertions in the test, including the
additional assertion block around the referenced lines, to use
pacquet_fs::read_symlink_dir instead of std::fs::read_link so junctions work on
Windows. Preserve the existing expected relative-target comparisons and
assertion behavior.
In `@pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs`:
- Line 393: Make both permission-error tests deterministic by adding a narrow
Host/Sys filesystem capability seam and injecting errors instead of relying on
mode bits: in pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs:393-393,
preserve node_modules then inject PermissionDenied from remove_dir_all; in
pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs:458-458, inject
PermissionDenied from symlink_metadata for target/node_modules. Update the
relevant test setup and Host/Sys implementations while keeping the production
filesystem behavior unchanged.
In `@pnpm/crates/deps-restorer/src/link_bins.rs`:
- Around line 684-687: Update the documentation near the fallback path in
`link_bins.rs` to remove or correct the unresolved
`crate::InstallWithFreshLockfile` link, using plain prose consistent with the
surrounding comment unless a valid import or re-export is intentionally added.
Ensure the resulting documentation resolves successfully in `cargo doc`.
In `@pnpm/crates/deps-restorer/src/prune_direct_deps/tests.rs`:
- Around line 292-293: Rename the test function
prune_direct_deps_respects_trusted_importer_allow_set to reflect that it
exercises prunable_importer_ids, not trusted_importer_ids. Add the short
rationale comment used by the sibling tests explaining this set is unrelated to
trusted importer validation.
---
Outside diff comments:
In `@pnpm/crates/deps-restorer/src/hoist.rs`:
- Around line 65-70: The public build_hoist_graph_with_max_length API needs
justification and documentation. Prefer making build_hoist_graph_with_max_length
private to crate::hoist if external callers do not require it; otherwise add
rustdoc describing degraded behavior when metadata is missing and how
virtual_store_dir_max_length influences sort_key ordering.
---
Nitpick comments:
In `@pnpm/crates/deps-restorer/src/create_virtual_store/tests.rs`:
- Around line 99-105: Remove the early-return guard based on
rayon::current_num_threads() from cold_batch_links_slots_in_parallel so the
concurrency assertion always executes. Let the test fail naturally when
insufficient rayon threads are available, without silently skipping the
assertion.
In `@pnpm/crates/deps-restorer/src/install_package_from_registry/tests.rs`:
- Around line 396-397: Update the assertion for second-alias in the relevant
install-package test to use the existing symlink-specific helper used by sibling
tests, ensuring it verifies the path is actually a symlink rather than merely an
existing directory.
- Around line 27-178: Replace the full struct literal in create_config with
Config::new(), overriding only the test-required fields such as store_dir,
modules_dir, virtual_store_dir, cache_dir, registry, verify_store_integrity, and
child_concurrency. Match the initialization pattern used by the sibling test
modules, and remove the file-level clippy::default_trait_access expectation
since it is no longer needed.
In `@pnpm/crates/deps-restorer/src/link_file.rs`:
- Around line 30-34: Update the comments describing AUTO_STATE and
CLONE_OR_COPY_STATE to state that each process-global AtomicU8 is declared
inside try_import, replacing the incorrect reference to link_file. Apply this
correction to both comment blocks while preserving their explanation that the
states are independent.
In `@pnpm/crates/deps-restorer/src/link_hoisted_modules/tests.rs`:
- Around line 140-180: Extend the tests around link_hoisted_modules to use the
existing recording reporter and assert each run emits the pnpm:stats Removed
event with the expected prefix and removal count. Add coverage for
remove_orphans using a prev_graph entry whose directory is outside confine_root,
and assert that directory remains intact after linking. Preserve the existing
orphan removal assertions for paths within the confinement root.
In `@pnpm/crates/deps-restorer/src/symlink_direct_dependencies.rs`:
- Around line 275-288: Collapse the duplicated rustdoc comments for
validate_importer_id and importer_root_dir into one concise contract per public
function. Retain only the non-obvious importer-key safety invariant and the "."
root/POSIX-relative path behavior; remove repeated descriptions of rejected
shapes and return values without changing implementation behavior.
In `@pnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rs`:
- Around line 40-48: Move the duplicated EVENTS static and RecordingReporter
implementation from the individual tests into the crate-level tests module as a
shared helper. Update each affected test in the symlink direct-dependencies test
module to reuse that helper while preserving the existing event-clearing and
recording behavior.
🪄 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: 12a0ff75-36d2-420f-af2e-2afd6eaf6f10
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (67)
Cargo.tomlpnpm/crates/cli/tests/multiple_importers.rspnpm/crates/deps-restorer/Cargo.tomlpnpm/crates/deps-restorer/src/build_modules.rspnpm/crates/deps-restorer/src/build_modules/tests.rspnpm/crates/deps-restorer/src/build_sequence.rspnpm/crates/deps-restorer/src/build_sequence/tests.rspnpm/crates/deps-restorer/src/create_symlink_layout.rspnpm/crates/deps-restorer/src/create_symlink_layout/tests.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/tests.rspnpm/crates/deps-restorer/src/current_lockfile.rspnpm/crates/deps-restorer/src/current_lockfile/tests.rspnpm/crates/deps-restorer/src/deps_graph.rspnpm/crates/deps-restorer/src/deps_graph/tests.rspnpm/crates/deps-restorer/src/graph_sequencer.rspnpm/crates/deps-restorer/src/graph_sequencer/tests.rspnpm/crates/deps-restorer/src/hoist.rspnpm/crates/deps-restorer/src/hoist/tests.rspnpm/crates/deps-restorer/src/hoisted_dep_graph.rspnpm/crates/deps-restorer/src/hoisted_dep_graph/tests.rspnpm/crates/deps-restorer/src/hoisting_limits.rspnpm/crates/deps-restorer/src/hoisting_limits/tests.rspnpm/crates/deps-restorer/src/import_indexed_dir.rspnpm/crates/deps-restorer/src/import_indexed_dir/tests.rspnpm/crates/deps-restorer/src/install_frozen_lockfile.rspnpm/crates/deps-restorer/src/install_frozen_lockfile/tests.rspnpm/crates/deps-restorer/src/install_package_by_snapshot.rspnpm/crates/deps-restorer/src/install_package_by_snapshot/tests.rspnpm/crates/deps-restorer/src/install_package_from_registry.rspnpm/crates/deps-restorer/src/install_package_from_registry/tests.rspnpm/crates/deps-restorer/src/installability.rspnpm/crates/deps-restorer/src/installability/tests.rspnpm/crates/deps-restorer/src/lib.rspnpm/crates/deps-restorer/src/link_bins.rspnpm/crates/deps-restorer/src/link_bins/tests.rspnpm/crates/deps-restorer/src/link_file.rspnpm/crates/deps-restorer/src/link_file/tests.rspnpm/crates/deps-restorer/src/link_hoisted_modules.rspnpm/crates/deps-restorer/src/link_hoisted_modules/tests.rspnpm/crates/deps-restorer/src/link_root_component_members.rspnpm/crates/deps-restorer/src/link_root_component_members/tests.rspnpm/crates/deps-restorer/src/package_map.rspnpm/crates/deps-restorer/src/package_map/tests.rspnpm/crates/deps-restorer/src/pnp.rspnpm/crates/deps-restorer/src/prune_direct_deps.rspnpm/crates/deps-restorer/src/prune_direct_deps/tests.rspnpm/crates/deps-restorer/src/prune_stale_modules.rspnpm/crates/deps-restorer/src/remove_quarantine.rspnpm/crates/deps-restorer/src/remove_quarantine/tests.rspnpm/crates/deps-restorer/src/retry_config.rspnpm/crates/deps-restorer/src/safe_join_modules_dir.rspnpm/crates/deps-restorer/src/safe_join_modules_dir/tests.rspnpm/crates/deps-restorer/src/store_init.rspnpm/crates/deps-restorer/src/symlink_direct_dependencies.rspnpm/crates/deps-restorer/src/symlink_direct_dependencies/tests.rspnpm/crates/deps-restorer/src/symlink_package.rspnpm/crates/deps-restorer/src/validate_lockfile_paths.rspnpm/crates/deps-restorer/src/validate_lockfile_paths/tests.rspnpm/crates/deps-restorer/src/version_policy.rspnpm/crates/deps-restorer/src/virtual_store_layout.rspnpm/crates/deps-restorer/src/virtual_store_layout/tests.rspnpm/crates/package-manager/Cargo.tomlpnpm/crates/package-manager/src/lib.rspnpm/plans/TEST_PORTING.md
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/plans/TEST_PORTING.md
- pnpm/crates/cli/tests/multiple_importers.rs
🛑 Comments failed to post (3)
pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs (1)
24-34: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail # Locate and inspect the internal symlink implementations. rg -n -C 8 \ 'fn (force_symlink_dir|symlink_dir)\b|junction|read_link' \ pnpm/crates \ --type rust # Locate Windows CI coverage for this crate. rg -n -C 4 \ 'windows|deps-restorer|cargo nextest|cargo test' \ .github pnpm \ -g '*.yml' -g '*.yaml' -g '*.toml'Repository: pnpm/pnpm
Length of output: 139
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== files ==" git ls-files 'pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs' 'pnpm/crates/*fs*' | sed -n '1,120p' echo "== create_symlink_layout tests relevant ==" if [ -f pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs ]; then wc -l pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs sed -n '1,80p;210,250p' pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs fi echo "== force_symlink_dir/read_link search focused ==" rg -n -C 6 'force_symlink_dir|symlink_dir|read_link|junction' pnpm/crates --type rust | sed -n '1,260p' echo "== CI package/test mentions ==" rg -n -C 3 'deps-restorer|create_symlink_layout|package-manager|cargo nextest|cargo test' .github pnpm -g '*.yml' -g '*.yaml' -g '*.toml' | sed -n '1,260p'Repository: pnpm/pnpm
Length of output: 139
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== git status ==" git status --short | sed -n '1,80p' || true echo "== files ==" git ls-files 'pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs' 'pnpm/crates/*fs*' 'pnpm/crates/registry-mock' | sed -n '1,200p' || true echo "== locate symlink funcs ==" rg -n -C 6 'force_symlink_dir|symlink_dir|junction|read_link' pnpm/crates --type rust 2>/dev/null | sed -n '1,240p' || true echo "== locate target test ==" rg -n -C 6 'read_link|target_path|pathdiff|create_symlink_layout' pnpm/crates/deps-restorer/src/create_symlink_layout/tests.rs pnpm/crates/deps-restorer/src --type rust 2>/dev/null | sed -n '1,260p' || trueRepository: pnpm/pnpm
Length of output: 47859
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== fs lib exports ==" sed -n '1,140p' pnpm/crates/fs/src/lib.rs echo "== symlink_dir implementation ==" sed -n '1,260p' pnpm/crates/fs/src/symlink_dir.rs echo "== tests around raw read assertions ==" sed -n '220,270p' pnpm/crates/fs/src/symlink_dir/tests.rs || true rg -n -C 6 'read_link|junction|force_symlink_dir|symlink_dir' pnpm/crates/fs/src/symlink_dir/tests.rs pnpm/crates/fs/src --type rust | sed -n '1,220p'Repository: pnpm/pnpm
Length of output: 32576
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== windows module ==" sed -n '1,260p' pnpm/crates/fs/src/symlink_dir.rs.windows 2>/dev/null || rg -n -C 8 'mod windows|create_junction|windows::create' pnpm/crates/fs/src/symlink_dir.rs pnpm/crates/fs/src --type rust | sed -n '1,260p' rg -n -C 6 'create_junction|junction::create|symlink_dir' pnpm/crates/fs/src/symlink_dir.rs pnpm/crates/fs/src --type rust | sed -n '1,260p' echo "== create_symlink_layout caller ==" rg -n -C 8 'force_symlink_dir|symlink_dir|read_link_dir|read_symlink_dir|create_directory_symlink|create_directory_hardlink' pnpm/crates/deps-restorer/src/create_symlink_layout.rs pnpm/crates/deps-restorer/src --type rust | sed -n '1,260p'Repository: pnpm/pnpm
Length of output: 50365
Use the Windows-aware symlink reader for
read_linkassertions.
create_symlink_layoutcan produce junctions on Windows, andstd::fs::read_linkfails withInvalidInputfor junctions. These raw assertions should usepacquet_fs::read_symlink_diror resolve paths on Windows so the tests pass on the junction fallback path.Also applies to: 227-237
🤖 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_symlink_layout/tests.rs` around lines 24 - 34, Update the symlink assertions in the test, including the additional assertion block around the referenced lines, to use pacquet_fs::read_symlink_dir instead of std::fs::read_link so junctions work on Windows. Preserve the existing expected relative-target comparisons and assertion behavior.pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs (1)
393-393: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Make the permission-error tests deterministic.
Mode bits do not force
PermissionDeniedfor a privileged test process. Both tests can reach the success path and fail atexpect_err. Add a narrowHost/Sysfilesystem seam and inject the required errors.
pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs#L393-L393: injectPermissionDeniedfromremove_dir_allafter preservingnode_modules.pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs#L458-L458: injectPermissionDeniedfromsymlink_metadatafortarget/node_modules.As per coding guidelines, use dependency injection through
Host/Syscapability traits for filesystem error branches that real fixtures cannot portably reach.📍 Affects 1 file
pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs#L393-L393(this comment)pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs#L458-L458🤖 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/import_indexed_dir/tests.rs` at line 393, Make both permission-error tests deterministic by adding a narrow Host/Sys filesystem capability seam and injecting errors instead of relying on mode bits: in pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs:393-393, preserve node_modules then inject PermissionDenied from remove_dir_all; in pnpm/crates/deps-restorer/src/import_indexed_dir/tests.rs:458-458, inject PermissionDenied from symlink_metadata for target/node_modules. Update the relevant test setup and Host/Sys implementations while keeping the production filesystem behavior unchanged.Source: Coding guidelines
pnpm/crates/deps-restorer/src/prune_direct_deps/tests.rs (1)
292-293: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Rename the test: it does not exercise
trusted_importer_ids.The test name says
trusted_importer_allow_set, but the argument it passes isprunable_importer_ids.prune_direct_deps.rslines 77-80 state that this set is unrelated tocrate::SymlinkDirectDependencies::trusted_importer_ids, which names importers allowed to skip ID validation. The current name asserts the opposite contract. Rename it to match the parameter, and add the short rationale comment the sibling tests carry.✏️ Proposed rename
+/// `prunable_importer_ids` narrows removal to the importers a filtered +/// install re-materialized; every other importer's links stay. #[test] -fn prune_direct_deps_respects_trusted_importer_allow_set() { +fn prune_direct_deps_only_touches_prunable_importer_ids() {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements./// `prunable_importer_ids` narrows removal to the importers a filtered /// install re-materialized; every other importer's links stay. #[test] fn prune_direct_deps_only_touches_prunable_importer_ids() {🤖 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/prune_direct_deps/tests.rs` around lines 292 - 293, Rename the test function prune_direct_deps_respects_trusted_importer_allow_set to reflect that it exercises prunable_importer_ids, not trusted_importer_ids. Add the short rationale comment used by the sibling tests explaining this set is unrelated to trusted importer validation.
Main renamed pnpm/crates/package-manager/src/install_package_from_registry/tests.rs into the new deps-restorer crate (#13637). The branch's added config_warnings field initializer in create_config follows the file to its new home at pnpm/crates/deps-restorer/src/install_package_from_registry/tests.rs.
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
Extract the Rust headless installation pipeline from
pacquet-package-managerinto one new internalpacquet-deps-restorercrate, matching the responsibility boundary used by the TypeScript implementation.The supporting materialization, linking, build, and lockfile helpers move with the installer so the new crate does not depend back on
pacquet-package-manager. The package-manager crate consumes and re-exports the restorer API, preserving existing call sites without duplicating implementations or changing install behavior.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.Written by an agent (Codex, GPT-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Bug Fixes
Tests