Skip to content

fix(store-dir): rebuild when the side-effects cache has nothing to restore - #14744

Merged
zkochan merged 4 commits into
mainfrom
fix/side-effects-cache-empty-overlay
Sep 10, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix/side-effects-cache-empty-overlay

Conversation

@TrevorBurnham

@TrevorBurnham TrevorBurnham commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #14717.

pnpm 12 skips a dependency's build scripts on a side-effects cache hit even when the matched cache row has nothing to restore, so the scripts don't run and nothing is materialized in their place. A build whose whole effect lands outside its own package directory — a git-hook installer, a script seeding a shared download cache — therefore never takes effect. pnpm 11 rebuilds in this case.

A row is recorded whenever a build script ran, and a build that changed nothing inside the package directory produces an empty one. Both stacks write that row; only the read paths differed:

  • pnpm 11 checkPkgFilesIntegrity (store/cafs/src/checkPkgFilesIntegrity.ts:89) adds a row to sideEffectsMaps only under if (added) … else if (deleted). An empty row matches neither branch, so it is dropped, sideEffectsCacheKey is never set, isBuilt stays false, and the build runs.
  • pnpm 12 build_side_effects_maps turned every row into an overlay. An empty row became an overlay equal to the base files, and the is_built gate took it as a hit.

This PR drops the row at the same point pnpm 11 does. An entry's presence now means there is build output to materialize, which is what the is_built gate already assumed.

The reproduction in the issue, run against this build:

project a hook: .git/hooks/pre-commit
project b hook: .git/hooks/pre-commit

On 12.3.2 project b's hook is MISSING.

Notes for reviewers

  • The drop keys off having nothing to restore, not off added being absent. A row carrying only deleted still counts as a hit: that build happened and its effect is reproducible from the row. side_effects_overlay_with_only_deletions_keeps_cache_key_entry pins that, so the fix can't quietly widen into "only added rows count."
  • Nothing downstream needed a matching change. prefetch.rs:257 already filters an empty side_effects_maps out of the prefetch result, so a package whose only row is dropped contributes no entry to side_effects_maps_by_snapshot and the frozen-install fast path at build_phase.rs:210 still sees an empty table. I checked the remote path too: shared_side_effects.rs builds side_effects_maps_by_snapshot from resolved artifacts directly rather than through build_side_effects_maps, so a remote artifact with real content is unaffected.
  • A row with only remote_origin set and no added/deleted is dropped as well. Same reasoning, and it matches pnpm 11, whose check looks only at added/deleted.
  • The write path is unchanged. pnpm 11 also stores the empty row, so removing it on write would be the divergence rather than the fix, and it would change the store's on-disk contents for no benefit.
  • This is v12-only. pnpm 11 already behaves correctly here, so there is nothing to fix in pnpm11/. Verified by measurement rather than by reading — see the table below.

Validation

Measured with one project per cell, a fresh store per pnpm version, and node_modules wiped between the two installs. ran / ran means the build script ran on both installs.

build script 11.5.2 11.26.0 12.3.2 this PR
prints only, no in-package change ran / ran ran / ran ran / skipped ran / ran
writes a file into the package ran / skipped ran / skipped ran / skipped ran / skipped

The second row is the legitimate cache hit and still skips, with the cached file restored. Only the first row changes, and it now matches both pnpm 11 versions.

  • Reproduced the issue's two-project simple-git-hooks scenario against released 12.3.2 (project b's hook missing), then confirmed both projects get the hook with this build.
  • New tests: a_build_with_nothing_to_restore_runs_on_every_install (e2e, asserts the postinstall runs on three consecutive installs), plus side_effects_overlay_with_nothing_to_restore_drops_cache_key_entry and side_effects_overlay_with_only_deletions_keeps_cache_key_entry (unit).
  • Each new test was run against a reverted implementation and fails there. The e2e failure is the reported bug exactly: install 2 prints a clean successful install and the script does not run.
  • New registry fixture @pnpm.e2e/postinstall-writes-outside-package, whose postinstall appends a byte to a file named by an env var and leaves its own directory untouched. Its diff is empty by construction, which is what the test needs.
  • Suites run green: pnpm-store-dir, pnpm-deps-restorer, and pnpm-tarball in full (766 tests), and the side_effects_cache, lifecycle_scripts, global_virtual_store, and local_tarball_dependency modules of pnpm-cli (95 tests). Both side_effects_materialized_on_warm_frozen_reinstall variants pass, which are the tests that would catch an over-broad drop.
  • cargo clippy --locked --workspace --all-targets -- -D warnings and RUSTDOCFLAGS=-D warnings cargo doc --workspace --no-deps are clean; cargo fmt and taplo format applied. just ready was not runnable in this environment (just and typos are not installed), so those steps are left to CI.

Squash Commit Body

A side-effects row is recorded whenever a build script ran, including a
build that changed nothing inside the package directory. `calculate_diff`
returns `added: None, deleted: None` for that case and the row is stored
anyway, so a package whose whole build effect lands elsewhere -- a
git-hook installer, a script seeding a shared download cache -- gets an
empty row.

`build_side_effects_maps` turned every row into an overlay, so an empty
one became an overlay equal to the base files and the `is_built` gate
took it as a hit. The scripts were skipped and nothing was materialized
in their place: the package directory after such an install is
byte-identical to the pristine tarball, and the build's effect never
happens at all. The cache key does not include the consuming project, so
this is not limited to reinstalls -- a project's first install can hit a
row an unrelated project seeded on the same machine.

pnpm 11 drops the row instead. Its `checkPkgFilesIntegrity` adds to
`sideEffectsMaps` only under `if (added) ... else if (deleted)`, so an
empty row matches neither branch, `sideEffectsCacheKey` is never set,
`isBuilt` stays false, and the build runs. Both stacks write the same
empty row and only their read paths differed, so this drops it at the
same point pnpm 11 does. An entry's presence now means there is build
output to materialize, which is what the `is_built` gate already assumed.

A row carrying only `deleted` still counts as a hit. That build did
happen and its effect is reproducible from the row.

`prefetch.rs` already filters an empty `side_effects_maps` out of the
prefetch result, so a package whose only row is dropped contributes no
entry at all and the frozen-install fast path in `build_phase` still
sees an empty table.

Closes pnpm/pnpm#14717

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. (pnpm 11 already rebuilds in
    this case, so there is nothing to fix there — see the table above.)
  • 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.
  • Updated the documentation if needed.

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

Summary by CodeRabbit

  • Bug Fixes

    • pnpm install now reruns dependency build scripts when the side-effects cache has no files to restore.
    • Build scripts that produce effects outside their package directory now run correctly on repeated installs, including frozen-lockfile installs.
    • Side-effects cache entries containing only deletions continue to restore correctly.
  • Tests

    • Added coverage for repeated installs and side-effects cache entries with empty or deletion-only changes.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 64f21b0a-afc3-4f60-af23-4dae722b3e7b

📥 Commits

Reviewing files that changed from the base of the PR and between eff8032 and fcef09d.

📒 Files selected for processing (6)
  • .changeset/side-effects-cache-empty-overlay.md
  • pnpm/crates/deps-restorer/src/shared_side_effects.rs
  • pnpm/crates/deps-restorer/src/shared_side_effects/tests.rs
  • pnpm/crates/shared-artifact-protocol/src/lib.rs
  • pnpm/crates/store-dir/src/check_pkg_files_integrity.rs
  • pnpm/crates/store-dir/src/store_index.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7b9f6156-c501-4a4e-bbf4-681523d05bb6

📥 Commits

Reviewing files that changed from the base of the PR and between 325d054 and 2f211ea.

📒 Files selected for processing (5)
  • .changeset/side-effects-cache-empty-overlay.md
  • pnpm/crates/cli/tests/suite/side_effects_cache.rs
  • pnpm/crates/store-dir/src/check_pkg_files_integrity.rs
  • pnpm/crates/store-dir/src/check_pkg_files_integrity/tests.rs
  • pnpr/.fixtures/packages/@pnpm.e2e/postinstall-writes-outside-package/1.0.0/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/side-effects-cache-empty-overlay.md

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


📝 Walkthrough

Walkthrough

The side-effects cache now treats empty diffs as cache misses. Packages with no in-package build output run their build scripts during installation, including frozen reinstalls. Unit and end-to-end tests cover this behavior.

Changes

Side-effects cache fix

Layer / File(s) Summary
Empty overlay fallback
pnpm/crates/store-dir/src/check_pkg_files_integrity.rs, pnpm/crates/store-dir/src/check_pkg_files_integrity/tests.rs
overlay_for drops cache entries with no added or deleted files. Deletion-only entries remain available for restoration. Unit tests cover both cases.
Install and release validation
pnpm/crates/cli/tests/suite/side_effects_cache.rs, pnpr/.fixtures/packages/@pnpm.e2e/postinstall-writes-outside-package/1.0.0/package.json, .changeset/side-effects-cache-empty-overlay.md
The end-to-end test verifies that an outside-package postinstall runs on each install. The fixture records each run, and the changeset declares a patch release for pacquet.

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

Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
[#14717] Do not treat an empty side-effects cache row as a cache hit; run the dependency build script instead. ✅
[#14717] Ensure builds with effects outside the package directory run on repeated and frozen installs. ✅

Suggested labels: product: pacquet, product: pnpr

Merge Risk: ⚪ Minimal · up to 2f211

Dependencies whose build scripts produce no package-directory output now rebuild instead of being incorrectly treated as restored cache hits, while deletion-only and normal cache restoration behavior remain covered. No current merge-blocking risk is identified.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/side-effects-cache-empty-overlay

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

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     11.2±0.02ms    33.4 MB/sec    1.07     12.0±0.05ms    31.3 MB/sec
packument/parse                                  1.00     36.8±0.26µs  1804.1 MB/sec    1.09     39.9±0.15µs  1661.8 MB/sec
tarball/download_dependency                      1.00      3.8±0.14ms  1146.7 KB/sec    1.10      4.2±0.54ms  1043.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    184.9±2.19ms 86.5 KElem/sec    1.05    194.4±9.59ms 82.3 KElem/sec
workspace_resolution/hoist_heavy                 1.00    245.8±1.02ms        ? ?/sec    1.02    250.8±1.53ms        ? ?/sec
workspace_sort/chained_projects                  1.00     13.5±0.96ms        ? ?/sec    1.07     14.4±0.56ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.52%. Comparing base (4b55d61) to head (fcef09d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14744      +/-   ##
==========================================
+ Coverage   90.43%   90.52%   +0.08%     
==========================================
  Files         796      796              
  Lines      155522   155540      +18     
==========================================
+ Hits       140653   140802     +149     
+ Misses      14869    14738     -131     

☔ 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 Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: eff8032eedda

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

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.314 ± 0.106 2.243 2.559 1.65 ± 0.17
pacquet@main 2.378 ± 0.155 2.231 2.615 1.69 ± 0.19
pnpr@HEAD 1.413 ± 0.091 1.294 1.606 1.01 ± 0.12
pnpr@main 1.403 ± 0.132 1.290 1.667 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.31443907044,
      "stddev": 0.1064085247122949,
      "median": 2.2715351878399996,
      "user": 1.22011936,
      "system": 1.42987436,
      "min": 2.24296162334,
      "max": 2.55932251834
    },
    {
      "command": "pacquet@main",
      "mean": 2.37812706544,
      "stddev": 0.15522783031727835,
      "median": 2.30157980184,
      "user": 1.21231846,
      "system": 1.40662546,
      "min": 2.2314719363399997,
      "max": 2.6154829723399997
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.41262248504,
      "stddev": 0.09125086509476205,
      "median": 1.3961747283400001,
      "user": 1.1263315600000001,
      "system": 1.26824166,
      "min": 1.29403394434,
      "max": 1.60619778634
    },
    {
      "command": "pnpr@main",
      "mean": 1.4030398726400002,
      "stddev": 0.13246560444650446,
      "median": 1.3562037443400001,
      "user": 1.08584696,
      "system": 1.2603995599999998,
      "min": 1.2901667783400002,
      "max": 1.6667608413400001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 210.0 ± 6.3 198.6 219.4 1.00
pacquet@main 216.5 ± 8.1 206.5 230.0 1.03 ± 0.05
pnpr@HEAD 224.3 ± 9.2 211.7 239.1 1.07 ± 0.05
pnpr@main 228.2 ± 8.0 213.5 243.2 1.09 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.21002996266,
      "stddev": 0.006312776616956831,
      "median": 0.21074296146000002,
      "user": 0.21026993999999996,
      "system": 0.5107346199999999,
      "min": 0.19855887196000002,
      "max": 0.21935056396000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.21651011086,
      "stddev": 0.008120750275835071,
      "median": 0.21724177496000002,
      "user": 0.23040084,
      "system": 0.49802292000000004,
      "min": 0.20645845696,
      "max": 0.23001508296
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.22430277646000002,
      "stddev": 0.009212855673837924,
      "median": 0.22313384696000002,
      "user": 0.22172424,
      "system": 0.48490041999999994,
      "min": 0.21171368496,
      "max": 0.23913721796
    },
    {
      "command": "pnpr@main",
      "mean": 0.22820182346,
      "stddev": 0.008000523017735878,
      "median": 0.22790374396000002,
      "user": 0.21953333999999997,
      "system": 0.50946752,
      "min": 0.21349542696,
      "max": 0.24321332196
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 7.3 ± 0.9 5.7 11.3 1.15 ± 0.18
pacquet@main 6.8 ± 0.4 6.0 8.6 1.08 ± 0.11
pnpr@HEAD 6.4 ± 0.6 5.7 9.6 1.00
pnpr@main 6.4 ± 0.6 5.6 9.8 1.01 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.007291886018257263,
      "stddev": 0.0009186671855866406,
      "median": 0.0072147084,
      "user": 0.00374862398340249,
      "system": 0.00400783502074689,
      "min": 0.0056655614,
      "max": 0.0113487394
    },
    {
      "command": "pacquet@main",
      "mean": 0.0068382081493112935,
      "stddev": 0.000363640511279907,
      "median": 0.006823389400000001,
      "user": 0.004161598732782374,
      "system": 0.0031239887603305783,
      "min": 0.0060311724,
      "max": 0.0086366164
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.006355572149999996,
      "stddev": 0.0005793582054916143,
      "median": 0.0062232349,
      "user": 0.004090919010989012,
      "system": 0.002649534065934067,
      "min": 0.005666514400000001,
      "max": 0.0096168084
    },
    {
      "command": "pnpr@main",
      "mean": 0.006392327042857139,
      "stddev": 0.0006184162070986796,
      "median": 0.0062480374,
      "user": 0.0038564146938775516,
      "system": 0.0029216725510204096,
      "min": 0.0056404544,
      "max": 0.0097946524
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 7.1 ± 1.3 5.7 13.6 1.00
pacquet@main 7.3 ± 1.4 5.7 13.8 1.03 ± 0.27
pnpr@HEAD 8.1 ± 1.2 5.9 14.0 1.15 ± 0.27
pnpr@main 8.1 ± 0.6 6.8 11.3 1.14 ± 0.22
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.007075279726517577,
      "stddev": 0.0012799226121946112,
      "median": 0.006549784800000001,
      "user": 0.00430149130990415,
      "system": 0.0031711556549520784,
      "min": 0.0057410658,
      "max": 0.013635200800000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.007286257394029854,
      "stddev": 0.0013568016286974757,
      "median": 0.0068680558,
      "user": 0.004274851044776118,
      "system": 0.003408752417910449,
      "min": 0.0057310768,
      "max": 0.013802476800000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008108281596721313,
      "stddev": 0.0012079201323722155,
      "median": 0.007909092800000002,
      "user": 0.004700122295081966,
      "system": 0.0038607578360655764,
      "min": 0.0059234218,
      "max": 0.014041166800000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.008096046344850503,
      "stddev": 0.0006151568123638037,
      "median": 0.0079831928,
      "user": 0.004517677940199337,
      "system": 0.003995195880398671,
      "min": 0.006800147800000001,
      "max": 0.011335485800000001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.432 ± 0.022 2.408 2.481 1.68 ± 0.13
pacquet@main 2.422 ± 0.007 2.411 2.434 1.67 ± 0.13
pnpr@HEAD 1.448 ± 0.113 1.366 1.658 1.00
pnpr@main 1.473 ± 0.133 1.356 1.714 1.02 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4316648147600004,
      "stddev": 0.02248084418954723,
      "median": 2.42434222326,
      "user": 1.6319495400000001,
      "system": 1.46859278,
      "min": 2.40754573926,
      "max": 2.48110046726
    },
    {
      "command": "pacquet@main",
      "mean": 2.4223813636600005,
      "stddev": 0.006995885633390768,
      "median": 2.42424600626,
      "user": 1.5264397400000003,
      "system": 1.4725717800000002,
      "min": 2.41126541626,
      "max": 2.43351802826
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.44838017076,
      "stddev": 0.1134070862387833,
      "median": 1.38548002976,
      "user": 0.9814207399999999,
      "system": 1.20158938,
      "min": 1.36580159126,
      "max": 1.6582520912599998
    },
    {
      "command": "pnpr@main",
      "mean": 1.4732204976599999,
      "stddev": 0.13283064573037204,
      "median": 1.4378214537599998,
      "user": 0.9966120399999999,
      "system": 1.1660885799999998,
      "min": 1.35627559326,
      "max": 1.71387838526
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 340.8 ± 13.7 310.7 363.4 1.35 ± 0.06
pacquet@main 328.8 ± 8.8 315.2 343.4 1.30 ± 0.04
pnpr@HEAD 256.6 ± 11.0 242.5 273.6 1.01 ± 0.05
pnpr@main 253.0 ± 5.2 246.5 262.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.34080406364,
      "stddev": 0.013684923994727864,
      "median": 0.34039064594,
      "user": 0.46769969999999994,
      "system": 0.7598838600000002,
      "min": 0.31069388994,
      "max": 0.36342481494
    },
    {
      "command": "pacquet@main",
      "mean": 0.32883021164000004,
      "stddev": 0.008805425956522584,
      "median": 0.32759043394,
      "user": 0.46338280000000004,
      "system": 0.7494818599999999,
      "min": 0.31516800894,
      "max": 0.34342783894
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.25660523634,
      "stddev": 0.011036955204696546,
      "median": 0.25633452044,
      "user": 0.1746476,
      "system": 0.47327975999999994,
      "min": 0.24245682494000004,
      "max": 0.27358372294
    },
    {
      "command": "pnpr@main",
      "mean": 0.25298579733999993,
      "stddev": 0.005167271445160262,
      "median": 0.25241997444,
      "user": 0.17509129999999998,
      "system": 0.46768925999999994,
      "min": 0.24649632794000004,
      "max": 0.26238580694
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.532 ± 0.012 1.509 1.554 5.65 ± 0.28
pacquet@main 1.519 ± 0.011 1.506 1.544 5.60 ± 0.28
pnpr@HEAD 0.276 ± 0.022 0.251 0.321 1.02 ± 0.10
pnpr@main 0.271 ± 0.013 0.258 0.292 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.53203795712,
      "stddev": 0.011842697272201665,
      "median": 1.53545808222,
      "user": 0.7202153399999999,
      "system": 0.87814056,
      "min": 1.50918728872,
      "max": 1.55375167572
    },
    {
      "command": "pacquet@main",
      "mean": 1.5194251677200001,
      "stddev": 0.010582154152337332,
      "median": 1.51787010872,
      "user": 0.69461694,
      "system": 0.85156376,
      "min": 1.50571074072,
      "max": 1.54367539772
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27565847722000003,
      "stddev": 0.02224142508250127,
      "median": 0.26971693322,
      "user": 0.21216054,
      "system": 0.48905985999999996,
      "min": 0.25059894272,
      "max": 0.32077759172000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.27123224472,
      "stddev": 0.01334262196542288,
      "median": 0.26535324822000006,
      "user": 0.19030403999999995,
      "system": 0.47730606,
      "min": 0.25753684072,
      "max": 0.29177180072000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 198.6 ± 6.9 188.0 216.0 2.27 ± 0.08
pacquet@main 195.3 ± 18.6 171.4 233.8 2.23 ± 0.21
pnpr@HEAD 91.8 ± 2.0 87.2 96.4 1.05 ± 0.03
pnpr@main 87.6 ± 1.0 86.8 91.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.19857902705384617,
      "stddev": 0.006949062880478598,
      "median": 0.1972453489,
      "user": 0.2110014153846154,
      "system": 0.07436501846153847,
      "min": 0.1880152199,
      "max": 0.21595396490000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.1953237196857143,
      "stddev": 0.018644168677896766,
      "median": 0.1940493359,
      "user": 0.19556472857142854,
      "system": 0.06111776571428572,
      "min": 0.1713844099,
      "max": 0.23383508690000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09175187541612903,
      "stddev": 0.001985132002774978,
      "median": 0.0918733399,
      "user": 0.03233205806451613,
      "system": 0.014387189677419357,
      "min": 0.08719095290000001,
      "max": 0.09639898090000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.0876249172870968,
      "stddev": 0.0010114196006592803,
      "median": 0.08735681690000001,
      "user": 0.028886638709677417,
      "system": 0.013761544516129034,
      "min": 0.0867603509,
      "max": 0.0914935129
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 672.6 ± 77.8 576.2 754.6 1.02 ± 0.17
pacquet@main 662.3 ± 77.8 540.1 754.2 1.00
pnpm@HEAD 3047.8 ± 62.1 2930.1 3127.8 4.60 ± 0.55
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6725768246377778,
      "stddev": 0.07779619642497727,
      "median": 0.70864582086,
      "user": 0.6737512044444444,
      "system": 0.17076769777777778,
      "min": 0.5761695198600001,
      "max": 0.7546387788600001
    },
    {
      "command": "pacquet@main",
      "mean": 0.6623329555266667,
      "stddev": 0.07776154393910405,
      "median": 0.69553983586,
      "user": 0.6670694266666666,
      "system": 0.14312825333333332,
      "min": 0.54005885486,
      "max": 0.7541503258600001
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0477554001933336,
      "stddev": 0.06208000821222307,
      "median": 3.05461375786,
      "user": 4.734293093333333,
      "system": 0.26869103111111114,
      "min": 2.9301293298599997,
      "max": 3.12775222186
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.422 ± 0.162 4.256 4.729 1.29 ± 0.07
pacquet@main 4.379 ± 0.142 4.283 4.703 1.28 ± 0.06
pnpr@HEAD 3.461 ± 0.136 3.331 3.696 1.01 ± 0.05
pnpr@main 3.430 ± 0.119 3.343 3.723 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.4216649852,
      "stddev": 0.16158386461022212,
      "median": 4.390985624099999,
      "user": 1.35564564,
      "system": 1.41433348,
      "min": 4.2557465731,
      "max": 4.729451325099999
    },
    {
      "command": "pacquet@main",
      "mean": 4.379220421199999,
      "stddev": 0.14218159273893677,
      "median": 4.3081443041,
      "user": 1.28427814,
      "system": 1.38288978,
      "min": 4.283261803099999,
      "max": 4.7025592641
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.4614104404000003,
      "stddev": 0.13595265268770945,
      "median": 3.4045462146,
      "user": 1.22490634,
      "system": 1.3103336799999998,
      "min": 3.3308352091,
      "max": 3.6957049171
    },
    {
      "command": "pnpr@main",
      "mean": 3.4299819936000007,
      "stddev": 0.11933324611245728,
      "median": 3.3825515611,
      "user": 1.23652244,
      "system": 1.3274274799999999,
      "min": 3.3432925361000003,
      "max": 3.7227875701
    }
  ]
}

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. Comparable to that scenario head-to-head.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 121.9 ± 4.8 115.0 135.8 1.00
pacquet@main 123.9 ± 4.8 115.1 132.1 1.02 ± 0.06
pnpr@HEAD 139.0 ± 4.2 131.4 147.1 1.14 ± 0.06
pnpr@main 147.8 ± 16.3 129.8 190.8 1.21 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.12187097794363634,
      "stddev": 0.004826239263873835,
      "median": 0.12062623357999999,
      "user": 0.16299387818181818,
      "system": 0.15555168909090908,
      "min": 0.11500462158000001,
      "max": 0.13577190158000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.12391290067090908,
      "stddev": 0.004780262410509496,
      "median": 0.12353871708,
      "user": 0.16672306,
      "system": 0.16145050727272722,
      "min": 0.11511437958,
      "max": 0.13206537858
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.1389685147466667,
      "stddev": 0.00423667559494148,
      "median": 0.13830019308000002,
      "user": 0.1781209488888889,
      "system": 0.15664016888888888,
      "min": 0.13138357958000002,
      "max": 0.14706272358000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.14778640822705885,
      "stddev": 0.01629274044072825,
      "median": 0.14600632858,
      "user": 0.18285361882352943,
      "system": 0.16427151529411765,
      "min": 0.12981902458000003,
      "max": 0.19084721458
    }
  ]
}

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/14744
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
115.00 ms
(-19.14%)Baseline: 142.23 ms
170.68 ms
(67.38%)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,407.55 ms
(-5.26%)Baseline: 2,541.12 ms
3,049.35 ms
(78.95%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,509.19 ms
(-5.51%)Baseline: 1,597.17 ms
1,916.61 ms
(78.74%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
310.69 ms
(-22.74%)Baseline: 402.16 ms
482.59 ms
(64.38%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
188.02 ms
(-17.39%)Baseline: 227.58 ms
273.10 ms
(68.84%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,242.96 ms
(-2.50%)Baseline: 2,300.42 ms
2,760.50 ms
(81.25%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,255.75 ms
(-2.56%)Baseline: 4,367.39 ms
5,240.87 ms
(81.20%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
198.56 ms
(-16.30%)Baseline: 237.22 ms
284.66 ms
(69.75%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
576.17 ms
(-11.58%)Baseline: 651.65 ms
781.99 ms
(73.68%)
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
🚷 view threshold
5.74 ms
(-23.92%)Baseline: 7.55 ms
9.06 ms
(63.40%)
isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
🚷 view threshold
5.67 ms
(-20.77%)Baseline: 7.15 ms
8.58 ms
(66.02%)
🐰 View full continuous benchmarking report in Bencher

@TrevorBurnham
TrevorBurnham force-pushed the fix/side-effects-cache-empty-overlay branch from c9a79da to 0dadabc Compare September 9, 2026 18:49
@TrevorBurnham
TrevorBurnham marked this pull request as ready for review September 9, 2026 19:24
Copilot AI lite review requested due to automatic review settings September 9, 2026 19:24
@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 →

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.

🟢 Approval recommended

The functional change is well-scoped, aligns v12 with v11 semantics for empty side-effects rows, and is covered by targeted unit + e2e regression tests.

Pull request overview

Fixes pacquet (pnpm v12) side-effects cache behavior so a “cache hit” only counts when there is actual in-package build output to restore; otherwise the importer must rebuild (matching pnpm v11 behavior). This addresses cases where build scripts have effects entirely outside the package directory (e.g. git-hook installers), which previously could be skipped with no materialization.

Changes:

  • Drop side-effects cache rows whose diff has nothing to restore (no added and no deleted), preventing false-positive “already built” decisions.
  • Add unit coverage in store-dir for empty-row drop behavior and “deletions-only” rows remaining valid hits.
  • Add an e2e fixture and regression test ensuring such builds re-run on consecutive installs.
File summaries
File Description
pnpr/.fixtures/packages/@pnpm.e2e/postinstall-writes-outside-package/1.0.0/package.json Adds a fixture package whose postinstall writes outside its own directory to reproduce the empty-diff scenario.
pnpm/crates/store-dir/src/check_pkg_files_integrity.rs Drops empty side-effects rows during overlay materialization so is_built isn’t satisfied by a no-op overlay.
pnpm/crates/store-dir/src/check_pkg_files_integrity/tests.rs Adds unit tests to pin empty-row drop semantics and preserve deletions-only behavior.
pnpm/crates/cli/tests/suite/side_effects_cache.rs Adds an e2e regression test asserting the postinstall runs on multiple installs when nothing can be restored from the cache.
.changeset/side-effects-cache-empty-overlay.md Adds a user-facing release note for the v12 fix.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 9, 2026
Copilot AI review requested due to automatic review settings September 9, 2026 19:59

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.

🟢 Approval recommended

The behavioral change is narrowly scoped, well-tested (unit + e2e), and aligns pacquet with pnpm 11’s handling of empty side-effects rows.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

pnpr/.fixtures/packages/@pnpm.e2e/postinstall-writes-outside-package/1.0.0/package.json:6

  • The postinstall script uses single quotes around the node -e snippet, which can be brittle across shells (and differs from other fixtures here that use node -e "..."). Prefer double quotes around the -e payload and use single quotes inside the JS for consistency and better portability.
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@zkochan
zkochan force-pushed the fix/side-effects-cache-empty-overlay branch from 325d054 to 2f211ea Compare September 10, 2026 06:26
Copilot AI review requested due to automatic review settings September 10, 2026 06:26

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Remote cache still skips empty builds ✓ Resolved 🐞 Bug ≡ Correctness
Description
overlay_for drops empty persisted diffs, but apply_resolved_artifact bypasses it and records an
accepted remote artifact with empty added and deleted lists as a base-only overlay. When a
published build changes only files outside its package, already_built treats that overlay as a hit
and skips the approved lifecycle script, so the external effect still never occurs for remote-cache
consumers.
Code

pnpm/crates/store-dir/src/check_pkg_files_integrity.rs[290]

+    if added.as_ref().is_none_or(HashMap::is_empty) && deleted.as_ref().is_none_or(Vec::is_empty) {
Relevance

●●● Strong

Remote artifacts bypass local filtering; empty remote diffs can falsely satisfy already_built and
skip required scripts.

PR-#14259

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The artifact protocol permits manifests with zero additions and deletions, and the publication path
submits diffs without rejecting that case. Remote resolution then clones the base map, records the
unchanged overlay directly, and the build gate treats any matching overlay as sufficient to skip
scripts, bypassing the newly added overlay_for predicate.

pnpm/crates/shared-artifact-protocol/src/lib.rs[530-559]
pnpm/crates/deps-restorer/src/shared_side_effects.rs[583-600]
pnpm/crates/deps-restorer/src/shared_side_effects.rs[610-647]
pnpm/crates/deps-restorer/src/shared_side_effects.rs[650-671]
pnpm/crates/deps-restorer/src/build_modules/build_one_snapshot.rs[252-273]

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

## Issue description
The new empty-row check applies only while reading persisted store-index rows. Empty remote artifacts bypass `overlay_for`, become base-only overlays, and still suppress lifecycle scripts whose effects occur outside the package directory.

## Fix Focus Areas
- pnpm/crates/store-dir/src/check_pkg_files_integrity.rs[285-297]
- pnpm/crates/deps-restorer/src/shared_side_effects.rs[583-671]
- pnpm/crates/deps-restorer/src/shared_side_effects.rs[1081-1167]

## Recommended Fix
Apply the same “nothing to restore” rule to resolved remote artifacts before inserting or persisting their overlays. Reject or ignore artifacts whose added and deleted collections are both empty so the local build runs, avoid publishing such empty artifacts where practical, and add a remote-cache regression test for an external-only build.

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



Remediation recommended

2. One release-note sentence mixes changes 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The final sentence combines consuming empty shared-cache artifacts with stopping publication of
those artifacts. Because these are separate read-path and write-path changes, readers cannot scan or
reuse either release-note item independently.
Code

.changeset/side-effects-cache-empty-overlay.md[5]

+`pnpm install` now runs a dependency's build scripts again when its side-effects cache entry has no files to restore. Such builds were skipped and nothing was put in their place, so a script whose whole effect lands outside its own package directory, such as a git-hook installer, never took effect. The same applies to an artifact from the shared side-effects cache, and pnpm no longer publishes such empty artifacts [#14717](https://github.com/pnpm/pnpm/issues/14717).
Relevance

●●● Strong

Recent reviews accept splitting compound changeset sentences describing separate user-visible
behaviors.

PR-#14736
PR-#14635

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3058304 requires each changeset sentence to describe one logical change. Line 5
joins the shared-cache restore behavior and publishing behavior with and in one sentence.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/side-effects-cache-empty-overlay.md[5-5]

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

## Issue description
The changeset's final sentence combines two distinct changes: handling empty artifacts from the shared cache and preventing publication of empty artifacts.

## Fix Focus Areas
- .changeset/side-effects-cache-empty-overlay.md[5-5]

## Recommended Fix
Split the final sentence so that consuming empty shared-cache artifacts and no longer publishing them are each described in a separate sentence.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 47 rules
✅ Cross-repo context — repo relationships
Review mode: 🧠 Deep: This push adds substantial behavior across independent deploy-resolution and side-effects-cache paths, including security/performance-sensitive install behavior, with many test and integration changes where multiple subtle defects could be missed in one pass.

Grey Divider

Tip of the day
💡 Did you know, you can turn these tips off under Display preferences

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit fcef09d

Results up to commit eff8032 ⚖️ Balanced


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


Action required
1. Remote cache still skips empty builds ✓ Resolved 🐞 Bug ≡ Correctness
Description
overlay_for drops empty persisted diffs, but apply_resolved_artifact bypasses it and records an
accepted remote artifact with empty added and deleted lists as a base-only overlay. When a
published build changes only files outside its package, already_built treats that overlay as a hit
and skips the approved lifecycle script, so the external effect still never occurs for remote-cache
consumers.
Code

pnpm/crates/store-dir/src/check_pkg_files_integrity.rs[290]

+    if added.as_ref().is_none_or(HashMap::is_empty) && deleted.as_ref().is_none_or(Vec::is_empty) {
Relevance

●●● Strong

Remote artifacts bypass local filtering; empty remote diffs can falsely satisfy already_built and
skip required scripts.

PR-#14259

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The artifact protocol permits manifests with zero additions and deletions, and the publication path
submits diffs without rejecting that case. Remote resolution then clones the base map, records the
unchanged overlay directly, and the build gate treats any matching overlay as sufficient to skip
scripts, bypassing the newly added overlay_for predicate.

pnpm/crates/shared-artifact-protocol/src/lib.rs[530-559]
pnpm/crates/deps-restorer/src/shared_side_effects.rs[583-600]
pnpm/crates/deps-restorer/src/shared_side_effects.rs[610-647]
pnpm/crates/deps-restorer/src/shared_side_effects.rs[650-671]
pnpm/crates/deps-restorer/src/build_modules/build_one_snapshot.rs[252-273]

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

## Issue description
The new empty-row check applies only while reading persisted store-index rows. Empty remote artifacts bypass `overlay_for`, become base-only overlays, and still suppress lifecycle scripts whose effects occur outside the package directory.

## Fix Focus Areas
- pnpm/crates/store-dir/src/check_pkg_files_integrity.rs[285-297]
- pnpm/crates/deps-restorer/src/shared_side_effects.rs[583-671]
- pnpm/crates/deps-restorer/src/shared_side_effects.rs[1081-1167]

## Recommended Fix
Apply the same “nothing to restore” rule to resolved remote artifacts before inserting or persisting their overlays. Reject or ignore artifacts whose added and deleted collections are both empty so the local build runs, avoid publishing such empty artifacts where practical, and add a remote-cache regression test for an external-only build.

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


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings September 10, 2026 06:33
@zkochan
zkochan force-pushed the fix/side-effects-cache-empty-overlay branch from 2f211ea to eff8032 Compare September 10, 2026 06:33

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

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

@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

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/14744
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
131.38 ms
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,365.80 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
250.60 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
242.46 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
87.19 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,294.03 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,330.84 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
211.71 ms
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
5.92 ms
isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
5.67 ms
🐰 View full continuous benchmarking report in Bencher

TrevorBurnham and others added 4 commits September 10, 2026 09:07
…store

A side-effects row is recorded whenever a build script ran, including a
build that changed nothing inside the package directory. `calculate_diff`
returns `added: None, deleted: None` for that case and the row is stored
anyway, so a package whose whole build effect lands elsewhere -- a
git-hook installer, a script seeding a shared download cache -- gets an
empty row.

`build_side_effects_maps` turned every row into an overlay, so an empty
one became an overlay equal to the base files and the `is_built` gate
took it as a hit. The scripts were skipped and nothing was materialized
in their place: the package directory after such an install is
byte-identical to the pristine tarball, and the build's effect never
happens at all. The cache key does not include the consuming project, so
this is not limited to reinstalls -- a project's first install can hit a
row an unrelated project seeded on the same machine.

pnpm 11 drops the row instead. Its `checkPkgFilesIntegrity` adds to
`sideEffectsMaps` only under `if (added) ... else if (deleted)`, so an
empty row matches neither branch, `sideEffectsCacheKey` is never set,
`isBuilt` stays false, and the build runs. Both stacks write the same
empty row and only their read paths differed, so this drops it at the
same point pnpm 11 does. An entry's presence now means there is build
output to materialize, which is what the `is_built` gate already assumed.

A row carrying only `deleted` still counts as a hit. That build did
happen and its effect is reproducible from the row.

`prefetch.rs` already filters an empty `side_effects_maps` out of the
prefetch result, so a package whose only row is dropped contributes no
entry at all and the frozen-install fast path in `build_phase` still
sees an empty table.

Closes #14717
Use `is_none_or(is_empty)` for the empty-diff check. It is the idiom the
rest of the workspace uses for exactly this shape, including
`build_phase.rs` in the subsystem this gate feeds.

Strip the ambient pnpm configuration from the `Command`s these tests
spawn directly. `CommandTempCwd` already does this for the commands it
builds, so the installs after the first were the only ones in the file
still inheriting `PNPM_CONFIG_*` from the developer's shell or from CI --
including `PNPM_CONFIG_SIDE_EFFECTS_CACHE`, which decides the behavior
under test. `run_frozen_install` had the same gap and gets the same
treatment: it drives the two tests that guard against this fix dropping
too much, so it has to be the one deciding the config.
Quote the fixture's `node -e` payload the way the sibling fixtures do so
it also runs under cmd.exe, state the empty-row rationale once in
`overlay_for` instead of in three places, share the frozen-install
command between the e2e tests, and lead the changeset with the
user-visible change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QpL16HSRQRoLWd3vgoKXt5
…s cache

The empty-row guard lived only in the store-index read path. The shared
remote cache bypassed it on both sides: the publisher uploaded an
artifact for any build, including one whose diff names no files, and
`apply_resolved_artifact` staged such an artifact as a base-only overlay
that the build phase took as a hit. Dropping the persisted row only sent
the consumer back to the server for the same empty artifact.

`SideEffectsDiff::is_empty` now carries the rule once. `overlay_for`
and the publisher use it, and the publisher returns early instead of
uploading. `ArtifactManifest::is_empty` guards the consumer before any
blob is downloaded, which also covers artifacts older versions already
published.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QpL16HSRQRoLWd3vgoKXt5
@zkochan
zkochan force-pushed the fix/side-effects-cache-empty-overlay branch from eff8032 to fcef09d Compare September 10, 2026 07:11
Copilot AI review requested due to automatic review settings September 10, 2026 07:11

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

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

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan
zkochan merged commit 2af57c1 into main Sep 10, 2026
33 checks passed
@zkochan
zkochan deleted the fix/side-effects-cache-empty-overlay branch September 10, 2026 07:19
biisal pushed a commit to biisal/pnpm that referenced this pull request Sep 15, 2026
…store (pnpm#14744)

A side-effects row is recorded whenever a build script ran, including a
build that changed nothing inside the package directory. `calculate_diff`
returns `added: None, deleted: None` for that case and the row is stored
anyway, so a package whose whole build effect lands elsewhere -- a
git-hook installer, a script seeding a shared download cache -- gets an
empty row.

`build_side_effects_maps` turned every row into an overlay, so an empty
one became an overlay equal to the base files and the `is_built` gate
took it as a hit. The scripts were skipped and nothing was materialized
in their place: the package directory after such an install is
byte-identical to the pristine tarball, and the build's effect never
happens at all. The cache key does not include the consuming project, so
this is not limited to reinstalls -- a project's first install can hit a
row an unrelated project seeded on the same machine.

pnpm 11 drops the row instead. Its `checkPkgFilesIntegrity` adds to
`sideEffectsMaps` only under `if (added) ... else if (deleted)`, so an
empty row matches neither branch, `sideEffectsCacheKey` is never set,
`isBuilt` stays false, and the build runs. Both stacks write the same
empty row and only their read paths differed, so this drops it at the
same point pnpm 11 does. An entry's presence now means there is build
output to materialize, which is what the `is_built` gate already assumed.

A row carrying only `deleted` still counts as a hit. That build did
happen and its effect is reproducible from the row.

`prefetch.rs` already filters an empty `side_effects_maps` out of the
prefetch result, so a package whose only row is dropped contributes no
entry at all and the frozen-install fast path in `build_phase` still
sees an empty table.

Closes pnpm#14717

---------

Co-authored-by: Zoltan Kochan <[email protected]>
zkochan pushed a commit that referenced this pull request Sep 26, 2026
…15859)

On Windows the post-build rehash cannot see the mode stored from the
tarball. pnpm 12 reports a fixed 0o644 and pnpm 11 reports the mode
from fs.stat (0o666, or 0o444 for a read-only file). The side-effects
diff treated that difference as an added file, so the row was never
empty.

Both stacks rebuild only when the row has nothing to restore
(#14744 for pnpm 12). A build whose whole effect lies outside
the package directory, such as a git hook installer, was treated as a
cache hit and skipped. Compare modes only where the rehash can observe
them.

Closes #15667

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Gabriel Mari S. Flores <[email protected]>
zkochan added a commit that referenced this pull request Oct 11, 2026
…#16843)

A rebuild with skipIfHasSideEffectsCache still ran the build of a package
whose side-effects row is empty: a build that changed nothing inside the
package, such as ssh2's install script when its optional native binding
cannot compile. Since #14744 the store's read path drops empty
rows from the overlays, so the is_built gate never sees them, and such a
package ran its script on every rebuild. An embedder that installs without
a modules directory and then rebuilds the pending packages re-ran these
scripts each time.

pnpm v11's rebuild checks only that the store index has a row for the
cache key (`pkgFilesIndex.sideEffects.has(key)`), empty or not. This
matches it: the build phase now also gets the raw rows, and a rebuild
with skip_if_has_side_effects_cache treats an empty row for the key as
built, with nothing to materialize, unless the package directory carries
the build marker of a global virtual store slot that was never built. The
dependency graph is built for the gate when such rows exist even if no
overlay does. The overlays and the rows travel together as
CachedSideEffects. An install keeps
running these builds, since their effect may lie outside the package
directory (#14717).
zkochan added a commit to kairosci/pnpm that referenced this pull request Oct 30, 2026
The loaded linker sent a build that changed nothing inside its package to
the global virtual store. pnpm drops an empty side-effects row on read
since pnpm#14744, so such a build never counted as a cache hit and
its package, with its whole dependency tree, got a directory. Real
packages hit this often: es5-ext's postinstall only prints a message.

The loaded linker, which is experimental, now restores an empty row as
an overlay of the package's pristine files, both from the store index
and right after a temporary build. Other projects that share the store
reuse the build without running its script, which matches how a shared
global virtual store directory already behaves. sideEffectsCache.exclude
is the opt-out for a script that must run in every project, and an
excluded package no longer goes through a temporary build. The other
linkers keep dropping empty rows; making them cache too is planned for
the next major in pnpm/tasks#242.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kairosci pushed a commit to kairosci/pnpm that referenced this pull request Nov 6, 2026
The loaded linker sent a build that changed nothing inside its package to
the global virtual store. pnpm drops an empty side-effects row on read
since pnpm#14744, so such a build never counted as a cache hit and
its package, with its whole dependency tree, got a directory. Real
packages hit this often: es5-ext's postinstall only prints a message.

The loaded linker, which is experimental, now restores an empty row as
an overlay of the package's pristine files, both from the store index
and right after a temporary build. Other projects that share the store
reuse the build without running its script, which matches how a shared
global virtual store directory already behaves. sideEffectsCache.exclude
is the opt-out for a script that must run in every project, and an
excluded package no longer goes through a temporary build. The other
linkers keep dropping empty rows; making them cache too is planned for
the next major in pnpm/tasks#242.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zkochan added a commit to kairosci/pnpm that referenced this pull request Nov 7, 2026
The loaded linker sent a build that changed nothing inside its package to
the global virtual store. pnpm drops an empty side-effects row on read
since pnpm#14744, so such a build never counted as a cache hit and
its package, with its whole dependency tree, got a directory. Real
packages hit this often: es5-ext's postinstall only prints a message.

The loaded linker, which is experimental, now restores an empty row as
an overlay of the package's pristine files, both from the store index
and right after a temporary build. Other projects that share the store
reuse the build without running its script, which matches how a shared
global virtual store directory already behaves. sideEffectsCache.exclude
is the opt-out for a script that must run in every project, and an
excluded package no longer goes through a temporary build. The other
linkers keep dropping empty rows; making them cache too is planned for
the next major in pnpm/tasks#242.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zkochan added a commit that referenced this pull request Nov 7, 2026
…7318)

* feat(store-loader): complete temporary builds and materialization

* fix(store-loader): remove obsolete cycle cache warmup

* fix(store-loader): keep cache keys for snapshots outside a temporary build

The temporary-build pass handed the later materialization pass cache
keys for its build candidates only. A cold snapshot outside them, such
as a `nodeLinker.excluded` package, then hit the "derived a cache key
for every lockfile snapshot" panic. The handoff now keeps the keys of
every retained snapshot.

Also:
- proceed unserialized when the global virtual store slot lock is not
  available, as the lock's other callers do;
- rename the output `SnapshotSelection` to `SnapshotPlacement`, which
  no longer shares a name with the input selection;
- merge the two overlapping changesets and stop describing approved
  cache misses as materialized;
- restore the doc comments dropped from retained items.

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

* fix(store-loader): carry the final loaded selection into the build phase

The loaded linker's output covered only the snapshots its
materialization pass installed. The build metadata of loaded and
promoted snapshots now comes from the fetch pass, so the list of
dependencies requiring a build includes them. The build phase's
post-build bin relinking now sees every physical snapshot, including
those materialized automatically, not only the `nodeLinker.excluded`
closure.

The changeset now qualifies which builds run in a temporary directory
and says the filesystem-access scan misses computed imports.

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

* fix(store-loader): keep a rebuilt slot's withheld cache overlay withheld

Merging the fetch pass's side-effects overlays into the loaded
linker's output restored the overlay the materialization pass withholds
from a slot that must be rebuilt, such as one with a build marker. The
build phase then took the cached output and skipped the lifecycle
scripts. The fetch pass now fills in build metadata only for the
snapshots the materialization pass did not install.

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

* fix(store-loader): stop merging fetch-pass build metadata into the output

Filling in `requiresBuild` and the side-effects overlays of the loaded
and promoted snapshots from the fetch pass exposed them to the build
phase. Under the global virtual store, the build phase resolves every
snapshot to its slot path whether or not the slot exists. A CAS-loaded
build package then became a build candidate for a slot the loaded
linker never created. The output again carries the materialization
pass's metadata only.

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

* fix(store-loader): report loaded build packages as requiring a build

The list of dependencies requiring a build came from the build phase's
`requiresBuild` map. That map covers only the snapshots the loaded
linker materialized, so CAS-loaded and promoted build packages were left
out. They are now recorded on the snapshot placement and added to the
reported list. The build phase still never sees them.

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

* fix(store-loader): load builds that change no package files from CAS

The loaded linker sent a build that changed nothing inside its package to
the global virtual store. pnpm drops an empty side-effects row on read
since #14744, so such a build never counted as a cache hit and
its package, with its whole dependency tree, got a directory. Real
packages hit this often: es5-ext's postinstall only prints a message.

The loaded linker, which is experimental, now restores an empty row as
an overlay of the package's pristine files, both from the store index
and right after a temporary build. Other projects that share the store
reuse the build without running its script, which matches how a shared
global virtual store directory already behaves. sideEffectsCache.exclude
is the opt-out for a script that must run in every project, and an
excluded package no longer goes through a temporary build. The other
linkers keep dropping empty rows; making them cache too is planned for
the next major in pnpm/tasks#242.

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

* fix(store-loader): reuse a dependency's empty build in a temporary build

A temporary build takes its side-effects overlays from its own pass,
which reads the retained prefetch rows. Those rows still dropped an
empty build, so a cache miss that depends on a package whose build
changed no files ran that dependency's script again.

The overlays that restore_empty_builds adds now go to the retained
prefetch as well, the way an overlay captured after a temporary build
already does. The later passes apply their own build-marker and
sideEffectsCache.exclude checks to them.

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

* fix(store-loader): restore empty builds in the partition

restore_empty_builds added an overlay of the package's files for every
snapshot whose row had an empty build, after the partition had already
decided which snapshots' overlays to withhold. A peer variant with a
build marker got the overlay anyway. Copying that variant's map into the
retained prefetch row, which its peer variants share, could also drop
an overlay another variant still needed.

The partition now adds the overlay itself, for the snapshots it does not
withhold, whenever the configured node linker is loaded. Every pass of
a loaded install reads the shared rows the same way, so nothing rewrites
them. After a temporary build, the captured result updates only its own
cache key in the shared row.

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

* fix(deps-restorer): import slot metadata types

* fix(store-loader): align materialization with current APIs

* fix(store-loader): satisfy Rust workspace checks

* fix(deps-restorer): rerun builds without cached effects

* fix(store-loader): keep junction links when promoting temporary builds

Promoting a temporary build retargets the slot's dependency links. On
Windows without symlink privileges those links are junctions, and
recreating them through the plain symlink API failed. Directory links now
go through the junction-aware helper, and the link target is compared
without its verbatim prefix.

Also replace the `restores_empty_builds` flag with an `EmptyBuilds` enum
and log the store manifest in the loaded-linker build tests.

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

* fix(store-loader): build in the global virtual store when a runtime is pinned

A temporary build's graph holds only the built package's dependencies,
so it ran on the host Node.js even when the root project pins one with a
`runtime:` dependency. The result was still cached under the pinned
runtime's engine. Such installs now skip temporary builds, and the
packages build in the global virtual store on the pinned runtime.

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

* fix(store-loader): honor --no-runtime and stop copying CAS file maps

A pinned runtime that the install skips no longer turns temporary builds
off, since builds then run on the host Node.js either way. The loader
manifest now reads each package's CAS paths in place without copying
them into an intermediate map. The changeset names pnpm as the actor
that materializes packages.

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

---------

Co-authored-by: Zoltan Kochan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 12 skips a dependency's build script on a side-effects cache hit that has nothing to restore

4 participants