Skip to content

fix(deps-resolver): rename peer dependents after collapsing a variant - #16359

Merged
zkochan merged 6 commits into
mainfrom
fix/16356-dedupe-rename-peer-dependents
Sep 28, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix/16356-dedupe-rename-peer-dependents

Conversation

@zkochan

@zkochan zkochan commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #16356.

pnpm dedupe was not idempotent: pnpm dedupe --check failed right after pnpm dedupe (first bad release 12.4.2).

Root cause. A lockfile key is the package id plus a peer suffix that spells out the keys of the peers it resolved. dedupe_peer_dependents runs after those keys are built. When it collapses a variant into a larger compatible one, it rewrites the edges that pointed at the collapsed variant, but it keeps every other node's key. In the reporter's repro, @babel/[email protected] collapses into @babel/[email protected]([email protected]). That leaves two babel-plugin-styled-components variants with identical edges, and the dep-path tie-break keeps the one whose key still names the collapsed @babel/core. The lockfile after the first and second dedupe has identical snapshot contents. Only two keys differ. Even the fresh install lockfile names a styled-components variant that does not exist in it.

pnpm v12 reads locked peer versions back from those keys, so the next resolution starts from the stale names and produces a different graph. #14810 (12.4.2) made the collapse fire far more often, which is why the problem surfaced then. The recent convergence fixes (#14898, #15600, #15740, #16335) each made one way of reading the lockfile back less lossy. This PR fixes the writing side instead: a key's peer suffix now names the peers the node actually resolves to.

Fix. After the collapse, every surviving node is renamed from the peers it resolves to (dedupe_peer_dependents/survivor_names.rs), and keys, child edges, and importer direct deps are rewritten.

  • The name is rebuilt from the typed peer ids that the final depPath pass now records (FinalDepPaths.peer_ids). A hashed suffix is hashed again.
  • A name@version peer that closes a cycle is never renamed, even when its text matches a collapsed peerless variant.
  • Only the provisional depPaths the walk nests in a suffix to break a cycle are read back from their text. A graph node without recorded peer ids is never renamed.
  • Nodes renamed to one key merge their edges, the way the peer resolution merges records that share a depPath.
  • The rename runs only when something collapsed.

Verified on the reporter's repro:

  • One dedupe is enough, and dedupe --check passes repeatedly.
  • Every key nested in a peer suffix now names an existing snapshot. Before, even the settled lockfile referenced a missing variant.
  • A frozen install from the new lockfile works.
  • A plain install leaves an existing up-to-date lockfile untouched, so keys only change when something re-resolves (dedupe, update, add).

pnpm v11. v11 has the same collapse-without-rename code in resolvePeers.ts, but it does not read peer pins back from keys the way v12 does, and 11.28.2 is clean on this repro. Renaming there would rewrite keys in maintenance-mode lockfiles without fixing a failure users see, so v11 is left unchanged.

Squash Commit Body

A lockfile key is the package id plus a peer suffix that spells out
the keys of the peers it resolved. dedupe_peer_dependents runs after
those keys are built. When it collapses a variant into a larger
compatible one, it rewrites the edges that pointed at the collapsed
variant but kept every other node's key. A node whose suffix named the
collapsed variant stayed keyed after a variant that no longer exists.
When the collapse left two variants with identical edges, the dep-path
tie-break could also keep the one whose key spelled the collapsed peer.

pnpm v12 reads locked peer versions back from those keys, so the next
resolution started from the stale names and produced a different
graph. `pnpm dedupe` therefore needed a second run to settle, and
`pnpm dedupe --check` failed right after `pnpm dedupe`.

After the collapse, every surviving node is now renamed from the peers
it resolves to. The name is rebuilt from the peer ids the final depPath
pass recorded for it, so a hashed suffix is hashed again and a
`name@version` peer that closes a cycle is left alone. Only the
provisional depPaths the walk nests in a suffix to break a cycle are
read back from their text; a graph node without recorded peer ids,
such as one whose tarball-URL id ends in parentheses, is never renamed.
Keys, child edges, and importer direct deps are rewritten through the
renames. Nodes renamed to one key merge the way the peer resolution
merges records that share a depPath. The rename runs only when something
collapsed, and peer ids are recorded only when this pass will read them.

pnpm v11 shares the collapse-without-rename code but does not read peer
pins back from lockfile keys, and it is not affected by the reported
repro, so it is unchanged.

Closes pnpm/pnpm#16356

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed lockfile peer suffixes when deduplication merges package variants, so pnpm dedupe --check passes immediately after pnpm dedupe.
    • Corrected dependency paths and merged dependency information when deduplication causes package entries to share a name, helping keep the resulting lockfile consistent.

zkochan and others added 2 commits September 28, 2026 22:38
A lockfile key is the package id plus a peer suffix that spells out
the keys of the peers it resolved. dedupe_peer_dependents runs after
those keys are built. When it collapses a variant into a larger
compatible one, it rewrites the edges that pointed at the collapsed
variant but kept every other node's key. A node whose suffix named the
collapsed variant stayed keyed after a variant that no longer exists.
When the collapse left two variants with identical edges, the dep-path
tie-break could also keep the one whose key spelled the collapsed peer.

pnpm v12 reads locked peer versions back from those keys, so the next
resolution started from the stale names and produced a different
graph. `pnpm dedupe` therefore needed a second run to settle, and
`pnpm dedupe --check` failed right after `pnpm dedupe`.

After the collapse, every surviving node is now renamed from the peers
it resolves to. The name is rebuilt from the peer ids the final depPath
pass recorded for it, so a hashed suffix is hashed again and a
`name@version` peer that closes a cycle is left alone. Only the
provisional depPaths the walk nests in a suffix to break a cycle are
read back from their text. Keys, child edges, and importer direct deps
are rewritten through the renames. The rename runs only when something
collapsed.

Closes #16356

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: f4db6ca1-0b2a-4147-aa0f-302753279d1c

📥 Commits

Reviewing files that changed from the base of the PR and between 4e0d711 and 8932636.

📒 Files selected for processing (2)
  • pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs
  • pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs

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


📝 Walkthrough

Walkthrough

The resolver now records peer IDs with final dependency paths when peer-dependent deduplication is enabled. Deduplication uses those IDs to rename surviving peer-dependent nodes after package variants collapse, and updates graph references and importer dependencies.

Changes

Peer-suffix renaming after deduplication

Layer / File(s) Summary
Collect final paths and peer IDs
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs, pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs, pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs
Final dependency-path construction returns node paths and, when requested, peer IDs. The resolver walker requests path construction without peer-ID recording.
Pass peer data into deduplication
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs
Workspace finalization stores peer IDs and supplies them with the configured suffix-length limit when it runs peer-dependent deduplication.
Rename peer-dependent survivors
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents.rs, pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs, pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs, .changeset/dedupe-renames-peer-suffix-after-collapse.md
Deduplication renames affected survivors and updates graph references and importer dependencies. It merges nodes when renamed paths collide and prunes unreachable nodes when a collision occurs. Tests cover renamed paths, suffix handling, and merge behavior. The changeset records the patch.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant FinishedWorkspaceGraph
  participant dedupe_peer_dependents
  participant rename_survivors
  participant DependenciesGraph
  FinishedWorkspaceGraph->>dedupe_peer_dependents: pass peer IDs and suffix-length limit
  dedupe_peer_dependents->>rename_survivors: pass collapsed paths and peer suffix data
  rename_survivors->>DependenciesGraph: update references and rekey survivor nodes
Loading

Assessment against linked issues

Objective Addressed Explanation
Make pnpm dedupe produce a lockfile that pnpm dedupe --check accepts immediately after the dedupe run [#16356] ✅

Suggested labels: product: pacquet

Merge Risk: ⚪ Minimal · up to 89326

No actionable merge-blocking issue remains; the change is ready for normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 89326

The change affects 1 system.

Changed systems: pnpm

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — pnpm (service) was modified; 8 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents.rs: The module now re-exports PeerSuffixes, imports rename_survivors, and declares the survivor_names submodule; the previous direct imports of the graph and collection types are retained.
  • observed — Modified behavior in pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents.rs: The function is now pub(crate) rather than pub, and its signature adds a PeerSuffixes argument. Documentation notes that collapsed variants can change the peers of their dependents, whose peer-suffixed paths are then renamed.
  • observed — Modified behavior in pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents.rs: After pruning unreachable collapsed variants, the function now calls rename_survivors with the graph, importer dependencies, collapse map, and peer suffixes.
  • observed — Modified behavior in pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs: Introduces FinalDepPaths to hold computed paths, optional peer-ID records, and recursion state. build_final_dep_paths now takes a recording flag, returns this structure, and passes shared peer-cycle context and accumulated state into node path construction instead of separate maps and a visiting set.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

When two survivors rename to one key, the second is dropped. Nodes only
it reached had no incoming edge left but stayed in the graph and would
surface as orphan snapshots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.15     15.1±0.60ms    24.8 MB/sec    1.00     13.1±0.24ms    28.6 MB/sec
packument/parse                                  1.02     50.3±1.52µs  1318.7 MB/sec    1.00     49.2±3.33µs  1348.6 MB/sec
tarball/download_dependency                      1.84      9.9±1.24ms   438.2 KB/sec    1.00      5.4±0.20ms   804.9 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.53   306.3±17.61ms 52.2 KElem/sec    1.00    200.7±3.57ms 79.7 KElem/sec
workspace_resolution/hoist_heavy                 1.43   380.8±62.13ms        ? ?/sec    1.00    266.4±5.24ms        ? ?/sec
workspace_sort/chained_projects                  1.17     16.5±1.62ms        ? ?/sec    1.00     14.1±0.70ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.13%. Comparing base (57e7b9b) to head (8932636).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...olver/src/dedupe_peer_dependents/survivor_names.rs 95.93% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #16359    +/-   ##
========================================
  Coverage   92.12%   92.13%            
========================================
  Files        1509     1510     +1     
  Lines      203232   203374   +142     
========================================
+ Hits       187234   187384   +150     
+ Misses      15998    15990     -8     

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

@zkochan
zkochan marked this pull request as ready for review September 28, 2026 21:06
@github-actions

github-actions Bot commented Sep 28, 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 2514.25 ms 2414.77 ms -4.0% 125.71 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1506.39 ms 1500.67 ms -0.4% 75.32 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 379.34 ms 402.30 ms 6.1% 18.97 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pnpr 453.81 ms 361.18 ms -20.4% 22.69 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 10.90 ms 10.90 ms -0.1% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 8.93 ms 9.35 ms 4.7% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 11.27 ms 11.83 ms 5.0% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 10.79 ms 11.10 ms 2.9% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 3372.86 ms 3346.76 ms -0.8% 168.64 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1807.41 ms 1909.25 ms 5.6% 90.37 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pacquet 758.45 ms 785.84 ms 3.6% 37.92 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 442.17 ms 438.66 ms -0.8% 22.11 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1872.45 ms 1930.26 ms 3.1% 93.62 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 412.24 ms 387.45 ms -6.0% 20.61 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 247.59 ms 249.69 ms 0.9% 12.38 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 95.95 ms 93.76 ms -2.3% 4.80 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 1145.61 ms 1216.01 ms 6.1% 57.28 ms Inconclusive (overlapping samples)
isolated-linked-workspace-resolve-hot-cache-offline pacquet 279.93 ms 288.06 ms 2.9% 14.00 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4502.44 ms 4605.62 ms 2.3% 225.12 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3524.88 ms 3597.48 ms 2.1% 176.24 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 187.11 ms 174.39 ms -6.8% 9.36 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 217.12 ms 242.40 ms 11.6% 10.86 ms Inconclusive (overlapping samples)

Integrated-Benchmark Report (Linux)

Commit: 8932636b0b72

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.466 ± 0.113 2.360 2.738 1.65 ± 0.15
pacquet@main 2.554 ± 0.165 2.356 2.828 1.71 ± 0.17
pnpr@HEAD 1.515 ± 0.115 1.377 1.740 1.01 ± 0.11
pnpr@main 1.494 ± 0.114 1.346 1.661 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.46632606298,
      "stddev": 0.1125367033681843,
      "median": 2.4147707022800002,
      "user": 1.7316599399999997,
      "system": 1.7255439200000002,
      "min": 2.35963448528,
      "max": 2.73813123228
    },
    {
      "command": "pacquet@main",
      "mean": 2.5543331897800003,
      "stddev": 0.16525671933508182,
      "median": 2.51425174728,
      "user": 1.7943796399999996,
      "system": 1.8006157200000001,
      "min": 2.35568059428,
      "max": 2.82762520728
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.51468271528,
      "stddev": 0.11474491751038203,
      "median": 1.50066687578,
      "user": 1.6583676399999998,
      "system": 1.6631550199999996,
      "min": 1.37698797028,
      "max": 1.74036907728
    },
    {
      "command": "pnpr@main",
      "mean": 1.49393931928,
      "stddev": 0.11388744080724517,
      "median": 1.5063854717799998,
      "user": 1.63743464,
      "system": 1.64974712,
      "min": 1.34618687928,
      "max": 1.66095218328
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 424.3 ± 101.9 352.5 698.4 1.12 ± 0.30
pacquet@main 380.2 ± 34.0 336.4 434.9 1.00 ± 0.15
pnpr@HEAD 379.1 ± 47.3 338.5 484.4 1.00
pnpr@main 456.9 ± 37.6 405.5 521.9 1.21 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.42430395732,
      "stddev": 0.10192167787047678,
      "median": 0.40230329452,
      "user": 0.46277412,
      "system": 0.8502860999999999,
      "min": 0.35254664502,
      "max": 0.6984456880200001
    },
    {
      "command": "pacquet@main",
      "mean": 0.38019525542000004,
      "stddev": 0.034020881962013305,
      "median": 0.37934362102,
      "user": 0.45700722000000005,
      "system": 0.7862123,
      "min": 0.33643803202,
      "max": 0.43488291102
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.37913230162,
      "stddev": 0.04734967238362764,
      "median": 0.36117745152,
      "user": 0.42686441999999997,
      "system": 0.7577059999999998,
      "min": 0.33849305002,
      "max": 0.48435662802
    },
    {
      "command": "pnpr@main",
      "mean": 0.4569302283200001,
      "stddev": 0.03758035687760935,
      "median": 0.45381469352000003,
      "user": 0.52255682,
      "system": 0.8473103999999999,
      "min": 0.40546583802,
      "max": 0.52194112602
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.2 ± 1.6 8.9 17.7 1.20 ± 0.23
pacquet@main 11.1 ± 1.4 8.3 15.8 1.20 ± 0.22
pnpr@HEAD 9.9 ± 1.6 7.8 17.7 1.06 ± 0.22
pnpr@main 9.3 ± 1.2 7.8 15.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.01115269682329005,
      "stddev": 0.0016256260274843518,
      "median": 0.01089758878,
      "user": 0.006203249177489178,
      "system": 0.006120835151515154,
      "min": 0.00885262378,
      "max": 0.017703085780000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.01112381352654379,
      "stddev": 0.0013937447862700041,
      "median": 0.010904171780000001,
      "user": 0.0061549443317972345,
      "system": 0.006156920552995393,
      "min": 0.008330306780000001,
      "max": 0.01580112078
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009856027009838711,
      "stddev": 0.001603697101345028,
      "median": 0.009349324280000001,
      "user": 0.005441247903225808,
      "system": 0.005447334354838707,
      "min": 0.00784497778,
      "max": 0.017670885780000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.00927335718780142,
      "stddev": 0.0011898138273776441,
      "median": 0.00892808078,
      "user": 0.005070696170212762,
      "system": 0.005190344397163121,
      "min": 0.00783244678,
      "max": 0.015678819780000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 12.2 ± 1.5 9.9 18.0 1.12 ± 0.18
pacquet@main 11.3 ± 1.5 7.5 16.7 1.03 ± 0.17
pnpr@HEAD 11.3 ± 1.5 8.2 15.8 1.03 ± 0.17
pnpr@main 10.9 ± 1.0 8.9 14.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.012203241530303027,
      "stddev": 0.0015382343324458851,
      "median": 0.011834959500000002,
      "user": 0.006772769696969699,
      "system": 0.006600783272727269,
      "min": 0.0098545445,
      "max": 0.0179532505
    },
    {
      "command": "pacquet@main",
      "mean": 0.011311539674999998,
      "stddev": 0.00147398264371004,
      "median": 0.011273120000000001,
      "user": 0.006469137499999996,
      "system": 0.005832424166666669,
      "min": 0.0074848875,
      "max": 0.0166602055
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.011278095667464126,
      "stddev": 0.0014862692057849415,
      "median": 0.011095372499999999,
      "user": 0.006325157894736848,
      "system": 0.005905139138755981,
      "min": 0.008176535500000002,
      "max": 0.0157860745
    },
    {
      "command": "pnpr@main",
      "mean": 0.010937949541152257,
      "stddev": 0.0010426119644771292,
      "median": 0.010785060500000002,
      "user": 0.006214600823045267,
      "system": 0.00563722156378601,
      "min": 0.008858854499999999,
      "max": 0.014645423500000001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.305 ± 0.201 3.007 3.673 1.83 ± 0.16
pacquet@main 3.396 ± 0.160 3.160 3.710 1.89 ± 0.15
pnpr@HEAD 1.947 ± 0.169 1.750 2.271 1.08 ± 0.12
pnpr@main 1.801 ± 0.116 1.640 1.981 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.3046979602599995,
      "stddev": 0.20139690415964373,
      "median": 3.34675619366,
      "user": 3.7009715799999996,
      "system": 2.82768028,
      "min": 3.0065392711600003,
      "max": 3.67330935216
    },
    {
      "command": "pacquet@main",
      "mean": 3.3961059160600002,
      "stddev": 0.16048931961042065,
      "median": 3.37285629266,
      "user": 3.9136304799999997,
      "system": 2.9842157800000004,
      "min": 3.16013089116,
      "max": 3.71037795116
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.94655604716,
      "stddev": 0.1692488264069355,
      "median": 1.90924956916,
      "user": 2.23881868,
      "system": 2.3988673799999995,
      "min": 1.7504659101600002,
      "max": 2.2713377441600002
    },
    {
      "command": "pnpr@main",
      "mean": 1.8013034782600001,
      "stddev": 0.11595764928425521,
      "median": 1.8074122886600001,
      "user": 2.09054208,
      "system": 2.3237857799999997,
      "min": 1.6403966251600002,
      "max": 1.9806622261600002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 793.2 ± 62.0 695.6 920.8 1.84 ± 0.19
pacquet@main 771.1 ± 47.3 720.5 869.1 1.79 ± 0.17
pnpr@HEAD 446.2 ± 29.4 404.2 490.5 1.04 ± 0.10
pnpr@main 430.1 ± 30.3 378.3 457.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.79317295512,
      "stddev": 0.06201702510516824,
      "median": 0.78583941032,
      "user": 1.1291499399999998,
      "system": 1.1128062800000003,
      "min": 0.69561652732,
      "max": 0.9208213673200001
    },
    {
      "command": "pacquet@main",
      "mean": 0.77109327532,
      "stddev": 0.04727611640757675,
      "median": 0.75845195182,
      "user": 1.08841874,
      "system": 1.13269448,
      "min": 0.72054923232,
      "max": 0.86910764332
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.44617000732,
      "stddev": 0.029424279401337582,
      "median": 0.43865891732000006,
      "user": 0.41477724,
      "system": 0.84242358,
      "min": 0.40419309732,
      "max": 0.49050387732
    },
    {
      "command": "pnpr@main",
      "mean": 0.43011197252000005,
      "stddev": 0.0302888671628403,
      "median": 0.44217202132,
      "user": 0.4051867399999999,
      "system": 0.81109648,
      "min": 0.37826768232,
      "max": 0.45740452832
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.933 ± 0.039 1.876 1.988 5.00 ± 0.28
pacquet@main 1.903 ± 0.100 1.769 2.116 4.92 ± 0.37
pnpr@HEAD 0.386 ± 0.020 0.351 0.423 1.00
pnpr@main 0.415 ± 0.030 0.375 0.458 1.08 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.93335741244,
      "stddev": 0.0390185284572245,
      "median": 1.93025822544,
      "user": 1.5095787,
      "system": 1.4139045199999998,
      "min": 1.87556074344,
      "max": 1.98836875244
    },
    {
      "command": "pacquet@main",
      "mean": 1.9026542875399997,
      "stddev": 0.0998596635161799,
      "median": 1.87244895444,
      "user": 1.501748,
      "system": 1.31886322,
      "min": 1.76855328444,
      "max": 2.11622805244
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.38633980794,
      "stddev": 0.020429219259804763,
      "median": 0.38745136844000005,
      "user": 0.3759968,
      "system": 0.8228778199999999,
      "min": 0.35079517044,
      "max": 0.42331083744000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.41547656184,
      "stddev": 0.02990270609385439,
      "median": 0.41223529194,
      "user": 0.4093428,
      "system": 0.86918522,
      "min": 0.37498198944000005,
      "max": 0.45826538044000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 250.8 ± 8.7 238.4 263.7 2.66 ± 0.13
pacquet@main 251.3 ± 19.4 222.2 289.7 2.67 ± 0.22
pnpr@HEAD 94.2 ± 3.0 89.9 102.0 1.00
pnpr@main 99.6 ± 8.6 90.9 123.0 1.06 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25084351743666666,
      "stddev": 0.008673117702010845,
      "median": 0.24969200552,
      "user": 0.23967898333333335,
      "system": 0.13934795666666666,
      "min": 0.23838503752,
      "max": 0.26371705052
    },
    {
      "command": "pacquet@main",
      "mean": 0.25131740615636367,
      "stddev": 0.01944458016808062,
      "median": 0.24758665252,
      "user": 0.22782744545454545,
      "system": 0.11990258545454546,
      "min": 0.22224110452,
      "max": 0.28972330552000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09415242300275865,
      "stddev": 0.003013000392615161,
      "median": 0.09376174052,
      "user": 0.03690096896551724,
      "system": 0.013767350344827586,
      "min": 0.08989592152,
      "max": 0.10204953352
    },
    {
      "command": "pnpr@main",
      "mean": 0.09960607603724139,
      "stddev": 0.00864476751422991,
      "median": 0.09595285352,
      "user": 0.03971352068965518,
      "system": 0.017360350344827587,
      "min": 0.09093622252,
      "max": 0.12299630252
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.163 ± 0.188 0.758 1.341 1.02 ± 0.23
pacquet@main 1.139 ± 0.172 0.821 1.453 1.00
pnpm@HEAD 3.583 ± 0.397 3.084 4.156 3.15 ± 0.59
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.1629172148355553,
      "stddev": 0.1876721995033856,
      "median": 1.21600764328,
      "user": 1.2396468866666666,
      "system": 0.3557511511111111,
      "min": 0.7580558972800001,
      "max": 1.3410296822799999
    },
    {
      "command": "pacquet@main",
      "mean": 1.13891477028,
      "stddev": 0.17196105223079894,
      "median": 1.14560782528,
      "user": 1.2124768866666666,
      "system": 0.34189059555555557,
      "min": 0.82063113728,
      "max": 1.45282092928
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.5833955200577776,
      "stddev": 0.3967800491475604,
      "median": 3.58207646428,
      "user": 5.291036886666666,
      "system": 0.3006418177777778,
      "min": 3.08371314028,
      "max": 4.15598014628
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 287.9 ± 26.2 245.7 320.8 1.04 ± 0.11
pacquet@main 277.7 ± 13.6 257.5 300.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.28794984662,
      "stddev": 0.026212028407552348,
      "median": 0.28806431862000004,
      "user": 0.22749276,
      "system": 0.12561646,
      "min": 0.24569047662000001,
      "max": 0.32078490862000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.27766669102,
      "stddev": 0.013648711861670153,
      "median": 0.27992873862,
      "user": 0.22768606,
      "system": 0.11677486000000001,
      "min": 0.25750640562,
      "max": 0.30064942462
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.636 ± 0.120 4.477 4.837 1.31 ± 0.05
pacquet@main 4.557 ± 0.167 4.408 4.861 1.29 ± 0.06
pnpr@HEAD 3.625 ± 0.139 3.453 3.888 1.03 ± 0.05
pnpr@main 3.535 ± 0.097 3.420 3.793 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.63622926906,
      "stddev": 0.12002883816897413,
      "median": 4.60562480586,
      "user": 2.2370747799999995,
      "system": 2.04703118,
      "min": 4.47709904036,
      "max": 4.83693004336
    },
    {
      "command": "pacquet@main",
      "mean": 4.556775259059999,
      "stddev": 0.16650072905173433,
      "median": 4.50243836386,
      "user": 2.11714028,
      "system": 1.94350918,
      "min": 4.40793553536,
      "max": 4.86055088736
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.62542108256,
      "stddev": 0.13865497004289615,
      "median": 3.59747741136,
      "user": 1.9730041799999998,
      "system": 1.8096209799999996,
      "min": 3.45317007736,
      "max": 3.88772807536
    },
    {
      "command": "pnpr@main",
      "mean": 3.53547685996,
      "stddev": 0.09669065893386575,
      "median": 3.52487718936,
      "user": 1.9719962799999997,
      "system": 1.7828795800000001,
      "min": 3.42013560036,
      "max": 3.79261781236
    }
  ]
}

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 176.5 ± 21.5 140.4 211.0 1.00
pacquet@main 196.3 ± 28.9 168.9 267.8 1.11 ± 0.21
pnpr@HEAD 254.9 ± 57.3 176.9 366.5 1.44 ± 0.37
pnpr@main 211.9 ± 20.6 174.8 242.3 1.20 ± 0.19
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.17650982292333336,
      "stddev": 0.02148222978080971,
      "median": 0.17439036634000005,
      "user": 0.22780989666666662,
      "system": 0.17458120999999996,
      "min": 0.14044322334,
      "max": 0.21095652434000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.19628542217333336,
      "stddev": 0.028892491709620764,
      "median": 0.18711228334000002,
      "user": 0.25024506333333335,
      "system": 0.17153620999999997,
      "min": 0.16888086534000002,
      "max": 0.26783743734000004
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.25488810823999997,
      "stddev": 0.05734746197995981,
      "median": 0.24240005584000002,
      "user": 0.28108778,
      "system": 0.23528175999999998,
      "min": 0.17689041434000002,
      "max": 0.36646086534000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.2119080049763636,
      "stddev": 0.02063457983834196,
      "median": 0.21712186734000002,
      "user": 0.24718434363636366,
      "system": 0.19311100545454546,
      "min": 0.17475461334000003,
      "max": 0.24231133634000002
    }
  ]
}

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Keep peer-suffixed lockfile keys consistent after deduplication

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Rename surviving variants after peer-dependent deduplication so lockfile keys reflect their
 resolved peers.
• Rewrite graph references and importer dependencies, restoring dedupe --check idempotence.
• Cover hashed suffixes, cyclic peers, key collisions, and orphan pruning with regression tests.
Diagram

graph TD
  A["Resolve peers"] --> B["Final depPaths"] --> C{"Variants collapsed?"} -->|Yes| D["Rename survivors"] --> E["Rewrite references"] --> F["Lockfile graph"]
  C -->|No| F
Loading
High-Level Assessment

Retaining typed peer IDs from finalization is the appropriate approach: suffix text alone cannot recover hashed peers or distinguish cycle-closing name/version pairs from variant paths. Re-running peer resolution after deduplication would add a larger, more expensive second pass; the targeted rename avoids it.

Files changed (8) +432 / -54

Bug fix (4) +211 / -42
dedupe_peer_dependents.rsRename surviving nodes after variant collapse +12/-1

Rename surviving nodes after variant collapse

• Passes peer-suffix metadata into deduplication and invokes survivor renaming after collapsed variants have been removed. Skips the new work when nothing collapses.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents.rs

survivor_names.rsRebuild survivor keys and graph references +152/-0

Rebuild survivor keys and graph references

• Recursively rebuilds affected peer suffixes from typed peer IDs, including hashed suffixes, while preserving cycle-closing pairs. Rekeys nodes, rewrites child and importer references, resolves key collisions deterministically, and prunes newly unreachable nodes.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs

resolve_peers.rsCarry final peer IDs into workspace deduplication +21/-4

Carry final peer IDs into workspace deduplication

• Stores finalized peer IDs alongside the finished workspace graph and passes them, with the suffix length limit, to peer-dependent deduplication.

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs

final_paths.rsRecord the peer IDs behind final depPaths +26/-37

Record the peer IDs behind final depPaths

• Changes final-path construction to return paths together with the typed peer IDs used for each peer suffix. Keeps the existing cycle-tracking behavior within the new result structure.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs

Refactor (2) +3 / -1
finalize.rsExpose finalized path metadata +2/-0

Expose finalized path metadata

• Re-exports 'FinalDepPaths' so workspace resolution can access both finalized paths and their peer IDs.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs

walker.rsAdapt the walker to finalized path metadata +1/-1

Adapt the walker to finalized path metadata

• Reads the path-by-node map from the new 'FinalDepPaths' result for the walker's graph and importer construction.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs

Tests (1) +213 / -11
tests.rsTest survivor renaming and collision behavior +213/-11

Test survivor renaming and collision behavior

• Extends existing deduplication tests to supply suffix metadata and verify renamed consumer references. Adds regressions for the stale-key tie-break, hashed suffixes, cycle-closing pairs, and orphan pruning after a rename collision.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs

Documentation (1) +5 / -0
dedupe-renames-peer-suffix-after-collapse.mdDocument the dedupe idempotence fix +5/-0

Document the dedupe idempotence fix

• Adds a patch changeset explaining that lockfile peer suffixes now name surviving variants, allowing 'dedupe --check' to pass after deduplication.

.changeset/dedupe-renames-peer-suffix-after-collapse.md

@qodo-code-review

qodo-code-review Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Merged consumers pick wrong children ✓ Resolved
Description
rekey builds transitive_by_dep_path before merging colliding nodes, so it records only the first
node’s transitive peers for each shared key. When a later consumer collision compares that key with
another child for the same alias, merge_additional_edges uses the incomplete metadata and can
select a different child than it would with the merged peer set.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R102-105]

+    let transitive_by_dep_path: HashMap<DepPath, HashSet<String>> = graph
+        .iter()
+        .map(|(dep_path, node)| (dep_path.clone(), node.edges.transitive_peer_dependencies.clone()))
+        .collect();
Relevance

●●● Strong

Specific correctness bug; stale merge metadata can select wrong children, matching accepted resolver
bug precedents.

PR-#15331
PR-#15674

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
rekey inserts the first renamed node at a new key, queues subsequent collisions, then snapshots
only the graph node’s transitive-peer set; the queued nodes’ sets are absent. The merge extends the
graph node’s set but consults that unchanged snapshot when choosing child edges. The existing graph
builder instead unions transitive peers from all records sharing a depPath before performing those
comparisons.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[82-108]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/graph_edges.rs[110-137]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/graph_edges.rs[238-248]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs[382-400]

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

## Issue description
`rekey` snapshots transitive-peer sets before colliding nodes contribute their sets. Later child-edge comparisons can therefore select the wrong dependency.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[99-108]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/graph_edges.rs[110-137]

## Recommended Fix
Build the lookup by unioning transitive-peer sets from both graph entries and every queued colliding node under its final key before calling `merge_additional_edges`. Add a regression test with a child-key collision and a subsequent parent collision that compares that child against another alias target.

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


2. Importers can lose a resolved child ✓ Resolved
Description
merge_edges keeps the existing child when both renamed nodes have the same alias, without checking
whether their child paths agree. If a peer collapse gives two otherwise incompatible consumers the
same key, an importer of the discarded consumer receives the retained consumer’s child edge instead.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R107-109]

+    for (alias, child) in other.edges.children {
+        edges.children.entry(alias).or_insert(child);
+    }
Relevance

●●● Strong

Accepted-style precedent favors regression fixes for lost child edges and compatibility mismatches
in resolver graph merges.

PR-#15674
PR-#14810

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new test demonstrates that a collapsed peer can rename one consumer onto another consumer’s
existing key, but tests only a shared alias whose edge becomes identical and two distinct extra
aliases. The compatibility check rejects differing child paths unless their package identities and
descendant edges are compatible; the new merge does not repeat that check. On a same-alias conflict,
or_insert discards one edge, and reachability pruning follows only the retained edges before the
lockfile snapshot is built.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[558-615]
pnpm/crates/resolving-deps-resolver/src/dep_path_compatibility.rs[83-129]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[94-112]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/packages.rs[327-346]

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

## Issue description
A rename collision merges nodes with `or_insert`, silently discarding a different child path under the same alias.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[94-112]
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[554-615]

## Recommended Fix
Handle same-alias child conflicts using the graph builder’s preferred-child rules where applicable; do not silently merge nodes whose edges remain incompatible. Add a collision test in which both consumers have the same child alias with different paths after the peer collapse.

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


3. Opaque package URLs can be rewritten ✓ Resolved
Description
rename_peers treats balanced parentheses at the end of an opaque package URL as a peer suffix when
the depPath has no recorded peer IDs. If the apparent peer matches a collapsed variant, the
URL-backed node and its importer references are renamed; a collision with an existing key can then
select that other node's resolution.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R125-130]

+        let peer_ids: Cow<'a, [PeerId]> = match peer_suffixes.peer_ids.get(dep_path) {
+            Some(peer_ids) => Cow::Borrowed(peer_ids),
+            // A depPath the peer resolution did not emit as final is the
+            // provisional one it put in a suffix to break a cycle. Its
+            // segments are read back from the text.
+            None => split_peer_suffix_segments(suffix)?
Relevance

●● Moderate

Security-sensitive URL parsing concern is plausible, but history lacks a closely matching rejection
or acceptance precedent.

PR-#14314

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Finalization forms a depPath from the package ID, and the suffix scanner recognizes any balanced
parenthesized ending. The new fallback converts that ending into peer depPaths, substitutes
collapsed keys, and rekeys the graph; lockfile metadata subsequently derives package identity and
resolution from the surviving node.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[49-70]
pnpm/crates/deps-path/src/suffix_index.rs[14-35]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[106-150]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[77-94]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/packages.rs[165-187]

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

## Issue description
Opaque URL, git, and tarball identities ending in balanced parentheses can be parsed and rewritten as peer suffixes after an unrelated collapse.
## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[121-150]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[49-70]
## Recommended Fix
Carry an explicit typed distinction between actual peer suffixes and opaque package-identity text. Do not parse an arbitrary graph key's trailing parentheses as peers; add a regression test with an opaque URL whose ending resembles a collapsed variant.

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



Remediation recommended

4. Merged variants lose their unique dependencies ✓ Resolved
Description
rekey silently drops a renamed node when its new key is occupied, without checking whether the two
nodes have compatible child edges, and rename_survivors redirects the dropped node’s importers to
the occupant. When the nodes have different children, an importer is redirected to a node missing a
dependency it had resolved, and prune_unreachable removes that child.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R86-93]

+    for (new, mut node) in renamed_nodes {
+        match graph.entry(new) {
+            Entry::Vacant(entry) => {
+                node.dep_path = entry.key().clone();
+                entry.insert(node);
+            }
+            Entry::Occupied(_) => merged = true,
+        }
Relevance

●●● Strong

Recent accepted precedents support fixing graph inconsistencies where incompatible child edges are
dropped or redirected.

PR-#15331
PR-#14810

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cited collision path sets merged = true and drops the renamed node without comparing its edges
with the occupant’s. The regression test gives the two consumers distinct leftover and kept
children, then verifies that project-a is redirected to via_larger and that the losing
consumer’s leftover child is removed; lockfile snapshots are built from the surviving node’s
edges.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[36-49]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[574-580]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[533-562]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[564-580]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[77-94]

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

## Issue description
A rename collision can discard a consumer whose child dependencies differ from those of the node already holding the key. Its importers are redirected to the survivor, and dependencies reachable only through the discarded consumer are pruned.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[75-96]
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[527-581]

## Recommended Fix
On a key collision, compare the nodes’ child edges after renaming and validate any relevant snapshot fields before merging. Merge only when they are compatible; otherwise leave the old key and its edges in place, or fail explicitly if both graphs cannot be represented. Update the collision test to require that the losing consumer’s unique child is not silently removed.

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


5. Provider paths retain obsolete names 🐞 Bug ≡ Correctness
Description
FinishedWorkspaceGraph::dedupe_peer_dependents renames graph keys but leaves paths_by_node_id at
its pre-rename values. When callers request those paths for a locked-peer-provider reuse pass, the
provider-path equality check rejects a renamed provider even though its new depPath is present in
the graph.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[R425-429]

+        dedupe_peer_dependents(
+            &mut self.graph,
+            &mut self.direct_dependencies_by_importer,
+            &PeerSuffixes { peer_ids: &self.peer_ids, max_length: peers_suffix_max_length },
+        );
Relevance

●● Moderate

Stale provider paths could break reuse, but evidence is architectural and lacks a direct precedent
for this exact rename flow.

PR-#13172

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Workspace finalization records provider paths before dedupe, while the new renamer receives and
updates only the graph and importer maps. The resolver's documented reuse mechanism compares those
returned provider paths against previous depPaths and rejects unequal values.

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[355-367]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[423-429]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[441-469]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[26-47]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/context/peer_providers.rs[89-101]

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 workspace result can return old provider depPaths after the graph has renamed those nodes.
## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[423-429]
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[26-49]
## Recommended Fix
Apply the collapse and survivor-rename mappings to collected `paths_by_node_id` values before returning the workspace result. Add a test that feeds the returned paths into a locked-peer-provider reuse pass.

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



Informational

6. Every install keeps peer ids it rarely uses ✓ Resolved
Description
final_dep_path_for_node unconditionally clones each peer-suffixed node’s dep path and stores its
peer-ID vector in a second map, adding allocation, hashing, and peak-memory costs. The
single-importer path immediately discards that map, while workspace resolution retains it even when
dedupe-peer-dependents is disabled; only the enabled workspace dedupe pass reads it.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[R67-68]

+        final_dep_paths.peer_ids.insert(dep_path.clone(), peer_ids);
+        final_dep_paths.by_node_id.insert(node_id.clone(), dep_path.clone());
Relevance

●●● Strong

Recent history accepts targeted allocation and unnecessary-work reductions in peer-resolution hot
paths.

PR-#13172
PR-#13589

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Finalization visits nodes with external peers and unconditionally populates
FinalDepPaths.peer_ids. The public single-importer path calls walker.walk(), which keeps only
by_node_id and drops the peer metadata, while workspace resolution reads peer_ids only in the
dedupe_peer_dependents_enabled branch.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[340-340]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[360-362]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[23-34]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[58-70]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[337-343]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[288-312]

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

## Issue description
`build_final_dep_paths` records peer-ID metadata on resolution paths that cannot use it; only the workspace dedupe-peer-dependents rename pass needs that map.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[23-70]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[337-343]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[438-469]

## Recommended Fix
Pass a flag into `build_final_dep_paths` and collect `peer_ids` only when the workspace dedupe-peer-dependents pass is enabled. Preserve the existing `by_node_id` result for single-importer resolution and workspace runs with dedupe disabled.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 63 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/ramda (sha: 50c6b571) — View relationship
  Explored: repo: pnpm/node-semver-rs (sha: 3d74d6b7) — View relationship
Review mode: 🚀 Fast: The push makes a small, localized graph-merge adjustment with focused regression coverage and no security, performance, or broad cross-cutting risk.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 8932636

Results up to commit 58c6e6b 🧠 Deep


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


Action required
1. Opaque package URLs can be rewritten ✓ Resolved
Description
rename_peers treats balanced parentheses at the end of an opaque package URL as a peer suffix when
the depPath has no recorded peer IDs. If the apparent peer matches a collapsed variant, the
URL-backed node and its importer references are renamed; a collision with an existing key can then
select that other node's resolution.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R125-130]

+        let peer_ids: Cow<'a, [PeerId]> = match peer_suffixes.peer_ids.get(dep_path) {
+            Some(peer_ids) => Cow::Borrowed(peer_ids),
+            // A depPath the peer resolution did not emit as final is the
+            // provisional one it put in a suffix to break a cycle. Its
+            // segments are read back from the text.
+            None => split_peer_suffix_segments(suffix)?
Relevance

●● Moderate

Security-sensitive URL parsing concern is plausible, but history lacks a closely matching rejection
or acceptance precedent.

PR-#14314

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Finalization forms a depPath from the package ID, and the suffix scanner recognizes any balanced
parenthesized ending. The new fallback converts that ending into peer depPaths, substitutes
collapsed keys, and rekeys the graph; lockfile metadata subsequently derives package identity and
resolution from the surviving node.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[49-70]
pnpm/crates/deps-path/src/suffix_index.rs[14-35]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[106-150]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[77-94]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/packages.rs[165-187]

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

## Issue description
Opaque URL, git, and tarball identities ending in balanced parentheses can be parsed and rewritten as peer suffixes after an unrelated collapse.
## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[121-150]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[49-70]
## Recommended Fix
Carry an explicit typed distinction between actual peer suffixes and opaque package-identity text. Do not parse an arbitrary graph key's trailing parentheses as peers; add a regression test with an opaque URL whose ending resembles a collapsed variant.

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



Remediation recommended
2. Merged variants lose their unique dependencies ✓ Resolved
Description
rekey silently drops a renamed node when its new key is occupied, without checking whether the two
nodes have compatible child edges, and rename_survivors redirects the dropped node’s importers to
the occupant. When the nodes have different children, an importer is redirected to a node missing a
dependency it had resolved, and prune_unreachable removes that child.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R86-93]

+    for (new, mut node) in renamed_nodes {
+        match graph.entry(new) {
+            Entry::Vacant(entry) => {
+                node.dep_path = entry.key().clone();
+                entry.insert(node);
+            }
+            Entry::Occupied(_) => merged = true,
+        }
Relevance

●●● Strong

Recent accepted precedents support fixing graph inconsistencies where incompatible child edges are
dropped or redirected.

PR-#15331
PR-#14810

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cited collision path sets merged = true and drops the renamed node without comparing its edges
with the occupant’s. The regression test gives the two consumers distinct leftover and kept
children, then verifies that project-a is redirected to via_larger and that the losing
consumer’s leftover child is removed; lockfile snapshots are built from the surviving node’s
edges.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[36-49]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[574-580]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[533-562]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[564-580]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[77-94]

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

## Issue description
A rename collision can discard a consumer whose child dependencies differ from those of the node already holding the key. Its importers are redirected to the survivor, and dependencies reachable only through the discarded consumer are pruned.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[75-96]
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[527-581]

## Recommended Fix
On a key collision, compare the nodes’ child edges after renaming and validate any relevant snapshot fields before merging. Merge only when they are compatible; otherwise leave the old key and its edges in place, or fail explicitly if both graphs cannot be represented. Update the collision test to require that the losing consumer’s unique child is not silently removed.

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


3. Provider paths retain obsolete names 🐞 Bug ≡ Correctness
Description
FinishedWorkspaceGraph::dedupe_peer_dependents renames graph keys but leaves paths_by_node_id at
its pre-rename values. When callers request those paths for a locked-peer-provider reuse pass, the
provider-path equality check rejects a renamed provider even though its new depPath is present in
the graph.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[R425-429]

+        dedupe_peer_dependents(
+            &mut self.graph,
+            &mut self.direct_dependencies_by_importer,
+            &PeerSuffixes { peer_ids: &self.peer_ids, max_length: peers_suffix_max_length },
+        );
Relevance

●● Moderate

Stale provider paths could break reuse, but evidence is architectural and lacks a direct precedent
for this exact rename flow.

PR-#13172

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Workspace finalization records provider paths before dedupe, while the new renamer receives and
updates only the graph and importer maps. The resolver's documented reuse mechanism compares those
returned provider paths against previous depPaths and rejects unequal values.

pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[355-367]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[423-429]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[441-469]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[26-47]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/context/peer_providers.rs[89-101]

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 workspace result can return old provider depPaths after the graph has renamed those nodes.
## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[423-429]
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[26-49]
## Recommended Fix
Apply the collapse and survivor-rename mappings to collected `paths_by_node_id` values before returning the workspace result. Add a test that feeds the returned paths into a locked-peer-provider reuse pass.

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



Informational
4. Every install keeps peer ids it rarely uses ✓ Resolved
Description
final_dep_path_for_node unconditionally clones each peer-suffixed node’s dep path and stores its
peer-ID vector in a second map, adding allocation, hashing, and peak-memory costs. The
single-importer path immediately discards that map, while workspace resolution retains it even when
dedupe-peer-dependents is disabled; only the enabled workspace dedupe pass reads it.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[R67-68]

+        final_dep_paths.peer_ids.insert(dep_path.clone(), peer_ids);
+        final_dep_paths.by_node_id.insert(node_id.clone(), dep_path.clone());
Relevance

●●● Strong

Recent history accepts targeted allocation and unnecessary-work reductions in peer-resolution hot
paths.

PR-#13172
PR-#13589

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Finalization visits nodes with external peers and unconditionally populates
FinalDepPaths.peer_ids. The public single-importer path calls walker.walk(), which keeps only
by_node_id and drops the peer metadata, while workspace resolution reads peer_ids only in the
dedupe_peer_dependents_enabled branch.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[340-340]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[360-362]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[23-34]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[58-70]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[337-343]
pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[288-312]

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

## Issue description
`build_final_dep_paths` records peer-ID metadata on resolution paths that cannot use it; only the workspace dedupe-peer-dependents rename pass needs that map.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/final_paths.rs[23-70]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[337-343]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers.rs[438-469]

## Recommended Fix
Pass a flag into `build_final_dep_paths` and collect `peer_ids` only when the workspace dedupe-peer-dependents pass is enabled. Preserve the existing `by_node_id` result for single-importer resolution and workspace runs with dedupe disabled.

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


Results up to commit f2a31b5 ⚖️ Balanced


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


Action required
1. Importers can lose a resolved child ✓ Resolved
Description
merge_edges keeps the existing child when both renamed nodes have the same alias, without checking
whether their child paths agree. If a peer collapse gives two otherwise incompatible consumers the
same key, an importer of the discarded consumer receives the retained consumer’s child edge instead.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R107-109]

+    for (alias, child) in other.edges.children {
+        edges.children.entry(alias).or_insert(child);
+    }
Relevance

●●● Strong

Accepted-style precedent favors regression fixes for lost child edges and compatibility mismatches
in resolver graph merges.

PR-#15674
PR-#14810

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new test demonstrates that a collapsed peer can rename one consumer onto another consumer’s
existing key, but tests only a shared alias whose edge becomes identical and two distinct extra
aliases. The compatibility check rejects differing child paths unless their package identities and
descendant edges are compatible; the new merge does not repeat that check. On a same-alias conflict,
or_insert discards one edge, and reachability pruning follows only the retained edges before the
lockfile snapshot is built.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[558-615]
pnpm/crates/resolving-deps-resolver/src/dep_path_compatibility.rs[83-129]
pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[94-112]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/packages.rs[327-346]

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

## Issue description
A rename collision merges nodes with `or_insert`, silently discarding a different child path under the same alias.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[94-112]
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/tests.rs[554-615]

## Recommended Fix
Handle same-alias child conflicts using the graph builder’s preferred-child rules where applicable; do not silently merge nodes whose edges remain incompatible. Add a collision test in which both consumers have the same child alias with different paths after the peer collapse.

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


Results up to commit 4e0d711 ⚖️ Balanced


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


Action required
1. Merged consumers pick wrong children ✓ Resolved
Description
rekey builds transitive_by_dep_path before merging colliding nodes, so it records only the first
node’s transitive peers for each shared key. When a later consumer collision compares that key with
another child for the same alias, merge_additional_edges uses the incomplete metadata and can
select a different child than it would with the merged peer set.
Code

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[R102-105]

+    let transitive_by_dep_path: HashMap<DepPath, HashSet<String>> = graph
+        .iter()
+        .map(|(dep_path, node)| (dep_path.clone(), node.edges.transitive_peer_dependencies.clone()))
+        .collect();
Relevance

●●● Strong

Specific correctness bug; stale merge metadata can select wrong children, matching accepted resolver
bug precedents.

PR-#15331
PR-#15674

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
rekey inserts the first renamed node at a new key, queues subsequent collisions, then snapshots
only the graph node’s transitive-peer set; the queued nodes’ sets are absent. The merge extends the
graph node’s set but consults that unchanged snapshot when choosing child edges. The existing graph
builder instead unions transitive peers from all records sharing a depPath before performing those
comparisons.

pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[82-108]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/graph_edges.rs[110-137]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/graph_edges.rs[238-248]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs[382-400]

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

## Issue description
`rekey` snapshots transitive-peer sets before colliding nodes contribute their sets. Later child-edge comparisons can therefore select the wrong dependency.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/dedupe_peer_dependents/survivor_names.rs[99-108]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/graph_edges.rs[110-137]

## Recommended Fix
Build the lookup by unioning transitive-peer sets from both graph entries and every queued colliding node under its final key before calling `merge_additional_edges`. Add a regression test with a child-key collision and a subsequent parent collision that compares that child against another alias target.

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


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.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 28, 2026
…s opaque

When a rename sends two nodes to one key, the second one's child
aliases, optional children and transitive peers now merge into the node
that keeps the key, the way the peer resolution merges records that
share a depPath. Before, the second node's edges were discarded and
children only it reached were pruned.

The text fallback that reads peers back from a suffix now applies only
to the provisional depPaths nested in a suffix. A graph node with no
recorded peer ids has no peer suffix, even when its package id, such as
a tarball URL, ends in parentheses.

Peer ids are recorded during the final depPath pass only when the
workspace dedupe of peer dependents will read them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zkochan

zkochan commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

Replies to the findings in the Qodo review summary.

2. Merged variants lose their unique dependencies. Real, fixed in f2a31b5. When a rename sends two nodes to one key, the second node's child aliases, optional children and transitive peers now merge into the node that keeps the key. That is how the peer resolution merges records that share a depPath (merge_additional_edges). Where both have an alias, the kept node's edge wins, and anything left unreachable is pruned. a_consumer_renamed_onto_an_existing_key_merges_its_children now requires the losing consumer's unique child to survive on the merged node, and it fails without the merge.

3. Provider paths retain obsolete names. Not acting on this. WorkspaceResolvePeersResult::paths_by_node_id is populated only when collect_paths_by_node_id is set, and nothing sets it on the workspace path outside tests. The map also went stale after the collapse already on main, since the collapse map was never applied to it either. If a caller starts reading it, the combined collapse and rename map should be applied then, together with a test through that caller.

4. Every install keeps peer ids it rarely uses. Real, fixed in f2a31b5. build_final_dep_paths records peer ids only when asked. The single-importer walk never asks, and the workspace pass asks only when dedupePeerDependents is enabled.


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

@qodo-code-review

Copy link
Copy Markdown

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

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

…er does

When a rename merges two consumers that disagree on an alias, the child
is now chosen by merge_additional_edges, the same rule the peer
resolution applies to records that share a depPath: the child whose
peers the consumer's suffix provides wins. Edges are retargeted to the
new keys before the nodes move, so the comparison sees final names.

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4e0d711

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

…merging

The transitive-peer lookup that merge_additional_edges consults was
built from the graph before colliding nodes merged in, so it held only
the kept node's set for a shared key. A parent collision that compared
that key with another child could then choose differently from the
graph builder, which unions the sets of every record sharing a depPath.
The lookup now includes the colliding nodes' sets under their new keys.

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

Copy link
Copy Markdown

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

@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 373c7f3 into main Sep 28, 2026
56 checks passed
@zkochan
zkochan deleted the fix/16356-dedupe-rename-peer-dependents branch September 28, 2026 22:43
KSXGitHub pushed a commit that referenced this pull request Sep 29, 2026
Brings in the 16 commits main gained since this branch was started, up
to d162953 (#16362). Four of them touch files this branch also
changes (resolve_peers.rs, resolve_peers/finalize.rs,
finalize/final_paths.rs and resolve_peers/walker.rs, from the
peer-dependent dedupe work in #16359 and #16361); git
merged them without conflicts, and none of main's new code reads the
ResolvedPackage fields this branch made private.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 12.4.2+: pnpm dedupe is not idempotent — dedupe --check fails right after dedupe

2 participants