Skip to content

source-control/babysit-prs: harden prune_babysit_worktrees.py against orphaned state #816

Description

@kyle-sexton

This was generated by AI during triage.

Two robustness gaps in prune_babysit_worktrees.py observed at queue-start prune:

  • A leftover state record for a merged/closed PR whose worktree directory no longer exists makes prune error fatal: not a git repository on every run instead of self-healing. When git status (or equivalent) fails with "not a git repository" for a tracked worktree path, treat that path as already-gone and drop its state record.
  • On Windows a file lock blocking removal can leave an empty directory behind, requiring manual rm -rf + git worktree prune. Detect the residual empty directory and either retry/clean it or report it explicitly rather than leaving a silent orphan.

Acceptance: an orphaned state record pointing at a nonexistent path is dropped without erroring the whole prune; a lock-blocked removal does not silently leave an untracked empty directory (it is cleaned or clearly reported).

Sweep-converted from #657.

Work-class: C3 (bug-fix-shaped) — attended triage 2026-07-23, operator-ratified. 🤖

Metadata

Metadata

Assignees

Labels

agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions