Skip to main content

Module controller_backstop

Module controller_backstop 

Source
Expand description

A backstop for agent panes nobody connected to after a restart. A controller is registered when a window’s pane mounts and resyncs its block, so an agent block in a layout that no open window shows (another workspace, a window that was not reopened) has no process and no controller until someone looks at it. Some seconds after startup, once the windows that are going to reconnect have asked for their panes, this registers the controller of each such block through the same resync a pane does.

It runs after the boot refresh-token single-flight (identity::token_warmup) and goes through the same spawn gate: the controller’s spawn takes the account’s warm-up slot and the sign-in check, so panes on one account are started one after the other, not at once. A block whose account is signed out or out of quota is left alone (its turn would only fail), as is one the user stopped (agent:desired = stopped) and one a terminal view starts.

Constants§

DELAY 🔒
How long after startup the backstop runs: windows reconnect and resync their own panes first (a few seconds after srv is up), and a pane one of them got to has a controller by now.
GAP 🔒
Between two registrations, so a layout of many agents does not start them in one burst.

Functions§

candidates 🔒
The agent blocks in a tab that have no controller and should have one: (block_id, tab_id). Each one it leaves alone is logged with the reason, so an agent a restart did not bring back says why.
failed_on_its_account 🔒
The pane’s last turn failed because its account is signed out, or out of quota until a reset not yet reached: starting it would only fail again. (agent_state::unavailable_of_block reads this only from a pane with a controller, which these have not.)
install 🔒
Run the backstop once, DELAY after startup.
left_alone 🔒
Why the backstop leaves an agent block in a tab alone (it has no controller), None when it starts it.
run_once 🔒
Register the controllers candidates names. Returns how many.
starts_no_controller 🔒
Why a pane never gets a controller from the backstop or a restart: its harness was removed (its saved command would launch a CLI AgentMux no longer offers, and the pane says so when opened), or its term view starts it once attached.