Skip to content

perf(lockfile): drop removed dependencies without resolving - #13698

Merged
zkochan merged 5 commits into
mainfrom
fast-remove
Aug 7, 2026
Merged

zkochan merged 5 commits into
mainfrom
fast-remove

Conversation

@zkochan

@zkochan zkochan commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Related to #13696, the first of the cases that still re-resolve even though the lockfile already answers them.

A dependency the lockfile records but the manifest no longer declares forced a full resolution. Answering it needs no registry access at all: drop the importer's entry and prune whatever that leaves unreachable. Both stacks already had the pruning, from the ignoredOptionalDependencies handler.

  • Extend the importer fast path in both stacks to drop entries the manifest dropped.
  • Fix hasChangedProjectSpecifiers, which only compared the manifest against the lockfile in one direction, so a removed dependency was never noticed as a change and the fast path was never offered the case.

Scope, and what this does not do yet

This is the lockfile transformation pnpm remove performs, and it applies today to an install over a hand-edited package.json — which is the same operation a user reaches for when they delete a dependency by hand.

Wiring the remove command itself still needs the mutation gate opened, and that is deliberately not in this PR. The gates differ between the stacks: the TypeScript CLI gates on installsOnly (allMutationsAreInstalls) and feeds removals into resolution via removePackages, while pacquet's pacquet remove is ProjectMutation::NoInstall, a variant it shares with link, import, fetch, and rebuild. Opening either gate is its own change with its own risks, and it is easier to review once the transformation underneath it is settled.

When it falls back

A surviving package that resolves a peer through the removed one has its id embedded in its own key, so the removal would rekey the dependent rather than only prune it. Peer suffixes are checked after pruning, so a peer-dependent package that the removal itself makes unreachable does not force a fallback. A peer suffix pnpm shortened into a hash cannot be read to rule the above out, so that falls back too.

What review and CI added

  • A catalog entry that loses its last referent is pruned, matching a full resolution — in this handler and in the merged ignoredOptionalDependencies handler, which had the same gap.
  • The TypeScript handler stages its work on a cloned candidate, so a rejected fast update leaves the caller's lockfile untouched.
  • Two of the three original CI failures (rehoist, pendingBuilds) were symptoms of a pre-existing headless bug, fixed separately in fix(deps-restorer): react to removed packages in the headless install #13700; this PR's tests now pass on top of it.

Squash Commit Body

A dependency the lockfile records but the manifest no longer declares
needed a full resolution, even though answering it takes no registry
access: drop the importer entry and prune what that leaves unreachable.

`hasChangedProjectSpecifiers` compared the manifest against the lockfile
in one direction only, so a dropped dependency was not noticed as a
change and the fast path was never offered the case.

Fall back when a surviving package resolves a peer through a dropped one:
its id is embedded in that package's key, so the removal would rekey the
dependent rather than only prune it. A peer suffix pnpm shortened into a
hash cannot be read to rule that out, so it falls back too.

This is the lockfile transformation `pnpm remove` performs, and applies
today to an install over a hand-edited manifest. Wiring the remove
mutation itself needs the mutation gate opened, which differs between the
stacks and is left to its own change.

Related to pnpm/pnpm#13696.

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


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

  • New Features

    • Removing dependencies updates the lockfile and installed packages without registry access.
    • Unused dependency entries, package subtrees, and catalog entries are automatically pruned while referenced data is preserved.
    • Peer dependency relationships are validated before pruning to prevent unsafe updates.
  • Bug Fixes

    • Removed dependencies are no longer retained in importer metadata or linked in node_modules.
    • Updates safely fall back when removal could affect peer resolution.

Copilot AI lite review requested due to automatic review settings August 7, 2026 10:17

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 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 554aff6f-21de-4777-bfc9-d06f304fd223

📥 Commits

Reviewing files that changed from the base of the PR and between bb102fb and 15062be.

📒 Files selected for processing (7)
  • pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs
  • pnpm/crates/package-manager/src/fast_update_catalog_versions.rs
  • pnpm/crates/package-manager/src/fast_update_catalogs.rs
  • pnpm/crates/package-manager/src/fast_update_importers/tests.rs
  • pnpm11/installing/deps-installer/src/install/index.ts
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts
  • pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts
📝 Walkthrough

Walkthrough

Dependency removal now uses fast lockfile updates in Rust and TypeScript. Removed importer entries, unreachable packages, and orphaned catalog entries are pruned without registry access. Updates fall back to full resolution when surviving peer references depend on removed packages.

Changes

Dependency removal fast updates

Layer / File(s) Summary
Rust fast-update pruning
pnpm/crates/package-manager/src/fast_update_importers.rs, pnpm/crates/package-manager/src/fast_update_lockfile.rs, pnpm/crates/package-manager/src/fast_update_catalogs.rs, pnpm/crates/package-manager/src/fast_update_ignored_optional_dependencies.rs
The Rust path removes undeclared dependencies, validates peer suffixes, prunes unreachable packages, and removes unreferenced catalogs.
TypeScript fast-update integration
pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts, pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts, pnpm11/installing/deps-installer/src/install/tryFastUpdateIgnoredOptionalDependencies.ts
The TypeScript path detects removed specifiers, updates a cloned lockfile, removes empty groups, prunes packages and catalogs, and commits changes only after peer validation succeeds.
Fast-update regression coverage
pnpm/crates/package-manager/src/fast_update_importers/tests.rs, pnpm/crates/package-manager/src/fast_update_ignored_optional_dependencies/tests.rs, pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts, pnpm11/installing/deps-installer/test/install/ignoredOptionalDependencies.ts
Tests cover dependency subtree pruning, peer-dependent removals, hashed peer suffix fallback, catalog retention and removal, empty dependency groups, and ignored optional dependencies.
CLI regression coverage and release metadata
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs, .changeset/drop-removed-dependencies-without-resolving.md
CLI coverage verifies offline removal from the lockfile and node_modules. The changeset records patch releases and peer-resolution fallback behavior.

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

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#13464 — Modifies fast lockfile update logic for removed dependencies and unreachable entries.
  • pnpm/pnpm#13482 — Modifies fast lockfile pruning for ignored optional dependencies.
  • pnpm/pnpm#13477 — Modifies fast importer and catalog update paths.

Suggested labels: product: pacquet, product: pnpm@11

✨ 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 fast-remove

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

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

Copy link
Copy Markdown

PR Summary by Qodo

Fast-path lockfile updates when dependencies are removed from manifest

✨ Enhancement 🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Fast-update lockfile when manifest drops dependencies by deleting importer edges and pruning
 unreachable entries.
• Fix specifier-change detection so removed dependencies trigger the fast path.
• Prune orphaned catalog entries and add coverage for peer-suffix and hashed-suffix fallbacks.
Diagram

graph TD
  A["Install command"] --> B["Specifier change check"] --> C["Fast update importers"] --> D[("pnpm-lock.yaml")]
  C --> E["Prune unreachable"] --> F{"Peer suffix safe?"} --> D
  F -->|"yes"| G["Prune catalogs"] --> D
  F -->|"no"| H["Full resolution"] --> D

  subgraph Legend
    direction LR
    _svc(["Process/step"]) ~~~ _dec{"Decision"} ~~~ _data[("Lockfile data")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Always fall back to full resolution on any removal
  • ➕ Simplest correctness story; no peer-suffix corner cases
  • ➕ No need for additional pruning/callback logic
  • ➖ Regresses performance/offline behavior for common “remove dep then install” workflow
  • ➖ Unnecessary registry access when lockfile already contains the answer
2. Support peer-suffix rekeying instead of falling back
  • ➕ Would keep fast path even when surviving packages embed dropped peers
  • ➕ Eliminates a class of fallback installs
  • ➖ Significantly more complex: requires reconstructing peer graphs and rewriting depPaths/snapshots safely
  • ➖ Higher risk of subtle lockfile corruption; harder to validate across lockfile versions
3. Centralize pruning + safety checks in a shared library across Rust/TS
  • ➕ Reduces divergence between pacquet and TS CLI implementations
  • ➕ Easier to keep catalog/peer-suffix rules consistent over time
  • ➖ Non-trivial refactor; may not be feasible given language boundary
  • ➖ Delays delivering the immediate performance fix

Recommendation: Current approach is a good trade-off: it captures the high-value removal fast-path (no registry access) while keeping correctness via explicit fallbacks for peer-suffix rekeying and hashed suffixes. Consider rekeying support only after collecting real-world fallback frequency and adding more lockfile fixtures around peer-suffix formats.

Files changed (13) +757 / -24

Enhancement (4) +209 / -22
fast_update_importers.rsDrop manifest-removed importer deps and guard against peer-suffix rekeying +80/-5

Drop manifest-removed importer deps and guard against peer-suffix rekeying

• Extends importer fast update to remove dependencies missing from the manifest, clean up empty groups/specifiers, prune unreachable packages, and prune unreferenced catalog entries. Adds a safety check that falls back when any surviving snapshot’s peer suffix could reference a dropped package (including hashed suffix cases).

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

fast_update_lockfile.rsAdd catalog pruning utility for fast-update paths +32/-0

Add catalog pruning utility for fast-update paths

• Implements prune_unreferenced_catalog_entries to remove catalog entries that no importer references anymore, mirroring full-resolution output.

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

tryFastUpdateCatalogs.tsAdd TS helper to prune unreferenced catalog entries +21/-0

Add TS helper to prune unreferenced catalog entries

• Implements pruneUnreferencedCatalogEntries for the TypeScript installer, deleting orphaned aliases and empty catalogs, and removing the catalogs object when empty.

pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts

tryFastUpdateImporters.tsExtend TS importer fast update to handle removals + fix change detection +76/-17

Extend TS importer fast update to handle removals + fix change detection

• Fixes hasChangedProjectSpecifiers to detect dependencies removed from the manifest. Updates tryFastUpdateImporters to clone the lockfile, drop removed specifiers/dependency entries, prune packages, validate peer-suffix safety (fallback on hashed/unsafe suffix), prune orphaned catalogs, and then commit changes back only on success.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts

Bug fix (2) +4 / -0
fast_update_ignored_optional_dependencies.rsPrune unreferenced catalog entries after optional-dep fast update +1/-0

Prune unreferenced catalog entries after optional-dep fast update

• Extends the ignoredOptionalDependencies fast-update path to also remove orphaned catalog entries after pruning unreachable packages.

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

tryFastUpdateIgnoredOptionalDependencies.tsInvoke catalog pruning after ignored-optional fast update +3/-0

Invoke catalog pruning after ignored-optional fast update

• Imports and calls pruneUnreferencedCatalogEntries to keep catalogs consistent after pruning optional dependencies without full resolution.

pnpm11/installing/deps-installer/src/install/tryFastUpdateIgnoredOptionalDependencies.ts

Refactor (1) +5 / -1
fast_update_catalogs.rsExpose catalog reference checker for pruning +5/-1

Expose catalog reference checker for pruning

• Makes catalog_entry_is_referenced public(crate) so other fast-update paths can prune catalogs based on importer references.

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

Tests (5) +532 / -1
lockfile_resolution_reuse.rsAdd end-to-end test asserting removal skips resolution +70/-0

Add end-to-end test asserting removal skips resolution

• Introduces an integration test that installs once, removes a dependency from package.json, rewrites registry to a dead URL, and verifies install skips resolution while pruning the removed package from lockfile and node_modules.

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs

tests.rsTest catalog entry pruning when ignored optional dep was sole referent +37/-0

Test catalog entry pruning when ignored optional dep was sole referent

• Adds coverage ensuring that ignoring the only catalog-referenced optional dependency removes the now-orphaned catalogs section.

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

tests.rsAdd comprehensive tests for importer-removal fast path and fallbacks +275/-1

Add comprehensive tests for importer-removal fast path and fallbacks

• Adds fixtures and tests for removing a dependency, pruning its subtree, catalog-entry pruning, keeping catalogs referenced by other importers, succeeding when peer-dependent snapshots become unreachable, and rejecting when peer suffixes (including hashed) make rekeying possible.

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

ignoredOptionalDependencies.tsTest TS catalog pruning for ignored optional dependencies +27/-0

Test TS catalog pruning for ignored optional dependencies

• Adds a Jest test verifying that ignoring an optional dependency that was the only catalog referent removes the catalogs section.

pnpm11/installing/deps-installer/test/install/ignoredOptionalDependencies.ts

importerRemovalFastUpdate.tsAdd Jest suite for importer removal fast-update behavior +123/-0

Add Jest suite for importer removal fast-update behavior

• Adds tests confirming: removals are detected as changes, dropped deps are removed and their subtree pruned, peer-suffix and hashed-suffix cases fall back without mutation, emptied dependency groups are deleted, and catalog entries are pruned/retained appropriately across importers.

pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts

Documentation (1) +7 / -0
drop-removed-dependencies-without-resolving.mdAdd release note for removal fast-path lockfile behavior +7/-0

Add release note for removal fast-path lockfile behavior

• Documents that removing a dependency from package.json no longer forces re-resolution. Notes pruning behavior (packages and catalogs) and the peer-suffix-based fallback conditions.

.changeset/drop-removed-dependencies-without-resolving.md

@greptile-apps

greptile-apps Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains, and the previously reported narrating comment has been removed without changing behavior.

Reviews (5): Last reviewed commit: "fix(lockfile): parse catalog references ..." | 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: 4

🧹 Nitpick comments (1)
pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts (1)

105-106: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use string operations for peer delimiters.

After peersIndex identifies the suffix, use slice(1, -1) instead of two custom regular expressions.

As per coding guidelines, prefer plain string operations over custom regular expressions.

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

In `@pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts`
around lines 105 - 106, In the peer-suffix parsing logic after peersIndex
identifies the suffix, replace the chained leading and trailing parenthesis
regular-expression calls with a single slice(1, -1) operation. Preserve removal
of exactly the outer peer delimiters.

Source: Coding guidelines

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

Inline comments:
In `@pnpm/crates/package-manager/src/fast_update_importers.rs`:
- Around line 36-40: Update the removal fast path in
pnpm/crates/package-manager/src/fast_update_importers.rs:36-40 and
pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts:75-87 to
create a detached candidate with importer edges removed, prune or compute
reachability first, then validate peer suffixes only against surviving
snapshots/packages. Fall back only when a reachable peer suffix references a
dropped dependency, while preserving the existing pruning, mutation, and removal
behavior.

In `@pnpm/crates/package-manager/src/fast_update_importers/tests.rs`:
- Around line 158-170: Add hashed peer-suffix regression coverage in
`rejects_dropping_a_dependency_another_package_resolves_as_a_peer` and the
equivalent `tryFastUpdateImporters` test: create fixtures whose peer suffix is
opaque/hashed, then assert `try_fast_update_importers()` returns `None` in
`tests.rs` and `tryFastUpdateImporters()` returns `false` in
`importerRemovalFastUpdate.ts`; update both affected files at the specified
ranges.

In `@pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts`:
- Around line 61-75: Stage the importer aliases to remove instead of deleting
them directly from lockfile.importers during the loop. Run
peerSuffixesAreIndependentOf() against the staged state or equivalent validation
input, return false without mutating lockfile when validation rejects, and apply
all removals only after validation succeeds. Add an assertion in the
peer-fallback test confirming subject remains unchanged.
- Around line 69-71: After deleting the alias in tryFastUpdateImporters, remove
any now-empty dependencies, devDependencies, or optionalDependencies group from
importer. Preserve non-empty groups and align the resulting lockfile shape with
the Rust implementation.

---

Nitpick comments:
In `@pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts`:
- Around line 105-106: In the peer-suffix parsing logic after peersIndex
identifies the suffix, replace the chained leading and trailing parenthesis
regular-expression calls with a single slice(1, -1) operation. Preserve removal
of exactly the outer peer delimiters.
🪄 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: 8ba08efa-c619-40d6-acd9-69399dfc8657

📥 Commits

Reviewing files that changed from the base of the PR and between 654af93 and fea68fe.

📒 Files selected for processing (6)
  • .changeset/drop-removed-dependencies-without-resolving.md
  • pnpm/crates/cli/tests/lockfile_resolution_reuse.rs
  • pnpm/crates/package-manager/src/fast_update_importers.rs
  • pnpm/crates/package-manager/src/fast_update_importers/tests.rs
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts
  • pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.01     15.3±0.91ms    24.4 MB/sec    1.00     15.3±1.64ms    24.5 MB/sec
packument/parse                                  1.00     45.4±2.15µs  1461.9 MB/sec    1.00     45.3±1.82µs  1464.6 MB/sec
tarball/download_dependency                      1.00      2.9±0.45ms  1515.2 KB/sec    1.53      4.4±1.13ms   988.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   233.0±16.46ms 68.7 KElem/sec    1.24   289.0±41.91ms 55.4 KElem/sec
workspace_resolution/hoist_heavy                 1.00   336.9±24.92ms        ? ?/sec    1.02   343.9±18.63ms        ? ?/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Catalog:default pruned (TS) 🐞 Bug ≡ Correctness
Description
pruneUnreferencedCatalogEntries()/prune_unreferenced_catalog_entries() can delete a default-catalog
snapshot entry that is still referenced because the reference check only treats the bare catalog:
protocol as default-catalog usage and fails to recognize the valid catalog:default specifier. This
can silently drop lockfile.catalogs data during fast-update flows that invoke the new pruning
stage.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[R83-86]

+  for (const [catalogName, catalog] of Object.entries(lockfile.catalogs)) {
+    for (const alias of Object.keys(catalog)) {
+      if (!catalogEntryIsReferenced(lockfile.importers, catalogName, alias)) {
+        delete catalog[alias]
Relevance

●●● Strong

Same bug pattern accepted before: default catalog reference check must treat catalog:default as
referenced.

PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The codebase explicitly supports catalog:default as a legitimate way to reference the default
catalog (via the catalog protocol parsing logic and related tests), but the newly introduced pruning
stage decides whether to keep or delete catalog snapshots using a helper that, for `catalogName ==
"default", only string-compares against catalog:`. As a result, an importer dependency specified
as catalog:default can be misclassified as unreferenced by
catalogEntryIsReferenced()/catalog_entry_is_referenced() and then pruned, leading to unintended
removal of lockfile.catalogs entries during fast-update execution paths.

pnpm11/catalogs/protocol-parser/src/parseCatalogProtocol.ts[7-17]
pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts[76-90]
pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[48-55]
pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[77-96]
pnpm/crates/catalogs-protocol-parser/src/tests.rs[14-22]
pnpm/crates/package-manager/src/fast_update_catalogs/tests.rs[194-219]
pnpm/crates/package-manager/src/fast_update_catalogs.rs[105-127]
pnpm/crates/package-manager/src/fast_update_lockfile.rs[60-89]

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 catalog-pruning step (`pruneUnreferencedCatalogEntries()` / `prune_unreferenced_catalog_entries()`) can incorrectly remove default-catalog snapshot entries that are still in use because the reference-check helper only recognizes `catalog:` as a default-catalog reference, even though `catalog:default` is also a supported/default-catalog specifier. This can cause fast-update flows to silently delete `lockfile.catalogs` data.

## Issue Context
- The project’s catalog protocol parsing supports both `catalog:` and `catalog:default` as valid references to the default catalog.
- The pruning logic was introduced/expanded in this PR and is invoked from fast-update paths, so a misclassification here can lead to catalog snapshot deletion even when importers still reference those entries.
- The current reference check for the default catalog relies on strict string matching that does not account for `catalog:default`.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[76-96]
- pnpm/crates/package-manager/src/fast_update_lockfile.rs[59-90]
- pnpm/crates/package-manager/src/fast_update_catalogs.rs[105-109]

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


2. Mutates lockfile on fallback ✓ Resolved 🐞 Bug ≡ Correctness
Description
tryFastUpdateImporters() deletes importer entries for dropped deps before
peerSuffixesAreIndependentOf() validation; when the peer-suffix check fails it returns false but
leaves the passed-in lockfile mutated. This can corrupt fallback behavior for direct callers (and
violates the established “no mutation on failure” contract for these fast-update helpers).
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R66-69]

+      if (manifestSpecifiers[alias] != null) continue
+      dropped.add(alias)
+      delete importer.specifiers[alias]
+      delete importer.dependencies?.[alias]
Relevance

●●● Strong

Team previously accepted “no mutation on failure”/atomic fast-update contract for this helper area.

PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The implementation deletes importer entries (specifier + dependency maps) while building dropped,
and only afterwards performs the peer-suffix validation that may return false. The newly added
test exercises the fallback (toBe(false)) but does not assert the input lockfile is unchanged.
This matches a previously accepted bug pattern in the same function area where mutation-on-failure
was considered incorrect.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[61-88]
pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts[24-34]
PR-#13477

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

### Issue description
`tryFastUpdateImporters()` performs in-place deletions for dropped dependencies before it knows whether it must fall back (peer-suffix dependency). If it falls back (`return false`), the caller’s lockfile object is left partially modified.

### Issue Context
This function is exported and is called directly in unit tests, so callers can observe mutation even when the function reports failure. Prior work in this area established/expected transactional behavior (no mutation unless the function succeeds).

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[27-90]
- pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts[24-35]

### Suggested fix
- Do **not** delete from `importer.specifiers`/`dependencies` until after `peerSuffixesAreIndependentOf()` passes.
 - Compute `dropped` by comparing `importer.specifiers` keys to `manifestSpecifiers` **without mutating**.
 - Run `peerSuffixesAreIndependentOf(lockfile, dropped)`.
 - Only then apply deletions and run `pruneSharedLockfile`.
- Add a regression assertion to the new peer-fallback test that the lockfile is unchanged when `tryFastUpdateImporters()` returns `false` (deep equality against a pre-call clone).

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



Remediation recommended

3. Peer check substring false-positives 🐞 Bug ➹ Performance
Description
The peer-suffix safety check searches for dropped aliases using a raw substring match like
"{alias}@" against the entire peer suffix, which can false-positive when one package name is a
suffix of another (e.g. dropped "is" matches "this@"). This needlessly forces a full resolution
(safe but slower) and reduces how often the new fast path triggers.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R104-107]

+                .split(")(")
+                .all(|segment| segment.contains('@'))
+                && !dropped.iter().any(|name| peers.contains(&format!("{name}@"))))
+    })
Relevance

●● Moderate

Potential correctness/perf edge-case, but no close precedent found on peer-suffix parsing
false-positives.

PR-#13680

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both implementations use substring search (contains/includes) for "{alias}@" in the peer suffix;
substring matching can collide across distinct package names and will conservatively fail the fast
path even when no dropped peer is present.

pnpm/crates/package-manager/src/fast_update_importers.rs[88-108]
pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[100-120]

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

### Issue description
`peer_suffixes_are_independent_of()` (Rust) and its TS equivalent check for dropped peers by doing `contains("{name}@")` over the raw peer suffix string. This is not delimiter-aware and can match unrelated package names that merely contain the same substring, causing conservative (but unnecessary) fallback to full resolution.

### Issue Context
The peer suffix is already split into `)(` segments; each segment that contains an `@` appears to be a `name@version`-like token (including scoped names). We can extract the peer *package name* from each segment and compare for exact equality against the dropped set.

### Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[94-108]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[108-119]

### Suggested fix approach
- After splitting into segments, derive the peer package name as `segment[..segment.rfind('@')]` (last `@` separates name from version even for scoped names).
- Compare that extracted name for exact equality against dropped package names (precomputed as strings, e.g. `HashSet<String>` / `Set<string>`), instead of substring searching within the full `peers` string.
- Keep the existing “hashed suffix” conservative fallback (`segment.includes('@')` / `segment.contains('@')`) as-is.

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


4. Per-key Set spread allocation 🐞 Bug ➹ Performance
Description
peerSuffixesAreIndependentOf() spreads dropped into an array ([...dropped]) for every package
key checked, causing avoidable allocations and extra work in large lockfiles when removing deps.
This overhead is on the dependency-removal fast-update path and is easy to eliminate without
changing behavior.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R107-110]

+      .split(')(')
+      .every((segment) => segment.includes('@')) &&
+      ![...dropped].some((alias) => peers.includes(`${alias}@`))
+  })
Relevance

●● Moderate

Perf micro-optimization; no close accepted precedent, and similar perf refactors were previously
rejected.

PR-#13600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code performs [...dropped] inside the per-package loop, guaranteeing an allocation per
depPath processed.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[99-110]

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

### Issue description
`peerSuffixesAreIndependentOf()` allocates a new array from the `dropped` Set for each `depPath` (`![...dropped].some(...)`). This is unnecessary and can add noticeable overhead when `lockfile.packages` is large.

### Issue Context
This check runs whenever at least one dependency is dropped and fast-update attempts to validate peer-suffix safety.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[99-110]

### Suggested fix
- Move the Set materialization outside the `every()` loop:
 - `const droppedList = [...dropped]` once, then use `droppedList.some(...)`, **or**
 - iterate the Set directly with a `for (const alias of dropped)` loop and early-return false when matched.
- Keep semantics identical (still fallback if any dropped alias appears in the peer suffix).

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



Informational

5. Extra parsing in pruning loop 🐞 Bug ➹ Performance ⭐ New
Description
The new catalogEntryIsReferenced() logic parses+trims each importer specifier via
parseCatalogProtocol() inside a nested scan used by catalog-entry pruning, adding avoidable
per-check overhead compared to direct string comparisons. This is a low-severity constant-factor
slowdown on the fast-update path when many importers and catalog entries exist.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[R55-57]

+  return Object.values(importers).some(
+    (importer) => parseCatalogProtocol(importer.specifiers[alias] ?? '') === catalogName
+  )
Relevance

● Weak

Similar fast-path constant-factor perf micro-optimizations were previously rejected as unnecessary
complexity.

PR-#13600
PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
catalogEntryIsReferenced() is called from the pruning loop and now invokes
parseCatalogProtocol() per importer; parseCatalogProtocol() performs a .slice(...).trim()
normalization, making this repeated parsing avoidable when simple equality checks would suffice for
the canonical spellings.

pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[48-58]
pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[80-99]
pnpm11/catalogs/protocol-parser/src/parseCatalogProtocol.ts[1-17]

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

### Issue description
`catalogEntryIsReferenced()` now calls `parseCatalogProtocol()` for every importer inspected. Because pruning scans catalogs×aliases and calls this helper for each entry, this adds repeated parsing work in a hot-ish loop.

### Issue Context
This change was made to ensure `catalog:default` counts as a reference to the default catalog. That behavior must be preserved.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[48-58]

### Suggested fix
Implement a fast path that avoids parsing for the common canonical spellings:
- If `catalogName === 'default'`: treat referenced when `specifier === 'catalog:' || specifier === 'catalog:default'`.
- Else: treat referenced when `specifier === `catalog:${catalogName}``.
- Optionally keep the current parser-based behavior only as a fallback when `specifier` starts with `catalog:` but doesn’t match canonical forms (to preserve any whitespace-tolerant behavior if needed).

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


6. Quadratic specifier pruning 🐞 Bug ➹ Performance
Description
Rust remove_dependencies_absent_from() prunes importer.specifiers with removed.iter().any(...) and
per-iteration to_string() allocations, yielding avoidable O(specifiers×removed) work when many
deps are removed. This extra work runs specifically on the removal fast-update path and can erode
the intended speedup for bulk removals.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R82-85]

+    if let Some(specifiers) = importer.specifiers.as_mut() {
+        specifiers.retain(|alias, _| !removed.iter().any(|name| name.to_string() == *alias));
+    }
+    removed
Relevance

●●● Strong

Team recently accepted removing per-iteration to_string() allocations in fast-update Rust paths;
same issue here.

PR-#13482

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new pruning logic performs nested scans and allocations while updating importer state; this
overhead is introduced by the new removal-handling code path.

pnpm/crates/package-manager/src/fast_update_importers.rs[49-86]

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_dependencies_absent_from()` does nested iteration and repeated string allocations when pruning `importer.specifiers`, which is avoidable overhead.

### Issue Context
Current code:
- Builds `removed: HashSet<PkgName>`.
- For each `specifiers` entry, scans `removed` and allocates `name.to_string()` repeatedly.

### Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[49-86]

### Suggested fix approach
- Build a `HashSet<String>` once:
 - `let removed_names: HashSet<String> = removed.iter().map(ToString::to_string).collect();`
 - Then `specifiers.retain(|alias, _| !removed_names.contains(alias));`
- Similarly, avoid `alias.to_string()` in `declared(...)` by parsing manifest aliases once into `HashSet<PkgName>` (or by building a `HashSet<String>` of manifest keys and comparing against a precomputed `alias_str` once per alias).

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


7. Redundant lockfile cloning 🐞 Bug ➹ Performance
Description
In the TypeScript stack, tryFastUpdateImporters() deep-clones the lockfile even though
tryFastUpdateLockfile() already clones before invoking the update callback, doubling clone work on
the fast-update path. On large lockfiles this extra clone can materially reduce the performance
benefit of skipping resolution.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R33-35]

+  const candidate = clone(lockfile)
+  const dropped = new Set<string>()
+  let changed = false
Relevance

● Weak

Direct precedent: suggestion to avoid deep-cloning lockfile on TS fast path was rejected; same
change type/context.

PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The TS fast-update wrapper already deep-clones the lockfile before calling the update callback; the
new tryFastUpdateImporters now deep-clones again, creating an unnecessary second full clone on this
path.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[29-38]
pnpm11/installing/deps-installer/src/install/tryFastUpdateLockfile.ts[4-18]
pnpm11/installing/deps-installer/src/install/index.ts[706-813]

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

### Issue description
`tryFastUpdateImporters()` performs `clone(lockfile)` even when called from the normal fast-update pipeline where `tryFastUpdateLockfile()` already supplies an isolated cloned candidate. This introduces a redundant deep clone that can significantly increase CPU time and peak memory usage for large lockfiles.

### Issue Context
- In production, `tryFastUpdateImporters()` is invoked via `tryFastUpdateLockfile(update: ...)`, which deep-clones the lockfile before calling the update callback.
- The new implementation of `tryFastUpdateImporters()` deep-clones again to ensure atomicity on failure.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[29-98]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateLockfile.ts[4-18]

### Suggested fix approach
- Avoid the second deep clone by making `tryFastUpdateImporters()` atomic without cloning the full lockfile:
 - Stage intended edits (specifier updates + dropped aliases per importer) in temporary data structures.
 - Validate all changes first (semver checks, peer-suffix checks, prune viability).
 - Apply mutations only after validation succeeds.
- Alternatively (if acceptable by API contract), require callers to pass an isolated candidate and remove the internal clone; update tests/callers accordingly.

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


View more (1)
8. YAML append may break test 🐞 Bug ⚙ Maintainability
Description
The new Rust E2E test appends trustLockfile: true to pnpm-workspace.yaml via raw string
concatenation without ensuring a trailing newline, which can produce invalid YAML if the file ever
stops ending with \n. This makes the test setup brittle and prone to future false failures.
Code

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[R1070-1073]

+    let workspace_yaml =
+        fs::read_to_string(&workspace_yaml_path).expect("read pnpm-workspace.yaml");
+    fs::write(&workspace_yaml_path, format!("{workspace_yaml}trustLockfile: true\n"))
+        .expect("enable trusted lockfile");
Relevance

● Weak

Very recent close precedent rejected replacing YAML string-concat in same test file.

PR-#13600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test reads the YAML file and immediately appends a new key via
format!("{workspace_yaml}trustLockfile: true\n"), which is sensitive to whether workspace_yaml
already ends with a newline. This matches a previously accepted brittleness pattern in similar
tests.

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[1069-1073]
PR-#13386

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 appends YAML by concatenating strings. If the existing YAML content does not end with a newline, the appended key can run into the previous line and break parsing.

### Issue Context
This is test-only, but it can create flaky/fragile CI failures when fixtures change formatting.

### Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[1069-1073]

### Suggested fix
- Before appending, ensure the file ends with `\n` (conditionally add one), or use an existing repo helper for editing workspace YAML (if available).
- Keep the test intent unchanged (enable `trustLockfile: true`).

ⓘ 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

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

Previous review results

Review updated until commit 15062be

Results up to commit fea68fe ⚖️ Balanced


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


Action required
1. Mutates lockfile on fallback ✓ Resolved 🐞 Bug ≡ Correctness
Description
tryFastUpdateImporters() deletes importer entries for dropped deps before
peerSuffixesAreIndependentOf() validation; when the peer-suffix check fails it returns false but
leaves the passed-in lockfile mutated. This can corrupt fallback behavior for direct callers (and
violates the established “no mutation on failure” contract for these fast-update helpers).
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R66-69]

+      if (manifestSpecifiers[alias] != null) continue
+      dropped.add(alias)
+      delete importer.specifiers[alias]
+      delete importer.dependencies?.[alias]
Relevance

●●● Strong

Team previously accepted “no mutation on failure”/atomic fast-update contract for this helper area.

PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The implementation deletes importer entries (specifier + dependency maps) while building dropped,
and only afterwards performs the peer-suffix validation that may return false. The newly added
test exercises the fallback (toBe(false)) but does not assert the input lockfile is unchanged.
This matches a previously accepted bug pattern in the same function area where mutation-on-failure
was considered incorrect.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[61-88]
pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts[24-34]
PR-#13477

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

### Issue description
`tryFastUpdateImporters()` performs in-place deletions for dropped dependencies before it knows whether it must fall back (peer-suffix dependency). If it falls back (`return false`), the caller’s lockfile object is left partially modified.

### Issue Context
This function is exported and is called directly in unit tests, so callers can observe mutation even when the function reports failure. Prior work in this area established/expected transactional behavior (no mutation unless the function succeeds).

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[27-90]
- pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts[24-35]

### Suggested fix
- Do **not** delete from `importer.specifiers`/`dependencies` until after `peerSuffixesAreIndependentOf()` passes.
 - Compute `dropped` by comparing `importer.specifiers` keys to `manifestSpecifiers` **without mutating**.
 - Run `peerSuffixesAreIndependentOf(lockfile, dropped)`.
 - Only then apply deletions and run `pruneSharedLockfile`.
- Add a regression assertion to the new peer-fallback test that the lockfile is unchanged when `tryFastUpdateImporters()` returns `false` (deep equality against a pre-call clone).

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



Remediation recommended
2. Per-key Set spread allocation 🐞 Bug ➹ Performance
Description
peerSuffixesAreIndependentOf() spreads dropped into an array ([...dropped]) for every package
key checked, causing avoidable allocations and extra work in large lockfiles when removing deps.
This overhead is on the dependency-removal fast-update path and is easy to eliminate without
changing behavior.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R107-110]

+      .split(')(')
+      .every((segment) => segment.includes('@')) &&
+      ![...dropped].some((alias) => peers.includes(`${alias}@`))
+  })
Relevance

●● Moderate

Perf micro-optimization; no close accepted precedent, and similar perf refactors were previously
rejected.

PR-#13600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code performs [...dropped] inside the per-package loop, guaranteeing an allocation per
depPath processed.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[99-110]

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

### Issue description
`peerSuffixesAreIndependentOf()` allocates a new array from the `dropped` Set for each `depPath` (`![...dropped].some(...)`). This is unnecessary and can add noticeable overhead when `lockfile.packages` is large.

### Issue Context
This check runs whenever at least one dependency is dropped and fast-update attempts to validate peer-suffix safety.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[99-110]

### Suggested fix
- Move the Set materialization outside the `every()` loop:
 - `const droppedList = [...dropped]` once, then use `droppedList.some(...)`, **or**
 - iterate the Set directly with a `for (const alias of dropped)` loop and early-return false when matched.
- Keep semantics identical (still fallback if any dropped alias appears in the peer suffix).

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



Informational
3. YAML append may break test 🐞 Bug ⚙ Maintainability
Description
The new Rust E2E test appends trustLockfile: true to pnpm-workspace.yaml via raw string
concatenation without ensuring a trailing newline, which can produce invalid YAML if the file ever
stops ending with \n. This makes the test setup brittle and prone to future false failures.
Code

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[R1070-1073]

+    let workspace_yaml =
+        fs::read_to_string(&workspace_yaml_path).expect("read pnpm-workspace.yaml");
+    fs::write(&workspace_yaml_path, format!("{workspace_yaml}trustLockfile: true\n"))
+        .expect("enable trusted lockfile");
Relevance

● Weak

Very recent close precedent rejected replacing YAML string-concat in same test file.

PR-#13600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test reads the YAML file and immediately appends a new key via
format!("{workspace_yaml}trustLockfile: true\n"), which is sensitive to whether workspace_yaml
already ends with a newline. This matches a previously accepted brittleness pattern in similar
tests.

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[1069-1073]
PR-#13386

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 appends YAML by concatenating strings. If the existing YAML content does not end with a newline, the appended key can run into the previous line and break parsing.

### Issue Context
This is test-only, but it can create flaky/fragile CI failures when fixtures change formatting.

### Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[1069-1073]

### Suggested fix
- Before appending, ensure the file ends with `\n` (conditionally add one), or use an existing repo helper for editing workspace YAML (if available).
- Keep the test intent unchanged (enable `trustLockfile: true`).

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


Results up to commit bb102fb ⚖️ Balanced


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


Remediation recommended
1. Peer check substring false-positives 🐞 Bug ➹ Performance
Description
The peer-suffix safety check searches for dropped aliases using a raw substring match like
"{alias}@" against the entire peer suffix, which can false-positive when one package name is a
suffix of another (e.g. dropped "is" matches "this@"). This needlessly forces a full resolution
(safe but slower) and reduces how often the new fast path triggers.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R104-107]

+                .split(")(")
+                .all(|segment| segment.contains('@'))
+                && !dropped.iter().any(|name| peers.contains(&format!("{name}@"))))
+    })
Relevance

●● Moderate

Potential correctness/perf edge-case, but no close precedent found on peer-suffix parsing
false-positives.

PR-#13680

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both implementations use substring search (contains/includes) for "{alias}@" in the peer suffix;
substring matching can collide across distinct package names and will conservatively fail the fast
path even when no dropped peer is present.

pnpm/crates/package-manager/src/fast_update_importers.rs[88-108]
pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[100-120]

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

### Issue description
`peer_suffixes_are_independent_of()` (Rust) and its TS equivalent check for dropped peers by doing `contains("{name}@")` over the raw peer suffix string. This is not delimiter-aware and can match unrelated package names that merely contain the same substring, causing conservative (but unnecessary) fallback to full resolution.

### Issue Context
The peer suffix is already split into `)(` segments; each segment that contains an `@` appears to be a `name@version`-like token (including scoped names). We can extract the peer *package name* from each segment and compare for exact equality against the dropped set.

### Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[94-108]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[108-119]

### Suggested fix approach
- After splitting into segments, derive the peer package name as `segment[..segment.rfind('@')]` (last `@` separates name from version even for scoped names).
- Compare that extracted name for exact equality against dropped package names (precomputed as strings, e.g. `HashSet<String>` / `Set<string>`), instead of substring searching within the full `peers` string.
- Keep the existing “hashed suffix” conservative fallback (`segment.includes('@')` / `segment.contains('@')`) as-is.

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



Informational
2. Quadratic specifier pruning 🐞 Bug ➹ Performance
Description
Rust remove_dependencies_absent_from() prunes importer.specifiers with removed.iter().any(...) and
per-iteration to_string() allocations, yielding avoidable O(specifiers×removed) work when many
deps are removed. This extra work runs specifically on the removal fast-update path and can erode
the intended speedup for bulk removals.
Code

pnpm/crates/package-manager/src/fast_update_importers.rs[R82-85]

+    if let Some(specifiers) = importer.specifiers.as_mut() {
+        specifiers.retain(|alias, _| !removed.iter().any(|name| name.to_string() == *alias));
+    }
+    removed
Relevance

●●● Strong

Team recently accepted removing per-iteration to_string() allocations in fast-update Rust paths;
same issue here.

PR-#13482

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new pruning logic performs nested scans and allocations while updating importer state; this
overhead is introduced by the new removal-handling code path.

pnpm/crates/package-manager/src/fast_update_importers.rs[49-86]

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_dependencies_absent_from()` does nested iteration and repeated string allocations when pruning `importer.specifiers`, which is avoidable overhead.

### Issue Context
Current code:
- Builds `removed: HashSet<PkgName>`.
- For each `specifiers` entry, scans `removed` and allocates `name.to_string()` repeatedly.

### Fix Focus Areas
- pnpm/crates/package-manager/src/fast_update_importers.rs[49-86]

### Suggested fix approach
- Build a `HashSet<String>` once:
 - `let removed_names: HashSet<String> = removed.iter().map(ToString::to_string).collect();`
 - Then `specifiers.retain(|alias, _| !removed_names.contains(alias));`
- Similarly, avoid `alias.to_string()` in `declared(...)` by parsing manifest aliases once into `HashSet<PkgName>` (or by building a `HashSet<String>` of manifest keys and comparing against a precomputed `alias_str` once per alias).

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


3. Redundant lockfile cloning 🐞 Bug ➹ Performance
Description
In the TypeScript stack, tryFastUpdateImporters() deep-clones the lockfile even though
tryFastUpdateLockfile() already clones before invoking the update callback, doubling clone work on
the fast-update path. On large lockfiles this extra clone can materially reduce the performance
benefit of skipping resolution.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[R33-35]

+  const candidate = clone(lockfile)
+  const dropped = new Set<string>()
+  let changed = false
Relevance

● Weak

Direct precedent: suggestion to avoid deep-cloning lockfile on TS fast path was rejected; same
change type/context.

PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The TS fast-update wrapper already deep-clones the lockfile before calling the update callback; the
new tryFastUpdateImporters now deep-clones again, creating an unnecessary second full clone on this
path.

pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[29-38]
pnpm11/installing/deps-installer/src/install/tryFastUpdateLockfile.ts[4-18]
pnpm11/installing/deps-installer/src/install/index.ts[706-813]

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

### Issue description
`tryFastUpdateImporters()` performs `clone(lockfile)` even when called from the normal fast-update pipeline where `tryFastUpdateLockfile()` already supplies an isolated cloned candidate. This introduces a redundant deep clone that can significantly increase CPU time and peak memory usage for large lockfiles.

### Issue Context
- In production, `tryFastUpdateImporters()` is invoked via `tryFastUpdateLockfile(update: ...)`, which deep-clones the lockfile before calling the update callback.
- The new implementation of `tryFastUpdateImporters()` deep-clones again to ensure atomicity on failure.

### Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts[29-98]
- pnpm11/installing/deps-installer/src/install/tryFastUpdateLockfile.ts[4-18]

### Suggested fix approach
- Avoid the second deep clone by making `tryFastUpdateImporters()` atomic without cloning the full lockfile:
 - Stage intended edits (specifier updates + dropped aliases per importer) in temporary data structures.
 - Validate all changes first (semver checks, peer-suffix checks, prune viability).
 - Apply mutations only after validation succeeds.
- Alternatively (if acceptable by API contract), require callers to pass an isolated candidate and remove the internal clone; update tests/callers accordingly.

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


Results up to commit 4157267 ⚖️ Balanced


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


Action required
1. Catalog:default pruned (TS) 🐞 Bug ≡ Correctness
Description
pruneUnreferencedCatalogEntries()/prune_unreferenced_catalog_entries() can delete a default-catalog
snapshot entry that is still referenced because the reference check only treats the bare catalog:
protocol as default-catalog usage and fails to recognize the valid catalog:default specifier. This
can silently drop lockfile.catalogs data during fast-update flows that invoke the new pruning
stage.
Code

pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[R83-86]

+  for (const [catalogName, catalog] of Object.entries(lockfile.catalogs)) {
+    for (const alias of Object.keys(catalog)) {
+      if (!catalogEntryIsReferenced(lockfile.importers, catalogName, alias)) {
+        delete catalog[alias]
Relevance

●●● Strong

Same bug pattern accepted before: default catalog reference check must treat catalog:default as
referenced.

PR-#13477

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The codebase explicitly supports catalog:default as a legitimate way to reference the default
catalog (via the catalog protocol parsing logic and related tests), but the newly introduced pruning
stage decides whether to keep or delete catalog snapshots using a helper that, for `catalogName ==
"default", only string-compares against catalog:`. As a result, an importer dependency specified
as catalog:default can be misclassified as unreferenced by
catalogEntryIsReferenced()/catalog_entry_is_referenced() and then pruned, leading to unintended
removal of lockfile.catalogs entries during fast-update execution paths.

pnpm11/catalogs/protocol-parser/src/parseCatalogProtocol.ts[7-17]
pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts[76-90]
pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[48-55]
pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[77-96]
pnpm/crates/catalogs-protocol-parser/src/tests.rs[14-22]
pnpm/crates/package-manager/src/fast_update_catalogs/tests.rs[194-219]
pnpm/crates/package-manager/src/fast_update_catalogs.rs[105-127]
pnpm/crates/package-manager/src/fast_update_lockfile.rs[60-89]

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 catalog-pruning step (`pruneUnreferencedCatalogEntries()` / `prune_unreferenced_catalog_entries()`) can incorrectly remove default-catalog snapshot entries that are still in use because the reference-check helper only recognizes `catalog:` as a default-catalog reference, even though `catalog:default` is also a supported/default-catalog specifier. This can cause fast-update flows to silently delete `lockfile.catalogs` data.

## Issue Context
- The project’s catalog protocol parsing supports both `catalog:` and `catalog:default` as valid references to the default catalog.
- The pruning logic was introduced/expanded in this PR and is invoked from fast-update paths, so a misclassification here can lead to catalog snapshot deletion even when importers still reference those entries.
- The current reference check for the default catalog relies on strict string matching that does not account for `catalog:default`.

## Fix Focus Areas
- pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts[76-96]
- pnpm/crates/package-manager/src/fast_update_lockfile.rs[59-90]
- pnpm/crates/package-manager/src/fast_update_catalogs.rs[105-109]

ⓘ 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 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.01961% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.21%. Comparing base (b11fa81) to head (15062be).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...crates/package-manager/src/fast_update_lockfile.rs 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13698      +/-   ##
==========================================
+ Coverage   88.19%   88.21%   +0.01%     
==========================================
  Files         615      615              
  Lines       99955   100070     +115     
==========================================
+ Hits        88157    88273     +116     
+ Misses      11798    11797       -1     

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

@blacksmith-sh

blacksmith-sh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Found 4 test failures on Blacksmith runners:

Failures

Test View Logs
test/fetch.ts/fetch View Logs
test/fetch.ts/fetch View Logs
test/fetch.ts/fetch View Logs
test/fetch.ts/fetch View Logs

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

@zkochan
zkochan marked this pull request as draft August 7, 2026 10:35
@zkochan

zkochan commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

Moving this to draft: CI found three real regressions, and they point at something structural rather than a bug in the rewrite.

All three are installs that remove packages, and all three now take the fast path where they used to resolve:

  • lockfile catalog snapshots should remove unused entries — a catalog entry that nothing references any more is no longer pruned.
  • pendingBuilds gets updated if install removes packages — .modules.yaml keeps the builds that the removal should have dropped.
  • should rehoist after running a general install — hoisting is not recomputed.

The rewritten lockfile itself is right, which is why the unit and integration tests I wrote all pass. What is missing is everything else an install does when packages disappear. Those steps live on the full-resolution path, and the fast path routes around them into headless materialization.

That has a consequence beyond this PR, which is the part worth attention: the same reasoning applies to any fast path that removes packages, and tryFastUpdateIgnoredOptionalDependencies already does. It prunes exactly the same way, and it is not covered by these three tests. I have not confirmed it, but it looks like the same latent gap.

So the question this PR has to answer first is not "how do I prune catalogs too" — it is whether removal bookkeeping belongs on the fast path at all, or whether the fast path needs to signal that packages were dropped so the install still does the removal work. I would rather settle that than bolt three fixes on.

Leaving the transformation and its tests in place, since they are useful either way.


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

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 15062be19448

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.779 ± 0.133 2.600 2.989 1.74 ± 0.16
pacquet@main 2.882 ± 0.192 2.616 3.217 1.80 ± 0.18
pnpr@HEAD 1.704 ± 0.126 1.515 1.857 1.07 ± 0.11
pnpr@main 1.597 ± 0.123 1.508 1.909 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.77870506784,
      "stddev": 0.1332120236147204,
      "median": 2.77270309534,
      "user": 2.82189508,
      "system": 2.1416986200000006,
      "min": 2.60010733534,
      "max": 2.98939825734,
      "times": [
        2.66148154834,
        2.87005699934,
        2.93448405634,
        2.7388701483399998,
        2.98939825734,
        2.80653604234,
        2.61537631634,
        2.7223616963399997,
        2.84837827834,
        2.60010733534
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.8815378901399997,
      "stddev": 0.19175325261909817,
      "median": 2.85594338184,
      "user": 3.15813938,
      "system": 2.3550964199999997,
      "min": 2.61598778434,
      "max": 3.21748833934,
      "times": [
        3.21748833934,
        2.61598778434,
        3.08618160734,
        2.91770632734,
        3.0379866883399997,
        2.71578291334,
        2.74334042834,
        2.79418043634,
        2.95004266634,
        2.73668171034
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.70429361094,
      "stddev": 0.1256561921698147,
      "median": 1.71341802184,
      "user": 2.0248186799999996,
      "system": 1.9271801199999998,
      "min": 1.5154695813399999,
      "max": 1.85738680734,
      "times": [
        1.80936353434,
        1.64258010634,
        1.55643668434,
        1.85738680734,
        1.84441507034,
        1.6691058773399998,
        1.75773016634,
        1.80108058734,
        1.58936769434,
        1.5154695813399999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5967111943399999,
      "stddev": 0.12339808476210815,
      "median": 1.5516195163399997,
      "user": 1.9511001799999999,
      "system": 1.81621292,
      "min": 1.50784741634,
      "max": 1.90869308734,
      "times": [
        1.7045404783399998,
        1.5434251803399999,
        1.5441959393399998,
        1.51735607034,
        1.90869308734,
        1.50784741634,
        1.55904309334,
        1.58643166834,
        1.51631368934,
        1.5792653203399998
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 398.6 ± 13.1 380.2 420.2 1.06 ± 0.06
pacquet@main 376.2 ± 16.6 354.5 401.7 1.00
pnpr@HEAD 399.3 ± 27.7 361.3 461.6 1.06 ± 0.09
pnpr@main 416.9 ± 24.4 380.9 444.1 1.11 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.39856557666000003,
      "stddev": 0.013100973245284009,
      "median": 0.39720797866,
      "user": 0.34730472,
      "system": 0.72282356,
      "min": 0.38020713016,
      "max": 0.42015312216,
      "times": [
        0.39220781716,
        0.40135051816,
        0.38020713016,
        0.41737834616,
        0.40154786816000004,
        0.42015312216,
        0.39274616016,
        0.40387344216000004,
        0.39306543916000003,
        0.38312592316000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.37622141496,
      "stddev": 0.016636603744311432,
      "median": 0.37283440166000004,
      "user": 0.32962012,
      "system": 0.7019557599999999,
      "min": 0.35448577916,
      "max": 0.40169102416,
      "times": [
        0.38013504516,
        0.37062995416,
        0.39981205216000004,
        0.40169102416,
        0.37503884916,
        0.35951945116,
        0.36023593916,
        0.37040702416000004,
        0.39025903116000005,
        0.35448577916
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.39929702536000006,
      "stddev": 0.02770367983174071,
      "median": 0.3969541776600001,
      "user": 0.32744752,
      "system": 0.6991955599999999,
      "min": 0.36129755016000004,
      "max": 0.46155554216000005,
      "times": [
        0.40649184716000003,
        0.40382571716000004,
        0.38475774916000005,
        0.38011935116,
        0.36129755016000004,
        0.39008263816000005,
        0.37810270716000005,
        0.41507041216,
        0.41166673916,
        0.46155554216000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.4169027376600001,
      "stddev": 0.024378695921940727,
      "median": 0.42059490616000006,
      "user": 0.35136611999999995,
      "system": 0.7363527599999999,
      "min": 0.38088581716000003,
      "max": 0.44406119816,
      "times": [
        0.44195978516,
        0.44406119816,
        0.42084443916000003,
        0.41720268716000003,
        0.43917039116,
        0.43206277316,
        0.39142359416,
        0.38107131816,
        0.38088581716000003,
        0.42034537316000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.915 ± 0.074 2.759 2.992 1.78 ± 0.19
pacquet@main 2.768 ± 0.072 2.682 2.929 1.69 ± 0.18
pnpr@HEAD 1.735 ± 0.158 1.570 2.033 1.06 ± 0.14
pnpr@main 1.633 ± 0.164 1.481 1.895 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.91476424962,
      "stddev": 0.07372248974317551,
      "median": 2.92927661602,
      "user": 2.7855126599999993,
      "system": 2.1134421199999998,
      "min": 2.75870943052,
      "max": 2.99203416952,
      "times": [
        2.99203416952,
        2.97962703552,
        2.95956847952,
        2.94162195552,
        2.91693127652,
        2.86614164252,
        2.91536196452,
        2.84094262452,
        2.97670391752,
        2.75870943052
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.76780996932,
      "stddev": 0.07185535662735479,
      "median": 2.7449737025200003,
      "user": 2.43225186,
      "system": 1.85823112,
      "min": 2.68160339152,
      "max": 2.92930529452,
      "times": [
        2.74513780252,
        2.72237257152,
        2.74480960252,
        2.71518554952,
        2.80660053752,
        2.68160339152,
        2.72886360052,
        2.77291408352,
        2.92930529452,
        2.83130725952
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.73547785232,
      "stddev": 0.157750700598595,
      "median": 1.69049520952,
      "user": 1.8509898599999999,
      "system": 1.7403537200000003,
      "min": 1.56959375852,
      "max": 2.03314795252,
      "times": [
        2.03314795252,
        1.7022831575200001,
        1.9783354805200002,
        1.61901129652,
        1.67870726152,
        1.58501840552,
        1.7556670895200002,
        1.56959375852,
        1.77654048652,
        1.6564736345200002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.63309192032,
      "stddev": 0.1644809201309766,
      "median": 1.5548393365200002,
      "user": 1.4754571600000002,
      "system": 1.39724112,
      "min": 1.48086128352,
      "max": 1.8946910895200002,
      "times": [
        1.50904585852,
        1.48086128352,
        1.8946910895200002,
        1.48573603952,
        1.59610949452,
        1.49017582452,
        1.51356917852,
        1.73956662352,
        1.76391480552,
        1.85724900552
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 525.4 ± 47.7 450.2 612.0 1.46 ± 0.14
pacquet@main 529.6 ± 34.8 479.8 580.6 1.47 ± 0.10
pnpr@HEAD 360.9 ± 9.0 346.1 375.4 1.00
pnpr@main 367.1 ± 9.5 348.6 376.2 1.02 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5253766385799999,
      "stddev": 0.04770275971347447,
      "median": 0.5280275888800001,
      "user": 0.6847358399999999,
      "system": 0.8708038,
      "min": 0.45015053138,
      "max": 0.61200357138,
      "times": [
        0.5272718213800001,
        0.45982962538,
        0.5052023723800001,
        0.45015053138,
        0.5287833563800001,
        0.61200357138,
        0.5374654373800001,
        0.5741938553800001,
        0.5336762033800001,
        0.5251896113800001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5296492339800001,
      "stddev": 0.034797178335169696,
      "median": 0.5253764948800002,
      "user": 0.70289224,
      "system": 0.8777595,
      "min": 0.47984841838000003,
      "max": 0.58059173738,
      "times": [
        0.5249003723800001,
        0.5002153003800001,
        0.49318091138000003,
        0.51946892038,
        0.47984841838000003,
        0.5314244653800001,
        0.5789879343800001,
        0.58059173738,
        0.5258526173800001,
        0.5620216623800001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.36089513438000004,
      "stddev": 0.009000598427713892,
      "median": 0.35935529738,
      "user": 0.25472474,
      "system": 0.6079199,
      "min": 0.34605104638,
      "max": 0.37535634038,
      "times": [
        0.37229920838,
        0.37535634038,
        0.35742672438,
        0.36712739738,
        0.35209857738,
        0.35578297338,
        0.35905329238,
        0.36409848138,
        0.35965730238,
        0.34605104638
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.36708580678,
      "stddev": 0.009474923085685379,
      "median": 0.36948675238,
      "user": 0.2600574399999999,
      "system": 0.624101,
      "min": 0.34858668838,
      "max": 0.37620268238,
      "times": [
        0.37613575938,
        0.35816945138,
        0.35858683238,
        0.37620268238,
        0.34858668838,
        0.36403108938,
        0.37530643038,
        0.36935940738,
        0.36961409738,
        0.37486562938
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.819 ± 0.050 1.760 1.907 5.84 ± 0.25
pacquet@main 1.767 ± 0.022 1.731 1.815 5.68 ± 0.19
pnpr@HEAD 0.311 ± 0.010 0.300 0.328 1.00
pnpr@main 0.323 ± 0.014 0.291 0.339 1.04 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.81922780644,
      "stddev": 0.050481698581951395,
      "median": 1.81128340674,
      "user": 1.00097562,
      "system": 0.9469894200000001,
      "min": 1.75971028874,
      "max": 1.90674617874,
      "times": [
        1.84604241374,
        1.76541168074,
        1.75971028874,
        1.84824269074,
        1.90674617874,
        1.8804117067400001,
        1.78118415774,
        1.82818027574,
        1.7943865377400001,
        1.78196213374
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.76744969824,
      "stddev": 0.02232357382663734,
      "median": 1.76717477874,
      "user": 0.9057010200000001,
      "system": 0.87836782,
      "min": 1.7313480997400001,
      "max": 1.8148905397400001,
      "times": [
        1.7313480997400001,
        1.75497222074,
        1.78100095374,
        1.76247380074,
        1.75325645974,
        1.75307864074,
        1.77187575674,
        1.77585611974,
        1.7757443907400001,
        1.8148905397400001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31134318344000006,
      "stddev": 0.009848834180836095,
      "median": 0.31013624274,
      "user": 0.19961271999999997,
      "system": 0.5317372199999999,
      "min": 0.29952603474,
      "max": 0.32753286974,
      "times": [
        0.32440611974000005,
        0.30405280774000004,
        0.31300876274,
        0.30494647274000003,
        0.31449693674,
        0.29952603474,
        0.30726372274,
        0.29995841574000004,
        0.31823969174000005,
        0.32753286974
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.32282084064000005,
      "stddev": 0.014124924489811896,
      "median": 0.32573213674,
      "user": 0.23026971999999998,
      "system": 0.5384974199999999,
      "min": 0.29059487074,
      "max": 0.33900199174,
      "times": [
        0.29059487074,
        0.32793552574,
        0.30877188574000003,
        0.33900199174,
        0.32317132074000005,
        0.33424400774,
        0.32799151874000004,
        0.31988671374000005,
        0.33308182374,
        0.32352874774
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 235.2 ± 15.5 214.7 261.4 2.59 ± 0.19
pacquet@main 259.3 ± 23.0 230.0 291.0 2.85 ± 0.27
pnpr@HEAD 90.9 ± 2.8 86.3 99.4 1.00
pnpr@main 91.2 ± 2.5 85.1 95.6 1.00 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.23516882435333333,
      "stddev": 0.015461019235245163,
      "median": 0.23302735252,
      "user": 0.17750971333333332,
      "system": 0.08209989333333333,
      "min": 0.21471230102000002,
      "max": 0.26140433102,
      "times": [
        0.23950868302000003,
        0.22654602202000002,
        0.22234063102,
        0.24926150902000002,
        0.25212515702,
        0.22285172202000003,
        0.26140433102,
        0.21471230102000002,
        0.21929515502000002,
        0.22272653902000003,
        0.24651969102000001,
        0.24473415102000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25927655185333337,
      "stddev": 0.023021349465970908,
      "median": 0.26074079902,
      "user": 0.20475696333333335,
      "system": 0.10394780999999999,
      "min": 0.23003088602000002,
      "max": 0.29099217502,
      "times": [
        0.24231193602000003,
        0.25505565002,
        0.26959849502,
        0.29099217502,
        0.28415576002,
        0.28404310402,
        0.26642594802,
        0.28108156402,
        0.24602454702000004,
        0.23003088602000002,
        0.23074425202,
        0.23085430502000004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09090375423428573,
      "stddev": 0.0027993448753564462,
      "median": 0.09081375002,
      "user": 0.02113623714285714,
      "system": 0.012632774285714285,
      "min": 0.08634069502,
      "max": 0.09938801002,
      "times": [
        0.09938801002,
        0.09163363602,
        0.09040636902,
        0.08663288502000001,
        0.09078551802,
        0.09127931602,
        0.09046029802000001,
        0.09578867602,
        0.09051284702000001,
        0.09002557702,
        0.09228003702,
        0.09285124802,
        0.09223585602,
        0.09235598602,
        0.09375879002000001,
        0.08951864002,
        0.09147813702,
        0.08694752102,
        0.09115040402,
        0.09084198202,
        0.08654843902,
        0.08634069502,
        0.09380583602,
        0.09005132002,
        0.08900348502000001,
        0.09118991602,
        0.08903331702,
        0.08900037702000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09119347689096778,
      "stddev": 0.002527646281024512,
      "median": 0.09085792402000001,
      "user": 0.02292442838709677,
      "system": 0.010878850322580642,
      "min": 0.08512712002,
      "max": 0.09560642902000001,
      "times": [
        0.08903581602,
        0.09051091502,
        0.08804150602000001,
        0.09038468002,
        0.09467876702,
        0.08945591202,
        0.09336372402,
        0.08839379102,
        0.09121996802,
        0.09440619602,
        0.09402492002,
        0.09288561602,
        0.09418689002,
        0.09443147602,
        0.08922623602,
        0.09168926002000001,
        0.09026962702,
        0.08582952702,
        0.08512712002,
        0.08975021602000001,
        0.09000033302,
        0.09089903702,
        0.09149039602,
        0.09051905802,
        0.09060697202000001,
        0.09251099702,
        0.09085792402000001,
        0.09560642902000001,
        0.09325719602,
        0.09376414902,
        0.09057312902
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 714.1 ± 120.6 522.8 877.6 1.00
pacquet@main 861.9 ± 232.1 562.7 1160.2 1.21 ± 0.38
pnpm@HEAD 2905.5 ± 18.0 2878.4 2930.4 4.07 ± 0.69
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7140545341577779,
      "stddev": 0.12055056958438311,
      "median": 0.71439352538,
      "user": 0.648780031111111,
      "system": 0.15710334444444443,
      "min": 0.5227664413800001,
      "max": 0.8776215673800001,
      "times": [
        0.72537000738,
        0.85721936938,
        0.71439352538,
        0.81240540238,
        0.5227664413800001,
        0.62957610138,
        0.8776215673800001,
        0.59091931338,
        0.69621907938
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.8618564633800001,
      "stddev": 0.23213315253222078,
      "median": 0.9183695133800001,
      "user": 0.7915569199999999,
      "system": 0.1724507888888889,
      "min": 0.56269887138,
      "max": 1.16024518938,
      "times": [
        1.10699608338,
        0.9183695133800001,
        1.0588162113800001,
        1.16024518938,
        0.56269887138,
        0.7329479303800001,
        0.6236486383800001,
        0.98165472738,
        0.61133100538
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 2.90551175038,
      "stddev": 0.018043188512289345,
      "median": 2.90687330738,
      "user": 4.190231364444444,
      "system": 0.28667690000000007,
      "min": 2.87844623438,
      "max": 2.93038506538,
      "times": [
        2.88640310938,
        2.8944631493800004,
        2.92605612538,
        2.87844623438,
        2.91856724338,
        2.9133773243800003,
        2.89503419438,
        2.90687330738,
        2.93038506538
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.686 ± 0.140 4.508 4.889 1.29 ± 0.05
pacquet@main 4.799 ± 0.148 4.526 5.037 1.32 ± 0.05
pnpr@HEAD 3.724 ± 0.133 3.586 4.035 1.02 ± 0.05
pnpr@main 3.634 ± 0.097 3.524 3.777 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.68569577396,
      "stddev": 0.1398919787695273,
      "median": 4.674456274460001,
      "user": 2.5116119800000005,
      "system": 1.9873386199999998,
      "min": 4.50843051946,
      "max": 4.88857493246,
      "times": [
        4.71101671346,
        4.88857493246,
        4.63789583546,
        4.53445099246,
        4.76141656946,
        4.80031738746,
        4.56350378546,
        4.86840708146,
        4.58294392246,
        4.50843051946
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.79927283186,
      "stddev": 0.14767258959754545,
      "median": 4.80070945246,
      "user": 2.98221418,
      "system": 2.2627349199999998,
      "min": 4.5258523004599995,
      "max": 5.0374898434599995,
      "times": [
        4.5258523004599995,
        4.82712156446,
        4.65916221346,
        5.0374898434599995,
        4.770433339459999,
        4.97511393846,
        4.7757259004599995,
        4.82569300446,
        4.87338370046,
        4.72275251346
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.72442779446,
      "stddev": 0.1332662329012653,
      "median": 3.70775872046,
      "user": 2.0774082799999998,
      "system": 1.8757845200000003,
      "min": 3.5859517344600005,
      "max": 4.03466746246,
      "times": [
        3.6853266884600004,
        3.8117802714600004,
        3.5859517344600005,
        3.61575140846,
        3.6674804244600003,
        3.5929628944600003,
        3.7731785004600003,
        3.73019075246,
        3.7469878074600005,
        4.03466746246
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.6339179919600006,
      "stddev": 0.09726785409017333,
      "median": 3.6043760594600003,
      "user": 1.7335309799999998,
      "system": 1.5829256200000001,
      "min": 3.52427909446,
      "max": 3.77686427646,
      "times": [
        3.65300675146,
        3.77250515546,
        3.58484494246,
        3.74016430746,
        3.5462289354600003,
        3.6239071764600004,
        3.5460490794600004,
        3.5713302004600003,
        3.52427909446,
        3.77686427646
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13698
Testbedpacquet

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
isolated-linker.fresh-restore.hot-cache.hot-storeLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
380.21 ms
(+34.64%)Baseline: 282.39 ms
338.86 ms
(112.20%)

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,758.71 ms
(+3.72%)Baseline: 2,659.72 ms
3,191.66 ms
(86.43%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,759.71 ms
(-0.59%)Baseline: 1,770.08 ms
2,124.09 ms
(82.85%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
450.15 ms
(+1.20%)Baseline: 444.79 ms
533.75 ms
(84.34%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
214.71 ms
(+1.52%)Baseline: 211.51 ms
253.81 ms
(84.60%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,600.11 ms
(+6.54%)Baseline: 2,440.59 ms
2,928.71 ms
(88.78%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,508.43 ms
(-0.06%)Baseline: 4,511.08 ms
5,413.30 ms
(83.28%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
🚨 view alert (🔔)
380.21 ms
(+34.64%)Baseline: 282.39 ms
338.86 ms
(112.20%)

isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
522.77 ms
(-28.17%)Baseline: 727.78 ms
873.33 ms
(59.86%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13698
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

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

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,468.31 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
294.99 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
293.62 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
88.40 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,404.76 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,456.36 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
294.90 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan

zkochan commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

The redesign landed as its own PR: #13700 fixes the underlying headless bug (#13699) that this PR's CI surfaced — the hoist layer and pendingBuilds now react to removed packages, computed from the wanted lockfile rather than the incremental work list. Two of the three CI failures here were symptoms of it.

Once 13700 merges, this PR gets rebased on top of it; the remaining work here is the third failure, which is genuinely this PR's: pruning catalog snapshots that lose their last referent when an importer edge is dropped.


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

zkochan added a commit that referenced this pull request Aug 7, 2026
… review

A dropped importer edge whose specifier was a catalog reference left the
catalog snapshot behind once nothing referenced it, where a full
resolution removes it. Prune unreferenced catalog entries after dropping
edges, in the removal handler and in the ignored-optional handler, which
had the same gap since it also removes importer edges. Both stacks.

Stage the TypeScript removal on a cloned candidate so a rejected fast
update leaves the callers lockfile untouched, matching the Rust handler,
which already returned a fresh candidate.

Check peer suffixes after pruning rather than before: a peer-dependent
package that the removal itself makes unreachable needs no rekeying, so
dropping a dependency together with its dependent now takes the fast
path. Delete importer dependency groups the removal empties, matching
the Rust handler, and cover the hashed-peer-suffix fallback in both
stacks.

Reported by CodeRabbit, Greptile, and Qodo on #13698.
@zkochan
zkochan marked this pull request as ready for review August 7, 2026 12:42
Copilot AI review requested due to automatic review settings August 7, 2026 12:42

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 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 `@pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts`:
- Around line 73-97: Update tryFastUpdateImporters() to reject the fast path
when dropped dependencies require install-side state changes, including
pendingBuilds or hoisting, rather than committing the candidate directly. Keep
the fast path limited to safe importer updates and use the existing full-install
fallback for removals; add an integration regression verifying installed state
and relevant .modules.yaml fields after removing a dependency.
🪄 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: ec54399d-5b40-4879-b6a9-4525ca8fe9ab

📥 Commits

Reviewing files that changed from the base of the PR and between fea68fe and bb102fb.

📒 Files selected for processing (12)
  • .changeset/drop-removed-dependencies-without-resolving.md
  • pnpm/crates/package-manager/src/fast_update_catalogs.rs
  • pnpm/crates/package-manager/src/fast_update_ignored_optional_dependencies.rs
  • pnpm/crates/package-manager/src/fast_update_ignored_optional_dependencies/tests.rs
  • pnpm/crates/package-manager/src/fast_update_importers.rs
  • pnpm/crates/package-manager/src/fast_update_importers/tests.rs
  • pnpm/crates/package-manager/src/fast_update_lockfile.rs
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateCatalogs.ts
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateIgnoredOptionalDependencies.ts
  • pnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.ts
  • pnpm11/installing/deps-installer/test/install/ignoredOptionalDependencies.ts
  • pnpm11/installing/deps-installer/test/install/importerRemovalFastUpdate.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/drop-removed-dependencies-without-resolving.md
  • pnpm/crates/package-manager/src/fast_update_importers.rs

@qodo-code-review

Copy link
Copy Markdown

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

@qodo-code-review

Copy link
Copy Markdown

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

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

…tocol

The referenced-check compared importer specifiers to a rebuilt protocol
string, so the catalog:default spelling of the default catalog read as
unreferenced. The range-only handler has carried that since it landed,
where the miss only dropped a config-removed entry early; the pruning
this PR adds turned it into losing a live entry. Parse the specifier
with the catalog protocol parser on both sides instead.

The sole-reference check of the exact-version rewrite had the same
comparison with the opposite failure direction -- a catalog:default
referent fell back needlessly -- so it parses now too.

Reported by Qodo on #13698.
Copilot AI review requested due to automatic review settings August 7, 2026 13:37

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

Code review by qodo was updated up to the latest commit 15062be

@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 merged commit fa6a7b2 into main Aug 7, 2026
36 of 37 checks passed
@zkochan
zkochan deleted the fast-remove branch August 7, 2026 14:12
@zkochan

zkochan commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

For the record on the Bencher alert (isolated-linker.fresh-restore.hot-cache.hot-store, 380.21ms vs a 338.86ms boundary): that scenario runs install --frozen-lockfile (integrated-benchmark/src/cli_args.rs), and every code path this PR added is gated on !frozen_lockfile — the fast-update coordinator is not entered at all on a frozen restore, and the TypeScript changes do not run in pacquet. No baseline for this scenario existed on the PR's earlier pushes to compare against, so this reads as measurement noise rather than a regression from this diff.

If the main-branch trend for this benchmark stays elevated after the merge commit, that would falsify the noise reading and deserve a bisect — worth a glance at the next few main runs.


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

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

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants