Skip to content

feat: remove a discovered worktree by the registered-worktree rules - #6690

Merged
janicduplessis merged 1 commit into
mainfrom
@janic/discovered-removal-rules
Nov 29, 2026
Merged

janicduplessis merged 1 commit into
mainfrom
@janic/discovered-removal-rules

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Removing a discovered linked worktree (one Stim found, not created) added two guesses on top of the registered-worktree rules: a 15 s walk of every source entry's modification time, git-ignored files included, and a name test that kept any worktree inside a dot-folder other than .worktrees (such as .claude/worktrees) as "managed by another tool". Both came from the coordinator and the reviews of #5519, not from the maintainer, and took seven fixes (#5785, #5969, #6002, #6044, #6066, #6646, #6651).

The walk only added the recency of ignored files: a non-ignored edit already makes the worktree dirty, and a dirty discovered worktree is kept. #6643 made ignored files in a linked worktree disposable.

Maintainer decision: "should be same rules as registered workspace", 2026-11-11, for discovered checkouts.
Maintainer decision: "Yes do all 4", 2026-11-29, in chat with the coordinator, answering the cleanup-rule audit whose second candidate this is.

Solution

discoveredRemovalHold now keeps a discovered worktree the registered rules let go only for a process running from it, an agent session in it, or a tracked file hidden from git status. It no longer reads idleness evidence, so idle.dormantDays no longer gates removal. The source walk (discoveredEvidence) stays where it gates dormant build outputs (daemon/stages.ts). A dirty discovered worktree is still kept and never archived, and still gets no Podfile.lock churn exclusion.

What this PR accepts:

  • a merged, clean worktree under .claude/worktrees (or another tool's dot-folder inside the repository) is removed, and that tool lists a stale entry;
  • idle.dormantDays no longer gates removal, so a clean discovered worktree with no commits of its own goes once its git writes are older than the registered rules' grace (at least gc.worktreeGraceMinutes), as a registered one does. Its git-ignored files go with it (gc keeps finished worktrees for regenerated ignored folders such as .docusaurus #6643).

LLP 0004 "Removing a discovered worktree" (renamed from "... needs more evidence"), the cleanup guide, the website and the release notes are updated.

Test plan

  • discovered-worktrees.test.ts: a finished worktree with a recent write to an ignored file is removable; a worktree under <main>/.claude/worktrees gets no hold; the process, agent-session, hidden-edit and dirty keeps still hold.

Fixes #6683

@janicduplessis janicduplessis added area: cli packages/stim-cli, including its README and guide area: website website/ area: docs docs/ and root documents labels Nov 29, 2026
@janicduplessis
janicduplessis force-pushed the @janic/discovered-removal-rules branch from 9212eae to 5290b7b Compare November 29, 2026 15:43
@janicduplessis
janicduplessis marked this pull request as ready for review November 29, 2026 17:46
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 29, 2026
@janicduplessis
janicduplessis force-pushed the @janic/discovered-removal-rules branch from e4e3945 to 7da120d Compare November 29, 2026 17:54
@janicduplessis janicduplessis removed the review: ai-approved A fresh AI review found nothing left to fix label Nov 29, 2026
@janicduplessis
janicduplessis marked this pull request as draft November 29, 2026 18:02
@janicduplessis
janicduplessis marked this pull request as ready for review November 29, 2026 18:44
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 29, 2026
@janicduplessis
janicduplessis force-pushed the @janic/discovered-removal-rules branch from 7da120d to 6e0a5d9 Compare November 29, 2026 20:01
@janicduplessis
janicduplessis merged commit 41f65bb into main Nov 29, 2026
35 checks passed
@janicduplessis
janicduplessis deleted the @janic/discovered-removal-rules branch November 29, 2026 20:08
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: docs docs/ and root documents area: website website/ 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.

gc: remove a discovered worktree by the registered-worktree rules, without the source walk and dot-folder test

1 participant