Skip to content

fix: keep the pre-run gate from re-resolving after a frozen install - #16588

Closed
zkochan wants to merge 1 commit into
mainfrom
fix-16583
Closed

zkochan wants to merge 1 commit into
mainfrom
fix-16583

Conversation

@zkochan

@zkochan zkochan commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #16591 for #16583. #16591 fixes the issue when lockfile.includeResolutionSettings is on. This PR fixes it with that setting off, which is the default.

Rebased onto #16591. The workspace-state writers keep its recorded_auto_dedupe and also record frozenLockfile.

With autoDedupe: true, a pnpm install --frozen-lockfile that changes packages records no dedupe baseline in node_modules/.pnpm-workspace-state-v1.json, because only a resolving install can record one. Outside CI, the verifyDepsBeforeRun gate read the missing baseline as settings drift and spawned a regular pnpm install before the script. That install reran every lifecycle script and could re-resolve and rewrite the lockfile the frozen install had just accepted. A deploy server running git pull && pnpm install --frozen-lockfile && pnpm run build hits this on every deploy that changes a dependency.

#16396 made the gate skip the autoDedupe key when the install it would spawn runs frozen, which it decided from the pnpm run invocation alone (CI or a configured frozenLockfile). This PR follows the issue's proposal:

  • The workspace state records "frozenLockfile": true when the install that wrote it ran frozen. The materializing install and the up-to-date refresh set it from the install's lockfile policy. The refresh-only paths (repeat-install settle, run-gate content check) carry it forward, like they already carry autoDedupe.
  • The gate (lockfile_stays_frozen, formerly install_would_run_frozen) also skips the autoDedupe key when the recorded install was frozen. A frozenLockfile configured for the run still decides on its own, so --config.frozenLockfile=false still gets the deduplication install.

Any other drift (an edited manifest, a changed setting) still spawns the gate's usual install. Only the dedupe baseline stops counting as drift after a frozen install.

The bug is v12-only: autoDedupe does not exist in pnpm v11. v11 ignores the new top-level key when it reads the state file.

Squash Commit Body

A `pnpm install --frozen-lockfile` that changes packages records no
`autoDedupe` baseline, since only a resolving install can record one.
Outside CI the `verifyDepsBeforeRun` gate read the missing baseline as
settings drift and spawned a regular install. That install reran every
lifecycle script and could re-resolve and rewrite the lockfile the frozen
install had just accepted.

The workspace state now records `frozenLockfile` when the install that
wrote it ran frozen. The materializing and up-to-date install paths set it
from the install's lockfile policy, and the refresh-only paths (repeat
install settle, run gate content check) carry it forward. The gate skips
the `autoDedupe` key when the recorded install was frozen, unless
`frozenLockfile` is configured for the run.

Follow-up to pnpm/pnpm#16591 for pnpm/pnpm#16583.

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.

Tests: a new CLI e2e test (auto_dedupe::a_materializing_frozen_install_does_not_make_the_gate_spawn_an_install) reproduces the issue's flow and asserts that pnpm run spawns no install and leaves the lockfile untouched. The gate unit test now covers the recorded frozen install and a configured frozenLockfile: false. Both fail with the gate change reverted.


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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • After pnpm install --frozen-lockfile, pnpm run and pnpm exec no longer trigger an additional install solely because autoDedupe is enabled.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The install now records whether it used a frozen lockfile. The repeat-install gate uses this state when checking for auto-dedupe drift. A CLI regression test covers a frozen install followed by a non-CI run.

Changes: Frozen install gate

Layer / File(s) Summary
Record frozen-lockfile state
pnpm/crates/package-manager/src/install/state_options.rs, pnpm/crates/workspace-state/src/lib.rs, pnpm/crates/package-manager/src/install/workspace_state/*, pnpm/crates/package-manager/src/install/{apply_materialization.rs,prepare_modules_state.rs,run/*}, pnpm/crates/package-manager/src/install/tests/*, pnpm/crates/package-manager/src/optimistic_repeat_install/tests.rs, pnpm/crates/workspace-state/src/tests.rs
Install and workspace state carry the frozen-lockfile setting through install execution, workspace refreshes, and state writes. Fixtures set the new field explicitly.
Use recorded state in the repeat-install gate
pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs, pnpm/crates/package-manager/src/optimistic_repeat_install/freshness.rs, pnpm/crates/package-manager/src/optimistic_repeat_install/tests/auto_dedupe.rs
The auto-dedupe drift check accounts for frozen-lockfile configuration, recorded frozen-install state, and wanted-lockfile presence. Tests cover the combinations and expected drift.
Verify frozen install behavior through the CLI
pnpm/crates/cli/tests/suite/auto_dedupe.rs, .changeset/frozen-install-skips-dedupe-gate.md
The CLI regression test checks that a frozen install records no dedupe baseline and that the next non-CI gate run executes the script without another install or lockfile change. A patch changeset describes the behavior.

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

Change: Bug fix

Suggested labels: product: pacquet

Suggested reviewers: kairosci, cnzary

Merge Risk: Minimal · up to 34939

The change stops a frozen install from causing the next non-CI run to spawn an unwanted regular install. No concrete merge-blocking risk was found.

Security architecture risk: Low · up to 46b35

The change preserves explicit lockfile configuration and other dependency-drift checks while avoiding an unnecessary resolving install. Remaining uncertainty concerns concurrent operations and failure to save install history.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The affected decision is scoped to local projects using the selected install-state and lockfile root. Shared workspaces can share that decision across projects; dedicated per-project lockfiles and a configured lockfileDir alter the root. The relevant outcome is whether the existing CLI gate proceeds or starts another install under the invoking user's authority.

Trust Boundaries and Controls

  • observed — The gate reads historical policy from the existing local workspace-state JSON. A writer able to replace that file can influence the new exemption, but the PR does not grant file-write authority. Explicit frozenLockfile=false overrides recorded history, a missing or empty wanted lockfile disqualifies the exemption, and lockfile-conflict, other setting, configuration-dependency and catalog checks remain active.

Resilience and Maintainability Implications

  • inferred — The initial run-gate check occurs before its install lock is acquired, and a passing content check can refresh state from an earlier snapshot. Atomic file replacement therefore does not by itself prove preservation of the newest completed install policy. The locking and warning-only persistence mechanisms predate this PR; their end-to-end effect on the new historical field remains unvalidated rather than a demonstrated new security finding.

Hardening Proposals

  • proposed — If frozen-install history is intended to provide a durable guarantee across concurrent commands or interrupted writes, consider shared read-validate-write serialization or generation-checked publication, together with explicit history-loss recovery. This is a hardening proposal, not an observed vulnerability.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2b150af and 34939d3.

Files selected for processing: 16

  • pnpm/crates/package-manager/src/install/apply_materialization.rs
  • pnpm/crates/package-manager/src/install/prepare_modules_state.rs
  • pnpm/crates/package-manager/src/install/prepare_modules_state/tests.rs
  • pnpm/crates/package-manager/src/install/prepare_modules_state/up_to_date.rs
  • pnpm/crates/package-manager/src/install/run/dispatch.rs
  • pnpm/crates/package-manager/src/install/run/execution.rs
  • pnpm/crates/package-manager/src/install/state_options.rs
  • pnpm/crates/package-manager/src/install/tests/frozen_policy.rs
  • pnpm/crates/package-manager/src/install/tests/lockfile_recovery.rs
  • pnpm/crates/package-manager/src/install/tests/repeat_install.rs
  • pnpm/crates/package-manager/src/install/workspace_state.rs
  • pnpm/crates/package-manager/src/install/workspace_state/write.rs
  • pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs
  • pnpm/crates/package-manager/src/optimistic_repeat_install/freshness.rs
  • pnpm/crates/package-manager/src/optimistic_repeat_install/tests.rs
  • pnpm/crates/workspace-state/src/tests.rs

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

@codecov-commenter

codecov-commenter commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.22%. Comparing base (d40d642) to head (34939d3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16588      +/-   ##
==========================================
- Coverage   92.22%   92.22%   -0.01%     
==========================================
  Files        2465     2465              
  Lines      313085   313096      +11     
==========================================
+ Hits       288753   288761       +8     
- Misses      24332    24335       +3     

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

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

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                    pr
-----                                            ----                                    --
lockfile/parse_pnpm_lock                         1.00      4.4±0.38ms    86.0 MB/sec     1.09      4.8±0.30ms    78.7 MB/sec
packument/parse                                  1.00     45.6±2.76µs  1456.1 MB/sec     1.03     46.7±3.94µs  1419.5 MB/sec
tarball/download_dependency                      1.34  1284.1±316.90µs     3.3 MB/sec    1.00  959.8±280.17µs     4.4 MB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    241.8±8.70ms 66.2 KElem/sec     1.01   244.9±17.25ms 65.3 KElem/sec
version_pick/repeated_ranges_file                1.00      5.4±0.29ms  5.7 KElem/sec     1.00      5.4±0.14ms  5.7 KElem/sec
version_pick/repeated_ranges_raw                 1.02      5.4±0.29ms  5.8 KElem/sec     1.00      5.3±0.13ms  5.9 KElem/sec
version_pick/wildcard_lowest                     1.00     46.0±1.56µs 21.2 KElem/sec     1.02     47.0±1.03µs 20.8 KElem/sec
workspace_resolution/hoist_heavy                 1.00    284.6±6.11ms        ? ?/sec     1.10    311.8±9.46ms        ? ?/sec
workspace_sort/chained_projects                  1.00     16.3±1.76ms        ? ?/sec     1.19     19.3±3.10ms        ? ?/sec

@github-actions

github-actions Bot commented Oct 4, 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 2318.55 ms 2424.83 ms 4.6% 115.93 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1526.54 ms 1551.91 ms 1.7% 76.33 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 228.33 ms 211.51 ms -7.4% 11.42 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 255.20 ms 252.83 ms -0.9% 12.76 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 11.31 ms 12.25 ms 8.3% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 11.39 ms 10.31 ms -9.5% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 11.34 ms 13.18 ms 16.2% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 11.50 ms 11.66 ms 1.4% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2460.75 ms 2439.34 ms -0.9% 123.04 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1524.16 ms 1548.40 ms 1.6% 76.21 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 516.26 ms 527.46 ms 2.2% 25.81 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 317.03 ms 313.44 ms -1.1% 15.85 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1736.67 ms 1721.74 ms -0.9% 86.83 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 296.07 ms 323.04 ms 9.1% 14.80 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pacquet 286.67 ms 293.00 ms 2.2% 14.33 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 100.56 ms 99.23 ms -1.3% 5.03 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 262.01 ms 257.16 ms -1.9% 13.10 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 88.76 ms 102.02 ms 14.9% 4.44 ms Inconclusive (overlapping samples)
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 136.40 ms 155.85 ms 14.3% 6.82 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4517.18 ms 4488.35 ms -0.6% 225.86 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3503.48 ms 3490.63 ms -0.4% 175.17 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 206.66 ms 198.67 ms -3.9% 10.33 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 229.52 ms 243.54 ms 6.1% 11.48 ms Inconclusive (overlapping samples)
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1168.94 ms 1180.20 ms 1.0% 58.45 ms Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet 36.94 ms 39.57 ms 7.1% 2.00 ms Inconclusive (overlapping samples)

Same-run syscall check

Each install runs 2 more times per revision, untimed, under strace --follow-forks --summary-only. A file syscall regresses when HEAD's fewest calls exceed main's most by more than 2% of main or 50 calls, whichever is larger. mkdir and mkdirat count only the calls that created a directory, since concurrent installs fail a varying number with EEXIST. A syscall whose identical runs differ by more than that tolerance is reported unstable and not gated, unless HEAD's fewest calls also exceed main's most by more than the tolerance plus that difference. Each scenario lists its largest change relative to its tolerance and every row that is not within tolerance.

Scenario Engine Syscall main calls (max) HEAD calls (min) Change Tolerance Identical-run spread Result
isolated-fresh-restore-cold-cache-cold-store pacquet symlink 3888 3891 +0.1% 77 2 Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet readlink 15303 15312 +0.1% 306 55 Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet readlink 16706 16718 +0.1% 334 17 Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr statx 94238 94241 +0.0% 1884 10 Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet openat 15394 15398 +0.0% 307 14 Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet readlink 15718 15541 -1.1% 314 344 Unstable (identical runs differ by 344, not gated)
isolated-fresh-install-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr access 11 11 +0.0% 50 0 Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet access 10 10 +0.0% 50 0 Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 34939d395bd2

Compared against main at: d40d64242f9f

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked, injected, and Cargo 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.462 ± 0.115 2.353 2.662 1.63 ± 0.13
pacquet@main 2.402 ± 0.144 2.257 2.639 1.59 ± 0.14
pnpr@HEAD 1.507 ± 0.099 1.357 1.641 1.00
pnpr@main 1.516 ± 0.129 1.355 1.695 1.01 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4618782188400004,
      "stddev": 0.11523348741516097,
      "median": 2.42483297284,
      "user": 2.3986724400000003,
      "system": 1.50998076,
      "min": 2.35292756884,
      "max": 2.66216037684
    },
    {
      "command": "pacquet@main",
      "mean": 2.4015857786400003,
      "stddev": 0.14449351926516396,
      "median": 2.31855172634,
      "user": 2.21916374,
      "system": 1.42603736,
      "min": 2.2565666768400003,
      "max": 2.63862422684
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.50716454794,
      "stddev": 0.09898694515300255,
      "median": 1.5519131658399998,
      "user": 2.1767576400000004,
      "system": 1.4993340600000002,
      "min": 1.35747575884,
      "max": 1.64130638684
    },
    {
      "command": "pnpr@main",
      "mean": 1.51591764164,
      "stddev": 0.1285994733668038,
      "median": 1.52654012634,
      "user": 2.3963068400000003,
      "system": 1.53503186,
      "min": 1.35459764884,
      "max": 1.6945438878399999
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 213.4 ± 11.5 199.2 230.8 1.00
pacquet@main 231.7 ± 10.2 222.1 255.8 1.09 ± 0.08
pnpr@HEAD 263.6 ± 41.3 222.0 355.0 1.23 ± 0.20
pnpr@main 264.1 ± 33.3 227.6 349.2 1.24 ± 0.17
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.21344485662,
      "stddev": 0.011525177953248728,
      "median": 0.21151237622000002,
      "user": 0.26392373999999996,
      "system": 0.5297510599999999,
      "min": 0.19923189472000002,
      "max": 0.23078574472000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.23165791512,
      "stddev": 0.010155272019581985,
      "median": 0.22833410622,
      "user": 0.28741933999999997,
      "system": 0.5837105599999999,
      "min": 0.22206325472000002,
      "max": 0.25579221372
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26355219172,
      "stddev": 0.04130784575905267,
      "median": 0.25282562122,
      "user": 0.31135794,
      "system": 0.5949836599999999,
      "min": 0.22202080472000002,
      "max": 0.35500457172
    },
    {
      "command": "pnpr@main",
      "mean": 0.26406924942,
      "stddev": 0.033343938279570995,
      "median": 0.25519580371999995,
      "user": 0.31402673999999997,
      "system": 0.6141144599999999,
      "min": 0.22760715972,
      "max": 0.34921344372
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 12.6 ± 1.7 10.1 18.1 1.21 ± 0.17
pacquet@main 11.6 ± 1.3 9.5 16.8 1.11 ± 0.14
pnpr@HEAD 10.4 ± 0.6 9.3 13.6 1.00
pnpr@main 11.5 ± 1.0 9.5 14.5 1.11 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.012562764187899167,
      "stddev": 0.0016558596835377674,
      "median": 0.012246966440000001,
      "user": 0.0075006038655462196,
      "system": 0.006200146218487397,
      "min": 0.010082011440000002,
      "max": 0.01813862344
    },
    {
      "command": "pacquet@main",
      "mean": 0.011569546239043065,
      "stddev": 0.0013316746281004275,
      "median": 0.011310871440000002,
      "user": 0.007242368229665063,
      "system": 0.005306194354066988,
      "min": 0.009541830440000001,
      "max": 0.01678937344
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.010411295681666665,
      "stddev": 0.0006109067682754489,
      "median": 0.010308020940000003,
      "user": 0.006605344166666665,
      "system": 0.00464680925,
      "min": 0.009283050440000001,
      "max": 0.013620772440000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.011527592931228067,
      "stddev": 0.000958163633094745,
      "median": 0.011385451440000001,
      "user": 0.007089331228070172,
      "system": 0.005378812491228071,
      "min": 0.009471641440000001,
      "max": 0.014512092440000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 13.3 ± 1.6 10.7 18.6 1.14 ± 0.17
pacquet@main 11.6 ± 1.0 9.8 14.9 1.00
pnpr@HEAD 11.9 ± 1.0 9.9 15.0 1.02 ± 0.13
pnpr@main 11.6 ± 1.1 9.8 14.6 1.00 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.013261514867485377,
      "stddev": 0.001580964544541111,
      "median": 0.01317741654,
      "user": 0.007935250409356722,
      "system": 0.006617200584795322,
      "min": 0.01068444854,
      "max": 0.018649415540000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.011606768760779216,
      "stddev": 0.0010432285874264018,
      "median": 0.01133967754,
      "user": 0.0074552122077922115,
      "system": 0.0051600606060606055,
      "min": 0.009845418540000001,
      "max": 0.01488821754
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.011891423236261687,
      "stddev": 0.0010430822978115073,
      "median": 0.01166334254,
      "user": 0.006988321869158879,
      "system": 0.005913220560747665,
      "min": 0.00988941754,
      "max": 0.014987986540000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.011625411235652175,
      "stddev": 0.0010565989031275254,
      "median": 0.01150421804,
      "user": 0.0072017352173913045,
      "system": 0.005435085326086956,
      "min": 0.00976486854,
      "max": 0.01458505654
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.453 ± 0.054 2.413 2.600 1.56 ± 0.14
pacquet@main 2.470 ± 0.075 2.401 2.658 1.57 ± 0.14
pnpr@HEAD 1.593 ± 0.158 1.429 1.825 1.01 ± 0.13
pnpr@main 1.573 ± 0.135 1.448 1.828 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.45345624116,
      "stddev": 0.05394257827219637,
      "median": 2.43934393286,
      "user": 2.75086808,
      "system": 1.6440245,
      "min": 2.41308508436,
      "max": 2.59986291936
    },
    {
      "command": "pacquet@main",
      "mean": 2.4700508352600004,
      "stddev": 0.07515453902293373,
      "median": 2.46075315486,
      "user": 2.7390022800000002,
      "system": 1.6951692,
      "min": 2.40055200336,
      "max": 2.65787716336
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5933756567599997,
      "stddev": 0.15791895386598773,
      "median": 1.54840384886,
      "user": 2.24205638,
      "system": 1.5948933,
      "min": 1.4294159253599998,
      "max": 1.8252028173600001
    },
    {
      "command": "pnpr@main",
      "mean": 1.57267269966,
      "stddev": 0.13521028097241844,
      "median": 1.5241621583599998,
      "user": 2.30202718,
      "system": 1.6933889,
      "min": 1.4481917523599999,
      "max": 1.82787831436
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 543.4 ± 38.4 502.0 615.6 1.73 ± 0.13
pacquet@main 515.5 ± 14.9 489.7 542.4 1.64 ± 0.06
pnpr@HEAD 314.2 ± 8.4 296.8 326.0 1.00
pnpr@main 318.4 ± 6.1 312.5 330.0 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5433682960599999,
      "stddev": 0.038440043184778144,
      "median": 0.52745912946,
      "user": 0.8106945399999999,
      "system": 0.9628262599999997,
      "min": 0.5019813654599999,
      "max": 0.6155814454599999
    },
    {
      "command": "pacquet@main",
      "mean": 0.51549649976,
      "stddev": 0.0149300883554077,
      "median": 0.5162556359599999,
      "user": 0.78208974,
      "system": 0.9088098600000002,
      "min": 0.48967826246,
      "max": 0.5423787904599999
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31416481786,
      "stddev": 0.00837307913696369,
      "median": 0.31343679746,
      "user": 0.28145304000000004,
      "system": 0.6428213599999999,
      "min": 0.29678019646000003,
      "max": 0.32604429946
    },
    {
      "command": "pnpr@main",
      "mean": 0.31836028166,
      "stddev": 0.006099992078107879,
      "median": 0.31702983496000003,
      "user": 0.31169984000000006,
      "system": 0.64087646,
      "min": 0.31252311046000003,
      "max": 0.32995190746
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.746 ± 0.087 1.700 1.992 5.92 ± 0.39
pacquet@main 1.775 ± 0.104 1.670 1.992 6.02 ± 0.44
pnpr@HEAD 0.326 ± 0.024 0.297 0.379 1.11 ± 0.10
pnpr@main 0.295 ± 0.013 0.275 0.324 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7458788004800003,
      "stddev": 0.08698598154970043,
      "median": 1.72173690028,
      "user": 1.4947301199999998,
      "system": 1.32846034,
      "min": 1.7004641422800002,
      "max": 1.99156486328
    },
    {
      "command": "pacquet@main",
      "mean": 1.77501608188,
      "stddev": 0.10408499412715462,
      "median": 1.7366738712800003,
      "user": 1.51514012,
      "system": 1.29135574,
      "min": 1.6698879532800002,
      "max": 1.99179913928
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.32588005638,
      "stddev": 0.024367675401208634,
      "median": 0.32303991128000004,
      "user": 0.30361262,
      "system": 0.6422267399999999,
      "min": 0.29729478428000006,
      "max": 0.37936435628000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.2947365879800001,
      "stddev": 0.012949133928457488,
      "median": 0.29607424478,
      "user": 0.27316421999999996,
      "system": 0.59116824,
      "min": 0.27542232628,
      "max": 0.32354605028000005
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 294.6 ± 15.9 267.9 318.1 2.93 ± 0.22
pacquet@main 286.0 ± 13.5 259.1 308.9 2.85 ± 0.21
pnpr@HEAD 100.4 ± 5.5 93.2 111.8 1.00
pnpr@main 101.2 ± 4.4 93.6 111.7 1.01 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29460648030000003,
      "stddev": 0.015865848928382133,
      "median": 0.29300346499999996,
      "user": 0.29663465999999994,
      "system": 0.1946126,
      "min": 0.2679323055,
      "max": 0.3180993435
    },
    {
      "command": "pacquet@main",
      "mean": 0.2860375972,
      "stddev": 0.013468764099780017,
      "median": 0.286669066,
      "user": 0.28614496,
      "system": 0.19753169999999998,
      "min": 0.2591266875,
      "max": 0.3089151455
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10039232598275863,
      "stddev": 0.005466681254123204,
      "median": 0.0992299075,
      "user": 0.04578564275862069,
      "system": 0.020229496551724138,
      "min": 0.09323773850000001,
      "max": 0.11179918350000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.10117550077586207,
      "stddev": 0.004392452768399449,
      "median": 0.10056381750000001,
      "user": 0.04805771172413794,
      "system": 0.01980470344827586,
      "min": 0.09362204850000001,
      "max": 0.11174157550000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 263.1 ± 17.0 245.8 286.9 1.00
pacquet@main 264.0 ± 10.1 252.8 280.7 1.00 ± 0.08
pnpm@HEAD 4688.1 ± 315.9 4244.3 5166.8 17.82 ± 1.67
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2630503167088889,
      "stddev": 0.017032209100835447,
      "median": 0.25716164282000004,
      "user": 0.30706851555555553,
      "system": 0.04266734666666667,
      "min": 0.24584296382,
      "max": 0.28686687482
    },
    {
      "command": "pacquet@main",
      "mean": 0.26404667770888895,
      "stddev": 0.01009807481213023,
      "median": 0.26201198982,
      "user": 0.2963549599999999,
      "system": 0.05037979111111111,
      "min": 0.25283339782,
      "max": 0.28072209382
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.688100273375556,
      "stddev": 0.315878850898498,
      "median": 4.643999587820001,
      "user": 7.1612610711111095,
      "system": 0.44498201333333337,
      "min": 4.24425357582,
      "max": 5.16676545782
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 101.7 ± 10.1 84.2 128.3 1.15 ± 0.16
pacquet@main 88.8 ± 8.2 77.7 117.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.10174753091142859,
      "stddev": 0.010090716004334732,
      "median": 0.10202193883999999,
      "user": 0.10543513857142857,
      "system": 0.049503630000000014,
      "min": 0.08419541184,
      "max": 0.12832666784000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.08882477142064517,
      "stddev": 0.00821914757934209,
      "median": 0.08875575884,
      "user": 0.09564489548387095,
      "system": 0.03829583161290324,
      "min": 0.07770243184,
      "max": 0.11760474284
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 155.0 ± 11.4 136.2 170.9 1.12 ± 0.13
pacquet@main 138.6 ± 12.8 120.4 164.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.15503746760352943,
      "stddev": 0.011409189917761825,
      "median": 0.15584569678000001,
      "user": 0.0627489494117647,
      "system": 0.10732525411764705,
      "min": 0.13619333778,
      "max": 0.17087533078
    },
    {
      "command": "pacquet@main",
      "mean": 0.13864263297047622,
      "stddev": 0.0127990553476999,
      "median": 0.13639677878,
      "user": 0.05271218190476191,
      "system": 0.09936767428571427,
      "min": 0.12036307378,
      "max": 0.16411141378
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.544 ± 0.158 4.400 4.851 1.29 ± 0.06
pacquet@main 4.526 ± 0.123 4.389 4.721 1.29 ± 0.05
pnpr@HEAD 3.513 ± 0.113 3.379 3.749 1.00
pnpr@main 3.551 ± 0.132 3.398 3.778 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.54389388492,
      "stddev": 0.15832442936239943,
      "median": 4.48835246492,
      "user": 2.04062596,
      "system": 1.4042499999999998,
      "min": 4.39975268842,
      "max": 4.85124484442
    },
    {
      "command": "pacquet@main",
      "mean": 4.52613071552,
      "stddev": 0.12317283403607776,
      "median": 4.51718397242,
      "user": 2.05154696,
      "system": 1.4101679,
      "min": 4.38893417442,
      "max": 4.72124251342
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.51324672462,
      "stddev": 0.11316451084836054,
      "median": 3.49062936592,
      "user": 1.8749637600000004,
      "system": 1.3418196999999998,
      "min": 3.37908946042,
      "max": 3.74911447242
    },
    {
      "command": "pnpr@main",
      "mean": 3.55139534932,
      "stddev": 0.13221969542011394,
      "median": 3.50347675942,
      "user": 1.8468106600000003,
      "system": 1.3155284999999999,
      "min": 3.39796554442,
      "max": 3.77750459542
    }
  ]
}

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 195.7 ± 11.9 175.5 210.6 1.00
pacquet@main 206.8 ± 7.9 194.5 216.5 1.06 ± 0.08
pnpr@HEAD 242.1 ± 9.0 221.4 254.6 1.24 ± 0.09
pnpr@main 227.9 ± 13.8 203.6 246.9 1.16 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.19573150188333333,
      "stddev": 0.01191474826872432,
      "median": 0.19867048880000002,
      "user": 0.2681229533333333,
      "system": 0.17406745999999998,
      "min": 0.17551234980000002,
      "max": 0.21059558180000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.20680140972307692,
      "stddev": 0.007877536245222368,
      "median": 0.2066552708,
      "user": 0.27733592769230764,
      "system": 0.19742088307692304,
      "min": 0.1945046768,
      "max": 0.21650821380000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.24206398510000002,
      "stddev": 0.008965016323263767,
      "median": 0.24354085480000004,
      "user": 0.31601862,
      "system": 0.19885046,
      "min": 0.22137706580000002,
      "max": 0.25456920780000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.22785738189090907,
      "stddev": 0.013842499639685863,
      "median": 0.2295243428,
      "user": 0.29932216545454543,
      "system": 0.1809471418181818,
      "min": 0.20362956580000002,
      "max": 0.24693432580000002
    }
  ]
}

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.190 ± 0.036 1.158 1.281 1.02 ± 0.03
pacquet@main 1.170 ± 0.019 1.148 1.204 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.1896709738600002,
      "stddev": 0.036063575935036306,
      "median": 1.18019568626,
      "user": 0.72140068,
      "system": 0.2620502,
      "min": 1.15817000976,
      "max": 1.2808157447600002
    },
    {
      "command": "pacquet@main",
      "mean": 1.16988497356,
      "stddev": 0.01904256973161182,
      "median": 1.16893869576,
      "user": 0.6992861800000001,
      "system": 0.2878469,
      "min": 1.14840127376,
      "max": 1.20357586376
    }
  ]
}

Scenario: Cargo: repeat install, hot cache + hot store

Frozen repeat install of a Cargo workspace (cargo.enabled: true) whose crates are already materialized in <storeDir>/v11/crates/ and linked into .pnpm/crates/crates-io. Direct installs only.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 39.9 ± 2.3 35.6 46.5 1.06 ± 0.14
pacquet@main 37.7 ± 4.6 32.0 68.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.039885191347179494,
      "stddev": 0.0023463134599685243,
      "median": 0.03957222786,
      "user": 0.030708243589743594,
      "system": 0.023353425128205135,
      "min": 0.03561199736,
      "max": 0.04647201436
    },
    {
      "command": "pacquet@main",
      "mean": 0.03766948150473685,
      "stddev": 0.004588895867390577,
      "median": 0.03693927436,
      "user": 0.02908219736842105,
      "system": 0.021557614736842118,
      "min": 0.03197516236,
      "max": 0.06875883836
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review October 4, 2026 23:29
Copilot AI balanced review requested due to automatic review settings October 4, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Prevent pre-run reinstalls after frozen installs

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Record whether the last install used a frozen lockfile in workspace state.
• Prevent a missing dedupe baseline alone from triggering a pre-run install after a frozen install.
• Cover the gate’s behavior, explicit configuration overrides, and lockfile preservation with tests.
Diagram

graph TD
  A["Install policy"] --> B["State writers"] --> C[("Workspace state")] --> D["Pre-run gate"] --> E["Run or exec"]
  D --> F["Install on drift"] --> E
Loading
High-Level Assessment

Recording the actual install policy is appropriate: the run invocation’s configuration alone cannot reveal that a preceding install was frozen. The flag leaves other drift checks intact and allows an explicit frozenLockfile=false setting to take precedence.

Files changed (19) +132 / -35

Bug fix (10) +49 / -26
apply_materialization.rsRecord frozen policy after materialization +2/-5

Record frozen policy after materialization

• Passes the complete completion mode through resolve-only handling and writes its frozen-lockfile value to workspace state after materialization.

pnpm/crates/package-manager/src/install/apply_materialization.rs

prepare_modules_state.rsForward frozen policy to up-to-date handling +2/-0

Forward frozen policy to up-to-date handling

• Carries the install’s frozen-lockfile policy into up-to-date state refreshes and frozen-tree preparation.

pnpm/crates/package-manager/src/install/prepare_modules_state.rs

up_to_date.rsPersist frozen policy on up-to-date refresh +6/-4

Persist frozen policy on up-to-date refresh

• Adds frozenLockfile to the state supplied to up-to-date refreshes and writes it alongside the retained dedupe baseline.

pnpm/crates/package-manager/src/install/prepare_modules_state/up_to_date.rs

dispatch.rsDistinguish frozen policy from the frozen path +1/-0

Distinguish frozen policy from the frozen path

• Passes the resolved frozen-lockfile policy separately from whether dispatch selected a frozen path, which can also occur for an up-to-date lockfile.

pnpm/crates/package-manager/src/install/run/dispatch.rs

execution.rsInclude frozen policy in completion mode +10/-5

Include frozen policy in completion mode

• Constructs completion mode with the resolved install lockfile policy so materialization can record it.

pnpm/crates/package-manager/src/install/run/execution.rs

state_options.rsAdd frozen policy to install state options +4/-0

Add frozen policy to install state options

• Extends completion and repeat-install options with an explicit frozenLockfile field, separate from the selected frozen path.

pnpm/crates/package-manager/src/install/state_options.rs

workspace_state.rsDefault newly built state to non-frozen +1/-0

Default newly built state to non-frozen

• Initializes the new field to false; install paths that know the actual policy set it before writing.

pnpm/crates/package-manager/src/install/workspace_state.rs

deps_status.rsIgnore dedupe drift when the lockfile stays frozen +19/-12

Ignore dedupe drift when the lockfile stays frozen

• Makes the pre-run gate consider the recorded frozen install as well as CI behavior, while honoring an explicit frozenLockfile setting. Content-check state refreshes retain the recorded value.

pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs

settle.rsPreserve frozen policy during repeat-install settle +1/-0

Preserve frozen policy during repeat-install settle

• Carries the recorded frozen-lockfile value into refreshed workspace state when a repeat install settles without a new materialization.

pnpm/crates/package-manager/src/optimistic_repeat_install/settle.rs

lib.rsAdd optional frozenLockfile state metadata +3/-0

Add optional frozenLockfile state metadata

• Adds a backward-compatible frozen_lockfile field to serialized workspace state. Missing values default to false, and false values are omitted from output.

pnpm/crates/workspace-state/src/lib.rs

Tests (8) +78 / -9
auto_dedupe.rsExercise the deploy-style frozen-install sequence +41/-0

Exercise the deploy-style frozen-install sequence

• Adds an outside-CI integration test that changes a dependency, performs a frozen install, then runs a gated script. It checks that the gate does not spawn another install or alter the accepted lockfile.

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

tests.rsSupply frozen policy in preparation fixture +1/-0

Supply frozen policy in preparation fixture

• Updates a repeat-install policy fixture to include the new frozen-lockfile field.

pnpm/crates/package-manager/src/install/prepare_modules_state/tests.rs

frozen_policy.rsUpdate frozen-policy test fixture +1/-0

Update frozen-policy test fixture

• Adds the new workspace-state field to a frozen-policy test fixture.

pnpm/crates/package-manager/src/install/tests/frozen_policy.rs

lockfile_recovery.rsUpdate lockfile-recovery state fixtures +2/-0

Update lockfile-recovery state fixtures

• Adds the frozen-lockfile field to workspace-state fixtures used by lockfile recovery and optimistic repeat-install tests.

pnpm/crates/package-manager/src/install/tests/lockfile_recovery.rs

repeat_install.rsUpdate repeat-install state fixtures +3/-0

Update repeat-install state fixtures

• Adds the frozen-lockfile field to workspace-state fixtures covering repeat-install fast paths and partial installs.

pnpm/crates/package-manager/src/install/tests/repeat_install.rs

tests.rsUpdate optimistic-repeat state fixture +1/-0

Update optimistic-repeat state fixture

• Initializes the frozen-lockfile field in the shared workspace-state test helper.

pnpm/crates/package-manager/src/optimistic_repeat_install/tests.rs

auto_dedupe.rsTest frozen-lockfile dedupe drift decisions +25/-9

Test frozen-lockfile dedupe drift decisions

• Expands the gate’s dedupe-baseline test to cover recorded frozen installs, CI, explicit false configuration, and absent lockfiles.

pnpm/crates/package-manager/src/optimistic_repeat_install/tests/auto_dedupe.rs

tests.rsUpdate workspace-state serialization fixtures +4/-0

Update workspace-state serialization fixtures

• Initializes the new field in workspace-state round-trip, omission, and error-path test fixtures.

pnpm/crates/workspace-state/src/tests.rs

Documentation (1) +5 / -0
frozen-install-skips-dedupe-gate.mdDocument the frozen-install gate fix +5/-0

Document the frozen-install gate fix

• Adds a patch changeset explaining that run and exec no longer reinstall solely because autoDedupe lacks a baseline after a frozen install.

.changeset/frozen-install-skips-dedupe-gate.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. A v11 check revives the redundant install 🐞 Bug ≡ Correctness ⭐ New
Description
lockfile_stays_frozen depends on the recorded frozenLockfile value, but a passing pnpm v11
dependency check rebuilds the shared workspace state without that new field. After a v12 frozen
install, a v11 check that refreshes the state removes the marker; the next v12 run treats the
missing dedupe baseline as drift and can spawn the non-frozen install this change is meant to avoid.
Code

pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs[187]

+        state.frozen_lockfile || (config.ci && config.prefer_frozen_lockfile),
Relevance

●●● Strong

Concrete correctness bug: v11 state refresh drops a v12-written field. Close precedent PR 17391
(accepted) flagged the same cross-version state-field loss in v11 refresh.

PR-#17391

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed v12 gate reads the flag to suppress autoDedupe drift. The v11 refresh calls
updateWorkspaceState, which creates a fresh state object containing only enumerated keys before
writing it; its type and constructor omit frozenLockfile. V12 deserializes an omitted flag as
false.

pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs[94-100]
pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs[184-188]
pnpm11/deps/status/src/validationProof.ts[166-190]
pnpm11/workspace/state/src/updateWorkspaceState.ts[53-78]
pnpm11/workspace/state/src/createWorkspaceState.ts[14-27]
pnpm/crates/workspace-state/src/lib.rs[84-88]

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 pnpm v11 dependency-check refresh discards the new frozen-install marker from the shared workspace state. A subsequent v12 run can therefore spawn a redundant non-frozen install.

## Fix Focus Areas
- pnpm11/workspace/state/src/types.ts[6-28]
- pnpm11/workspace/state/src/updateWorkspaceState.ts[53-78]
- pnpm11/deps/status/src/validationProof.ts[166-190]

## Recommended Fix
Make v11 refresh-only writes carry forward an existing `frozenLockfile` marker without interpreting it as a v11 install policy. Ensure an actual v11 install does not retain a marker from an earlier v12 frozen install, and test the cross-version refresh sequence.

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

Dismiss ↗ | View ↗


2. Release note hedges the lockfile effect ✓ Resolved

Resolving commit: 2b150af

Description
The changeset says the redundant install could rewrite the lockfile, presenting a possible outcome
rather than a definite behavior change. Readers of the release note get a speculative claim
alongside the concrete fix to the pre-run install gate.

3. State comment mislabels the frozen install ✓ Resolved

Resolving commit: cd1cab7

Description
The WorkspaceState::frozen_lockfile comment says the install that wrote the state ran frozen, but
an up-to-date refresh writes the state while carrying the earlier value forward. After a frozen
install followed by a non-frozen up-to-date install, the field remains true, so a reader could
mistake it for the latest install’s lockfile policy.

Grey Divider

Context sources
⚠️ Tickets: not configured — No jira, linear integration is connected for the linked tickets
✅ Compliance rules (platform): 41 rules
✅ Cross-repo context — repo relationships
✅ Context preparation
  Past issues: summarized; full text retained for this review
Review mode: Auto: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 34/18, lines 147/200; both must reach the floor). Router rationale: State propagation spans many install paths with subtle gate and lockfile risks.

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 34939d3 ⚖️ Balanced

Results up to commit 1607c2b ⚖️ Balanced


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


Remediation recommended
1. State comment mislabels the frozen install ✓ Resolved

Resolving commit: cd1cab7

Description
The WorkspaceState::frozen_lockfile comment says the install that wrote the state ran frozen, but
an up-to-date refresh writes the state while carrying the earlier value forward. After a frozen
install followed by a non-frozen up-to-date install, the field remains true, so a reader could
mistake it for the latest install’s lockfile policy.

Results up to commit cd1cab7 🚀 Fast


No changes from previous review

Results up to commit 46b3550 🧠 Deep


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


Remediation recommended
1. Release note hedges the lockfile effect ✓ Resolved

Resolving commit: 2b150af

Description
The changeset says the redundant install could rewrite the lockfile, presenting a possible outcome
rather than a definite behavior change. Readers of the release note get a speculative claim
alongside the concrete fix to the pre-run install gate.

Results up to commit 2b150af ⏭️ Skipped


No changes from previous review

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 Oct 4, 2026
Copilot AI balanced review requested due to automatic review settings October 4, 2026 23:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Oct 4, 2026

Copy link
Copy Markdown
Member Author

Qodo finding (state comment mislabels the frozen install): partly right, reworded in cd1cab7. The up-to-date refresh does not carry the value forward; it records the current install's frozenLockfile. The repeat-install fast path and the run gate's own refresh do carry it forward, so "the install that wrote the state" was inaccurate there. The field doc now names the last install past the repeat-install check.


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

@qodo-code-review

Copy link
Copy Markdown

Qodo finding (state comment mislabels the frozen install): partly right, reworded in cd1cab7. The up-to-date refresh does not carry the value forward; it records the current install's frozenLockfile. The repeat-install fast path and the run gate's own refresh do carry it forward, so "the install that wrote the state" was inaccurate there. The field doc now names the last install past the repeat-install check.


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

Your clarification is correct. Finding 1 was partly valid: the up-to-date refresh records the current install’s frozenLockfile via RepeatInstallPolicy, while the repeat-install content check and run-gate refresh explicitly carry the previous value forward (prepare_modules_state/up_to_date.rs:268-272, optimistic_repeat_install/{settle.rs:85-86,deps_status.rs:327-328}).

The revised wording—“the last install past the repeat-install check”—accurately covers both behaviors, so the finding is appropriately resolved.

@qodo-code-review

Copy link
Copy Markdown

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

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan

zkochan commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Alternative approach in #16591: an opt-in lockfile.includeResolutionSettings that records autoDedupe (plus dedupeInjectedDeps, dedupePeerDependents, linkWorkspacePackages) in pnpm-lock.yaml, so any machine can trust a deduplicated lockfile. Keeping both open until one is chosen.


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

Copilot AI balanced review requested due to automatic review settings October 5, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 46b3550

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

Copilot AI balanced review requested due to automatic review settings October 5, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Qodo finding (release note hedges the lockfile effect): fixed in 2b150af by dropping the hedged sentence.


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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2b150af

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@qodo-code-review

Copy link
Copy Markdown

Qodo finding (release note hedges the lockfile effect): fixed in 2b150af by dropping the hedged sentence.


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

Thanks for the update. The change in 2b150af20c addresses finding 1 by removing the hedged lockfile-rewrite sentence.

A `pnpm install --frozen-lockfile` that changes packages records no
`autoDedupe` baseline, since only a resolving install can record one.
Outside CI the `verifyDepsBeforeRun` gate read the missing baseline as
settings drift and spawned a regular install. That install reran every
lifecycle script and could re-resolve and rewrite the lockfile the frozen
install had just accepted.

The workspace state now records `frozenLockfile` when the install that
wrote it ran frozen. The materializing and up-to-date install paths set it
from the install's lockfile policy, and the refresh-only paths (repeat
install settle, run gate content check) carry it forward. The gate skips
the `autoDedupe` key when the recorded install was frozen, unless
`frozenLockfile` is configured for the run.

Closes #16583

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

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Reviews (1) · Last reviewed commit: "fix: keep the pre-run gate from re-resol..." · Reviewed by Greptile

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 34939d3

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan

zkochan commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Closing this in favor of recording the resolution settings in the lockfile.

If you run pnpm install --frozen-lockfile and then pnpm run with autoDedupe enabled, record the settings in pnpm-lock.yaml and pnpm run will no longer start an extra install:

# pnpm-workspace.yaml
lockfile:
  includeResolutionSettings: true

This setting was added in #16591 (pnpm v12.10.0). The experimental lockfile.format: v13 records these settings without it (#18283). pnpm v11 and pnpm v12 before v12.10.0 drop the recorded settings when they rewrite the lockfile. Turn the setting on once everyone on the project uses v12.10.0 or later.


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

@zkochan zkochan closed this Nov 20, 2026
ahamana added a commit to ahamana/tauri-app that referenced this pull request Nov 25, 2026
pnpm-lock.yaml does not record that it was resolved with autoDedupe,
so pnpm trusts only a lockfile it deduplicated itself. A non-frozen
install re-resolves a lockfile that a pull changed, and after a frozen
install that changes node_modules, a plain pnpm run or pnpm exec first
runs an install that reruns the lefthook postinstall (pnpm/pnpm#16583).

pnpm/pnpm#16588, the fix for the default lockfile format, was closed
unmerged. autoDedupe changed no dependency when it was added, so go
back to the default instead of offsetting it with
lockfile.includeResolutionSettings.
ahamana added a commit to next-colors/jakartaee-framework that referenced this pull request Nov 25, 2026
pnpm-lock.yaml does not record that it was resolved with autoDedupe,
so pnpm trusts only a lockfile it deduplicated itself. A non-frozen
install re-resolves a lockfile that a pull changed, and after a frozen
install that changes node_modules, a plain pnpm run or pnpm exec first
runs an install that reruns the lefthook postinstall (pnpm/pnpm#16583).

pnpm/pnpm#16588, the fix for the default lockfile format, was closed
unmerged. autoDedupe changed no dependency when it was added, so go
back to the default instead of offsetting it with
lockfile.includeResolutionSettings.
ahamana added a commit to ahamana/relate-docker that referenced this pull request Nov 25, 2026
pnpm-lock.yaml does not record that it was resolved with autoDedupe,
so pnpm trusts only a lockfile it deduplicated itself. A non-frozen
install re-resolves a lockfile that a pull changed, and after a frozen
install that changes node_modules, a plain pnpm run or pnpm exec first
runs an install that reruns the lefthook postinstall (pnpm/pnpm#16583).

pnpm/pnpm#16588, the fix for the default lockfile format, was closed
unmerged. autoDedupe changed no dependency when it was added, so go
back to the default instead of offsetting it with
lockfile.includeResolutionSettings.
ahamana added a commit to ahamana/canvas-lms-docker that referenced this pull request Nov 25, 2026
pnpm-lock.yaml does not record that it was resolved with autoDedupe,
so pnpm trusts only a lockfile it deduplicated itself. A non-frozen
install re-resolves a lockfile that a pull changed, and after a frozen
install that changes node_modules, a plain pnpm run or pnpm exec first
runs an install that reruns the lefthook postinstall (pnpm/pnpm#16583).

pnpm/pnpm#16588, the fix for the default lockfile format, was closed
unmerged. autoDedupe changed no dependency when it was added, so go
back to the default instead of offsetting it with
lockfile.includeResolutionSettings.
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.

3 participants