Skip to content

fix: pnpm's node_modules/.package-map.json no longer counts as a hand edit - #6608

Merged
janicduplessis merged 1 commit into
mainfrom
fix/6603-package-map-edit
Nov 28, 2026
Merged

janicduplessis merged 1 commit into
mainfrom
fix/6603-package-map-edit

Conversation

@janicduplessis

Copy link
Copy Markdown
Collaborator

Description

A finished linked worktree is never removed automatically if pnpm install ran in it after Stim recorded its own install, for example stim worktree warm followed by pnpm install. Every maintenance pass keeps it with "its node_modules: 1 file in it changed after its install (.package-map.json)", at every pressure level.

pnpm writes node_modules/.package-map.json itself during install (pnpm 11 and 12). Once the stamp is newer than Stim's record, the edit check measures root files against the old record. A root file belongs to no package, so it counts as an edit. excludedFromEdits already skipped the stamps and .pnpm-workspace-state*.json, but not this file. LLP 0002 already says a package manager's state files are not edits, so no decision doc changes.

On the maintainer's MacBook on 2026-11-27, 10 of the 11 worktrees that stim gc --dry-run listed as would remove-worktree were kept for this file while the disk was at high.

Solution

.package-map.json at the node_modules root now counts as package-manager state. The root-file rule is pulled into packageManagerState, which also filters recorded known edits, the same way .bin entries are already dropped. Without that filter, a record that an acting pass wrote before this fix would still keep the tree.

Worst case: a hand edit made to node_modules/.package-map.json itself is no longer protected. pnpm regenerates that file on every install.

Test plan

  • Two regressions in dependency-edits.integration.test.ts fail on main and pass here:
    • An install Stim did not run, after its recorded one, writes .package-map.json and rewrites the stamp.
    • A stale record lists .package-map.json as an edit.
  • Read-only dependencyEditsHold against the real home, on the 8 kept .worktrees/64xx and 6548-cow-clone worktrees:
    • 7 now return null (removable).
    • 6548-cow-clone is still kept for 14 changed files inside cow-clone's prebuilds/. That is a different case and I left it alone.

Fixes #6603

…not a hand edit

pnpm writes .package-map.json at the node_modules root on install. After an
install Stim did not run, the edit check counted it as an edit and kept
finished worktrees at every pressure. Exclude it with the other root state
files and drop it from recorded edits.

Fixes #6603
@janicduplessis janicduplessis added the area: cli packages/stim-cli, including its README and guide label Nov 28, 2026
@janicduplessis
janicduplessis marked this pull request as ready for review November 28, 2026 00:25
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 28, 2026
@janicduplessis
janicduplessis enabled auto-merge (squash) November 28, 2026 00:26
@janicduplessis
janicduplessis merged commit 9a208c7 into main Nov 28, 2026
72 of 74 checks passed
@janicduplessis
janicduplessis deleted the fix/6603-package-map-edit branch November 28, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli packages/stim-cli, including its README and guide review: ai-approved A fresh AI review found nothing left to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm's node_modules/.package-map.json counts as a hand edit and keeps finished worktrees forever

1 participant