Skip to content

fix(install): preserve hoisted prior groups and check transitive local deps under --filter - #17138

Merged
zkochan merged 6 commits into
mainfrom
fix/filtered-install-scope-and-freshness
Oct 19, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix/filtered-install-scope-and-freshness

Conversation

@zkochan

@zkochan zkochan commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Unifies filtered-install workspace scope, hoisted per-importer dependency group preservation, and local/linked dependency freshness checks.

Closes pnpm/tasks#164

  1. Preserve per-importer dependency groups in hoisted filtered installs (--prod / --dev / --no-optional):

    • Previously, selected_materialization_ids unioned unselected prior importers into the selected importer ID set and passed one global GroupSelection to materialization_closure, install_frozen_lockfile, hoisted linking, and stale module pruning, stripping previously installed devDependencies (or dependencies) of unselected workspace projects.
    • Introduces selected_materialization_closure, which applies the CLI GroupSelection only to the selected importer closure and retains the dependency groups recorded in the prior current lockfile for unselected workspace projects.
    • Updates frozen/fresh materialization, hoisted linking, workspace link creation, stale link pruning, and build-phase top-level bin linking to read retained per-importer groups from scope.lockfile().
  2. Keep requested_importer_ids whenever --filter was passed on the CLI:

    • In a sparse checkout where --filter matches every on-disk project while missing projects remain in pnpm-lock.yaml, filtered_install is false for on-disk projects, but requested_importer_ids now still restricts materialization to the requested on-disk importers so missing projects are not materialized.
  3. Check transitive local directory dependencies and importer link: ranges during freshness and repeat-install checks:

    • Recurses through LockfileResolution::Directory children in check_directory_dependencies_freshness (with cycle detection) so modifying a transitive injected/local package invalidates both --frozen-lockfile and the optimistic repeat-install fast path.
    • Verifies importer-level ImporterDepVersion::Link entries against workspace: and link: specifiers in check_single_dep_spec_directory_freshness.
    • Fixes mark_importers_of_unproven_directory_deps in optimistic repeat install to handle ImporterDepVersion::File and ImporterDepVersion::Link, compare exact directory paths (or publishConfig.directory) instead of prefix-matching the workspace root ".", and iterate to a fixpoint.

Squash Commit Body

Unify filtered-install workspace scope, hoisted per-importer group
preservation, and local/linked dependency freshness checks
(Closes https://github.com/pnpm/tasks/issues/164):

1. Preserve per-importer dependency groups in hoisted filtered installs:
   - Introduce `selected_materialization_closure`, which applies the CLI
     `GroupSelection` only to the selected importer closure and retains the
     dependency groups recorded in the prior current lockfile for unselected
     workspace projects.
   - Update frozen/fresh materialization, hoisted linking, workspace link
     creation, stale link pruning, and build-phase top-level bin linking to
     read retained per-importer groups from `scope.lockfile()`.

2. Keep `requested_importer_ids` whenever `--filter` was passed on the CLI:
   - In a sparse checkout where `--filter` matches every on-disk project while
     missing projects remain in `pnpm-lock.yaml`, `requested_importer_ids`
     still restricts materialization to the requested on-disk importers.

3. Check transitive local directory dependencies and importer `link:` ranges:
   - Recurse through `LockfileResolution::Directory` children in
     `check_directory_dependencies_freshness` (with cycle detection) so
     modifying a transitive injected/local package invalidates both
     `--frozen-lockfile` and the optimistic repeat-install fast path.
   - Verify importer-level `ImporterDepVersion::Link` entries against
     `workspace:` and `link:` specifiers in
     `check_single_dep_spec_directory_freshness`.
   - Fix `mark_importers_of_unproven_directory_deps` to handle
     `ImporterDepVersion::File` and `ImporterDepVersion::Link`, compare exact
     directory paths (or `publishConfig.directory`) rather than prefix-matching
     `"."`, and iterate to a fixpoint.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Generated by Antigravity (Claude Opus 4.6)


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Filtered installs using the hoisted linker now preserve previously installed dependency groups for unselected workspace projects while applying the requested dependency selection to selected projects.
    • Repeated installs now detect changes in nested local dependencies and linked workspace versions, prompting fresh resolution when needed.
    • Workspace links in sparse checkouts are handled more reliably, including when target directories are missing.

@zkochan
zkochan marked this pull request as ready for review October 19, 2026 16:57
Copilot AI balanced review requested due to automatic review settings October 19, 2026 16:57

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

qodo-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Preserve hoisted groups and validate local dependencies in filtered installs

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Preserve previously installed dependency groups for unselected projects during filtered hoisted
 installs.
• Keep explicit filter scope in sparse checkouts so missing projects are not materialized.
• Detect transitive directory and linked-dependency changes before reusing lockfiles or skipping
 repeat installs.
Diagram

graph TD
  Filter["CLI filter"] --> Scope["Importer scope"] --> Closure["Materialization closure"] --> Current["Current lockfile"] --> Hoist["Hoisted links"]
  Prior["Prior lockfile"] --> Closure
  Scope --> Freshness["Local freshness"] --> Decision{"Dependencies fresh?"}
  Decision -->|no| Closure
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Propagate per-importer group selections throughout the installer
  • ➕ Keeps the wanted lockfile unchanged until individual consumers select groups.
  • ➖ Requires every graph walker, linker, build step, and pruning path to apply the same importer-specific policy.

Recommendation: Prefer the PR's materialization-closure approach: encode selected and retained groups in the scoped lockfile once, then let downstream hoisted consumers use its recorded importer maps. Review the selected-versus-retained overlap and optional-snapshot behavior carefully because those boundaries carry the principal regression risk.

Files changed (29) +1913 / -701

Bug fix (19) +1157 / -459
reachability.rsAllow traversal of all recorded importer groups +15/-0

Allow traversal of all recorded importer groups

• Adds a GroupSelection variant that visits all direct importer groups while retaining transitive optional and peer-edge policy.

pnpm/crates/deps-restorer/src/current_lockfile/reachability.rs

install_frozen_lockfile.rsRetain recorded groups in the frozen current lockfile +8/-2

Retain recorded groups in the frozen current lockfile

• Filters the already-scoped wanted lockfile without globally removing retained importer groups.

pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs

build_phase.rsSelect hoisted build bins from recorded importer groups +14/-2

Select hoisted build bins from recorded importer groups

• Lets hoisted builds and top-level bin linking inspect all groups present in scoped importer snapshots instead of applying one global group list.

pnpm/crates/deps-restorer/src/install_frozen_lockfile/build_phase.rs

hoisted.rsHoist directly from the scoped lockfile +11/-50

Hoist directly from the scoped lockfile

• Removes the hoisted linker's global importer-group filtering and uses the scoped graph lockfile for traversal and root dependency aliases.

pnpm/crates/deps-restorer/src/install_frozen_lockfile/hoisted.rs

stale_links.rsPrune hoisted links using recorded groups +0/-1

Prune hoisted links using recorded groups

• Stops passing the global dependency-group selection to stale direct-link pruning.

pnpm/crates/deps-restorer/src/install_frozen_lockfile/hoisted/stale_links.rs

workspace_links.rsPreserve scoped hoisted workspace links +23/-28

Preserve scoped hoisted workspace links

• Creates workspace links and detects linked-bin directories across all groups retained in importer snapshots. Extracts trusted importer ID construction into a helper.

pnpm/crates/deps-restorer/src/install_frozen_lockfile/hoisted/workspace_links.rs

materialization.rsCompute frozen skips across recorded importer groups +2/-1

Compute frozen skips across recorded importer groups

• Uses the expanded direct-group selection when calculating installability skips from the scoped lockfile.

pnpm/crates/deps-restorer/src/install_frozen_lockfile/materialization.rs

skipped_snapshots.rsSeparate transient optional exclusions from retained skips +253/-0

Separate transient optional exclusions from retained skips

• Houses the extracted skipped-snapshot implementation and adds a view without --no-optional exclusions for retained importer traversal. Ensures newly recorded installability skips do not overlap other skip classes.

pnpm/crates/deps-restorer/src/installability/skipped_snapshots.rs

prune_stale_modules.rsCompare stale links against all recorded wanted groups +1/-2

Compare stale links against all recorded wanted groups

• Bases hoisted direct-link pruning on the scoped wanted importer snapshot rather than a global included-group argument.

pnpm/crates/deps-restorer/src/prune_stale_modules.rs

hoisted_selection.rsMerge selected and previously materialized closures +108/-1

Merge selected and previously materialized closures

• Builds separate closures for selected importers and unselected importers recorded in the prior current lockfile. Merges their importers and reachable packages while preserving retained dependency groups.

pnpm/crates/package-manager/src/hoisted_selection.rs

directory_deps.rsValidate transitive directory dependencies and importer links +151/-179

Validate transitive directory dependencies and importer links

• Recursively checks directory-resolved children with cycle detection and validates importer link entries against their declared specifiers.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs

injected_manifest.rsCentralize local target manifest resolution +247/-0

Centralize local target manifest resolution

• Extracts injected-manifest lookup and adds workspace-path, published-directory, and symlink-boundary checks shared by freshness validation.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/injected_manifest.rs

spec.rsValidate linked targets against paths and ranges +75/-59

Validate linked targets against paths and ranges

• Checks importer workspace and link specifiers against resolved targets, including version ranges and publishConfig.directory targets. Reuses the extracted target-manifest lookup.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs

materialize.rsDistinguish requested groups from frozen installer groups +5/-57

Distinguish requested groups from frozen installer groups

• Adds a separate frozen-installer group selection so retained hoisted groups can be installed without changing the caller's requested group policy. Moves frozen-scope construction into the frozen module.

pnpm/crates/package-manager/src/install/materialize.rs

frozen.rsUse selected closure for frozen materialization +72/-5

Use selected closure for frozen materialization

• Constructs frozen scope from selected and retained importer closures when a filter is present. Passes expanded installer groups when a prior hoisted lockfile contributes retained groups.

pnpm/crates/package-manager/src/install/materialize/frozen.rs

importer_selection.rsRegister importer-selection tests +3/-0

Register importer-selection tests

• Adds the test module for explicit filter scope. The checked-out implementation also retains requested importer IDs whenever --filter was supplied, even if all on-disk projects match.

pnpm/crates/package-manager/src/install/run/importer_selection.rs

plan.rsApply retained closure to fresh install planning +67/-39

Apply retained closure to fresh install planning

• Builds initial and final scopes with prior hoisted groups intact. Computes skip sets from the scoped lockfile and avoids globally excluding retained optional dependencies.

pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs

drift.rsPropagate unproven local dependencies to a fixpoint +81/-32

Propagate unproven local dependencies to a fixpoint

• Marks consumers of unproven file or link targets repeatedly until no further projects change status. Matches exact project paths or published directories rather than treating every child of an unproven workspace root as a match.

pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs

manifest_agreement.rsClassify stale linked packages during repeat checks +21/-1

Classify stale linked packages during repeat checks

• Recognizes linked-package freshness failures during project content validation and reports a linked-package-specific reason to abandon the optimistic fast path.

pnpm/crates/package-manager/src/optimistic_repeat_install/manifest_agreement.rs

Refactor (3) +19 / -239
installability.rsExtract skipped-snapshot implementation +2/-238

Extract skipped-snapshot implementation

• Moves SkippedSnapshots into its own module while preserving the public re-export.

pnpm/crates/deps-restorer/src/installability.rs

peers.rsShare optional-peer name extraction +14/-0

Share optional-peer name extraction

• Moves optional peer metadata lookup into the peer-handling module for use during directory dependency validation.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/peers.rs

lib.rsExpose selected materialization closure internally +3/-1

Expose selected materialization closure internally

• Re-exports the shared closure helper for frozen and fresh installation paths.

pnpm/crates/package-manager/src/lib.rs

Tests (6) +732 / -3
warm_install.rsCover filtered hoisting, sparse checkouts, and repeat installs +286/-2

Cover filtered hoisting, sparse checkouts, and repeat installs

• Adds integration cases for group preservation under --prod, --dev, and --no-optional; a missing workspace project; and changed injected or linked dependencies.

pnpm/crates/cli/tests/suite/install_filters/warm_install.rs

tests.rsTest selected and retained closure groups +209/-0

Test selected and retained closure groups

• Verifies that --prod, --dev, and --no-optional remove only selected groups while preserving unselected importers and their snapshots.

pnpm/crates/package-manager/src/hoisted_selection/tests.rs

tests.rsTest loaded linked projects outside the workspace root +36/-0

Test loaded linked projects outside the workspace root

• Confirms an explicitly loaded project above the workspace root is accepted unless its directory becomes a symlink elsewhere.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec/tests.rs

tests.rsTest transitive directory drift detection +106/-1

Test transitive directory drift detection

• Adds a consumer-to-injected-child-to-directory-child case that expects the changed transitive package to invalidate freshness.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/tests.rs

tests.rsTest explicit filter scope with complete on-disk matches +29/-0

Test explicit filter scope with complete on-disk matches

• Verifies requested importer IDs remain set when the filter matches every project currently on disk.

pnpm/crates/package-manager/src/install/run/importer_selection/tests.rs

tests.rsTest repeat-install dependency propagation targets +66/-0

Test repeat-install dependency propagation targets

• Checks that an unproven workspace root does not implicate unrelated children and that a relative workspace link identifies its target project.

pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift/tests.rs

Documentation (1) +5 / -0
filtered-install-hoisted-groups-and-freshness.mdDocument filtered-install patch fixes +5/-0

Document filtered-install patch fixes

• Adds a patch changeset for preserving hoisted dependency groups and detecting changed local or linked dependencies.

.changeset/filtered-install-hoisted-groups-and-freshness.md

@qodo-code-review

qodo-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (6) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (1)

Grey Divider


Action required

1. Sparse checkouts fail frozen installs on workspace links ✗ Dismissed
Description
importer_link_satisfies sends every workspace:<range> importer link, workspace:*/^/~
included, to target_dir_satisfies. That function returns false whenever target_manifest can't
find a package.json for the link target, and it also requires the target's name to match. Before
this PR, link deps returned Ok(()). Now, in a sparse checkout where an on-disk project depends
with workspace:* on a project that is still in pnpm-lock.yaml but missing from disk,
check_importer_satisfies reports LocalDependencyOutdated. --frozen-lockfile then fails as
outdated, and every repeat install re-resolves, even though the existing linked_dep_is_up_to_date
logic treats a missing linked dir or a */^/~ range as up to date.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[R233-239]

+    target_dir_satisfies(
+        dirs,
+        &project_dir.join(link_path),
+        expected_name,
+        parsed_range_str,
+        &range,
+    )
Relevance

●●● Strong

Missing workspace manifests now fail freshness checks despite sparse-checkout preservation and prior
workspace-link tolerance.

PR-#16936
PR-#16815
PR-#15133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
check_single_dep_spec_directory_freshness now routes every ImporterDepVersion::Link to
check_importer_link_freshness and turns a false result into local_dependency_outdated. For a
non-path workspace: spec, importer_link_satisfies calls target_dir_satisfies, which starts
with let Some(pkg_json) = target_manifest(..) else { return false }. The */^/~ short-circuit
only runs after the manifest has been found and its name matched. For a directory that doesn't
exist, target_manifest returns None: publishing_project_manifest finds no publishing ancestor,
and project_or_disk_manifest fails at canonicalize. Compare linked_dep_is_up_to_date in
manifest_agreement.rs, which returns true when the linked dir can't be found and treats
*/^/~ as satisfied without reading anything. The ticket names sparse checkouts with off-disk
projects kept in the lockfile as a supported case.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[196-279]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/injected_manifest.rs[152-187]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[145-155]
pnpm/crates/package-manager/src/optimistic_repeat_install/manifest_agreement.rs[319-350]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`importer_link_satisfies` returns false for importer `link:` entries with a `workspace:*`/`^`/`~` spec, or any `workspace:` range, when the target project has no manifest on disk, for example a project left out of a sparse checkout. Frozen installs then fail as outdated, and repeat installs always re-resolve.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[196-279]

## Recommended Fix
In `importer_link_satisfies`, return `true` right away when `parsed_range_str` is `*` (which `parse_workspace_range` already produces for `*`, `^`, `~` and empty), matching `linked_dep_is_up_to_date`. Also return `true` when the link target directory does not exist, the same way `linked_dep_is_up_to_date` treats a missing linked dir. Add a test with an importer `workspace:*` link to a directory that does not exist.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Production installs retain dev packages ✗ Dismissed
Description
InstallFrozenLockfile::current_lockfile unconditionally calls with_all_importer_groups(),
overriding the requested dependency-group selection before producing the current lockfile. When an
unfiltered --prod, --dev, or --no-optional install runs, excluded importer groups remain
recorded in the current lockfile and are exposed to subsequent linking and state processing.
Code

pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs[R464-470]

+        crate::filter_lockfile_for_current(
+            self.lockfiles.wanted,
+            &self
+                .inputs()
+                .groups()
+                .with_all_importer_groups(),
+            skipped,
Relevance

●● Moderate

The change intentionally preserves prior groups for filtered hoisted installs; unfiltered behavior
is ambiguous without a direct regression precedent.

PR-#15480
PR-#16936

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed frozen-install path always expands the requested groups before filtering the current
lockfile. with_all_importer_groups() sets both production and development groups to true, while
filter_lockfile_for_current uses those flags to decide which importer maps survive, so unfiltered
group selections no longer constrain the recorded current lockfile.

Use one consistent workspace install scope
pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs[463-471]
pnpm/crates/deps-restorer/src/current_lockfile/reachability.rs[61-83]
pnpm/crates/deps-restorer/src/current_lockfile.rs[402-447]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`current_lockfile` now enables all importer groups for every frozen install, so unfiltered group selections such as `--prod` can retain excluded dependency groups in the current lockfile.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs[463-471]
- pnpm/crates/deps-restorer/src/current_lockfile/reachability.rs[61-83]

## Recommended Fix
Apply `with_all_importer_groups()` only when the install is a filtered hoisted install that must preserve unselected importers. For unfiltered installs, pass the original `GroupSelection` through unchanged so excluded dependency groups are removed from the current lockfile.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Optional fetch failures abort filtered installs ✓ Resolved
Description
merge_retained_snapshots sets retained snapshots' optional flag to false under
--no-optional, although those snapshots remain in the materialization closure. In a filtered
hoisted install, a fetch failure for a previously installed optional dependency of an unselected
project then aborts the install instead of being skipped and retried on a later install.
Code

pnpm/crates/package-manager/src/hoisted_selection.rs[R122-125]

+    if !groups.included.optional_dependencies {
+        for snapshot in retained_snapshots.values_mut() {
+            snapshot.optional = false;
+        }
Evidence
The retained closure removes optional exclusions before merging, so retained packages are attempted;
the changed flag then controls whether their fetch errors can be swallowed.

pnpm/crates/package-manager/src/hoisted_selection.rs[55-62]
pnpm/crates/package-manager/src/hoisted_selection.rs[120-130]
pnpm/crates/deps-restorer/src/create_virtual_store/cold.rs[58-80]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Filtered hoisted `--no-optional` installs retain optional dependencies of unselected projects but reclassify their snapshots as required, making optional fetch failures fatal.
## Fix Focus Areas
- pnpm/crates/package-manager/src/hoisted_selection.rs[112-132]
- pnpm/crates/deps-restorer/src/install_frozen_lockfile/materialization.rs[353-369]
## Recommended Fix
Keep the snapshot's original optional classification. Represent the selected importers' optional exclusions separately from retained dependencies so the skip-set calculation does not discard retained packages.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (1)
4. Filtered tests omit required cases ✓ Resolved
Description
The added regression coverage exercises only a hoisted --prod install plus injected and linked
dependency changes, not isolated linking, sparse checkouts, --dev, or --no-optional. Those
untested combinations can still disagree about selected and unselected materialization, lockfile
contents, and recorded installation state without failing this PR's tests.
Code

pnpm/crates/cli/tests/suite/install_filters/warm_install.rs[R60-97]

+fn filtered_hoisted_prod_install_preserves_unselected_dev_dependencies() {
+    let fixture = WorkspaceFixture::new();
+    fixture.append_workspace_yaml("nodeLinker: hoisted\n");
+    fixture.project(
+        "selected",
+        "selected",
+        ManifestDeps {
+            prod: &[(HELLO, "1.0.0")],
+            dev: &[(NO_DEPS, "1.0.0")],
+            ..Default::default()
+        },
+    );
+    fixture.project(
+        "unselected",
+        "unselected",
+        ManifestDeps { dev: &[(PARENT, "100.0.0")], ..Default::default() },
+    );
+    fixture.run(["install"]);
+    assert!(
+        fixture.workspace
+            .join("node_modules")
+            .join(HELLO)
+            .is_dir(),
+    );
+    assert!(
+        fixture.workspace
+            .join("node_modules")
+            .join(NO_DEPS)
+            .is_dir(),
+    );
+    assert!(
+        fixture.workspace
+            .join("node_modules")
+            .join(PARENT)
+            .is_dir(),
+    );
+
+    fixture.run(["--filter", "selected", "install", "--prod"]);
Evidence
The checklist requires invariant coverage across isolated and hoisted linkers, full and sparse
checkouts, all dependency groups, and workspace, link, and injected file chains. The added tests
cover a hoisted --prod case and freshness scenarios, but the changed test code contains no
isolated-linker, sparse-checkout, --dev, or --no-optional scenario.

Cover filtered-install scope and linker invariants
pnpm/crates/cli/tests/suite/install_filters/warm_install.rs[60-197]
pnpm/crates/package-manager/src/hoisted_selection/tests.rs[65-143]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The filtered-install regression tests cover hoisted `--prod` behavior and freshness changes, but omit the required isolated-linker, sparse-checkout, `--dev`, and `--no-optional` combinations.

## Fix Focus Areas
- pnpm/crates/cli/tests/suite/install_filters/warm_install.rs[60-197]
- pnpm/crates/package-manager/src/hoisted_selection/tests.rs[65-143]

## Recommended Fix
Add invariant tests that exercise both isolated and hoisted linkers, full and sparse workspaces, every dependency-group selection including `--dev` and `--no-optional`, and workspace, `link:`, and injected `file:` chains. Assert selected and unselected disk materialization, current and wanted lockfile importer groups, and recorded installation state for each relevant combination.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. Partial runs can lose transitive optional dependencies ✓ Resolved
Description
closure_importer_ids now builds a materialization closure whenever
install.included().excludes_a_group(), even if the resolve pass did not widen any groups.
GroupSelection::classify(built, included) with optional_dependencies: false makes
collect_reachable drop every snapshot-level optional edge. A non-full run that narrows
dependency_groups to leave out Optional, which the existing comment says must keep its transitive
optionals (include_transitive_optional_dependencies is true when !is_full_install), previously
got no closure and installed all of built. It now drops the transitive optional dependencies of
its included packages.
Code

pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[R371-376]

+            (install.resolve_widened_groups() || install.included().excludes_a_group()).then(|| {
+                built.importers
+                    .keys()
+                    .cloned()
+                    .collect()
+            })
Relevance

●●● Strong

The new closure trigger contradicts the documented partial-install requirement to retain transitive
optional dependencies.

PR-#12965
PR-#15480

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
include_transitive_optional_dependencies returns `!is_full_install ||
included.optional_dependencies, so partial runs keep transitive optionals. mode.included` comes
from dependency_groups, so a narrowed partial run has optional_dependencies: false. The new
excludes_a_group() trigger gives such a run a closure that materialization_closure walks with
that selection. visit_snapshot passes groups.included.optional_dependencies to
followed_entries, which drops optional child edges, so those snapshots leave the materialized
lockfile even though compute_fresh_skip_set was told to keep them.

pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[349-378]
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs[270-294]
pnpm/crates/deps-restorer/src/current_lockfile/reachability.rs[171-191]
pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[300-315]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `excludes_a_group()` trigger in `closure_importer_ids` builds a closure for partial runs whose `included.optional_dependencies` is false. The closure walk then drops transitive optional dependencies that partial runs are supposed to keep.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[34-63]
- pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[360-378]

## Recommended Fix
Only add the `excludes_a_group()` trigger for full installs (`install.projects.is_full_install`). Alternatively, when `include_transitive_optional_dependencies` is true, classify the closure's `GroupSelection` with transitive `optional_dependencies` forced to `true`. Add a test covering a non-full fresh run with narrowed groups.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Frozen checks miss injected metadata 🐞 Bug ≡ Correctness
Description
check_child_directory_dep_freshness ignores the child’s injected flag and treats missing package
metadata as acceptable unless its specifier starts with file: or workspace:. When a directory
dependency declares an injected workspace child using a semver range, a frozen freshness check can
accept its recorded local resolution even though the corresponding package metadata is absent.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[R307-309]

+        if is_declared_local_directory(spec) || spec.starts_with("workspace:") {
+            return Err(parent_dep.outdated());
+        }
Relevance

●●● Strong

Closely matches recent accepted fixes to this same freshness-check file for missed injected/metadata
edge cases.

PR-#17053
PR-#17042
PR-#17047

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
manifest_child_specs reads dependenciesMeta[name].injected into the fourth ChildSpec field,
which the new helper discards. The resolver documents that this flag selects a local file:
resolution even for an ordinary range; in frozen mode, child_is_fresh permits a resolution it
cannot judge, after which the new missing-metadata branch returns success for that range.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs[146-151]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs[229-247]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[287-310]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[337-359]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An injected workspace child can use a semver specifier while resolving to a local package. Frozen freshness checks currently accept its recorded resolution when the corresponding package metadata is missing.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[287-310]

## Recommended Fix
Retain the child tuple’s injected flag and return a stale result when metadata is missing for an injected child, regardless of whether its specifier begins with `file:` or `workspace:`. Add a frozen-check regression test using an injected child declared with a semver range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


7. Deep local dependency chains crash installs 🐞 Bug ⛨ Security
Description
check_child_directory_dep_freshness calls check_single_directory_dep_freshness recursively for
each distinct directory dependency, while visited prevents cycles but does not limit call-stack
depth. A repository with a sufficiently long chain of local package manifests and matching lockfile
snapshots can exhaust the install process stack during frozen or repeat-install freshness checks.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[R327-332]

+    check_single_directory_dep_freshness(
+        check,
+        |peer_name| snapshot_declares(parent_snapshot, peer_name),
+        &child_dep,
+        (snapshot, pkg_meta),
+        visited,
Relevance

●● Moderate

Recursion is intentional and cycle-safe, but stack exhaustion from adversarially deep unique chains
lacks decisive repository precedent.

PR-#16863
PR-#17053

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new child check is called for every fresh recorded child and calls back into the directory
check, which checks that child’s children in turn. The only termination guard shown is package-key
membership in visited; it stops repeated keys, not a long chain of unique keys.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[279-283]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[294-302]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[315-333]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[218-231]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Transitive directory freshness checking recurses once per dependency. A long, repository-controlled chain can exhaust the install process stack even though cycles are detected.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[279-283]
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[287-333]

## Recommended Fix
Replace recursive child traversal with an explicit worklist that carries each child’s parent context and shares the visited set. Keep the existing freshness and peer checks for every reached directory, and test a long chain.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (4)
8. Freshness checks repeat directory reads 🐞 Bug ➹ Performance
Description
check_directory_dependencies_freshness creates a new visited set per importer and recursively
checks every reachable directory dependency, including reading its manifest. Freshness checks run
independently for each workspace importer, so a chain of injected local packages causes the same
downstream manifests to be checked repeatedly, with quadratic work across the workspace.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[54]

+    let mut visited = HashSet::new();
Evidence
Every importer gets a separate traversal set, while the workspace freshness runner checks all
importers and the new recursive path reads and checks each reached local manifest.

pnpm/crates/package-manager/src/install/lockfile_freshness.rs[372-390]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[51-65]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[195-231]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[279-334]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Per-importer recursion repeats manifest reads and freshness checks for shared transitive directory dependencies in a workspace.
## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness.rs[372-390]
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[51-65]
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[287-334]
## Recommended Fix
Cache transitive validation across importer checks where the validation inputs are equivalent, including snapshot identity and any peer or configuration context that affects the result; retain per-traversal cycle detection.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


9. Filtered links lack Windows coverage 📜 Skill insight ▣ Testability
Description
The changed importer-link freshness logic resolves link targets with path joins and direct path
equality, while its new tests cover only POSIX paths such as link:../b and /ws/packages/b. A
Windows separator or drive-path case can therefore regress link freshness decisions without being
caught by the test suite.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[R196-215]

+pub(super) fn importer_link_satisfies(
+    dirs: &SpecDirs<'_>,
+    project_dir: &Path,
+    dep_name: &str,
+    spec: &str,
+    link_target: &str,
+) -> bool {
+    if super::is_declared_local_directory(spec) {
+        return true;
+    }
+    if let Some(target) = spec.strip_prefix("link:") {
+        return resolve_local_spec_path(project_dir, target)
+            == resolve_local_spec_path(project_dir, link_target);
+    }
+    let Some(workspace_spec) = spec.strip_prefix("workspace:") else {
+        return true;
+    };
+    if is_workspace_path(workspace_spec) {
+        return resolve_local_spec_path(project_dir, workspace_spec)
+            == resolve_local_spec_path(project_dir, link_target);
Evidence
The compliance checklist requires Windows-specific coverage when path parsing or link handling
changes. The PR changes importer link path resolution and repeat-install link dependency
propagation, but the added tests use only /ws/... paths and link:../b, with no Windows separator
or Windows-specific case.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[196-237]
pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift/tests.rs[42-65]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The importer `link:` freshness comparison and workspace link resolution were changed without tests covering Windows separators or Windows-specific paths.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[196-237]
- pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs[303-333]
- pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift/tests.rs[42-65]

## Recommended Fix
Add platform-aware tests for backslash-separated relative link targets and Windows absolute or drive-prefixed paths, asserting that equivalent paths are accepted and mismatched or unsafe paths are rejected. Include the same Windows-form coverage for optimistic repeat-install propagation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


10. Freshness checks now hit the filesystem for every workspace link 🐞 Bug ➹ Performance
Description
check_single_dep_spec_directory_freshness now sends every importer-level
ImporterDepVersion::Link dep to importer_link_satisfies. For workspace:<range> specs this
reaches target_manifest/target_dir_within_workspace, which canonicalizes the workspace root and
the target dir and stats/canonicalizes package.json again for every link of every importer. Before
this change, link deps returned Ok(()) straight away. The freshness check runs per importer on
frozen and repeat installs, so in a large monorepo the number of syscalls grows with importers ×
workspace deps, and the canonical workspace root is recomputed every time even though it never
changes during the check.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[R153-155]

+    if let pnpm_lockfile::ImporterDepVersion::Link(link_target) = &dep_spec.version {
+        return check_importer_link_freshness(check, &dep_str, &dep_spec.specifier, link_target);
    }
-    let Some(pkg_key) = dep_spec.version.resolved_key(dep_name) else {
Evidence
Link deps used to return early (removed lines). Now each one calls importer_link_satisfies →
target_dir_satisfies → target_manifest. That path calls std::fs::canonicalize(workspace_root),
canonicalize(target_dir), symlink_metadata and canonicalize(manifest_path) on every call. It
runs for every importer through check_importer_satisfies (manifest.rs:107).

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[196-237]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[275-318]
pnpm/crates/package-manager/src/install/lockfile_freshness/manifest.rs[105-109]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Importer-level `link:` freshness checks now canonicalize the workspace root, the target dir and the manifest path for every link dep of every importer. This runs on every frozen and repeat install.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[116-131]
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[196-237]
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[305-318]

## Recommended Fix
Compute the canonical workspace root once per freshness check, for example as a lazily initialized field passed through `SpecDirs`, instead of calling `canonicalize` on each link. When the range is `*`/`^`/`~` and the target is in `manifests_by_dir`, compare the name from memory before doing any filesystem work. Also consider memoizing results per resolved target dir within one check.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


11. Repeat-install checks rescan long chains 🐞 Bug ➹ Performance
Description
mark_importers_of_unproven_directory_deps runs full propagation passes until a fixpoint,
rebuilding the unproven list and comparing dependency paths against every unproven project on each
pass. When a changed project sits at the end of a workspace dependency chain, each pass can discover
only one more consumer, repeatedly scanning the workspace on the repeat-install path.
Code

pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs[242]

+    while propagate_unproven_directory_deps_pass(check.workspace_root, lockfile, stats) {}
Evidence
The new loop repeats a pass that snapshots all unproven projects, scans proven importers, and tests
each dependency against the unproven list; projects marked during a pass enter that list only on the
next pass.

pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs[225-286]
pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs[289-335]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Fixpoint propagation repeatedly scans all project dependencies and all unproven projects, making long workspace chains expensive on the repeat-install path.
## Fix Focus Areas
- pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs[225-286]
- pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs[289-335]
## Recommended Fix
Build a reverse directory-dependency index once, including publish-directory targets, then traverse affected consumers with a queue and visited set.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Informational

12. Filtered hoisted installs copy the whole lockfile 🐞 Bug ➹ Performance
Description
retained_prior_importers calls lockfile.clone() before checking whether any prior importer needs
retention, copying the full package and snapshot maps just to replace importers for a second
materialization_closure walk. Every filtered hoisted install with a prior lockfile reaches this
path in the frozen scope or in both the initial and final fresh-plan scopes, so large workspaces
incur full-map copies even when no importer is retained.
Code

pnpm/crates/package-manager/src/hoisted_selection.rs[R71-73]

+    let mut retained_source = lockfile.clone();
+    let mut retained_ids = HashSet::new();
+    retained_source.importers = prior.importers
Evidence
In retained_prior_importers, the full clone occurs before the empty-retention check, and only its
importers map is changed before the read-only materialization_closure call.
selected_materialization_closure is invoked from the frozen materialization path and from both the
initial and final fresh-plan phases, with a second reachability walk when retention is nonempty.

pnpm/crates/package-manager/src/hoisted_selection.rs[40-86]
pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[41-99]
pnpm/crates/package-manager/src/hoisted_selection.rs[48-85]
pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[41-63]
pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[78-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`retained_prior_importers` deep-clones the full lockfile, including packages and snapshots, before checking for retained importers, solely to supply a different importer map to the retained closure. Fresh filtered hoisted installs repeat this preparation in initial and final scopes.

## Fix Focus Areas
- pnpm/crates/package-manager/src/hoisted_selection.rs[66-86]
- pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs[38-99]

## Recommended Fix
Determine retained importer IDs before allocating a source lockfile. Supply the retained importer map to `materialization_closure` while sharing or borrowing the original package and snapshot maps, for example through an importer-override parameter, or construct only the importer and graph data needed for the retained closure. Avoid repeating unchanged preparation between the initial and final fresh-plan scopes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 62 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: 🚀 Fast: Localized freshness predicate change with contained behavioral impact.
✅ Fix-loop round: fix loop

Grey Divider

Tip of the day
💡 Did you know, you can import rules and skills only from the repositories your team follows

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 9910b71

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate linked local dependency targets

Validate file: link targets against resolved paths instead of returning true
unconditionally.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs [203-205]

+if let Some(target) = spec.strip_prefix("file:") {
+    return workspace_path_matches_target(
+        dirs,
+        &resolve_local_spec_path(project_dir, target),
+        &resolve_local_spec_path(project_dir, link_target),
+    );
+}
 if super::is_declared_local_directory(spec) {
     return true;
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 7

__

Why: Checking the link target for file: dependencies rather than unconditionally returning true prevents invalid cache hits during filtered repeat installs.

Medium
Prune excluded links in selected projects

Restore pruning for excluded dependency groups in selected projects. Pass
selected importer IDs and requested groups to apply the correct dependency
groups.

pnpm/crates/deps-restorer/src/prune_stale_modules.rs [293]

-let wanted_specs = direct_deps_of(wanted_snapshot, &RECORDED_GROUPS);
+let groups = if selected_importer_ids
+    .is_none_or(|ids| ids.contains(importer_id))
+{
+    included_groups
+} else {
+    &RECORDED_GROUPS
+};
+let wanted_specs = direct_deps_of(wanted_snapshot, groups);

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out a potential issue with pruning behavior for selected importers when applying --prod or --dev filters.

Medium
  • Update

Previous suggestions

Suggestions up to commit 0ae65e6
CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve group-aware pruning for selected importers

Restore group-aware pruning by using the requested included_groups for selected
importers.

pnpm/crates/deps-restorer/src/prune_stale_modules.rs [276-293]

 pub(crate) fn prune_stale_hoisted_direct_links(
     ...
     current_lockfile: &Lockfile,
+    included_groups: &[DependencyGroup],
+    selected_importer_ids: Option<&std::collections::HashSet<String>>,
 ) -> Result<(), PruneDirectDepsError> {
     ...
-    let wanted_specs = direct_deps_of(wanted_snapshot, &RECORDED_GROUPS);
+    let wanted_groups = if selected_importer_ids
+        .is_none_or(|ids| ids.contains(importer_id))
+    {
+        included_groups
+    } else {
+        &RECORDED_GROUPS
+    };
+    let wanted_specs = direct_deps_of(wanted_snapshot, wanted_groups);
Suggestion importance[1-10]: 7

__

Why: The change to unconditionally use &RECORDED_GROUPS instead of the requested groups may incorrectly skip pruning of unneeded dependencies when running with --prod or --dev.

Medium
Preserve overlapping optional exclusions

Track optional exclusions separately when they overlap with installability
skips.

pnpm/crates/deps-restorer/src/installability/skipped_snapshots.rs [128-233]

-    if self.installability.contains(&key) || self.fetch_failed.contains(&key) {
+    if self.installability.contains(&key) {
+        self.deferred_optional_excluded.insert(key);
         return;
     }
-    self.optional_excluded.insert(key);
+    if !self.fetch_failed.contains(&key) {
+        self.optional_excluded.insert(key);
+    }
 ...
-    self.installability.remove(key);
+    if self.installability.remove(key) && self.deferred_optional_excluded.remove(key) {
+        self.optional_excluded.insert(key.clone());
+    }
Suggestion importance[1-10]: 3

__

Why: Tracking overlapping optional exclusions separately might prevent edge cases where snapshots are improperly installed, though it adds complexity to the state management.

Low
Suggestions up to commit d9c5dd8
CategorySuggestion                                                                                                                                    Impact
Possible issue
Respect selected groups in current lockfile

Revert the change to groups to properly respect the selected groups in the
current lockfile.

pnpm/crates/deps-restorer/src/install_frozen_lockfile.rs [464-471]

-crate::filter_lockfile_for_current(
-    self.lockfiles.wanted,
-    &self
-        .inputs()
-        .groups()
-        .with_all_importer_groups(),
-    skipped,
-)
+crate::filter_lockfile_for_current(self.lockfiles.wanted, self.inputs().groups(), skipped)
Suggestion importance[1-10]: 7

__

Why: Reverting to the old groups() avoids incorrectly retaining uninstalled dev snapshots during a --prod install.

Medium
Suggestions up to commit 4e334ff
CategorySuggestion                                                                                                                                    Impact
Possible issue
Check shared dependencies in every context

Remove items from the visited set after checking to allow re-evaluation in
different peer contexts.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs [184-190]

-check_single_directory_dep_freshness(
+let result = check_single_directory_dep_freshness(
     check,
     |name| importer_declares(importer, name),
     &dep,
     (snapshot, pkg_meta),
     visited,
-)
+);
+visited.remove(&pkg_key);
+result
Suggestion importance[1-10]: 8

__

Why: The suggestion identifies a highly impactful logical flaw regarding peer dependency resolution caching and cycle detection across multiple traversal paths.

Medium
Suggestions up to commit a4ebc79
CategorySuggestion                                                                                                                                    Impact
Possible issue
Visit only confirmed directory dependencies

Move the visited.insert(pkg_key) check to after confirming the dependency's
metadata exists and resolves to a directory. This prevents non-directory
dependencies or dependencies with missing metadata from falsely claiming a
visit.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs [300-314]

-if !visited.insert(pkg_key.clone()) {
-    return Ok(());
-}
 let Some(pkg_meta) = check.lockfile.packages
     .as_ref()
     .and_then(|packages| packages.get(&pkg_key.without_peer()))
 else {
     if is_declared_local_directory(spec) || spec.starts_with("workspace:") {
         return Err(parent_dep.outdated());
     }
     return Ok(());
 };
 let pnpm_lockfile::LockfileResolution::Directory(dir_res) = &pkg_meta.resolution else {
     return Ok(());
 };
+if !visited.insert(pkg_key.clone()) {
+    return Ok(());
+}
Suggestion importance[1-10]: 9

__

Why: Delaying the insertion of pkg_key into visited until after verifying that the package metadata exists and its resolution is a directory correctly handles missing metadata errors and avoids incorrectly marking non-directory dependencies as visited.

High
Propagate changed publishing directories

Simplify the unproven directory check to verify if the dependency directory
starts with the unproven directory. This prevents consumers from erroneously
being marked as proven if a project changes its publish directory.

pnpm/crates/package-manager/src/optimistic_repeat_install/freshness/drift.rs [332-339]

-.any(|(unproven_dir, unproven_manifest)| {
-    dep_dir == *unproven_dir
-        || pnpm_package_manifest::publishes_from_directory(
-            unproven_dir,
-            unproven_manifest,
-            &dep_dir,
-        )
-})
+.any(|(unproven_dir, _)| dep_dir.starts_with(unproven_dir))
Suggestion importance[1-10]: 8

__

Why: Checking if the dependency directory starts with the unproven directory avoids issues when a project changes its publishConfig.directory, ensuring stale consumers are properly marked unproven.

Medium
Preserve peer-edge classification during installation

Replace GroupSelection::all() with a method that preserves the
skipped_peer_edges context. This prevents changes to how peer edges are
traversed during filtered hoisted installs.

pnpm/crates/package-manager/src/install/materialize/frozen.rs [188]

-crate::GroupSelection::all()
+groups.with_all_groups_preserving_peer_edges()
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that GroupSelection::all() loses the skipped_peer_edges context, though the specific proposed method name is not defined in the PR, making it a conceptually valid but slightly inaccurate fix.

Low
Suggestions
CategorySuggestion                                                                                                                                    Impact
Possible issue
Reject incomplete transitive local resolutions

Return an error when transitive local dependencies lack package metadata to
ensure they are properly re-resolved.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs [306-311]

 let Some(pkg_meta) = check.lockfile.packages
     .as_ref()
     .and_then(|packages| packages.get(&pkg_key.without_peer()))
 else {
+    if is_declared_local_directory(spec) || spec.starts_with("workspace:") {
+        return Err(parent_dep.outdated());
+    }
     return Ok(());
 };
Suggestion importance[1-10]: 8

__

Why: It correctly identifies a logic gap where a missing package metadata for a local dependency incorrectly verifies it as fresh, preventing necessary re-resolution.

Medium
Keep skip categories disjoint

Remove the key from transient subsets before adding it to installability to
maintain the disjoint-subset invariant.

pnpm/crates/deps-restorer/src/installability/skipped_snapshots.rs [217-219]

+self.fetch_failed.remove(&key);
+self.optional_excluded.remove(&key);
 self.installability.insert(key);
Suggestion importance[1-10]: 7

__

Why: This enforces the documented disjoint-subset invariant for skipped snapshots, preventing potential logic errors in downstream processing.

Medium

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                    pr
-----                                            ----                                    --
lockfile/parse_pnpm_lock                         1.00     16.8±1.98ms    22.3 MB/sec     1.43     23.9±3.69ms    15.6 MB/sec
packument/parse                                  1.00     42.7±1.07µs  1553.6 MB/sec     1.06     45.3±3.30µs  1464.2 MB/sec
tarball/download_dependency                      1.00  1166.3±198.64µs     3.6 MB/sec    1.13  1316.6±426.15µs     3.2 MB/sec
tarball_batch/cold_store_many_medium_tarballs    1.07   276.6±24.58ms 57.9 KElem/sec     1.00   258.9±20.61ms 61.8 KElem/sec
version_pick/repeated_ranges_file                1.04      5.4±1.86ms  5.8 KElem/sec     1.00      5.2±0.68ms  6.0 KElem/sec
version_pick/repeated_ranges_raw                 1.02      5.1±0.50ms  6.1 KElem/sec     1.00      5.1±0.66ms  6.2 KElem/sec
workspace_resolution/hoist_heavy                 1.00  600.5±172.16ms        ? ?/sec     1.08   649.2±89.18ms        ? ?/sec
workspace_sort/chained_projects                  1.00     20.6±4.36ms        ? ?/sec     1.87    38.5±11.86ms        ? ?/sec

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2741.45 ms 2813.10 ms 2.6% 137.07 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1540.83 ms 1479.34 ms -4.0% 77.04 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 347.70 ms 329.98 ms -5.1% 17.38 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 380.23 ms 377.38 ms -0.8% 19.01 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 11.76 ms 11.40 ms -3.1% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 15.65 ms 13.18 ms -15.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 14.27 ms 13.34 ms -6.6% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 13.53 ms 14.04 ms 3.8% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 4356.90 ms 3541.17 ms -18.7% 217.85 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 2218.58 ms 2147.72 ms -3.2% 110.93 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 656.21 ms 1201.23 ms 83.1% 32.81 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 372.62 ms 352.58 ms -5.4% 18.63 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 2232.16 ms 2206.51 ms -1.1% 111.61 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 475.06 ms 436.45 ms -8.1% 23.75 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 359.81 ms 387.71 ms 7.8% 17.99 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 118.51 ms 115.09 ms -2.9% 5.93 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 288.84 ms 305.35 ms 5.7% 14.44 ms Inconclusive (overlapping samples)
isolated-linked-workspace-resolve-hot-cache-offline pacquet 305.25 ms 291.90 ms -4.4% 15.26 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 107.31 ms 115.67 ms 7.8% 5.37 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 5060.09 ms 5186.63 ms 2.5% 253.00 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 4055.06 ms 3852.27 ms -5.0% 202.75 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 225.52 ms 235.41 ms 4.4% 11.28 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 265.39 ms 289.04 ms 8.9% 13.27 ms Inconclusive (overlapping samples)
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 2215.22 ms 1769.50 ms -20.1% 110.76 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 9910b71c93dd

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked and injected workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.817 ± 0.138 2.613 3.100 1.82 ± 0.17
pacquet@main 2.765 ± 0.060 2.715 2.905 1.79 ± 0.15
pnpr@HEAD 1.544 ± 0.124 1.454 1.786 1.00
pnpr@main 1.564 ± 0.105 1.427 1.731 1.01 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.8173332682199996,
      "stddev": 0.13754910681048368,
      "median": 2.8130970587200004,
      "user": 2.6617595999999994,
      "system": 1.9872439399999997,
      "min": 2.61301001722,
      "max": 3.10039031222
    },
    {
      "command": "pacquet@main",
      "mean": 2.7654994413200003,
      "stddev": 0.059841738297897386,
      "median": 2.74144785072,
      "user": 2.6980475999999998,
      "system": 1.9169491399999998,
      "min": 2.71530122822,
      "max": 2.90451241722
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5443710075200001,
      "stddev": 0.12356151497754085,
      "median": 1.47933908222,
      "user": 2.1908323999999997,
      "system": 1.70584744,
      "min": 1.45375894122,
      "max": 1.78602364222
    },
    {
      "command": "pnpr@main",
      "mean": 1.56350599732,
      "stddev": 0.10545669572627549,
      "median": 1.54083246772,
      "user": 2.4558994999999992,
      "system": 1.8587413399999995,
      "min": 1.42742948022,
      "max": 1.7314876032200002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 356.1 ± 82.7 285.4 532.5 1.02 ± 0.25
pacquet@main 349.1 ± 31.6 306.6 401.0 1.00
pnpr@HEAD 381.0 ± 39.8 324.5 440.3 1.09 ± 0.15
pnpr@main 374.5 ± 31.7 326.4 423.3 1.07 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35607357262,
      "stddev": 0.08274498856341525,
      "median": 0.32997530661999996,
      "user": 0.40709928,
      "system": 0.73607406,
      "min": 0.28539608912000003,
      "max": 0.53245191412
    },
    {
      "command": "pacquet@main",
      "mean": 0.34908952252000003,
      "stddev": 0.03164475345815324,
      "median": 0.34769795162,
      "user": 0.41536777999999996,
      "system": 0.7683666599999999,
      "min": 0.30659984712,
      "max": 0.40098387912
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.38100801652000005,
      "stddev": 0.03978295375605648,
      "median": 0.37737600112,
      "user": 0.42606567999999995,
      "system": 0.7583055599999999,
      "min": 0.32454224312,
      "max": 0.44027828512
    },
    {
      "command": "pnpr@main",
      "mean": 0.37449873362,
      "stddev": 0.03165685510123672,
      "median": 0.38022867212,
      "user": 0.42346048,
      "system": 0.7521069600000001,
      "min": 0.32640224412,
      "max": 0.42333920312
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.6 ± 1.3 9.4 18.1 1.00
pacquet@main 12.2 ± 1.7 9.3 21.3 1.05 ± 0.18
pnpr@HEAD 13.9 ± 2.9 9.7 24.8 1.20 ± 0.28
pnpr@main 15.8 ± 1.5 12.7 20.2 1.36 ± 0.20
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.011626244868672572,
      "stddev": 0.0012521401181031671,
      "median": 0.01140247782,
      "user": 0.0067542867256637175,
      "system": 0.006022195221238943,
      "min": 0.00940134032,
      "max": 0.018104595320000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.01217412732,
      "stddev": 0.0016785003877083059,
      "median": 0.01176314132,
      "user": 0.007073140425531917,
      "system": 0.006269019744680856,
      "min": 0.00928237632,
      "max": 0.02132367732
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.013949209720862074,
      "stddev": 0.0028646940889332276,
      "median": 0.01317583282,
      "user": 0.007832989655172406,
      "system": 0.007358209482758616,
      "min": 0.00966051732,
      "max": 0.024828197320000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.015814951526250006,
      "stddev": 0.0015347789942331107,
      "median": 0.015647575820000002,
      "user": 0.00873585,
      "system": 0.008519133250000002,
      "min": 0.01267099832,
      "max": 0.020160090320000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 13.5 ± 1.5 10.3 18.1 1.02 ± 0.20
pacquet@main 14.2 ± 1.6 10.1 18.2 1.07 ± 0.21
pnpr@HEAD 14.1 ± 1.2 10.9 17.8 1.06 ± 0.20
pnpr@main 13.3 ± 2.2 8.7 18.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.013477064928070185,
      "stddev": 0.001509057183359422,
      "median": 0.013338396700000001,
      "user": 0.007683750760233917,
      "system": 0.007267122807017542,
      "min": 0.010262743700000002,
      "max": 0.0181163207
    },
    {
      "command": "pacquet@main",
      "mean": 0.014241470437864084,
      "stddev": 0.0016283521301596756,
      "median": 0.014273777700000002,
      "user": 0.0077981343689320325,
      "system": 0.007989861165048542,
      "min": 0.010098683700000001,
      "max": 0.0182318927
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.014110254298958342,
      "stddev": 0.001192382567899571,
      "median": 0.014041497700000002,
      "user": 0.007094462291666666,
      "system": 0.008577421875000003,
      "min": 0.010944163700000002,
      "max": 0.0177796607
    },
    {
      "command": "pnpr@main",
      "mean": 0.01326442914594595,
      "stddev": 0.0021746151708075703,
      "median": 0.0135298477,
      "user": 0.007028124594594595,
      "system": 0.007596210810810812,
      "min": 0.008709961700000001,
      "max": 0.0180124617
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.747 ± 0.582 3.073 4.980 1.70 ± 0.30
pacquet@main 4.383 ± 0.365 3.786 5.027 1.99 ± 0.24
pnpr@HEAD 2.270 ± 0.290 2.034 2.939 1.03 ± 0.16
pnpr@main 2.198 ± 0.193 1.888 2.568 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.74702765612,
      "stddev": 0.582290822144838,
      "median": 3.5411730533199997,
      "user": 4.5511713799999995,
      "system": 3.0986822399999996,
      "min": 3.07310586832,
      "max": 4.97975582132
    },
    {
      "command": "pacquet@main",
      "mean": 4.383349313320001,
      "stddev": 0.36483091270767437,
      "median": 4.35690189832,
      "user": 5.006183179999999,
      "system": 3.4465125399999996,
      "min": 3.78601567832,
      "max": 5.02718923032
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.26979911022,
      "stddev": 0.29029543790031065,
      "median": 2.1477208498199998,
      "user": 2.9534019799999998,
      "system": 2.5754154399999996,
      "min": 2.0342094723199997,
      "max": 2.93915303732
    },
    {
      "command": "pnpr@main",
      "mean": 2.19799609992,
      "stddev": 0.193206810823257,
      "median": 2.2185756683199997,
      "user": 2.9034322799999996,
      "system": 2.4786012399999997,
      "min": 1.88822068332,
      "max": 2.56799242632
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.153 ± 0.297 0.729 1.591 3.13 ± 0.89
pacquet@main 0.681 ± 0.065 0.605 0.783 1.85 ± 0.29
pnpr@HEAD 0.368 ± 0.045 0.318 0.448 1.00
pnpr@main 0.374 ± 0.029 0.335 0.423 1.02 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.15336786102,
      "stddev": 0.29696949977965426,
      "median": 1.20123332042,
      "user": 1.3990305600000001,
      "system": 1.2958869199999998,
      "min": 0.7290689234200001,
      "max": 1.59070047242
    },
    {
      "command": "pacquet@main",
      "mean": 0.6805257004199998,
      "stddev": 0.06487693452434977,
      "median": 0.6562054044200001,
      "user": 0.99411416,
      "system": 0.9775062200000001,
      "min": 0.60501331542,
      "max": 0.7826863004200001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.36824161592000004,
      "stddev": 0.045151333281207906,
      "median": 0.35257768242000004,
      "user": 0.30334046,
      "system": 0.6810896199999998,
      "min": 0.31768863842000006,
      "max": 0.44758993042000006
    },
    {
      "command": "pnpr@main",
      "mean": 0.37377092572000004,
      "stddev": 0.029312025674764406,
      "median": 0.37261640792000006,
      "user": 0.33610936,
      "system": 0.6810202200000001,
      "min": 0.33531674442000003,
      "max": 0.42268785242000007
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.210 ± 0.122 2.035 2.427 5.02 ± 0.43
pacquet@main 2.220 ± 0.223 1.903 2.516 5.04 ± 0.60
pnpr@HEAD 0.441 ± 0.029 0.392 0.484 1.00
pnpr@main 0.477 ± 0.042 0.414 0.573 1.08 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.2102395182200003,
      "stddev": 0.12228492526129556,
      "median": 2.20651400482,
      "user": 1.8466484199999997,
      "system": 1.4814891600000002,
      "min": 2.03504730232,
      "max": 2.4268963653199997
    },
    {
      "command": "pacquet@main",
      "mean": 2.22034140602,
      "stddev": 0.2228682497795038,
      "median": 2.23215886832,
      "user": 1.8909732199999998,
      "system": 1.5484805600000002,
      "min": 1.9029107543200001,
      "max": 2.51592980032
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.44061929052000004,
      "stddev": 0.028822818247788675,
      "median": 0.43645121732000003,
      "user": 0.41656502,
      "system": 0.7889882600000001,
      "min": 0.39218482132000004,
      "max": 0.48435863232000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.4765964189200001,
      "stddev": 0.04215277579227875,
      "median": 0.47505680532000005,
      "user": 0.4621438200000001,
      "system": 0.82932356,
      "min": 0.41380581032,
      "max": 0.57312974432
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 387.9 ± 44.8 324.6 445.3 3.35 ± 0.43
pacquet@main 357.0 ± 29.0 306.5 392.0 3.08 ± 0.30
pnpr@HEAD 115.9 ± 6.3 105.9 129.5 1.00
pnpr@main 119.3 ± 6.5 107.4 131.4 1.03 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.38789880424,
      "stddev": 0.0448338960650548,
      "median": 0.38770851804,
      "user": 0.3761905,
      "system": 0.16432974,
      "min": 0.32463232004,
      "max": 0.44528189904
    },
    {
      "command": "pacquet@main",
      "mean": 0.35699295514,
      "stddev": 0.02900944340983766,
      "median": 0.35980786454,
      "user": 0.3598528,
      "system": 0.12857864,
      "min": 0.30651889204,
      "max": 0.39199176904
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11589631378074074,
      "stddev": 0.006282017575623161,
      "median": 0.11509214304,
      "user": 0.05329053333333333,
      "system": 0.020776380740740744,
      "min": 0.10587191104,
      "max": 0.12947601404
    },
    {
      "command": "pnpr@main",
      "mean": 0.1192661909566667,
      "stddev": 0.006486873735522727,
      "median": 0.11851377804,
      "user": 0.053771491666666664,
      "system": 0.024795764999999994,
      "min": 0.10737091204,
      "max": 0.13139835004000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 315.4 ± 40.4 264.3 386.0 1.08 ± 0.17
pacquet@main 292.1 ± 24.6 264.8 343.5 1.00
pnpm@HEAD 6792.0 ± 1399.5 4672.7 9037.3 23.25 ± 5.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.31542935270444444,
      "stddev": 0.040378121395404275,
      "median": 0.30534989726,
      "user": 0.3203231644444445,
      "system": 0.06870454,
      "min": 0.26431758026,
      "max": 0.38599321926
    },
    {
      "command": "pacquet@main",
      "mean": 0.2921410985933333,
      "stddev": 0.024632422353248806,
      "median": 0.28884065526,
      "user": 0.3087844977777778,
      "system": 0.06362176222222221,
      "min": 0.26478784026,
      "max": 0.34354287726000005
    },
    {
      "command": "pnpm@HEAD",
      "mean": 6.791953970593334,
      "stddev": 1.399513704130931,
      "median": 6.59163152126,
      "user": 10.167228386666666,
      "system": 0.6869367622222221,
      "min": 4.67267637426,
      "max": 9.03727617626
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 296.2 ± 20.4 264.6 320.7 1.00
pacquet@main 301.7 ± 30.0 258.2 355.5 1.02 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29616218584,
      "stddev": 0.020401459875213548,
      "median": 0.2919006122400001,
      "user": 0.24228196,
      "system": 0.1127063,
      "min": 0.26462195274000005,
      "max": 0.32069605374000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.30174966074000015,
      "stddev": 0.030002229331268792,
      "median": 0.30524987574000007,
      "user": 0.24224286,
      "system": 0.1189775,
      "min": 0.25824791174000006,
      "max": 0.35553065874000006
    }
  ]
}

Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 115.8 ± 13.6 94.8 148.6 1.04 ± 0.18
pacquet@main 111.3 ± 13.6 96.4 150.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.11582503297517242,
      "stddev": 0.013566404618583357,
      "median": 0.11567319232,
      "user": 0.04790035310344827,
      "system": 0.07841247310344827,
      "min": 0.09482188132000001,
      "max": 0.14861220932000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.11129983736000001,
      "stddev": 0.01360937791117549,
      "median": 0.10730750232000001,
      "user": 0.04488152,
      "system": 0.07588204,
      "min": 0.09638950332,
      "max": 0.15015739932000002
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 5.222 ± 0.269 4.814 5.833 1.36 ± 0.08
pacquet@main 5.166 ± 0.305 4.959 5.993 1.34 ± 0.09
pnpr@HEAD 3.854 ± 0.102 3.705 4.048 1.00
pnpr@main 4.083 ± 0.147 3.899 4.377 1.06 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 5.222220158439999,
      "stddev": 0.268602080057771,
      "median": 5.18662915094,
      "user": 3.31829584,
      "system": 2.6989113999999996,
      "min": 4.81442120444,
      "max": 5.83313229944
    },
    {
      "command": "pacquet@main",
      "mean": 5.16564573944,
      "stddev": 0.3050150533344932,
      "median": 5.06008852944,
      "user": 3.36956104,
      "system": 2.5333596,
      "min": 4.958734246440001,
      "max": 5.99302724944
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.8537071090399997,
      "stddev": 0.10209678218312901,
      "median": 3.8522706954400006,
      "user": 2.73746264,
      "system": 2.2381891,
      "min": 3.70541488444,
      "max": 4.04804781044
    },
    {
      "command": "pnpr@main",
      "mean": 4.083246181740001,
      "stddev": 0.14739937968258077,
      "median": 4.0550559359400005,
      "user": 3.05365164,
      "system": 2.4082611999999997,
      "min": 3.8988298394400003,
      "max": 4.3769200144400005
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 240.7 ± 24.4 211.2 280.2 1.03 ± 0.15
pacquet@main 232.7 ± 24.3 205.7 291.6 1.00
pnpr@HEAD 290.7 ± 17.0 260.1 323.3 1.25 ± 0.15
pnpr@main 255.9 ± 35.6 190.7 287.4 1.10 ± 0.19
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24070414639666662,
      "stddev": 0.02436622215116465,
      "median": 0.23541369398,
      "user": 0.28854004666666666,
      "system": 0.24853228000000002,
      "min": 0.21119064348,
      "max": 0.28018090148
    },
    {
      "command": "pacquet@main",
      "mean": 0.23266975729818185,
      "stddev": 0.0242535661594325,
      "median": 0.22551633248,
      "user": 0.2981832436363636,
      "system": 0.20046446181818178,
      "min": 0.20572008948,
      "max": 0.29158696148
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29073794648,
      "stddev": 0.01696398197333264,
      "median": 0.28904318448,
      "user": 0.32955897999999995,
      "system": 0.27635528000000004,
      "min": 0.26008935148,
      "max": 0.32328162848
    },
    {
      "command": "pnpr@main",
      "mean": 0.25592394468,
      "stddev": 0.03555488663598997,
      "median": 0.26539433798,
      "user": 0.29848317999999996,
      "system": 0.26115998,
      "min": 0.19073538348,
      "max": 0.28737729848
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.795 ± 0.163 1.611 2.125 1.00
pacquet@main 2.188 ± 0.137 1.942 2.371 1.22 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.79494888852,
      "stddev": 0.16293331850329512,
      "median": 1.76950071272,
      "user": 1.2139343999999999,
      "system": 0.48056735999999994,
      "min": 1.61072558622,
      "max": 2.12469907622
    },
    {
      "command": "pacquet@main",
      "mean": 2.18821148702,
      "stddev": 0.13657237050180815,
      "median": 2.2152204817200003,
      "user": 1.3798476999999998,
      "system": 0.6329840599999998,
      "min": 1.94150290622,
      "max": 2.37094329122
    }
  ]
}

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Filtered hoisted installs now retain previously materialized dependency groups for unselected importers. Local dependency freshness checks now traverse nested directory dependencies and validate workspace links. Repeat-install freshness propagation now handles linked paths and transitive workspace changes.

Changes: Filtered install behavior

Layer / File(s) Summary
Build filtered materialization closures
pnpm/crates/package-manager/src/hoisted_selection.rs, pnpm/crates/package-manager/src/install_with_fresh_lockfile/plan.rs, pnpm/crates/package-manager/src/install/materialize*, pnpm/crates/deps-restorer/src/installability/*, pnpm/crates/package-manager/src/hoisted_selection/tests.rs, pnpm/crates/package-manager/src/install/run/importer_selection/tests.rs, pnpm/crates/package-manager/src/lib.rs, .changeset/*
The materialization closure combines selected importers with eligible prior groups for unselected importers. Frozen installation receives installer groups separately from the closure groups. Tests cover group retention and filtered importer selection.
Link all recorded dependency groups
pnpm/crates/deps-restorer/src/install_frozen_lockfile/*, pnpm/crates/deps-restorer/src/prune_stale_modules.rs, pnpm/crates/cli/tests/suite/install_filters/warm_install.rs
Hoisted linking, bin lookup, and stale-link pruning use all recorded dependency groups. CLI tests cover filtered --prod, --dev, and --no-optional installs, plus a missing sparse-checkout importer.
Check linked and transitive directory freshness
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps*
Freshness checks recursively inspect local directory dependencies, validate importer links against their specs, and use workspace-aware manifest lookup. Tests cover transitive dependencies, symlink boundaries, and missing sparse-checkout targets.
Propagate repeat-install freshness
pnpm/crates/package-manager/src/optimistic_repeat_install/*, pnpm/crates/cli/tests/suite/install_filters/warm_install.rs
Repeat-install checks propagate changed status across file and link dependencies. Stale linked packages produce a linked-package error; tests cover transitive injected changes and an incompatible workspace version.

Priority: ➖ Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant InstallWithFreshLockfilePlan
  participant SelectedMaterializationClosure
  participant FrozenMaterialization
  participant InstallFrozenLockfile
  InstallWithFreshLockfilePlan->>SelectedMaterializationClosure: selected importer IDs and prior hoisted lockfile
  SelectedMaterializationClosure-->>InstallWithFreshLockfilePlan: closure with retained importer groups
  InstallWithFreshLockfilePlan->>FrozenMaterialization: materialization scope and installer groups
  FrozenMaterialization->>InstallFrozenLockfile: lockfile and installer groups
Loading

Assessment against linked issues

Objective Addressed Explanation
Preserve prior dependency groups for unselected importers during filtered hoisted installs [#164] ✅
Retain off-disk importer lockfile data during filtered installs [#164] ✅
Detect transitive injected and linked workspace dependency changes during repeat installs [#164] ✅
Unify filtered-install scope across the pipeline, align install scope with verifyDepsBeforeRun, and add the proposed invariant oracle [#164] ❌ The diff does not implement the broader scope unification, verifyDepsBeforeRun alignment, or the proposed cross-mode invariant harness.

Possibly related PRs

  • pnpm/pnpm#13081: Adds workspace-importer lockfile freshness checks extended here with recursive local-directory checks and linked-package error handling.
  • pnpm/pnpm#13141: Adds SkippedSnapshots behavior extended here to retain optional snapshots for unselected importers.
  • pnpm/pnpm#15356: Adds directory-dependency freshness checks extended here with recursive traversal and workspace-link validation.

Suggested reviewers: altaywtf

Fixed issue severity: <fixed_issue_severity>Medium</fixed_issue_severity>

Merge Risk: ⚪ Minimal · up to 9910b

The change has no established merge-blocking risk; the allocation optimization can be addressed separately.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:01

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4f5e98e

@qodo-code-review

qodo-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Reject incomplete transitive local resolutions

Return an error when transitive local dependencies lack package metadata to
ensure they are properly re-resolved.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs [306-311]

 let Some(pkg_meta) = check.lockfile.packages
     .as_ref()
     .and_then(|packages| packages.get(&pkg_key.without_peer()))
 else {
+    if is_declared_local_directory(spec) || spec.starts_with("workspace:") {
+        return Err(parent_dep.outdated());
+    }
     return Ok(());
 };

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: It correctly identifies a logic gap where a missing package metadata for a local dependency incorrectly verifies it as fresh, preventing necessary re-resolution.

Medium
Keep skip categories disjoint

Remove the key from transient subsets before adding it to installability to
maintain the disjoint-subset invariant.

pnpm/crates/deps-restorer/src/installability/skipped_snapshots.rs [217-219]

+self.fetch_failed.remove(&key);
+self.optional_excluded.remove(&key);
 self.installability.insert(key);

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 7

__

Why: This enforces the documented disjoint-subset invariant for skipped snapshots, preventing potential logic errors in downstream processing.

Medium
  • More

Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:30

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…l deps under --filter

Unify filtered-install workspace scope, hoisted per-importer group
preservation, and local/linked dependency freshness checks
(Closes pnpm/tasks#164):

1. Preserve per-importer dependency groups in hoisted filtered installs:
   - Introduce `selected_materialization_closure`, which applies the CLI
     `GroupSelection` only to the selected importer closure and retains the
     dependency groups recorded in the prior current lockfile for unselected
     workspace projects.
   - Update frozen/fresh materialization, hoisted linking, workspace link
     creation, stale link pruning, and build-phase top-level bin linking to
     read retained per-importer groups from `scope.lockfile()`.

2. Keep `requested_importer_ids` whenever `--filter` was passed on the CLI:
   - In a sparse checkout where `--filter` matches every on-disk project while
     missing projects remain in `pnpm-lock.yaml`, `requested_importer_ids`
     still restricts materialization to the requested on-disk importers.

3. Check transitive local directory dependencies and importer `link:` ranges:
   - Recurse through `LockfileResolution::Directory` children in
     `check_directory_dependencies_freshness` (with cycle detection) so
     modifying a transitive injected/local package invalidates both
     `--frozen-lockfile` and the optimistic repeat-install fast path.
   - Verify importer-level `ImporterDepVersion::Link` entries against
     `workspace:` and `link:` specifiers in
     `check_single_dep_spec_directory_freshness`.
   - Fix `mark_importers_of_unproven_directory_deps` to handle
     `ImporterDepVersion::File` and `ImporterDepVersion::Link`, compare exact
     directory paths (or `publishConfig.directory`) rather than prefix-matching
     `"."`, and iterate to a fixpoint.
…fig.directory links

Keep optional: true on retained snapshots from unselected hoisted importers when
merging the filtered materialization closure under --no-optional, and pass
GroupSelection::all() once the closure has narrowed each importer's groups. Also
resolve publishConfig.directory link targets against their ancestor workspace
project manifest during lockfile link freshness checks.
…e root

- Allow loaded workspace projects declared via parent-relative patterns
  (such as ../libs/*) to pass link target freshness checks unless the
  project directory or its package.json escapes its own root via a
  symlink.
- Reject transitive local dependencies that lack package metadata in
  check_child_directory_dep_freshness.
- Remove transient skip entries when inserting a snapshot key into
  SkippedSnapshots::installability.
@qodo-code-review

Copy link
Copy Markdown

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

Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:33

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan
zkochan force-pushed the fix/filtered-install-scope-and-freshness branch from a4ebc79 to 4e334ff Compare October 19, 2026 18:33

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@zkochan zkochan closed this Oct 19, 2026
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 19, 2026
@zkochan
zkochan merged commit 7de0195 into main Oct 19, 2026
63 checks passed
@zkochan
zkochan deleted the fix/filtered-install-scope-and-freshness branch October 19, 2026 21:20
@qodo-code-review qodo-code-review Bot mentioned this pull request Nov 5, 2026
5 tasks done
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.

Unify filtered install workspace scope and fix hoisted/sparse-checkout/repeat-install bugs

3 participants