pub fn stale_agent_worktrees(
repo_root: &Path,
age: Duration,
) -> Result<Vec<AgentWorktree>>Expand description
Managed agent worktrees under <base>/.claude/worktrees/ untouched
for at least age, for the reconciliation sweep that runs at every
session spawn: it reaps what a one-shot failure or a missed
completion event left behind. A lock whose reason carries a live pid
(the CLI stamps one on a live isolation agent’s tree) keeps the tree
out; a dead pid - a crashed CLI’s leftover, which git never prunes on
its own - is reapable. Locks without a parsable pid are not ours to
judge and skip. Ok(vec![]) when the worktrees dir is absent; other
read errors propagate, and a repo git cannot answer about sweeps as
empty - the fail-closed direction for a deleter. Feed the result to
reap_agent_worktree.