Skip to content

wu:prune

← Back to CLI Commands

Lease-aware stale worktree cleanup and already-merged remote lane branch pruning

pnpm wu:prune

Before removing any tracked worktree directory, wu:prune reads the WU record committed INSIDE that worktree itself (not origin/main and not the operator’s own checkout) and the lane branch’s commit count ahead of origin/<mainBranch>. A worktree whose own record shows in_progress, or whose branch carries commits origin/main has never seen, is refused — naming the WU id, the exact ahead count, and the governed recovery route (pnpm wu:recover --id <id> --action resume, or --action restore if the directory is already missing) — even when the main-side record looks settled. --dry-run and --execute classify and record the refusal identically, and it is written to the same .lumenflow/quarantine/worktrees/cleanup.jsonl ledger as a real removal.

--remote lists and, with --execute, deletes only remote lane/* branches that git proves merged into the integration branch (by the exit code of merge-base --is-ancestor). An unmerged branch, or one whose ancestry git cannot prove, is never listed or deleted.

The claim-marker sweep (refs/lumenflow/claims/*) decides from origin, never from the checkout’s own files: a marker is removed only when the integration branch on origin records the WU done with the same claim generation as the marker, and every delete is a --force-with-lease on the marker sha observed at that decision. A stale checkout, a reclaimed WU or a marker refreshed meanwhile keeps its marker.


← Back to CLI Commands