On this page
Sommatic Docs
Open portal

Worker state machine

The finite state machine of a Link Loom worker: its seven states, the nine events that move it, the hook each transition runs and what a workflow step uses.

View as Markdown
Open in

Every worker instance, and so every node step, is driven by the WorkerStateMachine of the Link Loom SDK: a deterministic state machine moved only by commands, with no timers or background loops. Each transition runs one hook of the worker; if the hook throws, the instance goes to CRASHED.

States

StateMeaning
(none)Before CREATE: the instance does not exist yet
INACTIVECreated and prepared; no active work
ACTIVE_FOREGROUNDActive with foreground semantics
ACTIVE_BACKGROUNDActive with background semantics: where a node does its work
SUSPENDEDResources released, minimal footprint; can resume
TERMINATINGGraceful shutdown in progress
TERMINATEDFinal: the instance is removed
CRASHEDFinal: a hook threw during a transition

Events and transitions

EventFromToHook it runs
CREATE(none)INACTIVEsetup
ACTIVATE_BACKGROUNDINACTIVEACTIVE_BACKGROUNDactivateBackground
ACTIVATE_FOREGROUNDINACTIVEACTIVE_FOREGROUNDactivateForeground
DEACTIVATEACTIVE_*INACTIVEdeactivate
SUSPENDINACTIVE, ACTIVE_*SUSPENDEDsuspend
RESUMESUSPENDEDINACTIVEresume
STOPINACTIVE, ACTIVE_*, SUSPENDEDTERMINATINGterminate (skipped with force)
STOPTERMINATINGTERMINATEDnone
STOPCRASHED, TERMINATEDTERMINATEDnone: idempotent cleanup
SIGNALany non-final statethe same statehandleSignal
FAILany non-final stateCRASHEDnone

Any other event in any other state is rejected with Invalid transition from "<state>" on "<event>".

A workflow step

A node step uses a short path through the machine, always the same: CREATE, ACTIVATE_BACKGROUND, STOP and STOP again. The figure above plays it, then the same step when its worker crashes, and then the foreground and suspended states the SDK also supports.

If activateBackground throws, the path ends in CRASHED instead, and the cleanup STOP turns it into TERMINATED without running any hook. Foreground activation, suspension, resumption and signals exist in the SDK but are not used by workflow nodes.

Rules of the machine

  • One instance, one step. The engine never reuses a worker instance: every step starts at CREATE.
  • A throwing hook crashes the instance. The state becomes CRASHED, the error is logged with the transition and thrown again to the engine (see When a node fails).
  • No retries inside the machine. Retrying is a policy of the node (execution settings), not of the state machine.
  • Every transition is logged as <worker>:<alias> <from> --<event>-> <to>, which is how a step can be followed in the service logs.

Next steps

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs