Skip to content

fix: hardlink store files whose mode differs from the umask only in write bits - #16678

Merged
zkochan merged 3 commits into
mainfrom
fix/16677-hardlink-group-writable-store
Oct 7, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix/16677-hardlink-group-writable-store

Conversation

@zkochan

@zkochan zkochan commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #16677.

Since #15882, a store write takes group-write from the shard directory and never sets other-write. The importer (pnpm/pnpm#15646) still hardlinks a store inode only if its mode is exactly what the current umask gives a fresh file. In the reported setup (umask 000, 0777 store), store entries are 0664/0775 but the umask asks for 0666/0755, so every file was copied. Installs were about 30% slower. Executables in a 0775 store under umask 002 hit the same mismatch.

The hardlink tiers now ignore group-write and other-write when the store inode is missing them, and an extra group-write bit. The shared inode already grants those bits through the store. Read, execute, owner, and extra other-write bits must still match, so the #3807 case (a store populated under 022, installed under 077) still copies. The copy and clone tiers still materialize at the umask's mode.

Both CLIs had the bug and both are fixed:

  • pnpm v12: pnpm_fs::file_mode::store_inode_mode_is_linkable, used by source_has_desired_mode.
  • pnpm v11: isLinkableStoreMode in @pnpm/fs.indexed-pkg-importer.

Tests (the new ones fail with the exact-match check restored):

  • umask::installs_hardlink_from_a_world_writable_store_under_umask_000: the issue's scenario, end to end.
  • Unit tests for the predicate (every inherited_file_mode directory/umask combination it should accept, plus the differences it must still reject) and for the hardlink tier in both stacks.

Squash Commit Body

Since pnpm/pnpm#15882 a store write takes group-write from the shard
directory and never sets other-write, while the importer (pnpm/pnpm#15646)
linked a store inode only if its mode was exactly what the current umask
gives a fresh file. Under umask 000 with a 0777 store the entries are
0664/0775 and the umask asks for 0666/0755, so every file was copied. The
same happens to executables in a 0775 store under umask 002.

The hardlink tiers now ignore missing group- and other-write bits and an
extra group-write bit. The shared inode already grants those through the
store. Read, execute, owner and other-write bits must still match, so a
store populated under umask 022 is still copied into an install under 077.
The copy and clone tiers keep materializing at the umask's mode.

Fixed in both pnpm v12 and pnpm v11.

Closes pnpm/pnpm#16677

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

🤖 Generated with Claude Code


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


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

Summary by CodeRabbit

  • Bug Fixes
    • pnpm install can hardlink files from group-writable or world-writable stores when their permissions are otherwise compatible with the installed files. Previously, these files could be copied into node_modules instead.

zkochan and others added 2 commits October 7, 2026 01:32
…rite bits

Since #15882 a store write takes group-write from the shard
directory and never sets other-write, while the importer (pnpm/pnpm#15646)
linked a store inode only if its mode was exactly what the current umask
gives a fresh file. Under umask 000 with a 0777 store the entries are
0664/0775 and the umask asks for 0666/0755, so every file was copied. The
same happens to executables in a 0775 store under umask 002.

The hardlink tiers now ignore missing group- and other-write bits and an
extra group-write bit. The shared inode already grants those through the
store. Read, execute, owner and other-write bits must still match, so a
store populated under umask 022 is still copied into an install under 077.
The copy and clone tiers keep materializing at the umask's mode.

Fixes #16677

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

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08388bdb-3319-44b3-b1c1-512d4f9c1625
📥 Commits

Reviewing files that changed from the base of the PR and between 40468fb and 5159d8d.

📒 Files selected for processing (1)
  • .changeset/hardlink-group-writable-store.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/hardlink-group-writable-store.md

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


📝 Walkthrough

Walkthrough

The Rust and pnpm 11 importers now permit specified store-file write-bit differences when checking hardlink eligibility. Tests cover permission mismatches and verify that installed files share inodes with store entries.

Changes

Store hardlink eligibility

Layer / File(s) Summary
Rust store-mode linkability
pnpm/crates/fs/src/file_mode.rs, pnpm/crates/deps-restorer/src/link_file/target_mode.rs, pnpm/crates/fs/src/file_mode/tests.rs, pnpm/crates/deps-restorer/src/link_file/tests/installation.rs, pnpm/crates/cli/tests/suite/umask.rs, .changeset/hardlink-group-writable-store.md
The Rust code adds a shared predicate for store-mode linkability and uses it in link-file checks on Unix and WASI. Unit and installation tests cover accepted and rejected permission differences, including hardlinks from a world-writable store. The changeset declares patch releases for three packages.
pnpm 11 importer linkability
pnpm11/fs/indexed-pkg-importer/src/index.ts, pnpm11/fs/indexed-pkg-importer/test/umaskImport.test.ts
The importer allows specified write-bit differences in its store-mode comparison. A Linux test checks that imported executable and plain files share inodes with their store entries.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
[#16677] Retain hardlinking when store and checkout permissions differ under umask 0000, without changing existing shared-store files. ✅

Suggested labels: product: pnpm@11, product: pacquet

Merge Risk: ⚪ Minimal · up to 5159d

The changed permission checks support hardlinking from writable stores without an identified permission regression. The PR is mergeable after normal checks.

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

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

❤️ Share

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

@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.36%. Comparing base (629bd20) to head (5159d8d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16678   +/-   ##
=======================================
  Coverage   92.35%   92.36%           
=======================================
  Files        1591     1591           
  Lines      210207   210211    +4     
=======================================
+ Hits       194145   194156   +11     
+ Misses      16062    16055    -7     

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

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     13.8±0.36ms    27.1 MB/sec    1.11     15.3±3.70ms    24.4 MB/sec
packument/parse                                  1.09     51.0±9.87µs  1300.4 MB/sec    1.00     46.6±0.83µs  1422.9 MB/sec
tarball/download_dependency                      1.00      7.2±1.03ms   600.0 KB/sec    1.13      8.2±1.53ms   530.9 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   278.3±21.58ms 57.5 KElem/sec    1.01   281.7±19.07ms 56.8 KElem/sec
version_pick/repeated_ranges_file                1.00      4.1±0.17ms  7.6 KElem/sec    1.23      5.1±1.20ms  6.2 KElem/sec
version_pick/repeated_ranges_raw                 1.00      4.2±0.15ms  7.5 KElem/sec    1.21      5.0±0.90ms  6.2 KElem/sec
workspace_resolution/hoist_heavy                 1.00   233.9±20.33ms        ? ?/sec    1.23    287.9±8.00ms        ? ?/sec
workspace_sort/chained_projects                  1.00     15.2±1.33ms        ? ?/sec    1.39     21.2±4.66ms        ? ?/sec

@github-actions

github-actions Bot commented Oct 6, 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 2537.82 ms 2454.43 ms -3.3% 126.89 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1520.65 ms 1429.77 ms -6.0% 76.03 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 340.53 ms 342.20 ms 0.5% 17.03 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 326.32 ms 358.87 ms 10.0% 16.32 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 16.86 ms 16.76 ms -0.6% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 13.64 ms 18.18 ms 33.3% 2.00 ms Inconclusive (overlapping samples)
isolated-repeat-install-cold-cache-hot-store pacquet 13.23 ms 13.63 ms 3.0% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 14.23 ms 12.47 ms -12.4% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 3030.82 ms 3182.31 ms 5.0% 151.54 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1744.26 ms 1714.83 ms -1.7% 87.21 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 1041.87 ms 537.64 ms -48.4% 52.09 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 541.08 ms 542.67 ms 0.3% 27.05 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1784.35 ms 1765.79 ms -1.0% 89.22 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 391.13 ms 329.62 ms -15.7% 19.56 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 323.48 ms 322.89 ms -0.2% 16.17 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 106.51 ms 111.26 ms 4.5% 5.33 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 252.19 ms 275.92 ms 9.4% 12.61 ms Inconclusive (overlapping samples)
isolated-linked-workspace-resolve-hot-cache-offline pacquet 297.19 ms 296.09 ms -0.4% 14.86 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4431.37 ms 4916.01 ms 10.9% 221.57 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3604.54 ms 3681.44 ms 2.1% 180.23 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 240.09 ms 229.32 ms -4.5% 12.00 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 281.29 ms 290.04 ms 3.1% 14.06 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 5159d8da7fdf

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

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.543 ± 0.174 2.397 2.866 1.78 ± 0.14
pacquet@main 2.568 ± 0.101 2.454 2.746 1.79 ± 0.09
pnpr@HEAD 1.431 ± 0.050 1.354 1.509 1.00
pnpr@main 1.541 ± 0.105 1.388 1.681 1.08 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.54291351804,
      "stddev": 0.17421741974705407,
      "median": 2.4544269409400004,
      "user": 1.9656473399999996,
      "system": 1.9229281199999995,
      "min": 2.39730709494,
      "max": 2.86577497594
    },
    {
      "command": "pacquet@main",
      "mean": 2.56847220804,
      "stddev": 0.10066423224766345,
      "median": 2.5378162489400005,
      "user": 2.0081748399999997,
      "system": 1.9987833199999998,
      "min": 2.45437453694,
      "max": 2.74607925694
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.43140251994,
      "stddev": 0.04995666350064989,
      "median": 1.42977279944,
      "user": 1.7205237399999997,
      "system": 1.6401546199999995,
      "min": 1.3543615779400002,
      "max": 1.5085712989400002
    },
    {
      "command": "pnpr@main",
      "mean": 1.54095702734,
      "stddev": 0.10506681894668182,
      "median": 1.5206502744400001,
      "user": 1.6912185400000002,
      "system": 1.66520512,
      "min": 1.38811861794,
      "max": 1.68086170694
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 353.0 ± 44.0 300.8 441.7 1.08 ± 0.14
pacquet@main 336.8 ± 42.8 261.2 414.2 1.03 ± 0.14
pnpr@HEAD 357.1 ± 27.4 301.8 388.1 1.09 ± 0.10
pnpr@main 327.6 ± 15.5 303.3 358.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35299491204,
      "stddev": 0.04401619008461102,
      "median": 0.34219613764,
      "user": 0.42441611999999995,
      "system": 0.8089231,
      "min": 0.30079480214000004,
      "max": 0.44165857514
    },
    {
      "command": "pacquet@main",
      "mean": 0.33675883204,
      "stddev": 0.042795414559918504,
      "median": 0.34053374664,
      "user": 0.40332771999999995,
      "system": 0.781026,
      "min": 0.26118988314,
      "max": 0.41421537214000004
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.35708751454,
      "stddev": 0.02737596626429473,
      "median": 0.35886951414,
      "user": 0.4172145199999999,
      "system": 0.7803673000000001,
      "min": 0.30179112514,
      "max": 0.38807916614000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.32757435444000005,
      "stddev": 0.015470271783486289,
      "median": 0.32631590264000004,
      "user": 0.38249711999999997,
      "system": 0.7079614999999999,
      "min": 0.30330645114000004,
      "max": 0.35806247014000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 17.1 ± 2.7 12.5 27.0 1.20 ± 0.32
pacquet@main 16.9 ± 2.9 11.0 28.7 1.18 ± 0.33
pnpr@HEAD 18.3 ± 2.6 12.7 26.4 1.28 ± 0.33
pnpr@main 14.3 ± 3.1 10.7 29.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.017114173026493505,
      "stddev": 0.0027099592993879893,
      "median": 0.01676058852,
      "user": 0.010133109350649351,
      "system": 0.008598195324675331,
      "min": 0.012479055020000001,
      "max": 0.02701623102
    },
    {
      "command": "pacquet@main",
      "mean": 0.016893545681111115,
      "stddev": 0.0029101203141083266,
      "median": 0.01685674852,
      "user": 0.010044543333333327,
      "system": 0.008477892999999995,
      "min": 0.011004894020000001,
      "max": 0.02865357802
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.018266975788707483,
      "stddev": 0.0025596724483496042,
      "median": 0.01818328802,
      "user": 0.010101531428571427,
      "system": 0.009804611836734695,
      "min": 0.01269749302,
      "max": 0.02643237802
    },
    {
      "command": "pnpr@main",
      "mean": 0.014310142540833327,
      "stddev": 0.003118590248906625,
      "median": 0.013639143020000001,
      "user": 0.007340918333333333,
      "system": 0.008352312638888883,
      "min": 0.010653325020000002,
      "max": 0.02945960802
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 13.9 ± 1.9 9.9 19.0 1.10 ± 0.22
pacquet@main 13.3 ± 1.4 10.2 16.8 1.05 ± 0.18
pnpr@HEAD 12.7 ± 1.7 9.0 19.2 1.00
pnpr@main 14.3 ± 1.8 9.8 21.4 1.13 ± 0.21
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.013925427573793106,
      "stddev": 0.0019432067683280059,
      "median": 0.013631196160000001,
      "user": 0.0076424193103448255,
      "system": 0.007885406321839079,
      "min": 0.00989962416,
      "max": 0.01898859916
    },
    {
      "command": "pacquet@main",
      "mean": 0.013304844332839514,
      "stddev": 0.0013993529541677537,
      "median": 0.013234796160000001,
      "user": 0.007779083209876546,
      "system": 0.007049907654320987,
      "min": 0.010211744160000001,
      "max": 0.016783248160000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.012685755336795577,
      "stddev": 0.001746204173371218,
      "median": 0.01246549616,
      "user": 0.007108625635359113,
      "system": 0.006985224530386737,
      "min": 0.00903862416,
      "max": 0.01916203916
    },
    {
      "command": "pnpr@main",
      "mean": 0.014336889370526313,
      "stddev": 0.0017666780914988144,
      "median": 0.014228381160000001,
      "user": 0.00782740842105263,
      "system": 0.008075217789473689,
      "min": 0.00977951416,
      "max": 0.021363660160000002
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.214 ± 0.137 3.054 3.436 1.84 ± 0.12
pacquet@main 3.031 ± 0.048 2.939 3.098 1.74 ± 0.09
pnpr@HEAD 1.766 ± 0.101 1.665 1.965 1.01 ± 0.08
pnpr@main 1.744 ± 0.089 1.633 1.877 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.21421756398,
      "stddev": 0.1366983598432672,
      "median": 3.18231046888,
      "user": 3.96356232,
      "system": 2.95590068,
      "min": 3.05421442738,
      "max": 3.43552102638
    },
    {
      "command": "pacquet@main",
      "mean": 3.03063791598,
      "stddev": 0.04778335537495358,
      "median": 3.0308236518799996,
      "user": 3.5500247199999997,
      "system": 2.80183228,
      "min": 2.93899438638,
      "max": 3.09752253338
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.76612456398,
      "stddev": 0.10132053378088728,
      "median": 1.7148272353800003,
      "user": 2.22141212,
      "system": 2.1378613799999995,
      "min": 1.6650825323800003,
      "max": 1.96475570838
    },
    {
      "command": "pnpr@main",
      "mean": 1.7444604256800003,
      "stddev": 0.08943641003497743,
      "median": 1.74425964388,
      "user": 2.29868732,
      "system": 2.1007819800000003,
      "min": 1.6330849533800003,
      "max": 1.87689356238
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 583.9 ± 115.6 494.2 830.4 1.09 ± 0.23
pacquet@main 1051.7 ± 201.5 712.0 1338.5 1.96 ± 0.41
pnpr@HEAD 556.2 ± 67.2 441.6 658.2 1.04 ± 0.15
pnpr@main 536.6 ± 44.4 442.1 601.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5839188430000001,
      "stddev": 0.11561869484153099,
      "median": 0.5376438744,
      "user": 0.80835472,
      "system": 0.8806220999999999,
      "min": 0.4942116134000001,
      "max": 0.8303712234
    },
    {
      "command": "pacquet@main",
      "mean": 1.0516578705000001,
      "stddev": 0.20152728193145195,
      "median": 1.0418701819,
      "user": 1.3494051200000001,
      "system": 1.2948193,
      "min": 0.7119988694,
      "max": 1.3384666433999999
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.5562416237999999,
      "stddev": 0.06719484040592406,
      "median": 0.5426724689,
      "user": 0.54880292,
      "system": 0.8909059999999999,
      "min": 0.44163084340000003,
      "max": 0.6582049894
    },
    {
      "command": "pnpr@main",
      "mean": 0.536616911,
      "stddev": 0.04441516939970525,
      "median": 0.5410777989,
      "user": 0.50017432,
      "system": 0.8785971,
      "min": 0.4421281074,
      "max": 0.6010795034
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.769 ± 0.054 1.706 1.888 5.35 ± 0.31
pacquet@main 1.799 ± 0.071 1.699 1.944 5.44 ± 0.34
pnpr@HEAD 0.331 ± 0.016 0.301 0.354 1.00
pnpr@main 0.394 ± 0.051 0.333 0.497 1.19 ± 0.17
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7690654962999997,
      "stddev": 0.054477978230148105,
      "median": 1.7657891938999999,
      "user": 1.2107857599999996,
      "system": 1.0251091799999998,
      "min": 1.7059366714000002,
      "max": 1.8875329364
    },
    {
      "command": "pacquet@main",
      "mean": 1.7990816331000001,
      "stddev": 0.07142574146884387,
      "median": 1.7843529624,
      "user": 1.2652577599999997,
      "system": 1.0624649800000001,
      "min": 1.6985601194,
      "max": 1.9441689784
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33061945820000005,
      "stddev": 0.016112072846613163,
      "median": 0.3296161139,
      "user": 0.30754856,
      "system": 0.6534470800000001,
      "min": 0.3007582184,
      "max": 0.3536413654
    },
    {
      "command": "pnpr@main",
      "mean": 0.39364947620000007,
      "stddev": 0.05136003630662147,
      "median": 0.3911331899,
      "user": 0.37772716,
      "system": 0.75647038,
      "min": 0.3326502644,
      "max": 0.4971408104
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 317.0 ± 26.4 275.7 348.4 2.97 ± 0.29
pacquet@main 327.2 ± 14.5 308.2 352.3 3.07 ± 0.21
pnpr@HEAD 112.1 ± 5.1 104.1 122.7 1.05 ± 0.07
pnpr@main 106.6 ± 5.6 95.6 119.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.31700348966,
      "stddev": 0.026375708732749803,
      "median": 0.32289281306,
      "user": 0.31960822,
      "system": 0.13504091999999998,
      "min": 0.27565816906,
      "max": 0.34838277206
    },
    {
      "command": "pacquet@main",
      "mean": 0.32718929166000005,
      "stddev": 0.014513374691795942,
      "median": 0.32347522706,
      "user": 0.33711112,
      "system": 0.14104002,
      "min": 0.30820739506,
      "max": 0.35233944006
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11208326165259258,
      "stddev": 0.005078731778496654,
      "median": 0.11125816506,
      "user": 0.051727349629629625,
      "system": 0.023618379259259255,
      "min": 0.10410226706,
      "max": 0.12266938306
    },
    {
      "command": "pnpr@main",
      "mean": 0.10656878380074072,
      "stddev": 0.00555494914173323,
      "median": 0.10651434006,
      "user": 0.04546531259259258,
      "system": 0.022958971851851844,
      "min": 0.09557257106,
      "max": 0.11958040206000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 278.3 ± 17.2 252.7 305.7 1.04 ± 0.14
pacquet@main 267.9 ± 31.7 230.4 331.4 1.00
pnpm@HEAD 4647.7 ± 398.0 4231.3 5446.6 17.35 ± 2.54
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.27825129760444445,
      "stddev": 0.017180931094773463,
      "median": 0.27592497816,
      "user": 0.2981484022222222,
      "system": 0.07391413333333333,
      "min": 0.25266716216,
      "max": 0.30569802516
    },
    {
      "command": "pacquet@main",
      "mean": 0.2678543049377778,
      "stddev": 0.03173714863246054,
      "median": 0.25218762316000004,
      "user": 0.28127273555555554,
      "system": 0.06379546666666666,
      "min": 0.23041181416,
      "max": 0.33140162616
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.647717805715556,
      "stddev": 0.3979517657274687,
      "median": 4.549352622160001,
      "user": 7.506138735555556,
      "system": 0.4526606888888888,
      "min": 4.23130857916,
      "max": 5.446565538160001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 294.0 ± 31.2 246.1 335.3 1.00
pacquet@main 298.3 ± 30.7 253.2 348.3 1.01 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29402889356,
      "stddev": 0.0312373390397292,
      "median": 0.29608841646,
      "user": 0.24749791999999998,
      "system": 0.10892945999999999,
      "min": 0.24610711796000004,
      "max": 0.33528617096
    },
    {
      "command": "pacquet@main",
      "mean": 0.29834205276000003,
      "stddev": 0.030693707427244907,
      "median": 0.29719001996000005,
      "user": 0.24088491999999997,
      "system": 0.12017285999999998,
      "min": 0.25315586996,
      "max": 0.34826667196
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 5.014 ± 0.468 4.461 6.087 1.39 ± 0.13
pacquet@main 4.482 ± 0.117 4.361 4.663 1.24 ± 0.04
pnpr@HEAD 3.699 ± 0.162 3.475 3.965 1.03 ± 0.05
pnpr@main 3.602 ± 0.079 3.500 3.719 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 5.014367461699999,
      "stddev": 0.4675337050768796,
      "median": 4.9160053137999995,
      "user": 2.26832048,
      "system": 2.0945902199999997,
      "min": 4.4608742283,
      "max": 6.086691174299999
    },
    {
      "command": "pacquet@main",
      "mean": 4.4817917387,
      "stddev": 0.11677426582394117,
      "median": 4.4313725163,
      "user": 1.6058864799999994,
      "system": 1.49396132,
      "min": 4.3614837213,
      "max": 4.6631922283
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.6990501191000007,
      "stddev": 0.16181388595841462,
      "median": 3.6814424908000003,
      "user": 1.76283658,
      "system": 1.6887371199999996,
      "min": 3.4746964813,
      "max": 3.9648128103
    },
    {
      "command": "pnpr@main",
      "mean": 3.6015567896,
      "stddev": 0.07932450847200109,
      "median": 3.6045360403,
      "user": 1.7624789799999998,
      "system": 1.53601902,
      "min": 3.4997623043000003,
      "max": 3.7186461573000003
    }
  ]
}

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 229.5 ± 12.4 209.1 251.5 1.00
pacquet@main 238.0 ± 17.3 205.4 262.2 1.04 ± 0.09
pnpr@HEAD 286.9 ± 20.2 258.5 314.5 1.25 ± 0.11
pnpr@main 277.0 ± 20.6 241.1 300.9 1.21 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.22947147844363636,
      "stddev": 0.012370950920467461,
      "median": 0.22931846908,
      "user": 0.27692881999999996,
      "system": 0.20088119636363636,
      "min": 0.20911959408,
      "max": 0.25145397908000006
    },
    {
      "command": "pacquet@main",
      "mean": 0.23797715798000002,
      "stddev": 0.01730785947825281,
      "median": 0.24008924458,
      "user": 0.28787602,
      "system": 0.19506996000000001,
      "min": 0.20540119008000002,
      "max": 0.26223237008000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2868678901800001,
      "stddev": 0.02018893929485055,
      "median": 0.29004465658,
      "user": 0.32477181999999993,
      "system": 0.19986025999999996,
      "min": 0.25853460708000003,
      "max": 0.31445126808000007
    },
    {
      "command": "pnpr@main",
      "mean": 0.27702241248000004,
      "stddev": 0.020557769567444487,
      "median": 0.28128662758,
      "user": 0.32296402,
      "system": 0.17328046,
      "min": 0.24114375708000002,
      "max": 0.30089093308000003
    }
  ]
}

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

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

PR Summary by Qodo

Restore hardlinks for store files with compatible write-bit differences

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Allow both pnpm CLIs to hardlink store files when only permitted write bits differ from the umask.
• Preserve copying for incompatible permissions and keep copied or cloned files at the umask-derived
 mode.
• Add permission checks and importer tests, including an end-to-end world-writable store regression.
Diagram

graph TD
  Store["CAS store inode"] --> Rust["v12 importer"] --> RustCheck{"Mode linkable?"} -->|Yes| Link["Shared hardlink"]
  Store --> TS["v11 importer"] --> TSCheck{"Mode linkable?"} -->|Yes| Link
  RustCheck -->|No| Copy["Aligned copy"]
  TSCheck -->|No| Copy
Loading
High-Level Assessment

Keep the predicate in each affected import stack. Changing shared store-inode permissions would affect other installs, while copying every mismatch retains the reported performance regression. The bounded write-bit exception preserves hardlinks without relaxing read, execute, owner-write, or extra other-write checks.

Files changed (8) +169 / -8

Bug fix (3) +34 / -8
target_mode.rsUse linkable-mode checks in the Rust hardlink path +10/-7

Use linkable-mode checks in the Rust hardlink path

• Replaces exact mode equality with the shared store-inode predicate on Unix and WASI. Incompatible store files still fall back to materialization.

pnpm/crates/deps-restorer/src/link_file/target_mode.rs

file_mode.rsDefine which store-inode modes are safe to hardlink +14/-0

Define which store-inode modes are safe to hardlink

• Adds a predicate that tolerates missing group- or other-write and extra group-write. Other mode differences, including extra other-write, remain disqualifying.

pnpm/crates/fs/src/file_mode.rs

index.tsApply the compatible-mode rule to v11 hardlink imports +10/-1

Apply the compatible-mode rule to v11 hardlink imports

• Replaces exact store-mode comparison with the equivalent TypeScript linkability predicate. The copy fallback remains in place for incompatible modes.

pnpm11/fs/indexed-pkg-importer/src/index.ts

Tests (4) +128 / -0
umask.rsVerify hardlinks from a world-writable store under umask 000 +43/-0

Verify hardlinks from a world-writable store under umask 000

• Adds an end-to-end install test for executable and plain files. It checks their inherited modes and confirms that their installed inodes match store inodes.

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

installation.rsCheck that a group-write difference retains the store inode +20/-0

Check that a group-write difference retains the store inode

• Adds a hardlink-tier regression test that toggles only group-write on a CAS entry and verifies inode sharing.

pnpm/crates/deps-restorer/src/link_file/tests/installation.rs

tests.rsCover accepted and rejected store-mode differences +48/-0

Cover accepted and rejected store-mode differences

• Tests directory-mode and umask combinations for plain and executable entries. Negative cases protect read, execute, owner-write, and extra other-write checks.

pnpm/crates/fs/src/file_mode/tests.rs

umaskImport.test.tsVerify v11 shares inodes across group-write differences +17/-0

Verify v11 shares inodes across group-write differences

• Adds a Linux hardlink-tier test for executable and plain store entries whose group-write bit differs from the umask-derived mode.

pnpm11/fs/indexed-pkg-importer/test/umaskImport.test.ts

Documentation (1) +7 / -0
hardlink-group-writable-store.mdDocument patch releases for restored hardlinking +7/-0

Document patch releases for restored hardlinking

• Adds a patch changeset for pnpm, pacquet, and the v11 indexed-package importer. It describes the unnecessary copies from writable stores and links the issue.

.changeset/hardlink-group-writable-store.md

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

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 📜 Skill insights (1)

Grey Divider


Remediation recommended

1. Release note explains implementation ✓ Resolved
Description
The changeset explains group-write inheritance, umask matching, and copying into node_modules
instead of limiting the entry to observable behavior. This implementation detail is triggered in the
release-note paragraph and makes the published summary describe internal permission mechanics rather
than only what pnpm install now does.
Code

.changeset/hardlink-group-writable-store.md[7]

+`pnpm install` hardlinks files from a group-writable or world-writable store again. Since store files take their group-write bit from the store directory, they did not match the install's umask, and pnpm copied every file into `node_modules` [#16677](https://github.com/pnpm/pnpm/issues/16677).
Evidence
The checklist requires changeset entries to describe observable behavior only and disallows design
or implementation justification clauses. The added sentence describes how store files obtain
permission bits and why their modes differ from the umask.

Rule 3058322: Changeset entries must describe observable behavior changes only
.changeset/hardlink-group-writable-store.md[7-7]

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 second sentence describes internal store permission and umask mechanics. Release-note entries should state only the observable install behavior and omit implementation rationale.

## Fix Focus Areas
- .changeset/hardlink-group-writable-store.md[7-7]

## Recommended Fix
Remove the implementation explanation from the changeset entry and retain a concise statement that `pnpm install` hardlinks files from group-writable or world-writable stores again.

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


2. Release note mixes tenses ✓ Resolved
Description
The changeset's second sentence uses present tense for store files take and past tense for `did
not match and copied every file` in the same account of the defect. Because the old behavior is
not expressed as a clearly past-tense sentence, readers may not distinguish the historical failure
from the corrected behavior.
Code

.changeset/hardlink-group-writable-store.md[7]

+`pnpm install` hardlinks files from a group-writable or world-writable store again. Since store files take their group-write bit from the store directory, they did not match the install's umask, and pnpm copied every file into `node_modules` [#16677](https://github.com/pnpm/pnpm/issues/16677).
Evidence
The checklist requires previous buggy behavior to appear in its own past-tense sentence. The second
sentence in the added changeset combines present-tense take with past-tense did not match and
copied.

Rule 3058498: Describe previous buggy behavior in a separate past-tense sentence
.changeset/hardlink-group-writable-store.md[7-7]

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 describes the old failure in a sentence that mixes present and past tense: it says store files `take` their group-write bit but also says they `did not match` and pnpm `copied` files.

## Fix Focus Areas
- .changeset/hardlink-group-writable-store.md[7-7]

## Recommended Fix
Rewrite the historical explanation as a separate, consistently past-tense sentence beginning with `Previously,` and keep the corrected behavior in its own sentence.

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


3. Release metadata mixes two CLIs 📘 Rule violation § Compliance
Description
The changeset places the TypeScript importer, pnpm, and pacquet in one release entry instead of
separating the v11 and v12 targets. When release automation processes this PR, version-specific
package metadata and notes remain combined rather than isolated by CLI stack.
Code

.changeset/hardlink-group-writable-store.md[R2-4]

+"@pnpm/fs.indexed-pkg-importer": patch
+"pnpm": patch
+"pacquet": patch
Evidence
The checklist requires separate changesets when one PR changes both pnpm v11 and pnpm v12, with each
file targeting only the appropriate package set. The added changeset targets the v11 importer and
pnpm alongside pacquet in a single file.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/hardlink-group-writable-store.md[1-7]

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 PR changes both the pnpm v11 TypeScript importer and the pnpm v12 Rust implementation, but one changeset combines their package targets. The release metadata must distinguish the supported versions.

## Fix Focus Areas
- .changeset/hardlink-group-writable-store.md[1-7]

## Recommended Fix
Replace the combined changeset with separate changeset files: one targeting the v11 packages with the required patch bump, and another targeting `pacquet` with its appropriate bump. Keep each entry's release-note text limited to the behavior of the stack it targets.

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

Dismiss ↗ | View ↗


View medium (2)
4. Hardlink coverage omits Windows behavior 📜 Skill insight ▣ Testability
Description
The new hardlink regression test is restricted to Unix, while the corresponding v11 test runs only
on Linux. Windows therefore has no coverage for the changed hardlink-mode behavior, so
platform-specific regressions can pass unnoticed.
Code

pnpm/crates/deps-restorer/src/link_file/tests/installation.rs[R150-152]

+#[test]
+#[cfg(unix)]
+fn hardlink_shares_a_store_inode_that_differs_only_in_group_write() {
Evidence
The checklist requires Windows-specific coverage whenever hardlink handling changes. The new Rust
regression test is explicitly gated with #[cfg(unix)], and the v11 regression test is Linux-only,
so neither implementation exercises the changed behavior on Windows.

pnpm/crates/deps-restorer/src/link_file/tests/installation.rs[150-152]
pnpm11/fs/indexed-pkg-importer/test/umaskImport.test.ts[113-128]
Skill: review-code

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

## Issue description
The hardlink-mode behavior changed, but the new regression coverage is limited to Unix/Linux and does not exercise Windows behavior.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/link_file/tests/installation.rs[150-152]
- pnpm11/fs/indexed-pkg-importer/test/umaskImport.test.ts[113-128]

## Recommended Fix
Add an explicit Windows-specific hardlink test or extend the platform test matrix to run the relevant hardlink scenario on Windows, using assertions that reflect Windows filesystem semantics where POSIX mode bits are unavailable.

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

Dismiss ↗ | View ↗


5. Bin setup changes the shared store 🐞 Bug ≡ Correctness
Description
store_inode_mode_is_linkable and isLinkableStoreMode now accept an extra group-write bit, so a
non-executable store file at 0664 can be hardlinked where the install expects 0644. When that
file is a declared package bin, bin linking adds execute bits to the shared inode, changing the
store entry to 0775 and causing later imports of that non-executable entry to copy it.
Code

pnpm/crates/fs/src/file_mode.rs[R43-44]

+    const GROUP_OTHER_WRITE: u32 = 0o022;
+    (mode ^ desired) & 0o777 & !GROUP_OTHER_WRITE == 0 && mode & !desired & 0o002 == 0
Evidence
Tar extraction classifies executability from the archive's mode, and the store writer uses that
classification for the CAS path; inherited store permissions can give a non-executable entry mode
0664. The new predicate admits that entry against desired mode 0644, while the hardlink importer
shares its inode with the installed file. Both bin linkers subsequently add execute bits to the
installed target without first separating that inode; the resulting execute-bit mismatch makes a
later import of the same non-executable CAS path take the copy branch.

pnpm/crates/tarball/src/extract/streaming.rs[183-204]
pnpm/crates/store-dir/src/cas_file.rs[85-100]
pnpm/crates/fs/src/file_mode.rs[21-45]
pnpm/crates/fs/src/file_mode.rs[258-280]
pnpm/crates/deps-restorer/src/link_file.rs[379-416]
pnpm/crates/cmd-shim/src/link_bins/shim_writer.rs[160-169]
pnpm/crates/cmd-shim/src/capabilities/executable.rs[21-51]
pnpm11/fs/indexed-pkg-importer/src/index.ts[377-405]
pnpm11/bins/linker/src/fileChecks.ts[98-120]

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 newly eligible hardlink can share a non-executable bin's inode with the content-addressable store. Adding execute bits during bin linking then changes the store entry itself in both CLIs.

## Fix Focus Areas
- pnpm/crates/fs/src/file_mode.rs[42-45]
- pnpm/crates/cmd-shim/src/capabilities/executable.rs[34-51]
- pnpm11/fs/indexed-pkg-importer/src/index.ts[377-389]
- pnpm11/bins/linker/src/fileChecks.ts[98-120]

## Recommended Fix
Before chmodding an imported bin that needs executable bits, give it an independent inode if it is hardlinked to the store. Apply this in both CLIs and test a non-executable bin imported from a group-writable store under umask 022, including the store mode after bin linking.

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

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Tickets: 🎫 umask issue
✅ Compliance rules (platform): 66 rules
Review mode: Auto: ⏭️ Skipped: Latest push only changes changeset documentation prose.

Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 5159d8d

Results up to commit 40468fb ⚖️ Balanced


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


Remediation recommended
1. Release metadata mixes two CLIs 📘 Rule violation § Compliance
Description
The changeset places the TypeScript importer, pnpm, and pacquet in one release entry instead of
separating the v11 and v12 targets. When release automation processes this PR, version-specific
package metadata and notes remain combined rather than isolated by CLI stack.
Code

.changeset/hardlink-group-writable-store.md[R2-4]

+"@pnpm/fs.indexed-pkg-importer": patch
+"pnpm": patch
+"pacquet": patch
Evidence
The checklist requires separate changesets when one PR changes both pnpm v11 and pnpm v12, with each
file targeting only the appropriate package set. The added changeset targets the v11 importer and
pnpm alongside pacquet in a single file.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/hardlink-group-writable-store.md[1-7]

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 PR changes both the pnpm v11 TypeScript importer and the pnpm v12 Rust implementation, but one changeset combines their package targets. The release metadata must distinguish the supported versions.

## Fix Focus Areas
- .changeset/hardlink-group-writable-store.md[1-7]

## Recommended Fix
Replace the combined changeset with separate changeset files: one targeting the v11 packages with the required patch bump, and another targeting `pacquet` with its appropriate bump. Keep each entry's release-note text limited to the behavior of the stack it targets.

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

Dismiss ↗ | View ↗


2. Hardlink coverage omits Windows behavior 📜 Skill insight ▣ Testability
Description
The new hardlink regression test is restricted to Unix, while the corresponding v11 test runs only
on Linux. Windows therefore has no coverage for the changed hardlink-mode behavior, so
platform-specific regressions can pass unnoticed.
Code

pnpm/crates/deps-restorer/src/link_file/tests/installation.rs[R150-152]

+#[test]
+#[cfg(unix)]
+fn hardlink_shares_a_store_inode_that_differs_only_in_group_write() {
Evidence
The checklist requires Windows-specific coverage whenever hardlink handling changes. The new Rust
regression test is explicitly gated with #[cfg(unix)], and the v11 regression test is Linux-only,
so neither implementation exercises the changed behavior on Windows.

pnpm/crates/deps-restorer/src/link_file/tests/installation.rs[150-152]
pnpm11/fs/indexed-pkg-importer/test/umaskImport.test.ts[113-128]
Skill: review-code

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

## Issue description
The hardlink-mode behavior changed, but the new regression coverage is limited to Unix/Linux and does not exercise Windows behavior.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/link_file/tests/installation.rs[150-152]
- pnpm11/fs/indexed-pkg-importer/test/umaskImport.test.ts[113-128]

## Recommended Fix
Add an explicit Windows-specific hardlink test or extend the platform test matrix to run the relevant hardlink scenario on Windows, using assertions that reflect Windows filesystem semantics where POSIX mode bits are unavailable.

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

Dismiss ↗ | View ↗


3. Bin setup changes the shared store 🐞 Bug ≡ Correctness
Description
store_inode_mode_is_linkable and isLinkableStoreMode now accept an extra group-write bit, so a
non-executable store file at 0664 can be hardlinked where the install expects 0644. When that
file is a declared package bin, bin linking adds execute bits to the shared inode, changing the
store entry to 0775 and causing later imports of that non-executable entry to copy it.
Code

pnpm/crates/fs/src/file_mode.rs[R43-44]

+    const GROUP_OTHER_WRITE: u32 = 0o022;
+    (mode ^ desired) & 0o777 & !GROUP_OTHER_WRITE == 0 && mode & !desired & 0o002 == 0
Evidence
Tar extraction classifies executability from the archive's mode, and the store writer uses that
classification for the CAS path; inherited store permissions can give a non-executable entry mode
0664. The new predicate admits that entry against desired mode 0644, while the hardlink importer
shares its inode with the installed file. Both bin linkers subsequently add execute bits to the
installed target without first separating that inode; the resulting execute-bit mismatch makes a
later import of the same non-executable CAS path take the copy branch.

pnpm/crates/tarball/src/extract/streaming.rs[183-204]
pnpm/crates/store-dir/src/cas_file.rs[85-100]
pnpm/crates/fs/src/file_mode.rs[21-45]
pnpm/crates/fs/src/file_mode.rs[258-280]
pnpm/crates/deps-restorer/src/link_file.rs[379-416]
pnpm/crates/cmd-shim/src/link_bins/shim_writer.rs[160-169]
pnpm/crates/cmd-shim/src/capabilities/executable.rs[21-51]
pnpm11/fs/indexed-pkg-importer/src/index.ts[377-405]
pnpm11/bins/linker/src/fileChecks.ts[98-120]

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 newly eligible hardlink can share a non-executable bin's inode with the content-addressable store. Adding execute bits during bin linking then changes the store entry itself in both CLIs.

## Fix Focus Areas
- pnpm/crates/fs/src/file_mode.rs[42-45]
- pnpm/crates/cmd-shim/src/capabilities/executable.rs[34-51]
- pnpm11/fs/indexed-pkg-importer/src/index.ts[377-389]
- pnpm11/bins/linker/src/fileChecks.ts[98-120]

## Recommended Fix
Before chmodding an imported bin that needs executable bits, give it an independent inode if it is hardlinked to the store. Apply this in both CLIs and test a non-executable bin imported from a group-writable store under umask 022, including the store mode after bin linking.

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

Dismiss ↗ | View ↗


View medium (2)
4. Release note explains implementation ✓ Resolved
Description
The changeset explains group-write inheritance, umask matching, and copying into node_modules
instead of limiting the entry to observable behavior. This implementation detail is triggered in the
release-note paragraph and makes the published summary describe internal permission mechanics rather
than only what pnpm install now does.
Code

.changeset/hardlink-group-writable-store.md[7]

+`pnpm install` hardlinks files from a group-writable or world-writable store again. Since store files take their group-write bit from the store directory, they did not match the install's umask, and pnpm copied every file into `node_modules` [#16677](https://github.com/pnpm/pnpm/issues/16677).
Evidence
The checklist requires changeset entries to describe observable behavior only and disallows design
or implementation justification clauses. The added sentence describes how store files obtain
permission bits and why their modes differ from the umask.

Rule 3058322: Changeset entries must describe observable behavior changes only
.changeset/hardlink-group-writable-store.md[7-7]

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 second sentence describes internal store permission and umask mechanics. Release-note entries should state only the observable install behavior and omit implementation rationale.

## Fix Focus Areas
- .changeset/hardlink-group-writable-store.md[7-7]

## Recommended Fix
Remove the implementation explanation from the changeset entry and retain a concise statement that `pnpm install` hardlinks files from group-writable or world-writable stores again.

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


5. Release note mixes tenses ✓ Resolved
Description
The changeset's second sentence uses present tense for store files take and past tense for `did
not match and copied every file` in the same account of the defect. Because the old behavior is
not expressed as a clearly past-tense sentence, readers may not distinguish the historical failure
from the corrected behavior.
Code

.changeset/hardlink-group-writable-store.md[7]

+`pnpm install` hardlinks files from a group-writable or world-writable store again. Since store files take their group-write bit from the store directory, they did not match the install's umask, and pnpm copied every file into `node_modules` [#16677](https://github.com/pnpm/pnpm/issues/16677).
Evidence
The checklist requires previous buggy behavior to appear in its own past-tense sentence. The second
sentence in the added changeset combines present-tense take with past-tense did not match and
copied.

Rule 3058498: Describe previous buggy behavior in a separate past-tense sentence
.changeset/hardlink-group-writable-store.md[7-7]

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 describes the old failure in a sentence that mixes present and past tense: it says store files `take` their group-write bit but also says they `did not match` and pnpm `copied` files.

## Fix Focus Areas
- .changeset/hardlink-group-writable-store.md[7-7]

## Recommended Fix
Rewrite the historical explanation as a separate, consistently past-tense sentence beginning with `Previously,` and keep the corrected behavior in its own sentence.

ⓘ 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 balanced review requested due to automatic review settings October 7, 2026 00:03

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.

@zkochan

zkochan commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

Replies to the Qodo review of 40468fb:

  1. Release metadata mixes two CLIs. Not acting. AGENTS.md allows one changeset for a shared bug fix when the same release-note text applies to both targets. Here it does: both CLIs had the same exact-mode check and the same inherited store modes, and both now hardlink.
  2. and 3. Release note mixes tenses, explains implementation. Fixed in 5159d8d. The note now states the new behavior, then the old behavior in its own past-tense sentence. The mechanism is gone.
  3. Hardlink coverage omits Windows. Not acting. Windows has no POSIX mode bits. source_has_desired_mode always returns true there, and v11's storeEntryModeForSource returns undefined on win32. No Windows code path changed, so there is nothing for a Windows test to assert.
  4. Bin setup changes the shared store. Not introduced here. A non-executable store entry whose mode matches the umask exactly (0644 under 022) was already hardlinked before this PR, and both bin linkers then chmod that shared inode. This PR only widens which write bits count as a match. It adds no new path by which a bin linker reaches a store inode. Giving bins their own inode before the chmod would be a separate change to bin linking.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5159d8d

@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 41dbcbc into main Oct 7, 2026
68 checks passed
@zkochan
zkochan deleted the fix/16677-hardlink-group-writable-store branch October 7, 2026 00:20
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.

Shared-store permission inheritance forces copies under umask 0000, slowing pnpm 12 installs

3 participants