Infrastructure · Primitives
TaskLifecycle
Formal state machine governing task progression
Definition
Mechanism
Explicit StateTransition machine governing Task progression through five states: PENDING (created, awaiting assignment), ASSIGNED (claimed by an Agent), RUNNING (actively executing, emitting Heartbeat), COMPLETED (successfully finished, Result attached), FAILED (terminated with Exception, retry decision required). Each transition requires a typed Event: assign, start, complete, fail, cancel. Invalid transitions are rejected. RUNNING state requires periodic Heartbeat; timeout triggers automatic FAILED transition. The attached Risk profile informs retry and escalation policy on failure.
Preconditions
- Task exists in PENDING state
Postconditions
- Task in terminal state (COMPLETED, FAILED, or CANCELLED)
Invariants
- Forward-Only: Tasks must not regress (no COMPLETED to RUNNING via StateTransition)
- Single Owner: Exactly one Agent owns a Task in ASSIGNED or RUNNING state
- FAILED tasks must include an Exception describing the failure
- RUNNING tasks must emit Heartbeat within configured interval
Risks
Failure modes
Heartbeat timeout (agent dies silently — task stuck in RUNNING without timeout enforcement).
State desync (two agents believe they own the same task due to network partition).
Zombie tasks (FAILED tasks never retried or escalated — accumulate in queue).
Relationships
Builds on
Composes with
Explicit finite-state machine governance
References
Yields
The output of agentic transformation
Nothing in this library builds on this pattern yet.
Reference
Parameters
heartbeat_interval_secondsInteger, [5, 300]- Maximum seconds between heartbeats before RUNNING task is marked FAILED
Signature
StateTransition(Task)
