Skip to content

feat(scan): offer a worktree still on main after one idle day - #92

Merged
merge-loop[bot] merged 2 commits into
mainfrom
cb/unused-branch-window
Nov 19, 2026
Merged

merge-loop[bot] merged 2 commits into
mainfrom
cb/unused-branch-window

Conversation

@cjber

@cjber cjber commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner
flowchart LR
  W[clean worktree] --> M{merged PR proof?}
  M -- yes --> O[offered now]
  M -- no --> C{HEAD on the default branch?}
  C -- yes --> D1[wait 1 idle day]
  C -- no --> D7[wait --stale-days, 7 by default]
Loading

Why

Agents cut many cb/ worktrees from main that they never commit to. These hold nothing main lacks, but each one waited the full 7-day window. On the machine this came from, 47 of 72 nebula worktrees were waiting on it, 30 of them branches still on a main commit.

What changed

  • inspectWorktree: a checkout whose HEAD is contained in the default branch waits min(--stale-days, 1) idle days instead of --stale-days. Merged-PR proof still outruns the window.
  • The window does not depend on the PR list. A first version keyed it on "no PR for this branch", which review showed was wrong twice: the per-repo lookup returns every PR in the repository, and a missing or logged-out gh also reads as an empty list. Containment alone is the safety property: a clean checkout on a default-branch commit has no work of its own to lose.
  • Dirty files, a running process, a hold, an open PR and a failed lookup still block, as before.
  • AGENTS.md rule and CHANGELOG updated.

Verification

  • New test: a branch still on main is blocked today ("offered after 1 idle day") and offered as low risk at 2 days idle. Confirmed it fails without the scanner change.
  • bun run gate: 138 pass, 0 fail.
  • Review: Codex (gpt-reserve, xhigh). Its three findings are fixed by the second commit. The Muse arm could not run, as its subscription quota is exhausted until 2026-11-23.

Risk

A worktree cut from main, left clean and untouched for a full day with no hold, becomes low risk and the hourly run removes it. An agent returning to one should keeper hold it, as the skill already says.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KXatHLEwwQDashiEwr9ASp

cjber and others added 2 commits November 19, 2026 14:23
A checkout still on a default-branch commit, with no pull request for its
branch, holds nothing the default branch lacks. It now waits one idle day
instead of the full --stale-days window, so worktrees agents cut and never
used stop piling up for a week. Any pull request, open or closed, keeps the
full window, and a lower --stale-days still wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KXatHLEwwQDashiEwr9ASp
Review found two holes in keying the shorter window on an empty PR list:
the per-repo lookup returns every PR in the repository, so a busy repo
never had an empty list, and a missing or logged-out gh also reads as an
empty list, so a branch with an open PR could look unused. A clean
checkout whose HEAD is on the default branch holds nothing to lose
whatever its PRs say, so containment alone decides it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KXatHLEwwQDashiEwr9ASp
@cjber cjber changed the title feat(scan): offer an unused worktree after one idle day feat(scan): offer a worktree still on main after one idle day Nov 19, 2026
@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: 1a5ad82
Status: ✅  Deploy successful!
Preview URL: https://ba96014f.keeper-9oy.pages.dev
Branch Preview URL: https://cb-unused-branch-window.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

Merged as 81cad47.

@merge-loop
merge-loop Bot merged commit 81cad47 into main Nov 19, 2026
7 checks passed
@merge-loop
merge-loop Bot deleted the cb/unused-branch-window branch November 19, 2026 14:34
@merge-loop merge-loop Bot removed the mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it label Nov 19, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant