Repository navigation
fix(control): let sessions carry on when their runner comes back - #94
Merged
Merged
Conversation
A runner away for ten minutes loses its sessions: FleetDO marks them stopped. When the runner came back with an agent still at work, the fleet stopped that agent as if the session had been deleted, and what it did meanwhile never reached the transcript. FleetDO now remembers the sessions it stopped for their runner's absence. When the runner comes back with one, and no other run has started since, the session carries on there: FleetDO assigns it again, restores its runner so the host's uplink can replay the agent's events, and the transcript says the runner is back. A session that moved to another runner meanwhile, that someone stopped, put away or deleted, still stops, with a reason that says which. Refs #46
…s up on it When the fleet stopped a session because its runner stayed away, SessionDO sent viewers the runner's state before the session's: no runner, so no absence to report, for a session still running. fctl attach took that for the runner's return and printed "runner … is back" just before "stopped". SessionDO now sends the runner's state after the summary. Refs #46
A runner that comes back after its session moved to another runner gets its old run stopped. When that run ended, FleetDO took its report for the session's end and marked the session stopped, though it ran on the other runner: it only ignored reports of earlier runs on the same runner. A report from a runner the session doesn't run on is now ignored too (fctl_domain::reconcile::ended_earlier). Refs #46
5 of 7 tasks
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.
In #46, runner
nowwent quiet for half an hour while its agent kept working. After ten minutes the fleet marked the session stopped. And when a runner came back with an agent still at work, the fleet told its host to stop that agent "because the session was deleted": the agent was interrupted, and what it did meanwhile stayed in its sandbox's journal, because the session was no longer the runner's and the host's uplink was refused. This does item 7 of #46, and settles the decisions it left.What changes
A session stopped only because its runner was away carries on when the runner comes back with it. FleetDO remembers the sessions it stops for their runner's absence (
stopped_away, in its storage). When that runner's hello reports one of them running, and no other run of it has started since, FleetDO assigns it to the runner again and gives the session back its runner. The host's uplink then gets in and replays the agent's journal, so the transcript fills in what the agent did meanwhile. The transcript says "Runner now is back with the agent still running, so the session carries on there."So does a session resumed meanwhile that no runner took. With one runner, a message to the stopped session queues it ("Waiting for a runner"). When the runner comes back, the agent that still runs gets the message, rather than being stopped for a new run.
Otherwise the old run stops, with a reason that says why:
Shutdownwhen the session runs on another runner by then;Deletedwhen its project was deleted;Userwhen someone stopped or archived it.All of them used to get
Deleted.The stopped status says what happens: "Runner now has been offline for 10 minutes. If it comes back with the agent still running, the session carries on there; a message resumes it on another runner." It used to end "Resume the session to continue elsewhere."
The decisions are pure functions in
fctl_domain::reconcile, with unit tests.Docs:
docs/architecture.md(A runner that goes away),docs/getting-started.md, and ADR 0020.Found on the way, fixed here
reconcile::ended_earlier).maintakes this path too, withStopReason::Deleted.fctl attachprinted "runner now is back" just before "stopped" when the fleet gave up on a runner. SessionDO sent the runner's state before the session's, sofctl attachsaw no absence for a session it still thought active. It now sends it after the summary.Decisions
#46 left three questions for a person. The person who started this session asked for what was left of #46 to be done, so this takes the answers suggested in the issue, and ADR 0020 records them:
Compatibility
Control plane only: no protocol change, no migration (FleetDO's new table is created with
IF NOT EXISTS), and no host or agent release. Hosts already report their sessions in every hello. FleetDO's internalControlStatefor SessionDO gains an optionalnotice.How I verified it
fctl_domain::reconcile: which reported runs carry on, are kept or stop, with which reason, and which ended runs are earlier ones.cargo xtask check, before and after mergingmain.cargo xtask dev, with its host started on its own so that I could kill it (SIGKILL: the process driver's agents keep running), and fake-claude slowed down (FAKE_CLAUDE_DELAY_MS). To keep the waits short, cases 1 to 4 and 6 ran on a control plane built with the grace period at one minute; case 5 used the real ten minutes.fctl attachsaid◌ runner dev-host is away (last heard from just now); the agent's work shows up here when it's back: A stalled host freezes transcripts and stops sessions whose agents are still working #46's item 6, from feat: show when a session's runner is away or can't reach its agent #69. The fleet then stopped the session with the new wording, while the agent finished its turn in the sandbox: journal atagent_seq15, 5 acknowledged. With the host back, the session went idle, the transcript said the runner is back, and the replay brought the turn:Bash(ls -la),Write(away.md), the commit and the result.dev-host-2: the first host killed, the session stopped, and a message resumed it ondev-host-2in a new sandbox. When the first host came back, its old run stopped (Shutdown; FleetDO loggedignoring the end of an earlier run), and the session stayed idle ondev-host-2. Before theSessionEndedfix it showed "Stopped because the host is shutting down" instead.User), and the session stayed stopped and archived.main(fix(agent): keep sessions up while agents wait for background tasks #91, feat(host): make room when the disk runs low #93), case 1 again, with the host and the control plane built from the merge.Screenshots
At 46cdef2, before merging
main, which doesn't change these screens. The session page after its runner was killed mid-turn, stopped by the fleet, and brought back, with this branch's control plane and withmain's, against the same local state.main)notes.md, the commit, "Turn finished". The session waits for a message.Refs #46
Session: https://app.fctl.sh/s/ses_01M585PP4R26Y6BKA64816JD1W