---
library: "bootstrap"
slug: "TaskLifecycle"
name: "TaskLifecycle"
ref: "TaskLifecycle#5591"
hash: "sema:TaskLifecycle#mh:SHA-256:559124d595219af971fe018e4709077bbe77f3ce7e1769a058cbeffd4a11c38b"
type: "Primitives"
layer: "Infrastructure"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/TaskLifecycle"
---

# TaskLifecycle

Formal state machine governing task progression

Infrastructure · Primitives

## Mechanism

Explicit [StateTransition](https://semahash.org/vocabularies/bootstrap/patterns/StateTransition.md) machine governing [Task](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) progression through five states: PENDING (created, awaiting assignment), ASSIGNED (claimed by an [Agent](https://semahash.org/vocabularies/bootstrap/patterns/Agent.md)), RUNNING (actively executing, emitting [Heartbeat](https://semahash.org/vocabularies/bootstrap/patterns/Heartbeat.md)), COMPLETED (successfully finished, [Result](https://semahash.org/vocabularies/bootstrap/patterns/Result.md) attached), FAILED (terminated with [Exception](https://semahash.org/vocabularies/bootstrap/patterns/Exception.md), retry decision required). Each transition requires a typed [Event](https://semahash.org/vocabularies/bootstrap/patterns/Event.md): assign, start, complete, fail, cancel. Invalid transitions are rejected. RUNNING state requires periodic [Heartbeat](https://semahash.org/vocabularies/bootstrap/patterns/Heartbeat.md); timeout triggers automatic FAILED transition. The attached [Risk](https://semahash.org/vocabularies/bootstrap/patterns/Risk.md) profile informs retry and escalation policy on failure.

## Invariants

- Forward-Only: Tasks must not regress (no COMPLETED to RUNNING via [StateTransition](https://semahash.org/vocabularies/bootstrap/patterns/StateTransition.md))
- Single Owner: Exactly one [Agent](https://semahash.org/vocabularies/bootstrap/patterns/Agent.md) owns a [Task](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) in ASSIGNED or RUNNING state
- FAILED tasks must include an [Exception](https://semahash.org/vocabularies/bootstrap/patterns/Exception.md) describing the failure
- RUNNING tasks must emit [Heartbeat](https://semahash.org/vocabularies/bootstrap/patterns/Heartbeat.md) 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](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) exists in PENDING state

## Postconditions

- [Task](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) 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](https://semahash.org/vocabularies/bootstrap/patterns/Heartbeat.md) (references)
- [Task](https://semahash.org/vocabularies/bootstrap/patterns/Task.md) (references)
- [Agent](https://semahash.org/vocabularies/bootstrap/patterns/Agent.md) (references)
- [Event](https://semahash.org/vocabularies/bootstrap/patterns/Event.md) (references)
- [Risk](https://semahash.org/vocabularies/bootstrap/patterns/Risk.md) (references)
- [Exception](https://semahash.org/vocabularies/bootstrap/patterns/Exception.md) (references)
- [Result](https://semahash.org/vocabularies/bootstrap/patterns/Result.md) (yields)
- [StateTransition](https://semahash.org/vocabularies/bootstrap/patterns/StateTransition.md) (composes_with)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: TaskLifecycle#5591
- Hash: sema:TaskLifecycle#mh:SHA-256:559124d595219af971fe018e4709077bbe77f3ce7e1769a058cbeffd4a11c38b

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/TaskLifecycle
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/TaskLifecycle.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
