Skip to content

fix(package-manager): don't wipe node_modules on an included-deps change - #12676

Merged
zkochan merged 5 commits into
pnpm:mainfrom
YESHYUNGSEOK:fix/pacquet-purge-keep-user-files
Jul 4, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
YESHYUNGSEOK:fix/pacquet-purge-keep-user-files

Conversation

@YESHYUNGSEOK

@YESHYUNGSEOK YESHYUNGSEOK commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When .modules.yaml recorded a different included dependency set than
the current install wants — switching pnpm install --prod <-> a full
install, or toggling --no-optional — modules_consistent_with reported
node_modules inconsistent, which drives the purge that empties the
directory of everything except pnpm's own and dotfile entries. A user's
non-pnpm contents (a vendored directory, stray files placed directly in
node_modules) were deleted silently on that routine flag change.

pnpm never purges the root project's node_modules for an included
mismatch: its validateModules
only treats included drift as purge-worthy for non-root importers (the
lockfileDir !== rootDir guard), and an included change is satisfied by
relinking plus a targeted prune of the removed deps — not by wiping the
directory.

This splits the consistency check and adds the targeted prune:

  • The purge gate now uses modules_layout_consistent_with, which
    compares every layout-determining setting except included.
  • The up-to-date fast path keeps using modules_consistent_with
    (which still compares included), so a --prod<->full switch still
    forces a reinstall.
  • A new prune_direct_deps_excluded_by_groups pass runs exactly when
    the purge is skipped for an included drift: it diffs each importer's
    direct-dep names between the old and new group selections (via the
    current lockfile) and removes the now-excluded links and their
    .bin shims
    — mirroring pnpm's removeDirectDependency prune. So
    excluded dev deps do not stay resolvable after a --prod reinstall.
    Removal is conservative: importer keys are validated, aliases go
    through safe_join_modules_dir, only symlinks/junctions are removed
    (a user's real file or directory is never touched; hoisted-linker real
    directories are handled by its own orphan diff), and bin names come
    from the same sanitized set the shim writer uses.

The relink that follows re-creates everything the new selection wants,
so correctness of the switch is preserved while the directory — and the
user's own contents — are left intact.

Parity

pnpm already behaves this way (validateModules + the modules-cleaner
prune), so this is the pacquet side catching up — no TypeScript-side
change is needed. pnpm's pnpm:root removed / stats.removed emissions
remain unported (pacquet currently emits a hardcoded removed: 0
placeholder); that slice is unchanged here.

Squash Commit Body

When .modules.yaml recorded a different `included` set than the current
install wants (pnpm install --prod <-> full, or --no-optional),
modules_consistent_with reported the directory inconsistent, driving the
purge that empties node_modules of everything except pnpm's own and
dotfile entries. A user's non-pnpm contents were deleted silently.

pnpm never purges the root project's node_modules for an included
mismatch (validateModules's lockfileDir !== rootDir guard); an included
change is satisfied by relinking plus a targeted prune of the removed
deps.

Split the check: the purge gate uses modules_layout_consistent_with
(every layout setting except included); the up-to-date fast path keeps
modules_consistent_with (still compares included), so a --prod<->full
switch still forces a reinstall. A new prune pass
(prune_direct_deps_excluded_by_groups) runs when the purge is skipped
for an included drift and removes the now-excluded direct-dep links and
their .bin shims — mirroring pnpm's removeDirectDependency — so excluded
deps don't stay resolvable. Only symlinks/junctions are removed, so the
user's own node_modules contents are never touched.

Checklist

  • Added or updated tests.
  • Updated the documentation if needed (doc comments on the split check and the prune).

Written by an agent (Claude Code, claude-opus-4-8; revised by Claude Code, claude-fable-5).

@YESHYUNGSEOK
YESHYUNGSEOK requested a review from zkochan as a code owner June 26, 2026 02:09
@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 78ac3766-b3a3-4dd4-a6e1-7cc56308dcbb

📥 Commits

Reviewing files that changed from the base of the PR and between 3cf61e6 and 8f188f0.

📒 Files selected for processing (2)
  • pacquet/crates/package-manager/src/install.rs
  • pacquet/crates/package-manager/src/install/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pacquet/crates/package-manager/src/install.rs
  • pacquet/crates/package-manager/src/install/tests.rs

📝 Walkthrough

Walkthrough

The installer now treats .modules.yaml layout drift separately from included dependency-group drift when deciding whether to purge node_modules. Tests cover the layout-only consistency check and both drift cases.

Changes

Modules layout drift handling

Layer / File(s) Summary
Split layout and included checks
pacquet/crates/package-manager/src/install.rs
modules_consistent_with now checks included directly and delegates the remaining comparisons to modules_layout_consistent_with; the inconsistent node_modules branch now uses the layout-only helper for purge decisions.
Layout-only consistency tests
pacquet/crates/package-manager/src/install/tests.rs
Tests add a layout-only .modules.yaml wrapper and cover included-drift and layout-drift outcomes, including the install-level purge regression.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • pnpm/pnpm#11904: Both PRs change install-time gating logic that interprets .modules.yaml consistency, including how included or dependency-group fields affect reuse decisions.
  • pnpm/pnpm#12536: Both PRs adjust Install::run_inner and .modules.yaml consistency logic that decides when node_modules is purged on layout-related mismatches.

Suggested labels

product: pacquet

Suggested reviewers

  • zkochan
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Prevent node_modules purge when only included dependency set changes
🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Description

• Prevent node_modules purge when only .modules.yaml included-deps settings drift.
• Keep reinstall/relink behavior for --prod / --no-optional switches.
• Add regression tests covering included-only drift vs true layout drift.
Diagram

graph TD
A["Install::run"] --> B["Read .modules.yaml"] --> C{"Layout drift?"}
C -->|"yes"| D["Purge node_modules"]
C -->|"no"| E{"Included drift?"} -->|"yes"| F["Relink / reinstall deps"]
E -->|"no"| G["Up-to-date fast path"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Purge whitelist expansion
  • ➕ Keeps current single consistency predicate (less conceptual split).
  • ➕ Can preserve additional user-known safe paths beyond pnpm internals.
  • ➖ Hard to make safe/complete: unknown user entries are still at risk.
  • ➖ Still performs an unnecessary destructive operation for included-only drift.
2. Root-importer guard (pnpm-style)
  • ➕ Matches pnpm’s semantics directly: included drift purge only for non-root importers.
  • ➕ Keeps included in consistency, but avoids root wipe.
  • ➖ Requires reliably detecting root vs non-root importer contexts in pacquet.
  • ➖ More conditional complexity than a clean split between layout vs included checks.

Recommendation: The current split (layout-only check for purge, full check for fast-path) is the safest and simplest: it prevents silent data loss while preserving correctness by still forcing a relink/reinstall on included changes. The alternatives either remain risky (whitelist) or add importer-context complexity (root guard).

Files changed (2) +131 / -2

Bug fix (1) +25 / -2
install.rsSplit purge gate from included-deps consistency check +25/-2

Split purge gate from included-deps consistency check

• Changes the node_modules purge decision to use a new 'modules_layout_consistent_with' predicate that excludes 'included' drift. Refactors 'modules_consistent_with' to compose 'included' equality with the layout check, preserving the fast-path relink/reinstall behavior while preventing destructive purges on '--prod'/'--no-optional' toggles.

pacquet/crates/package-manager/src/install.rs

Tests (1) +106 / -0
tests.rsAdd regression tests for included-only drift vs layout drift +106/-0

Add regression tests for included-only drift vs layout drift

• Introduces a test helper that checks layout consistency (ignoring 'included'). Adds tests asserting that included-only drift fails the fast-path consistency check but still counts as layout-consistent, and that genuine layout drift (e.g., nodeLinker change) still marks the layout inconsistent.

pacquet/crates/package-manager/src/install/tests.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/package-manager/src/install/tests.rs`:
- Around line 5924-6006: The current tests only exercise the helper checks and
do not cover the real purge path in Install::run_inner, so add an install-level
regression that seeds a custom non-pnpm entry in node_modules, changes included
via the same setup used by
is_modules_yaml_consistent/is_modules_yaml_layout_consistent, runs the install
flow, and asserts the entry survives when only included drifts. Keep the
layout-drift case using Install::run_inner or the install path to confirm
genuine nodeLinker drift still triggers the destructive wipe. Use the existing
symbols Install::run_inner, is_modules_yaml_consistent, and
is_modules_yaml_layout_consistent to locate the relevant setup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a732afd2-fecc-4236-a15e-eb9d796d207a

📥 Commits

Reviewing files that changed from the base of the PR and between aea6ace and bcc5b3a.

📒 Files selected for processing (2)
  • pacquet/crates/package-manager/src/install.rs
  • pacquet/crates/package-manager/src/install/tests.rs

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (6) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. TOCTOU .bin delete escape 🐞 Bug ⛨ Security ⭐ New
Description
remove_dep_bins validates <modules_dir>/.bin once, then deletes shim paths by name; an attacker
who can mutate the workspace can race-replace .bin with a symlink/junction after the check and
before remove_bin, redirecting deletions outside node_modules. This is an arbitrary file
deletion risk because remove_bin ultimately uses plain std::fs::remove_file on the computed
path.
Code

pacquet/crates/package-manager/src/prune_direct_deps.rs[R234-246]

+    // Shims are deleted with plain `remove_file`, so a `.bin` that is
+    // itself a symlink or junction would redirect the deletions
+    // outside the confined modules dir — skip shim removal unless
+    // `.bin` is a real directory. (Absent `.bin` means no shims.)
+    let bins_dir = modules_dir.join(".bin");
+    if !is_real_dir(&bins_dir) {
+        return Ok(());
+    }
+    for command in get_bins_from_package_manifest::<Host>(&manifest, link) {
+        let shim_path = bins_dir.join(&command.name);
+        remove_bin(&shim_path)
+            .map_err(|error| PruneDirectDepsError::RemoveBin { path: shim_path, error })?;
+    }
Evidence
The prune code performs a one-time .bin directory safety check but then deletes by path, and
remove_bin uses std::fs::remove_file on the computed pathname; this creates a TOCTOU window
where swapping .bin after the check can redirect removals outside the confined directory.

pacquet/crates/package-manager/src/prune_direct_deps.rs[223-246]
pacquet/crates/package-manager/src/prune_direct_deps.rs[169-177]
pacquet/crates/cmd-shim/src/link_bins.rs[667-682]

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

## Issue description
`remove_dep_bins()` checks that `<modules_dir>/.bin` is a “real directory” and then deletes shims via path-based `remove_bin(bins_dir.join(name))`. This is a classic TOCTOU: `.bin` can be swapped (directory -> symlink/junction) after the check, and subsequent `remove_file` calls will follow the new `.bin` target, enabling deletion outside the intended tree.

## Issue Context
- The new prune path is intentionally safety-sensitive (it’s deleting files based on lockfile/manifests).
- `remove_bin()` deletes by pathname using `std::fs::remove_file`, with no directory-handle anchoring.

## Fix Focus Areas
- pacquet/crates/package-manager/src/prune_direct_deps.rs[223-246]
- pacquet/crates/cmd-shim/src/link_bins.rs[667-682]

### Suggested remediation approaches (pick one)
1) **FD-relative deletion (preferred)**: open `.bin` as a directory handle once (reject if it’s not a real dir), and delete entries via an `unlinkat`-style API relative to that handle (no pathname traversal through `.bin`).
2) **Re-validate per deletion (weaker but simpler)**: immediately before each `remove_bin` call, re-check that `.bin` is still a real directory and that its canonicalized path is still within the canonicalized `modules_dir`; skip deletion if it changed.

Also consider storing and comparing stable directory identity (inode/file-id) of `.bin` between check and deletes to detect swaps.

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


2. Prune skips path-safety guard 🐞 Bug ⛨ Security
Description
On included-only drift, Install::run invokes prune_direct_deps_excluded_by_groups without the
canonical-path “within workspace root” guard used by the purge path, so a symlink/junctioned
node_modules/.bin can make the prune delete files outside the workspace. This is a
symlink-traversal file-deletion risk because the prune removes shims via plain remove_file on
computed paths.
Code

pacquet/crates/package-manager/src/install.rs[R1126-1145]

+        // An included-only drift (`--prod`<->full, `--no-optional`)
+        // skips the purge above, so the direct-dep links the previous
+        // install created for now-excluded groups would linger — and
+        // stay resolvable — after the relink. Remove exactly those
+        // (plus their bin shims), leaving everything else in place.
+        if !resolve_only
+            && !is_inconsistent
+            && let Some(modules) = modules_manifest
+            && modules.included != included
+            && let Some(current) = current_lockfile.as_ref()
+        {
+            crate::prune_direct_deps_excluded_by_groups(
+                current,
+                modules.included,
+                included,
+                &workspace_root,
+                config,
+            )
+            .map_err(InstallError::PruneDirectDeps)?;
+        }
Evidence
The purge path explicitly canonicalizes config.modules_dir and verifies it stays under
workspace_root before deleting anything, but the new included-drift prune call has no equivalent
guard. The prune then removes bin shims by joining /.bin/ and calling remove_bin, which
ultimately deletes via std::fs::remove_file, so a symlinked/junctioned parent can redirect
deletions outside the workspace.

pacquet/crates/package-manager/src/install.rs[1041-1123]
pacquet/crates/package-manager/src/install.rs[1126-1145]
pacquet/crates/package-manager/src/prune_direct_deps.rs[150-189]
pacquet/crates/cmd-shim/src/link_bins.rs[659-683]
pacquet/crates/fs/src/symlink_dir.rs[89-104]

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 included-drift cleanup calls `prune_direct_deps_excluded_by_groups` without applying the same canonicalized workspace-root containment check used by the purge path. As a result, if `node_modules` (or `node_modules/.bin`) is a symlink/junction that resolves outside `workspace_root`, the prune can delete shim files (and symlinked dep entries) in that external location.
### Issue Context
The purge path already performs `canonicalize(modules_dir)` and refuses destructive operations when the canonical modules dir is outside the canonical workspace root. The included-drift prune should follow the same safety posture.
### Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[1126-1145]
- pacquet/crates/package-manager/src/prune_direct_deps.rs[150-189]
### What to change
1. Before calling `prune_direct_deps_excluded_by_groups`, add a workspace-root escape guard equivalent to the purge guard:
- Canonicalize `workspace_root` and the root importer’s modules dir (and/or each importer modules dir if you want stronger coverage).
- If the canonical modules dir is not under canonical workspace root, log a warning and skip pruning (mirroring the purge refusal).
2. Additionally harden bin-shim removal against a symlinked `.bin`:
- In `remove_dep_bins`, check `symlink_metadata` for `<modules_dir>/.bin`; if it exists and is a symlink/junction (or not a directory), skip shim removal (or restrict removal to safe directory types).
This keeps the new behavior (no wipe on included drift) while preserving the repository’s existing “don’t delete outside the workspace” security invariant.

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


3. Stale direct deps persist 🐞 Bug ⛨ Security
Description
After this change, an included-only drift (full � --prod / --no-optional) no longer triggers
the node_modules purge, but the relink path does not delete previously-created top-level
node_modules/ entries that are no longer in the selected dependency groups. This can leave
excluded direct dependencies still resolvable from node_modules in a production-mode install,
undermining the expected dependency surface and potentially shipping/using dev-only code.
Code

pacquet/crates/package-manager/src/install.rs[R1088-1091]

  let is_inconsistent = read_failed
      || match &modules_manifest {
-                Some(modules) => !modules_consistent_with(modules, config, node_linker, included),
+                Some(modules) => !modules_layout_consistent_with(modules, config, node_linker),
          // Treat existence-check errors conservatively as inconsistent.
Evidence
The PR changes the purge gate to ignore included, so an included-only drift will skip the only
code path that deletes existing node_modules entries. The relink step (direct-dependency linking)
only creates/updates symlinks for currently-selected dependency groups and does not include any
removal pass for entries that are no longer selected, so stale direct-dependency entries from a
previous mode can remain present.

pacquet/crates/package-manager/src/install.rs[1068-1101]
pacquet/crates/package-manager/src/install.rs[1099-1171]
pacquet/crates/package-manager/src/symlink_direct_dependencies.rs[378-517]

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

## Issue description
Switching dependency-group selection (e.g. full install � `--prod` or toggling `--no-optional`) no longer triggers the destructive `node_modules` purge (by design), but pacquet currently has no targeted cleanup to remove *previously-linked* top-level direct dependencies that are now excluded. That leaves stale `node_modules/<dep>` entries behind, so excluded packages can remain resolvable/usable even in production-mode installs.
## Issue Context
- The purge gate now uses `modules_layout_consistent_with` (ignores `included`), so included drift will not wipe `node_modules`.
- `SymlinkDirectDependencies` links the currently-selected groups but does not remove any other pre-existing entries under `<importer>/node_modules`.
- The only removal currently happening in the root `node_modules` tree is the purge branch (which no longer runs on included drift).
## Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[1084-1171]
- pacquet/crates/package-manager/src/symlink_direct_dependencies.rs[378-517]
### Suggested fix approach
When `.modules.yaml` exists and `modules.included != included` (i.e., included drift), do a *non-destructive direct-dep cleanup* before (or as part of) relinking:
1. Compute which dependency groups became excluded (old included `true` -> new included `false`).
2. For each importer, compute the direct dependency names belonging to those now-excluded groups using the lockfile importer maps.
3. Remove only those corresponding filesystem entries under `<importer>/node_modules`:
- Handle scoped packages (`@scope/name`) by unlinking `node_modules/@scope/name` and removing the `@scope` dir if it becomes empty.
- Only remove entries that look pacquet-managed (e.g., symlink/junction into the virtual store or a `link:` target), to avoid deleting user vendored directories/files.
This keeps the PR�s goal (preserve user files) while restoring the correctness/security contract that excluded groups are not present after a mode switch.

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



Remediation recommended

4. Redundant canonicalize in prune 🐞 Bug ➹ Performance
Description
prune_direct_deps_excluded_by_groups canonicalizes workspace_root once per importer via
confined_modules_dir, and also re-checks whether /.bin is a "real" directory for every removed
dependency. On large workspaces or dev→prod switches with many pruned deps, this adds avoidable
filesystem syscalls on an otherwise routine reinstall path.
Code

pacquet/crates/package-manager/src/prune_direct_deps.rs[R119-167]

+    for (importer_id, snapshot) in &current_lockfile.importers {
+        // A malformed importer key is rejected with a typed error by
+        // the symlink pass; never *delete* based on one.
+        if validate_importer_id(importer_id).is_err() {
+            continue;
+        }
+        // Same canonical containment check as the purge: delete only
+        // through a modules dir that resolves inside the workspace
+        // root, and operate on the canonicalized path so a symlink
+        // swap can't redirect the removals after the check.
+        let modules_dir = importer_root_dir(workspace_root, importer_id).join(modules_dir_name);
+        let Some(modules_dir) = confined_modules_dir(&modules_dir, workspace_root) else {
+            continue;
+        };
+        let new_names: HashSet<String> =
+            direct_dep_names_for_importer(snapshot, new_groups.iter().copied(), &skipped, false)
+                .into_iter()
+                .collect();
+        for name in
+            direct_dep_names_for_importer(snapshot, old_groups.iter().copied(), &skipped, false)
+        {
+            if new_names.contains(&name) {
+                continue;
+            }
+            remove_direct_dep_link(&modules_dir, &name)?;
+        }
+    }
+    Ok(())
+}
+
+/// Canonicalize `modules_dir` and require it to stay within
+/// `workspace_root` — the same containment check the purge applies
+/// before its destructive sweep. Returns the canonical path the
+/// removals should operate on, or `None` when there is nothing to
+/// prune (the directory doesn't exist) or when the resolution escapes
+/// the workspace — never delete through an escape.
+fn confined_modules_dir(modules_dir: &Path, workspace_root: &Path) -> Option<PathBuf> {
+    let modules_canon = std::fs::canonicalize(modules_dir).ok()?;
+    let root_canon = std::fs::canonicalize(workspace_root).ok()?;
+    if modules_canon.starts_with(&root_canon) {
+        Some(modules_canon)
+    } else {
+        tracing::warn!(
+            ?modules_dir,
+            "refusing to prune direct dependencies outside the workspace root",
+        );
+        None
+    }
+}
Evidence
The per-importer loop calls confined_modules_dir(), which canonicalizes workspace_root every
time. Shim removal checks .bin via is_real_dir() for each removed dep, and is_real_dir()
relies on read_symlink_dir() which may do additional syscalls (notably on Windows due to junction
handling).

pacquet/crates/package-manager/src/prune_direct_deps.rs[119-145]
pacquet/crates/package-manager/src/prune_direct_deps.rs[155-167]
pacquet/crates/package-manager/src/prune_direct_deps.rs[234-246]
pacquet/crates/fs/src/symlink_dir.rs[121-135]

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

## Issue description
`prune_direct_deps_excluded_by_groups()` performs redundant filesystem work:
- `confined_modules_dir()` canonicalizes `workspace_root` for every importer iteration.
- `.bin` “real directory” probing is repeated per removed dependency.
This is extra I/O on the `--prod`<->full / `--no-optional` drift path.
### Issue Context
This prune runs specifically to avoid destructive purges on `included` drift, so it can be triggered in everyday workflows. In large workspaces (many importers) and/or when many direct deps are removed, the repeated `canonicalize()` and repeated `.bin` checks can become noticeable.
### Fix Focus Areas
- pacquet/crates/package-manager/src/prune_direct_deps.rs[119-167]
- pacquet/crates/package-manager/src/prune_direct_deps.rs[238-246]
### Suggested approach
1. Canonicalize `workspace_root` once at the start of `prune_direct_deps_excluded_by_groups()` (e.g., `let root_canon = canonicalize(workspace_root)?;`) and pass `&root_canon` into a revised `confined_modules_dir()` that only canonicalizes `modules_dir`.
2. Compute whether `modules_dir/.bin` is a real directory once per importer (after `modules_dir` is known) and pass that boolean (or the validated bins dir path) into the per-dependency removal function so `is_real_dir(.bin)` isn’t re-run for every pruned dep.
3. Keep the same safety properties (no deletion through symlink/junctioned intermediates).

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


5. Stale .bin shims persist 🐞 Bug ≡ Correctness
Description
After this change, a --prod↔full included drift no longer triggers the node_modules purge, but
the bin-linking implementation only writes shims for the current set and does not remove shims that
are no longer selected. This can leave stale .bin/ entries from a previous install mode available
after relinking, causing prod-only installs to expose/execute commands that should have disappeared.
Code

pacquet/crates/package-manager/src/install.rs[R1084-1091]

+        // The purge keys off *layout* drift only, not `included`: an
+        // included (`--prod`<->full) change is handled by relinking, so it
+        // must not wipe the user's `node_modules` contents. See
+        // [`modules_layout_consistent_with`].
let is_inconsistent = read_failed
  || match &modules_manifest {
-                Some(modules) => !modules_consistent_with(modules, config, node_linker, included),
+                Some(modules) => !modules_layout_consistent_with(modules, config, node_linker),
      // Treat existence-check errors conservatively as inconsistent.
Evidence
The purge gate now ignores included, so included-only drift won’t enter the purge branch that
deletes .bin. The bin-linking implementation writes shims for the current chosen set but does not
remove any existing shims that are no longer chosen, so stale .bin entries can persist when the
purge is skipped.

pacquet/crates/package-manager/src/install.rs[1084-1097]
pacquet/crates/package-manager/src/install.rs[1130-1169]
pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[1747-1759]
pacquet/crates/package-manager/src/install_frozen_lockfile.rs[521-549]
pacquet/crates/package-manager/src/symlink_direct_dependencies.rs[508-514]
pacquet/crates/cmd-shim/src/link_bins.rs[301-358]
pacquet/crates/package-manager/src/prune_virtual_store.rs[11-16]

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

## Issue description
With the purge gate now ignoring `.modules.yaml.included`, `--prod`↔full switches won’t wipe `node_modules`. However, the current bin-linking path only creates/overwrites shims for bins that *exist in the newly chosen set* and does not remove shims that disappeared (or belonged to deps that are no longer linked). This can leave stale `.bin/*` shims from prior installs, changing command availability/behavior after an `included`-only reinstall.
### Issue Context
- The purge path is the only place that deletes `.bin` contents today, but it no longer runs for `included` drift.
- `pacquet_cmd_shim::link_bins_of_packages_with_excludes` writes shims for `chosen` but does not enumerate/remove existing entries in `bins_dir`.
### Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[1084-1097]
- pacquet/crates/cmd-shim/src/link_bins.rs[301-358]
- pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[1747-1759]
- pacquet/crates/package-manager/src/install_frozen_lockfile.rs[521-549]
### Suggested fix approach
Implement one of:
1) **Targeted `.bin` cleanup before relinking**: delete `<modules_dir>/.bin` (or enumerate and remove shims) at the start of the bin-link phases on reinstall paths, then re-link bins; or
2) **Prune-to-chosen behavior inside cmd-shim**: have `link_bins_of_packages_with_excludes` remove any existing shim files in `bins_dir` not present in `chosen` (respecting `exclude_bins`), potentially using the existing `remove_bin()` helper.
Add/adjust a regression test that seeds a `.bin/<devtool>` shim from a full install, switches to `--prod`, and asserts that the stale shim is removed (while non-pnpm user files in `node_modules/` remain intact).

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



Informational

6. Tests use two clients 🐞 Bug ⚙ Maintainability
Description
run_purge_regression_install constructs http_client and http_client_arc from two different
ThrottledClient instances, despite Install documenting they should come from the same source.
This makes the test setup less faithful to production (different internal client state), and can
make registry-backed tests harder to reason about.
Code

pacquet/crates/package-manager/src/install/tests.rs[R6031-6034]

+        tarball_mem_cache: Default::default(),
+        http_client: &Default::default(),
+        http_client_arc: std::sync::Arc::new(Default::default()),
+        config,
Evidence
The Install struct explicitly documents that the CLI builds both http_client and
http_client_arc from a single source, but the new test helper constructs them from two independent
Default::default() values.

pacquet/crates/package-manager/src/install.rs[99-107]
pacquet/crates/package-manager/src/install/tests.rs[6030-6034]

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

## Issue description
`run_purge_regression_install` builds `Install { http_client, http_client_arc }` from two separate default `ThrottledClient` instances. `Install`’s own documentation says the CLI builds both from a single source, so tests should mirror that to avoid subtle differences in behavior.
### Issue Context
This is test-only, but it reduces fidelity of the new install-level regression tests (and can complicate future debugging of intermittent network/throttling behavior).
### Fix Focus Areas
- pacquet/crates/package-manager/src/install/tests.rs[6030-6034]
- pacquet/crates/package-manager/src/install.rs[99-107]
### What to change
In `run_purge_regression_install`, construct the clients from a shared origin. For example:
- Create one base `ThrottledClient` configuration and derive both fields from it (e.g., by cloning if `ThrottledClient: Clone` and that clone shares underlying state), or
- Thread a pair `(http_client: &ThrottledClient, http_client_arc: Arc<ThrottledClient>)` into the helper from the caller (built once), to match the production wiring pattern.

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


Grey Divider

Previous review results

Review updated until commit bd0691d

Results up to commit bd0691d


🐞 Bugs (5) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Prune skips path-safety guard 🐞 Bug ⛨ Security
Description
On included-only drift, Install::run invokes prune_direct_deps_excluded_by_groups without the
canonical-path “within workspace root” guard used by the purge path, so a symlink/junctioned
node_modules/.bin can make the prune delete files outside the workspace. This is a
symlink-traversal file-deletion risk because the prune removes shims via plain remove_file on
computed paths.
Code

pacquet/crates/package-manager/src/install.rs[R1126-1145]

+        // An included-only drift (`--prod`<->full, `--no-optional`)
+        // skips the purge above, so the direct-dep links the previous
+        // install created for now-excluded groups would linger — and
+        // stay resolvable — after the relink. Remove exactly those
+        // (plus their bin shims), leaving everything else in place.
+        if !resolve_only
+            && !is_inconsistent
+            && let Some(modules) = modules_manifest
+            && modules.included != included
+            && let Some(current) = current_lockfile.as_ref()
+        {
+            crate::prune_direct_deps_excluded_by_groups(
+                current,
+                modules.included,
+                included,
+                &workspace_root,
+                config,
+            )
+            .map_err(InstallError::PruneDirectDeps)?;
+        }
Evidence
The purge path explicitly canonicalizes config.modules_dir and verifies it stays under
workspace_root before deleting anything, but the new included-drift prune call has no equivalent
guard. The prune then removes bin shims by joining /.bin/ and calling remove_bin, which
ultimately deletes via std::fs::remove_file, so a symlinked/junctioned parent can redirect
deletions outside the workspace.

pacquet/crates/package-manager/src/install.rs[1041-1123]
pacquet/crates/package-manager/src/install.rs[1126-1145]
pacquet/crates/package-manager/src/prune_direct_deps.rs[150-189]
pacquet/crates/cmd-shim/src/link_bins.rs[659-683]
pacquet/crates/fs/src/symlink_dir.rs[89-104]

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 included-drift cleanup calls `prune_direct_deps_excluded_by_groups` without applying the same canonicalized workspace-root containment check used by the purge path. As a result, if `node_modules` (or `node_modules/.bin`) is a symlink/junction that resolves outside `workspace_root`, the prune can delete shim files (and symlinked dep entries) in that external location.
### Issue Context
The purge path already performs `canonicalize(modules_dir)` and refuses destructive operations when the canonical modules dir is outside the canonical workspace root. The included-drift prune should follow the same safety posture.
### Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[1126-1145]
- pacquet/crates/package-manager/src/prune_direct_deps.rs[150-189]
### What to change
1. Before calling `prune_direct_deps_excluded_by_groups`, add a workspace-root escape guard equivalent to the purge guard:
 - Canonicalize `workspace_root` and the root importer’s modules dir (and/or each importer modules dir if you want stronger coverage).
 - If the canonical modules dir is not under canonical workspace root, log a warning and skip pruning (mirroring the purge refusal).
2. Additionally harden bin-shim removal against a symlinked `.bin`:
 - In `remove_dep_bins`, check `symlink_metadata` for `<modules_dir>/.bin`; if it exists and is a symlink/junction (or not a directory), skip shim removal (or restrict removal to safe directory types).
This keeps the new behavior (no wipe on included drift) while preserving the repository’s existing “don’t delete outside the workspace” security invariant.

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


2. Stale direct deps persist 🐞 Bug ⛨ Security
Description
After this change, an included-only drift (full � --prod / --no-optional) no longer triggers
the node_modules purge, but the relink path does not delete previously-created top-level
node_modules/ entries that are no longer in the selected dependency groups. This can leave
excluded direct dependencies still resolvable from node_modules in a production-mode install,
undermining the expected dependency surface and potentially shipping/using dev-only code.
Code

pacquet/crates/package-manager/src/install.rs[R1088-1091]

   let is_inconsistent = read_failed
       || match &modules_manifest {
-                Some(modules) => !modules_consistent_with(modules, config, node_linker, included),
+                Some(modules) => !modules_layout_consistent_with(modules, config, node_linker),
           // Treat existence-check errors conservatively as inconsistent.
Evidence
The PR changes the purge gate to ignore included, so an included-only drift will skip the only
code path that deletes existing node_modules entries. The relink step (direct-dependency linking)
only creates/updates symlinks for currently-selected dependency groups and does not include any
removal pass for entries that are no longer selected, so stale direct-dependency entries from a
previous mode can remain present.

pacquet/crates/package-manager/src/install.rs[1068-1101]
pacquet/crates/package-manager/src/install.rs[1099-1171]
pacquet/crates/package-manager/src/symlink_direct_dependencies.rs[378-517]

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

## Issue description
Switching dependency-group selection (e.g. full install � `--prod` or toggling `--no-optional`) no longer triggers the destructive `node_modules` purge (by design), but pacquet currently has no targeted cleanup to remove *previously-linked* top-level direct dependencies that are now excluded. That leaves stale `node_modules/<dep>` entries behind, so excluded packages can remain resolvable/usable even in production-mode installs.
## Issue Context
- The purge gate now uses `modules_layout_consistent_with` (ignores `included`), so included drift will not wipe `node_modules`.
- `SymlinkDirectDependencies` links the currently-selected groups but does not remove any other pre-existing entries under `<importer>/node_modules`.
- The only removal currently happening in the root `node_modules` tree is the purge branch (which no longer runs on included drift).
## Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[1084-1171]
- pacquet/crates/package-manager/src/symlink_direct_dependencies.rs[378-517]
### Suggested fix approach
When `.modules.yaml` exists and `modules.included != included` (i.e., included drift), do a *non-destructive direct-dep cleanup* before (or as part of) relinking:
1. Compute which dependency groups became excluded (old included `true` -> new included `false`).
2. For each importer, compute the direct dependency names belonging to those now-excluded groups using the lockfile importer maps.
3. Remove only those corresponding filesystem entries under `<importer>/node_modules`:
- Handle scoped packages (`@scope/name`) by unlinking `node_modules/@scope/name` and removing the `@scope` dir if it becomes empty.
- Only remove entries that look pacquet-managed (e.g., symlink/junction into the virtual store or a `link:` target), to avoid deleting user vendored directories/files.
This keeps the PR�s goal (preserve user files) while restoring the correctness/security contract that excluded groups are not present after a mode switch.

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



Remediation recommended
3. Redundant canonicalize in prune 🐞 Bug ➹ Performance ⭐ New
Description
prune_direct_deps_excluded_by_groups canonicalizes workspace_root once per importer via
confined_modules_dir, and also re-checks whether <modules_dir>/.bin is a "real" directory for
every removed dependency. On large workspaces or dev→prod switches with many pruned deps, this adds
avoidable filesystem syscalls on an otherwise routine reinstall path.
Code

pacquet/crates/package-manager/src/prune_direct_deps.rs[R119-167]

+    for (importer_id, snapshot) in &current_lockfile.importers {
+        // A malformed importer key is rejected with a typed error by
+        // the symlink pass; never *delete* based on one.
+        if validate_importer_id(importer_id).is_err() {
+            continue;
+        }
+        // Same canonical containment check as the purge: delete only
+        // through a modules dir that resolves inside the workspace
+        // root, and operate on the canonicalized path so a symlink
+        // swap can't redirect the removals after the check.
+        let modules_dir = importer_root_dir(workspace_root, importer_id).join(modules_dir_name);
+        let Some(modules_dir) = confined_modules_dir(&modules_dir, workspace_root) else {
+            continue;
+        };
+        let new_names: HashSet<String> =
+            direct_dep_names_for_importer(snapshot, new_groups.iter().copied(), &skipped, false)
+                .into_iter()
+                .collect();
+        for name in
+            direct_dep_names_for_importer(snapshot, old_groups.iter().copied(), &skipped, false)
+        {
+            if new_names.contains(&name) {
+                continue;
+            }
+            remove_direct_dep_link(&modules_dir, &name)?;
+        }
+    }
+    Ok(())
+}
+
+/// Canonicalize `modules_dir` and require it to stay within
+/// `workspace_root` — the same containment check the purge applies
+/// before its destructive sweep. Returns the canonical path the
+/// removals should operate on, or `None` when there is nothing to
+/// prune (the directory doesn't exist) or when the resolution escapes
+/// the workspace — never delete through an escape.
+fn confined_modules_dir(modules_dir: &Path, workspace_root: &Path) -> Option<PathBuf> {
+    let modules_canon = std::fs::canonicalize(modules_dir).ok()?;
+    let root_canon = std::fs::canonicalize(workspace_root).ok()?;
+    if modules_canon.starts_with(&root_canon) {
+        Some(modules_canon)
+    } else {
+        tracing::warn!(
+            ?modules_dir,
+            "refusing to prune direct dependencies outside the workspace root",
+        );
+        None
+    }
+}
Evidence
The per-importer loop calls confined_modules_dir(), which canonicalizes workspace_root every
time. Shim removal checks .bin via is_real_dir() for each removed dep, and is_real_dir()
relies on read_symlink_dir() which may do additional syscalls (notably on Windows due to junction
handling).

pacquet/crates/package-manager/src/prune_direct_deps.rs[119-145]
pacquet/crates/package-manager/src/prune_direct_deps.rs[155-167]
pacquet/crates/package-manager/src/prune_direct_deps.rs[234-246]
pacquet/crates/fs/src/symlink_dir.rs[121-135]

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

### Issue description
`prune_direct_deps_excluded_by_groups()` performs redundant filesystem work:
- `confined_modules_dir()` canonicalizes `workspace_root` for every importer iteration.
- `.bin` “real directory” probing is repeated per removed dependency.

This is extra I/O on the `--prod`<->full / `--no-optional` drift path.

### Issue Context
This prune runs specifically to avoid destructive purges on `included` drift, so it can be triggered in everyday workflows. In large workspaces (many importers) and/or when many direct deps are removed, the repeated `canonicalize()` and repeated `.bin` checks can become noticeable.

### Fix Focus Areas
- pacquet/crates/package-manager/src/prune_direct_deps.rs[119-167]
- pacquet/crates/package-manager/src/prune_direct_deps.rs[238-246]

### Suggested approach
1. Canonicalize `workspace_root` once at the start of `prune_direct_deps_excluded_by_groups()` (e.g., `let root_canon = canonicalize(workspace_root)?;`) and pass `&root_canon` into a revised `confined_modules_dir()` that only canonicalizes `modules_dir`.
2. Compute whether `modules_dir/.bin` is a real directory once per importer (after `modules_dir` is known) and pass that boolean (or the validated bins dir path) into the per-dependency removal function so `is_real_dir(.bin)` isn’t re-run for every pruned dep.
3. Keep the same safety properties (no deletion through symlink/junctioned intermediates).

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


4. Stale .bin shims persist 🐞 Bug ≡ Correctness
Description
After this change, a --prod↔full included drift no longer triggers the node_modules purge, but
the bin-linking implementation only writes shims for the current set and does not remove shims that
are no longer selected. This can leave stale .bin/ entries from a previous install mode available
after relinking, causing prod-only installs to expose/execute commands that should have disappeared.
Code

pacquet/crates/package-manager/src/install.rs[R1084-1091]

+        // The purge keys off *layout* drift only, not `included`: an
+        // included (`--prod`<->full) change is handled by relinking, so it
+        // must not wipe the user's `node_modules` contents. See
+        // [`modules_layout_consistent_with`].
let is_inconsistent = read_failed
   || match &modules_manifest {
-                Some(modules) => !modules_consistent_with(modules, config, node_linker, included),
+                Some(modules) => !modules_layout_consistent_with(modules, config, node_linker),
       // Treat existence-check errors conservatively as inconsistent.
Evidence
The purge gate now ignores included, so included-only drift won’t enter the purge branch that
deletes .bin. The bin-linking implementation writes shims for the current chosen set but does not
remove any existing shims that are no longer chosen, so stale .bin entries can persist when the
purge is skipped.

pacquet/crates/package-manager/src/install.rs[1084-1097]
pacquet/crates/package-manager/src/install.rs[1130-1169]
pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[1747-1759]
pacquet/crates/package-manager/src/install_frozen_lockfile.rs[521-549]
pacquet/crates/package-manager/src/symlink_direct_dependencies.rs[508-514]
pacquet/crates/cmd-shim/src/link_bins.rs[301-358]
pacquet/crates/package-manager/src/prune_virtual_store.rs[11-16]

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

## Issue description
With the purge gate now ignoring `.modules.yaml.included`, `--prod`↔full switches won’t wipe `node_modules`. However, the current bin-linking path only creates/overwrites shims for bins that *exist in the newly chosen set* and does not remove shims that disappeared (or belonged to deps that are no longer linked). This can leave stale `.bin/*` shims from prior installs, changing command availability/behavior after an `included`-only reinstall.
### Issue Context
- The purge path is the only place that deletes `.bin` contents today, but it no longer runs for `included` drift.
- `pacquet_cmd_shim::link_bins_of_packages_with_excludes` writes shims for `chosen` but does not enumerate/remove existing entries in `bins_dir`.
### Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[1084-1097]
- pacquet/crates/cmd-shim/src/link_bins.rs[301-358]
- pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[1747-1759]
- pacquet/crates/package-manager/src/install_frozen_lockfile.rs[521-549]
### Suggested fix approach
Implement one of:
1) **Targeted `.bin` cleanup before relinking**: delete `<modules_dir>/.bin` (or enumerate and remove shims) at the start of the bin-link phases on reinstall paths, then re-link bins; or
2) **Prune-to-chosen behavior inside cmd-shim**: have `link_bins_of_packages_with_excludes` remove any existing shim files in `bins_dir` not present in `chosen` (respecting `exclude_bins`), potentially using the existing `remove_bin()` helper.
Add/adjust a regression test that seeds a `.bin/<devtool>` shim from a full install, switches to `--prod`, and asserts that the stale shim is removed (while non-pnpm user files in `node_modules/` remain intact).

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



Informational
5. Tests use two clients 🐞 Bug ⚙ Maintainability
Description
run_purge_regression_install constructs http_client and http_client_arc from two different
ThrottledClient instances, despite Install documenting they should come from the same source.
This makes the test setup less faithful to production (different internal client state), and can
make registry-backed tests harder to reason about.
Code

pacquet/crates/package-manager/src/install/tests.rs[R6031-6034]

+        tarball_mem_cache: Default::default(),
+        http_client: &Default::default(),
+        http_client_arc: std::sync::Arc::new(Default::default()),
+        config,
Evidence
The Install struct explicitly documents that the CLI builds both http_client and
http_client_arc from a single source, but the new test helper constructs them from two independent
Default::default() values.

pacquet/crates/package-manager/src/install.rs[99-107]
pacquet/crates/package-manager/src/install/tests.rs[6030-6034]

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

## Issue description
`run_purge_regression_install` builds `Install { http_client, http_client_arc }` from two separate default `ThrottledClient` instances. `Install`’s own documentation says the CLI builds both from a single source, so tests should mirror that to avoid subtle differences in behavior.
### Issue Context
This is test-only, but it reduces fidelity of the new install-level regression tests (and can complicate future debugging of intermittent network/throttling behavior).
### Fix Focus Areas
- pacquet/crates/package-manager/src/install/tests.rs[6030-6034]
- pacquet/crates/package-manager/src/install.rs[99-107]
### What to change
In `run_purge_regression_install`, construct the clients from a shared origin. For example:
- Create one base `ThrottledClient` configuration and derive both fields from it (e.g., by cloning if `ThrottledClient: Clone` and that clone shares underlying state), or
- Thread a pair `(http_client: &ThrottledClient, http_client_arc: Arc<ThrottledClient>)` into the helper from the caller (built once), to match the production wiring pattern.

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


Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@codecov-commenter

codecov-commenter commented Jun 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.96552% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.02%. Comparing base (ce5d5a5) to head (bd0691d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...et/crates/package-manager/src/prune_direct_deps.rs 92.39% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12676      +/-   ##
==========================================
- Coverage   85.62%   85.02%   -0.60%     
==========================================
  Files         413      415       +2     
  Lines       64343    65395    +1052     
==========================================
+ Hits        55093    55602     +509     
- Misses       9250     9793     +543     

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

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

@github-actions

github-actions Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: bd0691d34ba3

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.118 ± 0.176 3.953 4.386 1.99 ± 0.13
pacquet@main 4.035 ± 0.124 3.928 4.353 1.95 ± 0.11
pnpr@HEAD 2.065 ± 0.096 1.952 2.274 1.00
pnpr@main 2.124 ± 0.108 1.970 2.308 1.03 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.1181952479,
      "stddev": 0.17554946713391562,
      "median": 4.0441736184,
      "user": 3.91673118,
      "system": 3.54157746,
      "min": 3.9532051209000003,
      "max": 4.3856812069,
      "times": [
        4.3182766659,
        4.3856812069,
        3.9775572389000002,
        4.3798633899,
        4.121589809900001,
        3.9532051209000003,
        4.0579335439,
        3.9737840279000003,
        3.9836477819000002,
        4.0304136929
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.0346684328,
      "stddev": 0.1242958481146948,
      "median": 3.9850285009,
      "user": 3.8562378799999997,
      "system": 3.5181251599999994,
      "min": 3.9280498619,
      "max": 4.3534200589,
      "times": [
        4.3534200589,
        4.1059499849000005,
        3.9743273559000003,
        3.9881122879,
        3.9798638749000004,
        3.9280498619,
        4.0552242419,
        4.0397477769000005,
        3.9400441709000003,
        3.9819447139
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.0646891602,
      "stddev": 0.09617322723595541,
      "median": 2.0343385344,
      "user": 2.62009878,
      "system": 3.0538826599999997,
      "min": 1.9516272809,
      "max": 2.2739522529,
      "times": [
        2.0411648519,
        2.0198556409,
        1.9998647448999998,
        1.9516272809,
        2.1838500769,
        2.0791375109000003,
        2.0275122169,
        2.2739522529,
        2.0692162619000003,
        2.0007107639
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1241352767,
      "stddev": 0.10801556627644346,
      "median": 2.0964134019000005,
      "user": 2.62192428,
      "system": 3.03580096,
      "min": 1.9703110519,
      "max": 2.3076403009,
      "times": [
        2.0186664579,
        2.3076403009,
        2.0703063619,
        2.0754207309000003,
        1.9703110519,
        2.2761389529000002,
        2.1249135279,
        2.0903593429000003,
        2.2051285789,
        2.1024674609000003
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 635.6 ± 7.1 627.1 650.6 1.00
pacquet@main 670.7 ± 72.3 631.9 872.7 1.06 ± 0.11
pnpr@HEAD 719.0 ± 82.0 684.6 951.2 1.13 ± 0.13
pnpr@main 719.5 ± 50.7 673.0 842.0 1.13 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.63561099018,
      "stddev": 0.0071163489244726996,
      "median": 0.6346870976800001,
      "user": 0.37493010000000004,
      "system": 1.3247316199999999,
      "min": 0.62712164368,
      "max": 0.6505872606800001,
      "times": [
        0.63116674968,
        0.63423570568,
        0.6505872606800001,
        0.63470961668,
        0.6349454906800001,
        0.63466457868,
        0.63668741068,
        0.64418643868,
        0.62712164368,
        0.62780500668
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.67069659578,
      "stddev": 0.07234256698860606,
      "median": 0.64885582318,
      "user": 0.3985999,
      "system": 1.3312666199999998,
      "min": 0.63187691968,
      "max": 0.87272051968,
      "times": [
        0.63570241268,
        0.67266366268,
        0.6551979436800001,
        0.63352651868,
        0.65256882468,
        0.64006519968,
        0.66750113468,
        0.63187691968,
        0.64514282168,
        0.87272051968
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.71896429468,
      "stddev": 0.08196332609886878,
      "median": 0.6910226766800001,
      "user": 0.3942464,
      "system": 1.37153942,
      "min": 0.68459413368,
      "max": 0.95119494768,
      "times": [
        0.70823567068,
        0.6878874646800001,
        0.68683773468,
        0.68745069368,
        0.69250517368,
        0.70296315968,
        0.68954017968,
        0.68459413368,
        0.95119494768,
        0.6984337886800001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.71953634418,
      "stddev": 0.050652151796588815,
      "median": 0.70424162968,
      "user": 0.4064685,
      "system": 1.3649192200000002,
      "min": 0.67304191868,
      "max": 0.8419502506800001,
      "times": [
        0.72256162568,
        0.67304191868,
        0.68730034968,
        0.70355046668,
        0.70493279268,
        0.71324309468,
        0.69960690768,
        0.8419502506800001,
        0.76896660668,
        0.68020942868
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.228 ± 0.023 4.187 4.258 1.91 ± 0.11
pacquet@main 4.264 ± 0.042 4.211 4.342 1.92 ± 0.11
pnpr@HEAD 2.217 ± 0.123 2.048 2.392 1.00
pnpr@main 2.233 ± 0.164 1.968 2.421 1.01 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.22755747356,
      "stddev": 0.022508739744230826,
      "median": 4.224261934559999,
      "user": 3.7397687999999993,
      "system": 3.40186954,
      "min": 4.18671265356,
      "max": 4.25829102256,
      "times": [
        4.18671265356,
        4.22563658856,
        4.21347376456,
        4.25829102256,
        4.24037752856,
        4.22288728056,
        4.20913574056,
        4.25512759256,
        4.217468215559999,
        4.24646434856
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.263647302259999,
      "stddev": 0.041719831248167444,
      "median": 4.26551199106,
      "user": 3.8121061999999997,
      "system": 3.4236671400000005,
      "min": 4.21094059856,
      "max": 4.34224319756,
      "times": [
        4.27647825256,
        4.34224319756,
        4.231575343559999,
        4.22209369456,
        4.21094059856,
        4.29039872256,
        4.25493662756,
        4.22821932156,
        4.2760873545599996,
        4.30349990956
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.21716240856,
      "stddev": 0.1232367148520933,
      "median": 2.21607345856,
      "user": 2.4573305,
      "system": 2.9415990400000003,
      "min": 2.04849995956,
      "max": 2.39226317456,
      "times": [
        2.32397301456,
        2.0919196635599997,
        2.04849995956,
        2.35233744656,
        2.14568224856,
        2.29454985856,
        2.0902518025599996,
        2.16604923856,
        2.39226317456,
        2.26609767856
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.2329265885599994,
      "stddev": 0.16396244791217657,
      "median": 2.24326615956,
      "user": 2.492037,
      "system": 2.91819954,
      "min": 1.96756291256,
      "max": 2.42071899356,
      "times": [
        2.15235256056,
        2.2536969715599997,
        2.23283534756,
        2.40404818256,
        1.96756291256,
        2.14361943056,
        2.42071899356,
        2.39000901056,
        2.0057624485599996,
        2.35866002756
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.355 ± 0.019 1.332 1.386 2.03 ± 0.11
pacquet@main 1.379 ± 0.039 1.348 1.481 2.07 ± 0.12
pnpr@HEAD 0.667 ± 0.034 0.644 0.761 1.00
pnpr@main 0.681 ± 0.076 0.646 0.894 1.02 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.3547703405799998,
      "stddev": 0.0192336931704276,
      "median": 1.34787732268,
      "user": 1.32319626,
      "system": 1.70669234,
      "min": 1.33229816768,
      "max": 1.38602790368,
      "times": [
        1.3526427566800001,
        1.36415319468,
        1.38602790368,
        1.36348684668,
        1.3409388766800001,
        1.33229816768,
        1.34311188868,
        1.33733742168,
        1.34284475468,
        1.38486159468
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3787542700800002,
      "stddev": 0.03913160439435337,
      "median": 1.36536158668,
      "user": 1.38393546,
      "system": 1.7099556399999998,
      "min": 1.3481739076800001,
      "max": 1.48061887768,
      "times": [
        1.36302389168,
        1.36569496868,
        1.48061887768,
        1.3481739076800001,
        1.36502820468,
        1.38684760368,
        1.39872768268,
        1.35557809768,
        1.37408099568,
        1.3497684706800002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6668551368800001,
      "stddev": 0.03434203949927823,
      "median": 0.65523357768,
      "user": 0.33383456,
      "system": 1.3028117399999999,
      "min": 0.6441516276800001,
      "max": 0.7614133576800001,
      "times": [
        0.65138603368,
        0.65383776268,
        0.6566293926800001,
        0.65087065468,
        0.64886259568,
        0.7614133576800001,
        0.6720282186800001,
        0.66088085768,
        0.6684908676800001,
        0.6441516276800001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6814904785800001,
      "stddev": 0.07553231568459584,
      "median": 0.6548077481800001,
      "user": 0.34742185999999997,
      "system": 1.2886436399999996,
      "min": 0.6456404706800001,
      "max": 0.89400475168,
      "times": [
        0.67152331068,
        0.64805459968,
        0.6580564666800001,
        0.6473160036800001,
        0.65155902968,
        0.65051155768,
        0.6739904466800001,
        0.6456404706800001,
        0.89400475168,
        0.67424814868
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.011 ± 0.047 2.961 3.122 4.49 ± 0.11
pacquet@main 3.036 ± 0.056 2.975 3.167 4.52 ± 0.12
pnpr@HEAD 0.671 ± 0.012 0.659 0.692 1.00
pnpr@main 0.690 ± 0.014 0.663 0.712 1.03 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.01137995126,
      "stddev": 0.04728046700522441,
      "median": 2.99928337646,
      "user": 1.7908327200000003,
      "system": 1.96969282,
      "min": 2.96118971496,
      "max": 3.12197788696,
      "times": [
        2.99885916596,
        2.98364621096,
        2.9811111709600002,
        2.99970758696,
        3.00221643296,
        3.06334320596,
        2.96118971496,
        3.01474398596,
        3.12197788696,
        2.98700415096
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.0364087309599994,
      "stddev": 0.055644027502695634,
      "median": 3.03247282296,
      "user": 1.8308645199999998,
      "system": 1.9789139199999997,
      "min": 2.97453653896,
      "max": 3.16683499296,
      "times": [
        3.03459894996,
        3.05144540196,
        3.06757547996,
        3.04270342396,
        2.98984809396,
        3.02920480996,
        2.97699292196,
        2.97453653896,
        3.16683499296,
        3.03034669596
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6712957873600002,
      "stddev": 0.011940258684582785,
      "median": 0.66533014146,
      "user": 0.34186651999999995,
      "system": 1.31587282,
      "min": 0.65869593796,
      "max": 0.69195129396,
      "times": [
        0.69195129396,
        0.67944859596,
        0.66515173196,
        0.65951614596,
        0.66291050296,
        0.67668484896,
        0.6655085509600001,
        0.66499554696,
        0.65869593796,
        0.68809471796
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.68972861706,
      "stddev": 0.014363594023492129,
      "median": 0.69164662796,
      "user": 0.35033262,
      "system": 1.31392602,
      "min": 0.6632422999600001,
      "max": 0.71186221096,
      "times": [
        0.67700165696,
        0.69430906996,
        0.6632422999600001,
        0.69545645696,
        0.69681163196,
        0.68435116396,
        0.67934633796,
        0.71186221096,
        0.70592115596,
        0.68898418596
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 7.017 ± 0.162 6.840 7.277 1.40 ± 0.04
pacquet@main 7.026 ± 0.221 6.789 7.419 1.40 ± 0.05
pnpr@HEAD 5.020 ± 0.088 4.891 5.132 1.00
pnpr@main 5.054 ± 0.154 4.834 5.358 1.01 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 7.0167554890999995,
      "stddev": 0.16221333262712798,
      "median": 6.969743558799999,
      "user": 4.146090620000001,
      "system": 3.8462867599999995,
      "min": 6.8398191843,
      "max": 7.2773878103,
      "times": [
        6.8816641043,
        6.8398191843,
        7.2334893163,
        6.9779238963,
        7.1894510533,
        6.8869903753,
        7.0451221553,
        7.2773878103,
        6.8741437743,
        6.9615632213
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 7.0261142854,
      "stddev": 0.22063112844978558,
      "median": 6.9652964768,
      "user": 4.16734912,
      "system": 3.8644747600000002,
      "min": 6.7892872353,
      "max": 7.4192826583,
      "times": [
        7.2892137323,
        6.9335556733,
        6.9614794653,
        7.4192826583,
        7.2233186173,
        6.9691134883,
        6.7932683903,
        7.0730873303,
        6.7892872353,
        6.8095362633
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.020113191399999,
      "stddev": 0.08817229272078031,
      "median": 5.0159396158,
      "user": 2.75456772,
      "system": 3.29600286,
      "min": 4.8905668613,
      "max": 5.1317468413,
      "times": [
        4.9047811613,
        5.0317546903,
        5.1317468413,
        4.9964541943,
        5.0928972563,
        4.8905668613,
        4.9408685563,
        5.1080807503,
        5.0001245413,
        5.1038570613
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 5.0535513386,
      "stddev": 0.15370980480514487,
      "median": 5.059137103299999,
      "user": 2.75164022,
      "system": 3.3052125599999997,
      "min": 4.8337583133,
      "max": 5.3583920723,
      "times": [
        4.9238206383,
        4.9282368533,
        4.8337583133,
        5.3583920723,
        5.0727181813,
        4.9832436453,
        5.0700810333,
        5.0481931733,
        5.0836541443,
        5.2334153313
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12676
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,227.56 ms
(-2.14%)Baseline: 4,320.19 ms
5,184.23 ms
(81.55%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,011.38 ms
(-1.17%)Baseline: 3,047.12 ms
3,656.54 ms
(82.36%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,354.77 ms
(-0.05%)Baseline: 1,355.47 ms
1,626.57 ms
(83.29%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,118.20 ms
(-0.76%)Baseline: 4,149.66 ms
4,979.60 ms
(82.70%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
7,016.76 ms
(+0.70%)Baseline: 6,968.16 ms
8,361.79 ms
(83.91%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
635.61 ms
(+1.51%)Baseline: 626.15 ms
751.38 ms
(84.59%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12676
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

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

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,217.16 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
671.30 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
666.86 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,064.69 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,020.11 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
718.96 ms
🐰 View full continuous benchmarking report in Bencher

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 26, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 3cf61e6

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 3cf61e6

@YESHYUNGSEOK
YESHYUNGSEOK force-pushed the fix/pacquet-purge-keep-user-files branch from 3cf61e6 to 8f188f0 Compare June 28, 2026 23:49
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8f188f0

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8f188f0

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2f7e816

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2f7e816

@YESHYUNGSEOK
YESHYUNGSEOK force-pushed the fix/pacquet-purge-keep-user-files branch from 2f7e816 to 9c07355 Compare June 29, 2026 00:45
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9c07355

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9c07355

YESHYUNGSEOK and others added 3 commits July 4, 2026 12:26
When `.modules.yaml` recorded a different `included` set than the current
install wants — e.g. switching `pnpm install --prod` <-> a full install,
or toggling `--no-optional` — `modules_consistent_with` reported the
directory inconsistent, which drove the purge that empties
`node_modules` of everything except pnpm's own and dotfile entries. A
user's non-pnpm contents (a vendored directory, stray files placed in
`node_modules`) were deleted silently on that routine flag change.

pnpm never purges the root project's node_modules for an included
mismatch: its `validateModules` only treats included drift as
purge-worthy for non-root importers (the `lockfileDir !== rootDir`
guard), and an included change is otherwise satisfied by relinking.

Split the consistency check: the purge gate now uses
`modules_layout_consistent_with`, which compares every layout-determining
setting *except* `included`. The up-to-date fast path keeps using
`modules_consistent_with` (which still compares `included`), so a
`--prod`<->full switch still forces a reinstall — the relink
(`filter_lockfile_for_current` + the removed-alias pruning in
`create_virtual_store`) adds or removes the right dependencies without
destroying the directory.

pnpm already behaves this way, so no TypeScript-side change is needed.

Co-authored-by: Claude <[email protected]>
…guard

Addresses the review on this PR: the helper-level checks proved the
`modules_consistent_with` / `modules_layout_consistent_with` split but
never drove the real purge path in `Install::run`. Add an install-level
regression that runs a full install, drops a user's own non-pnpm file
into node_modules, then re-installs with `--prod` (an included drift) and
asserts the file survives — and finally re-installs with a drifted
virtual-store-dir-max-length (a real layout change) and asserts the file
is wiped. Without the split, step two would purge the directory and the
assertion would fail.

Co-authored-by: Claude <[email protected]>
pacquet-cli stale_pin_dedupe::refreshes_stale_transitive_pin_to_higher_direct_dep_version
is a deterministic mock-registry test (passed 13/13 locally and on macOS/Windows CI).
It only flaked under ubuntu's parallel nextest load, so this empty commit re-triggers CI.

Co-authored-by: Claude <[email protected]>
@zkochan
zkochan force-pushed the fix/pacquet-purge-keep-user-files branch from 9c07355 to 609eafe Compare July 4, 2026 10:34
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 609eafe

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 609eafe

… included drift

With the purge gate keyed off layout drift only, an included change
(pnpm install --prod <-> full, --no-optional) no longer wipes
node_modules — but nothing removed the direct-dep links the previous
install created for the now-excluded groups, so dev deps (and their
.bin shims) stayed resolvable after a production-mode reinstall.

Add a targeted prune that runs exactly when the purge is skipped for an
included drift: diff each importer's direct-dep names between the old
and new group selections using the current lockfile, remove the
excluded links and their bin shims, and leave everything else alone.
Mirrors pnpm's removeDirectDependency prune. Removal is conservative:
importer keys are validated, aliases go through safe_join_modules_dir,
only symlinks/junctions are removed (a user's real file or directory
is never touched; hoisted-linker real dirs are left to its own orphan
diff), and bin names come from the same sanitized set the shim writer
uses.

Also wire the purge-regression test helper's http_client and
http_client_arc from a single ThrottledClient, and move the test
project's manifest inside the project root so the fresh and frozen
install paths anchor importer symlinks in the same directory, as they
do in production.

Addresses the review findings on
pnpm#12676.
@zkochan

zkochan commented Jul 4, 2026

Copy link
Copy Markdown
Member

All three Qodo findings are addressed in 8acfc55:

  1. Stale direct deps persist — fixed by the new prune_direct_deps_excluded_by_groups pass; see the reply on the inline thread for details.
  2. Stale .bin shims persist — the same prune removes each excluded dep's shims before unlinking it, resolving bin names through the same sanitized get_bins_from_package_manifest set the shim writer uses (Windows .ps1/.cmd/.exe flavors included via remove_bin). The relink that follows re-creates any shim a still-included dep owns, matching pnpm's prune-then-link order. The install-level regression asserts the dev dep's shim is gone after the --prod switch.
  3. Tests use two clients — run_purge_regression_install now derives http_client and http_client_arc from a single ThrottledClient, matching the CLI's documented single-source wiring.

Verified with the full pacquet-package-manager suite (638 passed), clippy --deny warnings, rustdoc -D warnings, and cargo fmt --check.


Written by an agent (Claude Code, claude-fable-5).

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8acfc55

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8acfc55

…ce root

The prune deleted through paths joined from the on-disk layout without
the canonical containment check the purge applies, so a symlinked
node_modules resolving outside the workspace — or a symlinked `.bin/`
or `@scope/` intermediate — could redirect the removals at external
files.

Canonicalize each importer's modules dir and require it to stay within
the canonical workspace root before any removal (operating on the
canonical path closes the check-to-use gap), and skip removals that
would reach through a `.bin/` or `@scope/` component that is not a real
directory (junction-aware via read_symlink_dir).

Addresses the follow-up review finding on
pnpm#12676.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@zkochan
zkochan merged commit 84cf84c into pnpm:main Jul 4, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants