fix: force worktree removal after successful draft-PR run - #77
Merged
Conversation
A successful run leaves the linked worktree dirty with post-push writes (e.g. .loopdeck/loops.md loop-state updates), and plain 'git worktree remove' refuses dirty worktrees. The branch was already pushed for the draft PR, so the worktree holds nothing worth preserving; force the removal so the run finishes clean instead of being flagged as a cleanup failure. Adds worktree_remove_dirty_worktree regression test.
suprie
marked this pull request as ready for review
August 5, 2026 10:49
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Problem
Run loops fail on cleanup after a successful draft PR:
A successful run leaves the linked worktree dirty with post-push writes (e.g.
.loopdeck/loops.mdloop-state updates).git worktree removerefuses dirty worktrees without--force, sofinalize_worktreeflags the run as a cleanup failure even though the PR shipped.Fix
worktree_removenow passes--force. The branch was already pushed for the draft PR, so the worktree holds nothing worth preserving; dirty leftovers are run artifacts.multi_agent.rscleanup is already gated onworktree_is_pristine;finalize_worktreekeep+flag fallback still catches genuine failures (locked/missing worktree).Test
Adds
worktree_remove_dirty_worktreeregression test — dirties a worktree with an untracked file and asserts forced removal succeeds. Fails if--forceis ever dropped.Verified:
cargo test worktree_lifecycle_add_list_remove,worktree_remove_dirty_worktree,finalize_worktree*all pass.