Skip to content

feat: remove hard-link sampling of dependency trees of unknown size - #6688

Merged
janicduplessis merged 2 commits into
mainfrom
@janic/rm-link-sample
Nov 29, 2026
Merged

janicduplessis merged 2 commits into
mainfrom
@janic/rm-link-sample

Conversation

@janicduplessis

Copy link
Copy Markdown
Collaborator

Description

Before the dormant dependency step and the 7-day source rule decided on a node_modules or Pods tree whose private size is unknown, gc sampled link counts in it and kept it when most files were hard links into a pnpm store outside the tree. The rule protected no user data, only a low-yield delete of a regenerable tree, and cost link-sample.ts (457 lines), a .modules.yaml parser, a native build output check with documented misses, and two locked sidecar records per tree. #6025 had already removed it from the pressure path.

Maintainer decision: "Like if wr detect it is links", 2026-11-18, quoted in #5942. It added the sample (#5946).

Maintainer decision: "Yes do all 4", 2026-11-29, quoted in #6685, answering the cleanup-rules audit whose first candidate drops the sample. It replaces the 2026-11-18 decision.

Solution

A tree of unknown size now follows the rule its step already had for any tree of unknown size, with no exception for hard links:

  • the dormant step takes an idle linked worktree's tree after the measured trees (selectDependencies(ranked, 'take'));
  • the 7-day source rule keeps a source checkout's tree with the "not measured" reason ('keep'), as it did for every unknown tree except a sampled one.

Worst case: a linked worktree's pnpm node_modules is deleted after idle.dormantDays, and pnpm relinks it from the store on the next install.

The <hash>.links.json and <hash>.native.json records an earlier Stim wrote stay recognized by the status cache listing, so the existing gc sweep still deletes them once their checkout is gone; nothing new writes them. forgetStatusMeasures no longer names them.

LLP 0001 "A tree of hard links stays" becomes "No step samples a tree for hard links" with both quotes. A separate commit fixes stale LLP text: the hand-edit check on dependency trees and the "install-edit" protection that #6639 removed, and "#6093 pending" in LLP 0001 and 0004 (closed by #6109 and #6115, which added the saved sentinel proof for scan-only marks).

Tests: the sampling tests in gc-dependencies.test.ts are deleted. One test now asserts that the dormant step takes a store-linked tree of unknown size; it fails on main, where the sample keeps it. The prune test for the leftover records seeds them by file name.

Test plan

  • gc-dependencies.test.ts: the new test fails against the old dependencies.ts/link-sample.ts and passes here.
  • maintenance-prune.test.ts: leftover .links.json/.native.json records of a gone checkout are deleted.
  • Affected unit files (gc, dormant, status-measures), format, lint (including ref-check), typecheck, build and knip pass locally.

Fixes #6685

A tree of unknown size now follows its step's rule: the dormant step takes a linked worktree's tree after the measured ones, and the 7-day source rule keeps a source checkout's tree. Removes link-sample.ts, its two sidecar records and the tests that only protected it, and replaces LLP 0001 "A tree of hard links stays".

Refs #6685
#6639 removed the hand-edit check on dependency trees, and #6109 and #6115 closed #6093 with the saved sentinel proof for scan-only marks.

Refs #6685
@janicduplessis janicduplessis added area: cli packages/stim-cli, including its README and guide area: core packages/core labels Nov 29, 2026
@janicduplessis
janicduplessis marked this pull request as ready for review November 29, 2026 15:34
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 29, 2026
@janicduplessis
janicduplessis enabled auto-merge (squash) November 29, 2026 15:34
@janicduplessis

Copy link
Copy Markdown
Collaborator Author

Review of head 7453b68, by a fresh reviewer subagent that did not implement the change, and by the Codex adversarial gate on the same head.

Fresh reviewer: clear, no findings. It checked:

Dismissed: dropping the kept-reason rows for store-linked trees is approved by "Yes do all 4" (#6685). The old sidecar files are left for the status cache sweep rather than removed by forgetStatusMeasures. No release-notes entry is an optional nit.

Codex adversarial review: approve, no material findings. It found no regression against main: source trees of unknown size stay protected, deletion rechecks are intact, and legacy sample records are still sweepable.

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 area: core packages/core 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.

Remove hard-link sampling of dependency trees of unknown size

1 participant