How a node runs
Each step of a run creates a Link Loom worker for the node, activates it in the background and stops it: what the worker receives, what it returns and why no state survives the step.
The orchestrator that runs workflows is a service built on the Link Loom SDK, and every
node operator (io.http, ai.classify, flow.if…) is a Link Loom worker: a class whose lifecycle is driven by a
finite state machine. A run does not call a node as a function; for each step, the engine creates a worker, activates
it and stops it.
Spawn
A new instance of the node’s worker is created for this step only, with its own alias (step-<node_id>-<time>). The
state machine receives CREATE and the worker enters INACTIVE; its setup hook runs.
Activate in the background
ACTIVATE_BACKGROUND moves it to ACTIVE_BACKGROUND and runs activateBackground(ctx) with the node’s configuration,
its input ($json), the run’s variables and the outputs of earlier nodes. The worker resolves the {{ }} expressions
of its configuration, does its job and returns the envelope { ok, data, port, meta? }.
Stop
STOP moves it to TERMINATING and then to TERMINATED, and the instance is removed. The engine stops the worker
whether the step succeeded or failed.
No instance outlives its step: a node keeps no memory between steps or between runs. What one step must pass to the next
travels in its output, which later nodes read with $json or $('Node label').
What the worker receives
activateBackground(ctx) receives the context the engine builds for the step. The node’s own configuration is spread
at the top of ctx.options, next to the run data:
In ctx.options | What it holds |
|---|---|
| The node’s configuration keys | Its config, as saved in the workflow (expressions not yet resolved) |
payload, input | The input of the node: the output of the node that routed to it ($json) |
inputs | When several branches join into the node, the outputs of each one |
node | The node definition: node_id, label, operator_slug, config |
state | The run’s variables: the output of every node that already ran, keyed by node_id, and the run ids |
graph | The outputs of the nodes that already ran, keyed by label, for $('Node label') |
The worker resolves the {{ }} values of its configuration first, then works with real values.
What the worker returns
Every node returns the same envelope, { ok, data, port, meta? }: data becomes the input of the next node, port
picks the edge to follow and meta carries details for the run history. See Ports and the envelope.
Next steps
From draft to an immutable version, and which mode runs what.
Runs and their statusesThe statuses of a run and of its result.
Worker state machineSeven states, nine events and the hook each transition runs.
When a node failsError port or crash, and how each one ends the run.
Isolation and sandboxesWorkers, expression contexts and code sandboxes.