Skip to content

fix: reject frozen install when an injected package's dependencies drift with separate lockfiles - #17022

Closed
neonsid wants to merge 1 commit into
pnpm:mainfrom
neonsid:fix/17008-frozen-injected-separate-lockfiles
Closed

neonsid wants to merge 1 commit into
pnpm:mainfrom
neonsid:fix/17008-frozen-injected-separate-lockfiles

Conversation

@neonsid

@neonsid neonsid commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With sharedWorkspaceLockfile: false, pnpm install --frozen-lockfile accepted a lockfile whose snapshot of an injected workspace package no longer matched that package's dependencies. It exited 0 and installed the old resolutions. With a shared lockfile the injected package is also an importer and its own check catches the drift. With separate lockfiles nothing did, because the frozen check passes skipLocalDirectoryDependencies.

The frozen path now compares the dependencies of injected workspace: dependencies with their snapshot. Plain file: directory dependencies stay skipped, so deploy lockfiles (absolute file:// refs) are unaffected.

Turning the comparison on in frozen mode exposed false "outdated" verdicts on unchanged lockfiles. These cost only a re-resolve on the non-frozen path, but they would fail CI under --frozen-lockfile. localDirectoryDepIsUpToDate now:

  • applies the install's readPackage hook (overrides, package extensions, pnpmfile) before comparing,
  • resolves catalog: specs,
  • accepts resolved peers recorded among the snapshot's dependencies, compares peer ranges as ranges, and treats a dependency that is also a peer the way the resolver does.

This is a v11-only bug. pnpm 12.14.0 already rejects the case, and its freshness check (lockfile_freshness/directory_deps) is the model for the rules above. I ran the same 16 workspace scenarios against this build and 12.14.0 (catalogs, named catalogs, overrides, packageExtensions, peers, dependency+peer, optional peers, optional deps, devDeps, shared lockfile, autoInstallPeers: false). Both accept the unchanged lockfile and reject the changed one in every scenario.

One side effect: pnpmfile readPackage hooks now also run on injected workspace manifests during the up-to-date check.

Closes #17008

Squash Commit Body

With `sharedWorkspaceLockfile: false`, a frozen install of a project that
injects a workspace package never compared that package's own
dependencies with its snapshot in the project's lockfile. The frozen
check passed `skipLocalDirectoryDependencies`, and with separate
lockfiles the injected package is not an importer of the same lockfile,
so nothing else caught the drift. `--frozen-lockfile` exited 0 and
installed the old resolutions.

The nested comparison now runs for injected `workspace:` dependencies on
the frozen path too. Plain `file:` directory dependencies are still
skipped, which keeps deploy lockfiles (absolute `file://` refs) passing.

A frozen install fails on a stale verdict, so the comparison had to stop
reporting unchanged lockfiles as stale:

- It applies the install's readPackage hook (overrides, package
  extensions, pnpmfile hooks) to the manifest before comparing, since
  the snapshot records the hooked manifest.
- It resolves `catalog:` specs through the configured catalogs.
- It accepts the resolved peers the snapshot records among the
  dependencies, compares peer ranges as ranges, and treats a dependency
  also declared as a peer the way the resolver does: as a peer when the
  lockfile records it among the peers, as an own dependency otherwise.

These rules match the v12 freshness check, which already rejects this
case.

Closes pnpm/pnpm#17008

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.

🤖 Generated with Claude Code

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


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

Summary by CodeRabbit

  • Bug Fixes
    • pnpm install --frozen-lockfile now reports ERR_PNPM_OUTDATED_LOCKFILE when dependencies of an injected workspace package change while separate workspace lockfiles are enabled, instead of succeeding with an outdated resolution.
    • Lockfile checks now better account for package manifest transformations, catalog references, and peer dependencies when verifying linked workspace packages.

…ift with separate lockfiles

With `sharedWorkspaceLockfile: false`, a frozen install of a project that
injects a workspace package never compared that package's own
dependencies with its snapshot in the project's lockfile. The frozen
check passed `skipLocalDirectoryDependencies`, and with separate
lockfiles the injected package is not an importer of the same lockfile,
so nothing else caught the drift. `--frozen-lockfile` exited 0 and
installed the old resolutions.

The nested comparison now runs for injected `workspace:` dependencies on
the frozen path too. Plain `file:` directory dependencies are still
skipped, which keeps deploy lockfiles (absolute `file://` refs) passing.

A frozen install fails on a stale verdict, so the comparison had to stop
reporting unchanged lockfiles as stale:

- It applies the install's readPackage hook (overrides, package
  extensions, pnpmfile hooks) to the manifest before comparing, since
  the snapshot records the hooked manifest.
- It resolves `catalog:` specs through the configured catalogs.
- It accepts the resolved peers the snapshot records among the
  dependencies, compares peer ranges as ranges, and treats a dependency
  also declared as a peer the way the resolver does: as a peer when the
  lockfile records it among the peers, as an own dependency otherwise.

These rules match the v12 freshness check, which already rejects this
case.

Closes pnpm#17008

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

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3673c079-55a8-46bc-af4f-8c687a41fc3a
📥 Commits

Reviewing files that changed from the base of the PR and between 086165d and 5d7dae0.

⛔ Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing: 10
  • .changeset/frozen-lockfile-injected-separate-lockfiles.md
  • pnpm11/installing/deps-installer/src/install/lockfileState.ts
  • pnpm11/installing/deps-installer/src/install/verifyFrozenLockfile.ts
  • pnpm11/lockfile/verification/package.json
  • pnpm11/lockfile/verification/src/allProjectsAreUpToDate.ts
  • pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts
  • pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts
  • pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts
  • pnpm11/lockfile/verification/tsconfig.json
  • pnpm11/pnpm/test/monorepo/index.ts

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

📝 Walkthrough

Frozen-lockfile validation now checks injected workspace package manifests against consumer lockfile snapshots when workspace lockfiles are separate. The comparison applies the package read hook and resolves catalog and peer dependency entries. Tests cover dependency changes, peer ranges, and skipped file: directory comparisons.

Changes: Injected package frozen validation

Layer / File(s) Summary
Frozen-check context propagation
pnpm11/installing/deps-installer/src/install/lockfileState.ts, pnpm11/installing/deps-installer/src/install/verifyFrozenLockfile.ts, pnpm11/lockfile/verification/src/allProjectsAreUpToDate.ts, pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts, pnpm11/lockfile/verification/package.json, pnpm11/lockfile/verification/tsconfig.json
The installer passes readPackageHook into up-to-date checks. The verification context now includes the hook and catalog data.
Injected package snapshot comparison
pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts, pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts
Workspace-range dependencies are compared with their lockfile snapshots even when local-directory checks are skipped. The comparison checks dependency and peer entries and resolves catalog specs.
Regression tests and release entry
pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts, pnpm11/pnpm/test/monorepo/index.ts, .changeset/frozen-lockfile-injected-separate-lockfiles.md
Tests cover matching and stale injected-package dependencies, peer ranges, skipped file: directory comparisons, and frozen-install rejection. The changeset records patch releases.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
Reject a frozen install when an injected workspace package dependency changes with separate workspace lockfiles [#17008] ✅
Return ERR_PNPM_OUTDATED_LOCKFILE instead of accepting the stale consumer lockfile [#17008] ✅

Suggested labels: product: pnpm@11

Merge Risk: ⚪ Minimal · up to 5d7da

No unresolved issue identified that should block merging after normal checks.

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

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

❤️ Share

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

@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 2328.19 ms 2495.36 ms 7.2% 116.41 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store pnpr 1395.75 ms 1339.88 ms -4.0% 69.79 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 224.07 ms 226.55 ms 1.1% 11.20 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 238.64 ms 289.39 ms 21.3% 11.93 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 7.58 ms 7.70 ms 1.6% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 15.22 ms 8.03 ms -47.2% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 8.66 ms 8.80 ms 1.6% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 8.73 ms 8.72 ms -0.1% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2466.99 ms 2468.06 ms 0.0% 123.35 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1478.79 ms 1436.95 ms -2.8% 73.94 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 439.52 ms 437.13 ms -0.5% 21.98 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 287.07 ms 275.84 ms -3.9% 14.35 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1710.75 ms 1715.52 ms 0.3% 85.54 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 366.12 ms 367.16 ms 0.3% 18.31 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 275.96 ms 281.56 ms 2.0% 13.80 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 99.27 ms 100.12 ms 0.9% 4.96 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 212.18 ms 219.94 ms 3.7% 10.61 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 199.17 ms 197.03 ms -1.1% 9.96 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 73.75 ms 78.59 ms 6.6% 3.69 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4378.25 ms 4400.65 ms 0.5% 218.91 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3509.61 ms 3457.67 ms -1.5% 175.48 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 119.25 ms 119.32 ms 0.1% 5.96 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 132.38 ms 128.71 ms -2.8% 6.62 ms Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1117.83 ms 1120.64 ms 0.3% 55.89 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 5d7dae006eb0

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked and injected workspace scenarios compare 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.445 ± 0.127 2.253 2.579 1.73 ± 0.20
pacquet@main 2.400 ± 0.158 2.247 2.616 1.70 ± 0.20
pnpr@HEAD 1.415 ± 0.143 1.296 1.659 1.00
pnpr@main 1.421 ± 0.095 1.297 1.570 1.00 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.44545746318,
      "stddev": 0.12720908452352472,
      "median": 2.49535919408,
      "user": 1.4534717799999999,
      "system": 1.3732607799999998,
      "min": 2.25331847858,
      "max": 2.57915875958
    },
    {
      "command": "pacquet@main",
      "mean": 2.40039727528,
      "stddev": 0.15754449406356255,
      "median": 2.32819293858,
      "user": 1.34709818,
      "system": 1.3102115800000003,
      "min": 2.24668958258,
      "max": 2.61580835058
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4147089154799999,
      "stddev": 0.1425367508637405,
      "median": 1.33988223058,
      "user": 1.2371434799999999,
      "system": 1.1402876800000001,
      "min": 1.2962249885800001,
      "max": 1.65854135458
    },
    {
      "command": "pnpr@main",
      "mean": 1.4212694495800002,
      "stddev": 0.09489441714330288,
      "median": 1.39575178208,
      "user": 1.2587190799999999,
      "system": 1.1520195800000002,
      "min": 1.29713351858,
      "max": 1.5696519745800002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 229.1 ± 8.0 217.0 239.7 1.00
pacquet@main 233.0 ± 30.0 205.7 310.9 1.02 ± 0.14
pnpr@HEAD 311.6 ± 84.4 225.5 423.9 1.36 ± 0.37
pnpr@main 239.7 ± 12.1 223.9 265.3 1.05 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2290561667,
      "stddev": 0.007990425279309786,
      "median": 0.2265537787,
      "user": 0.24545692,
      "system": 0.5730318999999999,
      "min": 0.21698891420000002,
      "max": 0.2396669042
    },
    {
      "command": "pacquet@main",
      "mean": 0.23304011070000002,
      "stddev": 0.029954947026694562,
      "median": 0.2240656197,
      "user": 0.27087392,
      "system": 0.5659597,
      "min": 0.2057007992,
      "max": 0.31090672620000004
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3116344832,
      "stddev": 0.08442127007241855,
      "median": 0.28939383020000004,
      "user": 0.36034521999999997,
      "system": 0.7170202000000001,
      "min": 0.2255081132,
      "max": 0.4239213352
    },
    {
      "command": "pnpr@main",
      "mean": 0.23971466350000004,
      "stddev": 0.012132941947687695,
      "median": 0.23864317570000002,
      "user": 0.27031602,
      "system": 0.553635,
      "min": 0.22394537720000002,
      "max": 0.26529941120000006
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 7.8 ± 0.5 7.0 11.2 1.02 ± 0.08
pacquet@main 7.6 ± 0.4 6.9 9.9 1.00
pnpr@HEAD 8.6 ± 1.7 7.0 17.7 1.12 ± 0.23
pnpr@main 15.0 ± 2.0 9.5 19.6 1.97 ± 0.28
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.007760439470310553,
      "stddev": 0.00045868818905374023,
      "median": 0.00769872302,
      "user": 0.004547783105590064,
      "system": 0.003899727577639751,
      "min": 0.00695773452,
      "max": 0.011248235520000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.007611456177575758,
      "stddev": 0.0003815944053869278,
      "median": 0.00757792552,
      "user": 0.0044148890909090875,
      "system": 0.0038214661818181785,
      "min": 0.00687164152,
      "max": 0.00994466352
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008550716116385538,
      "stddev": 0.0016852532300126078,
      "median": 0.008034354520000002,
      "user": 0.005415075180722892,
      "system": 0.003986177228915663,
      "min": 0.00696793252,
      "max": 0.017715311520000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.014975754681676645,
      "stddev": 0.0020111965807160267,
      "median": 0.015217642520000001,
      "user": 0.008222444670658684,
      "system": 0.00800884766467066,
      "min": 0.00954925952,
      "max": 0.01963422152
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 8.8 ± 0.5 7.8 10.7 1.01 ± 0.08
pacquet@main 8.7 ± 0.5 7.8 10.6 1.00
pnpr@HEAD 8.8 ± 0.5 7.5 11.4 1.00 ± 0.08
pnpr@main 8.8 ± 0.5 7.9 11.1 1.00 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.008843041749285713,
      "stddev": 0.0004926250400323346,
      "median": 0.008797390660000001,
      "user": 0.005606981428571429,
      "system": 0.0040889005714285715,
      "min": 0.00779528216,
      "max": 0.010666986160000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.008736512487272722,
      "stddev": 0.0004835472966610544,
      "median": 0.008660668160000001,
      "user": 0.005269400000000005,
      "system": 0.004269635054545456,
      "min": 0.00778471216,
      "max": 0.01057982216
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008761901932727278,
      "stddev": 0.0005453910142672586,
      "median": 0.008721807160000001,
      "user": 0.005617244848484849,
      "system": 0.00397798106060606,
      "min": 0.00745651516,
      "max": 0.01143949816
    },
    {
      "command": "pnpr@main",
      "mean": 0.00877718013222223,
      "stddev": 0.0004728598579807814,
      "median": 0.00872847516,
      "user": 0.005329271904761906,
      "system": 0.004212912539682542,
      "min": 0.007942338160000001,
      "max": 0.01105655816
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.494 ± 0.077 2.438 2.698 1.68 ± 0.13
pacquet@main 2.467 ± 0.014 2.439 2.487 1.66 ± 0.11
pnpr@HEAD 1.485 ± 0.102 1.384 1.682 1.00
pnpr@main 1.503 ± 0.114 1.387 1.702 1.01 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4944210887800002,
      "stddev": 0.07650916881371882,
      "median": 2.46806420918,
      "user": 1.79975472,
      "system": 1.5900822799999998,
      "min": 2.43764813718,
      "max": 2.69787154618
    },
    {
      "command": "pacquet@main",
      "mean": 2.46672283908,
      "stddev": 0.014384124142033421,
      "median": 2.46698735818,
      "user": 1.7013037199999999,
      "system": 1.4477577799999999,
      "min": 2.43859850918,
      "max": 2.48688705218
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4851214671800002,
      "stddev": 0.10187529944397235,
      "median": 1.4369523446799999,
      "user": 1.12350322,
      "system": 1.21895058,
      "min": 1.3843098481799998,
      "max": 1.68178195018
    },
    {
      "command": "pnpr@main",
      "mean": 1.5026245011800001,
      "stddev": 0.11353117658073687,
      "median": 1.47878881268,
      "user": 1.0919514199999998,
      "system": 1.1926174800000002,
      "min": 1.38724008018,
      "max": 1.70211295718
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 441.3 ± 21.3 406.9 476.6 1.58 ± 0.12
pacquet@main 439.6 ± 12.5 422.1 463.0 1.57 ± 0.10
pnpr@HEAD 280.1 ± 15.7 265.8 319.5 1.00
pnpr@main 288.5 ± 5.8 281.4 297.7 1.03 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.44126407294000003,
      "stddev": 0.02126316986876709,
      "median": 0.43713193594000005,
      "user": 0.60109072,
      "system": 0.77575018,
      "min": 0.40692918144,
      "max": 0.47659292944000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.43960971043999997,
      "stddev": 0.012489989969306033,
      "median": 0.43952141994000005,
      "user": 0.6194141199999998,
      "system": 0.77382778,
      "min": 0.42212628644000005,
      "max": 0.46300160344
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28007966654000005,
      "stddev": 0.015664482645410465,
      "median": 0.27583830844,
      "user": 0.23546472000000002,
      "system": 0.52184838,
      "min": 0.26575461444000004,
      "max": 0.31945368444
    },
    {
      "command": "pnpr@main",
      "mean": 0.28847715374000005,
      "stddev": 0.005782844336580527,
      "median": 0.28707161994,
      "user": 0.23525512,
      "system": 0.58251758,
      "min": 0.28136350744,
      "max": 0.29768627344000004
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.715 ± 0.009 1.703 1.734 4.72 ± 0.10
pacquet@main 1.777 ± 0.149 1.689 2.145 4.89 ± 0.42
pnpr@HEAD 0.367 ± 0.006 0.358 0.380 1.01 ± 0.03
pnpr@main 0.363 ± 0.007 0.349 0.371 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7151327286399998,
      "stddev": 0.008828531746585036,
      "median": 1.7155220174399999,
      "user": 1.10879328,
      "system": 1.2310626,
      "min": 1.70323158344,
      "max": 1.7337791134399998
    },
    {
      "command": "pacquet@main",
      "mean": 1.7769944525399997,
      "stddev": 0.14940419212885975,
      "median": 1.71075212594,
      "user": 1.2410044800000002,
      "system": 1.3582524999999999,
      "min": 1.6887078844399999,
      "max": 2.14460939644
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3667957566400001,
      "stddev": 0.006083573069932814,
      "median": 0.36715861644000003,
      "user": 0.33854267999999993,
      "system": 0.7794867000000001,
      "min": 0.35811411044,
      "max": 0.37966593144000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.36340297713999997,
      "stddev": 0.007497067632356662,
      "median": 0.36611529394000003,
      "user": 0.32319028000000005,
      "system": 0.8004614,
      "min": 0.34903955744000004,
      "max": 0.37100723744
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 280.2 ± 17.3 256.2 309.5 2.83 ± 0.19
pacquet@main 279.1 ± 16.5 250.5 304.9 2.82 ± 0.18
pnpr@HEAD 99.8 ± 2.5 94.7 104.5 1.01 ± 0.03
pnpr@main 99.0 ± 2.3 95.0 102.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.28023973636000005,
      "stddev": 0.01726416093069734,
      "median": 0.28155685286,
      "user": 0.25703087999999996,
      "system": 0.1239136,
      "min": 0.25622431886,
      "max": 0.30951218086000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.27905913496,
      "stddev": 0.01653416004609968,
      "median": 0.27596392236,
      "user": 0.26213748,
      "system": 0.11773309999999997,
      "min": 0.25047465686000003,
      "max": 0.30485270286000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09980590882296297,
      "stddev": 0.002544518490715974,
      "median": 0.10011831686,
      "user": 0.044544005925925924,
      "system": 0.01856774814814815,
      "min": 0.09467971686,
      "max": 0.10452088586
    },
    {
      "command": "pnpr@main",
      "mean": 0.09901220125285712,
      "stddev": 0.002271405395941584,
      "median": 0.09927112536,
      "user": 0.045117687142857146,
      "system": 0.01645145714285714,
      "min": 0.09502984786,
      "max": 0.10291250286
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 243.2 ± 44.8 205.4 323.3 1.14 ± 0.21
pacquet@main 213.1 ± 5.2 207.1 223.4 1.00
pnpm@HEAD 3458.8 ± 111.1 3368.4 3690.5 16.23 ± 0.65
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24324989862222215,
      "stddev": 0.044755904582628236,
      "median": 0.2199393714,
      "user": 0.23846208444444444,
      "system": 0.06126202222222221,
      "min": 0.2054178704,
      "max": 0.3232889304
    },
    {
      "command": "pacquet@main",
      "mean": 0.21314774706666667,
      "stddev": 0.005161066998013231,
      "median": 0.2121847654,
      "user": 0.2172794177777778,
      "system": 0.05185779999999999,
      "min": 0.2071038254,
      "max": 0.2233837794
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.4588399236222225,
      "stddev": 0.11108017387702626,
      "median": 3.4120405074,
      "user": 4.950703528888888,
      "system": 0.42564791111111105,
      "min": 3.3683712214,
      "max": 3.6904858724
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 196.1 ± 4.9 189.2 209.3 1.00
pacquet@main 199.4 ± 5.2 191.3 208.3 1.02 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.19613815896000003,
      "stddev": 0.004857908098476561,
      "median": 0.19702777816000003,
      "user": 0.14969875333333335,
      "system": 0.08255418666666667,
      "min": 0.18915703916,
      "max": 0.20925883616000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.19944468030285714,
      "stddev": 0.005212571871559815,
      "median": 0.19917125866000002,
      "user": 0.1615854771428571,
      "system": 0.07597237714285714,
      "min": 0.19133487416000003,
      "max": 0.20827473616000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 79.4 ± 3.5 73.3 91.9 1.06 ± 0.06
pacquet@main 74.6 ± 2.7 70.7 81.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.07935263369621626,
      "stddev": 0.0035114114214724193,
      "median": 0.07858564748,
      "user": 0.03036470054054054,
      "system": 0.05444620648648649,
      "min": 0.07333242948,
      "max": 0.09190061248
    },
    {
      "command": "pacquet@main",
      "mean": 0.07459361745435898,
      "stddev": 0.0027360849052248523,
      "median": 0.07374804048000001,
      "user": 0.02648913435897435,
      "system": 0.05335815589743588,
      "min": 0.07066116648000001,
      "max": 0.08169947148000001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.486 ± 0.147 4.357 4.756 1.29 ± 0.06
pacquet@main 4.411 ± 0.085 4.322 4.573 1.27 ± 0.05
pnpr@HEAD 3.483 ± 0.110 3.403 3.773 1.00
pnpr@main 3.555 ± 0.126 3.399 3.749 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.4862935262,
      "stddev": 0.1468357845086953,
      "median": 4.400650902100001,
      "user": 1.3860151399999998,
      "system": 1.4915818599999997,
      "min": 4.3569669166,
      "max": 4.7555697256
    },
    {
      "command": "pacquet@main",
      "mean": 4.4110205132,
      "stddev": 0.08506023981330732,
      "median": 4.3782487856,
      "user": 1.41189484,
      "system": 1.4192768599999999,
      "min": 4.3223663636,
      "max": 4.5729821176
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.4832535471,
      "stddev": 0.11027296211862787,
      "median": 3.4576667410999997,
      "user": 1.3098903399999997,
      "system": 1.3415785599999999,
      "min": 3.4030139926,
      "max": 3.7734724566
    },
    {
      "command": "pnpr@main",
      "mean": 3.5547921064000008,
      "stddev": 0.1255605063426064,
      "median": 3.5096097861,
      "user": 1.35790364,
      "system": 1.31231076,
      "min": 3.3990059966,
      "max": 3.7488557096
    }
  ]
}

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 119.3 ± 3.2 114.2 126.1 1.00 ± 0.04
pacquet@main 118.8 ± 2.7 112.8 123.2 1.00
pnpr@HEAD 128.8 ± 3.1 123.8 135.7 1.08 ± 0.04
pnpr@main 131.8 ± 3.5 125.9 137.5 1.11 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.11934286354545458,
      "stddev": 0.0031555904836230325,
      "median": 0.11931897350000001,
      "user": 0.1436989090909091,
      "system": 0.1266067527272727,
      "min": 0.11417511600000001,
      "max": 0.12610164299999999
    },
    {
      "command": "pacquet@main",
      "mean": 0.11882618176190476,
      "stddev": 0.0027488100035890617,
      "median": 0.11924944200000001,
      "user": 0.15002019047619047,
      "system": 0.11633486095238095,
      "min": 0.11275431300000001,
      "max": 0.12320300000000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.12878752685,
      "stddev": 0.003114957786958701,
      "median": 0.1287085475,
      "user": 0.14551184999999997,
      "system": 0.13548313,
      "min": 0.12375261400000001,
      "max": 0.135700401
    },
    {
      "command": "pnpr@main",
      "mean": 0.13184447789473683,
      "stddev": 0.0035132915693928853,
      "median": 0.132379515,
      "user": 0.157591947368421,
      "system": 0.13021174315789472,
      "min": 0.125884084,
      "max": 0.137499978
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.117 ± 0.027 1.061 1.158 1.00
pacquet@main 1.118 ± 0.021 1.083 1.146 1.00 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.1167739732999997,
      "stddev": 0.02684100084234003,
      "median": 1.1206425624,
      "user": 0.4883243799999999,
      "system": 0.21075964000000003,
      "min": 1.0607493204,
      "max": 1.1581078734
    },
    {
      "command": "pacquet@main",
      "mean": 1.1180693822999999,
      "stddev": 0.021392302329141744,
      "median": 1.1178268184,
      "user": 0.50330138,
      "system": 0.18510654,
      "min": 1.0826317864,
      "max": 1.1459452274
    }
  ]
}

@neonsid
neonsid marked this pull request as ready for review October 17, 2026 08:44
@neonsid
neonsid requested a review from zkochan as a code owner October 17, 2026 08:44
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 17, 2026

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this. The approach is the one we want for #17008 for now: pnpm/tasks#145 leaves the "record the declared specs in the lockfile" redesign for later.

The comparison now runs on the frozen path, and in its current form it rejects lockfiles that pnpm 11.28.6 just wrote. pnpm 12.13.0 accepts each of these lockfiles under --frozen-lockfile, but this branch fails with ERR_PNPM_OUTDATED_LOCKFILE. CI users would hit that directly. It is not limited to sharedWorkspaceLockfile: false: a shared lockfile reaches the same code whenever an injected package stays file: instead of being deduped to link:, which is the usual case for an injected package with peers.

I checked these by running the PR's verification sources against real 11.28.6 lockfiles. I did not run the bundle.

  1. Non-range specs always look outdated (localDirectoryDepIsUpToDate.ts, the semver.satisfies branch, now reached through linkedPackagesAreUpToDate.ts). Take an injected package that declares "is-positive": "latest". pnpm 11 records 3.1.0, and satisfies('3.1.0', 'latest') is false. Git, tarball, jsr: and npm:b@latest specs fail the same way. v12 accepts any spec that is not a valid range and checks only the alias name for name@version refs (npm_or_registry_spec_satisfies in pnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs).
  2. Optional peers declared only in peerDependenciesMeta always look outdated. The v11 resolver records them as peerDependencies: {name: '*'} (markOptionalPeers). getPeersResolvedAsPeers reads only manifest.peerDependencies, so the peer sets differ. When one of these peers resolves, it lands in the snapshot's optionalDependencies and fails the key check too. v12 adds these names as '*' (optional_peer_names in directory_deps/peers.rs).
  3. A dependency that is also an optional peer always looks outdated. With dependencies: {is-number: ^6}, peerDependencies: {is-number: *} and peerDependenciesMeta: {is-number: {optional: true}}, the resolver treats is-number as an own dependency and writes no peer meta. peerDependenciesMetaMatch still compares the manifest meta. Compare it only for names in the resolved-as-peer set, as v12 does.
  4. An optional dependency that never resolved fails every frozen install. With optionalDependencies: {is-positive: ^99.0.0}, pnpm 11 writes foo@file:foo: {}, and the check requires every manifest optional dependency to be in the snapshot. Importers already allow this on frozen installs (allowUnresolvedOptionalDependencies: frozenLockfile in verifyFrozenLockfile.ts), and so does v12.
  5. The readPackage hook gets a directory the resolver does not pass. ctx.readPackageHook(clone(manifest), localDepDir) selects the project hook set in createReadPackageHook, which leaves out the @yarnpkg/extensions compatibility extensions. The resolver calls ctx.readPackageHook(pkg) (resolveDependency.ts). Dropping the second argument keeps the two in step.
  6. Smaller: workspace:../foo is still skipped. The new comparison is gated on isWorkspaceRangeSpec, so an injected workspace:<path> spec stays under skipLocalDirectoryDependencies and keeps the bug. The comment saying injected workspace packages are always compared overstates this. Gate on whether the dependency is injected, or correct the comment.

Unit fixtures copied from real 11.28.6 lockfile output, one per shape above, would pin these. The current unit tests cover only shapes that already passed before this change.


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

@zkochan

zkochan commented Oct 17, 2026

Copy link
Copy Markdown
Member

One more case for the frozen path. An injected workspace package that publishes from publishConfig.directory is recorded as file:<project>/<publishDir>, and the resolver describes it with the project's own manifest. localDirectoryDepIsUpToDate looks up manifestsByDir[localDepDir] by project root. It misses the publish directory and reads <publishDir>/package.json from disk. When a build writes a package.json there with other dependencies, the check reports the lockfile outdated. With this PR that would fail --frozen-lockfile.

pnpm v12 has this bug today. #17042 fixes it there by keying each project's manifest by its publish directory too. The same keying in v11's manifestsByDir would keep the two in step.


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

@zkochan

zkochan commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Thanks for this, @neonsid. Your analysis of where the frozen check skips injected packages, and of the false "outdated" verdicts that come up once it stops skipping, shaped #17065.

#17065 fixes the same issue a different way. localDirectoryDepIsUpToDate takes its rules from the resolver itself:

  • getNonDevWantedDependencies and prepareDependencyManifest decide the children.
  • peerDependenciesWithoutOwn gives the recorded peers.
  • lockedVersionSatisfies judges a locked version, the same way the resolver judges a locked reference.

This is what v12 now does after #17053 and #17062. Because the rules match, the frozen install runs the check for every local directory dependency, including plain file: ones. The one exception is the install pnpm deploy runs: its lockfile records bound peers as plain dependencies, so it still skips the check.

Since the two PRs fix the same issue, would you be OK with closing this one in favor of #17065? If you see a case your PR covers that 17065 misses, please point it out and I'll add it.


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

@zkochan zkochan closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11.x: --frozen-lockfile accepts stale injected workspace dependencies with separate lockfiles

2 participants