Login controller

The Login controller: the plug's check and request through the runtime port, and the Tasks' turn failures, go in; it decides the incident and the posts; Login status and posts through the Gateway port come out

The Login controller watches one harness's login on one place. It decides from the Login, the answers of the harness's [login] plug, the turn failures that the Tasks report, and the time. The manager runs each command on the place and performs each post.

Read Answers
Login What does the status hold?
The plug What does an agent supply, and what does Fleet do with it?
State machine When does an incident open and close?
Interface What does the controller read, and what does the manager do?
Task controller How does a Task hold its work, and get its note to continue?

One run #

  1. A Task uses a harness whose profile has a [login] plug. The manager creates the Login of that harness and place, at the start of a sweep.
  2. The controller asks for the login check. The manager runs it on the place through the runtime port.
  3. The check's answer is one of three: a login is stored, with its end time when the plug reads one; no login is stored; or blind, an answer the plug cannot read. A blind answer opens nothing.
  4. An agent's turn fails on its login. Its hook runs fleet signal blocked with the hook's payload. The Task shows attention, and TaskController records loginFailed. The Login is due at once.
  5. The controller opens one incident and queues one alert. The manager posts it. Each Task of the harness on the place holds its work.
  6. Every 5 minutes, the check runs again. When it reads a stored login, the recovery request runs. A request that exits 0 closes the incident. Any other answer, a rate limit or an outage included, keeps it open.
  7. The reply to the alert lists the Tasks the incident stopped. Each one gets one note to continue, and the holds end.

The plug #

A harness profile's [login] table is the plug: the only part that knows the agent. Each part is optional. Profile format owns the keys.

Part Supplies Fleet uses it to
[login.check] A local command that says whether a login is stored, and how to read its answer Check every 5 minutes, and at the first sweep after a Task needs the place
[login.failure] The payload field that names a failed turn's error type, and the types that mean the login Open an incident at once when a turn fails on the login
[login.probe] A real minimal request Prove that the login works, only to close an incident
warn_days Days before the login's end time to warn Warn once per end time

Fleet ships plugs for these agents:

Harness Check Turn failure Recovery request Warning
claude claude auth status, read from its JSON: loggedIn, and loginExpiresAt, the latest end of the login StopFailure, error types authentication_failed, oauth_org_not_allowed, account_on_hold, billing_error and cloud_credential_error claude -p --model haiku --no-session-persistence --output-format json 'Reply with OK.' 10 days, as Claude Code's own warning
codex codex login status: exit 0 with Logged in, or exit 1 with Not logged in none codex exec --ephemeral --skip-git-repo-check 'Reply with OK.' none: it reports no end time
  • claude auth status exits 1 when no login is stored, and also when it cannot run. Only its JSON tells the two apart, so the plug reads the JSON and not the exit code. Output that is not JSON, as while claude update replaces the program, is blind.
  • codex login status exits 1 when no login is stored and when its config cannot load. Only the words Not logged in tell them apart.
  • Codex 0.154.0 runs no hook after UserPromptSubmit when a turn fails on a login: not Stop, not PreModelRequest, not PostModelRequest, and not its notify. So a Codex turn failure does not open an incident. The check opens it once the login is gone.
  • The other bundled agents have no plug. Their documentation names no login check and no typed turn failure.

Rules for a plug #

  • [login.failure] needs [login.probe]: only a request that works closes an incident that a turn opened.
  • Each failure type has lowercase letters, digits and _ only. fleet signal records a type only when the payload's field equals one of the listed types. A message to people names only that type, never the payload's text.
  • warn_days needs [login.check] json.ends_at.
  • The check and the request run as the runtime's exec on the place, with the place's environment. A Task that sets its own login in its environment uses a login the check does not see.

Implementation and evidence #

Responsibility Source Tests
Pure decisions: the check's answer, the incident, the posts, the schedule LoginController Unit tests in login.rs; Login E2E
The Task's hold, its loginFailed and its note to continue TaskController Task login passes
Resource, status and messages Login types, validation Unit tests in login.rs
The plug, its answers and the signal's failure type Harness profiles, signal Plug tests
Creation, sweep, runs, intent before post, receipts Manager Login E2E
Crate edges and the field manager architecture.toml Architecture suite

The E2E suite runs the fleet binary on the file store with the fake runtime and the fake gateway. Two Tasks fail on their login: both show attention, one incident opens and one alert is posted. A Task applied then stays Pending with LoginHeld. A failed request keeps the incident open. A request that works closes it: the reply goes into the alert's thread and lists both Tasks, each gets its note to continue, and the held Task spawns. A check that prints no JSON opens nothing and tells people once.

Login state machine #

Login state machine: a Login works until a turn fails, the check finds no login or the login ended; then one incident opens with one alert; a recovery request that exits 0 closes it, and anything else keeps it open; a blind check opens nothing

The controller does these steps in this order on each pass:

  1. It reads the receipts of its posts.
  2. It reads the check's answer, when the check ran.
    • Blind: it counts the runs in a row. At 3, it tells people once.
    • Readable after blind: it tells people the check reads again, if it told them it was blind.
    • No login, or an end time in the past: it opens an incident.
    • A login whose end time is within warn_days: it warns once for that end time, unless an incident is open.
  3. It reads the turn failures of its Tasks. A failure later than provenAt opens an incident, or joins the open one.
  4. It reads the request's answer, when the request ran. Exit 0 closes the incident and sets provenAt. Any other answer keeps it open.
  5. For a plug with no request, a fresh check that reads a stored login closes an incident the check opened.
  6. It plans the first post that is not delivered.

An incident opened within an hour of the last close takes that close's number again. Its alert was posted already, so no new alert goes out. This keeps a login that fails again at once from posting each time.

Conditions #

Condition True False Unknown
LoggedIn Stored: the check reads a login. The message gives its end time. NotStored: the check reads no login. CheckBlind: the check's answer cannot be read.
Works Proven: no incident is open, and a request or a check proved it. TurnFailed, LoggedOut or Expired: an incident is open. RequestFailed: the last request did not work. —
Notified Posted: every post went out. NoDestination: an incident is open and there is no channel to post to. PostFailing: a post failed 3 times and is retried. Posting: a post is not delivered yet.

Where the posts go #

The gateway's existing destinations carry the posts. Fleet has no channel of its own for a host's events:

  1. The first channel of the route that [gateway] questions names, as for a Task's Question.
  2. Else the [gateway] logs channel.
  3. Else no post. The Login's conditions still say what happened.

The alert, a warning and a blind notice each open a thread through the Gateway port's open. The reply after a recovery goes into the alert's thread. A post's text is Fleet's own sentence: it names the harness, the place, Task names, an error type from the plug and a time. No text of the agent's reaches it.

Login controller interface #

Controller API #

rust
impl LoginController {
    pub fn due(object: &Object, now: Millis) -> bool;
    pub fn due_with(object: &Object, now: Millis, tasks: &[TaskUse]) -> bool;
    pub fn asks(&self, input: &LoginInput<'_>) -> Result<Vec<Ask>, StoreError>;
    pub fn reconcile(&self, input: &LoginInput<'_>) -> Result<Plan, StoreError>;
}
  • due_with is also true when a Task reports a turn failure later than provenAt that the incident does not list. A failure opens the incident at the next sweep, not at the next check.
  • asks returns Check when the check is 5 minutes old, then Probe while an incident is open, the latest check is not logged out or past its end, and the request is 5 minutes old.
  • notBefore names a probe only when asks would return it: never while the check reads no login or a past end. After an Unknown check or request, the next pass is 30 s later.

Manager execution protocol #

  1. At the start of each pass, the manager groups the Tasks that are not being deleted by the harness and the place of their launch. It creates the Login of each group whose profile has a plug.
  2. Before it reconciles a Task with no session, it reads the Task's Login, for the harness and place that the Task resolved. When the Login is missing or has never been reconciled, the manager creates it and reconciles it at once, as in step 3. So a Task's first spawn comes after its Login's first check, also when a TaskConfig names the harness.
  3. For each Login that is due, it renews the lease and answers each ask with the runtime port's run: 10 s for the check, 120 s for the request.
  4. It writes the planned status, with each post's intent.
  5. It performs each post through the Gateway port, renewing the lease, and writes each receipt.
  6. It deletes the Login when the plan says so.

The runtime's exec verb bounds each command. A command's time is within workspaceTimeoutMs, so operation_bound, and the lease, still hold.

Recovery #

  • An Unknown run changes nothing, and the next pass comes 30 s later.
  • A post that failed, or whose answer is Unknown, is posted again after 30 s, then twice as long each time, up to 15 minutes. A post is never given up on. An Unknown answer can repeat a post: Fleet prefers a repeated alert to a lost one.
  • One manager holds the lease, and every write is compare-and-swap. Several Tasks that fail at once open one incident and post one alert.

Store port and write ownership #

LoginController owns all of a Login's status. Only the manager creates a Login, through create_fenced under the lease; fleet apply refuses it. The spec is fixed once created.