Skip to content

fix(deps-restorer): retire a project link dedupeDirectDeps makes redundant - #13780

Merged
zkochan merged 5 commits into
mainfrom
fix-13775
Aug 10, 2026
Merged

zkochan merged 5 commits into
mainfrom
fix-13775

Conversation

@zkochan

@zkochan zkochan commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #13775.

With dedupeDirectDeps: true, a project's direct-dependency symlink that becomes
redundant — because the workspace root later starts providing the same dependency
at the same resolution — was never removed. dedupeDirectDeps was only consulted
when creating links (SymlinkDirectDependencies), so a link an earlier install
legitimately wrote survived every subsequent install, and the on-disk layout
depended on install history rather than on the manifests. A clean install of the
same manifests produced a different tree.

The removal half lives in the prune pass. PruneStaleModules already diffs each
importer's current direct deps against the wanted lockfile; it now also drops a
non-root importer's entry whose alias the wanted root importer resolves to the
same version — the same condition pnpm's modules-cleaner prune folds into that
diff:

opts.dedupeDirectDeps && id !== '.' && wantedPkgs[depName] === wantedRootPkgs[depName]

Removal goes through the existing remove_direct_dep_link, so the dep's bin
shims are retired with it, and a pnpm:root removed event fires as for any other
pruned link. Over-removal stays self-healing: everything the install still wants
is re-linked by SymlinkDirectDependencies right after.

This is a Rust-only fix. The behavior is a pacquet regression against pnpm 10 and
11 — the TypeScript CLI already applies this condition, so there is nothing to
mirror.

Note on the remaining gap (pre-existing, present in both stacks): the
comparison is on lockfile version strings, so it does not fire for link:
workspace deps whose root and importer entries spell the same directory
differently (link:packages/shared vs link:../shared). Link-time dedupe
compares resolved paths and does catch those, so a link: dep that becomes
redundant still leaves a stale link in pnpm 10/11/12 alike. Fixing that means
resolving link: targets in both prunes; out of scope here, happy to follow up.

Squash Commit Body

`dedupeDirectDeps` only decided which direct-dependency links to create,
never which existing ones to retire. Once the workspace root started
providing a dependency a project already had linked, that project's
now-redundant symlink survived every later install, so the on-disk layout
depended on install history rather than on the manifests.

The prune pass now folds the same root comparison pnpm's `modules-cleaner`
prune applies into its diff, so an incremental install converges on the
layout a clean install of the same manifests produces.

Closes pnpm/pnpm#13775

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • 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.

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


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

Summary by CodeRabbit

  • Bug Fixes

    • Removed redundant dependency links and command shims when the workspace root provides the same dependency and version.
    • Ensured clean and incremental installs produce consistent dependency layouts.
    • Preserved valid project-specific links and restored them when the root dependency is removed.
    • Improved handling of importer-relative links during dependency cleanup.
  • Tests

    • Added regression coverage for repeated installs, deduplication, links, and command shims.
  • Documentation

    • Documented the updated dependency cleanup behavior.

…dundant

`dedupeDirectDeps` only decided which direct-dependency links to
create, never which existing ones to retire. Once the workspace root
started providing a dependency a project already had linked, that
project's now-redundant symlink survived every later install, so the
on-disk layout depended on install history rather than on the
manifests.

The prune pass now folds the same root comparison pnpm's
`modules-cleaner` prune applies into its diff, so an incremental
install converges on the layout a clean install of the same manifests
produces.

Close #13775

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 10, 2026 18:08

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.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: a7e94160-e974-45c6-92b0-a6fa45d5ec55

📥 Commits

Reviewing files that changed from the base of the PR and between 0e63922 and 7b3e8c9.

📒 Files selected for processing (1)
  • pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs

📝 Walkthrough

Walkthrough

dedupeDirectDeps now removes redundant non-root dependency links during incremental installs. The change updates stale-module pruning, adds regression coverage for cleanup and relative links, and documents the behavior.

Changes

Direct dependency deduplication

Layer / File(s) Summary
Prune root-provided redundant links
pnpm/crates/deps-restorer/src/prune_stale_modules.rs
The restorer records the workspace root’s wanted direct dependencies when dedupeDirectDeps is enabled. Non-root links are not retained when the root provides the same alias and version.
Validate cleanup and link preservation
pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs, .changeset/dedupe-removes-redundant-project-links.md
Regression tests verify removal and restoration of project links and .bin shims. They also verify that importer-relative link: dependencies retain each importer’s target. The changeset documents the patch.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
[#13775] Remove a redundant sibling symlink when the root later provides the same dependency resolution with dedupeDirectDeps enabled. ✅

Possibly related PRs

  • pnpm/pnpm#13151: Both changes update stale direct-dependency pruning for repeat installs.
  • pnpm/pnpm#13306: Both changes update root-provided dependency deduplication and stale project-link cleanup.

Suggested labels: product: pacquet

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

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-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix dedupeDirectDeps pruning: remove project links made redundant by root deps

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Prune redundant project direct-dep symlinks when workspace root provides same version under
 dedupeDirectDeps.
• Add regression test ensuring incremental installs converge to clean-install node_modules layout.
• Publish changeset describing the fix for pacquet patch release.
Diagram

graph TD
  A["pacquet install"] --> B["PruneStaleModules"] --> C["remove_direct_dep_link"] --> D[("node_modules + .bin")]
  A --> E["SymlinkDirectDependencies"]
  B --> F[("wanted lockfile")]
  B --> G[("current lockfile")]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Remove redundancy during the link phase (SymlinkDirectDependencies)
  • ➕ Keeps all dedupe logic in one place (creation + retirement)
  • ➕ Could avoid scanning current lockfile/importers for prune-only logic
  • ➖ Link phase is naturally additive; removal is harder to reason about there
  • ➖ More risk of transiently breaking invariants (e.g., bins) mid-linking
  • ➖ Would still need to handle already-present stale links somehow
2. Persist dedupe decisions in a manifest (e.g., .modules.yaml) and prune from it
  • ➕ Makes retirement decisions explicit and potentially cheaper
  • ➕ Can avoid comparing multiple lockfile snapshots per install
  • ➖ Adds new state that can drift and needs migrations
  • ➖ More surface area for bugs vs leveraging existing lockfile diffing

Recommendation: Keep the PR’s approach: pruning is the correct place to retire previously-created links, and it already owns safe removal semantics (including bin shim cleanup and pnpm:root removed events). The added root-vs-importer lockfile comparison matches upstream behavior and remains self-healing because the subsequent link pass re-materializes anything still wanted.

Files changed (3) +119 / -4

Bug fix (1) +28 / -4
prune_stale_modules.rsPrune project direct-dep links deduped by root under dedupeDirectDeps +28/-4

Prune project direct-dep links deduped by root under dedupeDirectDeps

• Extends PruneStaleModules to treat a non-root importer direct dependency as removable when the wanted root importer resolves the same alias to the same lockfile version string. Uses existing remove_direct_dep_link to ensure bin shims are removed and emits the standard removed events.

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

Tests (1) +86 / -0
dedupe_direct_deps.rsAdd regression test for install-history-independent dedupe +86/-0

Add regression test for install-history-independent dedupe

• Introduces a new test that performs two installs: first with only a workspace project depending on a package, then after adding the same dependency to the root. Asserts the project's previously-created direct-dep symlink and bin shim are removed after the second install.

pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs

Documentation (1) +5 / -0
dedupe-removes-redundant-project-links.mdAdd changeset for redundant-link pruning fix +5/-0

Add changeset for redundant-link pruning fix

• Adds a pacquet patch changeset documenting that dedupeDirectDeps now removes project symlinks that become redundant once the workspace root provides the same dependency/version.

.changeset/dedupe-removes-redundant-project-links.md

@greptile-apps

greptile-apps Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (5): Last reviewed commit: "test(deps-restorer): write the dedupe fi..." | Re-trigger Greptile

@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 `@pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs`:
- Around line 491-500: Update the dedupe test around dup_link and dup_bin to use
fs::symlink_metadata and assert an ErrorKind::NotFound result, so dangling
symlinks and bin shims cannot evade removal checks. Then remove the root
dependency, run a third install, and assert that both the project link and bin
shim are restored.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 586db446-45e2-41f6-8be5-7369a0749444

📥 Commits

Reviewing files that changed from the base of the PR and between 9f71dda and e32cbf0.

📒 Files selected for processing (3)
  • .changeset/dedupe-removes-redundant-project-links.md
  • pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs
  • pnpm/crates/deps-restorer/src/prune_stale_modules.rs

…on test

The test name, setup, and assertion messages already carry what the
comments restated; keep only the why and the upstream anchor.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 10, 2026 18:12

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

`Path::exists` follows the link, so the removal assertions would have
passed on a leftover whose target the install also pruned. Stat the
entry instead, and drop the root's declaration again to pin that the
project gets its link and bin shim back.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 10, 2026 18:14

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     20.3±3.05ms    18.4 MB/sec    1.04     21.2±5.42ms    17.7 MB/sec
packument/parse                                  1.13     54.9±7.08µs  1209.1 MB/sec    1.00     48.6±4.34µs  1364.1 MB/sec
tarball/download_dependency                      1.00      4.2±0.93ms  1025.3 KB/sec    1.04      4.4±0.85ms   983.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.04   337.6±42.71ms 47.4 KElem/sec    1.00   324.8±26.40ms 49.3 KElem/sec
workspace_resolution/hoist_heavy                 1.02   465.0±44.67ms        ? ?/sec    1.00   454.1±58.61ms        ? ?/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Brittle YAML key append ✓ Resolved 🐞 Bug ☼ Reliability ⭐ New
Description
The test appends raw YAML containing top-level keys (packages, dedupeDirectDeps) without
guarding against existing keys, making it brittle to harness/template changes and producing less
actionable failures if duplicate keys are introduced.
Code

pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[R787-790]

+        workspace_yaml.push('\n');
+    }
+    workspace_yaml.push_str("packages:\n  - 'packages/*'\ndedupeDirectDeps: true\n");
+    fs::write(&workspace_yaml_path, workspace_yaml).expect("write pnpm-workspace.yaml");
Relevance

●●● Strong

Guarding pnpm-workspace.yaml edits against duplicate top-level keys is a repeatedly accepted
test-hardening pattern here.

PR-#13563

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test appends a packages:/dedupeDirectDeps: block directly. The test utilities explicitly
document that pnpm rejects duplicate top-level YAML keys and provide a helper that guards against
this, but this test bypasses it.

pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[783-790]
pnpm/crates/cli/tests/suite/_utils/mod.rs[83-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
The test mutates `pnpm-workspace.yaml` by blindly appending YAML text that introduces top-level keys. If the harness ever starts writing `packages:` or `dedupeDirectDeps:` itself, pnpm will reject the file due to duplicate top-level mapping keys, and the failure won’t clearly indicate the real cause.

### Issue Context
The suite already has a helper (`append_workspace_yaml_key`) that asserts the key is not present before appending, specifically because pnpm rejects duplicate top-level keys.

### Fix Focus Areas
- pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[783-790]

### Suggested fix
- Use `append_workspace_yaml_key(&workspace, "dedupeDirectDeps", "true")`.
- For `packages`, either:
 - switch this test to use `WorkspaceFixture::new()` (which already appends a `packages/*` workspace), or
 - add a small helper for appending a `packages:` block with a “key absent” assertion, mirroring `append_workspace_yaml_key`’s guard behavior.

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


2. Unneeded mocked registry fixture 🐞 Bug ➹ Performance ⭐ New
Description
relative_link_payloads_survive_the_dedupe_prune starts a mocked registry process via
add_mocked_registry() even though it installs only local link: dependencies, adding avoidable
process startup and I/O overhead to the test suite.
Code

pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[R767-770]

+    let CommandTempCwd { pacquet, root, workspace, npmrc_info, .. } =
+        CommandTempCwd::init().add_mocked_registry();
+    let AddMockedRegistry { mock_instance, .. } = npmrc_info;
+
Relevance

●●● Strong

Team has accepted removing unnecessary add_mocked_registry setup to avoid wasted test
scaffolding/overhead.

PR-#13176

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test’s manifests depend only on a local link: spec, while add_mocked_registry() starts a
mocked registry (TestRegistry::start()) and configures registry-related .npmrc/workspace YAML,
which is unnecessary for this test’s dependency graph.

pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[767-778]
pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[805-812]
pnpm/crates/testing-utils/src/bin.rs[60-68]
pnpm/crates/testing-utils/src/bin.rs[105-107]

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 test starts a `TestRegistry` (via `CommandTempCwd::init().add_mocked_registry()`) despite using only `link:` dependencies. This adds unnecessary per-test overhead.

### Issue Context
This test constructs a workspace where both the root and app declare only `"x": "link:vendor/x"`. No registry resolution should be needed.

### Fix Focus Areas
- pnpm/crates/cli/tests/suite/dedupe_direct_deps.rs[767-770]

### Suggested fix
- Replace `CommandTempCwd::init().add_mocked_registry()` with `CommandTempCwd::init()`.
- Remove `npmrc_info` / `mock_instance` plumbing and the `drop((root, mock_instance))` cleanup.
- If hermetic config pinning is still needed (e.g. `enableGlobalVirtualStore: false`), write a minimal `pnpm-workspace.yaml` directly in this test (or add a lightweight helper in `pnpm/crates/testing-utils` that writes the YAML without starting the registry).

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


3. Link/file dedupe over-prunes 🐞 Bug ☼ Reliability
Description
PruneStaleModules now treats a non-root direct dependency as deduped when the root importer has an
equal ImporterDepVersion, but link:/file: values are stored verbatim and interpreted relative
to each importer’s rootDir. This can remove a still-wanted project link (and its bin shims) even
when it resolves to a different target than the root’s entry, and if the install errors after
pruning but before SymlinkDirectDependencies, the workspace can be left broken.
Code

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

+                let deduped_by_root = dedupe_against_root.is_some_and(|root_deps| {
+                    root_deps.get(alias).is_some_and(|version| **version == current_spec.version)
+                });
Relevance

●●● Strong

Repo has accepted fixes avoiding cross-importer reuse of relative link:/file: specs; same risk
applies to pruning dedupe.

PR-#13343

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The prune logic now dedupes against root by raw ImporterDepVersion equality, but
ImporterDepVersion::Link/File payloads are defined as importer-root-relative strings, so
equality across importers does not guarantee the same resolved target. The linker’s dedupe uses
resolved absolute targets, and prune runs before the relink phase, so an error between them can
strand the pruned state.

pnpm/crates/deps-restorer/src/prune_stale_modules.rs[90-149]
pnpm/crates/lockfile/src/resolved_dependency.rs[24-86]
pnpm/crates/deps-restorer/src/symlink_direct_dependencies.rs[427-444]
pnpm/crates/deps-restorer/src/linking.rs[215-276]

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

## Issue description
`PruneStaleModules` dedupes direct-dep links by comparing `ImporterDepVersion` values between a non-root importer and the root importer. This is safe for store-backed deps (regular/alias), but unsafe for `link:` and `file:` because the payload is stored verbatim and is interpreted relative to each importer’s `rootDir`.

This can cause the prune pass to remove a still-wanted direct-dep link (and its bin shims) when the raw strings match but their resolved targets differ, leaving the workspace in a pruned state if the install fails before the subsequent relink pass.

## Issue Context
- `ImporterDepVersion::Link`/`File` store raw strings and are relative to the importer’s rootDir.
- The link-time dedupe in `SymlinkDirectDependencies` compares resolved absolute target paths, not raw strings, so prune should not assume raw equality implies redundancy.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/prune_stale_modules.rs[90-137]

## Suggested fix approach
1. Restrict the prune-time root-dedupe predicate to importer-independent variants only:
  - Only consider `ImporterDepVersion::Regular` and `ImporterDepVersion::Alias` for `wanted_root_deps` and for `deduped_by_root`.
  - Treat `Link`/`File` as **not dedupe-eligible** in prune (or implement resolved-target comparison).

2. If you want parity for `link:` too:
  - Resolve root and importer `link:` targets to absolute paths using each importer’s `importer_root_dir`.
  - Compare lexical-normalized absolute paths (mirroring `SymlinkDirectDependencies`’ dedupe semantics) before pruning.

3. Add a focused regression test (optional but ideal): root and project both have the same textual `link:` payload that resolves differently due to different `rootDir`s, and verify prune does not remove the project link.

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



Informational

4. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset file declares only pacquet and omits the required pnpm package entry. This can
prevent correct release automation and violates the changeset package-declaration requirement.
Code

.changeset/dedupe-removes-redundant-project-links.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

● Weak

Multiple precedents reject adding pnpm to pacquet-only changesets; rule treated as non-applicable
here.

PR-#13549
PR-#13406
PR-#13708

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to include an entry for the pnpm package
with a valid bump type. The added changeset front-matter includes only "pacquet": patch and omits
pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/dedupe-removes-redundant-project-links.md[1-3]

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 changeset `.changeset/dedupe-removes-redundant-project-links.md` is missing a required `pnpm` entry in its front-matter.

## Issue Context
Compliance requires changesets to explicitly list the `pnpm` package with a valid bump type (`patch`/`minor`/`major`). This PR adds only `"pacquet": patch`.

## Fix Focus Areas
- .changeset/dedupe-removes-redundant-project-links.md[1-3]

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


Grey Divider

Context used
✅ Compliance rules (platform): 26 rules

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous review results

Review updated until commit 7b3e8c9

Results up to commit 99d6f5f ⚖️ Balanced


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


Remediation recommended
1. Link/file dedupe over-prunes 🐞 Bug ☼ Reliability
Description
PruneStaleModules now treats a non-root direct dependency as deduped when the root importer has an
equal ImporterDepVersion, but link:/file: values are stored verbatim and interpreted relative
to each importer’s rootDir. This can remove a still-wanted project link (and its bin shims) even
when it resolves to a different target than the root’s entry, and if the install errors after
pruning but before SymlinkDirectDependencies, the workspace can be left broken.
Code

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

+                let deduped_by_root = dedupe_against_root.is_some_and(|root_deps| {
+                    root_deps.get(alias).is_some_and(|version| **version == current_spec.version)
+                });
Relevance

●●● Strong

Repo has accepted fixes avoiding cross-importer reuse of relative link:/file: specs; same risk
applies to pruning dedupe.

PR-#13343

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The prune logic now dedupes against root by raw ImporterDepVersion equality, but
ImporterDepVersion::Link/File payloads are defined as importer-root-relative strings, so
equality across importers does not guarantee the same resolved target. The linker’s dedupe uses
resolved absolute targets, and prune runs before the relink phase, so an error between them can
strand the pruned state.

pnpm/crates/deps-restorer/src/prune_stale_modules.rs[90-149]
pnpm/crates/lockfile/src/resolved_dependency.rs[24-86]
pnpm/crates/deps-restorer/src/symlink_direct_dependencies.rs[427-444]
pnpm/crates/deps-restorer/src/linking.rs[215-276]

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

## Issue description
`PruneStaleModules` dedupes direct-dep links by comparing `ImporterDepVersion` values between a non-root importer and the root importer. This is safe for store-backed deps (regular/alias), but unsafe for `link:` and `file:` because the payload is stored verbatim and is interpreted relative to each importer’s `rootDir`.

This can cause the prune pass to remove a still-wanted direct-dep link (and its bin shims) when the raw strings match but their resolved targets differ, leaving the workspace in a pruned state if the install fails before the subsequent relink pass.

## Issue Context
- `ImporterDepVersion::Link`/`File` store raw strings and are relative to the importer’s rootDir.
- The link-time dedupe in `SymlinkDirectDependencies` compares resolved absolute target paths, not raw strings, so prune should not assume raw equality implies redundancy.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/prune_stale_modules.rs[90-137]

## Suggested fix approach
1. Restrict the prune-time root-dedupe predicate to importer-independent variants only:
  - Only consider `ImporterDepVersion::Regular` and `ImporterDepVersion::Alias` for `wanted_root_deps` and for `deduped_by_root`.
  - Treat `Link`/`File` as **not dedupe-eligible** in prune (or implement resolved-target comparison).

2. If you want parity for `link:` too:
  - Resolve root and importer `link:` targets to absolute paths using each importer’s `importer_root_dir`.
  - Compare lexical-normalized absolute paths (mirroring `SymlinkDirectDependencies`’ dedupe semantics) before pruning.

3. Add a focused regression test (optional but ideal): root and project both have the same textual `link:` payload that resolves differently due to different `rootDir`s, and verify prune does not remove the project link.

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



Informational
2. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset file declares only pacquet and omits the required pnpm package entry. This can
prevent correct release automation and violates the changeset package-declaration requirement.
Code

.changeset/dedupe-removes-redundant-project-links.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

● Weak

Multiple precedents reject adding pnpm to pacquet-only changesets; rule treated as non-applicable
here.

PR-#13549
PR-#13406
PR-#13708

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to include an entry for the pnpm package
with a valid bump type. The added changeset front-matter includes only "pacquet": patch and omits
pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/dedupe-removes-redundant-project-links.md[1-3]

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 changeset `.changeset/dedupe-removes-redundant-project-links.md` is missing a required `pnpm` entry in its front-matter.

## Issue Context
Compliance requires changesets to explicitly list the `pnpm` package with a valid bump type (`patch`/`minor`/`major`). This PR adds only `"pacquet": patch`.

## Fix Focus Areas
- .changeset/dedupe-removes-redundant-project-links.md[1-3]

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


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@codecov-commenter

codecov-commenter commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.15%. Comparing base (9f71dda) to head (7b3e8c9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13780   +/-   ##
=======================================
  Coverage   88.15%   88.15%           
=======================================
  Files         623      623           
  Lines      101492   101506   +14     
=======================================
+ Hits        89470    89484   +14     
  Misses      12022    12022           

☔ 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.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 10, 2026
… prune

`link:` versions are stored relative to their own importer, so the
version-string dedupe can fire on two importers that resolve the string
to different directories. The relink behind the prune is what keeps each
importer pointing at its own target; assert that rather than leave it to
inspection.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 10, 2026 18:25
@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 18:25

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

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 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Re: the link:/file: dedupe finding — checked and addressed in 0e63922.

The comparison is deliberately on raw ImporterDepVersion equality because that is exactly what upstream's prune does (wantedPkgs[depName] === wantedRootPkgs[depName] in modules-cleaner/src/prune.ts), with the same importer-relative link: payloads. Resolving the payloads on the pacquet side only would make the two stacks disagree on the resulting on-disk layout, which is the thing this PR is restoring.

The over-prune the finding describes is real but self-healing, and that is the documented contract of this pass: PruneStaleModules runs immediately before SymlinkDirectDependencies, which re-links everything the install still wants (bin shims included, since link_direct_dep_bins_resolved runs over all surviving entries, not just newly created ones). I added relative_link_payloads_survive_the_dedupe_prune to pin it: two importers whose link:vendor/x payloads are byte-identical but resolve to different directories — after the install that prunes, the project's link is still there and still resolves to its own vendor/x, not the root's.

The "install errors between prune and link" window is not introduced here — every removal this pass already performs shares it, and it is called out in the module docs ("over-removal of a still-wanted entry is self-healing because everything wanted is re-linked right after").

Separately, the same string comparison means a genuinely redundant link: dep spelled differently from the root (link:packages/shared vs link:../shared) is still not pruned — a pre-existing gap shared by pnpm 10, 11 and 12. Fixing that needs the payload resolution done in both stacks at once; noted in the PR description as a follow-up.


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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 10, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 0e63922

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

…h the guard

`append_workspace_yaml_key` asserts the key is absent before appending,
so a harness that starts writing `packages:` or `dedupeDirectDeps:`
itself fails on the duplicate rather than on pnpm's YAML parse.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 10, 2026 18:33
@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 18:33

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

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 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Re: the two new findings on relative_link_payloads_survive_the_dedupe_prune.

Brittle YAML key append — fixed in 7b3e8c9. Both tests added by this PR now go through _utils::append_workspace_yaml_key, including the packages key in its flow-sequence form (["'packages/*']), which is the form already used in exclude_links_from_lockfile.rs. I left the nine pre-existing tests in this file on their raw append — converting them is a file-wide cleanup, not part of a bug fix.

Unneeded mocked registry — not applying. add_mocked_registry is not just the registry: it is also what writes the hermetic store-dir / cache-dir into .npmrc and pnpm-workspace.yaml. Dropping it would point the install at the developer's real store and leave no pnpm-workspace.yaml for the test to extend. TestRegistry::start() returns a handle to a process-scoped instance rather than spawning one per call, and the test measures in line with its siblings in this module (0.19s against 0.12–0.27s), so the overhead the finding predicts does not show up.

Link/file dedupe over-prunes — same finding as before, re-emitted against the new commit; answered in #13780 (comment) and now pinned by relative_link_payloads_survive_the_dedupe_prune.


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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7b3e8c9

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan

zkochan commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Changeset missing pnpm entry — not applying. That rule has an explicit exception for the Rust products, in CLAUDE.md under "Changesets for the Rust products":

Do not add "pnpm" to a Rust-only changeset: in changesets, pnpm always means the TypeScript CLI package. A changeset whose implementation is Rust-only and targets pacquet must omit "pnpm".

This PR's implementation is entirely under pnpm/crates/, so "pacquet": patch on its own is the correct front-matter — adding "pnpm" would cut a TypeScript CLI release for a change that ships no TypeScript. (The release note prose does say pnpm, per the same section, since the published Rust CLI's executable is pnpm.)


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

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 7b3e8c970685

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

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.742 ± 0.182 2.524 2.994 1.59 ± 0.17
pacquet@main 2.917 ± 0.236 2.633 3.281 1.69 ± 0.20
pnpr@HEAD 1.757 ± 0.136 1.552 1.984 1.02 ± 0.11
pnpr@main 1.723 ± 0.141 1.532 1.920 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.74231445618,
      "stddev": 0.1822059141547437,
      "median": 2.67093746858,
      "user": 2.86201646,
      "system": 2.26083664,
      "min": 2.5236567490799997,
      "max": 2.99384637408,
      "times": [
        2.5236567490799997,
        2.97695026308,
        2.83817485308,
        2.55960830108,
        2.95760639408,
        2.99384637408,
        2.60365754908,
        2.62776914108,
        2.64643842008,
        2.6954365170799996
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9171131672799997,
      "stddev": 0.23643256281675568,
      "median": 2.93830352458,
      "user": 3.1162075599999994,
      "system": 2.4279325399999996,
      "min": 2.63252275808,
      "max": 3.28081306008,
      "times": [
        3.0877189910799996,
        2.68356801708,
        3.28081306008,
        2.89378386408,
        3.1648131820799996,
        2.68590188708,
        2.67502952808,
        2.63252275808,
        2.98282318508,
        3.08415720008
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.75710364288,
      "stddev": 0.13606861801103132,
      "median": 1.7231940030800001,
      "user": 2.08221856,
      "system": 1.9411639399999996,
      "min": 1.55240120908,
      "max": 1.9842173260800002,
      "times": [
        1.8226136530800001,
        1.9842173260800002,
        1.69002433708,
        1.7044683010800001,
        1.9487961790800001,
        1.55240120908,
        1.63271149008,
        1.8137632650800002,
        1.7419197050800002,
        1.68012096308
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.7229513816800004,
      "stddev": 0.14113739867598118,
      "median": 1.7140181835800001,
      "user": 2.1217318599999997,
      "system": 1.9570680399999998,
      "min": 1.53164385208,
      "max": 1.9195206870800001,
      "times": [
        1.81359482508,
        1.6771929360800002,
        1.53164385208,
        1.6421828470800002,
        1.75084343108,
        1.91377722708,
        1.8146080350800002,
        1.9195206870800001,
        1.5478473220800002,
        1.61830265408
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 418.3 ± 14.9 389.9 435.4 1.02 ± 0.09
pacquet@main 412.1 ± 32.5 370.6 467.0 1.00
pnpr@HEAD 465.3 ± 36.3 417.6 518.7 1.13 ± 0.13
pnpr@main 456.0 ± 30.2 400.1 503.5 1.11 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.41831241224,
      "stddev": 0.014880526370157562,
      "median": 0.42546362874,
      "user": 0.38537256,
      "system": 0.7709396799999999,
      "min": 0.38990324374,
      "max": 0.43540472874,
      "times": [
        0.42701931974,
        0.43051249774,
        0.40551353974000004,
        0.42732229274,
        0.38990324374,
        0.42737797574,
        0.40096950374,
        0.42390793774,
        0.41519308274,
        0.43540472874
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.4120753155400001,
      "stddev": 0.032457336626468526,
      "median": 0.40507002674000003,
      "user": 0.37976326,
      "system": 0.7520451799999999,
      "min": 0.37058364674,
      "max": 0.46700008674000004,
      "times": [
        0.39858448574,
        0.37058364674,
        0.39311839174,
        0.46616851574,
        0.46700008674000004,
        0.41200143174000003,
        0.40971669574,
        0.42295425074000004,
        0.40042335774000004,
        0.38020229274
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.46533036414000006,
      "stddev": 0.03633170152792961,
      "median": 0.47061224724,
      "user": 0.39951726,
      "system": 0.8096337800000001,
      "min": 0.41758129274,
      "max": 0.5187290557400001,
      "times": [
        0.42049044074,
        0.41758129274,
        0.5187290557400001,
        0.46254688974,
        0.5041955367400001,
        0.46545922674,
        0.41818891674,
        0.47806892774000004,
        0.47576526774,
        0.49227808674
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.45604210884,
      "stddev": 0.03018097496598746,
      "median": 0.45073431074000003,
      "user": 0.41739516,
      "system": 0.7802400799999998,
      "min": 0.40011229174,
      "max": 0.5034990827400001,
      "times": [
        0.43941870574,
        0.46925231474,
        0.5034990827400001,
        0.47934006374000004,
        0.43995779174,
        0.43730339074,
        0.49006882574000005,
        0.45091171774,
        0.45055690374,
        0.40011229174
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.967 ± 0.085 2.841 3.180 1.78 ± 0.11
pacquet@main 2.872 ± 0.034 2.802 2.920 1.72 ± 0.10
pnpr@HEAD 1.747 ± 0.179 1.571 2.074 1.05 ± 0.12
pnpr@main 1.671 ± 0.096 1.582 1.858 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.96719805108,
      "stddev": 0.08530626745146645,
      "median": 2.95959457228,
      "user": 2.9453916399999995,
      "system": 2.34668736,
      "min": 2.84052585278,
      "max": 3.1802246077799996,
      "times": [
        2.92772991378,
        2.96433779278,
        2.9727510267799997,
        2.94534014478,
        2.98615201278,
        2.92890518378,
        2.9711626237799997,
        3.1802246077799996,
        2.95485135178,
        2.84052585278
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.8722398472800004,
      "stddev": 0.03352639154312987,
      "median": 2.86927470228,
      "user": 2.7213226399999995,
      "system": 2.12660716,
      "min": 2.80159238178,
      "max": 2.9196230527799996,
      "times": [
        2.90712950978,
        2.9007573557799997,
        2.80159238178,
        2.8677889997799997,
        2.84959471178,
        2.9196230527799996,
        2.86315994378,
        2.8602941557799997,
        2.88169795678,
        2.87076040478
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.74666197138,
      "stddev": 0.17865772720586967,
      "median": 1.67194825328,
      "user": 1.91139824,
      "system": 1.8657900600000001,
      "min": 1.57145682178,
      "max": 2.0741700917799997,
      "times": [
        1.87997340278,
        1.57145682178,
        2.01742951578,
        1.65953524378,
        1.6039931607800002,
        1.67843741478,
        2.0741700917799997,
        1.66545909178,
        1.69891894278,
        1.61724602778
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6712617613800003,
      "stddev": 0.0959826999949998,
      "median": 1.63218898828,
      "user": 2.0144498399999997,
      "system": 1.8657496599999999,
      "min": 1.58247253178,
      "max": 1.85755102878,
      "times": [
        1.7447034947800002,
        1.59766780878,
        1.6035474677800001,
        1.5983099437800001,
        1.66083050878,
        1.58247253178,
        1.69596034678,
        1.85755102878,
        1.78188388078,
        1.5896906017799999
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 661.8 ± 29.4 615.3 710.4 1.61 ± 0.08
pacquet@main 656.4 ± 39.4 592.7 725.7 1.60 ± 0.10
pnpr@HEAD 410.1 ± 10.5 388.4 424.4 1.00
pnpr@main 429.3 ± 16.0 406.8 453.8 1.05 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6618096042,
      "stddev": 0.02941995820780961,
      "median": 0.6610512362000001,
      "user": 0.88149102,
      "system": 1.0980035799999999,
      "min": 0.6152900412,
      "max": 0.7104279122,
      "times": [
        0.7104279122,
        0.6152900412,
        0.6618962692,
        0.6525372722,
        0.6602062032,
        0.6368363522,
        0.6424075802,
        0.7081705732,
        0.6642889992,
        0.6660348392
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6564380579000001,
      "stddev": 0.03935843472875003,
      "median": 0.6617994892000001,
      "user": 0.90375412,
      "system": 1.0322228799999997,
      "min": 0.5927396572,
      "max": 0.7256597572,
      "times": [
        0.6370125932,
        0.6633450802,
        0.6286342692,
        0.7040759162,
        0.6700550082,
        0.6617453152,
        0.6618536632,
        0.5927396572,
        0.6192593192,
        0.7256597572
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.4101222803000001,
      "stddev": 0.010470245877276057,
      "median": 0.41090258020000003,
      "user": 0.31365292,
      "system": 0.71194928,
      "min": 0.38842870320000006,
      "max": 0.42436077920000004,
      "times": [
        0.41641667620000006,
        0.4134884072,
        0.4074795372,
        0.42436077920000004,
        0.42204220620000005,
        0.40188980320000006,
        0.40831675320000005,
        0.4048616722,
        0.38842870320000006,
        0.41393826520000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.4292872925000001,
      "stddev": 0.016025608439759354,
      "median": 0.42769333620000005,
      "user": 0.33713112,
      "system": 0.70794548,
      "min": 0.40680127120000004,
      "max": 0.45380089320000006,
      "times": [
        0.44210332120000007,
        0.41527273420000005,
        0.42230541520000003,
        0.43308125720000007,
        0.45380089320000006,
        0.44701993520000005,
        0.40680127120000004,
        0.43913849620000006,
        0.41160521420000007,
        0.4217443872
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.792 ± 0.127 1.715 2.050 6.21 ± 0.46
pacquet@main 1.736 ± 0.065 1.685 1.849 6.02 ± 0.27
pnpr@HEAD 0.295 ± 0.009 0.286 0.314 1.02 ± 0.04
pnpr@main 0.289 ± 0.007 0.278 0.304 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7924214486000003,
      "stddev": 0.12714800527258346,
      "median": 1.7263727416,
      "user": 0.9204176800000001,
      "system": 0.8973570800000001,
      "min": 1.7152639511,
      "max": 2.0499837761,
      "times": [
        2.0028298981,
        2.0499837761,
        1.8141656241,
        1.7207365951000002,
        1.7184692861000002,
        1.7295387381,
        1.7255877691000001,
        1.7271577141,
        1.7152639511,
        1.7204811341000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.7360741054000002,
      "stddev": 0.06523606537874713,
      "median": 1.7013239666,
      "user": 0.8312125800000001,
      "system": 0.81945198,
      "min": 1.6848707931000002,
      "max": 1.8492498181,
      "times": [
        1.7052262751,
        1.7153982951000002,
        1.6974216581000001,
        1.6848707931000002,
        1.6949153671000001,
        1.6912452481000002,
        1.8490812061,
        1.8492498181,
        1.7786370991000002,
        1.6946952941
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2946825971,
      "stddev": 0.008797497697670704,
      "median": 0.2931141216,
      "user": 0.18167888,
      "system": 0.5093418800000001,
      "min": 0.2856470131,
      "max": 0.3141396271,
      "times": [
        0.2987218361,
        0.2856470131,
        0.2858750851,
        0.2905815811,
        0.2924357671,
        0.3141396271,
        0.2863100501,
        0.2999116891,
        0.2994108461,
        0.2937924761
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28860669559999996,
      "stddev": 0.006851939225308695,
      "median": 0.2880530281,
      "user": 0.19059127999999997,
      "system": 0.49028647999999997,
      "min": 0.2777072641,
      "max": 0.3036974901,
      "times": [
        0.2910730901,
        0.2870983531,
        0.2777072641,
        0.2843275311,
        0.2837036031,
        0.2890077031,
        0.2900999131,
        0.3036974901,
        0.2864647081,
        0.2928873001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 222.4 ± 45.9 182.9 344.3 2.52 ± 0.53
pacquet@main 208.8 ± 11.7 183.9 226.1 2.36 ± 0.15
pnpr@HEAD 88.4 ± 2.8 84.5 95.4 1.00
pnpr@main 89.8 ± 2.8 85.4 95.8 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.22243454286615386,
      "stddev": 0.0459109992103619,
      "median": 0.20772707202000001,
      "user": 0.18421265384615382,
      "system": 0.08064176769230769,
      "min": 0.18292148602,
      "max": 0.34426633002000007,
      "times": [
        0.22190762402,
        0.19866734802,
        0.34426633002000007,
        0.28168894602000005,
        0.21829661402,
        0.18292148602,
        0.20718734502,
        0.24725623102,
        0.18354587302,
        0.20772707202000001,
        0.18997857102000001,
        0.18839482402,
        0.21981079302
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.2087679027123077,
      "stddev": 0.011735695124194595,
      "median": 0.20936540202,
      "user": 0.16330642307692306,
      "system": 0.06995446,
      "min": 0.18394914502,
      "max": 0.22612617602,
      "times": [
        0.20974220602000002,
        0.22612617602,
        0.21578994502,
        0.21728699302,
        0.20591264002,
        0.20756956502,
        0.21310918002,
        0.19314222502,
        0.18394914502,
        0.20936540202,
        0.22546013602,
        0.20279200302,
        0.20373711902
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08839802092322578,
      "stddev": 0.0027924441501656844,
      "median": 0.08772729902000001,
      "user": 0.020236822580645162,
      "system": 0.01142062387096774,
      "min": 0.08452869202,
      "max": 0.09535547502000001,
      "times": [
        0.08860736002000001,
        0.08755537802,
        0.08523675602000001,
        0.08720393102000001,
        0.08927576802000001,
        0.08841307302000001,
        0.09535547502000001,
        0.08603579302000001,
        0.09044422502,
        0.09007757502000001,
        0.09066441902000001,
        0.08452869202,
        0.08687912202,
        0.08623311902000001,
        0.09227645902,
        0.08621130302,
        0.08615191402000001,
        0.09319992702,
        0.08956786302000001,
        0.08772729902000001,
        0.09088572202,
        0.08786292802000001,
        0.08505925102,
        0.08605202602,
        0.08547662902000001,
        0.09240867702000001,
        0.08559522202000001,
        0.08744714202000001,
        0.08572607302000002,
        0.09267253102,
        0.08950699602000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08981167232303032,
      "stddev": 0.002818435653997128,
      "median": 0.09022583602,
      "user": 0.020734136363636364,
      "system": 0.011921793333333333,
      "min": 0.08537194502,
      "max": 0.09581594902000001,
      "times": [
        0.08565064302000001,
        0.08537194502,
        0.08713826502000001,
        0.09022583602,
        0.08813694502000001,
        0.08885213102000002,
        0.08807124602000001,
        0.09207369802000001,
        0.09024574702,
        0.09048315002000001,
        0.08624147602000001,
        0.09446103002,
        0.08764408402000001,
        0.09229464102000001,
        0.09286051502,
        0.08893843002000001,
        0.09144890102000001,
        0.08708306402,
        0.08730904702000002,
        0.09558189502000002,
        0.09233735002000001,
        0.08650821402000002,
        0.09062375902000001,
        0.09317245402,
        0.09042182702000001,
        0.09140887702000002,
        0.08673255802,
        0.08987117602000001,
        0.09104463302000002,
        0.08632346202,
        0.09581594902000001,
        0.08901485902,
        0.09039737902000002
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 795.4 ± 156.4 581.2 976.5 1.24 ± 0.33
pacquet@main 641.9 ± 116.2 496.9 807.6 1.00
pnpm@HEAD 2884.0 ± 113.3 2774.8 3168.0 4.49 ± 0.83
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7954427917977779,
      "stddev": 0.15641438256440038,
      "median": 0.8547167450200001,
      "user": 0.7496859866666665,
      "system": 0.14756264444444442,
      "min": 0.58120449602,
      "max": 0.9764982710200001,
      "times": [
        0.93215457702,
        0.58120449602,
        0.60456322902,
        0.6719321770200001,
        0.97071875102,
        0.8547167450200001,
        0.7056596620200001,
        0.86153721802,
        0.9764982710200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6419429051311112,
      "stddev": 0.11620792366593248,
      "median": 0.6235931980200001,
      "user": 0.5965185422222221,
      "system": 0.11482931111111111,
      "min": 0.49692304502,
      "max": 0.80757198502,
      "times": [
        0.8034064730200001,
        0.6235931980200001,
        0.80757198502,
        0.68804848502,
        0.6009548410200001,
        0.5133939690200001,
        0.5442695930200001,
        0.6993245570200001,
        0.49692304502
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 2.8840448239088885,
      "stddev": 0.11330568429866314,
      "median": 2.86248564902,
      "user": 4.132120431111111,
      "system": 0.28876442222222226,
      "min": 2.77480332302,
      "max": 3.16798279502,
      "times": [
        2.89716192702,
        2.8241204560199997,
        2.86248564902,
        2.8991070950199997,
        2.86634725402,
        2.83403958002,
        3.16798279502,
        2.77480332302,
        2.83035533602
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.644 ± 0.174 4.409 4.849 1.32 ± 0.06
pacquet@main 4.550 ± 0.126 4.436 4.768 1.29 ± 0.05
pnpr@HEAD 3.528 ± 0.111 3.435 3.819 1.00
pnpr@main 3.710 ± 0.158 3.501 4.054 1.05 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.644113354499999,
      "stddev": 0.17422411824725498,
      "median": 4.686144050599999,
      "user": 1.8355415599999998,
      "system": 1.3858702600000001,
      "min": 4.4089733886,
      "max": 4.8486214526,
      "times": [
        4.829581762599999,
        4.414417279599999,
        4.6611549216,
        4.4114592456,
        4.8486214526,
        4.4089733886,
        4.7911540466,
        4.7111331796,
        4.7345822796,
        4.6300559886
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5501938208,
      "stddev": 0.12637812588323125,
      "median": 4.5106324366,
      "user": 1.9650300600000001,
      "system": 1.4381181599999997,
      "min": 4.4357735946,
      "max": 4.7683193846,
      "times": [
        4.452195198599999,
        4.4432017026,
        4.7683193846,
        4.4357735946,
        4.4424547595999995,
        4.7146029646,
        4.607504533599999,
        4.6324995426,
        4.5690696746,
        4.4363168526
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5277423706,
      "stddev": 0.11061529159478378,
      "median": 3.5004944346,
      "user": 1.46454306,
      "system": 1.32410156,
      "min": 3.4354151836,
      "max": 3.8194666896,
      "times": [
        3.4354151836,
        3.5144440336000002,
        3.5127833046,
        3.4720637136000003,
        3.8194666896,
        3.4596203636,
        3.4683697386000003,
        3.5224234046,
        3.4882055646000003,
        3.5846317096
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.7100212748,
      "stddev": 0.1579349150064631,
      "median": 3.6752987371000003,
      "user": 1.9761869599999997,
      "system": 1.81649466,
      "min": 3.5014221136,
      "max": 4.053944964599999,
      "times": [
        3.7140086436,
        3.8602398316,
        3.6142677646,
        3.5864534686000002,
        3.5014221136,
        3.7069099686,
        3.6345911606,
        3.6436875056,
        4.053944964599999,
        3.7846873266000003
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13780
Testbedpacquet

🚨 2 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
isolated-linker.fresh-install.hot-cache.hot-storeLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
615.29 ms
(+38.75%)Baseline: 443.44 ms
532.13 ms
(115.63%)

isolated-linker.fresh-restore.hot-cache.hot-storeLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
389.90 ms
(+41.11%)Baseline: 276.32 ms
331.58 ms
(117.59%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,840.53 ms
(+7.50%)Baseline: 2,642.47 ms
3,170.96 ms
(89.58%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,715.26 ms
(-2.80%)Baseline: 1,764.65 ms
2,117.58 ms
(81.00%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
🚨 view alert (🔔)
615.29 ms
(+38.75%)Baseline: 443.44 ms
532.13 ms
(115.63%)

isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
182.92 ms
(-16.97%)Baseline: 220.30 ms
264.36 ms
(69.20%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,523.66 ms
(+4.51%)Baseline: 2,414.84 ms
2,897.81 ms
(87.09%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,408.97 ms
(-2.34%)Baseline: 4,514.76 ms
5,417.71 ms
(81.38%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
🚨 view alert (🔔)
389.90 ms
(+41.11%)Baseline: 276.32 ms
331.58 ms
(117.59%)

isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
581.20 ms
(-15.86%)Baseline: 690.75 ms
828.90 ms
(70.12%)
🐰 View full continuous benchmarking report in Bencher

@zkochan

zkochan commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

The red Bencher Report is runner variance, not a regression from this PR.

Evidence: I re-ran the integrated benchmark on the same commit (7b3e8c9706, no code change between the runs) and the alert moved to a different scenario entirely.

Run Alerting benchmark Δ
1 isolated-linker.peer-heavy-resolve.hot-cache.offline +20.03% (100.02% of boundary)
2 isolated-linker.fresh-resolve.hot-cache.offline +76.74% (147.28% of boundary)

peer-heavy-resolve came back under its boundary in run 2. Two runs of identical code producing two different "regressions" — one of them 76% — is the shared-runner contention this report's own preamble warns about.

It also cannot be this diff on the merits: both alerting scenarios resolve offline from a hot metadata mirror with no lockfile and no linking (see the BenchmarkScenario doc comments in pnpm/tasks/integrated-benchmark/src/cli_args.rs). PruneStaleModules runs in the link phase and only when a current lockfile exists, so the changed code never executes in either scenario. On the paths where it does run, the added work with dedupeDirectDeps off — its default — is one Option::is_some_and on a None per direct dependency.

I have kicked off one more re-run to try to land the check green.


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

@zkochan
zkochan merged commit edf5e6f into main Aug 10, 2026
35 of 36 checks passed
@zkochan
zkochan deleted the fix-13775 branch August 10, 2026 19:50
@zkochan

zkochan commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Third run of the same commit, third different set of alerting benchmarks:

Run Alerting benchmark(s) Δ
1 peer-heavy-resolve.hot-cache.offline +20.03%
2 fresh-resolve.hot-cache.offline +76.74%
3 fresh-install.hot-cache.hot-store, fresh-restore.hot-cache.hot-store +38.75%, +41.11%

No code changed between any of these — all three ran against 7b3e8c9706. Each run's alert clears in the next one and a different scenario takes its place, which is what the runner contention this report warns about looks like. I am going to stop re-running rather than keep burning runner time on a coin flip.

For the record on the merits: the changed code is a per-direct-dependency comparison inside PruneStaleModules, which runs only in the link phase and only when a current lockfile exists. With dedupeDirectDeps at its default (off), the added work is one Option::is_some_and on a None per direct dependency. It cannot move a hot-cache install by 38%, and it does not execute at all in the two resolve-only scenarios that alerted in runs 1 and 2.

Happy to re-run again if you would rather see the check green before merging.


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

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.

dedupeDirectDeps: a project's symlink that becomes redundant is not removed on a later install (regression in 12; 10 and 11 remove it)

3 participants