Skip to content

docs(changeset): say that a forced install repairs the store too - #15192

Merged
zkochan merged 2 commits into
mainfrom
fix/919-changeset-store-refetch
Sep 21, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix/919-changeset-store-refetch

Conversation

@zkochan

@zkochan zkochan commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Related to #919. Follow-up to #15162, whose changeset is still pending release.

That changeset said files changed in node_modules are restored "when the store content is intact". The qualifier is wrong. A repeat pnpm install --force refetches the package when the edit also reached the store, so the store copy is repaired too and pnpm store status comes back clean. The limit the note described is not there.

The claim came from a probe that appended to the file within the store's 100ms verification skip window (checkPkgFilesIntegrity.ts:391, and check_pkg_files_integrity.rs:588 on the v12 side). Inside that window the store treats the file as unverified-but-unchanged, so nothing is refetched. Outside it, which is every real edit, the refetch happens.

This PR corrects the sentence and covers the case it describes: append through the hardlink so the store's copy is mutated too, move the mtime past the skip window, and assert that the forced install restores the original bytes and leaves pnpm store status at exit 0.

pnpm v12 already behaves this way; I confirmed it against a built v12 binary, including that only the modified package is refetched. No v12 change is needed.

Validation

Sabotage-verified: with the !opts.force guard from #15162 removed from the bundled CLI, the new test fails on the tampered bytes; with it, it passes. 46 of 46 tests in pnpm11/pnpm/test/install/misc.ts pass locally. No production code changes, so nothing else was run locally.

Squash Commit Body

The note claimed files are restored "when the store content is intact".
A repeat forced install refetches the package when the edit reached the
store, so the qualifier described a limit that is not there.

Cover that case: append through the hardlink, which mutates the store's
copy, and assert that the forced install restores the bytes and leaves
`pnpm store status` clean. The edit's mtime is moved past the store's
100ms verification skip window, which a same-millisecond edit falls into.

Related to pnpm/pnpm#919.

Checklist

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

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


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 --force now reinstalls dependencies even when the manifest and lockfile are unchanged.
    • Modified dependency files in node_modules are restored, including cases where changes also affected the package store.
    • Packages are refetched when necessary to ensure restored files match their pristine contents.
  • Documentation

    • Clarified --force behavior and the existing conflict with --frozen-store on repeat installs.
    • Added coverage for restoring files changed through shared package-store content.

The note claimed files are restored "when the store content is intact".
A repeat forced install refetches the package when the edit reached the
store, so the qualifier described a limit that is not there.

Cover that case: append through the hardlink, which mutates the store's
copy, and assert that the forced install restores the bytes and leaves
`pnpm store status` clean. The edit's mtime is moved past the store's
100ms verification skip window, which a same-millisecond edit falls into.

Related to #919.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: f1faf74d-e30b-4551-84ef-8bd0e08fa2eb

📥 Commits

Reviewing files that changed from the base of the PR and between f5101ba and 166ee31.

📒 Files selected for processing (1)
  • .changeset/force-install-repairs-modified-files.md

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


📝 Walkthrough

Walkthrough

pnpm install --force documentation now describes restoration and refetch behavior. An integration test verifies repair after modifying a hardlinked dependency file and confirms a clean store.

Changes

Force install repair

Layer / File(s) Summary
Repair behavior and integration test
.changeset/force-install-repairs-modified-files.md, pnpm11/pnpm/test/install/misc.ts
The changeset documents restoration and refetch behavior. The integration test modifies a hardlinked file, advances its timestamp, verifies restoration, and checks store status.

Priority: ⬇️ Low

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

Change: Other

Suggested labels: product: pnpm@11

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

❤️ Share

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

@zkochan
zkochan marked this pull request as ready for review September 20, 2026 23:44
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Clarify forced install store repair behavior

📝 Documentation 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Correct release notes to state forced installs refetch packages when edits reach the store.
• Add regression coverage proving restored bytes and clean store integrity after forced reinstall.
• Move the tampered file's mtime beyond the verification skip window for deterministic detection.
Diagram

sequenceDiagram
  actor Test as Regression Test
  participant CLI as pnpm CLI
  participant Modules as node_modules
  participant Store as Content Store
  participant Registry as Package Registry
  Test->>CLI: Initial install
  CLI->>Registry: Fetch packages
  CLI->>Store: Cache content
  Store->>Modules: Hardlink package
  Test->>Modules: Tamper and age file
  Modules->>Store: Mutate linked content
  Test->>CLI: Forced install
  CLI->>Store: Verify integrity
  Store-->>CLI: Report corruption
  CLI->>Registry: Refetch package
  CLI->>Store: Replace content
  Store->>Modules: Restore file
  Test->>CLI: Check store status
  CLI-->>Test: Store is clean
Loading
High-Level Assessment

The end-to-end hardlink test is the appropriate approach because it validates the exact user-visible behavior described by the changeset: store corruption detection, package refetching, file restoration, and clean store status. Direct integrity-unit testing would not provide equivalent coverage of the forced-install workflow.

Files changed (2) +28 / -1

Tests (1) +27 / -0
misc.tsTest forced repair of modified store content +27/-0

Test forced repair of modified store content

• Adds a hardlink-based regression test that mutates both the installed file and store content, advances the mtime beyond the integrity-check skip window, and runs a forced install. It verifies the original bytes are restored and pnpm reports a clean store.

pnpm11/pnpm/test/install/misc.ts

Documentation (1) +1 / -1
force-install-repairs-modified-files.mdCorrect forced install repair release note +1/-1

Correct forced install repair release note

• Removes the incorrect claim that restoration requires intact store content. Clarifies that pnpm refetches a package when a node_modules change also modifies its store copy.

.changeset/force-install-repairs-modified-files.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. The release note combines two separate changes ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The changeset sentence says pnpm restores modified files and refetches packages whose store copy was
also changed. Readers cannot distinguish these two observable repairs as separate release-note
items, while the remaining sentence also introduces a separate frozen-store conflict behavior.
Code

.changeset/force-install-repairs-modified-files.md[6]

+`pnpm install --force` now reinstalls dependencies when the manifest and lockfile are unchanged. It previously reported "Already up to date" without reinstalling. pnpm restores files that changed in `node_modules`, and refetches the package when the change also reached the store. Combining `--force` with `--frozen-store` now reports a configuration conflict on repeat installs [#919](https://github.com/pnpm/pnpm/issues/919).
Relevance

●●● Strong

Recent changeset precedents accept splitting compound observable behaviors into separate sentences.

PR-#15121
PR-#15120
PR-#14932

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The modified changeset line contains multiple distinct behavior changes joined into compound
sentences, which violates the requirement that each sentence describe only one logical change.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/force-install-repairs-modified-files.md[6-6]

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 combines restoration of modified installed files with refetching packages whose store content was modified, and also includes a separate frozen-store conflict behavior in the same entry.

## Fix Focus Areas
- .changeset/force-install-repairs-modified-files.md[6-6]

## Recommended Fix
Rewrite the entry so each distinct observable behavior is expressed as its own sentence or bullet, avoiding a compound sentence that joins the restore/refetch behavior and the frozen-store conflict behavior.

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


2. The regression test omits Windows hardlink coverage 📜 Skill insight ▣ Testability
Description
The new test forces the package import method to hardlink and mutates the installed file, but
exercises only the platform-default path representation. Windows-specific hardlink behavior is
therefore not covered by the regression scenario, so a platform-specific failure could remain
undetected.
Code

pnpm11/pnpm/test/install/misc.ts[R787-798]

+  const env = { pnpm_config_package_import_method: 'hardlink' }
+
+  await execPnpm(['install'], { env })
+
+  const installedFile = path.resolve('node_modules/is-positive/index.js')
+  const pristine = fs.readFileSync(installedFile, 'utf8')
+  // Append through the hardlink, which mutates the store's copy as well.
+  fs.appendFileSync(installedFile, '\n// tampered\n', 'utf8')
+  // The store skips verifying a file whose mtime is within 100ms of the last
+  // check, so move it past that window to make the edit observable.
+  const afterTheSkipWindow = new Date(Date.now() + 60_000)
+  fs.utimesSync(installedFile, afterTheSkipWindow, afterTheSkipWindow)
Relevance

●● Moderate

Test-strengthening findings are often accepted, but no close Windows-specific hardlink coverage
precedent was found.

PR-#14642
PR-#14371

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed test explicitly exercises hardlink behavior through `pnpm_config_package_import_method:
'hardlink'`, but contains no Windows-specific case or separator/path variant.

pnpm11/pnpm/test/install/misc.ts[787-798]
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 regression test covers hardlink-based store mutation only on the default platform and does not exercise Windows-specific hardlink behavior.

## Fix Focus Areas
- pnpm11/pnpm/test/install/misc.ts[787-798]

## Recommended Fix
Add an explicit Windows-specific test case or parameterization that performs the same hardlink mutation, mtime adjustment, forced reinstall, and store-status assertions using the Windows execution path. Keep the existing case for other platforms if both paths need coverage.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 53 rules
✅ Skills: review-code
Review mode: ⏭️ Skipped: The latest push only revises prose in a changeset release-note markdown file and has no behavioral or runtime effect.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no actionable issues identified.

Reviews (2) · Last reviewed commit: "docs(changeset): split the restore and r..."

greptile-apps[bot]
greptile-apps Bot previously approved these changes Sep 20, 2026
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 20, 2026
The house style gives each observable behavior its own sentence rather
than joining two with a comma.

Related to #919.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@greptile-apps
greptile-apps Bot dismissed their stale review September 21, 2026 00:16

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@zkochan

zkochan commented Sep 21, 2026 •

Copy link
Copy Markdown
Member Author

Two findings from the last round, one taken and one declined.

Taken: the compound sentence. Fixed in 166ee31. I checked the precedents Qodo cited and they do settle it: #15121, #15120 and #14932 all use short separate sentences with no comma-joined behaviors, and #14932 runs to five of them. So entry length was never the problem, the join was. The sentence is now two:

pnpm restores files that changed in node_modules. When the change also reached the store, pnpm refetches the package.

Declined: "the regression test omits Windows hardlink coverage." The test is not platform-gated. It runs on Windows CI and passed on all three Windows shards of the previous head. Nothing in it is POSIX-specific: path.resolve resolves per platform, and NTFS hard links share content the same way, so the append reaches the store copy there too.

The nearby install --force restores a replaced dependency file test does gate one row for Windows, but only clone, because the CI volume has no copy-on-write. hardlink runs on every platform in both tests.


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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 166ee31

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

u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
…m#15192)

The note claimed files are restored "when the store content is intact".
A repeat forced install refetches the package when the edit reached the
store, so the qualifier described a limit that is not there.

Cover that case: append through the hardlink, which mutates the store's
copy, and assert that the forced install restores the bytes and leaves
`pnpm store status` clean. The edit's mtime is moved past the store's
100ms verification skip window, which a same-millisecond edit falls into.

Related to pnpm#919.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant