fix-worktree-build

Fix: worktree build artifacts (target/) accumulate unbounded -> disk exhaustion

Metadata

Statusopen ‖ paused
Created2026-07-26T06:37:08.291329183+00:00
Started2026-07-26T07:16:43.740400538+00:00
Completed2026-07-26T07:17:06.274044365+00:00
Tagsbug, worktree, disk
Tokens0 in / 0 out

Description

Objective

Isolated agent worktrees accumulate Rust target/ build dirs with no retention, which exhausted the disk this session: agent-688/target=58G, agent-749/target=53G, agent-808/target=33G (144G total, from only 3 dead worktrees) pushed the volume to 100% full. There is no automatic cleanup of build artifacts in worktrees, and the disk guard only pauses new BUILDS after the damage is done.

Work

  • Add retention/cleanup for build artifacts inside worktrees: clean target/ (and similar) for worktrees whose agent is dead/done/abandoned, on a cadence and on worktree reap.
  • Make the existing disk guard proactive: estimate per-worktree target/ growth and clean/reclaim before hitting the warning floor, not only pause new builds after.
  • Ensure wg cleanup (nightly/orphaned) sweeps dead worktrees' build artifacts.

Validation

  • Dead/done worktrees have their target/ cleaned automatically (no manual rm -rf needed).
  • A disk-full from accumulated worktree target/ cannot recur; the guard reclaims before the warning floor.
  • wg cleanup removes dead-worktree build artifacts.

Reference

This session: 144G in 3 dead worktrees' target/ -> disk 100% full (832M free).

Depends on

Required by

Log