Skip to content

engine run's session check across hosts - #79

Merged
dinoderek-agents merged 2 commits into
mainfrom
task/engine-63
Oct 25, 2026
Merged

dinoderek-agents merged 2 commits into
mainfrom
task/engine-63

Conversation

@dinoderek-agents

Copy link
Copy Markdown
Collaborator

Objective

engine run's 60-second session check and every pass read one status per 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's release. waiting-since (and stall-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

Lane Result Evidence
./dev test (every required lane) PASS format, vet, lint, unit, coverage, file-length, imports, versions, docs-check: all PASS at fef8d15 (.test-ai-results/summary.md, Overall: PASS)
  • New or changed tests:
    • 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 from status, dead → failed, died before claiming → released there and restarted, restart after the window vanished, reaped through release, 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 agents failing 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.Release goes to the named host.
    • internal/run/fake_test.go, scenario_test.go, place_test.go, done_test.go: the fake world now answers status per 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.
  • Not run, with reason: none.

Rulings

Ruling (risk: med): engine start deletes 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 refuseExisting in internal/session/worktree.go and its tests.

Ruling (risk: med): stall-noted moves 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 status must 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
  • Ruling (risk: low): the stall screen comes from status, which sends one only for a window whose session is not busy; a busy unclaimed session's stall comment has no screen.
  • Ruling (risk: low): during wind-down, a closed task's session on an unreadable host counts as live whatever its mode (gated too, since an unknown session's mode is unknown), so the run waits up to 15 minutes.
  • Ruling (risk: low): when claude agents fails on a host, waiting-since is left untouched.
  • Ruling (risk: low): a session started by a coordinator on another host, or by an older build, has no started-on note; 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.
  • Ruling (risk: low): World shape: HostLoad carries the raw Status; Rows(Fleet); Release(host, name); Windows, Agents, LatestRun, Capture and Kill removed; the session-note constants move from internal/session to internal/run. The unreachable log moves from Gather to the loop (outages).

Review

  • Fresh reviewer: Claude Code, claude-opus-5-5. Round 1: APPROVED with four optional findings, all fixed in 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.
  • Declined findings:
  • Review hard: 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 (refuseExisting deletes a branch).

Deviations

None from the card. Beyond its doc list: docs/hosts-and-sessions.md (worktree branch rule), docs/architecture.md and docs/project-brief.md (the session check across hosts is built).

🤖 Generated with Claude Code

https://claude.ai/code/session_01QnbKRgXHnjhbHNBfGcJJ99

dinoderek-agents and others added 2 commits October 25, 2026 20:28
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
@dinoderek-agents
dinoderek-agents merged commit f4d079e into main Oct 25, 2026
1 check passed
@dinoderek-agents
dinoderek-agents deleted the task/engine-63 branch October 25, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine run's session check across hosts

1 participant