Skip to content

feat(worktree): reclaim clean worktrees whose commits are all on a remote - #93

Merged
cjber merged 1 commit into
mainfrom
cb/pushed-worktrees
Nov 19, 2026
Merged

cjber merged 1 commit into
mainfrom
cb/pushed-worktrees

Conversation

@cjber

@cjber cjber commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Why

Agents create about 120 worktrees a week and keeper blocked nearly all of them (open PR, no merge proof, 7 day window), so about 1,000 piled up. Our rule is that work is always pushed, so a clean worktree with every commit on a remote loses nothing when deleted: the branch and PR stay on the remote and git worktree add recreates it.

What

  • New proof in inspectWorktree: clean status, rev-list --count HEAD --not --remotes is 0, valid checkout, no unfinished operation, not in use. Low risk, reason "Every commit is on a remote".
  • An open PR blocks only when the worktree has local-only commits or uncommitted files.
  • Pushed worktrees use pushedIdleDays = 1 instead of staleDays (merged stays exempt). --stale-days below 1 still wins.
  • Detached HEAD on a remote commit counts (the rev-list covers HEAD).
  • Merged and contained proofs, dirty, unpushed, in-use and hold blockers are unchanged.
  • keeper auto already applies every bulk-eligible low-risk finding, so it picks these up with no change.
  • README, site, CLI help, skill and changelog updated.

Verification

biome, tsc and keeper.test.ts pass, with new tests for pushed+open PR (low), touched an hour ago (blocked), unpushed+open PR (blocked), dirty+pushed (blocked), detached HEAD. Two load-renice tests fail only when run under nice 19 locally; CI runs them normally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KXatHM4gpsmfeiUgUipa9b

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying keeper with  Cloudflare Pages  Cloudflare Pages

Latest commit: c868c26
Status: ✅  Deploy successful!
Preview URL: https://eb1880b0.keeper-9oy.pages.dev
Branch Preview URL: https://cb-pushed-worktrees.keeper-9oy.pages.dev

View logs

@cjber cjber added the mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it label Nov 19, 2026
@merge-loop

merge-loop Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Ejected: the rebase failed: it conflicts in CHANGELOG.md, src/scanners.ts, and the workspace has no Anthropic API key for an agent to resolve that: add one in the dashboard's settings, https://mergeloop.ai/cjber/settings.

Add mergepatrol again to retry.

@merge-loop merge-loop Bot added mergepatrol:failed Mergepatrol ejected this PR; see its comment and removed mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it labels Nov 19, 2026
…as low risk

A worktree with no uncommitted files and no commits outside a remote loses nothing when
deleted: the branch and PR stay on the remote and git worktree add recreates it. An open PR
now blocks only when there are local-only commits or uncommitted files. Such worktrees use a
1 day idle window instead of staleDays. Detached HEADs on a remote commit count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KXatHM4gpsmfeiUgUipa9b
@cjber
cjber force-pushed the cb/pushed-worktrees branch from 4a9ae26 to c868c26 Compare November 19, 2026 14:52
@cjber
cjber merged commit 80bc45b into main Nov 19, 2026
7 checks passed
@cjber
cjber deleted the cb/pushed-worktrees branch November 19, 2026 14:54
merge-loop Bot pushed a commit that referenced this pull request Nov 19, 2026
Releases the two worktree changes on main: #92 (a worktree still on main
is offered after 1 idle day) and #93 (a clean worktree whose commits are
all on a remote is low risk). Also corrects the #92 changelog line,
which said an open PR still blocks; #93 changed that.

Verification: `bun run gate` passes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01KXatHLEwwQDashiEwr9ASp

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
cjber added a commit that referenced this pull request Nov 19, 2026
Prepares the 0.8.0 release: a clean worktree with every commit on a
remote is low risk (#93), and an unused worktree still on a
default-branch commit is offered after 1 idle day.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergepatrol:failed Mergepatrol ejected this PR; see its comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant