Repository navigation
feat: remove a discovered worktree by the registered-worktree rules - #6690
Merged
Merged
Conversation
janicduplessis
force-pushed
the
@janic/discovered-removal-rules
branch
from
November 29, 2026 15:43
9212eae to
5290b7b
Compare
janicduplessis
marked this pull request as ready for review
November 29, 2026 17:46
janicduplessis
force-pushed
the
@janic/discovered-removal-rules
branch
from
November 29, 2026 17:54
e4e3945 to
7da120d
Compare
janicduplessis
marked this pull request as draft
November 29, 2026 18:02
janicduplessis
marked this pull request as ready for review
November 29, 2026 18:44
janicduplessis
force-pushed
the
@janic/discovered-removal-rules
branch
from
November 29, 2026 20:01
7da120d to
6e0a5d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
discoveredRemovalHoldnow 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 fromgit status. It no longer reads idleness evidence, soidle.dormantDaysno 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 noPodfile.lockchurn exclusion.What this PR accepts:
.claude/worktrees(or another tool's dot-folder inside the repository) is removed, and that tool lists a stale entry;idle.dormantDaysno 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 leastgc.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/worktreesgets no hold; the process, agent-session, hidden-edit and dirty keeps still hold.Fixes #6683