feat(dev): lab reaps AFK runs on PR success, death, or timeout #73
No reviewers
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos!73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/63"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #63 — Slice 2 of #61 (lab owns the AFK-run lifecycle).
claude --remote-controlnever self-exits — an AFK run opens its PR and then idles, holding its tmux session and instance slot forever — so lab can't use "the session ended" as the done signal. This adds a single long-lived watcher goroutine (lab's first server-side periodic worker) that sweeps live AFK runs on a ~30s tick and reaps each terminal one, freeing its instance slot.Behavior
afk/<N>PR exists: stop the session, remove the worktree; the branch + PR survive (the PR'sCloses #Ncloses the issue on merge). A present PR is success regardless of session liveness (a run that opened its PR then died still succeeded).afk/<N>PR is treated as no PR (so the run fails on death/timeout rather than being falsely reaped as success).Design (per ADR-0007)
Tracker.ListPullsseam (tea pulls list, head + state matched client-side), mirroring the existingReadyIssuesseam and substitutable by the test fake.classifyAFKRun(prPresent, sessionAlive, age, budget)is the unit-tested core — no tmux, tea, or clock.reapAFKRun) — the seam #65 will extend to count consecutive failures. This slice reads/writes no failure counter.afkRunsMufrom fresh liveness and claims the run atomically, so a manual Stop racing a sweep is never reaped as a failure.Tests
go test ./...green under-race;go vet/go buildclean. Covers the done/failure/in-progress classification (including PR-present-but-session-dead = success and closed-unmerged = not-success), each reap path over a real tmux, the neutral manual Stop, and the stop-vs-reap concurrency.