Skip to content

feat(execution): the fleet controller: spares, bind and release, starting, the stopping state, the housekeeping lease, the breaker, bound seconds #405

Closed

Description

@allisonmahmood

Part of #384. Implements the controller of spec §5, §9's starting, the breaker and binding metering of §14; decisions the execution service decisions 1–6 and the contracts, limits (Company task, residency, pool; Runaway code), the first-party surfaces as picked on the design ticket.

What to build

  • execution/fleet: the controller as host code over the platform database, not a service. It is exercised here against a local task provider (processes on the machine standing in for tasks) so every state transition is testable offline; the ECS provider arrives with the next ticket.
  • Migration execution_fleet (Execution record): tasks (identity, deployment revision, state), bindings (company, task, binding epoch, state including stopping, one admission-serving binding per company as a unique partial index), binding history, the housekeeping lease, process metering rows, breaker kills.
  • Bind: an atomic row claim on an unbound spare, company uniqueness enforced by the database, an ambiguous acknowledgement retried idempotently by task identity and binding epoch, never by a second claim. Callbacks go to the private address of the host that opened the transaction.
  • Starting (spec §9): a tier 2 document's bootstrap asks the controller to ensure its company is bound; the stream sends starting, then ready or, after 40 s, start_failed (busy with retryAfter). The broker holds server.calls until ready, within the frame's bounds, and refuses them busy on start_failed, never replaying. The shell's starting element (as picked) offers a retry and retries with backoff while the document is open. A stream drop while starting keeps held calls held.
  • Release: after 30 minutes with zero connected tier 2 documents and nothing in flight (retry attempts, nested calls after departure and transaction cleanup included), fence admissions by entering stopping under the owner check in one statement, then stop the task. It is never returned to the pool. An open racing the release binds fresh.
  • The housekeeping lease, held by one replica: replenish spares to max(2, wake rate over 15 min × measured cold start) under the fleet budget; release idle companies; reconcile orphans; replace tasks from a superseded deployment by fencing, binding fresh, routing new invocations and stopping the old after drain. The binding epoch, process generation, housekeeping lease and deployment revision stay four distinct things.
  • Metering: binding history yields bound seconds per company, reconciled from the provider's stop time when a task dies without a normal release; process metering rows written from the supervisor's reports. The binding wide event: bind to release, spare wait, peak processes, release cause.
  • The breaker: three kills of one patch within 10 minutes, across its versions and across host replicas, pause it for 10 minutes; invocation admission refuses patch_paused with retryAfter; a new publish clears it. Off in dev.
  • Controller operations as code for v1 fleet work: release a company, drain a task, retire a deployment's tasks, set a limit override. They read and write through the controller, never by row edits.

Admitted at merge

The fleet executor runs against the local task provider in tests. Production still needs the ECS provider.

Done when

Two binds for one company leave one admission-serving binding; a stop racing an adoption never crosses the stopping state; a release racing an open binds fresh; a lost task's bound seconds are reconciled; a pause expires after 10 minutes and a publish clears it on every host; a first open with an empty pool shows the starting element and admits held calls on ready.

Surfaces

Migrations (three call sites, ADR-0003, CLAUDE.md), ADR-0012 (the controller, the pool numbers, the breaker), the Runtime glossary (Company task, Spare, Bind / release, Housekeeping lease, Stopping, Paused), docs/limits.md, ui-consistency for the starting element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:serverarea:uiready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions