Repository navigation
engine run's session check across hosts - #79
Merged
Merged
Conversation
Every check and pass reads one status per host, in parallel, and takes liveness, waiting, stall screens and dead detection from those replies. Reaping, and closing a session that died before claiming, use the session host's release. waiting-since and stall-noted move to the coordinator's note directory. A host that cannot be read leaves its sessions unknown: never failed, stalled, restarted or reaped, and the outage is logged once. A leftover local branch with no commits of its own is remade, so a restart after a pre-claim death no longer hits "branch exists". Refs #63 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnbKRgXHnjhbHNBfGcJJ99
… session Refs #63 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnbKRgXHnjhbHNBfGcJJ99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
engine run's 60-second session check and every pass read onestatusper host, in parallel. Liveness, waiting, stall screens and dead detection come from those replies. Reaping, and clearing an ended session before a restart, go through the session's host'srelease.waiting-since(andstall-noted) live in the coordinator's note directory for every host. A host that cannot be read leaves its sessions unknown: never failed, stalled, restarted or reaped, and the outage is logged once.Closes #63
Gates
./dev test(every required lane)fef8d15(.test-ai-results/summary.md,Overall: PASS)internal/run/remote_test.go: a remote session working, waiting (note in the note directory, not the run directory; one stall with the screen; cleared when it works), unclaimed stall with the screen fromstatus, dead → failed, died before claiming → released there and restarted, restart after the window vanished, reaped throughrelease, an unreachable host for 6 checks (nothing failed/restarted/reaped, one log line, recovers), an unclaimed session on an unreachable host not restarted, an unknown planner,claude agentsfailing keeps the wait, a kept worktree logged, stalls matched per session whatever the clocks.internal/run/system_test.go:System.Rows(Fleet)settles local and remote claims from the replies (and leaves them unknown on failure);System.Releasegoes to the named host.internal/run/fake_test.go,scenario_test.go,place_test.go,done_test.go: the fake world now answersstatusper host; existing scenarios updated to it.internal/session/integration_test.go,worktree_test.go,internal/hostops/spawn_test.go: a leftover local branch with no commits is remade from the default branch; one with commits is still refused.Rulings
Ruling (risk: med):
engine startdeletes and remakes a task's local branch that has no worktree, is not on origin and has no commits of its own; a branch with commits is still refused.Why: restarting a task whose session died before claiming hit "branch exists"; such a branch holds no work, and this needs no wire-contract change.
If wrong: revert
refuseExistingininternal/session/worktree.goand its tests.Ruling (risk: med):
stall-notedmoves to the coordinator's note directory, per task, and holds the session start or wait it flagged; stalls compare to it by equality (to the second).Why: a remote run directory is not writable from here, and two clocks are now in play.
If wrong: one note's meaning in
internal/run; an old note causes at most one repeat stall comment.Ruling (risk: med): the coordinator writes
started-on-<host>when it starts a session, so a session on an unreadable host stays unknown before it claims. A pass that starts a task makes that task's note directory.Why: a failed
statusmust leave that host's sessions unknown; without it a pre-claim session could be started again elsewhere.If wrong: drop the note and its reader in
internal/run/sessions.go.Ruling (risk: med): before starting a task again, the coordinator releases its last session (ended, on a host that answers) on that host, whether or not the window survived; a clean worktree is removed.
Why: settles the restart path after a pre-claim death, including after a host reboot.
If wrong: narrow one condition in
startTask.Low-risk decisions
status, which sends one only for a window whose session is not busy; a busy unclaimed session's stall comment has no screen.claude agentsfails on a host,waiting-sinceis left untouched.started-onnote; while its host is down and it is unclaimed, it is not found and may be started again elsewhere, where the executor's claim check ends the duplicate.Worldshape:HostLoadcarries the rawStatus;Rows(Fleet);Release(host, name);Windows,Agents,LatestRun,CaptureandKillremoved; the session-note constants move frominternal/sessiontointernal/run. The unreachable log moves fromGatherto the loop (outages).Review
fef8d15(stall notes by equality, release before any restart, a test rename, a no-waiting-since-in-run-dir assertion). Round 2 (new reviewer): APPROVED with three optional findings.started-onnote on an unreachable host may be restarted elsewhere): accepted as the low ruling above; the executor's claim check ends the duplicate.RunsErrorwith an older readable run elsewhere): declined; an unreadablerun.jsonon the claimed host is rare, and the claim's host still settles dead detection throughps, so the cost is at most one stall decision on stale data.internal/run/sessions.go(which host a session is read from, and when it is unknown);internal/run/decide.go(unknown sessions and stall flags);internal/session/worktree.go(refuseExistingdeletes a branch).Deviations
None from the card. Beyond its doc list:
docs/hosts-and-sessions.md(worktree branch rule),docs/architecture.mdanddocs/project-brief.md(the session check across hosts is built).🤖 Generated with Claude Code
https://claude.ai/code/session_01QnbKRgXHnjhbHNBfGcJJ99