Metadata
| Status | done |
|---|---|
| Assigned | agent-816 |
| Agent identity | 3184716484e6f0ea08bb13539daf07686ee79d440505f1fdf2de0357707034c3 |
| Created | 2026-04-27T17:19:11.063169401+00:00 |
| Started | 2026-04-27T18:40:55.603574902+00:00 |
| Completed | 2026-04-27T19:12:08.128618635+00:00 |
| Tags | eval-scheduled |
| Tokens | 9068831 in / 38150 out |
Description
Description
Today (2026-04-27) the disk hit 100% full (16K free on a 1.8T disk) primarily because .wg-worktrees had grown to 504G — 31 agent worktrees each carrying their own ~16G target/ dir.
Of the 31 worktrees, only 3 had live agent processes running (agent-700, agent-742, agent-765). The other 28 had completed/abandoned long ago but their target/ dirs persisted indefinitely.
After manually rm -rfing target/ in the 28 dead worktrees, disk went from 100% → 71% used (518G free).
This is going to keep happening. Every agent that builds the project leaves ~16G behind unless someone manually reaps it.
Required
Build a reaper that runs automatically. Pick whichever fits the existing service architecture:
A. On agent completion — when an agent's task transitions to done/failed/abandoned, the dispatcher (or a finalizer hook) rm -rfs its worktree's target/ before any worktree cleanup. The build artifacts are not needed once the work is committed/merged.
B. Periodic sweep — wg sweep (which already exists per memory: 'Sweep command + reconciliation') gains a --reap-targets flag that finds worktrees whose owning agent has been dead > N hours and removes their target/ dirs. Wire this into the periodic-cycle pattern (per memory feedback_periodic_work_via_graph_cycles).
C. Disk pressure trigger — when free disk drops below a threshold, run option B aggressively.
Recommend A + B: clean on completion (most builds get reaped right when the agent finishes), with a periodic safety net for cases where A failed (crash, kill -9, etc).
Files likely to touch
src/commands/sweep.rs(or whereverwg sweeplives) — add--reap-targetsand the worktree-walk logicsrc/commands/service/— agent finalization hook to reap target/ on agent end- Worktree management code (where
.wg-worktrees/agent-Nis created/destroyed)
Validation
-
Failing test first: spawn a fake agent that creates a fake
target/in its worktree, mark agent as done, then assert the target/ was removed -
Failing test for the periodic sweep: leave a worktree with stale
target/and an agent that's been dead > N hours, run sweep, assert removal - Live agents' target/ dirs MUST NOT be touched — test that with a 'live' agent (heartbeat fresh) the reaper skips it
- cargo build + cargo test pass with no regressions
-
Manual: trigger an agent run, let it complete, observe its worktree's target/ is gone afterward; verify by
du -sh .wg-worktrees/agent-Nshowing only source-tree size, not GB-of-build-artifacts size - Document the reaper behavior in the operations docs so users understand it's automatic
Depends on
Required by
- (none)
Log
- 2026-04-27T17:19:11.055463506+00:00 Task paused
- 2026-04-27T17:19:23.310082061+00:00 Task published
- 2026-04-27T17:24:19.786927849+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-27T17:24:54.022552351+00:00 Starting task: build worktree target/ reaper. Reading existing sweep + worktree code first.
- 2026-04-27T17:49:12.819670450+00:00 Task marked as failed: Agent exited with code 1
- 2026-04-27T18:39:11.139741402+00:00 Reset by `wg recover` — reason: openrouter outage cleanup; everything moved to claude:opus
- 2026-04-27T18:39:52.306463143+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-27T18:40:09.522676656+00:00 Resuming from prior attempt — inspecting existing diff before continuing
- 2026-04-27T18:40:54.096553680+00:00 Task unclaimed: agent 'agent-806' (PID 1982229) process exited
- 2026-04-27T18:40:55.603578539+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-27T19:06:47.994772531+00:00 Recovered prior work — git stash dropped from working tree, recovered via dangling commit 8fa26d8. NOTE: never stash in this repo (per memory_never_git_add_dash_A and feedback).
- 2026-04-27T19:06:48.016560693+00:00 Reaper code restored: 8 files, 459 insertions. All target-reaper unit tests pass. Proceeding to install + smoke.
- 2026-04-27T19:10:47.374232834+00:00 Committed: 945a6b23a — pushed to origin
- 2026-04-27T19:11:58.893411154+00:00 Live smoke result: 151G → 1.8G disk reclaimed. Reaper removed 31 dead-agent target/ dirs across .wg-worktrees. Found and filed edge case 'reaper-edge-case' for the wg-retry-in-place path.
- 2026-04-27T19:12:08.128623795+00:00 Task marked as done