Metadata
| Status | done |
|---|---|
| Assigned | agent-823 |
| Agent identity | f51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e |
| Created | 2026-04-27T19:11:54.714369991+00:00 |
| Started | 2026-04-27T19:13:02.195395624+00:00 |
| Completed | 2026-04-27T19:45:28.315875888+00:00 |
| Tags | eval-scheduled |
| Eval score | 0.89 |
| └ blocking impact | 0.90 |
| └ completeness | 0.90 |
| └ coordination overhead | 0.88 |
| └ correctness | 0.95 |
| └ downstream usability | 0.80 |
| └ efficiency | 0.80 |
| └ intent fidelity | 0.80 |
| └ style adherence | 0.92 |
Description
Description
Found while smoke-testing worktree-target-dirs reaper:
When agent-772's task fails and is retried as agent-806, agent-806 runs in agent-772's preserved worktree (the wg retry-in-place flow). However, the registry entry for 'agent-772' shows status=failed/dead with a stale heartbeat. The new agent-806 has its own registry entry but the directory is named 'agent-772/'.
reap_dead_target_dirs looks up liveness by directory name (agent-772), so it will reap target/ from under an actively-building wg retry agent.
Smoke-tested 2026-04-27: my own target/ in agent-772/ was reaped while agent-806 was actively using the worktree. No data loss (cargo rebuilds, source files preserved), but it forces a slow rebuild on resume.
Required
The reaper should detect 'is this worktree currently in use' beyond just looking at the original-owner registry entry. Two options:
- Walk the registry for ANY agent whose
worktree_pathmatches; treat the worktree as live if any such agent is_live(). - Add a 'current_occupant' / 'worktree_lease' field set by spawn that the reaper checks.
Option 1 is simpler if AgentEntry already has a worktree_path field. Option 2 is more explicit.
Files
- src/commands/service/worktree.rs (reap_dead_target_dirs)
- src/service/registry.rs (add lookup helper if needed)
Validation
- Failing test first: register agent-A (dead) and agent-B (live) where both list the same worktree path; assert reaper skips that worktree
- Existing tests still pass (skip-live, idempotent, orphan)
- Live smoke: trigger wg retry on a failed task, run wg sweep --reap-targets while retry-agent is building; assert target/ survives
Depends on
Required by
- (none)
Log
- 2026-04-27T19:13:00.267670591+00:00 Lightweight assignment: agent=Careful Programmer (f5143935), exec_mode=full, context_scope=graph, reason=Careful Programmer's high score (0.72) and 111 completed tasks make it ideal for this correctness-critical race condition fix; 'Careful' tradeoff matches the need for exhaustive testing and verification per project memory; task spans registry/worktree system components requiring graph-level context.
- 2026-04-27T19:13:02.195401906+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-27T19:13:10.215485786+00:00 Starting work on reaper-edge-case: protect target/ of worktrees in active wg retry
- 2026-04-27T19:27:35.428884029+00:00 All unit tests pass: 5 reaper, 35 registry, 2041 lib tests, 12 worktree integration tests
- 2026-04-27T19:44:32.131816508+00:00 Live smoke passed: target/ survives wg sweep --reap-targets when live retry agent occupies the worktree; negative control reaps when both agents dead
- 2026-04-27T19:45:00.900221196+00:00 Committed: 3a67135d1 — pushed to remote
- 2026-04-27T19:45:28.315891518+00:00 Task pending eval (agent reported done; awaiting `.evaluate-*` to score)
- 2026-04-27T19:47:22.282260126+00:00 PendingEval → Done (evaluator passed; downstream unblocks)