feat(fleet): reclaim the checkouts whose work already shipped - #42
Merged
Conversation
The fleet creates a git worktree per agent session and removes none of them. On 2026-08-26 there were 24, holding 5.2 GB, and every single one belonged to a PR that had already merged — 23 were byte-for-byte clean. That is a recurring manual sweep, so it becomes a script rather than something re-derived from scratch each time the disk gets tight. stranded-work.sh and this are the two halves of one question. That one asks "is any work trapped on this disk?"; this asks "is any checkout still here after its work shipped?" They turn on the same distinction, too: an upstream that is configured but no longer resolves means the branch was pushed and its remote branch deleted. Reading that backwards is what made stranded-work report 24 merged PRs as stranded yesterday. Because this one deletes checkouts, the entire design is the refusal list. A worktree is removable only if it was PUSHED, is CLEAN, is UNUSED, and GitHub says MERGED — and each of those is a case where removing it would have destroyed the only copy of something: no upstream the branch exists on exactly one disk any dirt a worktree is where the unfinished edit lives live session someone is working in it right now not MERGED CLOSED is abandoned, not gone; empty is gh failing, not consent The predicate is pure so all nine tests run without a repo, a network call or a session, including "no argument means dry-run" — if that ever inverts, the first person to run it bare loses every checkout. Verified on the real fleet: 23 removed, 5.2 GB freed, the four it refused being one never-pushed branch, one live session, one dirty tree, and one superseded local branch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The fleet creates a
git worktreeper agent session and removes none of them. Today there were 24 holding 5.2 GB — and every one belonged to a PR that had already merged. 23 were byte-for-byte clean.Companion to
fleet-stranded. That one asks "is any work trapped on this disk?"; this asks "is any checkout still here after its work shipped?" They turn on the same git distinction — an upstream that is configured but no longer resolves means the branch was pushed and its remote branch deleted. Reading that backwards is what madefleet-strandedreport 24 merged PRs as stranded in #40.The design is the refusal list
This deletes checkouts, so the only interesting failure is a false positive. Removable requires all four:
pushedcleanunusedMERGEDCLOSEDis abandoned, not gone; empty isghfailing, not consentsafe_to_remove()is pure, so all nine tests run with no repo, no network, no session. Each refusal is pinned separately — a combined "unsafe" fixture is exactly what hides one guard silently inverting. Includes "no argument means dry-run": if that inverts, the first person to run it bare loses every checkout.Verified on the real fleet
Wired into CI, and exposed as
fleet-gcalongsidefleet-stranded.🤖 Generated with Claude Code