Automation and workflows
A workflow is a JSON graph of typed nodes executed by topological sort. An automation binds a workflow to one or more triggers. This page covers the graph model, blocks, triggers, execution, waits, webhooks and the debugger.
Related: expressions · helpers · blueprints.
The editor is a library
The graph editor and the workflow engine are separate libraries. The editor is published on npm as
@reeve-iot/workflow-core (headless model, editor store, port-type registry, validation), @reeve-iot/workflow-mui
(canvas, palette, dialogs, configuration panel) and @reeve-iot/workflow-adapters (reads the server's port-type
vocabulary). The engine is the ReeveWorkflow.* NuGet packages. Sources:
github.com/reeve-iot/reeve-workflow.
The libraries know nothing about devices, rooms, scenes or C#. Reeve adds these parts:
| Part | Behaviour |
|---|---|
| Port types | Read once per sign-in from GET /api/workflows/port-types, the vocabulary the server's compiler enforces: the library's built-ins plus Device, its subtypes, the channel atoms, Room, Scene and Property<T>. Collection types (Collection<Device>) are derived. Until the read succeeds the editor shows as unavailable, with the reason and a retry. |
| Pickers | The device select lists only devices of a subtype input's type. Other pickers: sub-workflow, command, raw property, Property<T> target (on the three Property blocks and on each Property<X> argument of a SubWorkflow node), and the wait-block hints. |
| Live analysis | POST /api/workflows/analysis (needs automations.manage and the same scripting gate as a save) compiles the draft as a save would, writes nothing, and returns the diagnostics and every node's ports. The editor posts each edit, debounced, and lists the diagnostics in one collapsible panel. A click or Enter on a row selects its block. A save's or publish's compile result shows only while there is no live answer. |
| Projection controls | On a direct wire from a Json output they set the wire's projection: a path, a Read as JSON text toggle and, where the target type is unknown, a type picker. In Expression mode the same fields write jsonPath(${previous.<node>.<output>}, "<path>", "<type>"), or jsonPathText in JSON text mode. Suggest from a sample proposes paths and types from pasted JSON. |
| Node ids | n plus 12 random hex digits (n3f9a2b7c41d0). A UUID would not work because its - cannot appear in ${previous.<id>.Value}. |
In a node's panel the expression editor knows the blocks wired before that node: Insert value lists each one's
outputs ("Get Property → Value") and inserts ${previous.<id>.<output>} at the caret, and the autocomplete offers them
under previous. A node whose id an expression cannot read (a UUID, a blueprint's light-on) is listed disabled with
"add the block again".
Graph rules that hard-block a save
The rules are enforced on import and again before execution, not only in the editor.
| Rule | Why |
|---|---|
| Exactly one node has no incoming connection, and it is the Workflow Input node | Orphan roots are never auto-connected. |
| Every node is reachable | A disconnected subgraph would be silently dead. |
| A node input has at most one incoming connection | Two edges into one input would be ambiguous. |
| A sub-workflow's target is a literal id in node configuration, never a wire or an expression | The version manifest must be known before the run starts. |
| The graph reads only the root inputs the version declares and writes only the root outputs it declares | The declarations are the version's signature. A node output a branch forwards must be declared too. |
The Workflow Input node is present even with zero declared parameters. To carry a value past a node's direct children use passthrough, not a second root.
A workflow can be switched off. Reeve stores the flag in automation.workflow_enabled_states. One check decides
every start: trigger and schedule fires, webhooks, a script's Host.TriggerWorkflowAsync, debug runs, the
sub-workflow block (before its child starts) and POST /api/workflows/{id}/execute. The execute endpoint checks
ownership first, so a refusal does not reveal another user's workflow. A refused start is a 400 on the execute
endpoint, NotRunnable for a script and a logged verdict for a trigger. A workflow with no state row runs. If the
state cannot be read, the start goes through with a warning. The workflow list and detail endpoints show the stored
value, and PUT /api/workflows/{id}/enabled is the only write.
Switching off stops new runs, not admitted ones. A workflow switched off during a two-hour delay still finishes that run, because a run killed mid-sequence can leave devices half-set. To stop a run, cancel it (see Cancelling a run). A blueprint update or repair turns a workflow back on only when a binding error had turned it off.
A connection carries no transform or condition. Such a field in a stored graph is dropped on load and never executed. Every coercion is an explicit conversion block.
Publishing and versioning
Save publishes. The editor's primary Save creates a new published version. Saving a draft is a separate secondary action, and automations always run the published version. A draft raises a persistent banner naming the version automations actually run. Parameters declared in a draft do not reach the automation binding form until published.
A workflow with a draft opens on that draft. Until it has been read the editor shows no canvas and offers no Save, Save as draft or banner Publish. A failed read says so and offers Retry. The editor asks before closing when the canvas or any workflow setting (name, description, folder, parameters, concurrency, timeout, retry and checkpoint policy) differs from what was last loaded or saved.
A save that does not compile is stored, and does not run. Every write answers with one of seven outcomes. The caller acts on the outcome, not on the status code:
| Outcome | Meaning |
|---|---|
Published |
The written version is current. |
Unchanged |
No text was written: Save on an unchanged canvas, a rename, a folder move, or the current text sent back. |
DraftCompiles, DraftDoesNotCompile, DraftUnchanged, DraftNotJudged |
A draft was written but is not current. |
PublishDeferred |
A publish is still owed and nothing is known to be wrong. |
A create or import that does not compile is therefore 201 with a draft, not a refusal. The workflow exists, the
diagnostics say why it cannot run, and automations keep running the version already published. The editor clears its
"not published" markers only on Published and DraftCompiles, and never offers Publish on Unchanged.
PublishDeferred is a 503 carrying the stored draft and a Retry-After. Resubmitting would create a second
workflow, so the retry is the publish alone. The simple automation wizard waits out the Retry-After and then
publishes. Closing it during the wait publishes nothing and removes the stored draft.
Rollback creates a new version based on the target, so history is kept, and needs its own permission on top of ownership. Diff lists added, removed and modified nodes, added and removed edges, and parameter changes. A background service prunes versions past a maximum count and an age threshold, but never the active version, the latest draft or versions referenced by recent executions.
A publish disables only the automations it breaks. Save, Publish of a draft and Rollback compare the input parameters the new version declares with those of the version it replaces. Editing inside the graph (configuration, expressions, nodes, edges) leaves the declared inputs alone, so no bound automation is touched. A blueprint update or repair publishes a re-rendered version without this check and disables nothing.
When the declarations did change, an enabled automation is switched off only if its stored inputs no longer fit a parameter this publish changed:
| Change to a parameter | Disables an automation that |
|---|---|
| Added as required, or made required | has no value for it (by the automation form's own test: a boolean is never missing, a device capability needs both halves) |
| Removed or renamed | sets a value for the old name |
| Type changed | sets a value for it |
Adding an optional parameter, making one optional, a relabel or a reorder disables nothing. A mismatch on a parameter the publish did not touch is not blamed on it. Save returns the automations it disabled with the parameters that broke them, and the editor stays open to show them. Publish and Rollback apply the same rule but return no list. A draft save publishes nothing and disables nothing.
Access to another user's workflow (versions, diffs, executions, publish, rollback) returns not found, never forbidden, so existence is not leaked. The cross-user execution history is gated on audit viewing.
GET api/workflows/executions lists runs across users. It filters by workflow, start date, any number of status
values (anything but a single status name, such as a number or a comma list, is 400) and pluginTypeId, which
selects the live runs that use that plugin's workflow blocks. The plugin filter can miss runs whose blocks only a peer
replica holds, until that peer has reported its block ids. The answer carries Reeve-Applied-Filters naming the
filters it applied. A replica that cannot filter sends no such header, and the page then shows that instead of a list
with Cancel.
A run is pinned to the version tree it started with
At root start the engine records the root's version and builds a manifest pinning every statically referenced sub-workflow to its then-published version. Suspend and resume, restart and crash recovery reload the pinned versions, never the live current version.
There is no fallback. An unresolvable pin fails the run with an explicit reason. Edits reach only new runs, and a resumed run behaving "as though it were the old graph" is behaving correctly. A sub-workflow target must be a literal id because the manifest is built statically. A wire or an expression on that input is rejected at save, import and publish.
A start compiles what it runs, and a refusal is recorded. Admission re-compiles the pinned version, so a workflow
whose stored version no longer compiles (its plugin uninstalled, a script refused) does not start. The run is recorded
as Failed with a failureReason and appears under "has errors" in the automation's history:
failureReason |
Meaning |
|---|---|
did-not-compile |
The version does not compile. The diagnostics are the version's. |
compilation-unanswered |
Whether it compiles could not be answered. |
start-arguments-invalid |
The start arguments do not fit the workflow's parameters. |
node-validation-refused |
A node the host's validator refuses. |
A run already under way is never re-judged. A refusal is reported by door:
- The trigger runner (every webhook fire goes through it) logs it once per verdict at Warning.
- A script's
Host.TriggerWorkflowAsyncthrowsWorkflowStartRefusedExceptionwith the reason and the problems. The reason isNotAdmittedwhen the concurrency mode or safe mode did not let the run start. - A debug execute answers the refusal and ends the session
Cancelled. For the two findings reasons the answer is a 400 with the findings underdiagnostics.
A script-started run that parks on a wait before reaching an ending (WaitForTrigger, WaitForProperty,
WaitTemplate, or a SubWorkflow whose child parks) is not refused. Host.TriggerWorkflowAsync throws
WorkflowParkedException with the WorkflowId and the parked run's ExecutionId, and the run resumes on its own. A
WaitForDuration never parks such a run: it sleeps in place and the script waits.
Triggers
Each trigger type is a plugin registered under a string id. Triggers run off the request thread.
Where they run. Cron, Sun, Webhook and every third-party or WASM trigger type run on one replica, the
one that holds the trigger-host role. When that replica drains or loses the role, its triggers stop firing. The other
types (StateChange, DeviceEvent, the geofence and camera types) are armed on every replica, so the replica that
received a broadcast can fire on it, and fire de-duplication collapses the fan-out to one run. State such a trigger
keeps between fires must be cluster-wide, never a field on the plugin.
The de-duplication key includes the trigger row, so it collapses only copies of one fire made by sibling replicas. One event that matches two triggers is two fires and runs twice, as on a single replica.
A device the workflow's owner may not view. A trigger bound to one device (StateChange on a device, DeviceEvent,
CameraMotion, CameraObjectDetected, CameraPlateRecognized or CameraSoundDetected) asks, when it fires, whether the owner of the automation's workflow
may view that device. The check is the one the device read blocks use, including time windows. It comes before the
fire is claimed. If the owner may not view the device, the fire is dropped: it starts no run and wakes no parked run.
The drop is logged once per automation and device until the owner may view the device again. A failed lookup drops its
fires with a warning.
Fire de-duplication keys
A replica's trigger sees only what that replica ingested, so the key is built only from what every copy of one
occurrence carries identically, never from a replica's clock. Sources with an observed-at (Zigbee2MQTT last_seen,
plugins setting LastUpdateUtc, helper change times, location fixes, geofence crossings, events with an observed-at)
get a key that names the occurrence. Sources without one (Zigbee2MQTT without last_seen, Home Assistant discovery,
virtual devices, a WASM driver's device_emit_state) get a key from a hash of the payload, which names only the
payload.
A state snapshot with no observed-at, no raw payload and no canonical values has no key. The trigger refuses it with a logged warning instead of firing on every replica. A producer event id (Frigate's names a tracked object that several events share) does not name an occurrence, so two ids are two keys.
A payload-named key (it starts with payload:) is held by the first replica process that claims it, for the
de-duplication window. Each later claim by the same process renews the window, and any other process is refused. A
motion sensor reporting true, false, true with identical payloads runs twice, and one broadcast still runs once.
While Redis answers, no occurrence runs on two replicas. An occurrence can be under-fired: a repeat that only a
non-holder sees is not run, a restarted replica or a camera trigger whose cooldown claim another replica won is
refused while the holder keeps the key, and a draining or fenced holder refuses its own fires and every peer's, so a
repeat inside its window runs nowhere. The key lapses one window after the holder's last claim. A redelivery of one
message to the holder (an MQTT QoS 1 duplicate) runs again when the key is payload-named, although a state trigger
still sees no edge in it.
Re-arming and bounded starts
A trigger's plugin is built from its identity (type and configuration). The automation's run parameters (workflow, inputs, debug mode) are read when a run is taken up. Every automation, trigger and workflow write reaches all replicas and wakes their trigger lanes, with a 30 s sync as the backstop. A cycle rebuilds only a trigger whose identity differs from its row. Until a replica has rebuilt it, a run from the old plugin is refused and its fire wakes no parked run, so a stale plugin never answers an event the new configuration ignores. Editing the workflow, inputs or debug mode rebuilds nothing, and the next run on any replica uses the new values, including one already queued. A changed plugin grant re-arms an armed WASM trigger.
Each trigger's StartAsync gets 5 s. A start that throws or times out writes an in-memory failed-to-arm record
(reason TimedOut, or Faulted with the exception message, and the UTC time), cleared when the trigger arms. An
abandoned start is never armed and cannot fire an automation. A start that never finishes leaves the trigger unarmed
until the process restarts, and System status shows automation.trigger_unarmed (see Traps).
Trigger types
| Trigger | Fires on |
|---|---|
StateChange |
A device capability transition (Any → Y or X → Y), or a helper change. Any → Y compares with an operator: eq (default), ne, gt, gte, lt, lte. |
Cron |
A schedule, evaluated in the household time zone (an unset or unknown zone degrades to UTC). A non-string expression is validated at save. |
Sun |
Sunrise or sunset with an optional offsetMinutes (a whole number, negative for before), from household coordinates. |
DeviceEvent |
A momentary device event such as a button press. |
Webhook |
An inbound HTTP request (see Webhook triggers). |
GeofenceEnter / GeofenceLeave |
A monitored geofence crossing. |
CameraObjectDetected |
A camera recognised an object (camera.objectDetected). Optional filters: object class, zone, confidence floor, and a cluster-wide minimum interval between fires. |
CameraPlateRecognized |
A camera read a plate (camera.plateRecognized), matched against the trigger's own list in one of three modes: one of the list, not in the list, any plate. |
CameraSoundDetected |
A camera named a sound (camera.soundDetected). Optional comma-separated list of sound classes (matched ignoring case) and a cluster-wide minimum interval per sound class. |
CameraMotion |
A camera's motion started or stopped (camera.motionStarted / camera.motionStopped), from whichever source saw it. Bound to one camera with an edge of started (default) or stopped. Fires once per edge per stretch of motion. Optional cluster-wide minimum interval. |
| Rule | Detail |
|---|---|
| Coordinates gate sun triggers | A sun trigger has no firing time while the home has no location (latitude and longitude are null; 0, 0 is a real place). Each trigger logs one warning when it starts waiting and one line when it resumes. The one-minute maintenance pass raises home.location_missing with the count of enabled automations whose sun triggers wait. |
| One subject per state-change trigger | Exactly one of a device id or a helper id. A device form must supply the canonical capability key; a vendor-only key is rejected. Switching the subject in the automation form clears the other one. |
| A state-change trigger needs a target value | toValue is required and a blank string counts as missing. The form marks the field required and refuses the save while it, or the device, capability or helper, is empty. |
| A comparison fires on the crossing | Any → Y fires when the comparison starts holding and stays quiet while it keeps holding. lt 20 fires at 19.9 and not again at 19.8. It fires a second time only after the value leaves the predicate and re-enters. |
| Equality compares meaning | eq, ne and fromValue match two numbers that are the same number however written (1E+16 and 10000000000000000) on a Number capability and on a helper holding a JSON number. On a helper they also match two JSON strings that decode to the same text ("R\u0026B" and "R&B"). Everything else, including every Text, OpenEnum and Enum capability, compares as exact text, so 1.1 and 1.10 differ. |
| A comparison needs numbers on both sides | gt/gte/lt/lte parse both sides invariantly. A side that does not parse makes the predicate false, so a text capability compared numerically never fires. An absent observed value satisfies nothing, ne included, so a device that stopped reporting does not read as "not equal to 22". |
An operator and a fromValue are mutually exclusive |
X → Y is an equality on both ends, so pairing it with an operator is refused at admission. A configuration key holding JSON null counts as absent. An unrecognised operator name is refused too. A hand-edited row carrying one arms a trigger that satisfies nothing. |
| Helper changes | Helper writes emit synthetic events, so ordinary state-change triggers fire on them. The trigger compares the change's own previous and new value. |
| Geofence consent | A geofence trigger defaults to the automation owner and refuses another user unless explicitly authorised. |
| No expressions in trigger config | Expressions apply to action-block input ports only. |
First edge after arming. A device StateChange trigger keeps the last value it saw per instance. A fresh instance
(created, edited, enabled, restarted or failed over to) has none, and the first real edge must still fire. So the
trigger takes its reference from the row the incoming report replaced:
| Event reaching the trigger | Result |
|---|---|
| The replaced row reads the key, the instance has no reference | The replaced row's value is the previous value. It fires if that is the configured transition. |
| First report ever, or the replaced row cannot read the key or held no typed state (raw-only) | The report seeds the instance. No edge. |
| The instance has a reference | Its own value is the previous value, unless it missed writes on the same source (a version gap). Then the replaced row's value is used. |
| A report the freshness gate drops, another source's report, a raw-only report, the location service, a helper | No edge from the replaced row. The instance's own value is used, or the first sighting seeds. |
A replaced row of a source that is not the active one is never used. A source that mixes raw-only and canonical reports leaves the first canonical report after a raw-only one without a reference, so a fresh instance seeds on it and the first edge does not fire.
Trigger secrets are encrypted at rest. A field the trigger type declares Sensitive (the Webhook secret) is stored
as enc: plus data-protection ciphertext, and the owner-facing API shows it as ***. A value that cannot be
decrypted (a lost key) becomes a random string, so the webhook refuses every caller.
Secret headers. HttpRequest Headers are secret-capable: values are stored as enc: under a per-workflow
purpose, or as a ref: through the binding policy. Imports (bundle import, blueprint install, marketplace rollback)
drop what an edit would refuse and list it as droppedSecrets. Exports mask protected values. See secrets and audit.
The workflow schema at boot. The workflow library migrates its own tables before the host's migration. A replica
with Database:Startup:RunMigrationsOnStartup=false only verifies the schema and fails its boot with exit code 75
while it is not migrated.
Camera triggers
The camera triggers bind to the canonical Camera type, not to a vendor. Any camera plugin can drive them, and one
that cannot detect never fires.
- The zone filter matches the first zone the plugin reported. An object in both
porchanddrivewaymay not matchzone=driveway. - The object, sound and motion triggers have a minimum interval. The plate trigger has none.
- A plate is a claim made by whatever published to the camera's broker, which listens anonymously on the workload network. A wrong firing can open a gate.
- React to a sound with
CameraSoundDetected, notDeviceEvent: the generic trigger carries no sound class. A sound reported without a class never matches a sound filter.
CameraMotion fires on the published edges of a stretch of motion. Each edge carries the stretch id
(${trigger.stretchId}) so a workflow can pair a start with its stop. An edge the host publishes twice fires once.
CameraMotion differs from a StateChange on camera.motion. StateChange watches only the owning plugin's own
motion sensor and is not PTZ-masked. CameraMotion counts every source. Motion that starts during or just after a
camera move is held back until it pauses for about 6 s, while motion already visible before the move keeps counting. A
camera whose plugin reports no motion at all (an RTSP-only camera) can only use CameraMotion.
A DeviceEvent trigger with no event type on a camera whose plugin reports motion also fires on each motion edge. Set
its event type, or use CameraMotion.
WASM plugins cannot supply a fire payload. A sandboxed trigger fires with an envelope holding just id and
firedAt, so ${trigger.<field>} is empty for it.
How a fire becomes a run
What a fire payload may carry. The host drops, with a warning naming the key and the rule (never the value), in the
server log and in the history of the run the fire starts and of each parked run it wakes: an empty key, a top-level
date (it would read as text after a wait; send an ISO string or a number), a value that does not serialise to JSON, a
value over 1024 bytes with its key, and every key past the 32nd. An object or array is kept as a read-only JSON copy
taken at the fire, and ${trigger.<field>} reads it whole as Json.
A fire does not run the workflow. The host puts a work item on the replica's trigger run queue and returns, so
the plugin that fired is never held up by a run. Otherwise a long WaitForDuration in one automation would stall the
loop that hands each device state change to every subscriber, and other automations would miss state changes.
The queue has two lanes. A fire passes through them in this order:
| Step | Lane | What happens |
|---|---|---|
| Waiters | Notification (two workers) | A wake is published for every run parked on that trigger. These are short lookups on a lane of their own, so a WaitForTrigger hears its trigger even while every run slot is held by a sleeping run. Only then is the fire's run queued, so a run that suspends on its own trigger is not woken by the fire that started it. |
| Match gate | Run (MaxConcurrent workers) |
Checked when a worker takes the run up, which can be minutes after the fire. The run is skipped when the automation or the firing trigger has since been disabled or deleted, so switching off a misbehaving automation also stops its queued runs. It is also skipped, and the automation stopped, when a named device was removed (see Removed device stop); a failed check lets the run start. An All automation checks its other triggers now. |
| Run | Run | The workflow starts with the fire, the automation's inputs and its debug flag. The concurrency mode decides what happens if a run is already going (see Concurrency). |
| Rule | Detail |
|---|---|
| The run's token is the queue's | Runs are cancelled when the queue stops, not when their trigger is stopped or re-armed. A configuration edit does not cancel a run its old trigger already started. Deleting the workflow does. |
| A full lane drops the newest fire | Each lane holds QueueCapacity items (default 1000). A full notification lane drops the whole fire, counted as reason="notification_queue_full". If the run lane refuses after a successful de-duplication claim, the fire is dropped with a throttled warning and reason="queue_full". It never runs inline. |
| A run holds its worker for its whole length | A sleeping run occupies a slot until it wakes. Automations:TriggerRuns:MaxConcurrent defaults to 32 and must exceed the number of sleeping automations expected at once, or every other automation's fire waits. A sleep of DurableSleepParkWhenAtLeastSeconds or longer parks instead (see A long sleep parks its run). |
| Shutdown | Fires are accepted and runs keep going until every trigger host has stopped. Then the queue stops accepting, cancels running runs, discards queued ones and waits for the workers up to the host's shutdown timeout. A discarded run, or a fire refused after that point, counts as reason="shutting_down". Resumable state is in Postgres. |
| Order and trace | Fires of one automation are admitted in the order they were queued (see Concurrency). The run opens a trigger.run span (tagged automation.id, trigger.id) under the fire's trace. |
Combining triggers
An automation's triggers combine one of two ways, set by TriggerMatchMode:
| Mode | Meaning |
|---|---|
Any |
Default. Whichever trigger fires, the run starts. |
All |
A trigger firing starts the run only when every other enabled trigger is satisfied at that moment. |
The mode is in the Advanced automation editor under the trigger list, from the first trigger on.
In All mode every trigger keeps its own edge, and a change to any of them wakes the check. "Inside below 20 and
outside below 10" fires whichever threshold crosses last: inside crossing while outside is still 11 starts nothing, and
outside crossing later finds inside satisfied and runs. One physical situation starts exactly one run.
Only StateChange (a device canonical capability or a helper value) can answer "satisfied now?". DeviceEvent,
Webhook, Cron, Sun, Camera*, Geofence* and every third-party or WASM type cannot, because an event has no
value outside its own instant. A sibling bound to a device the workflow's owner may not view counts as not satisfied,
and its state is not read, so the run cannot leak the device state one bit per fire. A failed lookup counts those
siblings as not satisfied.
| Rule | Detail |
|---|---|
At most one event in an All set |
Two events never happen at the same moment. Refused at admission, on the automation endpoints and on the single-trigger ones. |
An X → Y state change counts as an event |
It can be the one edge but never answers as a sibling. |
| A leaf that cannot be evaluated holds the run back | Device deleted, value never reported, an evaluator that threw. The skip is logged, no audit row is written. |
| A disabled trigger is not a leaf | It is neither counted at admission nor consulted at fire time. Wakes still go out on a held-back fire. |
| The firing trigger's identity is checked at fire time | Its type and configuration must equal what its plugin was built from, or the run is refused. The run then uses the workflow, inputs and debug mode the automation holds at that moment. |
| Siblings are read at fire time | A trigger is re-armed only when its own type or configuration changes, so a sibling edit takes effect at once. |
| A failure to read the mode runs the automation | Almost every automation is Any, and holding them back on a transient read failure would silence the home. Every uncertainty after the mode is known to be All fails closed. |
Time-of-day and sun windows are not available as All leaves: a window that opens needs a scheduled wake at its
boundary, or "inside below 20 and after sunset" would go silent when sunset arrives after the temperature crossed.
Host-reserved configuration key. Every trigger plugin, including a sandboxed one that never declared it, receives
__triggerId in its configuration: the trigger row's id as a GUID string, and the only stable identity a trigger has
(TriggerContext.OwnerId is the automation author's user id). A stored value for that key is overwritten.
Blocks
Block factories declare their input ports, output ports, sub-canvas names and configuration schema. The config panel,
sub-canvas navigation and the palette are generated from those declarations. Plugins register further block types
through the block-plugin interface. * marks a required input. Any input port also accepts an expr: expression.
A block the host cannot describe is not registered. A plugin block that throws while the host reads its description (for example one built against an incompatible SDK) is refused at registration and logged at Error with its block type id. It is then absent from the palette and from every run, as an uninstalled one is. Rebuild the plugin against a compatible SDK.
The engine merges node configuration into any input a wire did not fill. So an input port is authorable only when the
factory also declares a config field of the same name, and that field must be Required: false. Ports with no
literal form (pickers) have no such field.
Where they come from. The generic blocks (IfElse, the loops, TryCatch, Rethrow, Expression, Filter,
Math, ParseJson, WaitForDuration, the six conversions, HttpRequest and SubWorkflow) ship in the
ReeveWorkflow.Blocks package and know nothing about devices. Reeve replaces two of them with its own rule:
HttpRequest uses the request-forgery-guarded client (and validates its URL), and SubWorkflow checks that the target
belongs to the running workflow's owner.
| Block | Ports and sub-canvases |
|---|---|
IfElse |
in Condition*: Boolean; sub-canvases Then, Else |
Expression |
in Expression*: $T → out Result: $T. Puts an expression result on a wireable port, for example into IfElse.Condition. The config defaults to expr: so the panel opens in expression mode. |
WhileLoop |
out Iterations: Int; sub-canvas Body (provides Continue: Boolean); config MaxIterations |
ForLoop |
in From/To/Step: Number; out Results, Iterations; sub-canvas Body (exposes Index, Current); config MaxIterations |
IterateOver |
in Collection*; out Results; sub-canvas Body (exposes Index, Item); config MaxItems |
TryCatch |
out CaughtError: Boolean, ErrorMessage: String; sub-canvases Try, Catch (exposes Error, Message, ExceptionType, FailedBlockTypeId), Finally |
Rethrow |
config Message; re-throws inside a Catch canvas |
StringToInt, IntToString, StringToBool, BoolToString, NumberToString, StringToNumber |
in Value* → out Result |
GetProperty |
in Target*: Property<$T> → out Value: $T. Reads the active source's canonical state. See Property blocks. |
GetRawDeviceProperty |
in Device* → out Value: String; config PropertyKey (unmapped vendor property). A device the workflow owner may not view fails with device.not-found, as a missing one does. |
GetDevices |
in Room: Room, DeviceType: String → out Devices: Collection<Device>, the matching devices the workflow owner may view. Each item is { Id, FriendlyName, DeviceType, RoomId }. Every Device port accepts one such item or a device id. |
GetRooms |
out Rooms: Collection<Room>, each { Id, Name } |
GetCameraMediaUrl |
in Device*: Device, EventId: String → out SnapshotUrl, ClipUrl: String. Links to the snapshot and clip the camera kept for one detection. A link comes back empty when the camera keeps no such recording, the workload is down or the plugin declared a bad template, so empty is not proof there was nothing to see. The links open only in a signed-in client (a browser session or the app), not from a bearer-only client. They stop working when the plugin's retention expires. See camera-media.md. |
SetProperty |
in Target*: Property<$T>, Value*: $T → out Status, CommandLogId. Sends the canonical command of the key's kind. A value off the CLR type of T fails the node, naming the port. |
WaitForProperty |
in Target*: Property<$T>, Predicate*: Expression<Boolean>, TimeoutSeconds → out Outcome, Value: $T?. See Property blocks and wait blocks. |
SetRawDeviceProperty |
in DeviceId*, Value → out Status, CommandLogId; config PropertyKey. Sends { PropertyKey: Value } with the run owner's device access. A hidden device fails with device.not-found. A device the owner may view but not control (or only outside a time window) is refused with the access error. The key must be a writable unmapped property the device's active source declares, or one of its controllable capabilities. The write is audited. |
SetHelperValue / IncrementHelper |
in HelperId* plus Value* or Delta → out HelperId, ValueJson |
Math |
in A*, B*: Number, Op → out Result, Error. Filter: in Collection*, Property, Value → out Filtered. ParseJson: in Json*, Path* → out Value, Success. |
HttpRequest |
in Url*, Method, Headers: Map<String,String> (secret-capable values), Body, TimeoutSeconds, ThrowOnFailure → out StatusCode, Body, Success |
SendNotification |
in Title*, Message*, Level (blank means info). See below. |
SendCameraNotification |
in Title*, Message*, Level, Device*: Device, EventId: String, Media: String. See below. |
ActivateScene |
in Scene*. Runs the scene as the workflow owner. An owner who may not access the scene fails the node. Each action uses the owner's device access, or none when the scene bypasses executor permissions. If the scene had actions and none reached a device (all skipped: offline, timed out, refused, removed, unparseable), the node fails with scene.nothing-delivered naming the skip reasons. Under the default FailWorkflow policy later steps do not run. A partial delivery succeeds with a warning. A disabled or empty scene succeeds. |
SubWorkflow |
in WorkflowId* (literal only) plus the referenced workflow's parameters as dynamic ports |
WaitForDuration, WaitForTrigger, WaitTemplate |
See wait blocks |
CSharpScript |
Author-declared dynamic ports; config Code, InputPorts, OutputPorts |
SendNotification reaches a connected client only: a toast in the browser, and an operating-system notification
in the Android app only while it is open. A phone whose owner declined the notification permission is told nothing.
Neither silence raises an error. The same title, message and level also go to every notification-sink output plugin,
which is the only path that reaches someone with no client open. The clients and every sink on the replica running
the workflow are tried independently. If one fails, the block fails with that target's error after the others were
tried, or with an AggregateException naming several. The workflow's retry policy reruns the block, so a target that
took the first attempt can receive the notification twice.
SendCameraNotification is the same notification plus the detection as fields (deviceId, eventId, kind). The
web app renders them. The Android app shows the text only. Media is snapshot (default, and what a blank field
means) or clip, and anything else fails the node. The node also fails on a blank Title, Message or Device, on a
missing or malformed event id, and when the device is not a camera with an active source. The fields are attached
whenever the camera's plugin can serve that media kind, which is not proof the file still exists. See
camera-media.md.
Property blocks
Property<T> is one canonical property of one device. Its only JSON form, which is also its literal form, is
{ "deviceId": "<uuid>", "key": "<string>" }. The reader is strict: a missing, extra or duplicate member, a deviceId
that is not a D-format UUID string, or a key that is not a string is refused, and {} never reads.
The allowed T are Boolean, Number, String and Collection<String>, and the key alone gives it. A catalogue key
of kind Toggle gives Boolean, Number gives Number, Enum, Text and OpenEnum give String, and TokenSet
gives Collection<String>. A channel member key (switch.channels[N].isOn) gives Boolean when the catalogue lists
the type's <path>.channels. A Color key, a Channel list, a scene controller's member key and any other key give
no T.
SetProperty, GetProperty and WaitForProperty (category Devices) take Target: Property<$T>. Target and
Value have no configuration field, since an object has no field type. A literal is a mapping on an incoming edge
keyed by the input name, and a root node gets it on the edge from __workflow_input__. The node carries
typeArguments: { "T": "<X>" }. A wired Target binds T from the wire. The editor's target picker offers the
device's keys that give a T and writes the literal and T together. On a SubWorkflow node it offers the same
picker for each Property<X> input of the child and writes only the literal. An automation's Property<T> input is
stored as the same object. The automation form binds it with the same picker, refuses to save a required input
without a whole object, and shows a saved key the picker no longer offers as stored.
| Block | Run time |
|---|---|
SetProperty |
Builds the canonical command of the key's kind from Value and sends it as a direct command is sent. A device the owner may view but not control keeps the access refusal. A failed command fails the node. Idempotent. |
GetProperty |
Reads the active source's canonical state as the CLR type of T. Fails with device.capability.missing or device.channel.missing when no source declares the key, and with a failure without a code when the state holds no value for it (a Number that is not finite is no value). Idempotent. |
WaitForProperty |
Reads as GetProperty does. If the state holds a value, it evaluates Predicate over value. true ends the node satisfied with that value and no park. Otherwise it parks (below). Not idempotent. |
A target that names no device, a device hidden from the run's owner, or a device with no source at all fails the
property blocks with device.not-found. The code leads the node's error message and lands in _error.code. A device
none of whose sources is online fails the read blocks (including both raw device-property blocks) with
device.offline, even though its last readings are stored: a run does not act on stale state. A triggered run that
fails on an offline device, or on an ActivateScene whose every action was skipped as offline or timed out, is logged
as a warning naming the node, without a stack trace.
The predicate wait. WaitForProperty parks with kind Predicate. TimeoutSeconds defaults to 300 and must be
above zero. Each report on the device's active source, after the batch committed, wakes the runs parked on that
device and property, once per report. The library evaluates the predicate: a satisfied one resumes the run, a false
one leaves it parked, and the library's own pass times a row out. Outcome is satisfied or timed_out, and Value
is the value for which the predicate held, null on a timeout. A parked run whose workflow owner may not view the
device is not woken, as if the device were silent for that owner. It stays parked until its timeout, or until a report
after the owner may view the device again.
A report between the first read and the park, a snapshot dropped under pressure, a report of a source that is not active, and a report without a value for the key wake nothing. The timeout bounds the wait. A predicate that fails at run time fails the node. Like the other waits it must sit on the root canvas.
Checks. Checks for Property<T>, subtype and channel inputs read static facts only. Device existence,
retirement, whether a source declares the key and whether it is controllable are device-model facts, judged by the
device-model scan (see Device model disable and re-enable). A device that does
not exist or is retired passes the checks below.
| Code | Raised when |
|---|---|
property.key-not-in-catalogue |
The key is not a catalogue key that gives a T, does not belong to the device's concrete type, or is not a member of a channel atom's list. |
property.type-mismatch |
The T the key gives differs from the site's Property<X>. |
property.target-malformed |
The object does not read. |
device.type-unknown |
The device's type is Unknown. Raised at Save and Publish, passes at Admission. |
device.type-mismatch |
A device of another concrete type feeds a subtype input, in every phase. |
The checks run at these sites:
| Where | Phase and answer |
|---|---|
A node literal of a Property<X>, subtype or Collection<XDevice> input (any nesting depth) |
Save, Publish and Admission: a finding on the node and port. A Publish finding stops the promotion. A malformed literal is also refused by the compile. |
| An automation's binding of such a parameter | Save phase of the automation create and update: a 400 carrying the first refusal's code. An unbound or null parameter follows the missing-value path. An id the JSON form cannot read is left to admission. |
| A start argument | Admission: a finding naming the parameter refuses the start. |
The device-model scan treats a Property<T> literal, a SubWorkflow argument literal and an automation's binding as
references to the property, or to the device alone for a blank or non-canonical key. A channel renumber moves the
device and key of such a literal in a draft, and a binding on the old number gets a device.channel.renumbered
finding. A collapse moves both.
The simple automation wizard's action step emits a SetProperty node with a literal Target and Value and
typeArguments taken from the picked key's catalogue kind.
Device subtypes
Reeve registers one port type per device type except Unknown (LightDevice, OutletDevice,
SmokeCoDetectorDevice, ...). Each has Device's id-string JSON and literal form and widens to Device. A subtype
feeds a Device input, and Collection<LightDevice> feeds Collection<Device>. A plain Device or another subtype
never feeds a subtype input, and the compile says port-type-mismatch. The device type fixes the subtype and no block
derives one. A channel is not part of the type: a channel member goes through Property<T>.
The device pickers for a Device or a subtype list only devices of that type and show an unknown stored id as
Unknown device <id>. A Collection<XDevice> has no picker: the automation form takes its value as JSON, and the
save refuses a member of another type at any depth.
Channel atoms
OutletChannel and SwitchChannel are port types whose JSON and literal form is the Property object. Each widens
to Property<Boolean>, so a channel feeds a Property<Boolean> input and a SetProperty Target. Nothing feeds a
channel input except another channel of its list.
Rules for authoring a block
| Rule | Consequence of breaking it |
|---|---|
| A config field whose name matches an input port is declared non-required | The editor validates required config independently of wiring and blocks Save on a node whose value arrives over a wire. |
| Match the dictionary-of-plain-objects shape, not JSON elements | A block matching only the element-typed shape never matches a real value from config, mappings or input parameters. |
| Looping blocks enforce a maximum-iteration cap and throw on reaching it | Warn-and-continue is not offered. Under the default policy the throw fails the run. The outcome is configurable per node. |
| A block computing a target set from an input fails closed when the input is present but unresolvable | Silently dropping an unrecognised room or device-type filter returns, and can actuate, every device in the home. |
| Guard for strings before iterating a collection | A string is enumerable. Wiring one iterates its characters. |
| Do not reflect case-sensitively over item properties | The collection filter does this, so dictionary-shaped items (every JSON-derived collection) match nothing and return empty with no error. |
| Parse operator-typed numbers with float-only styles | Permissive styles read a decimal comma as a thousands separator, inflating the value a hundred-fold. |
Read blocks name the device port Device, write blocks DeviceId |
Pick one for a new block and keep the other as an alias. Existing graphs persist their mappings. |
Accept both connections and edges, case-insensitively |
A definition's edge list may be spelled either way. Anything that diffs, scans, imports or migrates must handle both. |
| Never let a double-underscore config key reach a block | Those keys are editor-only. The same exclusion covers the retry and timeout resilience keys. |
| Read plugin configuration from the block context's service provider at execution time | Factories take no constructor arguments. Sensitive values arrive decrypted. The call returns an empty dictionary, never null. |
Declare IsIdempotent explicitly |
The default is false, so a factory that never mentions it is never retried. |
IsIdempotent matters when the engine retries only idempotent blocks: it gates a node that says nothing about retries
itself. A read is idempotent. So is a write that sets an absolute target state: SetProperty, SetHelperValue and
ActivateScene land in the same place however often they run. Anything that toggles, appends, sends or spends is not:
IncrementHelper, both notification blocks, HttpRequest (the method is an input, so it may be a POST),
SetRawDeviceProperty (the host does not know what the vendor key means), CSharpScript and SubWorkflow. Every
container answers false, because a retry re-runs its whole body. A node's own retry setting beats the factory's
answer.
Input resolution
| Rule | Detail |
|---|---|
| A wired input beats node configuration | A configuration key a wire already set is not merged, so the panel must not offer an editable field the engine ignores. |
| A dangling wire is skipped, not written as null | The node's own configuration still applies, and a genuinely missing value surfaces as the block's clean error. Only "present and null" writes null. |
| Expression inputs are pre-evaluated | The exception is the wait-for-expression block. A custom block storing an expression for later re-evaluation must declare its raw-expression inputs. |
| A sub-canvas is seeded only with its own input node | Parameter references mean the branching node's resolved inputs. Outputs of top-level nodes are not in scope. |
| A sub-workflow must belong to the running workflow's owner | The block re-checks the target id against that owner. A workflow the owner cannot open is refused. Depth is capped at 10 (runaway-recursion error). |
Crossing the sub-canvas boundary
A sub-canvas has no ambient scope. Nothing from the outer graph is visible inside a branch unless the branching node carries it in, and nothing a branch computes leaves it unless the branching node declares a port for it. Both are authored on the parent node, never inside the branch.
| Direction | How | Where |
|---|---|---|
| Into a branch | The branch's Workflow Input is seeded with the branching node's resolved inputs: every value a wire or the node's own configuration supplied, whether or not the block declares a port for it. Blocks add fixed extras (ForLoop.Index, TryCatch.Error). |
Node panel: wire it in, or give it a value |
| Out of a branch | A declared output port on the node, with a source key per branch. The branch's Workflow Output exposes that key as an input port, and the executor projects it onto the parent port name. A branch whose source key is empty produces nothing, which is how "only Then returns this" is expressed. |
Node panel: Declared Outputs |
A branch the node declares and the definition does not contain runs empty. Never opened, opened and left empty,
and absent from the stored graph are the same thing to the run, the compiler and the diff. An unopened Catch
catches and ignores, as an opened empty one does. A declared output that takes its source key from a branch never
opened returns null, and the editor warns at save: "Branch '<name>' of '<block>' does not set output '<port>' (returns
null)".
Passthrough is a different mechanism. At runtime node.passthrough re-emits named inputs as the node's own
outputs, so a node after the block can read a value that entered before it. It does not inject anything into a
branch. Injection needs only that the value is among the node's inputs. The editor also derives the node's virtual
input ports from the passthrough list, so ticking a passthrough name is also how a branch gets a port to read.
The editor's Workflow Parameters dialog is the root workflow's own signature and is disabled inside a sub-canvas, because a parameter declared there would land on the main workflow, not on the branch.
Error handling
Three layers: a per-node error policy, try/catch/finally blocks wrapping sub-canvases, and normalized error records with metrics and trace spans.
| Node error policy | Effect |
|---|---|
FailWorkflow |
Default: the run fails. |
ContinueWithDefault |
The node emits its default output and execution continues. |
EmitError |
A structured error is emitted on a virtual error port. |
Skip |
The node and everything downstream of it are skipped. |
The policy lives on the node as errorPolicy. A policy written into the node's configuration is never read, and
the compiler refuses it on every canvas (error-policy-in-configuration, error-policy-route-unread), so such a
definition cannot be published or started. The virtual error port is typed Json and exists exactly when the policy
is EmitError. A downstream handler that declares no input for it does not get the wire.
Timeouts. A block with no timeoutSeconds of its own runs under thirty seconds. A container (a loop, an if/else,
a try/catch, anything holding a sub-canvas) runs under no deadline unless the deployment sets
Workflow:Engine:ContainerTimeoutSeconds (1 to 86400). The engine cannot size a container's body. A thirty-second
guess would cut off a branch that opened a valve, waited ten minutes and closed it, leaving the valve open.
If you set the ceiling, it applies to every container, nested ones included, so an outer one must cover everything its inner ones do. A container that exceeds it fails. The editor's Resiliency section has a Timeout field on every node. A number written there beats both the deployment's ceiling and the block default, so on a container leave it empty unless you mean it.
The looping blocks take a maximum as configuration (WhileLoop defaults to 100 iterations, ForLoop to 10000,
IterateOver to 10000 items), and reaching it throws. IfElse and TryCatch do not loop, so what is unbounded there
is how long their branch takes.
No budget per run. Nothing limits a run's total nodes, iterations or CPU. The loop maximums are the only bound,
the author sets each with no host ceiling, and nested loops multiply: a ForLoop at its default inside another runs
its body up to a hundred million times.
Retry. A node's own word is retryEnabled (the editor's Resiliency section writes it as On or Off), and it wins
over everything below. A retryCount or retryBackoffSeconds stored without it is ignored. With the node silent,
Workflow:Engine:RetryOnlyIdempotentBlocks decides. It defaults to true: a block that declares itself idempotent
is retried and any other runs once. The editor shows this as Default: the block decides. A plugin block forwards
what its plugin declares, and a WASM descriptor that omits the field counts as false. With the key false, a silent
node is retried whatever its block says.
A retry covers a fixed list of exception types: a timeout, an HttpRequestException, and a TaskCanceledException
the run itself did not cause. Anything else fails on the first attempt. HttpRequest with ThrowOnFailure raises an
HttpRequestException for any non-success status, a refused egress and a malformed URL alike, so a POST answered 409
is sent again wherever that node's retry is on. A retry repeats the block three times after the first attempt unless
the node stores another count. The backoff starts from retryBackoffSeconds (one second when unset) and grows
exponentially with jitter. A workflow's own retryPolicy is separate: it re-runs the whole graph on an ordinary
failure, blocks that said false included.
Retries are exhausted first. The node's error policy applies only afterwards. Three failures escape the policy and fail the run whatever it says: a definition the engine cannot read, a wait below the root canvas, and a state row a peer has reclaimed. The error object exposed downstream is normalized. Raw exceptions and stack traces never reach a downstream handler or a plugin:
{ "type": "…", "message": "…", "blockTypeId": "HttpRequest", "nodeId": "…",
"caughtBy": "TryCatch | errorPolicy | null", "policy": "EmitError | FailWorkflow | …", "timestampUtc": "…" }
Execution status is one of Running, Succeeded, Failed, Cancelled, TimedOut. "Skipped" is not an execution
status (a single-mode skip is an audit event), but steps use Succeeded, Failed or Skipped. Cancelled covers
host shutdown, restart supersession and operator cancel, and a cancelled row without an operator request carries a
reason. TimedOut is the engine cancelling its own timeout.
C# scripting
The scripting block compiles and runs user C# in-process with full host privileges. It is gated by a dedicated scripting permission held by administrators only, checked on create, update, import and blueprint install. In-process sandboxing is not possible, so the control is the privilege level. Whoever can save a workflow containing a script effectively has code execution on the backend host. Treat that permission as deploy access, and never feed untrusted input (webhook bodies, device payloads) into a script without strict validation.
A compiled script is cached by the hash of its source (at most 128 scripts, least recently used evicted) only to skip recompiling, so a full cache never fails a run. Each compilation's code lives in a collectible load context that is released once nothing references it, so a rarely run script costs compile time, not permanent memory.
#r is refused at compile time. A script can use only the assemblies in
CSharpScriptEnvironment
(the editor's cheatsheet lists them) and the host assemblies those depend on.
Concurrency
One coordinator per workflow decides what happens when a trigger fires while a run is in progress. The budget is per workflow, not per trigger: several triggers on one workflow share it. Trigger fires reach it through the replica's trigger run queue (see How a fire becomes a run), whose worker count is a ceiling on trigger-started runs executing at once on that replica across all workflows.
The budget holds across replicas. Single and Restart use a cluster-wide run lock, Parallel and Queued a
cluster-wide slot count, and fire de-duplication makes one physical event open one run rather than one per replica. A
host that does not provide all three does not start. A replica that is starting up or fenced does not hold the run
lock, so a Single or Restart run is skipped there as if a peer ran it, and a run ends at its first heartbeat
(every 10 s) after its lock is lost.
| Field | Default | Meaning |
|---|---|---|
Mode |
Single |
The policy, below |
MaxConcurrentRuns |
1 |
Permits. Ignored in Single and Restart (always 1) |
MaxQueuedRuns |
10 |
Wait-queue capacity, Queued only |
OverflowBehavior |
Drop |
Drop silently, Log with a warning, or Error (throws, audited) |
| Mode | Budget free | Budget full | Overflow consulted |
|---|---|---|---|
Single |
Run | Skip | No |
Restart |
Run | Cancel the running run, start the new one | No |
Queued |
Run | Enqueue if the queue has room, else apply overflow | Yes |
Parallel |
Run | Apply overflow directly, no queue | Yes |
Order of fires. Fires of one automation reach admission in the order they were queued, so an "on" and an "off"
trigger of the same Restart automation in one ingest batch leave the newer run standing. The order is best effort and
per replica. After Automations:TriggerRuns:AdmissionOrderWaitSeconds (default 30, 1 to 300), or when the run queue is
full, a waiting run is admitted out of order, counted in reeve_trigger_runs_unordered_total and named in a throttled
warning.
Changing the budget. A reconfiguration applies to runs already queued. A lowered queue capacity keeps its waiters
and refuses the next one. A Restart trigger waiting for the permit stands aside when a newer one queues behind it,
and is answered Skipped with the reason restart_mode_superseded_by_a_newer_trigger. A resumed wait takes a place in
the budget like a fresh run, and one with no room is put back as Suspended and taken again later. A decision that
does not start a run immediately (skipped, restarted, queued, dropped) writes no audit row. Metrics and logs record it.
POST /api/workflows/{id}/execute surfaces the outcome as a status code:
| Outcome | Status | Body |
|---|---|---|
| Ran, or the trigger was absorbed without error | 200 |
Resolved outputs, or an empty map |
Unknown workflow (404), or definition or inputs failed validation (400) |
404 / 400 |
Problem details |
Overflow set to Error and the budget is exhausted |
409 |
{ workflowId, mode, outcome, message } |
| The version, or a sub-workflow it calls, holds the C# script block and the deployment turned scripting off | 403 |
Problem details with code: "scripting-switched-off" |
| The version, or a sub-workflow it calls, holds a block of a native plugin whose uninstall this replica is retiring | 403 |
Problem details with code: "plugin-uninstalled", naming the plugin |
A newer restart-mode trigger claimed the single permit (host shutdown and client disconnect are not mapped to 499) |
499 |
Empty |
Deleting a workflow removes finished execution state and suspensions first, then the workflow, in one
transaction. A workflow with a non-terminal execution refuses deletion, and so does a blueprint-installed workflow
while its installation record exists. Every replica then cancels the runs it held for the workflow, and a run waiting
for a retry ends Cancelled with no further attempt. Each replica writes one automation.run.cancelled_by_delete
audit entry per run it cancelled. The DELETE response does not wait for the other replicas.
Cancelling a run. The workflow's owner lists its non-terminal runs (Pending, Running, Sleeping, Waiting,
Suspended) with GET /api/workflows/{id}/active-runs (the 100 newest, and moreRunning when there are more) and
cancels one with POST /api/workflows/{id}/active-runs/{executionId}/cancel. This needs automations.manage and
ownership. Another user's workflow, or a run of another workflow, is a 404. An operator with audit.view and
home.manage cancels any run through POST /api/workflows/executions/{id}/cancel.
A cancel moves the run to Cancelled (409 when it already ended or moved meanwhile), ends every wait the run is
parked on and closes its journal entry, so the workflow can then be deleted. A live run started through a sub-workflow
block is cancelled down the whole chain. A wake that lands after the cancel writes nothing, so the remaining blocks
never execute. The web app shows runs in progress with a Cancel button above a workflow's history and refreshes the
list every 15 seconds and after each cancel.
Crash recovery. Every replica runs the library's recovery sweep, and a row two replicas see is taken by exactly
one. The interval, batch size, abandonment cutoff and give-up bound come from the Workflow:Engine settings. Signals
between replicas (a Restart superseding their runs, a debugger command) travel on the cluster bus. A missed signal
is not a correctness failure, because the durable state is in Postgres. The cost is a takeover or a step, never a run
that should not have started.
Wait blocks
These blocks pause a run until a condition arrives or a timeout elapses. Suspended state is persisted and survives a restart. A resume comes from a trigger fire (published as a wake) or from the library's waker, and a single compare-and-swap decides which replica wakes the run.
| Block | Config | Outputs |
|---|---|---|
WaitForTrigger |
TriggerIds* (comma-separated), TimeoutSeconds* |
Outcome = satisfied/timed_out, TriggerData |
WaitTemplate |
Expression* (must start with expr:), TimeoutSeconds*, PollIntervalSecondsOverride |
Outcome, LastEvaluation |
WaitForProperty |
Predicate*, TimeoutSeconds (default 300); Target is a port |
Outcome = satisfied/timed_out, Value |
WaitForDuration |
DurationMs* |
Completed, DurationMs |
A wait must sit on the root canvas. A wait inside a loop, a try/catch or any other container is refused by name. Move it out of the container.
Prefer WaitForTrigger when a purpose-built trigger exists. It is event-driven and costs nothing idle. Only a
trigger fire resumes one, and the waker's pass can only time it out. A fire reads the parked rows at that moment, so a
row parked a moment ago, or by a peer replica, is still woken. A TriggerIds entry that parses as a GUID is stored in
lower-case hyphenated form, so a hand-typed upper-case or braced id still works. Every id must be a trigger on one of
the workflow owner's own automations. Any other id, another user's trigger included, fails the node.
TriggerData after a resume is JSON text, not a Json value. A downstream block wired to TriggerData receives the
envelope's JSON as a String. Hand it to a String input, or read a field with ParseJson. (${trigger.<field>}
is a Json value.) A fire whose payload the host clipped also adds one Warning entry to the woken run's history,
naming the keys and the rule, never a value.
WaitTemplate is evaluated by the waker on its own pass, at Workflow:WaitPollIntervalSeconds (default 5), whatever
the expression reads. That includes an expression over helpers only and a constant one: nothing publishes a helper
change as a wake. PollIntervalSecondsOverride is not read. Every parked template is looked at on the one cadence,
which can only make a wait resolve sooner than the override asked for.
To control polling cadence system-wide, wrap the raw reference in a helper that carries the condition, give the helper a sensible cadence, and write the wait against the helper. A generic "watch any expression" trigger is not offered because it would bypass this.
If a trigger fire misses a parked row, that run waits to its timeout and takes the timeout branch, and no counter shows it. An oversize suspend payload fails with a structured error.
A long sleep parks its run
Workflow:Engine:DurableSleepParkWhenAtLeastSeconds defaults to 30 seconds. A WaitForDuration shorter than that
waits in the process, holding the run's concurrency slot. A sleep at least that long parks: the run becomes a Sleep
suspension row whose timeout is its wake time, and the library's waker re-enters the run when it is due. A parked
sleep still counts for Single and Restart: a Single fire is skipped while one is parked, and a Restart fire
cancels it. That holds only on a replica with the threshold set.
A sleep parks only when everything below holds. Otherwise it stays in the process, silently and correctly:
| Condition | Why |
|---|---|
The automation is Single or Restart |
A resumed sleep asks for a place without waiting, which under a steady Queued or Parallel queue it would never get. |
| The sleep is on the root canvas of a root run with a state row | A resume re-enters a container from its start, and a child's parent waits for its outputs in memory. |
| No debugger, no recorded run log, no execution timeout, no multi-attempt retry | All of these live in the process. |
No node has failed under a Skip error policy yet |
A resume would run it again. |
| The payload is JSON and under the suspension cap | The engine parks against the cap the store enforces. |
What differs from a sleep in the process. Outputs of the nodes before the sleep are stored as JSON and read back,
so a node after the wake sees JSON shapes: a DateTimeOffset or Guid as a string, an int as a long, a record as
a dictionary. The wake time is fixed from the parking replica's clock and compared against the database's, so clock
skew moves the wake by that much, and the wake is up to one waker pass (5 s) late. While parked the execution state
reads Suspended, not Sleeping, and the suspension metrics show kind="sleep".
Suspension metrics. reeve_workflow_active_suspensions is read from the database at each collection and reports
every kind, 0 included. It is the same cluster-wide number on every replica, so take one replica's value or the max,
never the sum. It counts rows, not runs, and goes stale instead of reporting zero when the database cannot be read.
reeve_workflow_suspensions_total and reeve_workflow_suspension_duration_seconds count a suspension when the segment
it resumed ends, labelled with that segment's status (succeeded, failed, cancelled). The counter misses some
cancellations (a sleep that recovery ends after its replica died). The gauge does not.
A stopping replica has room to save. Resumed runs on a stopping replica save Cancelled, or hand over, inside the
host's shutdown timeout, so a pod stopped mid-run leaves its journal Cancelled or handed over, never Running for
recovery to replay. Hosting:ShutdownTimeoutSeconds defaults to 204 s and the Helm chart's
backend.shutdown.gracePeriodSeconds to 214 s. The chart refuses a render that leaves less than 10 s between them.
Raise both together if a deployment's runs are slower than that.
Turning it off. An empty Workflow:Engine:DurableSleepParkWhenAtLeastSeconds disables new parking (in Helm,
automations.durableSleep.parkWhenAtLeastSeconds=null). Drain first:
- Set the threshold to
86400on every replica. Only a sleep of a day or longer still parks. - Wait until no parked sleep is left. This query reads 0:
SELECT count(*) FROM automation.workflow_suspensions s JOIN automation.workflow_execution_logs l ON l.id = s.execution_log_id WHERE s.kind = 2 AND s.status IN ('Suspended','Resumed','TimedOut') AND l.completed_at_utc IS NULLThe waker wakes them at their due time meanwhile. A workflow with sleeps of 24 h or longer that keeps firing can hold the count above 0 until those sleeps end or are cancelled. - Set the threshold empty (or chart value
null) on every replica.
A Single automation that keeps skipping with single_mode_parked_sleep while its execution shows Running and no
sleep row is due is a run whose park was lost. Recovery picks it up once its replica has been silent for five minutes.
If it outlasts that, cancel the execution, which cancels its sleep rows, and the workflow fires again.
Checkpoints and recovery. Before every root block the engine stores a checkpoint. Reeve does not re-enter a run from it: the resume runner replays from the start. A resumed segment that is handed over or reclaimed therefore starts the whole run again, and reaches the sleep, and waits it out, a second time. Config backups, workflow exports and bundle exports preserve the workflow's checkpoint policy alongside its timeout and retry policy.
When recovery finds an abandoned run it first cancels any sleep the dead attempt left parked and ends that attempt's
journal Failed ("abandoned by a dead replica"). It replays the run only if every block in its pinned definition is
idempotent, including every block inside a container (a container that declares itself idempotent does not answer for
its body). The claimed row ends one of these ways:
Failed/block_not_idempotent_during_recovery: some block is not idempotent.Completed/replayed_by_recovery: the replay has a row of its own.Failed/resume_failed: the replay failed.Failed/not_admitted: admission refused the replay, and the run is older thanWorkflow:Engine:RefusedReplayGiveUpAfterSeconds(60 to 86400), counted from its start. A younger refused run stays claimed and is retried about every five minutes. A run already older than the bound when its replica died gets one attempt.
Recovery does not run while the host is in safe mode, and the rows wait for a normal boot. Suspensions and execution state are runtime state, protected only by database backup.
Webhook triggers
POST /api/automations/triggers/webhook/{webhookId}
The endpoint is anonymous and rate-limited. The path segment is the caller-chosen id from the trigger's configuration.
The budget is 5 requests per 10 seconds per webhook id, shared by every replica, so a caller that posts more often
than about once every two seconds gets 429. The limiter runs before the id is looked up, so unknown ids are counted
too. The count lives in Redis. With Redis unreachable the endpoint answers 503 with Retry-After instead of letting
a fire through uncounted.
| Config field | Type | Required | Notes |
|---|---|---|---|
webhookId |
Text | yes | Becomes the path segment. Re-registering an id in use overwrites the previous callback. |
secret |
Password | no | Compared in constant time against the X-Webhook-Secret header. |
A webhook is a fire signal, not a data channel. The body is not mapped into workflow input ports, and the workflow runs with its own defaults. For an accepted call, the body, headers (minus the secret) and source address are stored as an invocation record for inspection and replay only.
There is no body-signature scheme. The header secret is the whole auth model, and an unconfigured secret leaves that id open to anyone who can reach the endpoint. An unknown id, an inactive trigger and a wrong secret all return the same not-found response so ids cannot be enumerated. A missing or wrong secret is written to the backend log with the id and source address, and nothing of the call is stored. Replay re-fires a stored invocation and does not re-check the secret.
Debugger
A step-through debugger pauses a run before each node carrying a breakpoint, captures a snapshot of inputs and variables in scope, and waits for a command. The commands are step, step-into, step-over, resume and kill. Variable mutation is rejected because an injected value can land in the wrong type slot.
Session metadata and snapshots are persisted, but the pause/resume state lives in the memory of one replica. A hub
command completes after local application or handoff to the transport, which does not confirm delivery. A lost command
leaves the run paused until another command arrives or the orphan timeout kills it. The timeout is 300 seconds from the
start of each pause (Debug:OrphanedSessionTimeoutSeconds), and a lost command does not extend it. A run nobody steps
is killed rather than continued, because an unattended half-stepped workflow can leave devices and external services
mid-state.
The audit records Resume and Kill requests (which may not have landed) and a Step only when the run steps. Kill has no effect on a run that is Running but not paused, and deleting its debug session in that state does not stop the
workflow. A session ends Completed when the run it watched succeeded, Failed when that run failed or timed out (a
block threw, the network egress policy refused a request), and Cancelled otherwise. The panel shows Failed in the
error colour.
| Method | Path |
|---|---|
| POST | /api/workflows/{workflowId}/debug-sessions: create idle, optional breakpointNodeIds |
| POST | /api/workflows/debug-sessions/{sessionId}/execute: optional body { inputParametersJson }, a JSON object keyed by parameter name (anything else is 400) |
| GET | /api/workflows/debug-sessions/{sessionId} and …/snapshots |
| DELETE | /api/workflows/debug-sessions/{sessionId}: request kill, then delete the session |
execute starts the run and answers once admission has decided: 202, or a refusal that ends the session Cancelled.
The refusals are the start refusals described under A run is pinned,
as 400 with diagnostics
when the version does not compile or the start refuses the inputs (a missing required parameter included), 503 with
Retry-After when that could not be answered, 400 for no published version or unresolved import references, 403 when
the owner may not run the scripts the workflow holds, 404 when the workflow is gone, and 409 when the run mode or a full
queue refuses it, scripting is switched off (errorCode capability_switched_off) or a retiring plugin's block is in
the version (code plugin-uninstalled). A session no run binds after a 202 ends Cancelled too.
The realtime hub is /hubs/workflow-debug, gated on automation management, with per-method checks requiring session
ownership or household management. Server events: Paused, Resumed, Completed, SnapshotCaptured. Client
methods: JoinDebugSession, LeaveDebugSession, Step, StepInto, StepOver, Resume, Kill, SetBreakpoints.
Sharing and import
Export produces a self-contained document. Import validates it, reports missing block types and references needing remapping, then creates the workflow and publishes a version immediately. Internal ids are regenerated and only natural keys survive. Device and room mappings are applied before the version is created. Import is rejected outright when a referenced block type is not installed. Device and room mismatches do not block it.
A document is judged as sent: it is validated as received, the unmapped device, room and Property<T> ids are mapped,
and it is validated again. Nothing is rewritten. This holds at every door (single import, plugin API, bundle,
blueprint install, rollback, update and repair, and import/validate). A document that does not compile (for example
a SetDeviceState node, an alias or Any type name, or a text literal on a Boolean, Int or Number site) is
refused with a 400 and the diagnostics a publish would answer. A bundle holding one is refused whole, and its
refusal names the workflow. Only a publish that could not be finished after the commit leaves a draft (see the
save outcomes). A backup restore is not an import and keeps such a workflow as a draft.
A bundle of workflows is imported as one unit. Callees are imported first and each sub-workflow call is pointed at its
callee's copy. Workflows that call each other, or one that calls itself, stay drafts: publishing a caller whose callee
has no published version is refused, and a cycle never gets one. A call to a workflow that is in neither the bundle
nor this installation refuses the whole bundle with a 400. A bundle whose manifest does not name each workflow's
sourceId has its calls refused unless the callee already exists here.
A workflow document or bundle is not a backup: no devices, telemetry, accounts or audit history travel with it. Move an installation with the database backup (see backup and restore).
Scenes
Scene access is checked per user and per scene, with optional hidden overrides and allowed time windows evaluated in the household time zone. A scene the user cannot see returns not found, so its existence is not disclosed. A visible scene outside its window is forbidden.
Scene activation is partial by design. An undispatchable action (device removed, access denied, typed commands unsupported, value unparseable, descriptor rejected) is reported in a skipped list and does not abort the rest. Dispatched plus skipped always equals the stored action count. Devices are dispatched in parallel, at most 8 at a time. A fault outside the per-device skips, or a caller cancellation, aborts the whole activation.
A scene marked to bypass executor permissions actuates through a privileged dispatcher instead of the access-checked path. The mark is off for a new scene, and an update request that omits the field is refused with 400.
A scene action outlives its device. No device deletion removes scene actions. An action whose device is gone is
reported as DeviceMissing, counted in MissingDeviceActionCount, and skipped at activation with DeviceNotFound, so
no command reaches a plugin. An update keeps such an action when the scene already held it, and refuses a new one on a
device that does not exist. See missing references.
Missing references
A stored device or helper id with no row behind it is a missing reference. It is computed on read, batched, so a list
costs a fixed number of queries whatever its length. A retired device is still a row and is never missing. It raises
device.replaced instead. The scan covers:
| Where | Reference label |
|---|---|
| Scene actions | action:<id> |
Automation triggers (the trigger's device, and a StateChange trigger's helperId) |
trigger:<id> |
| Bound inputs | input:<parameter> |
Blocks of the bound workflow's current version: literal device targets, and the literal HelperId of SetHelperValue or IncrementHelper |
workflow:<node reference> |
Dashboard widgets: device, camera, chart and statistics-table references, and the helperId of the three helper widgets |
widget:<path> |
It does not follow sub-workflows, wired or expression targets, Raw*Property vendor blocks or custom-widget bindings.
The automation summary reports BrokenTriggerCount (triggers), MissingReferenceCount (distinct places),
MissingInputCount and MissingBlockCount (the inputs and workflow blocks among them). Every dashboard response
carries MissingReferences, AutomationResponse.MissingReferences lists them, and each trigger sets
HasMissingDeviceReference. A run that fails on a removed target (device.not-found, a missing device or a missing
helper) is logged as one warning with the workflow, trigger, node and message and no stack.
The one-minute maintenance pass reconciles one Condition alert per automation, scene and shared dashboard with a missing reference (see alerts). The demo seeder rebuilds demo scenes, dashboards and automations that have a missing reference, replacing the user's edits to them.
Traps
| Symptom | Cause and fix |
|---|---|
| The automation runs, the log says success, nothing happened | It was saved as a draft, and the automation ran the older published version. Publish, and read the banner. |
| An automation switched itself off after a workflow was saved | The publish changed a declared input its values no longer fit (see publishing). Fix its inputs, then re-enable it. |
| A workflow input value silently becomes empty | An edge maps a source output that no longer exists. The dangling wire is skipped. Fix or delete the mapping. |
| An expression referencing device state previews correctly but is always null at run time | The device namespace is not populated during execution. Read state with a device-property block and reference that node's output (see expressions). |
| Inside a branch, a reference to an earlier top-level node resolves to nothing | The sub-canvas is seeded only with the branching node's inputs. Carry the value in on the parent node: ticking its name in that node's passthrough list gives the parent the input port to wire it into. See crossing the sub-canvas boundary. |
| A suspended run never resumes and never times out | For a trigger wait, the referenced trigger belongs to a disabled automation or a broken plugin. For a helper-only expression wait, the named helper does not exist, so the expression stays null. |
An automation never fires and System status shows automation.trigger_unarmed |
The trigger host cannot arm a trigger: its type is not installed, or its start failed or timed out, for at least 30 seconds and two syncs. The message names the type and the reason. |
| A sun-triggered automation never fires | The home has no location. There is no execution record and the debugger shows nothing. System status carries home.location_missing and the backend logs one warning per trigger. |
${trigger.<field>} is empty inside an IfElse branch, a ForLoop, IterateOver or WhileLoop body, or a TryCatch branch |
Sub-canvases start with no trigger and no envelope. Read the field in the outer graph and pass it into the sub-canvas as an input. |
| A camera media link answers "the camera workload answered unexpectedly" | The plugin's retention has expired the file, and the upstream 404 is restated as a gateway error. The same wording covers a genuinely broken workload, so the age of the link tells them apart. |
| A camera plate trigger blocks every save of its automation, including a rename | Its watched-plate list is longer than 100 entries. The cap is enforced in the editor only, so a list written through the API runs fine but cannot be saved from the editor, which re-validates every trigger on submit. Trim the list through the API. |
Not supported
- Connection-level transforms or conditionals. Use typed ports and explicit conversion blocks.
- A generic "watch any expression" trigger or a dedicated helper trigger type. Helpers carry the cadence lever, and helper writes ride the device event sink.
- Falling back to the current version when a pinned version is missing, auto-connecting orphan roots, and warn-and-continue for loop caps.
- A per-run execution budget, sandboxing the scripting block, and a separate execution status for skipped runs.
- Per-trigger concurrency budgets, adaptive concurrency, and a cooldown parameter on the workflow. A trigger type may expose its own minimum interval (the camera triggers do), which is not a budget over runs.
- Debugger rewind, conditional breakpoints, editing variables at a breakpoint, multi-user debugging, and breakpoints persisted across sessions.
- Cross-replica handoff of a suspension, pluggable execution-state backends, sub-second delays, cron-style waits and a "wait until workflow X finishes" block.
- An in-app backup button (see backup and restore) and a built-in workflow marketplace (use file exchange and checksummed blueprint repositories).
Device model disable and re-enable
An open error finding from the device model on an automation's trigger, on its workflow, or on any workflow it reaches through statically configured sub-workflow nodes disables the automation. The disable records the message of the oldest blocking finding (the device and the missing capability or channel) and shows it in the alert and in the automation's disabled notice. Warning findings do not disable. The findings endpoints list both kinds.
While an error finding remains, enabling the automation answers HTTP 409 with errorCode
automation.blocked.device-model.
When the last blocking error clears, the device-model reason is cleared. The automation then switches back on only under automatic resume. Otherwise it stays off as an ordinary disabled automation until the operator enables it.
Automatic resume
An automation resumes only if all of these hold:
- It was enabled when the model disabled it, and nobody has changed it since. A save, enabling or disabling, switching debug mode, and adding, editing, removing or replacing a trigger all count as a change. So does the inputs cascade of a workflow publish. Deleting its folder counts too.
- The scan that released the last error was a device-model scan (model event, passthrough or settle), not an object save, a workflow publish, a device removal or the startup check.
- The released error was on the scanned device.
On resume the automation is enabled and an automation.resumed audit row (actor: the system) is written. The host
raises the Info event automation.resumed and resolves the automation.disabled alert.
Without a resume the reason is cleared, the automation stays off and the automation.disabled alert is resolved.
The web app offers no inline Enable for it, so the operator enables it from the automation.
If an operator change commits before the scan reaches the automation, there is no resume. If another device raises
a new error, the automation does not resume, or is disabled again when the resume already committed. A failed alert
write is logged, and the one-minute maintenance pass resolves automation.disabled for an automation that has no
reason left.
Automation and workflow folders
Deleting a folder moves its automations and workflows to the root and clears their resume state. An automation or
workflow moved out of the folder while the deletion waited keeps its new folder. Saving an automation, or
writing a workflow, in a folder that is being deleted is refused: an automation save answers 404, and a workflow write
answers 400 with host-metadata-folder-not-found.
A workflow's folder is the folderId key of its host metadata. Reeve checks the metadata before the editor is asked to
save, and refuses with HTTP 400 and the problem body's code: host-metadata-key-refused for any metadata key but
folderId, host-metadata-folder-malformed for a value that is not a 36-character GUID in its D form, and
host-metadata-folder-not-found for a folder that does not exist for this caller.
Null and an empty map both mean no folder. The bundle import form field folderId follows the same rules, and a bundle
archive itself carries no folder. A blueprint install's folderId and the device-model gate's draft rewrite keep a
workflow where it is. A deletion removes the folderId key and nothing else.
A failed write to the change log rolls the save back (an auto-published save reports the failure as the result's Fault
and leaves the draft unpublished).
Saving over a newer revision. WorkflowResponse.revision counts the writes to a workflow. PUT /api/workflows/{id}
takes expectedRevision, the revision the caller's copy was read at. While the row still holds it the save goes
through. Otherwise nothing is written and the host answers 409 with the problem body's code revision-mismatch. A
409 without a code means the draft or the version history moved. Without expectedRevision the check is skipped.
The bundled web editor does not send it, so its saves are not checked, and it offers Reload on a 409. Deleting a
folder moves the revision of every workflow it unfiles.
Removed device stop
An enabled automation is stopped when a device that no longer exists is named by a bound input, by a published
workflow block, or by its enabled triggers so that it can no longer fire. In All mode any such trigger counts. In
Any mode every enabled trigger must be affected, so an Any automation that loses one of several triggers keeps
running with that trigger unarmed. The stop switches the automation off with the reason device removed.
DisabledDetail names the device ("Device 'Oven plug' was removed.", or "Device '{name}' and {n} more were
removed."; a device whose name is no longer known is given by its id). A device-model disable on the same automation
becomes this reason. An automation the operator switched off, or one off for its workflow's inputs, keeps its state.
Each stop raises one automation.disabled alert.
The stop runs from three places:
- Removal. After a device is deleted (device removal, plugin uninstall, instance removal, a plugin reporting a device gone, a merge or the retired-device purge), the host sweeps every running automation that names it.
- Maintenance. The one-minute device model retention pass sweeps every running automation, which also covers references that exist at startup.
- Run. Before admitting a run, the match gate checks whether the automation is stopped for a removed device and skips the run if so. A clean answer is reused for up to a minute, until this replica sees another removal. A failed check lets the run start.
A sub-workflow's blocks and wired or expression targets are not checked ahead of time, so a run that reaches a removed device there still fails and is logged as one warning line.
A merge re-points the merged device's references before it deletes the merged device (see devices). Trigger configurations, stored inputs and workflow drafts get the target's id. Published versions are not rewritten, so an automation whose published workflow names the merged device is stopped after the merge commits until its rewritten draft is published.
Enabling a stopped automation by hand clears the reason. If a removed device still stops it, the next maintenance pass
or fire stops it again, and Repairable stays false meanwhile. Resuming is refused while a device-model block holds
the automation. Demo automations the reseed rebuilt resume once no missing device is left, with an
automation.resumed audit row.