Skip to content

fix(install): accept an injected dependency's peer resolved to a workspace link - #16346

Merged
zkochan merged 1 commit into
mainfrom
fix-16332
Sep 28, 2026
Merged

zkochan merged 1 commit into
mainfrom
fix-16332

Conversation

@zkochan

@zkochan zkochan commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #16332.

Since 12.7.0, pnpm install --frozen-lockfile rejects the lockfile it just wrote when an injected workspace package declares a peer dependency that the consumer provides from the workspace (local dependency "lib" at "lib" is outdated).

The freshness check for injected/directory dependencies (added in #15356) re-tested each resolved peer in the snapshot against the declared range. A workspace-provided peer is recorded as link:<dir>, which never satisfies a range spec. An unmet peer (a version outside the range, which pnpm only warns about) failed the same way.

The resolved peers are the parent's choice and say nothing about staleness, so the check now compares only the declared peer ranges and peerDependenciesMeta against the ones recorded in packages:. Those comparisons already existed and still catch every edit to the injected package's peers.

pnpm v11 is not affected: the reporter's script and the unmet-peer variant both pass on 11.28.0, so this is a v12-only fix.

Squash Commit Body

A frozen install rejected a freshly generated lockfile when an injected
workspace package declared a peer dependency that the consuming project
provides from the workspace. The lockfile snapshot records that peer as
`link:<dir>`, and the freshness check re-tested every resolved peer against
the declared range, which never matches a `link:` ref. The same test also
failed for an unmet peer, which pnpm only warns about.

The resolved peers are the parent's choice, so they do not indicate a stale
lockfile. The check now compares only the declared peer ranges and
`peerDependenciesMeta` with the ones recorded in the lockfile, which still
catches every edit to the injected package's peers.

pnpm v11 is not affected.

Closes pnpm/pnpm#16332

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


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
    • Fixed frozen-lockfile installs failing with freshly generated lockfiles when an injected workspace package has peer dependencies.
    • Verified the fix with workspace peer dependencies provided by another package and with an unmet peer version.

…space link

A frozen install rejected a freshly generated lockfile when an injected
workspace package declared a peer dependency that the consuming project
provides from the workspace. The lockfile snapshot records that peer as
`link:<dir>`, and the freshness check re-tested every resolved peer against
the declared range, which never matches a `link:` ref. The same test also
failed for an unmet peer, which pnpm only warns about.

The resolved peers are the parent's choice, so they do not indicate a stale
lockfile. The check now compares only the declared peer ranges and
`peerDependenciesMeta` with the ones recorded in the lockfile, which still
catches every edit to the injected package's peers.

pnpm v11 is not affected.

Closes #16332

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: b3e3a77f-24ca-482e-b615-745cd117a798

📥 Commits

Reviewing files that changed from the base of the PR and between cfbf081 and 6f945bc.

📒 Files selected for processing (3)
  • .changeset/frozen-injected-peer-link.md
  • pnpm/crates/cli/tests/suite/inject_workspace_packages.rs
  • pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs

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


📝 Walkthrough

Walkthrough

The local peer dependency freshness check no longer compares declared peer specs with resolved snapshot dependencies. New regression tests cover frozen installs with workspace and mismatched peer-provider specs.

Changes

Injected peer freshness

Layer / File(s) Summary
Peer freshness check and regression coverage
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs, pnpm/crates/cli/tests/suite/inject_workspace_packages.rs, .changeset/frozen-injected-peer-link.md
The local peer dependency freshness check retains package metadata checks but removes the comparison against resolved snapshot dependencies. Regression tests cover frozen installs with workspace:* and 2.0.0 as the peer provider. The changeset records the patch.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
[ #16332 ] Allow pnpm install --frozen-lockfile to complete with a freshly generated lockfile when an injected workspace package has peer dependencies. ✅

Suggested labels: product: pacquet

Merge Risk: ⚪ Minimal · up to 6f945

The frozen-install fix is mergeable after normal checks; no actionable risk remains in the supplied evidence.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 6f945

The change fixes rejection of freshly generated lockfiles while retaining checks for edits to an injected package’s declared peers. No security exploit is established. Validation of unexpected peer references in an existing lockfile remains uncertain.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The affected decision concerns local or injected directory dependencies encountered during install. The changed test helpers add no production entrypoint or service boundary.

Trust Boundaries and Controls

  • inferred — An existing lockfile supplies resolved peer references, while the remaining freshness checks verify peer declarations against package metadata. The inspected path does not establish whether frozen-install consumption independently verifies that a peer reference came from the parent’s selected provider.

Hardening Proposals

  • proposed — If frozen installs are expected to validate lockfiles from lower-trust sources, establish where resolved peer references are tied to the parent provider and test an altered peer reference there, without reinstating a range check that rejects legitimate unmet peers.
✨ 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.

@github-actions

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.19     16.3±1.96ms    23.0 MB/sec    1.00     13.7±0.21ms    27.4 MB/sec
packument/parse                                  1.05     48.9±3.69µs  1355.4 MB/sec    1.00     46.8±1.34µs  1416.6 MB/sec
tarball/download_dependency                      1.16      5.6±0.72ms   775.9 KB/sec    1.00      4.8±0.19ms   903.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.10    257.3±7.53ms 62.2 KElem/sec    1.00    234.4±5.16ms 68.3 KElem/sec
workspace_resolution/hoist_heavy                 1.32   379.7±18.99ms        ? ?/sec    1.00    288.1±6.34ms        ? ?/sec
workspace_sort/chained_projects                  1.28     23.1±4.09ms        ? ?/sec    1.00     18.0±1.73ms        ? ?/sec

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.12%. Comparing base (ebffb9c) to head (6f945bc).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16346      +/-   ##
==========================================
- Coverage   92.13%   92.12%   -0.01%     
==========================================
  Files        1509     1509              
  Lines      203180   203159      -21     
==========================================
- Hits       187197   187163      -34     
- Misses      15983    15996      +13     

☔ 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

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 2546.95 ms 2480.03 ms -2.6% 127.35 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1684.47 ms 1606.69 ms -4.6% 84.22 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 420.09 ms 432.97 ms 3.1% 21.00 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 436.50 ms 485.22 ms 11.2% 21.83 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 11.63 ms 11.25 ms -3.2% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 11.52 ms 11.41 ms -1.0% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 16.97 ms 17.63 ms 3.9% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 18.48 ms 18.23 ms -1.3% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2866.86 ms 2716.85 ms -5.2% 143.34 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1618.11 ms 1789.39 ms 10.6% 80.91 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pacquet 907.52 ms 914.55 ms 0.8% 45.38 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 519.09 ms 502.45 ms -3.2% 25.95 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1762.85 ms 1793.15 ms 1.7% 88.14 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 343.85 ms 343.32 ms -0.2% 17.19 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 474.54 ms 436.68 ms -8.0% 23.73 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 139.02 ms 140.16 ms 0.8% 6.95 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 1400.62 ms 1537.74 ms 9.8% 70.03 ms Inconclusive (overlapping samples)
isolated-linked-workspace-resolve-hot-cache-offline pacquet 229.14 ms 244.76 ms 6.8% 11.46 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4686.32 ms 4908.08 ms 4.7% 234.32 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3636.26 ms 3595.95 ms -1.1% 181.81 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 172.66 ms 193.61 ms 12.1% 8.63 ms Inconclusive (overlapping samples)
gvs-fresh-restore-hot-cache-hot-store pnpr 208.67 ms 212.07 ms 1.6% 10.43 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 6f945bc51f41

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.096 2.337 2.599 1.48 ± 0.17
pacquet@main 2.543 ± 0.168 2.328 2.825 1.52 ± 0.19
pnpr@HEAD 1.672 ± 0.177 1.426 1.929 1.00
pnpr@main 1.798 ± 0.360 1.534 2.740 1.08 ± 0.24
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4662387041000007,
      "stddev": 0.09566167823167793,
      "median": 2.4800340193,
      "user": 1.7303226200000001,
      "system": 1.65683914,
      "min": 2.3372315408000004,
      "max": 2.5989012738
    },
    {
      "command": "pacquet@main",
      "mean": 2.5425675173,
      "stddev": 0.1675388358518125,
      "median": 2.5469518443,
      "user": 1.9228369199999995,
      "system": 1.8358925400000001,
      "min": 2.3279390538,
      "max": 2.8245666648000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6719993753,
      "stddev": 0.17701007662101093,
      "median": 1.6066873563000001,
      "user": 2.12406632,
      "system": 2.14381854,
      "min": 1.4261860088,
      "max": 1.9292126327999999
    },
    {
      "command": "pnpr@main",
      "mean": 1.7984114112,
      "stddev": 0.3598106697727547,
      "median": 1.6844715898,
      "user": 2.2127481199999997,
      "system": 2.2256415400000003,
      "min": 1.5337586388,
      "max": 2.7401366798
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 428.3 ± 38.4 373.7 504.2 1.00
pacquet@main 429.5 ± 55.6 367.9 566.7 1.00 ± 0.16
pnpr@HEAD 460.7 ± 78.2 344.7 558.0 1.08 ± 0.21
pnpr@main 448.7 ± 36.5 416.4 532.9 1.05 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.42829763554000005,
      "stddev": 0.03842173893499801,
      "median": 0.43296753544,
      "user": 0.46473205999999995,
      "system": 0.87482136,
      "min": 0.37374312844,
      "max": 0.5041949544400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.42948986874000006,
      "stddev": 0.05555352203246832,
      "median": 0.42008731744000005,
      "user": 0.48073346,
      "system": 0.8704574600000001,
      "min": 0.36792841744000004,
      "max": 0.5666889604400001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.46070651664000006,
      "stddev": 0.07817936999517561,
      "median": 0.48522373744,
      "user": 0.50389336,
      "system": 0.8830365600000001,
      "min": 0.34468287044,
      "max": 0.5580445194400001
    },
    {
      "command": "pnpr@main",
      "mean": 0.44871614404000004,
      "stddev": 0.03648507244000358,
      "median": 0.43650360844,
      "user": 0.48604585999999994,
      "system": 0.8658211599999998,
      "min": 0.41643702044,
      "max": 0.5329316764400001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.3 ± 1.2 9.2 15.8 1.00
pacquet@main 11.7 ± 1.1 8.7 14.6 1.04 ± 0.15
pnpr@HEAD 11.5 ± 0.9 9.3 14.3 1.02 ± 0.13
pnpr@main 11.6 ± 1.6 8.6 18.4 1.02 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.011334191122857136,
      "stddev": 0.0011637371168639625,
      "median": 0.01125439638,
      "user": 0.006688340000000001,
      "system": 0.0054131616,
      "min": 0.00921979338,
      "max": 0.015836180380000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.01173575320173913,
      "stddev": 0.0011349014341088452,
      "median": 0.01163213288,
      "user": 0.007310893043478262,
      "system": 0.005204973913043479,
      "min": 0.00867406238,
      "max": 0.01459774338
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.0115359042675,
      "stddev": 0.0009441773544645617,
      "median": 0.011409141880000001,
      "user": 0.006403809166666672,
      "system": 0.005902099833333331,
      "min": 0.00930588938,
      "max": 0.014274239380000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.01160806507230769,
      "stddev": 0.0016362768229974264,
      "median": 0.011519100380000001,
      "user": 0.006727766425339367,
      "system": 0.005599416108597281,
      "min": 0.008615083380000001,
      "max": 0.018447992380000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 18.1 ± 3.2 12.7 31.1 1.02 ± 0.28
pacquet@main 17.7 ± 3.7 12.0 29.4 1.00
pnpr@HEAD 18.7 ± 4.3 12.1 34.2 1.05 ± 0.32
pnpr@main 18.4 ± 3.1 11.4 31.9 1.04 ± 0.28
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.01806312726204081,
      "stddev": 0.003241067334042161,
      "median": 0.01763185416,
      "user": 0.010050197006802717,
      "system": 0.008905032653061223,
      "min": 0.01270784916,
      "max": 0.031110287160000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.017719515840000002,
      "stddev": 0.0036633569882898085,
      "median": 0.016965996160000003,
      "user": 0.009682819999999996,
      "system": 0.008882,
      "min": 0.01202468216,
      "max": 0.02936726116
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.01867724455751552,
      "stddev": 0.004254467881599649,
      "median": 0.01823138016,
      "user": 0.010258785590062115,
      "system": 0.009312609937888199,
      "min": 0.012124576159999999,
      "max": 0.034174970160000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.018368255056825402,
      "stddev": 0.0031419665297273713,
      "median": 0.018479736660000003,
      "user": 0.0104822673015873,
      "system": 0.00886699206349206,
      "min": 0.01138291516,
      "max": 0.03194220316
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.779 ± 0.213 2.551 3.189 1.68 ± 0.17
pacquet@main 2.938 ± 0.226 2.701 3.372 1.77 ± 0.18
pnpr@HEAD 1.777 ± 0.103 1.653 1.928 1.07 ± 0.10
pnpr@main 1.659 ± 0.116 1.507 1.904 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7789034446,
      "stddev": 0.21285426217335035,
      "median": 2.7168530307000003,
      "user": 2.6117077199999996,
      "system": 2.1344730399999996,
      "min": 2.5514306852,
      "max": 3.1891087582
    },
    {
      "command": "pacquet@main",
      "mean": 2.9378393839999997,
      "stddev": 0.22587182563801428,
      "median": 2.8668629142000004,
      "user": 3.22147362,
      "system": 2.36162134,
      "min": 2.7006240032,
      "max": 3.3718190872
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.7772993438000004,
      "stddev": 0.1032663268099541,
      "median": 1.7893943022,
      "user": 2.14588792,
      "system": 2.1125063400000004,
      "min": 1.6525984052,
      "max": 1.9276534842000002
    },
    {
      "command": "pnpr@main",
      "mean": 1.6588324673,
      "stddev": 0.11612883897089035,
      "median": 1.6181137042000002,
      "user": 1.78886152,
      "system": 1.68261164,
      "min": 1.5067756782000001,
      "max": 1.9044561062
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 932.3 ± 46.7 866.3 1000.2 1.83 ± 0.17
pacquet@main 923.4 ± 54.1 854.7 1018.0 1.81 ± 0.18
pnpr@HEAD 509.9 ± 41.5 452.4 596.1 1.00
pnpr@main 515.8 ± 46.6 434.7 578.2 1.01 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.9323230547000001,
      "stddev": 0.04672697063229213,
      "median": 0.9145512703,
      "user": 1.3192413200000002,
      "system": 1.2273667999999998,
      "min": 0.8663028538,
      "max": 1.0002450718
    },
    {
      "command": "pacquet@main",
      "mean": 0.9233988346,
      "stddev": 0.054144578568567525,
      "median": 0.9075179843000001,
      "user": 1.29171242,
      "system": 1.2162205,
      "min": 0.8546640718000001,
      "max": 1.0180282788000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.5098527573,
      "stddev": 0.04150615184577035,
      "median": 0.5024463683,
      "user": 0.48860512,
      "system": 0.8370048999999999,
      "min": 0.4523722328,
      "max": 0.5960687438000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.5157892343,
      "stddev": 0.04664465997088341,
      "median": 0.5190903403,
      "user": 0.47397821999999995,
      "system": 0.8497880999999999,
      "min": 0.4346611168,
      "max": 0.5782102888
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.783 ± 0.112 1.646 1.929 5.17 ± 0.46
pacquet@main 1.784 ± 0.069 1.699 1.900 5.18 ± 0.38
pnpr@HEAD 0.345 ± 0.022 0.316 0.391 1.00
pnpr@main 0.382 ± 0.074 0.317 0.509 1.11 ± 0.23
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7826071694000003,
      "stddev": 0.11194823506434874,
      "median": 1.7931507666000002,
      "user": 1.23325448,
      "system": 0.9788167399999999,
      "min": 1.6463039811000002,
      "max": 1.9289725121000003
    },
    {
      "command": "pacquet@main",
      "mean": 1.7844516340000003,
      "stddev": 0.06949926932079262,
      "median": 1.7628492986,
      "user": 1.2030543799999998,
      "system": 1.0219709399999999,
      "min": 1.6986655871,
      "max": 1.9000052111
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3447385326,
      "stddev": 0.021824653928846315,
      "median": 0.3433249521,
      "user": 0.29797167999999996,
      "system": 0.6444254399999998,
      "min": 0.3162027631,
      "max": 0.3905128921
    },
    {
      "command": "pnpr@main",
      "mean": 0.3820335635,
      "stddev": 0.07373214808655765,
      "median": 0.3438456556,
      "user": 0.33481658000000003,
      "system": 0.67134504,
      "min": 0.3166615101,
      "max": 0.5089178581
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 433.6 ± 29.0 393.4 483.1 3.13 ± 0.26
pacquet@main 468.8 ± 30.5 417.3 508.0 3.38 ± 0.27
pnpr@HEAD 138.6 ± 6.5 118.5 146.6 1.00
pnpr@main 139.3 ± 5.3 128.6 148.1 1.01 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.4336319490999999,
      "stddev": 0.028964721125613137,
      "median": 0.4366833647,
      "user": 0.4496816,
      "system": 0.19609868,
      "min": 0.3933700772,
      "max": 0.4831423172
    },
    {
      "command": "pacquet@main",
      "mean": 0.4688237122,
      "stddev": 0.03053206809798796,
      "median": 0.4745406837,
      "user": 0.4922205,
      "system": 0.19320617999999995,
      "min": 0.41725330320000004,
      "max": 0.5079509782
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.13858866243809523,
      "stddev": 0.006489242526929228,
      "median": 0.14016074520000002,
      "user": 0.0703415761904762,
      "system": 0.03115938,
      "min": 0.11850467120000001,
      "max": 0.14660121520000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.13929136956842106,
      "stddev": 0.005285571452864647,
      "median": 0.1390203922,
      "user": 0.07788704736842104,
      "system": 0.026759327368421057,
      "min": 0.1285757552,
      "max": 0.1480698822
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.712 ± 0.419 1.368 2.492 1.23 ± 0.37
pacquet@main 1.390 ± 0.249 0.963 1.787 1.00
pnpm@HEAD 4.143 ± 0.847 3.289 5.544 2.98 ± 0.81
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7121453737777779,
      "stddev": 0.4188198931566862,
      "median": 1.5377433569999999,
      "user": 1.8268164066666666,
      "system": 0.5415852088888888,
      "min": 1.367989768,
      "max": 2.4915133860000003
    },
    {
      "command": "pacquet@main",
      "mean": 1.3901969652222224,
      "stddev": 0.2490823386068339,
      "median": 1.400620139,
      "user": 1.4931315177777775,
      "system": 0.43345631999999995,
      "min": 0.9630094450000001,
      "max": 1.786620085
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.143009208222222,
      "stddev": 0.8471875644758053,
      "median": 3.8803985460000003,
      "user": 6.143189628888889,
      "system": 0.3333375422222222,
      "min": 3.288868347,
      "max": 5.544149754
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 248.0 ± 14.9 229.0 276.4 1.10 ± 0.10
pacquet@main 225.5 ± 15.1 207.4 256.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24800485648181822,
      "stddev": 0.01492667640456565,
      "median": 0.2447575693,
      "user": 0.20345589272727274,
      "system": 0.09793794363636361,
      "min": 0.22902391830000002,
      "max": 0.2764045763
    },
    {
      "command": "pacquet@main",
      "mean": 0.22552700713333337,
      "stddev": 0.015064431858625426,
      "median": 0.2291448158,
      "user": 0.17994770333333332,
      "system": 0.08812133,
      "min": 0.2074135443,
      "max": 0.2563545123
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.945 ± 0.197 4.724 5.376 1.35 ± 0.07
pacquet@main 4.730 ± 0.143 4.588 5.085 1.30 ± 0.06
pnpr@HEAD 3.651 ± 0.135 3.531 3.952 1.00
pnpr@main 3.654 ± 0.053 3.590 3.734 1.00 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.944737524720001,
      "stddev": 0.19697702933521818,
      "median": 4.908084666320001,
      "user": 2.947003079999999,
      "system": 2.7004772200000002,
      "min": 4.72430055532,
      "max": 5.375561068320001
    },
    {
      "command": "pacquet@main",
      "mean": 4.72961624062,
      "stddev": 0.14328869639003247,
      "median": 4.686320653320001,
      "user": 2.6486134800000003,
      "system": 2.47977512,
      "min": 4.58751958932,
      "max": 5.08518591632
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.6513557026200005,
      "stddev": 0.13486861370080006,
      "median": 3.59595026632,
      "user": 2.3135367799999997,
      "system": 2.14560752,
      "min": 3.5311911293200002,
      "max": 3.95198680332
    },
    {
      "command": "pnpr@main",
      "mean": 3.65430890632,
      "stddev": 0.053298978037987464,
      "median": 3.6362576838200003,
      "user": 2.4564904800000003,
      "system": 2.2344375199999997,
      "min": 3.5896512633200004,
      "max": 3.73398085932
    }
  ]
}

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 193.7 ± 14.4 175.2 218.8 1.12 ± 0.12
pacquet@main 173.7 ± 12.7 151.1 195.5 1.00
pnpr@HEAD 214.3 ± 13.9 199.8 242.0 1.23 ± 0.12
pnpr@main 204.9 ± 14.6 177.6 227.2 1.18 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1937122208333333,
      "stddev": 0.014359309829851232,
      "median": 0.19360855500000002,
      "user": 0.24203436999999997,
      "system": 0.20739521333333333,
      "min": 0.175206166,
      "max": 0.218750753
    },
    {
      "command": "pacquet@main",
      "mean": 0.17371906313333332,
      "stddev": 0.012721063034468048,
      "median": 0.172659171,
      "user": 0.21972448666666666,
      "system": 0.17580274666666668,
      "min": 0.151080061,
      "max": 0.195467539
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.21429865424999997,
      "stddev": 0.013875158703737718,
      "median": 0.212070493,
      "user": 0.2528600366666666,
      "system": 0.21036563,
      "min": 0.199773761,
      "max": 0.241978803
    },
    {
      "command": "pnpr@main",
      "mean": 0.20489367633333333,
      "stddev": 0.014581188774512092,
      "median": 0.208669254,
      "user": 0.24438045333333328,
      "system": 0.19486204666666662,
      "min": 0.177617361,
      "max": 0.22724996
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review September 28, 2026 15:52
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Accept fresh lockfiles with injected dependencies and workspace peers

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

Grey Divider

AI Description

• Stop treating a consumer’s resolved peer as evidence that an injected dependency’s lockfile entry
 is stale.
• Preserve freshness checks for declared peer ranges and peer metadata.
• Cover workspace-linked and unmet peers with frozen-install tests, and document the patch release.
Diagram

graph TD
  A["Frozen install"] --> B["Directory manifest"] --> C["Dependency checks"] --> D["Peer declarations"] --> F{"Declarations match?"} -->|Yes| G["Install injected copy"]
  E["Package metadata"] --> F
  F -->|No| H["Reject stale lockfile"]
Loading
High-Level Assessment

Keep the PR’s declaration-based freshness check. Resolving and validating snapshot peers instead would conflate the consumer’s peer choice with changes to the injected package, and would still mishandle warned-about unmet peers.

Files changed (3) +94 / -28

Bug fix (1) +6 / -28
directory_deps.rsExclude resolved peers from injected-dependency freshness checks +6/-28

Exclude resolved peers from injected-dependency freshness checks

• Removes the comparison between declared peer ranges and resolved snapshot dependencies. Freshness still checks declared peer ranges and peerDependenciesMeta against lockfile package metadata.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs

Tests (1) +83 / -0
inject_workspace_packages.rsCover frozen installs with workspace-linked and unmet peers +83/-0

Cover frozen installs with workspace-linked and unmet peers

• Adds a workspace fixture and end-to-end tests that generate a lockfile, run a frozen install, and verify the injected copy is materialized. The cases cover a peer provided through a workspace link and an unmet peer.

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

Documentation (1) +5 / -0
frozen-injected-peer-link.mdDocument the frozen-install fix for pacquet +5/-0

Document the frozen-install fix for pacquet

• Adds a patch changeset explaining that freshly generated lockfiles are accepted when injected workspace packages have peer dependencies.

.changeset/frozen-injected-peer-link.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Frozen installs link outside workspaces ✗ Dismissed 🐞 Bug ⛨ Security
Description
check_local_peer_deps_freshness now compares peer declarations with package metadata but never
validates the peer reference in the injected package's snapshot. If a crafted lockfile keeps a
declared peer such as foo: ^1.0.0 but records foo: link:../../../outside in that snapshot,
frozen installation accepts the entry and creates a node_modules/foo symlink to the outside
directory.
Code

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[R212-213]

    check_recorded_peer_specs_match(dep, &manifest_peers, pkg_meta)?;
-    check_peer_dependencies_meta_freshness(dep, local_manifest, pkg_meta)?;
-
-    for (name, spec) in &manifest_peers {
-        let lockfile_dep = snapshot_deps.and_then(|deps| {
-            pnpm_lockfile::PkgName::parse(*name)
-                .ok()
-                .and_then(|n| deps.get(&n))
-        });
-        if let Some(lockfile_dep) = lockfile_dep
-            && !spec_satisfies_snapshot_dep(
-                dep.workspace_root,
-                dep.lockfile_dir,
-                dep.dir,
-                name,
-                spec,
-                lockfile_dep,
-            )
-        {
-            return Err(dep.outdated());
-        }
-    }
-
-    Ok(())
+    check_peer_dependencies_meta_freshness(dep, local_manifest, pkg_meta)
Evidence
The removed loop previously passed each resolved peer reference to spec_satisfies_snapshot_dep;
for an ordinary semver peer, its alias check rejects a Link reference. The replacement only checks
recorded peer declarations and metadata. Lockfile parsing accepts any link: suffix, and the
materializer joins that suffix to the lockfile directory without checking containment before
creating the symlink.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[187-213]
pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs[286-310]
pnpm/crates/lockfile/src/snapshot_dep_ref.rs[169-180]
pnpm/crates/deps-restorer/src/create_symlink_layout.rs[47-59]
pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs[238-251]

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

## Issue description
Removing snapshot peer-reference validation lets an attacker-controlled lockfile turn an injected package's ordinary peer into a link outside the workspace during frozen installation.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[187-213]
- pnpm/crates/deps-restorer/src/create_symlink_layout.rs[47-59]

## Recommended Fix
Validate resolved peer references without requiring their versions to satisfy the declared range: legitimate workspace-provided links and unmet peers must remain accepted, while a snapshot link that does not correspond to an allowed peer provider must be rejected before materialization. Add a frozen-install regression test with a crafted outside-workspace peer link.

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



Informational

2. Peer freshness lacks a focused unit test 📜 Skill insight ▣ Testability
Description
check_local_peer_deps_freshness changes a validator decision, but the new regression tests
exercise it only through two CLI installs and a mocked registry. The workspace-link and unmet-peer
cases have no direct validator assertion, so failures in that decision must be diagnosed through the
full install setup.
Code

pnpm/crates/cli/tests/suite/inject_workspace_packages.rs[R954-955]

+fn frozen_install_accepts_injected_dependency_whose_peer_is_a_workspace_link() {
+    assert_frozen_install_accepts_fresh_lockfile("workspace:*");
Relevance

●● Moderate

Coverage improvements are often accepted, but similar requests to replace integration tests with
direct unit tests have mixed outcomes.

PR-#16211
PR-#15453

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3365276 calls for direct unit coverage of a narrow validator decision. The changed validator no
longer checks resolved snapshot peers, while both added regression cases call an end-to-end helper
that runs CLI installs.

pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[197-213]
pnpm/crates/cli/tests/suite/inject_workspace_packages.rs[918-960]
Skill: review-code

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 peer-freshness decision is covered only by end-to-end CLI tests, although the production change is confined to validator logic.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps.rs[197-213]
- pnpm/crates/cli/tests/suite/inject_workspace_packages.rs[952-961]

## Recommended Fix
Add direct validator tests for workspace-link and unmet-peer snapshot references. Keep the CLI tests to cover the install flow.

ⓘ 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/update (sha: fcaa952e) — View relationship
  Explored: repo: pnpm/setup (sha: fbda4c85) — View relationship
Review mode: ⚖️ Balanced: This changes lockfile freshness behavior in package installation and adds regression coverage, so it has meaningful correctness and compatibility risk despite being localized.

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

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

zkochan commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

On Qodo's summary item "Peer freshness lacks a focused unit test": not adding one. The validator reads the injected package's manifest and resolves workspace links on disk. pnpm/CODE_STYLE_GUIDE.md makes a real fixture the default for such code, including an integration test that spawns the binary. The two new tests in inject_workspace_packages.rs are that route. Both fail without the fix with local dependency "lib" at "lib" is outdated.

The security finding is answered in its thread.


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

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 install --frozen-lockfile rejects a freshly generated lockfile when an injected workspace package has peer dependencies

2 participants