Skip to content

fix(deps-restorer): react to removed packages in the headless install - #13700

Merged
zkochan merged 3 commits into
mainfrom
headless-removal
Aug 7, 2026
Merged

zkochan merged 3 commits into
mainfrom
headless-removal

Conversation

@zkochan

@zkochan zkochan commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #13699.

The headless installer derives its work from the incremental dependency graph — the packages the wanted lockfile records that are not materialized yet. An install whose lockfile only removes packages has an empty graph, so every graph-driven stage silently did nothing:

  • the hoist layer was never recomputed, so a package that became hoistable when a direct dependency was removed stayed unhoisted;
  • pendingBuilds only ever appended, so entries for removed packages stayed pending forever.

Reachable with no unusual flags: pull a lockfile in which a teammate removed a dependency and run pnpm install — allProjectsAreUpToDate sends it down the headless path. Both symptoms reproduce on main; the regression tests in this PR fail without the fix.

The fix

Desired state is computed from the wanted lockfile; incrementality stays at the I/O layer.

  • The graph includes the unchanged packages whenever the transition from the installed state removes a package — the same includeUnchangedDeps mechanism a hoist-pattern change already uses. Unchanged nodes carry no fetch, so they are not re-imported (linkAllPkgs skips them) and are marked isBuilt so the build step does not re-run their scripts or re-apply their patches.
  • With the graph complete, the recomputed hoist map replaces the recorded one instead of merging over it, so entries this install made ineligible are dropped from .modules.yaml.
  • pendingBuilds is reconciled against the wanted lockfile rather than appended: entries whose package the lockfile no longer records are dropped.

The removal check compares the current lockfile against the full wanted lockfile, not the importer-filtered one, so a --filter install is not mistaken for a removal.

pacquet

pacquet already behaves this way — real_hoist::hoist reads the lockfile, and merge_pending_builds retains only entries the current lockfile still records (covered by existing unit tests). The Rust side gains a pinning test for the rehoist scenario, which passes unchanged.

pacquet's own pending_builds test module already pins the removal scenario (removing_a_package_shrinks_the_list), so no Rust test was added either. An earlier revision of this description claimed a pendingBuilds population divergence; that was my misreading of a probe (#13701, closed as incorrect).

Why this PR exists

Surfaced by #13698, whose removal fast path routed three existing tests into the headless path and made them fail. Those failures were symptoms of this pre-existing bug — any fast lockfile update that removes packages (the merged ignoredOptionalDependencies handler included) inherits it. Fixing headless fixes them all at once; 13698 will be rebased on top of this.

Squash Commit Body

The headless installer derives its work from the incremental graph — the
packages the wanted lockfile records that are not materialized yet. An
install whose lockfile only removes packages has an empty graph, so every
graph-driven stage silently did nothing: the hoist layer was never
recomputed (a package that became hoistable when a direct dependency was
removed stayed unhoisted), and pendingBuilds only ever appended, so
entries for removed packages stayed pending forever.

Reachable with no unusual flags: pull a lockfile in which a dependency
was removed and run `pnpm install` — allProjectsAreUpToDate sends it down
the headless path.

Include the unchanged packages in the graph whenever the transition from
the installed state removes a package, the same mechanism a hoist-pattern
change already uses. Unfetched nodes are marked built so the build step
does not re-run their scripts or re-apply their patches, and with the
graph complete the recomputed hoist map replaces the recorded one instead
of merging over it. pendingBuilds is reconciled against the wanted
lockfile rather than appended.

pacquet already behaves this way — its hoist pass reads the lockfile and
its pending-builds merge retains only entries the current lockfile still
records — so the Rust side only gains a pinning test.

Fixes pnpm/pnpm#13699.

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

  • Bug Fixes

    • Lockfile-only installs now correctly recalculate dependency hoisting after packages are removed.
    • Removed packages no longer leave stale pending build entries.
    • Headless installs better reconcile dependencies and workspace packages with the updated lockfile.
  • Tests

    • Added regression coverage for dependency removal, rehoisting, and pending build cleanup.

Copilot AI lite review requested due to automatic review settings August 7, 2026 11:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f96416d9-ab22-483e-87a8-50d1317673d8

📥 Commits

Reviewing files that changed from the base of the PR and between 927a894 and f6f3ad2.

📒 Files selected for processing (4)
  • pnpm/crates/cli/tests/hoist.rs
  • pnpm11/installing/deps-installer/test/install/hoist.ts
  • pnpm11/installing/deps-installer/test/lockfile.ts
  • pnpm11/installing/deps-restorer/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • pnpm11/installing/deps-installer/test/lockfile.ts
  • pnpm/crates/cli/tests/hoist.rs
  • pnpm11/installing/deps-restorer/src/index.ts

📝 Walkthrough

Walkthrough

Headless installation now detects removed lockfile packages, recomputes hoisting, marks unchanged graph nodes as built, and reconciles pendingBuilds. Regression tests cover rehoisting and pending-build cleanup after lockfile-only dependency removal.

Changes

Headless removal reconciliation

Layer / File(s) Summary
Lockfile removal planning
pnpm11/installing/deps-restorer/src/index.ts
The headless path detects removed packages, includes unchanged dependencies, marks non-fetched nodes as built, and recomputes hoisting with configured workspace packages.
Install state reconciliation
pnpm11/installing/deps-restorer/src/index.ts
pendingBuilds is reconciled against the wanted lockfile and current graph instead of only appending entries.
Regression coverage and release metadata
pnpm/crates/cli/tests/hoist.rs, pnpm11/installing/deps-installer/test/install/hoist.ts, pnpm11/installing/deps-installer/test/lockfile.ts, .changeset/headless-removal-bookkeeping.md
Tests verify private rehoisting and removal of stale pending builds. Patch release metadata documents the changes.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant headlessInstall
  participant WantedLockfile
  participant Hoisting
  participant ModulesManifest

  User->>headlessInstall: run install
  headlessInstall->>WantedLockfile: compare installed and wanted packages
  WantedLockfile-->>headlessInstall: return removed packages
  headlessInstall->>Hoisting: recompute hoisted dependencies
  Hoisting-->>headlessInstall: return updated hoist map
  headlessInstall->>ModulesManifest: reconcile pendingBuilds
  ModulesManifest-->>User: updated install state
Loading

Assessment against linked issues

Objective Addressed Explanation
Recompute private hoisting after lockfile package removal [#13699] ✅
Remove stale pendingBuilds entries after lockfile package removal [#13699] ✅

Possibly related PRs

  • pnpm/pnpm#13151: Modifies install reconciliation and hoisting behavior with related repeat-install coverage.
  • pnpm/pnpm#13289: Modifies headlessInstall lockfile-based dependency graph handling.
  • pnpm/pnpm#13464: Modifies headless linking behavior using current and wanted lockfiles.

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

Suggested reviewers: copilot

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix headless install to handle lockfile-only package removals

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Detect lockfile-only removals and include unchanged deps so hoisting recomputes correctly.
• Reconcile pending builds against the wanted lockfile to drop removed packages.
• Add regression tests (TS + Rust) covering rehoist and pendingBuilds cleanup in headless mode.
Diagram

graph TD
  A["headlessInstall()"] --> B[("Current lockfile")]
  A --> C[("Wanted lockfile")]
  A --> D["Dep graph (includeUnchangedDeps on removal)"] --> E["Hoist recompute"] --> F[(".modules.yaml hoist map")]
  A --> G["pendingBuilds reconcile"] --> H[(".modules.yaml pendingBuilds")]
  I["Regression tests"] --> A
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Force non-headless path on any removal
  • ➕ Avoids having to special-case graph completeness semantics in headless install
  • ➕ Reuses the full install pipeline’s existing hoist/build behaviors
  • ➖ Potentially much slower for common “pull lockfile and install” workflows
  • ➖ Broader behavioral change vs. a targeted headless fix
2. Always include unchanged deps in headless dep graph
  • ➕ Simplifies logic by removing conditional graph expansion
  • ➕ Makes hoist recomputation consistently complete
  • ➖ May increase memory/CPU for large workspaces even when unnecessary
  • ➖ Could reduce the benefit of incremental headless installs
3. Recompute hoist directly from lockfile without graph expansion
  • ➕ Decouples hoisting from incremental graph shape
  • ➕ Could avoid carrying non-fetched nodes through later stages
  • ➖ More invasive refactor; risks divergence from existing hoist implementation expectations
  • ➖ May still require careful handling for build/patched state

Recommendation: Current approach is the best tradeoff: it keeps headless installs incremental by default, but selectively expands the graph only when removals would otherwise make the graph empty/incomplete. Replacing (not merging) the hoist map only when the graph is known-complete avoids regressing true incremental installs, and reconciling pendingBuilds against the wanted lockfile prevents stale entries without overbuilding.

Files changed (5) +180 / -38

Bug fix (1) +68 / -38
index.tsFix headless install to handle lockfile removals (hoist + pendingBuilds) +68/-38

Fix headless install to handle lockfile removals (hoist + pendingBuilds)

• Expands the dep graph to include unchanged packages when the installed→wanted transition removes any package, ensuring hoist recomputation can see all relevant nodes. Marks unfetched (already materialized) nodes as built to avoid re-running scripts/patches, replaces the hoist map when the graph is complete, and reconciles pendingBuilds against the wanted lockfile to drop removed entries. Adds a helper to detect removals using the full wanted lockfile to avoid misclassifying filtered installs.

pnpm11/installing/deps-restorer/src/index.ts

Tests (3) +106 / -0
hoist.rsAdd Rust regression test for rehoist after lockfile-only removal +46/-0

Add Rust regression test for rehoist after lockfile-only removal

• Introduces a test that simulates removing a direct dependency via a lockfile-only update, then running a headless install. Asserts that the previously-direct dependency becomes hoisted once it becomes purely transitive.

pnpm/crates/cli/tests/hoist.rs

hoist.tsAdd TS test for rehoist on headless install after dependency removal +29/-0

Add TS test for rehoist on headless install after dependency removal

• Adds a scenario where a direct dependency is removed via a lockfile-only install, followed by a normal install that takes the headless path. Verifies that the newly-hoistable transitive dependency becomes hoisted.

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

lockfile.tsAdd TS test for pendingBuilds cleanup under headless removals +31/-0

Add TS test for pendingBuilds cleanup under headless removals

• Adds a regression test ensuring that pendingBuilds shrinks when packages are removed via a lockfile-only update and the subsequent install is headless. Focuses on ignoreScripts behavior where pending builds are recorded but should be pruned for removed packages.

pnpm11/installing/deps-installer/test/lockfile.ts

Documentation (1) +6 / -0
headless-removal-bookkeeping.mdAdd changeset for headless removal bookkeeping fix +6/-0

Add changeset for headless removal bookkeeping fix

• Adds a patch changeset documenting that headless installs now respond to lockfile-only package removals. Notes hoist recomputation and pendingBuilds pruning behavior.

.changeset/headless-removal-bookkeeping.md

@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: 2

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

Inline comments:
In `@pnpm/crates/cli/tests/hoist.rs`:
- Around line 1546-1587: Extend
rehoists_when_an_up_to_date_lockfile_removes_a_direct_dependency to create
pending builds using --ignore-scripts, remove the dependency through
--lockfile-only, and run the headless install. Then read the resulting wanted
lockfile and assert every remaining pendingBuilds entry references a package
present in that lockfile, covering stale-entry cleanup alongside the existing
rehoisting assertions.

In `@pnpm11/installing/deps-restorer/src/index.ts`:
- Around line 608-618: Reconcile opts.pendingBuilds against wantedLockfile for
every install mode in the deps-restorer flow: always remove entries absent from
wantedLockfile.packages or wantedLockfile.importers, while adding requiresBuild
depNodes only when opts.ignoreScripts is true. In
pnpm11/installing/deps-restorer/src/index.ts lines 608-618, update the logic
around opts.pendingBuilds and depNodes; in
pnpm11/installing/deps-installer/test/lockfile.ts lines 637-667, run the final
install without ignoreScripts and assert every remaining pending entry exists in
the resulting wanted lockfile rather than checking only the count.
🪄 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: 5c5a399a-3529-42ed-8a59-7cc2c6e1c97c

📥 Commits

Reviewing files that changed from the base of the PR and between a8ce5f6 and 927a894.

📒 Files selected for processing (5)
  • .changeset/headless-removal-bookkeeping.md
  • pnpm/crates/cli/tests/hoist.rs
  • pnpm11/installing/deps-installer/test/install/hoist.ts
  • pnpm11/installing/deps-installer/test/lockfile.ts
  • pnpm11/installing/deps-restorer/src/index.ts

Comment thread pnpm/crates/cli/tests/hoist.rs Resolved
@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.00     11.4±0.34ms    32.9 MB/sec    1.01     11.5±0.36ms    32.5 MB/sec
packument/parse                                  1.03     38.8±0.88µs  1710.6 MB/sec    1.00     37.7±0.14µs  1760.7 MB/sec
tarball/download_dependency                      1.06      2.4±0.13ms  1827.5 KB/sec    1.00      2.2±0.09ms  1937.4 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    173.8±8.20ms 92.1 KElem/sec    1.00    174.3±2.39ms 91.8 KElem/sec
workspace_resolution/hoist_heavy                 1.02    241.9±7.35ms        ? ?/sec    1.00    236.7±5.03ms        ? ?/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Prototype-chain key lookups 🐞 Bug ⛨ Security ⭐ New
Description
New pendingBuilds reconciliation and lockfile-removal detection use prototype-chain property reads
on lockfile-derived objects, so inherited keys can be misinterpreted as “present” and bypass
cleanup/detection. This is inconsistent with existing lockfile traversal that explicitly guards with
Object.hasOwn, and can lead to stale .modules.yaml bookkeeping under polluted prototypes.
Code

pnpm11/installing/deps-restorer/src/index.ts[R604-608]

+  // Reconcile in every mode, not only when scripts are ignored: an entry
+  // whose package the wanted lockfile no longer records would otherwise
+  // stay pending forever.
+  opts.pendingBuilds = opts.pendingBuilds
+    .filter((id) => wantedLockfile.packages?.[id as DepPath] != null || wantedLockfile.importers[id as ProjectId] != null)
Relevance

●●● Strong

Team frequently hardens against prototype-chain keys on untrusted objects using
Object.hasOwn/NULL-prototype patterns.

PR-#13464
PR-#11169
PR-#13428

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new reconciliation/removal logic relies on raw property access, while existing lockfile
iteration explicitly skips non-own keys and documents lockfile-derived fields as
attacker-controllable, indicating the project expects defensive own-key handling.

pnpm11/installing/deps-restorer/src/index.ts[604-608]
pnpm11/installing/deps-restorer/src/index.ts[991-996]
pnpm11/deps/graph-builder/src/iteratePkgsForVirtualStore.ts[57-60]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[244-248]

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

### Issue description
New code checks lockfile membership using `obj[key] != null`, which consults the prototype chain.

### Issue Context
Lockfile-derived objects are treated defensively elsewhere in the repo (own-property checks), so this new code should follow the same rule to avoid inherited/prototype-polluted keys being treated as valid lockfile entries.

### Fix Focus Areas
- pnpm11/installing/deps-restorer/src/index.ts[604-608]
- pnpm11/installing/deps-restorer/src/index.ts[991-996]

### Suggested fix
- Replace membership checks with own-property checks:
 - `wantedLockfile.packages != null && Object.hasOwn(wantedLockfile.packages, id)`
 - `Object.hasOwn(wantedLockfile.importers, id)`
- In `lockfileRemovesPackages`, use a `for...in` loop + `Object.hasOwn` and test `Object.hasOwn(wantedPackages, depPath)` instead of `wantedPackages[depPath] == null`.

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


2. Unbounded mkdir fan-out 🐞 Bug ➹ Performance
Description
When a lockfile removes packages, headlessInstall now sets includeUnchangedDeps, which makes
lockfileToDepGraph include unchanged packages too; on large lockfiles this inflates depNodes and
triggers an unbounded Promise.all(fs.mkdir(...)) over all nodes, causing avoidable resource pressure
and slowdowns during removal-only headless installs.
Code

pnpm11/installing/deps-restorer/src/index.ts[R370-373]

    includeUnchangedDeps: (!equals(opts.currentHoistPattern ?? [], opts.hoistPattern ?? [])) ||
      (!equals(opts.currentPublicHoistPattern ?? [], opts.publicHoistPattern ?? [])) ||
-      (opts.enableGlobalVirtualStore === true && !equals(opts.modulesFile?.allowBuilds ?? {}, opts.allowBuilds ?? {})),
+      (opts.enableGlobalVirtualStore === true && !equals(opts.modulesFile?.allowBuilds ?? {}, opts.allowBuilds ?? {})) ||
+      lockfileRemovesPackages(currentLockfile, wantedLockfile),
Relevance

●●● Strong

Team previously accepted bounding unbounded Promise.all filesystem work in deps-restorer to reduce
resource pressure.

PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds lockfileRemovesPackages(...) into the includeUnchangedDeps condition, which enables
unchanged-node inclusion. The graph-builder explicitly documents that includeUnchangedDeps
controls whether unchanged packages are included, and its fast-path early return is disabled when
this option is set. headlessInstall then performs Promise.all mkdir across depNodes, so a larger
graph directly increases concurrent FS work.

pnpm11/installing/deps-restorer/src/index.ts[355-374]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[122-129]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[261-268]
pnpm11/installing/deps-restorer/src/index.ts[462-475]

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

### Issue description
`includeUnchangedDeps` is now enabled when the current -> wanted lockfile transition removes packages. This expands the dep graph to include unchanged packages as well, and headless install subsequently runs `Promise.all(depNodes.map(... fs.mkdir ...))`, which can schedule a very large number of concurrent filesystem operations.

### Issue Context
This is not about reverting the correctness fix (full graph needed for accurate hoisting after removals). The problem is the *unbounded concurrency* of the modules-dir mkdir pass, which becomes much more likely to be large now that removals can trigger a full graph.

### Fix Focus Areas
- pnpm11/installing/deps-restorer/src/index.ts[359-374]
- pnpm11/installing/deps-restorer/src/index.ts[462-466]

### Expected fix
Replace the unbounded `Promise.all(depNodes.map(...fs.mkdir...))` with a bounded variant (e.g., reuse the existing `pLimit(16)` limiter in this file, or introduce a dedicated limiter for mkdirs) so large depGraphs don’t explode concurrent fs operations.

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



Informational

3. Key-scan allocation overhead 🐞 Bug ➹ Performance ⭐ New
Description
lockfileRemovesPackages() allocates Object.keys(currentLockfile.packages) and scans it to detect
removals, adding an extra O(n) pass and temporary memory proportional to lockfile size on the
headless path. This is now part of includeUnchangedDeps computation and will run even when no
removal happened (the common case).
Code

pnpm11/installing/deps-restorer/src/index.ts[R991-996]

+function lockfileRemovesPackages (currentLockfile: LockfileObject | null, wantedLockfile: LockfileObject): boolean {
+  if (currentLockfile?.packages == null) return false
+  const wantedPackages = wantedLockfile.packages
+  if (wantedPackages == null) return Object.keys(currentLockfile.packages).length > 0
+  return Object.keys(currentLockfile.packages).some((depPath) => wantedPackages[depPath as DepPath] == null)
+}
Relevance

● Weak

Very similar “avoid Object.keys(lockfile.packages) allocation” perf suggestion was explicitly
rejected before.

PR-#12855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new includeUnchangedDeps condition calls lockfileRemovesPackages, and that helper
allocates/scans the full package-key list via Object.keys, introducing extra work proportional to
lockfile size.

pnpm11/installing/deps-restorer/src/index.ts[369-374]
pnpm11/installing/deps-restorer/src/index.ts[991-996]

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

### Issue description
`lockfileRemovesPackages()` uses `Object.keys(...).some(...)`, which allocates a full keys array and then iterates.

### Issue Context
This check is evaluated during headlessInstall setup as part of `includeUnchangedDeps`, so it runs on the hot path for “already up to date” installs.

### Fix Focus Areas
- pnpm11/installing/deps-restorer/src/index.ts[372-373]
- pnpm11/installing/deps-restorer/src/index.ts[991-996]

### Suggested fix
- Rewrite `lockfileRemovesPackages` to avoid `Object.keys` allocation:
 - Use `for (const depPath in currentLockfile.packages) { if (!Object.hasOwn(currentLockfile.packages, depPath)) continue; ... }`
 - Early-return on the first detected removal.
 - For `wantedPackages == null`, return `true` on the first own key in `currentLockfile.packages` (else `false`).

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


4. Test masks permission errors 🐞 Bug ☼ Reliability
Description
The new Rust test treats any symlink_metadata error as “path absent”, so unrelated filesystem errors
(e.g. PermissionDenied) can make the test pass without validating the intended condition.
Code

pnpm/crates/cli/tests/hoist.rs[R1567-1570]

+    assert!(
+        fs::symlink_metadata(&hoisted).is_err(),
+        "a direct dependency's name is not privately hoisted",
+    );
Relevance

●●● Strong

Exact accepted precedent: narrow symlink_metadata absence checks to ErrorKind::NotFound to avoid
false-green tests.

PR-#13378

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test currently uses a broad .is_err() check. Prior review guidance explicitly calls out this
pattern and recommends narrowing to ErrorKind::NotFound to avoid false-green tests on unrelated
I/O failures.

pnpm/crates/cli/tests/hoist.rs[1566-1570]
PR-#13378

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 assertion `fs::symlink_metadata(&hoisted).is_err()` passes for *any* I/O error, not just `NotFound`, which can create false-green coverage.

### Issue Context
A past accepted bug fixed the same pattern by checking specifically for `io::ErrorKind::NotFound`.

### Fix Focus Areas
- pnpm/crates/cli/tests/hoist.rs[1566-1570]

### Expected fix
Change the assertion to only accept `Err(e)` where `e.kind() == std::io::ErrorKind::NotFound`, and fail loudly on any other error kind.

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


Grey Divider

Context used
✅ Compliance rules (platform): 24 rules

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

Previous review results

Review updated until commit 53c66cf ⚖️ Balanced

Results up to commit 927a894 ⚖️ Balanced


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


Remediation recommended
1. Unbounded mkdir fan-out 🐞 Bug ➹ Performance
Description
When a lockfile removes packages, headlessInstall now sets includeUnchangedDeps, which makes
lockfileToDepGraph include unchanged packages too; on large lockfiles this inflates depNodes and
triggers an unbounded Promise.all(fs.mkdir(...)) over all nodes, causing avoidable resource pressure
and slowdowns during removal-only headless installs.
Code

pnpm11/installing/deps-restorer/src/index.ts[R370-373]

    includeUnchangedDeps: (!equals(opts.currentHoistPattern ?? [], opts.hoistPattern ?? [])) ||
      (!equals(opts.currentPublicHoistPattern ?? [], opts.publicHoistPattern ?? [])) ||
-      (opts.enableGlobalVirtualStore === true && !equals(opts.modulesFile?.allowBuilds ?? {}, opts.allowBuilds ?? {})),
+      (opts.enableGlobalVirtualStore === true && !equals(opts.modulesFile?.allowBuilds ?? {}, opts.allowBuilds ?? {})) ||
+      lockfileRemovesPackages(currentLockfile, wantedLockfile),
Relevance

●●● Strong

Team previously accepted bounding unbounded Promise.all filesystem work in deps-restorer to reduce
resource pressure.

PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds lockfileRemovesPackages(...) into the includeUnchangedDeps condition, which enables
unchanged-node inclusion. The graph-builder explicitly documents that includeUnchangedDeps
controls whether unchanged packages are included, and its fast-path early return is disabled when
this option is set. headlessInstall then performs Promise.all mkdir across depNodes, so a larger
graph directly increases concurrent FS work.

pnpm11/installing/deps-restorer/src/index.ts[355-374]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[122-129]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[261-268]
pnpm11/installing/deps-restorer/src/index.ts[462-475]

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

### Issue description
`includeUnchangedDeps` is now enabled when the current -> wanted lockfile transition removes packages. This expands the dep graph to include unchanged packages as well, and headless install subsequently runs `Promise.all(depNodes.map(... fs.mkdir ...))`, which can schedule a very large number of concurrent filesystem operations.

### Issue Context
This is not about reverting the correctness fix (full graph needed for accurate hoisting after removals). The problem is the *unbounded concurrency* of the modules-dir mkdir pass, which becomes much more likely to be large now that removals can trigger a full graph.

### Fix Focus Areas
- pnpm11/installing/deps-restorer/src/index.ts[359-374]
- pnpm11/installing/deps-restorer/src/index.ts[462-466]

### Expected fix
Replace the unbounded `Promise.all(depNodes.map(...fs.mkdir...))` with a bounded variant (e.g., reuse the existing `pLimit(16)` limiter in this file, or introduce a dedicated limiter for mkdirs) so large depGraphs don’t explode concurrent fs operations.

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



Informational
2. Test masks permission errors 🐞 Bug ☼ Reliability
Description
The new Rust test treats any symlink_metadata error as “path absent”, so unrelated filesystem errors
(e.g. PermissionDenied) can make the test pass without validating the intended condition.
Code

pnpm/crates/cli/tests/hoist.rs[R1567-1570]

+    assert!(
+        fs::symlink_metadata(&hoisted).is_err(),
+        "a direct dependency's name is not privately hoisted",
+    );
Relevance

●●● Strong

Exact accepted precedent: narrow symlink_metadata absence checks to ErrorKind::NotFound to avoid
false-green tests.

PR-#13378

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test currently uses a broad .is_err() check. Prior review guidance explicitly calls out this
pattern and recommends narrowing to ErrorKind::NotFound to avoid false-green tests on unrelated
I/O failures.

pnpm/crates/cli/tests/hoist.rs[1566-1570]
PR-#13378

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 assertion `fs::symlink_metadata(&hoisted).is_err()` passes for *any* I/O error, not just `NotFound`, which can create false-green coverage.

### Issue Context
A past accepted bug fixed the same pattern by checking specifically for `io::ErrorKind::NotFound`.

### Fix Focus Areas
- pnpm/crates/cli/tests/hoist.rs[1566-1570]

### Expected fix
Change the assertion to only accept `Err(e)` where `e.kind() == std::io::ErrorKind::NotFound`, and fail loudly on any other error kind.

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

@greptile-apps

greptile-apps Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Reviews (3): Last reviewed commit: "style(deps-installer): widen the test he..." | Re-trigger Greptile

@codecov-commenter

codecov-commenter commented Aug 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.19%. Comparing base (e18a6ec) to head (53c66cf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13700      +/-   ##
==========================================
- Coverage   88.19%   88.19%   -0.01%     
==========================================
  Files         615      615              
  Lines       99955    99955              
==========================================
- Hits        88160    88155       -5     
- Misses      11795    11800       +5     

☔ 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

This comment has been minimized.

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 53c66cf42843

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.552 ± 0.156 2.386 2.818 1.66 ± 0.19
pacquet@main 2.631 ± 0.116 2.385 2.726 1.72 ± 0.18
pnpr@HEAD 1.534 ± 0.149 1.344 1.813 1.00
pnpr@main 1.571 ± 0.178 1.372 1.782 1.02 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.55217677416,
      "stddev": 0.1564329216914678,
      "median": 2.48249640426,
      "user": 1.7876368,
      "system": 1.4849071199999997,
      "min": 2.38555849776,
      "max": 2.8181828377600002,
      "times": [
        2.38555849776,
        2.8181828377600002,
        2.49171933976,
        2.74097810276,
        2.40945437976,
        2.4187945757600002,
        2.6358562667600003,
        2.47327346876,
        2.69661402276,
        2.45133624976
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.6308361083600005,
      "stddev": 0.11550065813340968,
      "median": 2.68106674576,
      "user": 1.6328615,
      "system": 1.34186212,
      "min": 2.38459505276,
      "max": 2.72633988676,
      "times": [
        2.4879068867600003,
        2.70741066676,
        2.58046651076,
        2.72633988676,
        2.62054740476,
        2.38459505276,
        2.7253579497600002,
        2.69752275576,
        2.7136032337600002,
        2.66461073576
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5337482412600003,
      "stddev": 0.1490271082381341,
      "median": 1.5843440047600001,
      "user": 1.1607403999999997,
      "system": 1.21170332,
      "min": 1.3437029387600001,
      "max": 1.8133981227600002,
      "times": [
        1.38727879976,
        1.6213252857600002,
        1.6070693117600001,
        1.3437029387600001,
        1.57508155976,
        1.61041585076,
        1.5936064497600002,
        1.8133981227600002,
        1.3838468217600002,
        1.4017572717600002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5708690040600004,
      "stddev": 0.1775875502176949,
      "median": 1.5756028292600002,
      "user": 1.1940938,
      "system": 1.1900625200000001,
      "min": 1.3716204547600002,
      "max": 1.78197209876,
      "times": [
        1.65922013876,
        1.7748484687600001,
        1.4197341567600001,
        1.38247710076,
        1.71535092476,
        1.3764790797600002,
        1.7350020977600003,
        1.78197209876,
        1.3716204547600002,
        1.49198551976
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 290.4 ± 13.1 271.2 307.1 1.05 ± 0.07
pacquet@main 276.5 ± 12.7 262.5 298.0 1.00
pnpr@HEAD 286.9 ± 19.7 261.8 329.2 1.04 ± 0.09
pnpr@main 295.4 ± 16.1 278.0 332.3 1.07 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29035669878000003,
      "stddev": 0.013108150424655008,
      "median": 0.29264344158,
      "user": 0.24247297999999998,
      "system": 0.5602486999999998,
      "min": 0.27122101808000004,
      "max": 0.30708242808,
      "times": [
        0.27184751808,
        0.27122101808000004,
        0.30664845108000005,
        0.28315953308,
        0.30095214808000004,
        0.30708242808,
        0.29457644508,
        0.28144259108,
        0.29592641708000006,
        0.29071043808
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.27648349188,
      "stddev": 0.012687221836831195,
      "median": 0.27474325008,
      "user": 0.22643597999999998,
      "system": 0.5326668999999999,
      "min": 0.26248639608,
      "max": 0.29803244208,
      "times": [
        0.28745146308,
        0.28636860508000006,
        0.26437171508,
        0.26483030908000005,
        0.26248639608,
        0.28748574708,
        0.27220395008000003,
        0.27728255008,
        0.29803244208,
        0.26432174108000006
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28692100928000003,
      "stddev": 0.01969735438811248,
      "median": 0.28591601758000007,
      "user": 0.22086557999999998,
      "system": 0.5407442999999998,
      "min": 0.26180123708,
      "max": 0.32917324408000004,
      "times": [
        0.27451721408,
        0.26180123708,
        0.28316737808000003,
        0.26666651508000005,
        0.29821084708000006,
        0.29475393008000006,
        0.28866465708000005,
        0.32917324408000004,
        0.27379232908,
        0.29846274108000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.2954216586800001,
      "stddev": 0.01609514440066525,
      "median": 0.29100328508000006,
      "user": 0.25041287999999995,
      "system": 0.5433071999999999,
      "min": 0.27798988108000006,
      "max": 0.33231932708000006,
      "times": [
        0.28741790908000003,
        0.29012781208000005,
        0.27818596008,
        0.27798988108000006,
        0.31005302008,
        0.29752867208000006,
        0.29187875808,
        0.28968368508000003,
        0.29903156208000004,
        0.33231932708000006
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.636 ± 0.023 2.597 2.677 1.60 ± 0.13
pacquet@main 2.633 ± 0.019 2.617 2.683 1.60 ± 0.13
pnpr@HEAD 1.648 ± 0.131 1.437 1.862 1.00
pnpr@main 1.662 ± 0.172 1.465 1.875 1.01 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.63595257802,
      "stddev": 0.023395860455443156,
      "median": 2.63163468552,
      "user": 1.62816966,
      "system": 1.3603291,
      "min": 2.59680411702,
      "max": 2.6766725590199996,
      "times": [
        2.6766725590199996,
        2.59680411702,
        2.6424860630199998,
        2.6260532290199996,
        2.63107988102,
        2.65642506302,
        2.6303818470199998,
        2.61029843102,
        2.6321894900199996,
        2.65713510002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.63255731612,
      "stddev": 0.019313979494628392,
      "median": 2.6284332090199998,
      "user": 1.59174716,
      "system": 1.3985545000000001,
      "min": 2.61701640602,
      "max": 2.6834491950199997,
      "times": [
        2.61701640602,
        2.61838480202,
        2.62322566502,
        2.62885161702,
        2.63142040202,
        2.6343100920199998,
        2.62801480102,
        2.62069783702,
        2.6834491950199997,
        2.64020234402
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.64782960472,
      "stddev": 0.1310793543556141,
      "median": 1.65395022352,
      "user": 1.1436302600000001,
      "system": 1.2507723,
      "min": 1.43747909302,
      "max": 1.86188793102,
      "times": [
        1.72426993602,
        1.6521061570200002,
        1.53289016302,
        1.7456930840200002,
        1.43747909302,
        1.49013524802,
        1.6274008190200002,
        1.86188793102,
        1.7506393260200002,
        1.65579429002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6620693501200001,
      "stddev": 0.1723871498256451,
      "median": 1.6970798505200002,
      "user": 1.16713826,
      "system": 1.2276462000000001,
      "min": 1.46478960502,
      "max": 1.87547064002,
      "times": [
        1.74341857302,
        1.87547064002,
        1.46741926502,
        1.49186631602,
        1.47620486402,
        1.7932258950200002,
        1.46478960502,
        1.79667561802,
        1.6507411280200002,
        1.8608815970200001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 446.4 ± 21.0 419.3 479.8 1.40 ± 0.08
pacquet@main 451.3 ± 17.6 418.0 478.1 1.42 ± 0.07
pnpr@HEAD 324.7 ± 9.4 312.2 339.0 1.02 ± 0.04
pnpr@main 318.2 ± 9.8 304.5 336.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.44636417930000005,
      "stddev": 0.02095910857906849,
      "median": 0.4417059249,
      "user": 0.5642953199999999,
      "system": 0.72380114,
      "min": 0.4193276984,
      "max": 0.4797721444,
      "times": [
        0.4797721444,
        0.4467652284,
        0.4366466214,
        0.42166176240000003,
        0.4354529044,
        0.4304136974,
        0.4610562024,
        0.4193276984,
        0.46940808440000004,
        0.4631374494
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.4512809738,
      "stddev": 0.01756614115654061,
      "median": 0.4499789689,
      "user": 0.56622402,
      "system": 0.7278123400000001,
      "min": 0.4180437214,
      "max": 0.4780813814,
      "times": [
        0.4485809174,
        0.4488610944,
        0.4518568834,
        0.4180437214,
        0.4754014364,
        0.4376347004,
        0.4609102164,
        0.4423425434,
        0.4780813814,
        0.4510968434
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3247303015,
      "stddev": 0.009412765881970132,
      "median": 0.32525513640000003,
      "user": 0.22300782000000002,
      "system": 0.5610740399999999,
      "min": 0.3122350764,
      "max": 0.3389535334,
      "times": [
        0.3270126554,
        0.3389535334,
        0.3307254944,
        0.3147634064,
        0.3179114214,
        0.3368706324,
        0.3122350764,
        0.3157906194,
        0.3234976174,
        0.3295425584
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.31819183399999995,
      "stddev": 0.009804878680489326,
      "median": 0.3183694589,
      "user": 0.20532282,
      "system": 0.5506215400000001,
      "min": 0.3045445284,
      "max": 0.33688098240000003,
      "times": [
        0.3257878894,
        0.3196561964,
        0.3046242184,
        0.3045445284,
        0.3201038004,
        0.31556271140000003,
        0.3127907124,
        0.33688098240000003,
        0.3248845794,
        0.3170827214
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.758 ± 0.035 1.723 1.850 5.11 ± 0.18
pacquet@main 1.787 ± 0.020 1.762 1.813 5.19 ± 0.16
pnpr@HEAD 0.344 ± 0.010 0.323 0.355 1.00
pnpr@main 0.366 ± 0.044 0.340 0.477 1.06 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7578828702200002,
      "stddev": 0.03511355505417958,
      "median": 1.7503714169200002,
      "user": 0.8232300599999999,
      "system": 0.7778808,
      "min": 1.7232265664200002,
      "max": 1.85027992342,
      "times": [
        1.85027992342,
        1.7525683624200001,
        1.7232265664200002,
        1.7484880814200001,
        1.7465374094200001,
        1.74198973842,
        1.75225475242,
        1.75734664842,
        1.77284544342,
        1.7332917764200002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.78705744162,
      "stddev": 0.019641272818576673,
      "median": 1.78628202792,
      "user": 0.87727886,
      "system": 0.8335649999999999,
      "min": 1.76172486142,
      "max": 1.8129080584200001,
      "times": [
        1.7671237344200001,
        1.76638418242,
        1.76172486142,
        1.7741104444200002,
        1.8123438464200001,
        1.78203686242,
        1.7960614494200002,
        1.79052719342,
        1.8129080584200001,
        1.80735378342
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.34401347872,
      "stddev": 0.009706605789119072,
      "median": 0.34629775392,
      "user": 0.24331355999999996,
      "system": 0.5786871,
      "min": 0.32312501842,
      "max": 0.35546185242,
      "times": [
        0.34696846642,
        0.34390457042,
        0.35190582942000004,
        0.34389031342000004,
        0.34970535842,
        0.35546185242,
        0.33144967742000003,
        0.32312501842,
        0.34809665942,
        0.34562704142
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.36606077672000004,
      "stddev": 0.04410913540374565,
      "median": 0.34805351392,
      "user": 0.24827726,
      "system": 0.6332335,
      "min": 0.34003830242,
      "max": 0.47654113542000004,
      "times": [
        0.34775027842,
        0.35048757942000003,
        0.34674925542,
        0.34835674942,
        0.34018983842,
        0.34092244642,
        0.35870179042,
        0.34003830242,
        0.41087039142000004,
        0.47654113542000004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 243.3 ± 13.7 225.6 268.0 2.78 ± 0.16
pacquet@main 268.1 ± 26.3 239.0 328.6 3.06 ± 0.31
pnpr@HEAD 90.5 ± 2.6 86.8 94.5 1.03 ± 0.03
pnpr@main 87.5 ± 1.6 85.7 93.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24325687656000003,
      "stddev": 0.01371495573368855,
      "median": 0.24418289956000003,
      "user": 0.22169466666666662,
      "system": 0.07104431000000001,
      "min": 0.22562867656000002,
      "max": 0.26799730256000004,
      "times": [
        0.24191856856000002,
        0.22810892456000004,
        0.22759784356000004,
        0.26430814856,
        0.22562867656000002,
        0.23233873656000004,
        0.24479799756000004,
        0.26799730256000004,
        0.25330770456,
        0.24450720056000003,
        0.24385859856000003,
        0.24471281656000002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.26813008456,
      "stddev": 0.026310832248971912,
      "median": 0.26314099206,
      "user": 0.21071459999999997,
      "system": 0.08728455999999998,
      "min": 0.23896467756000003,
      "max": 0.32860403556,
      "times": [
        0.28286414556000006,
        0.25216770856000004,
        0.27158455456,
        0.32860403556,
        0.24267916856000002,
        0.27886093056000005,
        0.25358631856,
        0.27729187656000004,
        0.23896467756000003,
        0.25469742956
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09053977659333334,
      "stddev": 0.0025710049103421836,
      "median": 0.09138843756000001,
      "user": 0.02275493333333333,
      "system": 0.010337522666666665,
      "min": 0.08680844256,
      "max": 0.09454227956000001,
      "times": [
        0.09454227956000001,
        0.08736375756,
        0.08750649656000001,
        0.08754955756,
        0.09107285956000001,
        0.08727588156,
        0.09175857956000001,
        0.09079823156000001,
        0.08715176856000001,
        0.09151495056,
        0.08684309856000001,
        0.09380359856,
        0.08919360156,
        0.09208863156000001,
        0.09199331056,
        0.09126192456,
        0.09238681156,
        0.09266614756000001,
        0.09380987056000001,
        0.09243907156,
        0.09322238456000001,
        0.08983024056000001,
        0.09368198956000001,
        0.09301057556,
        0.09215799156,
        0.08836570356000001,
        0.08729434756,
        0.08680844256,
        0.09175132656,
        0.08704986656000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08750515124750001,
      "stddev": 0.0015872229009880534,
      "median": 0.08707518006000001,
      "user": 0.02047615625,
      "system": 0.01061746625,
      "min": 0.08568598056,
      "max": 0.09301692856,
      "times": [
        0.08913059256,
        0.09079335256000001,
        0.09123634656,
        0.08609442856,
        0.08663438456,
        0.08770947856000001,
        0.08770768556000001,
        0.08615399056,
        0.08701787656,
        0.08817523556000001,
        0.08598440156,
        0.08841659956,
        0.08568598056,
        0.08668697356,
        0.08710935956,
        0.08704100056000001,
        0.08749617756,
        0.08746579056,
        0.08761790656,
        0.08722518756,
        0.08617401856000001,
        0.08662442556000001,
        0.09301692856,
        0.08638799156,
        0.08801419256000001,
        0.08672479556000001,
        0.08751845856000001,
        0.08674862056,
        0.08747068956000001,
        0.08630999456,
        0.08685411856,
        0.08693785656
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 938.2 ± 168.0 754.4 1298.2 1.00
pacquet@main 942.6 ± 151.1 760.4 1189.4 1.00 ± 0.24
pnpm@HEAD 3427.6 ± 63.2 3318.6 3509.3 3.65 ± 0.66
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.9382036119755556,
      "stddev": 0.16804294534532072,
      "median": 0.89354091142,
      "user": 0.8954741666666668,
      "system": 0.16644072222222223,
      "min": 0.75442629242,
      "max": 1.2982216144199998,
      "times": [
        0.96001095142,
        1.10853050142,
        0.75442629242,
        0.8960923744200001,
        0.88366809942,
        0.8086711914200001,
        0.84067057142,
        1.2982216144199998,
        0.89354091142
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.9426239706422221,
      "stddev": 0.15109902187863047,
      "median": 0.9043771084200001,
      "user": 0.9038899444444445,
      "system": 0.16993672222222223,
      "min": 0.76038481842,
      "max": 1.18940098342,
      "times": [
        0.76038481842,
        0.82239401042,
        0.80344488542,
        0.9043771084200001,
        1.18940098342,
        1.0609462084199999,
        0.8356913984200001,
        1.09368744342,
        1.01328887942
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.4275513228644443,
      "stddev": 0.06324415288169535,
      "median": 3.44425350142,
      "user": 5.2731065,
      "system": 0.30826705555555556,
      "min": 3.31855585542,
      "max": 3.50927165842,
      "times": [
        3.40226843842,
        3.45857068842,
        3.3569050054200003,
        3.50466897442,
        3.31855585542,
        3.40911857142,
        3.50927165842,
        3.44425350142,
        3.44434921242
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.628 ± 0.166 4.469 4.892 1.32 ± 0.05
pacquet@main 4.515 ± 0.073 4.448 4.647 1.28 ± 0.03
pnpr@HEAD 3.534 ± 0.062 3.482 3.673 1.01 ± 0.03
pnpr@main 3.516 ± 0.064 3.473 3.642 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.627861273080001,
      "stddev": 0.166110188661757,
      "median": 4.522816884980001,
      "user": 2.0025151599999997,
      "system": 1.5204162999999997,
      "min": 4.46882168548,
      "max": 4.89215864148,
      "times": [
        4.49323465548,
        4.78014205748,
        4.503000296480001,
        4.733179505480001,
        4.8505141194800006,
        4.51192799948,
        4.515494121480001,
        4.46882168548,
        4.89215864148,
        4.5301396484800005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.51529682358,
      "stddev": 0.07342841346125989,
      "median": 4.480013876480001,
      "user": 1.86421886,
      "system": 1.4878067,
      "min": 4.44844855048,
      "max": 4.64679351148,
      "times": [
        4.47403600048,
        4.46349859648,
        4.63225219148,
        4.4816060784800005,
        4.64679351148,
        4.51890066348,
        4.44844855048,
        4.55909811248,
        4.44991285648,
        4.478421674480001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.53425329418,
      "stddev": 0.06161986416259646,
      "median": 3.5193424699799998,
      "user": 1.3170470599999997,
      "system": 1.3322827,
      "min": 3.4817546084799997,
      "max": 3.6730388594799996,
      "times": [
        3.6730388594799996,
        3.48337815448,
        3.4817546084799997,
        3.55348610948,
        3.4970138284799996,
        3.57316129148,
        3.48601409548,
        3.48294890648,
        3.57006597648,
        3.54167111148
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5158107047800002,
      "stddev": 0.06382755558881448,
      "median": 3.47950278448,
      "user": 1.2274140599999999,
      "system": 1.2668011,
      "min": 3.47313922248,
      "max": 3.64202373348,
      "times": [
        3.47912349548,
        3.47313922248,
        3.49013883848,
        3.64202373348,
        3.4748407054799997,
        3.61302894948,
        3.47661719848,
        3.47624781348,
        3.55306501748,
        3.47988207348
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13700
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,596.80 ms
(-3.29%)Baseline: 2,685.12 ms
3,222.14 ms
(80.59%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,723.23 ms
(-3.16%)Baseline: 1,779.54 ms
2,135.45 ms
(80.70%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
419.33 ms
(-4.99%)Baseline: 441.36 ms
529.63 ms
(79.17%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
225.63 ms
(+8.74%)Baseline: 207.50 ms
249.00 ms
(90.61%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,385.56 ms
(-2.49%)Baseline: 2,446.38 ms
2,935.66 ms
(81.26%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,468.82 ms
(-0.49%)Baseline: 4,490.75 ms
5,388.90 ms
(82.93%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
271.22 ms
(-6.02%)Baseline: 288.60 ms
346.32 ms
(78.32%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
754.43 ms
(+5.28%)Baseline: 716.56 ms
859.88 ms
(87.74%)
🐰 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/13700
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,437.48 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
323.13 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
312.24 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
86.81 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,343.70 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,481.75 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
261.80 ms
🐰 View full continuous benchmarking report in Bencher

zkochan added a commit that referenced this pull request Aug 7, 2026
A filtered install computes its hoist map from the filtered lockfile, so
replacing the recorded map there would forget the unselected importers
entries; the recomputed map now only replaces it when the graph covers
every importer, with a workspace regression test that fails without the
guard.

Reconcile pendingBuilds in every mode rather than only under
ignore-scripts: a normal headless install that removes a package now
drops the entry a previous ignore-scripts install recorded. The test
runs its final install with scripts enabled and asserts every surviving
entry is something the lockfile still records.

Trim the test narration to the one non-obvious why. No pacquet changes:
removing_a_package_shrinks_the_list already pins the removal
reconciliation there, which an earlier probe of mine missed.

Reported by CodeRabbit and Greptile on #13700.
Copilot AI review requested due to automatic review settings August 7, 2026 11:49

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.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 7, 2026
zkochan added 3 commits August 7, 2026 13:52
The headless installer derives its work from the incremental graph --
the packages the wanted lockfile records that are not materialized yet.
An install whose lockfile only removes packages has an empty graph, so
every graph-driven stage silently did nothing: the hoist layer was never
recomputed (a package that became hoistable when a direct dependency was
removed stayed unhoisted), and `pendingBuilds` only ever appended, so
entries for removed packages stayed pending forever.

Reachable with no unusual flags: pull a lockfile in which a dependency
was removed and run `pnpm install` -- `allProjectsAreUpToDate` sends it
down the headless path.

Include the unchanged packages in the graph whenever the transition from
the installed state removes a package, the same mechanism a hoist-pattern
change already uses. Unfetched nodes are marked built so the build step
does not re-run their scripts or re-apply their patches, and with the
graph complete the recomputed hoist map replaces the recorded one instead
of merging over it. `pendingBuilds` is reconciled against the wanted
lockfile rather than appended.

pacquet already behaves this way -- its hoist pass reads the lockfile and
its pending-builds merge retains only entries the current lockfile still
records -- so the Rust side only gains a pinning test.

Fixes #13699.
A filtered install computes its hoist map from the filtered lockfile, so
replacing the recorded map there would forget the unselected importers
entries; the recomputed map now only replaces it when the graph covers
every importer, with a workspace regression test that fails without the
guard.

Reconcile pendingBuilds in every mode rather than only under
ignore-scripts: a normal headless install that removes a package now
drops the entry a previous ignore-scripts install recorded. The test
runs its final install with scripts enabled and asserts every surviving
entry is something the lockfile still records.

Trim the test narration to the one non-obvious why. No pacquet changes:
removing_a_package_shrinks_the_list already pins the removal
reconciliation there, which an earlier probe of mine missed.

Reported by CodeRabbit and Greptile on #13700.
Copilot AI review requested due to automatic review settings August 7, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 53c66cf

@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 2d7efe3 into main Aug 7, 2026
37 checks passed
@zkochan
zkochan deleted the headless-removal branch August 7, 2026 12:22
zkochan pushed a commit that referenced this pull request Oct 12, 2026
… v10 (#16862)

* test(core): reproduce public hoist handover after lockfile removal

Amp-Thread-ID: https://ampcode.com/threads/T-01a12dba-9c30-727a-a3bf-e62366285e11
Co-authored-by: Amp <[email protected]>

* fix(headless): backport hoist reconciliation after package removal to v10

Backport the hoisting portion of #13700 from main (commit
2d7efe3) to release/10.

Include retained packages when the installed lockfile removes packages,
skip rebuilding already-materialized nodes, and only replace the hoist
map when it covers the full workspace. Keep pendingBuilds reconciliation
outside this focused backport.

Cover public hoist handover between two transitive runtime versions after
a frozen/offline install, plus the main fix filtered-importer regression.

Fixes #16861.

Amp-Thread-ID: https://ampcode.com/threads/T-01a12dba-9c30-727a-a3bf-e62366285e11
Co-authored-by: Amp <[email protected]>

* docs(headless): use spellcheck-compatible wording

Amp-Thread-ID: https://ampcode.com/threads/T-01a12dba-9c30-727a-a3bf-e62366285e11
Co-authored-by: Amp <[email protected]>

---------

Co-authored-by: Amp <[email protected]>
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.

Headless install leaves a stale hoist layer and pendingBuilds when the lockfile removes packages

3 participants