Skip to content

refactor(resolving-deps-resolver): split resolve_dependency_tree into focused modules - #13562

Merged
zkochan merged 5 commits into
mainfrom
fix-13554
Aug 1, 2026
Merged

zkochan merged 5 commits into
mainfrom
fix-13554

Conversation

@zkochan

@zkochan zkochan commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Summary

resolve_dependency_tree.rs was 4,037 lines — the largest file in
resolving-deps-resolver and the same shape resolve_peers.rs was in before
#13551. It combined the public options/error types, the shared
workspace context, the per-importer tree context, the recursive walk, node
reuse and children-ownership bookkeeping, lockfile-snapshot reuse checks,
catalog specifier resolution, and manifest extraction.

Same pattern as #13551: the file stays as the facade and the
implementation moves under resolve_dependency_tree/.

file lines holds
resolve_dependency_tree.rs 616 entry points, options / error / notification types
workspace_ctx.rs 948 WorkspaceTreeCtx, the shared dedup maps, children-ownership claim/handover
walk.rs 1,125 the fresh-resolve walk: seed, children walk, per-wanted resolve cache, level folds
reuse.rs 753 ReuseSource, the update scope, direct-dep change bookkeeping, subtree-reuse predicates, snapshot-driven walk
tree_ctx.rs 402 TreeCtx and the per-edge ResolveOptions derivations
manifest.rs 378 pkg id, child specs, peers, leaf classification, deprecation
catalogs.rs 43 catalog: specifier resolution

The boundaries follow the dependency graph rather than the line ranges the
issue sketched. Two deviations worth calling out: the importer direct-dep
bookkeeping (record_changed_direct_deps, record_direct_dep_versions,
higher_direct_dep_version) went to reuse.rs because it exists only to feed
the reuse gates, and build_pkg_id_with_patch_hash went to manifest.rs
because it derives the id from name_ver / the manifest.

Invariants

  • No user-visible behavior change. Pure code movement — no behavior,
    allocation, cloning, dispatch, or traversal change. Release builds use
    lto = "fat" with codegen-units = 1, so the module boundaries cannot shift
    inlining either.
  • No public API change. TreeCtx and WorkspaceTreeCtx stay one struct
    each with their inherent impls divided across modules; cross-module items are
    pub(super), so they stay private to resolve_dependency_tree. No
    pub/pub(crate) item was widened.
  • The pub(super) surface was derived mechanically, as refactor(resolving-deps-resolver): split resolve_peers into focused modules #13551
    recommended: every marker was stripped and the compiler re-added only the
    ones the crate cannot compile without (59 → 25 → 6 → 0 names over three
    rounds).

Proof of movement

No implementation line changed. Comparing the multiset of executable source
lines before and after — normalizing away imports, module declarations,
visibility markers and comments — the only differences are:

  • eleven signatures rustfmt re-wrapped because pub(super) pushed them past
    the width, and
  • the one deliberate code change, which is test-only and in its own commit: the
    engines-runtime fixture now calls test_support::manifest_result instead of
    repeating a ResolveResult literal identical to it in every field but the
    manifest.

Every one of the 46 test functions is preserved; only their module paths
changed. No stranded doc comments turned up this time (#13551 had two).

Comments

The only new prose is one //! per new module, in the shape #13551
established — a module has no name or signature to carry its contract. Two
first drafts were dropped again for restating documentation that already
exists: the facade's //! (the crate-level docs in lib.rs already describe
the tree pass, and rustdoc renders the module index with each submodule's own
first line, so the module tour paraphrased the thing directly below it), and a
paragraph in reuse.rs that inventoried which functions live there.

Co-locating each test with the item it exercises — they used to sit up to
~3,200 lines apart — also exposed six pre-existing doc comments that walk
through scenarios the tests below now state by name. Those are trimmed to the
contract plus the non-obvious why (34 net lines), since tests are the
documentation for behavior and prose repeating them reads as missing coverage.
The clearest case: is_update_target enumerated four outcomes that the ten
tests in mod is_update_target each name outright. Details in the commit.

Everything else is moved verbatim.

Intra-doc links

Twenty-three doc links broke where the item they name moved into a sibling
module. They are repointed with reference-style link definitions, so the prose
lines stay unchanged. Three named a helper that is private to another module
and so is not nameable from a sibling at all (walk::fallback_manifest,
walk::overlay_lookup_names, reuse::subtree_fully_reusable); those became
plain code spans rather than widening the helpers' visibility for a link.

Worth flagging for a separate fix: only Rust CI / Doc catches this class of
breakage, because it passes --document-private-items. The pre-push hook runs
cargo doc --no-deps --workspace --all-features without that flag, so it cannot
see a broken link on a private item — the divergence is why this surfaced in CI
rather than locally.

Tests

Unit tests that drive one module's internals moved next to it
(workspace_ctx/tests.rs, walk/tests.rs, reuse/tests.rs,
manifest/tests.rs), with the shared ResolveResult builder lifted into a
test_support module. The end-to-end tree-walk test stays at the facade.

just ready passes: 7,541 tests, 0 failures. cargo doc was re-run with
target/doc cleared so the intra-doc-link check was not served from cache.

Closes #13554.

Squash Commit Body

resolve_dependency_tree.rs carried the public options/error types, the shared
workspace context, the per-importer tree context, the recursive walk, node
reuse and children-ownership bookkeeping, lockfile-snapshot reuse checks,
catalog specifier resolution, and manifest extraction in one 4,037-line file.

Keep resolve_dependency_tree.rs as the facade holding the options, error, and
notification types plus the two entry points, and move the implementation into
resolve_dependency_tree/: workspace_ctx.rs (WorkspaceTreeCtx, the shared
per-pkgIdWithPatchHash dedup maps, and the children-ownership claim/handover),
tree_ctx.rs (TreeCtx and the per-edge ResolveOptions derivations), walk.rs (the
fresh-resolve walk — seed, children walk, per-wanted resolve cache, level
folds), reuse.rs (ReuseSource, the update scope, direct-dep change bookkeeping,
subtree-reuse predicates, and the snapshot-driven walk), manifest.rs (what the
walk reads off a resolved package: pkg id, child specs, peers, leaf
classification, deprecation), and catalogs.rs (catalog: specifier resolution).

TreeCtx and WorkspaceTreeCtx stay one struct each; their inherent impls are
divided across the modules with pub(super) visibility, so every cross-module
item stays private to resolve_dependency_tree and the crate's public API is
unchanged. The pub(super) surface was derived mechanically: every marker was
stripped and the compiler re-added only the ones the crate cannot compile
without. The unit tests that drive one module's internals move next to it, with
the shared result builder lifted into a test_support module; the end-to-end
tree-walk tests stay at the facade.

Pure code movement: no behavior, allocation, cloning, dispatch, or traversal
change. After normalizing away imports, module declarations, visibility
markers, and reference-style doc links, the multiset of source lines before and
after differs only by the eleven signatures rustfmt re-wrapped because
pub(super) pushed them past the width.

Closes pnpm/pnpm#13554.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    (pacquet-only internal module reorganization — no user-visible surface and
    no TypeScript counterpart, as the issue states.)
  • Added or updated tests. (No new tests: pure code movement. All 46
    existing tests are preserved and moved next to the module they exercise.)

Written by an agent (Claude Code, claude-opus-5[1m]).

Summary by CodeRabbit

  • New Features

    • Improved dependency resolution across workspaces, catalogs, lockfiles, aliases, patches, optional dependencies, peer dependencies, and bundled packages.
    • Added reuse of unchanged dependency-tree sections to speed up updates.
    • Improved handling of file, link, workspace, and other dependency sources.
    • Added more consistent package metadata, deprecation notices, snapshots, and fallback manifests.
  • Bug Fixes

    • Improved cycle detection, dependency ownership, stale lockfile refreshes, and optional dependency handling.
  • Tests

    • Expanded coverage for workspace traversal, dependency reuse, aliases, patches, manifests, and update depth limits.

… focused modules

resolve_dependency_tree.rs carried the public options/error types, the shared
workspace context, the per-importer tree context, the recursive walk, node
reuse and children-ownership bookkeeping, lockfile-snapshot reuse checks,
catalog specifier resolution, and manifest extraction in one 4,037-line file.

Keep resolve_dependency_tree.rs as the facade holding the options, error, and
notification types plus the two entry points, and move the implementation into
resolve_dependency_tree/: workspace_ctx.rs (WorkspaceTreeCtx, the shared
per-pkgIdWithPatchHash dedup maps, and the children-ownership claim/handover),
tree_ctx.rs (TreeCtx and the per-edge ResolveOptions derivations), walk.rs (the
fresh-resolve walk — seed, children walk, per-wanted resolve cache, level
folds), reuse.rs (ReuseSource, the update scope, direct-dep change bookkeeping,
subtree-reuse predicates, and the snapshot-driven walk), manifest.rs (what the
walk reads off a resolved package: pkg id, child specs, peers, leaf
classification, deprecation), and catalogs.rs (catalog: specifier resolution).

TreeCtx and WorkspaceTreeCtx stay one struct each; their inherent impls are
divided across the modules with pub(super) visibility, so every cross-module
item stays private to resolve_dependency_tree and the crate's public API is
unchanged. The pub(super) surface was derived mechanically: every marker was
stripped and the compiler re-added only the ones the crate cannot compile
without. The unit tests that drive one module's internals move next to it, with
the shared result builder lifted into a test_support module; the end-to-end
tree-walk tests stay at the facade.

Pure code movement: no behavior, allocation, cloning, dispatch, or traversal
change. After normalizing away imports, module declarations, visibility
markers, and reference-style doc links, the multiset of source lines before and
after differs only by the eleven signatures rustfmt re-wrapped because
pub(super) pushed them past the width.

Closes #13554.
Copilot AI review requested due to automatic review settings August 1, 2026 15:31
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9cd406fb-afc0-477c-8f06-b5dd3aa8949e

📥 Commits

Reviewing files that changed from the base of the PR and between b1bbb42 and dc4fd25.

📒 Files selected for processing (4)
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs

📝 Walkthrough

Walkthrough

The monolithic dependency-tree resolver is now a facade over focused modules for workspace state, per-importer context, manifest processing, catalog resolution, fresh walking, and lockfile reuse. Module-specific tests cover the extracted behavior.

Changes

Dependency tree resolver

Layer / File(s) Summary
Facade and resolver contexts
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs
The facade wires internal modules and re-exports resolver APIs. TreeCtx and WorkspaceTreeCtx manage resolution options, hooks, shared state, snapshots, and preferred versions.
Shared workspace state and ownership
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs
Workspace state handles synchronization, snapshots, ownership claims, peer records, occurrence indexing, lazy children, and update-related configuration.
Manifest and catalog processing
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/catalogs.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/test_support.rs
Focused helpers resolve catalog specifiers, construct package identities, extract dependency metadata, classify leaves, emit deprecations, and identify exotic sources.
Fresh dependency-tree walking
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk/tests.rs
Fresh resolution handles node seeding, cached resolution, child traversal, hooks, cycles, peers, aliases, fallback manifests, and tree insertion.
Lockfile subtree reuse
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs, pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse/tests.rs
Reuse logic tracks changed dependencies, validates snapshots, handles aliases and update scopes, and registers reusable subtrees.

Estimated code review effort: 4 (Complex) | ~45 minutes

Assessment against linked issues

Objective Addressed Explanation
Split resolve_dependency_tree.rs into focused internal modules while preserving resolver entry points and behavior [13554] ✅

Possibly related issues

  • [13548] — Both issues split large resolver implementations into focused internal modules while preserving behavior.

Possibly related PRs

  • pnpm/pnpm#13551 — Closely related modularization of dependency-resolution code.
  • pnpm/pnpm#13506 — Directly related to extracted workspace ownership and subtree handling.
  • pnpm/pnpm#13288 — Directly related to extracted lockfile reuse and update-depth logic.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13554

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (5): Last reviewed commit: "docs(resolving-deps-resolver): stop narr..." | Re-trigger Greptile

@qodo-code-review

qodo-code-review Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Previous review results

Review updated until commit dc4fd25 ⚖️ Balanced

Results up to commit b58c2f4 ⚖️ Balanced


No changes from previous review

Results up to commit 83590db ⚖️ Balanced


No changes from previous review

Results up to commit b1bbb42 ⚖️ Balanced


No changes from previous review

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Split resolve_dependency_tree into focused internal modules

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Turn resolve_dependency_tree.rs into a small facade with public types and entry points.
• Move workspace/importer contexts, walk, reuse, and manifest helpers into dedicated submodules.
• Relocate and expand unit tests to module-local tests.rs for better locality.
Diagram

graph TD
  Facade["resolve_dependency_tree.rs"] --> Walk["walk.rs"] --> Manifest["manifest.rs"]
  Facade --> Reuse["reuse.rs"] --> Workspace["workspace_ctx.rs"]
  Walk --> Tree["tree_ctx.rs"] --> Workspace
  Facade --> Catalogs["catalogs.rs"] --> Walk
Loading
High-Level Assessment

Keeping resolve_dependency_tree.rs as the facade and moving implementation under resolve_dependency_tree/ with pub(super) boundaries is the most maintainable split for a previously 4k+ line file. Alternatives like region-marked single-file organization or trait-based splitting would preserve much of the coupling and reduce navigability compared to the current module boundaries.

Files changed (13) +4578 / -4340

Refactor (7) +3796 / -3568
resolve_dependency_tree.rsConvert to facade and wire new internal modules +147/-3568

Convert to facade and wire new internal modules

• Adds module-level documentation, declares new internal submodules, and re-exports key types ('TreeCtx', 'WorkspaceTreeCtx') while keeping entry points/options/errors in place. Removes the bulk of the implementation from this file and routes behavior through the new modules without widening visibility beyond 'resolve_dependency_tree'.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs

catalogs.rsExtract 'catalog:' specifier resolution helpers +43/-0

Extract 'catalog:' specifier resolution helpers

• Introduces a dedicated module to replace 'catalog:' bare specifiers on importer direct dependencies using the catalogs map. Ensures catalog misconfiguration errors surface as 'ResolveDependencyTreeError::CatalogMisconfiguration' rather than a generic resolver-not-supported error.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/catalogs.rs

manifest.rsExtract manifest-derived package helper logic +378/-0

Extract manifest-derived package helper logic

• Moves helper logic for computing 'pkgIdWithPatchHash' (including patch hash application and link path normalization) and for extracting children/peer dependencies, leaf classification, and deprecation payloads. Provides focused APIs consumed by both fresh-walk and reuse paths.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs

reuse.rsExtract lockfile reuse and update-scope bookkeeping +753/-0

Extract lockfile reuse and update-scope bookkeeping

• Moves reuse policy types ('ReuseSource', 'UpdateScope'), subtree reuse predicates, and the snapshot-driven children walk into a standalone module. Also houses importer direct-dep change/version bookkeeping used exclusively to drive reuse gates.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs

tree_ctx.rsExtract per-importer TreeCtx and ResolveOptions derivations +402/-0

Extract per-importer TreeCtx and ResolveOptions derivations

• Introduces the per-importer 'TreeCtx' and associated helpers for deriving depth-specific 'ResolveOptions', project-relative cache scoping, and declaring-manifest-relative resolution for 'file:' children. Clarifies the boundary between per-importer configuration and workspace-shared state.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs

walk.rsExtract the fresh-resolve recursive walk +1125/-0

Extract the fresh-resolve recursive walk

• Moves the main dependency-graph traversal into 'walk.rs', splitting seed resolution and child walking to preserve sibling-level preference folding behavior. Wires in helpers from 'manifest', 'tree_ctx', 'workspace_ctx', 'reuse', and 'catalogs' while maintaining existing traversal semantics.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs

workspace_ctx.rsExtract WorkspaceTreeCtx and shared dedup/ownership state +948/-0

Extract WorkspaceTreeCtx and shared dedup/ownership state

• Moves the workspace-wide maps (per-wanted resolve cache keys, package/children dedup, preferred versions, ownership selection and children rewrite invalidation) into 'WorkspaceTreeCtx'. Adds helper functions for inserting nodes, claiming ownership, and rewriting non-owner nodes to lazy children.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs

Tests (6) +782 / -772
tests.rsAdd unit tests for manifest helpers +134/-0

Add unit tests for manifest helpers

• Adds tests for runtime-engine dependency extraction, bundled dependency filtering semantics, and deprecation payload fallback behavior when 'name_ver' is absent. Uses shared test helpers for consistent 'ResolveResult' construction.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs

tests.rsAdd unit tests for reuse gate helpers +307/-0

Add unit tests for reuse gate helpers

• Adds focused tests for direct-dependency refresh selection ('higher_direct_dep_version') and for parsing the real package name from aliasing specifiers (npm alias forms and jsr folding). Verifies update-target identification behavior stays consistent after refactor.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse/tests.rs

test_support.rsIntroduce shared test helper for manifest-backed ResolveResult +19/-0

Introduce shared test helper for manifest-backed ResolveResult

• Adds a small helper to construct a canonical 'ResolveResult' with a directory resolution and provided manifest JSON. Reduces duplication across the new module-local test suites.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/test_support.rs

tests.rsSlim root test module after moving tests to submodules +2/-772

Slim root test module after moving tests to submodules

• Removes large mixed-scope tests from the root 'tests.rs', leaving a minimal shell. Test coverage is relocated to module-local 'tests.rs' files under 'manifest/', 'walk/', 'reuse/', and 'workspace_ctx/'.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs

tests.rsAdd unit tests for walker utilities +106/-0

Add unit tests for walker utilities

• Adds tests for matching resolved ids against prior snapshot keys (peer/patch suffix stripping) and for fallback manifest naming/version behavior when resolvers omit manifests. Keeps walker regressions close to the implementation.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk/tests.rs

tests.rsAdd unit tests for workspace snapshotting and ownership rewrites +214/-0

Add unit tests for workspace snapshotting and ownership rewrites

• Adds tests for snapshot closure behavior (excluding unrelated nodes and following lazy edges) and for ownership rewrite invalidation via 'children_rewrites'. Validates that shared tree state semantics remain intact after extracting 'WorkspaceTreeCtx'.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs

@github-actions

github-actions Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.01     10.6±0.19ms    35.4 MB/sec    1.00     10.4±0.20ms    35.9 MB/sec
packument/parse                                  1.00     36.1±0.53µs  1837.0 MB/sec    1.00     36.1±0.55µs  1835.4 MB/sec
tarball/download_dependency                      1.00      2.8±0.11ms  1559.1 KB/sec    1.00      2.8±0.13ms  1557.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    162.5±1.36ms 98.4 KElem/sec    1.01    163.6±1.76ms 97.8 KElem/sec

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the pacquet (Rust) dependency-tree resolver by splitting the previously very large resolve_dependency_tree.rs implementation into focused submodules under resolve_dependency_tree/, while keeping the public API and user-visible behavior unchanged.

Changes:

  • Introduces a module layout that separates workspace-shared state (workspace_ctx), per-importer state (tree_ctx), the fresh-resolve walk (walk), lockfile reuse (reuse), manifest-derived logic (manifest), and catalog specifier resolution (catalogs).
  • Moves and rehomes unit tests alongside their corresponding modules, adding shared helpers in test_support.
  • Keeps the facade (resolve_dependency_tree.rs) as the entry-point surface (options/errors/types + entry points), delegating implementation to submodules.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs Facade: entry points, option/error/notification types, module wiring, and shared helpers.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs Workspace-shared context, dedup maps, ownership bookkeeping, and snapshot helpers.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs Workspace context unit tests moved next to implementation.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs Per-importer TreeCtx and per-edge ResolveOptions derivations.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs Fresh dependency-walk implementation and per-wanted caching path.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk/tests.rs Walk-specific unit tests relocated into the walk module.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs Prior-lockfile reuse logic, update scope handling, and snapshot-driven traversal.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse/tests.rs Reuse/update-related unit tests relocated into the reuse module.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs Manifest-driven extraction (children/peers/leaf/deprecation) and pkg-id construction.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs Manifest-related unit tests relocated into the manifest module.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/catalogs.rs catalog: specifier resolution moved into a dedicated helper module.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs Keeps the end-to-end/facade-level tests; removes tests relocated into submodules.
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/test_support.rs Shared test helpers extracted for reuse across module-level tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The `Rust CI / Doc` job runs `cargo doc --document-private-items`, so it
resolves the doc links on private items too — 23 of them broke when the items
they name moved into sibling modules. Neither the local `cargo doc` nor the
pre-push hook passes that flag, so the breakage only surfaced in CI.

Point them at their new homes with reference-style link definitions, keeping
the prose lines unchanged. Three links named a helper that is private to
another module and so is not nameable from a sibling at all
(`walk::fallback_manifest`, `walk::overlay_lookup_names`,
`reuse::subtree_fully_reusable`); those become plain code spans rather than
widening the helpers' visibility for the sake of a link.
@qodo-code-review

qodo-code-review Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to dc4fd25

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
Possible issue
Isolate in-progress reuse calculations

Isolate the provisional cycle-detection markers from the global cache by
tracking the recursion path locally (e.g., using a HashSet passed down the call
stack). Only write to the shared subtree_reusable memoization cache once the
final determination is made.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [457-465]

-    lock_recoverable(&ctx.workspace.subtree_reusable).insert(memo_key.clone(), false);
-    ...
-    lock_recoverable(&ctx.workspace.subtree_reusable).insert(memo_key, reusable);
+    let mut visiting = HashSet::default();
+    subtree_fully_reusable_inner(ctx, lockfile, key, depth, &mut visiting)
 
+...
+
+fn subtree_fully_reusable_inner(
+    ctx: &TreeCtx,
+    lockfile: &pacquet_lockfile::Lockfile,
+    key: &PkgNameVerPeer,
+    depth: i32,
+    visiting: &mut HashSet<SubtreeReuseKey>,
+) -> bool {
+    let scope = ctx.update_scope();
+    let memo_key =
+        (ctx.update_cache_scope(), key.clone(), scope.max_depth.memo_bucket(depth));
+    if let Some(&cached) =
+        lock_recoverable(&ctx.workspace.subtree_reusable).get(&memo_key)
+    {
+        return cached;
+    }
+    if !visiting.insert(memo_key.clone()) {
+        return false;
+    }
+
+    let name = key.name.to_string();
+    let reusable = !update_excludes(scope, &name, depth)
+        && synthesize_reused_result(lockfile, key, &name).is_some()
+        && subtree_children_reusable_inner(
+            ctx,
+            lockfile,
+            key,
+            depth,
+            visiting,
+        );
+
+    visiting.remove(&memo_key);
+    lock_recoverable(&ctx.workspace.subtree_reusable)
+        .insert(memo_key, reusable);
+    reusable
+}
+

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 10

__

Why: This fixes a critical concurrency bug where a temporary false marker in a globally shared cache (ctx.workspace.subtree_reusable) could be read by sibling resolutions, leading to non-deterministic failure of the lockfile reuse mechanism.

High
Honor inherited optional dependency status

Replace wanted.optional.unwrap_or(false) with current_is_optional to properly
handle inherited optionality in error matching.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs [324-329]

 Err(
     err @ (ResolveDependencyTreeError::Resolve(_)
     | ResolveDependencyTreeError::NoMatchingVersion(_)
     | ResolveDependencyTreeError::RegistryResponse(_)
     | ResolveDependencyTreeError::SpecNotSupported { .. }),
-) if wanted.optional.unwrap_or(false) => {
+) if current_is_optional => {

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: Checking current_is_optional correctly handles inherited optionality, preventing transitive required dependencies of optional packages from failing the entire installation.

High
Preserve optionality for reused children

Factor in is_optional_child when passing the optionality flag to resolve_node.
Compute this before the async block to avoid capturing issues and ensure
failures in optional dependencies do not become fatal.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [619-628]

+                let child_is_optional =
+                    current_is_optional || is_optional_child(snapshot, child_alias);
                 resolve_node(
                     ctx,
                     resolver,
                     child_wanted,
                     &next_ancestors,
                     depth + 1,
-                    current_is_optional,
+                    child_is_optional,
                     ReuseSource::Transitive { key: Some(child_key) },
                     parent_pkg_aliases,
                 )

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: This addresses a logical bug where an optional reused dependency might be incorrectly classified as required, potentially causing the entire resolution to fail if it cannot be fetched.

High
  • Update

Previous suggestions

Suggestions up to commit b1bbb42
CategorySuggestion                                                                                                                                    Impact
Possible issue
Skip failures in optional subtrees

Use current_is_optional instead of wanted.optional.unwrap_or(false) to properly
handle failures in optional subtrees.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs [324-329]

 Err(
     err @ (ResolveDependencyTreeError::Resolve(_)
     | ResolveDependencyTreeError::NoMatchingVersion(_)
     | ResolveDependencyTreeError::RegistryResponse(_)
     | ResolveDependencyTreeError::SpecNotSupported { .. }),
-) if wanted.optional.unwrap_or(false) => {
+) if current_is_optional => {
Suggestion importance[1-10]: 9

__

Why: Correctly checking current_is_optional avoids aborting the installation when a required child of an optional parent fails to resolve, fixing a critical bug in optional subtree handling.

High
Preserve reused child optionality

Pass the child's optionality status to WantedDependency.optional and
current_is_optional in resolve_reused_node. This ensures optional children of
reused packages are correctly processed as optional.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [633-658]

 .map(|(child_alias, child_key)| {
+    let child_is_optional = is_optional_child(snapshot, child_alias);
     let child_wanted = WantedDependency {
         alias: Some(child_alias.clone()),
         // The snapshot pins the exact version; carry it as
         // the bare specifier so the per-wanted dedup cache
         // key is stable and a fresh fallback (if reuse were
         // ever disabled) would still target the right pin.
         bare_specifier: Some(child_key.suffix.without_peer().to_string()),
+        optional: Some(child_is_optional),
         ..WantedDependency::default()
     };
     let next_ancestors = Arc::clone(&next_ancestors);
     let child_key = child_key.clone();
     async move {
         resolve_node(
             ctx,
             resolver,
             child_wanted,
             &next_ancestors,
             depth + 1,
-            current_is_optional,
+            current_is_optional || child_is_optional,
             ReuseSource::Transitive { key: Some(child_key) },
             parent_pkg_aliases,
         )
         .await
     }
 })
Suggestion importance[1-10]: 9

__

Why: Failing to propagate child optionality during reuse can cause optional dependencies to incorrectly fail the entire installation if they are unavailable, which violates standard package manager semantics.

High
Isolate in-progress reuse checks

Avoid inserting a provisional false into the globally shared subtree_reusable
cache during recursive traversal. Use a task-local visiting set for cycle
detection and only write finalized results to the global cache.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [478-484]

 if let Some(&cached) = lock_recoverable(&ctx.workspace.subtree_reusable).get(&memo_key) {
     return cached;
 }
-// Provisionally mark non-reusable so a cycle back to `key` resolves to
-// `false` (re-resolve) instead of recursing forever — see the doc above
-// for why `false` rather than `true`.
-lock_recoverable(&ctx.workspace.subtree_reusable).insert(memo_key.clone(), false);
+if !visiting.insert(memo_key.clone()) {
+    return false;
+}
+// Recurse while `memo_key` remains recursion-local. Remove it after
+// computing the result, then publish only the finalized value.
+...
+visiting.remove(&memo_key);
+lock_recoverable(&ctx.workspace.subtree_reusable).insert(memo_key, reusable);
Suggestion importance[1-10]: 9

__

Why: Globally caching a provisional false in a shared map during concurrent traversal introduces a race condition, leading to non-deterministic failure to reuse subtrees.

High
Return the canonical cached result

Return the cached value from resolved_by_wanted instead of the local result.
This guarantees consistency and avoids race conditions in concurrent resolver
executions.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs [912-915]

-lock_recoverable(&ctx.workspace.resolved_by_wanted)
-    .entry(cache_key)
-    .or_insert_with(|| Arc::clone(&result));
+let result = Arc::clone(
+    lock_recoverable(&ctx.workspace.resolved_by_wanted)
+        .entry(cache_key)
+        .or_insert_with(|| Arc::clone(&result)),
+);
 Ok(result)
Suggestion importance[1-10]: 8

__

Why: Returning the canonical cached result ensures consistency across concurrent executions and avoids non-deterministic package graphs due to race conditions.

Medium
Suggestions up to commit 83590db
CategorySuggestion                                                                                                                                    Impact
Possible issue
Honor inherited optional dependency status

Replace wanted.optional.unwrap_or(false) with current_is_optional in the error
matching guard. This properly respects the inherited optional status of the
dependency.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs [325-329]

             err @ (ResolveDependencyTreeError::Resolve(_)
             | ResolveDependencyTreeError::NoMatchingVersion(_)
             | ResolveDependencyTreeError::RegistryResponse(_)
             | ResolveDependencyTreeError::SpecNotSupported { .. }),
-        ) if wanted.optional.unwrap_or(false) => {
+        ) if current_is_optional => {
Suggestion importance[1-10]: 8

__

Why: Using current_is_optional ensures that required sub-dependencies of an optional dependency are correctly treated as optional in the error handling path, preventing them from improperly aborting the installation.

Medium
Preserve reused child optionality

Ensure that a child's optionality from the snapshot is propagated to
resolve_node and the WantedDependency.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [635-664]

 let child_results = child_refs
     .iter()
     .map(|(child_alias, child_key)| {
         let child_wanted = WantedDependency {
             alias: Some(child_alias.clone()),
             bare_specifier: Some(child_key.suffix.without_peer().to_string()),
+            optional: Some(is_optional_child(snapshot, child_alias)),
             ..WantedDependency::default()
         };
         let next_ancestors = Arc::clone(&next_ancestors);
         let child_key = child_key.clone();
+        let child_is_optional =
+            current_is_optional || is_optional_child(snapshot, child_alias);
         async move {
             resolve_node(
                 ctx,
                 resolver,
                 child_wanted,
                 &next_ancestors,
                 depth + 1,
-                current_is_optional,
+                child_is_optional,
                 ReuseSource::Transitive { key: Some(child_key) },
                 parent_pkg_aliases,
             )
             .await
         }
     })
     .pipe(future::try_join_all)
     .await?;
Suggestion importance[1-10]: 8

__

Why: Properly propagating the optional flag prevents spurious resolution failures and ensures accurate lockfile generation.

Medium
Deduplicate reused snapshot children

Deduplicate snapshot children by alias by using a BTreeMap instead of a Vec.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [731-752]

-let mut out: Vec<(String, PkgNameVerPeer)> = Vec::new();
+let mut out: BTreeMap<String, PkgNameVerPeer> = BTreeMap::new();
 for dep_map in [snapshot.dependencies.as_ref(), snapshot.optional_dependencies.as_ref()]
     .into_iter()
     .flatten()
 {
     for (alias, dep_ref) in dep_map {
         let alias_str = match &alias.scope {
             Some(scope) => Cow::Owned(format!("@{scope}/{}", alias.bare)),
             None => Cow::Borrowed(alias.bare.as_str()),
         };
         if peer_dependencies.contains_key(alias_str.as_ref())
             || transitive_peers.contains(alias_str.as_ref())
         {
             continue;
         }
         if let Some(key) = dep_ref.resolve(alias) {
-            out.push((alias_str.into_owned(), key));
+            out.insert(alias_str.into_owned(), key);
         }
     }
 }
-out.sort_by(|a, b| a.0.cmp(&b.0));
-out
+out.into_iter().collect()
Suggestion importance[1-10]: 7

__

Why: Using a BTreeMap deduplicates map entries and prevents bugs in the edge case where the same alias appears in both dependencies and optionalDependencies.

Medium
Suggestions up to commit a09a4ca
CategorySuggestion                                                                                                                                    Impact
Possible issue
Honor inherited optional dependency status

Use current_is_optional instead of wanted.optional to evaluate dependency
resolution failures. This correctly propagates the optional status down the
dependency tree.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs [327-329]

             | ResolveDependencyTreeError::RegistryResponse(_)
             | ResolveDependencyTreeError::SpecNotSupported { .. }),
-        ) if wanted.optional.unwrap_or(false) => {
+        ) if current_is_optional => {
Suggestion importance[1-10]: 9

__

Why: Checking current_is_optional correctly handles sub-dependencies of optional branches, preventing missing transitive optional dependencies from improperly failing the entire installation.

High
Preserve reused child optionality

Propagate the optionality status correctly to reused snapshot children.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs [638-663]

 .map(|(child_alias, child_key)| {
+    let child_is_optional = is_optional_child(snapshot, child_alias);
+    let effective_optional = current_is_optional || child_is_optional;
     let child_wanted = WantedDependency {
         alias: Some(child_alias.clone()),
         // The snapshot pins the exact version; carry it as
         // the bare specifier so the per-wanted dedup cache
         // key is stable and a fresh fallback (if reuse were
         // ever disabled) would still target the right pin.
         bare_specifier: Some(child_key.suffix.without_peer().to_string()),
+        optional: Some(effective_optional),
         ..WantedDependency::default()
     };
     let next_ancestors = Arc::clone(&next_ancestors);
     let child_key = child_key.clone();
     async move {
         resolve_node(
             ctx,
             resolver,
             child_wanted,
             &next_ancestors,
             depth + 1,
-            current_is_optional,
+            effective_optional,
             ReuseSource::Transitive { key: Some(child_key) },
             parent_pkg_aliases,
         )
         .await
     }
 })
Suggestion importance[1-10]: 9

__

Why: This resolves a bug where optional dependencies of reused nodes inherit the required status of their parent, which could incorrectly fail the installation if an optional child is not available.

High
Return the winning cached resolution

Return the actual value stored in the resolved_by_wanted cache rather than the
local result. This guarantees that concurrent cache misses for the same key
yield the exact same shared object.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs [912-916]

     let result = Arc::new(result);
-    lock_recoverable(&ctx.workspace.resolved_by_wanted)
-        .entry(cache_key)
-        .or_insert_with(|| Arc::clone(&result));
-    Ok(result)
+    let cached_result = {
+        let mut cache = lock_recoverable(&ctx.workspace.resolved_by_wanted);
+        Arc::clone(
+            cache
+                .entry(cache_key)
+                .or_insert_with(|| Arc::clone(&result)),
+        )
+    };
+    Ok(cached_result)
Suggestion importance[1-10]: 7

__

Why: Returning the cached entry resulting from or_insert_with prevents concurrent identical resolutions from resulting in multiple, unshared Arc instances and possible subtle state inconsistencies.

Medium
Suggestions up to commit b58c2f4
CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent deadlock by avoiding concurrent mutex locks

Extract mutex locks into separate statements before the struct literal to avoid
concurrent lock holding and potential deadlocks.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs [341-351]

 pub fn snapshot(&self, direct: Vec<DirectDep>) -> ResolvedTree {
+    let packages = lock_recoverable(&self.packages).clone();
+    let dependencies_tree = lock_recoverable(&self.dependencies_tree).clone();
+    let all_peer_dep_names = lock_recoverable(&self.all_peer_dep_names).clone();
+    let policy_violations = lock_recoverable(&self.policy_violations).clone();
+    let applied_patches = lock_recoverable(&self.applied_patches).clone();
+    let children_by_id = lock_recoverable(&self.children_by_id).clone();
+
     ResolvedTree {
         direct,
-        packages: lock_recoverable(&self.packages).clone(),
-        dependencies_tree: lock_recoverable(&self.dependencies_tree).clone(),
-        all_peer_dep_names: lock_recoverable(&self.all_peer_dep_names).clone(),
-        policy_violations: lock_recoverable(&self.policy_violations).clone(),
-        applied_patches: lock_recoverable(&self.applied_patches).clone(),
-        children_by_id: lock_recoverable(&self.children_by_id).clone(),
+        packages,
+        dependencies_tree,
+        all_peer_dep_names,
+        policy_violations,
+        applied_patches,
+        children_by_id,
     }
 }
Suggestion importance[1-10]: 9

__

Why: The suggestion accurately points out a subtle Rust lock order inversion and deadlock risk due to how temporary lifetimes work in struct literals.

High
Prevent deadlock by dropping mutex guards early

Explicitly drop the shadowed packages mutex guard before constructing the struct
literal to avoid holding multiple locks unnecessarily.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs [414-428]

-let packages = lock_recoverable(&self.packages);
+let packages_guard = lock_recoverable(&self.packages);
 let packages = reachable_pkg_ids
     .into_iter()
-    .filter_map(|pkg_id| packages.get(&pkg_id).cloned().map(|pkg| (pkg_id, pkg)))
+    .filter_map(|pkg_id| packages_guard.get(&pkg_id).cloned().map(|pkg| (pkg_id, pkg)))
     .collect();
+drop(packages_guard);
+
+let all_peer_dep_names = lock_recoverable(&self.all_peer_dep_names).clone();
+let policy_violations = lock_recoverable(&self.policy_violations).clone();
+let applied_patches = lock_recoverable(&self.applied_patches).clone();
 
 ResolvedTree {
     direct,
     packages,
     dependencies_tree,
-    all_peer_dep_names: lock_recoverable(&self.all_peer_dep_names).clone(),
-    policy_violations: lock_recoverable(&self.policy_violations).clone(),
-    applied_patches: lock_recoverable(&self.applied_patches).clone(),
+    all_peer_dep_names,
+    policy_violations,
+    applied_patches,
     children_by_id,
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly notes that shadowing a variable in Rust does not drop the original, which means the packages guard is unintentionally held during subsequent lock acquisitions.

Medium

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs (1)

8-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse manifest_result for this fixture.

This literal matches test_support::manifest_result in every field except manifest. The helper is already imported on Line 4 and the other four tests in this file use it. Reusing it removes the duplicated ResolveResult construction and the now-unneeded PkgResolutionId, LockfileResolution, and DirectoryResolution imports for this test.

♻️ Proposed reuse of the shared fixture
-    let result = ResolveResult {
-        id: PkgResolutionId::from("[email protected]"),
-        name_ver: None,
-        latest: None,
-        published_at: None,
-        manifest: Some(std::sync::Arc::new(serde_json::json!({
-            "name": "parent",
-            "version": "1.0.0",
-            "engines": {
-                "runtime": {
-                    "name": "node",
-                    "version": "22.19.0",
-                    "onFail": "download",
-                },
-            },
-        }))),
-        resolution: LockfileResolution::Directory(DirectoryResolution {
-            directory: "parent".to_string(),
-        }),
-        resolved_via: "npm-registry".to_string(),
-        normalized_bare_specifier: None,
-        alias: Some("parent".to_string()),
-        policy_violation: None,
-    };
+    let result = manifest_result(serde_json::json!({
+        "name": "parent",
+        "version": "1.0.0",
+        "engines": {
+            "runtime": {
+                "name": "node",
+                "version": "22.19.0",
+                "onFail": "download",
+            },
+        },
+    }));
As per path instructions, report "missed reuse or duplication across the monorepo".
🤖 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/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs`
around lines 8 - 31, Replace the duplicated ResolveResult literal in the
affected test with the imported test_support::manifest_result fixture, then
override only its manifest field with the test-specific JSON. Remove the
now-unused PkgResolutionId, LockfileResolution, and DirectoryResolution imports,
and report “missed reuse or duplication across the monorepo” as required.

Source: Path instructions

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs (1)

141-182: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the duplicated lockfile_dir derivation.

TreeCtx::new and TreeCtx::with_workspace both compute lockfile_dir with the same fallback logic. Extract a small private helper and call it from both constructors to remove the duplication.

♻️ Proposed refactor
+fn resolve_lockfile_dir(base_opts: &ResolveOptions) -> PathBuf {
+    if base_opts.lockfile_dir.as_os_str().is_empty() {
+        base_opts.project_dir.clone()
+    } else {
+        base_opts.lockfile_dir.clone()
+    }
+}
+
 impl TreeCtx {
     #[must_use]
     pub fn new(base_opts: ResolveOptions) -> Self {
-        let lockfile_dir = if base_opts.lockfile_dir.as_os_str().is_empty() {
-            base_opts.project_dir.clone()
-        } else {
-            base_opts.lockfile_dir.clone()
-        };
+        let lockfile_dir = resolve_lockfile_dir(&base_opts);
         TreeCtx {
             ...
         }
     }

     pub fn with_workspace(workspace: Arc<WorkspaceTreeCtx>, base_opts: ResolveOptions) -> Self {
-        let lockfile_dir = if base_opts.lockfile_dir.as_os_str().is_empty() {
-            base_opts.project_dir.clone()
-        } else {
-            base_opts.lockfile_dir.clone()
-        };
+        let lockfile_dir = resolve_lockfile_dir(&base_opts);
         TreeCtx {
             ...
         }
     }
 }
🤖 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/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs`
around lines 141 - 182, Extract the shared lockfile directory fallback logic
from TreeCtx::new and TreeCtx::with_workspace into a small private helper, then
call that helper from both constructors before lexical normalization. Preserve
the existing behavior of using project_dir when lockfile_dir is empty and
lockfile_dir otherwise.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs`:
- Around line 8-31: Replace the duplicated ResolveResult literal in the affected
test with the imported test_support::manifest_result fixture, then override only
its manifest field with the test-specific JSON. Remove the now-unused
PkgResolutionId, LockfileResolution, and DirectoryResolution imports, and report
“missed reuse or duplication across the monorepo” as required.

In `@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs`:
- Around line 141-182: Extract the shared lockfile directory fallback logic from
TreeCtx::new and TreeCtx::with_workspace into a small private helper, then call
that helper from both constructors before lexical normalization. Preserve the
existing behavior of using project_dir when lockfile_dir is empty and
lockfile_dir otherwise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 646fb722-3608-4e47-a4ca-ec3b76696d08

📥 Commits

Reviewing files that changed from the base of the PR and between fa8d383 and b58c2f4.

📒 Files selected for processing (13)
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/catalogs.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/test_support.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tree_ctx.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs

Copilot AI review requested due to automatic review settings August 1, 2026 15:38
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 1, 2026
@zkochan

zkochan commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Both Qodo suggestions land on WorkspaceTreeCtx::snapshot and
WorkspaceTreeCtx::snapshot_reachable_from, which this PR only relocates —
both bodies are byte-identical to main, so neither suggestion is about a
change made here. I'm leaving them out of this PR to keep it pure movement.

That said, the underlying concern is worth recording, and the real inversion
is not the one Qodo pointed at. Within snapshot all six guards are acquired
in one fixed order, so that function alone cannot deadlock. The genuine ABBA
pair is between two different functions:

  • snapshot holds packages → dependencies_tree (struct-literal temporaries
    live to the end of the statement, so all six guards are held at once).
  • provider_pkg_ids holds dependencies_tree → packages.

Two threads entering those concurrently can deadlock. Whether they ever do
overlap is the open question — the orchestrator calls snapshot between hoist
waves and the peer-discovery engine calls provider_pkg_ids, so it may well be
unreachable today.

The surrounding code shows the lock order is maintained deliberately elsewhere:
snapshot_reachable_from carries a comment explaining that it drops
dependencies_tree before taking the next guard specifically so it cannot
invert snapshot's order, and record_first_walk_missing documents
children_owner_by_id before first_walk_missing_by_pkg. provider_pkg_ids
looks like it was simply missed when that invariant was established.

Fixing it means either hoisting snapshot's locks out of the struct literal or
swapping provider_pkg_ids' two acquisitions — a one-line change either way,
but it deserves its own commit with its own reasoning rather than being buried
in a 4,300-line movement diff. @zkochan happy to send that as a follow-up if
you'd like it.


Written by an agent (Claude Code, claude-opus-5[1m]).

… the shared helper

The engines-runtime test built a `ResolveResult` literal identical to
`test_support::manifest_result` in every field but the manifest. The two sat in
different parts of the old 871-line test module; the split puts them in the same
file, where the duplication is plain.

Only the literal goes — `PkgResolutionId`, `LockfileResolution`, and
`DirectoryResolution` stay imported, because the deprecation test below builds
its own result with different values for all three.
@zkochan

zkochan commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Thanks — taking one of the two.

manifest/tests.rs — reuse manifest_result: applied in 83590db. The
literal was identical to test_support::manifest_result in every field but the
manifest; the two used to sit ~150 lines apart in the old 871-line test module,
and the split puts them in the same file where the duplication is obvious. Good
catch.

One correction to the proposed diff: it also removes the PkgResolutionId,
LockfileResolution, and DirectoryResolution imports, which would not
compile. deprecated_pkg_name_ver_falls_back_to_the_manifest further down the
same file builds its own ResolveResult with different values for all three
(git-pkg@…, git-repository, directory: "."), so it still needs them. Only
the literal was removed.

tree_ctx.rs — extract the lockfile_dir derivation: skipping. The
duplication between TreeCtx::new and TreeCtx::with_workspace is pre-existing
and unchanged by this PR. The property that makes a 4,300-line diff reviewable
here is that the implementation is pure movement — after normalizing imports,
module declarations, visibility markers and doc links, the before/after multiset
of source lines is identical. Hand-editing a constructor body forfeits that for
a change CodeRabbit itself rates 💤 low value. Worth doing on its own afterwards.


Written by an agent (Claude Code, claude-opus-5[1m]).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 1, 2026 15:42
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 83590db

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

Suppressed comments (2)

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs:659

  • provider_pkg_ids() currently locks dependencies_tree and then packages and holds both guards at the same time. Elsewhere (e.g. snapshot() and parts of the walk) the lock order is packages → dependencies_tree, so this inverted acquisition order can deadlock under concurrent access. Collect the (NodeId, pkg_id) pairs under one lock, drop it, then filter against packages under the second lock (or otherwise enforce a single global lock order).
        let dependencies_tree = lock_recoverable(&self.dependencies_tree);
        let packages = lock_recoverable(&self.packages);
        node_ids

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs:366

  • snapshot() builds the ResolvedTree using multiple lock_recoverable(...).clone() calls inline. In Rust, the temporary MutexGuards created for those field initializers can live until the end of the struct literal, meaning this can hold several workspace locks at once. That increases the risk of deadlocks with other code that acquires these mutexes in a different order (e.g. provider_pkg_ids). Cloning each map into locals first drops each guard immediately and keeps lock acquisition single-at-a-time.

This issue also appears on line 657 of the same file.

    pub fn snapshot(&self, direct: Vec<DirectDep>) -> ResolvedTree {
        ResolvedTree {
            direct,
            packages: lock_recoverable(&self.packages).clone(),
            dependencies_tree: lock_recoverable(&self.dependencies_tree).clone(),

@zkochan

zkochan commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Corroboration on the lock-ordering point above: Copilot's latest pass
independently reached the same conclusion, and named the same function —
"provider_pkg_ids() currently locks dependencies_tree and then packages
… Elsewhere (e.g. snapshot()) the lock order is packages →
dependencies_tree, so this inverted acquisition order can deadlock under
concurrent access." It suppressed the comments, presumably because the code is
unchanged by this PR.

So two independent reviewers land on the same pre-existing ABBA pair. Still
leaving it out of this PR — it is a behavior change in code this PR does not
otherwise touch, and it reviews far better on its own than inside a 4,300-line
movement diff. Say the word and I'll open it as a follow-up.


Written by an agent (Claude Code, claude-opus-5[1m]).

@codecov-commenter

codecov-commenter commented Aug 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.12154% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.96%. Comparing base (fa8d383) to head (dc4fd25).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...-deps-resolver/src/resolve_dependency_tree/walk.rs 97.54% 15 Missing ⚠️
...deps-resolver/src/resolve_dependency_tree/reuse.rs 96.35% 14 Missing ⚠️
...olver/src/resolve_dependency_tree/workspace_ctx.rs 97.12% 13 Missing ⚠️
...s-resolver/src/resolve_dependency_tree/manifest.rs 96.68% 7 Missing ⚠️
...s-resolver/src/resolve_dependency_tree/tree_ctx.rs 97.20% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13562      +/-   ##
==========================================
+ Coverage   87.94%   87.96%   +0.01%     
==========================================
  Files         556      563       +7     
  Lines       97218    97334     +116     
==========================================
+ Hits        85502    85616     +114     
- Misses      11716    11718       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…r own contents

Two of the module docs added with the split repeat documentation that already
exists elsewhere, which the comment conventions rule out.

The facade's `//!` said the file holds the entry points and then toured the six
submodules. Both halves are already written down: the crate-level docs in
lib.rs describe the tree pass, `resolve_dependency_tree`'s own doc states its
contract, and rustdoc renders the module index with each submodule's first doc
line — the tour was a paraphrase sitting directly above the thing it
paraphrased. The file carried no module doc before the split; it doesn't need
one now.

The paragraph appended to reuse.rs said which functions "live here too". That
is an inventory of the module, not a contract, and the item list renders itself.

The remaining six module docs stay: a module has no name or signature to carry
its contract, and they follow the shape the resolve_peers split established in
#13551.
Copilot AI review requested due to automatic review settings August 1, 2026 15:50
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b1bbb42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

…ady pin

The split moves each unit test next to the item it exercises; they used to sit
up to ~3,200 lines apart in one file. Co-locating them exposes doc comments that
walk through scenarios the tests below already state by name, which the comment
conventions rule out — tests are the documentation for behavior, and prose that
repeats them reads as missing coverage.

Trimmed to the contract plus the non-obvious why, dropping what a test pins:

- `is_update_target` loses the paragraph enumerating its four outcomes; the ten
  tests in `mod is_update_target` name each one. The contract it feeds (the
  `update_requested` flag behind the picker's held-back-update warning) stays.
- `real_package_name_of` loses the per-protocol worked examples and the four
  inline blocks narrating each branch; thirteen tests cover them, and the test
  for the scoped case names the `idx >= 1` guard directly.
- `higher_direct_dep_version` loses the prerelease note. Both directions are
  tested, and the test's own comment anchors the rule to pnpm's
  `semver.satisfies(.., true)` — a better reference than the one removed.
- `fallback_manifest` loses the list of identities it falls back to; its four
  tests are that list. Why a fallback exists at all, and that `0.0.0` is what
  pnpm writes into `packages:`, stay.
- `extract_children` keeps both rationales (npm merges `optionalDependencies` at
  publish time; npm ships bundled deps inside the tarball) and drops the
  restatement of what the four bundled-dependency tests assert.
- The `deprecated_pkg_name_ver` test doc shrinks to its why; the asserts and the
  test name already carry the rest.
Copilot AI review requested due to automatic review settings August 1, 2026 16:12
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit dc4fd25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: dc4fd2561294

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.612 ± 0.150 2.352 2.778 1.76 ± 0.21
pacquet@main 2.542 ± 0.179 2.335 2.801 1.71 ± 0.22
pnpr@HEAD 1.483 ± 0.155 1.350 1.781 1.00
pnpr@main 1.554 ± 0.157 1.333 1.755 1.05 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6120207586399995,
      "stddev": 0.1499137711164567,
      "median": 2.67175315584,
      "user": 1.6253422199999998,
      "system": 1.3335271599999996,
      "min": 2.35211037334,
      "max": 2.77800327534,
      "times": [
        2.70789724134,
        2.47780433734,
        2.65775257034,
        2.44200933234,
        2.77800327534,
        2.6857537413399997,
        2.52845470634,
        2.35211037334,
        2.72215788734,
        2.76826412134
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.54215679704,
      "stddev": 0.17870792131110558,
      "median": 2.54682352734,
      "user": 1.6323010200000003,
      "system": 1.30477286,
      "min": 2.3351285543399998,
      "max": 2.80142398534,
      "times": [
        2.73793596634,
        2.69121405534,
        2.53802146334,
        2.5556255913399997,
        2.34841087934,
        2.33867781334,
        2.80142398534,
        2.67471276834,
        2.3351285543399998,
        2.40041689334
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4826338806400001,
      "stddev": 0.1553691594763171,
      "median": 1.4406576633400001,
      "user": 1.1904545199999998,
      "system": 1.15323156,
      "min": 1.3496296973400002,
      "max": 1.78140225034,
      "times": [
        1.4044868763400002,
        1.4523712183400002,
        1.49112325534,
        1.3496296973400002,
        1.4376179613400002,
        1.7462916463400002,
        1.3611941313400002,
        1.35852440434,
        1.44369736534,
        1.78140225034
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5542538020400003,
      "stddev": 0.15692376218895107,
      "median": 1.51870977934,
      "user": 1.1646199199999998,
      "system": 1.1519864599999998,
      "min": 1.33348947434,
      "max": 1.7553407863400001,
      "times": [
        1.7553407863400001,
        1.4809078743400002,
        1.49960808034,
        1.3478175833400001,
        1.63317256534,
        1.53781147834,
        1.47524593534,
        1.33348947434,
        1.7442904403400001,
        1.7348538023400002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 249.3 ± 4.3 246.1 260.3 1.00
pacquet@main 252.9 ± 6.4 240.4 265.5 1.01 ± 0.03
pnpr@HEAD 268.7 ± 5.7 261.4 276.2 1.08 ± 0.03
pnpr@main 263.6 ± 5.8 255.3 269.8 1.06 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24926396033999998,
      "stddev": 0.004250072661081425,
      "median": 0.24808232784,
      "user": 0.19335194,
      "system": 0.51474048,
      "min": 0.24605744634,
      "max": 0.26034921534,
      "times": [
        0.24679374934,
        0.24909528134,
        0.24940374334,
        0.24605744634,
        0.24851656534,
        0.26034921534,
        0.25162122334000003,
        0.24764809034000002,
        0.24678836634,
        0.24636592234000002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25294208644000005,
      "stddev": 0.006366761219865584,
      "median": 0.25230058633999997,
      "user": 0.19644574,
      "system": 0.49786127999999985,
      "min": 0.24039169134000002,
      "max": 0.26554604634,
      "times": [
        0.24940282934000002,
        0.25467718334,
        0.25133173334000003,
        0.24039169134000002,
        0.26554604634,
        0.25326892534,
        0.25133224734,
        0.25732835634,
        0.25102794934,
        0.25511390234000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26868472064000004,
      "stddev": 0.0056604703677040425,
      "median": 0.26824624984,
      "user": 0.20549014000000004,
      "system": 0.50955988,
      "min": 0.26138033234,
      "max": 0.27621984134,
      "times": [
        0.27621984134,
        0.26913832934,
        0.26138033234,
        0.26338723834,
        0.27387587634,
        0.26581984934,
        0.26139962334,
        0.26735417034000003,
        0.27361818034,
        0.27465376534
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.26361740623999996,
      "stddev": 0.005750850134497339,
      "median": 0.26518732284,
      "user": 0.21740034000000003,
      "system": 0.49942758,
      "min": 0.25532226534,
      "max": 0.26978238434,
      "times": [
        0.26025416134,
        0.26771391134,
        0.26978238434,
        0.26884012634,
        0.25532226534,
        0.25664807034000003,
        0.26778403134,
        0.26266073434000003,
        0.26944143934000003,
        0.25772693834
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.586 ± 0.011 2.570 2.604 1.67 ± 0.15
pacquet@main 2.570 ± 0.014 2.547 2.588 1.66 ± 0.15
pnpr@HEAD 1.588 ± 0.117 1.431 1.772 1.02 ± 0.12
pnpr@main 1.550 ± 0.138 1.424 1.878 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5862005004600004,
      "stddev": 0.011095168542474856,
      "median": 2.5845091674600003,
      "user": 1.63814888,
      "system": 1.3100106599999999,
      "min": 2.57029810546,
      "max": 2.60437131046,
      "times": [
        2.6015330694600003,
        2.57029810546,
        2.57820868046,
        2.5907858684600003,
        2.58958077746,
        2.5773474264600003,
        2.57943755746,
        2.60437131046,
        2.57941512046,
        2.59102708846
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5696394010600003,
      "stddev": 0.014441855279438283,
      "median": 2.57111854446,
      "user": 1.61180518,
      "system": 1.3083730599999999,
      "min": 2.54683431846,
      "max": 2.58819481446,
      "times": [
        2.58819481446,
        2.5601272444600003,
        2.58114117246,
        2.5622826294600003,
        2.57903183046,
        2.55209784046,
        2.58005261146,
        2.5834262904600003,
        2.56320525846,
        2.54683431846
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5883011061599999,
      "stddev": 0.11692848618158978,
      "median": 1.61470556796,
      "user": 1.16846438,
      "system": 1.15035216,
      "min": 1.4306545664599999,
      "max": 1.7724862104599999,
      "times": [
        1.6325472214599999,
        1.4944654394599999,
        1.5041177344599999,
        1.43756322346,
        1.61634660446,
        1.4306545664599999,
        1.71594750846,
        1.61306453146,
        1.66581802146,
        1.7724862104599999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5503228620599998,
      "stddev": 0.13818943588284738,
      "median": 1.48863341696,
      "user": 1.15417648,
      "system": 1.1607215599999998,
      "min": 1.42368989046,
      "max": 1.8775471324600002,
      "times": [
        1.8775471324600002,
        1.49071636246,
        1.44509223746,
        1.62204095846,
        1.45585503446,
        1.42368989046,
        1.48037863246,
        1.65436159146,
        1.56699630946,
        1.48655047146
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 390.2 ± 9.5 369.1 402.9 1.31 ± 0.04
pacquet@main 383.2 ± 14.2 371.1 418.3 1.28 ± 0.05
pnpr@HEAD 305.0 ± 11.8 289.7 331.6 1.02 ± 0.04
pnpr@main 298.3 ± 5.8 290.6 306.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.3902193183,
      "stddev": 0.00948795366047521,
      "median": 0.39152705340000005,
      "user": 0.50480148,
      "system": 0.6911481599999998,
      "min": 0.3690562409,
      "max": 0.4028993369,
      "times": [
        0.3690562409,
        0.38561898990000004,
        0.3937662049,
        0.39126554490000004,
        0.3917885619,
        0.3926629359,
        0.38803976090000003,
        0.4016518999,
        0.4028993369,
        0.3854437069
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.38319266589999995,
      "stddev": 0.014209498206762441,
      "median": 0.3786909519,
      "user": 0.4865458799999999,
      "system": 0.69287386,
      "min": 0.37111881490000004,
      "max": 0.4182611479,
      "times": [
        0.38222244790000004,
        0.3723163659,
        0.37111881490000004,
        0.37977033590000003,
        0.37550487990000003,
        0.3758703679,
        0.3961075979,
        0.4182611479,
        0.3776115679,
        0.3831431329
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30500056640000006,
      "stddev": 0.011766032100813124,
      "median": 0.3038826309,
      "user": 0.18428538,
      "system": 0.5216550600000001,
      "min": 0.2896670169,
      "max": 0.3315567149,
      "times": [
        0.3072378719,
        0.3131357329,
        0.2896670169,
        0.2984972929,
        0.2926695789,
        0.3018174649,
        0.3009361639,
        0.3059477969,
        0.3315567149,
        0.3085400299
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29828707830000006,
      "stddev": 0.0057774441137276025,
      "median": 0.29946430290000003,
      "user": 0.18326668000000002,
      "system": 0.50617896,
      "min": 0.2906454609,
      "max": 0.3068192429,
      "times": [
        0.30133227290000003,
        0.3023913429,
        0.2906454609,
        0.2937864409,
        0.2979909959,
        0.3009376099,
        0.2938360909,
        0.3068192429,
        0.3044532789,
        0.2906780469
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.731 ± 0.012 1.716 1.751 5.83 ± 0.15
pacquet@main 1.726 ± 0.010 1.711 1.745 5.82 ± 0.15
pnpr@HEAD 0.297 ± 0.007 0.288 0.314 1.00
pnpr@main 0.304 ± 0.009 0.295 0.319 1.03 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.73108718688,
      "stddev": 0.011647110636078366,
      "median": 1.73010601018,
      "user": 0.7120430399999998,
      "system": 0.7698841399999999,
      "min": 1.71649478318,
      "max": 1.7511615141799999,
      "times": [
        1.7511615141799999,
        1.7228327151799998,
        1.7347475081800001,
        1.72839488818,
        1.74625649418,
        1.73181713218,
        1.71649478318,
        1.73814675418,
        1.7229561391800001,
        1.71806394018
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.72640863748,
      "stddev": 0.009735550368287663,
      "median": 1.72608632118,
      "user": 0.7105086399999999,
      "system": 0.76247654,
      "min": 1.71071290518,
      "max": 1.74471613518,
      "times": [
        1.72794541018,
        1.71558855418,
        1.73383768718,
        1.7211500521799998,
        1.72381305418,
        1.7242272321799998,
        1.73375799918,
        1.71071290518,
        1.72833734518,
        1.74471613518
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29678821688,
      "stddev": 0.007326880220399501,
      "median": 0.29630088968,
      "user": 0.20000694000000002,
      "system": 0.49474534,
      "min": 0.28821867118000005,
      "max": 0.3143078441800001,
      "times": [
        0.29170738718000006,
        0.28821867118000005,
        0.29710808318000004,
        0.29939608218,
        0.29825761718000005,
        0.3143078441800001,
        0.30001638818000004,
        0.29549369618000004,
        0.29306290718000005,
        0.29031349218
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.3044823521800001,
      "stddev": 0.008795761959015916,
      "median": 0.30326857618,
      "user": 0.18073073999999997,
      "system": 0.5142743399999999,
      "min": 0.29519792118000004,
      "max": 0.31863373518000004,
      "times": [
        0.31863373518000004,
        0.29541876618000007,
        0.30255557818000006,
        0.30492089118000004,
        0.29519792118000004,
        0.31448963218000003,
        0.31525001018000004,
        0.29789854918,
        0.29647686418,
        0.30398157418000005
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 182.8 ± 3.4 177.4 190.3 2.04 ± 0.07
pacquet@main 186.1 ± 6.5 177.1 201.8 2.07 ± 0.10
pnpr@HEAD 89.7 ± 2.7 85.4 95.8 1.00
pnpr@main 90.8 ± 3.4 86.1 102.7 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.18276893106000003,
      "stddev": 0.00335205807690214,
      "median": 0.18174633486000003,
      "user": 0.16551002666666664,
      "system": 0.08445468666666667,
      "min": 0.17735230886000003,
      "max": 0.19031852686000003,
      "times": [
        0.18284605786000002,
        0.18413857986,
        0.17735230886000003,
        0.18174633486000003,
        0.18647600886000001,
        0.18136899586000002,
        0.17983986886000003,
        0.18066239686000002,
        0.17961560886000003,
        0.18552457486,
        0.19031852686000003,
        0.18679613186000002,
        0.18259542086000002,
        0.18139588786000002,
        0.18085726286000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.18605782219333333,
      "stddev": 0.006473569519374859,
      "median": 0.18600069786000004,
      "user": 0.16594555999999996,
      "system": 0.08836328666666665,
      "min": 0.17713838686000002,
      "max": 0.20183769586000003,
      "times": [
        0.19030207586000003,
        0.18693532686000003,
        0.20183769586000003,
        0.18828163086000002,
        0.17795868486000002,
        0.17713838686000002,
        0.18529358686000003,
        0.18084550486000003,
        0.18596167186000004,
        0.18621543986000003,
        0.18001174786000002,
        0.19222330986000002,
        0.18016782486000002,
        0.18600069786000004,
        0.19169374786
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.0897091521725,
      "stddev": 0.002707440597028367,
      "median": 0.09044987586,
      "user": 0.020638366249999995,
      "system": 0.012109395,
      "min": 0.08540777086000001,
      "max": 0.09576008686000001,
      "times": [
        0.08815506686,
        0.09175859186,
        0.09112213886000001,
        0.09284150686,
        0.08870678086,
        0.08992822086,
        0.08641699186,
        0.08540777086000001,
        0.09218264886000001,
        0.09576008686000001,
        0.08669376886,
        0.09163831486,
        0.09189571986,
        0.09000337786000001,
        0.09199369986,
        0.09099381386000001,
        0.09370359686,
        0.08892030586,
        0.08619678286,
        0.09155303586,
        0.08642839686,
        0.08617934486,
        0.09146314486000001,
        0.08645075386000001,
        0.09044353186000001,
        0.09175133286,
        0.09158854386000001,
        0.09045621986,
        0.08584979986,
        0.09065334186,
        0.08651514986,
        0.08704108786
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09076273708580646,
      "stddev": 0.0033522960614069163,
      "median": 0.09098344786000001,
      "user": 0.02040641161290323,
      "system": 0.012717536129032255,
      "min": 0.08611815586,
      "max": 0.10265305686000001,
      "times": [
        0.09155933886,
        0.08892310586,
        0.08656844286000001,
        0.08678452286,
        0.09017004886,
        0.10265305686000001,
        0.09082754686000001,
        0.08934669386,
        0.08722421986000001,
        0.08734703886,
        0.08744137886,
        0.09035356186,
        0.09255983786000001,
        0.09104651286000001,
        0.08809340886,
        0.09254931786000001,
        0.08611815586,
        0.09145630886,
        0.09144406786,
        0.09098344786000001,
        0.09315023386,
        0.09771598286000001,
        0.08826476986000001,
        0.09099431286000001,
        0.09115628686,
        0.09136166286000001,
        0.09105197986,
        0.09503793586,
        0.08899905986000001,
        0.09033314586,
        0.09212946486000001
      ]
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.596 ± 0.260 1.272 2.105 1.00
pacquet@main 1.797 ± 0.459 1.328 2.543 1.13 ± 0.34
pnpm@HEAD 3.002 ± 0.205 2.822 3.357 1.88 ± 0.33
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.5956824455911114,
      "stddev": 0.2601557744624836,
      "median": 1.53606121248,
      "user": 1.4915673822222222,
      "system": 0.2289361155555555,
      "min": 1.27184578448,
      "max": 2.10547408148,
      "times": [
        1.7667936324800002,
        1.4000990564800002,
        1.37679726448,
        1.27184578448,
        1.7879591974800002,
        1.65263744748,
        1.53606121248,
        2.10547408148,
        1.4634743334800002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.7973308509244446,
      "stddev": 0.4591837226970484,
      "median": 1.66844449348,
      "user": 1.6746047155555557,
      "system": 0.2491724488888889,
      "min": 1.32826681948,
      "max": 2.5434085204800003,
      "times": [
        2.5434085204800003,
        2.0325727914800003,
        1.53482649648,
        1.3681222964800002,
        1.79351875948,
        1.4355620234800002,
        1.32826681948,
        1.66844449348,
        2.4712554574800003
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0015650730355556,
      "stddev": 0.20496192459852058,
      "median": 2.89589282848,
      "user": 4.240982382222223,
      "system": 0.30717455999999993,
      "min": 2.82241931748,
      "max": 3.35683851448,
      "times": [
        3.35683851448,
        2.91770855748,
        3.19808264948,
        2.8544148754800003,
        2.85865225948,
        2.86379374948,
        2.89589282848,
        2.82241931748,
        3.24628290548
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.515 ± 0.154 4.404 4.840 1.29 ± 0.05
pacquet@main 4.597 ± 0.190 4.408 4.883 1.31 ± 0.06
pnpr@HEAD 3.508 ± 0.121 3.440 3.846 1.00 ± 0.04
pnpr@main 3.505 ± 0.086 3.442 3.702 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.515280160960001,
      "stddev": 0.15355636708749756,
      "median": 4.43524681616,
      "user": 1.7487802199999998,
      "system": 1.4387636399999997,
      "min": 4.40439294316,
      "max": 4.83969668016,
      "times": [
        4.42109664016,
        4.41365174216,
        4.40439294316,
        4.83969668016,
        4.43258960316,
        4.49552119116,
        4.43790402916,
        4.74751198316,
        4.42604454816,
        4.53439224916
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.59729464406,
      "stddev": 0.1897130718172032,
      "median": 4.5176641791600005,
      "user": 1.76127142,
      "system": 1.4261948400000002,
      "min": 4.40792307716,
      "max": 4.88315910716,
      "times": [
        4.49651467216,
        4.40792307716,
        4.44019863916,
        4.79859440916,
        4.72683385116,
        4.88315910716,
        4.82630426016,
        4.53881368616,
        4.41084891816,
        4.44375582016
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5075660291600004,
      "stddev": 0.12135633153460529,
      "median": 3.47909009766,
      "user": 1.3149868200000001,
      "system": 1.18423454,
      "min": 3.43950947216,
      "max": 3.84577993216,
      "times": [
        3.48426318816,
        3.47391700716,
        3.48816614616,
        3.51410192816,
        3.43950947216,
        3.44542300516,
        3.48963800316,
        3.44461289916,
        3.45024871016,
        3.84577993216
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.50496756036,
      "stddev": 0.08560304960232624,
      "median": 3.45734438866,
      "user": 1.29302532,
      "system": 1.2153613399999998,
      "min": 3.44197718316,
      "max": 3.70176734216,
      "times": [
        3.54975253216,
        3.70176734216,
        3.44197718316,
        3.45801745116,
        3.45348543716,
        3.45667132616,
        3.59432792016,
        3.4518032441599997,
        3.44934813416,
        3.4925250331599997
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13562
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,570.30 ms
(-3.94%)Baseline: 2,675.68 ms
3,210.82 ms
(80.05%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,716.49 ms
(-5.42%)Baseline: 1,814.86 ms
2,177.83 ms
(78.82%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
369.06 ms
(-21.30%)Baseline: 468.94 ms
562.72 ms
(65.58%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
177.35 ms
(-18.77%)Baseline: 218.32 ms
261.99 ms
(67.70%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,352.11 ms
(-3.19%)Baseline: 2,429.62 ms
2,915.55 ms
(80.67%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,404.39 ms
(-2.64%)Baseline: 4,523.79 ms
5,428.54 ms
(81.13%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
246.06 ms
(-12.62%)Baseline: 281.60 ms
337.92 ms
(72.82%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
1,271.85 ms
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13562
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,430.65 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
288.22 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
289.67 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
85.41 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,349.63 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,439.51 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
261.38 ms
🐰 View full continuous benchmarking report in Bencher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(pacquet): split resolve_dependency_tree into focused modules

3 participants