Skip to content

fix(overrides): apply removal overrides to optional peers declared only in peerDependenciesMeta - #16682

Merged
zkochan merged 3 commits into
pnpm:mainfrom
lazerg:fix/issue-16681-override-meta-only-peer
Oct 7, 2026
Merged

zkochan merged 3 commits into
pnpm:mainfrom
lazerg:fix/issue-16681-override-meta-only-peer

Conversation

@lazerg

@lazerg lazerg commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A removal override such as "debug>supports-color": "-" did nothing when the package declares the optional peer only in peerDependenciesMeta, with no peerDependencies entry. [email protected] and follow-redirects do this. The resolver treats such an entry as an optional * peer, but the overrider only walked peerDependencies, so the meta entry stayed and a sibling workspace project could still supply the peer.

The overrider now also checks every peerDependenciesMeta name that peerDependencies does not declare, matching it against the overrides as *. When the chosen override is -, the meta entry is removed. Both pnpm v11 and v12 had the bug, so both are fixed. In v12, apply_to_arc skips manifests that no override applies to, so that check now counts these entries too.

With this change the issue's script gives [email protected] with no peer suffix, the same as ws.

Fixes #16681

Squash Commit Body

The resolver treats a peerDependenciesMeta entry with optional: true
and no peerDependencies entry as an optional "*" peer. The versions
overrider only iterated peerDependencies, so a removal override never
reached such a peer and a sibling workspace project could still
satisfy it.

Both overriders now also match each peerDependenciesMeta name that
peerDependencies does not declare against the overrides as "*", and
drop the meta entry when the chosen override is "-". In pacquet the
apply_to_arc fast path checks the same entries, so the manifest is
cloned and rewritten.

The workspace regression tests from pnpm/pnpm#15199 now also run
against @pnpm.e2e/abc-optional-peers-meta-only.

Fixes https://github.com/pnpm/pnpm/issues/16681

Checklist

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

Written by an agent (Claude Code, claude-opus-5-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
    • Removal overrides now apply to optional peers listed only in peer metadata, even when no matching peer dependency is declared.
    • Matching overrides remove the peer’s metadata entry while preserving unrelated optional peer metadata and declared peers.
    • Fixed behavior for both general and parent-specific removal overrides.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f070df91-8ea6-48e0-93aa-d17ae60fa5e2
📥 Commits

Reviewing files that changed from the base of the PR and between cd30373 and 76bc14a.

📒 Files selected for processing (1)
  • pnpm/crates/package-manager/src/overrides/meta_only_peers.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Removal overrides now apply to optional peers listed only in peerDependenciesMeta in both the Rust package manager and the read-package hook. Tests cover override handling and workspace installation.

Changes

Optional peer removal

Layer / File(s) Summary
Rust override handling
pnpm/crates/package-manager/src/overrides.rs, pnpm/crates/package-manager/src/overrides/meta_only_peers.rs, pnpm/crates/package-manager/src/overrides/tests.rs
The Rust override path identifies metadata-only peer names and removes entries that match a removal override. Its applicability check and tests cover the behavior.
Read-package hook handling
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts, pnpm11/hooks/read-package-hook/test/createVersionOverrider.test.ts
The hook removes undeclared peer metadata entries when a matching override uses -. Tests cover generic and parent-scoped selectors and verify the input metadata remains unchanged.
Workspace coverage and release note
pnpm/crates/cli/tests/suite/workspace_install.rs, pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts, .changeset/removal-override-meta-only-optional-peer.md
Workspace tests cover both optional-peer package variants. The changeset records patch releases and describes metadata-only peer removal.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
Apply parent-scoped removal overrides to optional peers listed only in peerDependenciesMeta [#16681] ✅

Possibly related PRs

  • pnpm/pnpm#15199: Removes metadata entries for declared optional peers; this PR extends removal-override handling to metadata-only peers.

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

Merge Risk: ⚪ Minimal · up to 76bc1

The change applies removal overrides to metadata-only optional peers, with tests covering both package-manager paths. No concrete merge-blocking risk is established.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

❤️ Share

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

@codecov-commenter

codecov-commenter commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.36%. Comparing base (ab1e504) to head (76bc14a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16682   +/-   ##
=======================================
  Coverage   92.36%   92.36%           
=======================================
  Files        1593     1594    +1     
  Lines      210358   210394   +36     
=======================================
+ Hits       194297   194331   +34     
- Misses      16061    16063    +2     

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

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

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

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

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

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2396.63 ms 2450.01 ms 2.2% 119.83 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1377.51 ms 1364.95 ms -0.9% 68.88 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 237.89 ms 244.04 ms 2.6% 11.89 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 271.48 ms 255.68 ms -5.8% 13.57 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 9.65 ms 9.73 ms 0.8% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 9.51 ms 10.04 ms 5.6% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 8.24 ms 8.04 ms -2.4% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 12.01 ms 8.63 ms -28.1% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2652.70 ms 2633.23 ms -0.7% 132.63 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1602.23 ms 1580.26 ms -1.4% 80.11 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 551.97 ms 712.66 ms 29.1% 27.60 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 349.26 ms 321.94 ms -7.8% 17.46 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1630.33 ms 1629.84 ms -0.0% 81.52 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 291.30 ms 388.88 ms 33.5% 14.57 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pacquet 280.95 ms 337.36 ms 20.1% 14.05 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 98.03 ms 97.36 ms -0.7% 4.90 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 249.63 ms 234.20 ms -6.2% 12.48 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 248.01 ms 245.23 ms -1.1% 12.40 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4542.73 ms 4610.59 ms 1.5% 227.14 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3549.73 ms 3612.19 ms 1.8% 177.49 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 127.96 ms 205.20 ms 60.4% 6.40 ms Inconclusive (overlapping samples)
gvs-fresh-restore-hot-cache-hot-store pnpr 136.44 ms 131.82 ms -3.4% 6.82 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 76bc14aeee89

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

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.463 ± 0.100 2.315 2.626 1.73 ± 0.14
pacquet@main 2.424 ± 0.099 2.318 2.606 1.71 ± 0.14
pnpr@HEAD 1.422 ± 0.131 1.315 1.719 1.00 ± 0.12
pnpr@main 1.421 ± 0.101 1.318 1.642 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.46348585596,
      "stddev": 0.10047469812164214,
      "median": 2.4500081627599997,
      "user": 1.46257986,
      "system": 1.4557851,
      "min": 2.31530060526,
      "max": 2.6263796672599997
    },
    {
      "command": "pacquet@main",
      "mean": 2.42410839236,
      "stddev": 0.09943003514578792,
      "median": 2.39663159676,
      "user": 1.4592661599999999,
      "system": 1.4003352,
      "min": 2.31783653926,
      "max": 2.60619196526
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.42239399406,
      "stddev": 0.1314048719062398,
      "median": 1.3649520397600001,
      "user": 1.4943962599999998,
      "system": 1.4970491000000004,
      "min": 1.3153057812600002,
      "max": 1.71934150226
    },
    {
      "command": "pnpr@main",
      "mean": 1.42120260776,
      "stddev": 0.10096074861155671,
      "median": 1.37750954826,
      "user": 1.4666358599999998,
      "system": 1.3316893,
      "min": 1.31844937126,
      "max": 1.6420844232600003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 243.5 ± 14.7 224.0 279.1 1.01 ± 0.08
pacquet@main 240.0 ± 13.2 224.2 268.7 1.00
pnpr@HEAD 255.4 ± 8.9 241.1 272.5 1.06 ± 0.07
pnpr@main 318.8 ± 88.7 247.1 487.8 1.33 ± 0.38
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24354236600000007,
      "stddev": 0.014727209134528076,
      "median": 0.24403905470000004,
      "user": 0.27013677999999997,
      "system": 0.58932954,
      "min": 0.22397944670000003,
      "max": 0.2790964917
    },
    {
      "command": "pacquet@main",
      "mean": 0.23999223949999998,
      "stddev": 0.013171494590230861,
      "median": 0.23788869370000001,
      "user": 0.26850508000000006,
      "system": 0.58925104,
      "min": 0.22415183770000002,
      "max": 0.2686947607
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2554384302,
      "stddev": 0.008859453313859443,
      "median": 0.2556847487,
      "user": 0.27430057999999996,
      "system": 0.5926526399999998,
      "min": 0.24108276770000003,
      "max": 0.2725104507
    },
    {
      "command": "pnpr@main",
      "mean": 0.3187583829999999,
      "stddev": 0.08874120239176467,
      "median": 0.2714768772,
      "user": 0.33601298,
      "system": 0.71431154,
      "min": 0.24707199570000002,
      "max": 0.4878309717
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.0 ± 1.7 8.7 36.7 1.05 ± 0.18
pacquet@main 9.8 ± 0.7 8.5 13.0 1.03 ± 0.09
pnpr@HEAD 10.1 ± 0.5 8.6 12.7 1.06 ± 0.08
pnpr@main 9.5 ± 0.5 8.3 11.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009985942603275266,
      "stddev": 0.0016814097455283587,
      "median": 0.00973137622,
      "user": 0.005743574494773524,
      "system": 0.00496564508710801,
      "min": 0.00867402922,
      "max": 0.03667643222
    },
    {
      "command": "pacquet@main",
      "mean": 0.009780310393431739,
      "stddev": 0.0006593656437798456,
      "median": 0.009653388220000001,
      "user": 0.0057277935055350514,
      "system": 0.004912854464944648,
      "min": 0.00852943622,
      "max": 0.013003254220000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.010080780143344951,
      "stddev": 0.0005297870687744432,
      "median": 0.010039895220000001,
      "user": 0.005461679024390242,
      "system": 0.005560307735191637,
      "min": 0.008613013220000002,
      "max": 0.012736563220000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.009531557536725981,
      "stddev": 0.0005060266496834741,
      "median": 0.00950606122,
      "user": 0.005624253380782919,
      "system": 0.004753769110320287,
      "min": 0.008334219220000001,
      "max": 0.011616508220000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 8.1 ± 0.5 7.2 10.5 1.00
pacquet@main 8.3 ± 0.6 7.3 10.9 1.02 ± 0.09
pnpr@HEAD 8.7 ± 0.6 7.3 11.5 1.07 ± 0.10
pnpr@main 12.1 ± 3.1 7.2 21.5 1.50 ± 0.40
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.008089121360149257,
      "stddev": 0.0004768335303280469,
      "median": 0.00804079214,
      "user": 0.005037330597014925,
      "system": 0.0037809600746268658,
      "min": 0.007172059140000001,
      "max": 0.01049400614
    },
    {
      "command": "pacquet@main",
      "mean": 0.008283072516306616,
      "stddev": 0.0005504480705404689,
      "median": 0.00823525214,
      "user": 0.004776436933797909,
      "system": 0.00428210292682927,
      "min": 0.00732746014,
      "max": 0.01089001814
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008681246651538457,
      "stddev": 0.0006447377022960247,
      "median": 0.008630347640000001,
      "user": 0.004990292307692304,
      "system": 0.004541985384615383,
      "min": 0.0073393031400000005,
      "max": 0.01146215114
    },
    {
      "command": "pnpr@main",
      "mean": 0.012131005039628245,
      "stddev": 0.003129091390845588,
      "median": 0.01200986814,
      "user": 0.006910266914498142,
      "system": 0.006218230185873603,
      "min": 0.007184191140000001,
      "max": 0.02150832414
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.676 ± 0.120 2.579 2.972 1.67 ± 0.15
pacquet@main 2.655 ± 0.047 2.599 2.753 1.66 ± 0.13
pnpr@HEAD 1.605 ± 0.103 1.469 1.768 1.00 ± 0.10
pnpr@main 1.601 ± 0.127 1.448 1.817 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.67606365882,
      "stddev": 0.11955367672740427,
      "median": 2.63322984142,
      "user": 2.3450217799999997,
      "system": 2.3018218599999996,
      "min": 2.57861205192,
      "max": 2.97231957792
    },
    {
      "command": "pacquet@main",
      "mean": 2.6551492422199994,
      "stddev": 0.04680936359793667,
      "median": 2.65269510092,
      "user": 2.42768718,
      "system": 2.06994766,
      "min": 2.59939522992,
      "max": 2.75311173392
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6048188359199997,
      "stddev": 0.10302986513235557,
      "median": 1.5802555299199998,
      "user": 1.4445913799999999,
      "system": 1.68983526,
      "min": 1.46878935292,
      "max": 1.76777099292
    },
    {
      "command": "pnpr@main",
      "mean": 1.6010663405199999,
      "stddev": 0.12673003995399784,
      "median": 1.60222512242,
      "user": 1.4937007799999997,
      "system": 1.7372936599999995,
      "min": 1.44786944792,
      "max": 1.8172240899199998
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 851.9 ± 282.7 604.9 1373.0 2.53 ± 0.88
pacquet@main 557.4 ± 31.7 516.2 611.4 1.65 ± 0.20
pnpr@HEAD 337.3 ± 36.4 307.9 429.6 1.00
pnpr@main 399.7 ± 118.8 313.6 687.1 1.18 ± 0.37
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.8518928536400002,
      "stddev": 0.2827486112347905,
      "median": 0.7126615726400001,
      "user": 1.23070876,
      "system": 1.33480868,
      "min": 0.6049475671400001,
      "max": 1.37295116314
    },
    {
      "command": "pacquet@main",
      "mean": 0.55740252774,
      "stddev": 0.031722442930887045,
      "median": 0.5519717416400001,
      "user": 0.81673846,
      "system": 0.90148858,
      "min": 0.51620692414,
      "max": 0.61135115614
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3373229749400001,
      "stddev": 0.03640524988158926,
      "median": 0.32193785764000005,
      "user": 0.30475065999999995,
      "system": 0.64047048,
      "min": 0.30787492214000006,
      "max": 0.42958913414000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.39968742974000004,
      "stddev": 0.11883874193141564,
      "median": 0.34925545314000006,
      "user": 0.37015796,
      "system": 0.8017359799999999,
      "min": 0.31356492314000006,
      "max": 0.6870691391400001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.681 ± 0.114 1.613 1.957 5.63 ± 0.52
pacquet@main 1.632 ± 0.023 1.597 1.663 5.46 ± 0.35
pnpr@HEAD 0.372 ± 0.062 0.297 0.445 1.25 ± 0.22
pnpr@main 0.299 ± 0.019 0.273 0.335 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.68095247184,
      "stddev": 0.11392700586317929,
      "median": 1.62984147364,
      "user": 0.9929621599999999,
      "system": 0.93527596,
      "min": 1.61325681564,
      "max": 1.9573637576400003
    },
    {
      "command": "pacquet@main",
      "mean": 1.6317459621400001,
      "stddev": 0.02279160591204063,
      "median": 1.6303312621400001,
      "user": 0.9166935599999999,
      "system": 0.84023896,
      "min": 1.5973822936400002,
      "max": 1.6627391856400002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3723171544400001,
      "stddev": 0.06205454957559686,
      "median": 0.38888043664000005,
      "user": 0.34702115999999994,
      "system": 0.73640776,
      "min": 0.29679431464,
      "max": 0.44499612064000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.29863642224,
      "stddev": 0.01885471415099512,
      "median": 0.29130397314,
      "user": 0.24618536,
      "system": 0.5942048600000001,
      "min": 0.27282180264,
      "max": 0.33452770164
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 347.5 ± 33.9 312.5 416.7 3.52 ± 0.37
pacquet@main 296.7 ± 59.3 230.3 390.7 3.00 ± 0.61
pnpr@HEAD 98.9 ± 5.9 91.7 117.2 1.00 ± 0.07
pnpr@main 98.8 ± 3.7 92.9 107.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.34754219776,
      "stddev": 0.033939229953086666,
      "median": 0.33735989866000005,
      "user": 0.35796407999999996,
      "system": 0.13670869999999996,
      "min": 0.31252827816,
      "max": 0.41665677116
    },
    {
      "command": "pacquet@main",
      "mean": 0.29671765646,
      "stddev": 0.05925676673545306,
      "median": 0.28095149316,
      "user": 0.28666238,
      "system": 0.11357149999999998,
      "min": 0.23028417116,
      "max": 0.39066790516
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09885320012666668,
      "stddev": 0.005860499278577573,
      "median": 0.09735685766,
      "user": 0.03741124666666666,
      "system": 0.017475033333333338,
      "min": 0.09173585216,
      "max": 0.11717199616000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.09881849402206896,
      "stddev": 0.0037324149871757937,
      "median": 0.09802628616,
      "user": 0.03991963862068966,
      "system": 0.015759779310344828,
      "min": 0.09287634116,
      "max": 0.10772694716
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 240.0 ± 28.2 209.8 303.9 1.00
pacquet@main 312.7 ± 91.1 227.3 438.4 1.30 ± 0.41
pnpm@HEAD 4297.4 ± 466.8 3692.1 4979.5 17.91 ± 2.86
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2399754432266667,
      "stddev": 0.02817264508213118,
      "median": 0.23420021556,
      "user": 0.2408490088888889,
      "system": 0.05105139555555555,
      "min": 0.20983440256000002,
      "max": 0.30386470656000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.3126904536711111,
      "stddev": 0.09108716141936331,
      "median": 0.24962843056,
      "user": 0.3149591199999999,
      "system": 0.06962228444444446,
      "min": 0.22728526856,
      "max": 0.43837394556000003
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.297360222782221,
      "stddev": 0.46678430779318336,
      "median": 4.087845650559999,
      "user": 6.730671342222221,
      "system": 0.45513084000000004,
      "min": 3.6920759225600004,
      "max": 4.97954822256
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 244.7 ± 12.5 230.0 274.5 1.00
pacquet@main 252.6 ± 11.4 242.0 274.7 1.03 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24468345606000005,
      "stddev": 0.01254111931834838,
      "median": 0.24523011706000003,
      "user": 0.19432568999999997,
      "system": 0.09822502333333331,
      "min": 0.23001021056,
      "max": 0.27447847556000005
    },
    {
      "command": "pacquet@main",
      "mean": 0.2525719262266667,
      "stddev": 0.01135401967352914,
      "median": 0.24801187606000002,
      "user": 0.20286035666666666,
      "system": 0.10245460666666666,
      "min": 0.24204492156000001,
      "max": 0.27473703256000004
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.661 ± 0.185 4.498 5.085 1.30 ± 0.07
pacquet@main 4.576 ± 0.137 4.397 4.821 1.27 ± 0.06
pnpr@HEAD 3.603 ± 0.097 3.472 3.731 1.00 ± 0.04
pnpr@main 3.598 ± 0.126 3.470 3.869 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.660843122099999,
      "stddev": 0.18492028062065866,
      "median": 4.610585145,
      "user": 1.78513908,
      "system": 1.69633188,
      "min": 4.497511150999999,
      "max": 5.085149770999999
    },
    {
      "command": "pacquet@main",
      "mean": 4.575860968700001,
      "stddev": 0.1366354225258,
      "median": 4.5427251669999995,
      "user": 1.78860538,
      "system": 1.6384701799999999,
      "min": 4.3969624959999996,
      "max": 4.821074348
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.6026074591000006,
      "stddev": 0.09736089353688918,
      "median": 3.612190957,
      "user": 1.5988120799999999,
      "system": 1.54999918,
      "min": 3.471976405,
      "max": 3.7307472820000003
    },
    {
      "command": "pnpr@main",
      "mean": 3.597991007,
      "stddev": 0.12610562460993124,
      "median": 3.5497309694999997,
      "user": 1.6825696799999998,
      "system": 1.49882928,
      "min": 3.469953629,
      "max": 3.868661151
    }
  ]
}

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

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 212.0 ± 28.5 176.2 261.3 1.61 ± 0.23
pacquet@main 138.0 ± 35.2 107.5 224.5 1.05 ± 0.27
pnpr@HEAD 131.5 ± 6.6 117.9 141.2 1.00
pnpr@main 135.7 ± 6.6 119.5 149.1 1.03 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.21195445054857145,
      "stddev": 0.028512573079730506,
      "median": 0.20520270662,
      "user": 0.26105982285714285,
      "system": 0.25493708000000004,
      "min": 0.17615768162,
      "max": 0.26129876262
    },
    {
      "command": "pacquet@main",
      "mean": 0.13799860757000001,
      "stddev": 0.03518864282260359,
      "median": 0.12796350662,
      "user": 0.17483262999999996,
      "system": 0.15334208,
      "min": 0.10745780162000002,
      "max": 0.22446384862000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.13146127619142858,
      "stddev": 0.00657699354258876,
      "median": 0.13182128962,
      "user": 0.1480011085714286,
      "system": 0.13217884190476184,
      "min": 0.11786340062000002,
      "max": 0.14124058162000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.1357120121755556,
      "stddev": 0.006638618432106012,
      "median": 0.13643862862,
      "user": 0.14991312444444443,
      "system": 0.13938508,
      "min": 0.11947812062000002,
      "max": 0.14905893262000003
    }
  ]
}

@lazerg
lazerg marked this pull request as ready for review October 7, 2026 03:39
@lazerg
lazerg requested a review from zkochan as a code owner October 7, 2026 03:39
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 7, 2026
@zkochan
zkochan force-pushed the fix/issue-16681-override-meta-only-peer branch from 83c0541 to cd30373 Compare October 7, 2026 06:19

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

The apply_to_arc fast path runs on every resolved manifest, and it only
needs a yes/no answer, so it no longer allocates a String per
peerDependenciesMeta key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Overrides remove ignored peer metadata 🐞 Bug ≡ Correctness ⭐ New
Description
meta_only_peer_names treats every peerDependenciesMeta key absent from peerDependencies as an
implicit peer, without checking optional: true or excluding names supplied by the package's own
dependencies. A - override for such a name therefore clones the manifest and deletes its metadata
even though the resolver ignores that entry as a peer, affecting manifests with non-optional
metadata or shadowed own dependencies.
Code

pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[R42-43]

+        .filter(move |name| !peers.is_some_and(|declared| declared.contains_key(*name)))
+        .map(String::as_str)
Relevance

●●● Strong

Exact precedent accepted matching optional-peer removal semantics; this helper omits resolver’s
optional and own-dependency exclusions.

PR-#15199

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The resolver documents that metadata-only entries count only when optional: true, and its
implementation skips names already supplied by own dependencies. The new helper checks only absence
from peerDependencies, while the override path uses its result both to decide whether to clone and
to remove entries from peerDependenciesMeta.

pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[35-43]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs[247-253]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs[270-291]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/manifest.rs[306-322]
pnpm/crates/package-manager/src/overrides.rs[517-521]

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

## Issue description
`meta_only_peer_names` treats all metadata-only names as implicit optional peers, but the resolver only recognizes entries with `optional: true` and skips names supplied by `dependencies` or `optionalDependencies`. Removal overrides can therefore delete metadata for entries that are not resolver peer edges.

## Fix Focus Areas
- pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[35-43]

## Recommended Fix
Align `meta_only_peer_names` with the resolver's peer extraction rules: require `peerDependenciesMeta[name].optional` to be exactly `true`, and exclude names present in the package's own dependency maps while preserving the resolver's peer-shadowing behavior where applicable. Add regression tests for non-optional metadata and metadata-only names shadowed by own dependencies.

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

Dismiss ↗ | View ↗


2. Rust installs scan peers without removals 🐞 Bug ➹ Performance
Description
has_meta_only_peer_removal collects and clones every metadata-only peer name, then searches the
overrides for each one even when the override set contains no - value. This runs for each resolver
manifest with peer metadata; when a removal does match, remove_meta_only_peers repeats the
collection and searches after the manifest is cloned.
Code

pnpm/crates/package-manager/src/overrides.rs[229]

+            || self.has_meta_only_peer_removal(value, &applicable_parent_scoped)
Relevance

●●● Strong

Recent Rust precedents accept eliminating repeated override scans and allocations in resolver hot
paths.

PR-#13762
PR-#14234

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The resolver invokes apply_to_arc through its manifest hook. The new clone-gate branch calls
has_meta_only_peer_removal, while meta_only_peer_names allocates a vector of cloned strings and
choose_override searches override candidates per name; a matching manifest goes through the same
collection again in apply_to_value.

pnpm/crates/package-manager/src/install_with_fresh_lockfile/manifest_transforms.rs[190-199]
pnpm/crates/package-manager/src/overrides.rs[181-195]
pnpm/crates/package-manager/src/overrides.rs[224-229]
pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[5-45]
pnpm/crates/package-manager/src/overrides.rs[428-458]

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 Rust resolver scans metadata-only peers for removal on manifests even when no removal override exists, and clones their names during both the applicability check and rewrite.
## Fix Focus Areas
- pnpm/crates/package-manager/src/overrides.rs[224-229]
- pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[5-45]
## Recommended Fix
Skip metadata-only peer checks when no applicable removal override exists. Iterate borrowed metadata keys in the applicability check, and allocate names only for entries that must be removed during the rewrite.

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

Dismiss ↗ | View ↗


3. One release note mixes v11 and v12 📘 Rule violation § Compliance
Description
The new changeset lists both pnpm and pacquet alongside the v11 hooks package in one file.
Because this PR changes both the TypeScript v11 and Rust v12 implementations, the version-specific
release notes must be split into separate changesets targeting the appropriate package.
Code

.changeset/removal-override-meta-only-optional-peer.md[R2-4]

+"@pnpm/hooks.read-package-hook": patch
+"pnpm": patch
+"pacquet": patch
Relevance

●●● Strong

Recent repository precedents explicitly accept splitting mixed pnpm and pacquet changesets.

PR-#15895
PR-#16479

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR changes both the pnpm11 TypeScript overrider and the pnpm Rust/pacquet overrider, but the
added changeset places pnpm and pacquet in the same file. The checklist requires separate
changesets targeting the appropriate package when both stacks are changed.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/removal-override-meta-only-optional-peer.md[1-7]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-243]
pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[1-45]

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 changeset combines the TypeScript v11 and Rust v12 package targets in one release note, while the checklist requires separate version-specific changesets when both implementations change.

## Fix Focus Areas
- .changeset/removal-override-meta-only-optional-peer.md[1-7]

## Recommended Fix
Create separate changeset files: one targeting the affected v11 published packages, including `pnpm` with a patch bump, and another targeting `pacquet` with an appropriate bump. Keep each release-note entry scoped to the behavior delivered by its target version.

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

Dismiss ↗ | View ↗


View medium (2)
4. The new peer helper follows its call 📘 Rule violation ⚙ Maintainability
Description
removeMetaOnlyPeers is declared after overrideDepsOfPkg calls it. The call at line 222 precedes
the new declaration at line 231 in the same TypeScript file, so the helper violates the required
declaration order.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[231]

+function removeMetaOnlyPeers (
Relevance

●● Moderate

The helper is already declared after its first use; evidence for enforcing this ordering is
uncertain.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist requires used top-level TypeScript function declarations to appear after at least one
usage. The new helper is called before its declaration in the changed file.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-231]

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

## Issue description
The new `removeMetaOnlyPeers` function is declared after its first usage, contrary to the project’s TypeScript declaration-order requirement.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-243]

## Recommended Fix
Move the `removeMetaOnlyPeers` function declaration above `overrideDepsOfPkg`, or otherwise place its declaration before the first call while preserving the existing behavior.

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

Dismiss ↗ | View ↗


5. Node installs search unused removal paths 🐞 Bug ➹ Performance
Description
removeMetaOnlyPeers enumerates every metadata key and calls pickVersionOverride for each
undeclared name, even when the configured overrides contain no removal. The read-package hook runs
for each manifest during resolution, so metadata-heavy packages add repeated override-array
filtering to installs that cannot remove a peer.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R239-241]

+  for (const peerName of Object.keys(peerDependenciesMeta)) {
+    if (peerDependencies?.[peerName] != null) continue
+    if (pickVersionOverride(overrides, peerName, '*')?.newBareSpecifier === '-') {
Relevance

●● Moderate

Performance concerns in this hook have been rejected before, but this specific repeated override
scan lacks an exact precedent.

PR-#13938

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
A nonempty override configuration installs the hook, which runs for each manifest. The added loop
enumerates metadata names and calls pickVersionOverride; that function filters the parent and
generic override arrays on each call without first checking whether removal is possible.

pnpm11/hooks/read-package-hook/src/createReadPackageHook.ts[119-127]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[101-127]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-244]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[343-352]

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 v11 read-package hook enumerates metadata-only peers and searches override arrays on every applicable manifest, including when no override can remove a peer.
## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[101-127]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-244]
## Recommended Fix
Precompute whether the override set contains a removal, skip the metadata-only walk when it does not, and restrict per-peer matching to removal-relevant candidates while preserving existing override precedence.

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

Dismiss ↗ | View ↗



Informational

6. A new TypeScript list misses its comma 📘 Rule violation ⚙ Maintainability
Description
The new removeMetaOnlyPeers parameter list ends with peerDependencies without a trailing comma.
Because the parameters are formatted across multiple lines, the final parameter must include the
comma under the TypeScript collection and multi-line construct convention.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R236-238]

+  peerDependenciesMeta: NonNullable<PackageManifest['peerDependenciesMeta']>,
+  peerDependencies: Dependencies | undefined
+): void {
Relevance

● Weak

Comparable multiline TypeScript parameter trailing-comma findings were rejected, including in this
same file.

PR-#12876
PR-#14234

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist requires trailing commas for multi-line TypeScript parameter lists. The newly added
function ends its parameter list with peerDependencies and no comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[231-238]

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 multi-line `removeMetaOnlyPeers` parameter list does not have a trailing comma after its final parameter.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[231-238]

## Recommended Fix
Add a comma after `peerDependencies` in the multi-line function parameter list and run the TypeScript formatter or linter to verify the surrounding style.

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

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 66 rules
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/update (sha: 2457663d) — View relationship
Review mode: Auto: 🚀 Fast: Localized iterator refactor with limited correctness risk and no security exposure.

Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 76bc14a

Results up to commit cd30373 ⚖️ Balanced


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


Remediation recommended
1. One release note mixes v11 and v12 📘 Rule violation § Compliance
Description
The new changeset lists both pnpm and pacquet alongside the v11 hooks package in one file.
Because this PR changes both the TypeScript v11 and Rust v12 implementations, the version-specific
release notes must be split into separate changesets targeting the appropriate package.
Code

.changeset/removal-override-meta-only-optional-peer.md[R2-4]

+"@pnpm/hooks.read-package-hook": patch
+"pnpm": patch
+"pacquet": patch
Relevance

●●● Strong

Recent repository precedents explicitly accept splitting mixed pnpm and pacquet changesets.

PR-#15895
PR-#16479

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR changes both the pnpm11 TypeScript overrider and the pnpm Rust/pacquet overrider, but the
added changeset places pnpm and pacquet in the same file. The checklist requires separate
changesets targeting the appropriate package when both stacks are changed.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/removal-override-meta-only-optional-peer.md[1-7]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-243]
pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[1-45]

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 changeset combines the TypeScript v11 and Rust v12 package targets in one release note, while the checklist requires separate version-specific changesets when both implementations change.

## Fix Focus Areas
- .changeset/removal-override-meta-only-optional-peer.md[1-7]

## Recommended Fix
Create separate changeset files: one targeting the affected v11 published packages, including `pnpm` with a patch bump, and another targeting `pacquet` with an appropriate bump. Keep each release-note entry scoped to the behavior delivered by its target version.

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

Dismiss ↗ | View ↗


2. Rust installs scan peers without removals 🐞 Bug ➹ Performance
Description
has_meta_only_peer_removal collects and clones every metadata-only peer name, then searches the
overrides for each one even when the override set contains no - value. This runs for each resolver
manifest with peer metadata; when a removal does match, remove_meta_only_peers repeats the
collection and searches after the manifest is cloned.
Code

pnpm/crates/package-manager/src/overrides.rs[229]

+            || self.has_meta_only_peer_removal(value, &applicable_parent_scoped)
Relevance

●●● Strong

Recent Rust precedents accept eliminating repeated override scans and allocations in resolver hot
paths.

PR-#13762
PR-#14234

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The resolver invokes apply_to_arc through its manifest hook. The new clone-gate branch calls
has_meta_only_peer_removal, while meta_only_peer_names allocates a vector of cloned strings and
choose_override searches override candidates per name; a matching manifest goes through the same
collection again in apply_to_value.

pnpm/crates/package-manager/src/install_with_fresh_lockfile/manifest_transforms.rs[190-199]
pnpm/crates/package-manager/src/overrides.rs[181-195]
pnpm/crates/package-manager/src/overrides.rs[224-229]
pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[5-45]
pnpm/crates/package-manager/src/overrides.rs[428-458]

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 Rust resolver scans metadata-only peers for removal on manifests even when no removal override exists, and clones their names during both the applicability check and rewrite.
## Fix Focus Areas
- pnpm/crates/package-manager/src/overrides.rs[224-229]
- pnpm/crates/package-manager/src/overrides/meta_only_peers.rs[5-45]
## Recommended Fix
Skip metadata-only peer checks when no applicable removal override exists. Iterate borrowed metadata keys in the applicability check, and allocate names only for entries that must be removed during the rewrite.

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

Dismiss ↗ | View ↗


3. The new peer helper follows its call 📘 Rule violation ⚙ Maintainability
Description
removeMetaOnlyPeers is declared after overrideDepsOfPkg calls it. The call at line 222 precedes
the new declaration at line 231 in the same TypeScript file, so the helper violates the required
declaration order.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[231]

+function removeMetaOnlyPeers (
Relevance

●● Moderate

The helper is already declared after its first use; evidence for enforcing this ordering is
uncertain.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist requires used top-level TypeScript function declarations to appear after at least one
usage. The new helper is called before its declaration in the changed file.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-231]

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

## Issue description
The new `removeMetaOnlyPeers` function is declared after its first usage, contrary to the project’s TypeScript declaration-order requirement.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-243]

## Recommended Fix
Move the `removeMetaOnlyPeers` function declaration above `overrideDepsOfPkg`, or otherwise place its declaration before the first call while preserving the existing behavior.

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

Dismiss ↗ | View ↗


View medium (1)
4. Node installs search unused removal paths 🐞 Bug ➹ Performance
Description
removeMetaOnlyPeers enumerates every metadata key and calls pickVersionOverride for each
undeclared name, even when the configured overrides contain no removal. The read-package hook runs
for each manifest during resolution, so metadata-heavy packages add repeated override-array
filtering to installs that cannot remove a peer.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R239-241]

+  for (const peerName of Object.keys(peerDependenciesMeta)) {
+    if (peerDependencies?.[peerName] != null) continue
+    if (pickVersionOverride(overrides, peerName, '*')?.newBareSpecifier === '-') {
Relevance

●● Moderate

Performance concerns in this hook have been rejected before, but this specific repeated override
scan lacks an exact precedent.

PR-#13938

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
A nonempty override configuration installs the hook, which runs for each manifest. The added loop
enumerates metadata names and calls pickVersionOverride; that function filters the parent and
generic override arrays on each call without first checking whether removal is possible.

pnpm11/hooks/read-package-hook/src/createReadPackageHook.ts[119-127]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[101-127]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-244]
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[343-352]

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 v11 read-package hook enumerates metadata-only peers and searches override arrays on every applicable manifest, including when no override can remove a peer.
## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[101-127]
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[221-244]
## Recommended Fix
Precompute whether the override set contains a removal, skip the metadata-only walk when it does not, and restrict per-peer matching to removal-relevant candidates while preserving existing override precedence.

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

Dismiss ↗ | View ↗



Informational
5. A new TypeScript list misses its comma 📘 Rule violation ⚙ Maintainability
Description
The new removeMetaOnlyPeers parameter list ends with peerDependencies without a trailing comma.
Because the parameters are formatted across multiple lines, the final parameter must include the
comma under the TypeScript collection and multi-line construct convention.
Code

pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[R236-238]

+  peerDependenciesMeta: NonNullable<PackageManifest['peerDependenciesMeta']>,
+  peerDependencies: Dependencies | undefined
+): void {
Relevance

● Weak

Comparable multiline TypeScript parameter trailing-comma findings were rejected, including in this
same file.

PR-#12876
PR-#14234

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist requires trailing commas for multi-line TypeScript parameter lists. The newly added
function ends its parameter list with peerDependencies and no comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[231-238]

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 multi-line `removeMetaOnlyPeers` parameter list does not have a trailing comma after its final parameter.

## Fix Focus Areas
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts[231-238]

## Recommended Fix
Add a comma after `peerDependencies` in the multi-line function parameter list and run the TypeScript formatter or linter to verify the surrounding style.

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

Dismiss ↗ | View ↗


Grey Divider

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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 76bc14a

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan

zkochan commented Oct 7, 2026

Copy link
Copy Markdown
Member

Rebased onto main and pushed 76bc14a, which makes the apply_to_arc fast path borrow the peerDependenciesMeta names instead of cloning them into a Vec<String> for every manifest. Behavior is unchanged.

Review status on 76bc14a: CodeRabbit approved with no actionable comments. Greptile did not review (trial ended) and Qodo reviews are paused for this author. All checks are green. The PR's ready-for-review status was left as is. Nothing remains within the scope of this fix.


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

@zkochan
zkochan merged commit d1e8874 into pnpm:main Oct 7, 2026
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Removal override ("parent>peer": "-") has no effect on a metadata-only optional peer (peerDependenciesMeta without peerDependencies)

3 participants