fix(reconcile): runtime dead-session sweep — end manual runs whose tmux session is gone (#93) #95
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab!95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/93"
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 #93
What
Generalizes readopt's death rule to a periodic runtime tick, owned by
internal/reconcile: every 30s, any active manual run (store.RunKindManual) whose tmux session is gone getsEndRun(death, "session gone")and arun.changedpublish. This closes the zombie-row gap — previously a manual run whose agent died at runtime stayed active forever (instance list showedlive=falseagainst an active row; the chat tailer polled the corpse until the next lab restart). It is also the hard-evidence half of #62's backstop and the future notification layer's "run died" chokepoint.Design (per the issue)
sweepDeadSessions,internal/reconcile/sweep.go): the runtime sibling of readopt, with a distinct pinned reason string ("session gone"vs readopt's"session gone at startup"— startup behavior unchanged).ActiveRunsfirst (a row inserted later is invisible),guard.Snapshot()strictly beforerunner.List, reap only if the session is in neither set. Verified againstinstance.Launchordering (Mark atlaunch.go:78→CreateRunat:169→ tmuxStartat:222→ deferred Clear), the only productionCreateRunsite.DeadSessionLoop, 30s,sweepTickfamily) rather than riding the reaper'ssweep_interval_minuteshook — that hook is throttled to 10 minutes by default, and a dead run should flip to ended within one short tick. No new settings key; fixed constant matches the existingsweepTickidiom. Wired incmd/lab/main.gobeside the reaper/scheduler loops, nil-guarded for degraded mode.Listerror reaps nothing (never misread as "everything is dead"); a missing tmux server already reads as zero sessions intmuxx, which is hard evidence.run.changed— nothing re-implemented here.Acceptance mapping
death/"session gone"+run.changedwithin one tick:TestSweepDeadSessions_deadManualReapedLiveManualKept,TestSweepDeadSessions_publishesRunChanged(tailer disarm/spool GC ride the existingrun.changedsync,internal/chat/tailer.go).TestSweepDeadSessions_afkKindsUntouched(reaper classification code untouched by this PR).TestSweepDeadSessions_startguardRace(Mark → not reaped; Clear → reaped), beside the existing startguard fixtures.Verification
gofmt -lclean,go build ./...,go vet ./...,go test ./...— all green except the pre-existinginternal/tmuxxreal-tmux integration failures, which fail identically on a clean tree in this sandbox (no working pane shell) and are unrelated.🤖 Generated with Claude Code
https://claude.ai/code/session_014MZmEYoNVSCQGvKawAzGf3