Login controller
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 #
- 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. - The controller asks for the login check. The manager runs it on the place through the runtime port.
- 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.
- An agent's turn fails on its login. Its hook runs
fleet signal blockedwith the hook's payload. The Task showsattention, and TaskController recordsloginFailed. The Login is due at once. - The controller opens one incident and queues one alert. The manager posts it. Each Task of the harness on the place holds its work.
- 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.
- 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 statusexits 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 whileclaude updatereplaces the program, is blind.codex login statusexits 1 when no login is stored and when its config cannot load. Only the wordsNot logged intell them apart.- Codex 0.154.0 runs no hook after
UserPromptSubmitwhen a turn fails on a login: notStop, notPreModelRequest, notPostModelRequest, and not itsnotify. 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 signalrecords 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_daysneeds[login.check] json.ends_at.- The check and the request run as the runtime's
execon 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 #
The controller does these steps in this order on each pass:
- It reads the receipts of its posts.
- 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.
- It reads the turn failures of its Tasks. A failure later than
provenAtopens an incident, or joins the open one. - It reads the request's answer, when the request ran. Exit 0 closes the
incident and sets
provenAt. Any other answer keeps it open. - For a plug with no request, a fresh check that reads a stored login closes an incident the check opened.
- 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:
- The first channel of the route that
[gateway] questionsnames, as for a Task's Question. - Else the
[gateway] logschannel. - 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 #
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_withis also true when a Task reports a turn failure later thanprovenAtthat the incident does not list. A failure opens the incident at the next sweep, not at the next check.asksreturnsCheckwhen the check is 5 minutes old, thenProbewhile an incident is open, the latest check is not logged out or past its end, and the request is 5 minutes old.notBeforenames a probe only whenaskswould 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 #
- 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.
- 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.
- 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. - It writes the planned status, with each post's intent.
- It performs each post through the Gateway port, renewing the lease, and writes each receipt.
- 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.