TaskLifecycle
Formal state machine governing task progression
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.
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
Parameters
- heartbeat_interval_seconds: type=Integer, range=[5, 300], description=Maximum seconds between heartbeats before RUNNING task is marked FAILED
Signature
- StateTransition(Task)
Preconditions
- Task exists in PENDING state
Postconditions
- Task in terminal state (COMPLETED, FAILED, or CANCELLED)
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).
Where this came from
—
Builds on
- Heartbeat references
- Task references
- Agent references
- Event references
- Risk references
- Exception references
- Result yields
- StateTransition composes_with
Identity
- Ref:
TaskLifecycle#5591 - Hash: sema:TaskLifecycle#mh:SHA-256:559124d595219af971fe018e4709077bbe77f3ce7e1769a058cbeffd4a11c38b
- Library: bootstrap 0.11.0, root a6a3d1ff0f98
- License: Not stated; check the repository