Tasks, jobs and resource lifecycle
Status: normative · Owns: state machines, retries, idempotency and effect processing.
A TaskSpec is not a prompt
Every task MUST have a stable ID, operator ID, goal, exact input references/digests, data class, effect classes, allowed regions/providers, budget/currency, deadline, acceptance oracle, desired outputs, retention and idempotency key. Requests missing essential constraints return needs_scope rather than improvising. Planned specs and approval-bound plan revisions are immutable.
Job lifecycle
received → scoped → planned → validated → awaiting_approval? → queued
→ leased → running → checking → completed
↘ failed | cancelled
awaiting_approval is mandatory for spend, external network transfers of restricted data, production writes, deletion, model downloads with relevant licensing consequences and other configured effects. Cancellation is a request until executor and provider states are reconciled. A completed answer does not imply chargeable resources were terminated.
Resource lifecycle
absent → proposed → quoted → approved → provisioning → ready → busy
→ draining → stopping → termination_verified → absent
Exceptions MUST have typed states including unreachable, cost_unknown, orphan_suspected, quarantined, stop_failed, and unknown_provider_outcome. Lack of heartbeat NEVER proves absence. The actual resource state is checked using provider-side inventory with owner tags and credentials outside model scope.
Dispatch invariant
Before a side effect: commit an outbox entry with effect_id, immutable payload digest, operator, exact grant ID, quote version and deterministic idempotency key. Workers consume a fenced lease (lease_id, generation, expiration, scope). Stale generations MUST fail. Commit outputs and a completion receipt transactionally when possible; external effects require idempotent reconciliation or compensation. A retry MUST NOT issue two paid allocations for the same effect; after an ambiguous provider response, query inventory before retry.
Checks and failure behavior
- Schema and semantic checks occur before cost quotation and again before execution.
- Worker cannot see complete operator secrets; use expiring scoped credentials where feasible.
- Timeouts yield explicit
timed_out; late receipts are checked against lease generation and never silently accepted. - Checkpoint payloads are hash-verified and stored outside ephemeral workers.
- A failed oracle marks results
not_acceptedeven if a model confidently reports success. - Reconciliation must handle delayed invoices and missing stop confirmation without making up a final bill.
- Operator emergency stop may use a separate privileged guardian even after web-session failure, but still writes audit evidence.
Recovery
Control restart reconstructs queue/outbox from durable state; lease guardian independently lists tagged provider resources, closes orphans where authorized and alerts on unknowns. A worker restart resumes from the last accepted checkpoint or restarts an idempotent node. Human approval is renewed for a materially changed plan or quote.
Related
Permissions · Operations · API.