Skip to content

Add managed worktree lifecycle cleanup and rollout health checks #275

@shiny-code-bot

Description

@shiny-code-bot

Summary

Every Code managed worktrees are accumulating under ~/.code/working. A local audit after pruning broken/stale entries still found 39 valid managed branch checkouts across repos, including 24 for launchplane, 4 for code, and several auto-review worktrees.

This is separate from the broken-worktree hardening in #273. Even when all worktrees are valid, the retention behavior is too loose for ephemeral review/task worktrees.

Observed local audit

After fixing the broken code/branches/auto-review checkout and pruning stale Git registry entries:

SUMMARY total=62 invalid=0 dirty=5 prune_candidates=0

Breakdown:

24 normal repos/checkouts under ~/Developer
39 Every Code managed branch checkouts under ~/.code/working

Managed checkout counts:

24 launchplane
 4 code
 2 sellyouroutboard
 2 odoo-tenant-opw
 2 codex-skills
 1 odoo-docker
 1 odoo-devkit
 1 verireel auto-review
 1 odoo-intelligence-mcp auto-review
 1 jetbrains-inspection-api auto-review

Notable disk usage examples:

~/.code/working/code/branches/auto-review-d70d879b       6.7G
~/.code/working/sellyouroutboard/branches/auto-review    520M
~/.code/working/sellyouroutboard/branches/auto-review-fc5aada8 470M

Expected behavior

Ephemeral review/task worktrees should have a clear lifecycle and should not accumulate indefinitely after Every Code exits or after a run finishes.

Acceptance criteria:

  • define which managed worktrees are ephemeral versus user-owned/preserved
  • clean ephemeral clean worktrees when their owning run/session closes successfully
  • keep dirty worktrees, active worktrees, and explicitly preserved branches
  • prune stale Git worktree registry entries for repos touched by the cleanup
  • add a dry-run cleanup surface that lists candidate removals with repo, branch/path, age, dirty state, and size
  • add a rollout/session health check that records or warns when managed worktree counts or disk usage exceed a threshold
  • include coverage for session-close cleanup, interrupted/failed run retention, dirty worktree preservation, and stale registry pruning

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions