Automation
This page describes the model and rules of Reeve's automation: the workflow engine and how the backend hosts it, triggers, the path from a fire to a run, waits and recovery, helpers, scenes, utility metering and blueprints. Block catalogue, trigger fields, endpoints and traps are in automation and workflows, expressions, helpers, blueprints and utility resources.
Building blocks
| Part | What it is |
|---|---|
| Workflow | A versioned JSON graph of typed nodes. The engine, graph model and editor come from the workflow library (ReeveWorkflow on the backend, @reeve-iot/workflow-* on the frontend), and the backend hosts the engine. |
| Automation | Binds one workflow to one or more triggers, with run parameters (input bindings, debug mode) and a match mode, Any or All. |
| Trigger | A plugin registered under a string id: device state change, schedule, sun, device event, webhook, geofence, the camera triggers, and third-party or WASM types. |
| Helper | Named, persistent automation state (boolean, number, counter, expression-derived), standalone or attached to a logical device. |
| Scene | A stored set of device actions dispatched together. |
| Blueprint | A parameterised workflow template fetched from a checksummed repository. |
| Utility meter and tariff | Counters read from device telemetry, and the cost formulas applied to them. |
| Expression | A closed infix language opted into on block inputs and used by expression helpers. |
A trigger fire is queued on the replica that saw it, re-checked by a worker, admitted by the workflow's coordinator against its run mode and the cluster-wide gates, and, when it waits, parked in PostgreSQL and resumed by exactly one replica.
The engine and its host
Blocks
The library owns the blocks that say nothing about the home: branches, loops, Try/Catch, conversions, Expression,
Filter, Math, ParseJson, WaitForDuration, HttpRequest and SubWorkflow. The blocks in this repository each
name a device, a room, a scene, a helper, a camera or the script host. Block type ids are stored in saved definitions
and never change.
A block id is registered once, and a plugin block cannot shadow a registered id. A refused built-in block fails startup and a refused plugin block is declined at plugin load. A plugin update replaces the plugin's whole set and never removes a block another owner holds. A block factory that cannot describe itself is dropped from the palette with an Error log. In safe mode no run starts.
Every start passes one gate for switched-off workflows
Whether a workflow runs is stored in automation.workflow_enabled_states. One gate refuses the start of a switched-off
workflow before the library's admission. It is asked where a start enters the engine: Reeve's start door (triggers,
webhooks, scripts and debug runs), the sub-workflow block, and an endpoint filter in front of the library's execute
endpoint. A missing row means enabled, and an unreadable row lets the start through with a warning, so a transient fault
never silences the home. Resuming, replaying and recovering an admitted run are not starts and are not gated.
A start that admission did not let run (safe mode, a Single run in flight, no room under a Drop or Log overflow)
answers as a refusal, not as a run with empty outputs. Admission also refuses, across the workflows the version calls:
| Code | When |
|---|---|
scripting-switched-off |
The version holds the C# script block while scripting is switched off. |
plugin-uninstalled |
The version holds a block of a native plugin this replica is retiring after an uninstall (Manual and Trigger starts only; see plugins). |
The library's execute endpoint answers these with 403 and the code, a debug-session start with 409. A trigger start
is logged.
Graph and data flow
- There is no implicit conversion and no transform or condition field on a connection.
- A definition is refused unless exactly one node has no incoming connection and it is the Workflow Input node, every node is reachable, and each input has at most one feed. The rules apply at save, import and before execution.
- An unopened
Catchcatches and ignores, and a declared output whose source key lives in an unopened branch returns null. - A node id or block-type id over 100 characters is refused at compile (
node-id-too-long,block-type-id-too-long), because the run's node log stores them incharacter varying(100)columns. - New nodes get ids an expression can read (
nplus 12 random hex digits), because the lexer reads no-inside${…}. An existing unreadable id is kept and listed disabled in the expression editor.
A per-node error policy (fail the workflow, the default; continue with a default; emit a structured error on a virtual error port; skip the node and its downstream) applies after retries are exhausted. Try/catch/finally blocks wrap sub-canvases. Handlers and plugins see a normalised error object, never a raw exception or stack trace. A policy found in a node's configuration instead of on the node is refused by the compiler.
Expressions are opted into with the expr: prefix on a block input. They support arithmetic, comparison, logic,
ternary, concatenation, variable paths under ${…} and a fixed function table, with no loops, closures, assignment,
regex, reflection or I/O. Depth, syntax-tree size and length are capped. An expression is typed before it runs, so an
unknown function or a type mismatch is refused at compile. A value missing at run time, an overflow or a division by
zero fails the node.
Saving, versions and import
Saving publishes, and a draft is the explicit exception
The editor's primary save publishes a new version, and saving a draft is a separate action. Automations always run the published version. An existing draft raises a banner naming the version that runs, and inputs declared only in a draft do not reach the automation binding form until published.
Every create, update and import answers one of seven outcomes with its diagnostics: Published, Unchanged,
DraftCompiles, DraftDoesNotCompile, DraftUnchanged, DraftNotJudged, PublishDeferred. A write that does not
compile is a success holding a draft: the published version keeps running and the diagnostics say why. A publish still
owed answers 503 with the stored draft and a Retry-After, and the retry is the publish alone, because resending a
create would make a second workflow.
A run is pinned to the version tree current when it started
At root start the engine records the root's version and a manifest pinning every statically referenced sub-workflow to
its then-published version. Suspend, resume, restart and recovery reload those versions. An unresolvable pin fails the
run with an explicit reason and never falls back to the current version, and a pinned version that does not compile is
recorded Failed with did-not-compile or compilation-unanswered. A sub-workflow's target must therefore be a
literal id in node configuration: a wire or an expression is refused at save, import and publish.
A publish switches off only the automations whose inputs it breaks
A publish from the editor compares the input parameters of the new version with the ones it replaces, and switches off an enabled automation only when its stored inputs do not fit a parameter this publish changed. A typeless parameter is refused. Blueprint update and repair publish a re-rendered version without this check.
Every import door validates the same way
All import doors and the validate endpoints share one order (read, rules, compile) that stores nothing, so validate and import cannot disagree. An import calling a workflow the host lacks is refused before anything is written, and callees are imported first. A graph whose device or room references cannot be resolved arrives switched off. A document that fails validation is refused with the diagnostics a publish would answer. Drafts of a host transaction are published after the commit, callee first, and a refused publish leaves a draft.
A workflow's folder is the folderId key of its host metadata (the only key accepted), a GUID in D form. A workflow
with a live execution refuses deletion with 409. Each replica's workflow reconciler cancels the runs it held for a
deleted workflow and writes one automation.run.cancelled_by_delete audit entry per run.
Automations and save-time validation
A trigger that could never fire is refused at save
A trigger that never fires would show a healthy card, so the save refuses a device-bound trigger whose device does not exist, a state-change key the device cannot resolve (channel membership comes
from the active source's descriptor), an unknown comparison operator (or one paired with a fromValue), an unknown edge
name or match mode, a watch list past the editor's bounds and a Cron expression that does not parse. An edit is one unit
of work: triggers reconcile before the single save.
An all-match set must be satisfiable by shape alone
In All mode a fire starts the run only when every other enabled trigger is satisfied at that moment. Save judges
whether a set can ever hold from configuration shape alone, with no I/O, so a device that has not reported yet cannot
make a legitimate automation unsavable. A set with two events is refused, because two events never coincide. A sibling
must be a type that answers "satisfied at this moment" (the state-condition registry) and its configuration must
describe a state, not a transition. Time windows are not All siblings.
Bindings, ownership and secrets
- Device and property bindings are checked from static facts, in one predicate, for node literals, bindings and
start arguments. The device type fixes the subtype, and another concrete type is refused in every phase. An
Unknowntype is refused at save and publish but not at admission. A missing or retired device is never refused here, because existence is admission's job. AProperty<T>value has one JSON form,{deviceId, key}. - An automation runs only its owner's workflows, and a sub-workflow block checks the owner of the running workflow. Another user's workflow, versions and executions answer not found (access filtering).
- A field a trigger type declares Sensitive is stored in an
enc:envelope and shown as***. A mask on a new trigger is refused, and on an existing trigger the stored value is restored before validation. An edit preserving an envelope the active key ring cannot decrypt is refused, and a value that cannot be decrypted at run time becomes a random string, so a webhook check refuses every caller. See secrets and audit. - Automation row writes take a transaction, lock the rows in ascending id order (after any device advisory lock), refresh the tracked copies, and only then decide and write. A writer that skips this can deadlock or overwrite.
Triggers
Feed-driven triggers run on every replica; the rest run on one
| Family | Types | Where armed |
|---|---|---|
| Feed-driven | StateChange, DeviceEvent, geofence enter and leave, the camera triggers |
Every replica, because the replica that ingested an event is the only one that can fire on it |
| Leader-owned | Cron, Sun, Webhook, every third-party and WASM type |
The replica holding the trigger-host unit kind |
Fire de-duplication collapses the feed-driven fan-out, so anything a feed-driven trigger remembers between fires must be cluster-wide state (no in-memory correctness state). The two reconcile lanes each stop only their own partition, so a lease blip never tears down feed-driven triggers.
Arming and rebuilding
A trigger plugin keeps state between events, so a sync rebuilds it only when its type or configuration changes (a rebuilt state-change trigger's first event only seeds its last value). Run parameters, match conditions and sibling sets are read from the rows when a worker takes the run up, never captured at arm time, and the fire-time gate refuses a run from a plugin whose type or configuration differs from the row.
A sync cycle reads the enabled triggers and the device set from one generation pin
(generations). A write wakes the sync lanes
only once the replica's generation holds it, because an earlier wake would read the old pin and arm nothing. Both lanes
also sync every 30 s. A trigger plugin's StartAsync has 5 s: a start that has not finished is abandoned, recorded as
failed to arm and never armed. StopAsync and DisposeAsync each have 30 s.
A Cron schedule fires at the household's local wall-clock time, and an unset or unknown zone degrades to UTC. A Sun
trigger has no firing time until the household coordinates are set, and it writes no execution record to say why.
State-change triggers
- A missing canonical value is a clean non-fire, never a raw-payload comparison.
- Edge detection runs under a per-trigger lock against the last value the instance saw, and the trigger fires after releasing it, because a fire that writes the watched helper re-enters the trigger. The value carried by the change is preferred over a re-read, so two changes in one ingest batch keep the intermediate edge.
- An absent operator means equality, and an unrecognised one makes the trigger silent. An absent value satisfies
nothing, not even
ne. - A change older than the configured maximum age has its side effect dropped, and the state is still stored.
- A trigger reacts to a device or a helper, never both.
An instance with no reference (created, edited, enabled, restarted or failed over to), or one that missed writes, takes its previous value from the typed state of the row the sink's upsert replaced, so the first alarm of a CO, smoke or leak automation is not lost to seeding.
The fire payload
A trigger type declares the leaves it populates. Each fire carries them into the run as ${trigger.<field>}, into a
wait-for-trigger block's trigger data and into the stored suspension, and a declared field is always present (null when
the device reported nothing).
idandfiredAtare written last by the host, and a plugin value for either is dropped.idis the trigger's own id and does not tell two runs apart.- A key breaking the payload bounds is dropped on its own and recorded in the run history by name and rule, never by value. The namespace is empty inside a sub-canvas and for a WASM trigger.
Fire de-duplication
One fire is collapsed across replicas by a window claim. Its key uses only what every copy of one occurrence carries byte for byte (the source's observed-at, a producer event id, the raw vendor payload, canonical values, the trigger row id), never a machine name, process id or clock reading. An event with no derivable key is refused rather than fired unkeyed.
A key with an observed-at names an occurrence and is claimed once per window. A key without one names only a payload,
is marked payload: and is held by the first process that claims it, which admits and renews the window while every
other process is refused. The cost is an under-fire when only a peer saw a repeat. A mixed fleet would claim two keys
for one copy, which the full-stop rule excludes.
Camera triggers
Object detection and plate recognition have their own trigger types, bound to the canonical camera type and event tokens, so every camera plugin drives them. Their filters only narrow: an unrecognised plate match mode falls back to the narrowest one, and a zoneless detection never matches a zone filter.
The minimum interval between camera-detection fires is a cluster-wide window claim under the cooldown use, keyed on
the trigger row id plus camera, object class and zone. It is taken before the fire and never released, so a run the
concurrency mode drops still spends the window. While Redis does not answer, the claim admits and logs a warning once
per trigger.
A watched plate list holds registration numbers only, with no names and no mapping to a person. A plate that fires a workflow is written raw into the trigger envelope, execution variables, debug snapshots, audit metadata, device-event history and the realtime push, bounded by retention (ninety days for event history and terminal execution state, a year for audit by default, seven days for debug snapshots). A plate is a claim by whatever published to the camera's broker, so a wrong firing on a gate automation can open the gate. See camera media and a camera event's source.
A webhook is a fire signal, not a data channel
The webhook endpoint is anonymous, rate-limited per webhook id across every replica, and optionally protected by a shared secret compared in constant time. The body is never mapped into workflow inputs, because that would be an untrusted path into blocks, scripting included.
- An accepted call stores the body, the headers minus the secret and the source address for replay. A call refused for its secret is only logged.
- An unknown id, an inactive trigger and a wrong secret answer identically, so ids cannot be enumerated. An unconfigured secret leaves the id open to anyone who can reach it.
- Every replica serves the endpoint. A non-leader resolves the webhook from PostgreSQL, answers 202 and queues the fire on its own run queue. Users see and replay only their own webhooks.
Location fixes, presence and geofence crossings
Each location report is attributed to a reporter, a handset identified by source kind and label. The label is stored
trimmed and lower-cased, and an empty label, a null one and default are one reporter. A report without a label that
came with a personal access token takes the label pat: plus the token id (a sent label with that prefix is refused),
so a new token is a new reporter.
One presence row stands for each reporter. A report claims the row for the device that holds its source (restoring a
row a merge removed, or taking it over from another device), never moving a row of another user. A new reporter counts against the limit of 10 per user (revoked or expired token reporters are not counted). Over
the limit the answer is 409 with errorCode location.reporter-limit.
A geofence crossing is computed per reporter from that reporter's previous fix. PostgreSQL decides which crossings are news (an upsert with zero affected rows means the direction was already announced). A reporter with no previous fix seeds the latch and never announces. Only the claim winner publishes a presence change.
A report with sentAtUtc, as the phone's has, is dated by its age (now minus the gap between the client's send and
capture stamps), so a clock offset neither reorders fixes nor moves them into the future. A report without it keeps the
client time, clamped to now when it is more than five minutes ahead. A fix captured before the reporter's latest stored
fix is history only: it moves neither presence nor a geofence latch and is not published, so a replayed backlog cannot
announce a leave the phone is already past.
Geofences are circles with no hysteresis margin. A geofence trigger defaults to the automation's owner and refuses another user unless explicitly authorised.
From fire to run
A fire queues its run and never runs it on the thread that fired
The fire callback bounds the payload and queues the fire on a bounded per-replica queue with two lanes. Waiters are
woken first on a small notification lane, so a run cannot be resumed by the fire that started it. The run then goes on
a run lane drained by MaxConcurrent workers, because running it inline would stall every later state change behind a
sleeping automation. A full lane drops the newest fire and counts it, and queued runs are lost with the pod. A sleeping
run holds its worker, so the worker count must exceed the long sleepers expected at once.
Each fire takes an ordering ticket in its automation's chain, and its run waits until the fire before it has been
admitted, or goes ahead unordered after AdmissionOrderWaitSeconds (30 by default). The chain is per replica, so the
order is best effort.
When a worker takes a run up, it re-checks the automation. A disabled or deleted automation or trigger skips the run.
An All automation evaluates its siblings, and a leaf that cannot be evaluated holds the run back. A failure to read
the mode itself runs the automation, because holding back every Any automation on a transient fault would silence the
home. Wakes still go out on a held-back fire.
Run modes are budgeted per workflow, with three cluster gates
One coordinator per workflow applies its mode (Single, Restart, Queued, Parallel), and the budget is per
workflow, not per trigger. Coordinators are per replica, so three cross-replica gates hold the budget: a run lock for
Single and Restart, a held-slot gate for Parallel and Queued, and fire de-duplication. A host that leaves one
unfilled does not start, and the error names the missing seams. Above one replica the newest Restart trigger is
decided by a generation read from the database, not by a clock.
The run lock is a cluster mutex. A held key and a replica that is not serving both answer null, never a throw,
because a throw reads as "degrade open" and would run unlocked. The lock reads invalid from a fence's first step and
from drain start, so a run ends at its next heartbeat, at most 10 s later. A readmitted replica does not resume a run it
lost (held tenures). The run-slot gate holds one self-renewing PostgreSQL slot per
run, and an acquire the database cannot answer admits the run on its in-process permit
(Postgres arbitrates held slots).
Restart supersession, debugger commands and breakpoint sets travel on Reeve's cluster bus with Reeve's channel names and message bodies. Changing one of these shapes is a wire change that would silence mid-rollout peers.
Waits, suspension and recovery
Wait blocks suspend to the database, and exactly one wake resumes a run
WaitForTrigger, WaitTemplate, WaitForProperty and a long WaitForDuration store their state as a suspension row
and survive a restart. Trigger fires and the typed canonical feed (active source only) publish wakes for the rows parked
on them. A WaitTemplate is evaluated on the waker's pass every Workflow:WaitPollIntervalSeconds. One
compare-and-swap decides which wake resumes the run. A wait answers at once if its predicate already holds, and a wait
inside a container is refused, because nothing could resume it.
A WaitForDuration of at least Workflow:Engine:DurableSleepParkWhenAtLeastSeconds (30 s by default; empty disables)
parks as a Sleep suspension instead of holding the run, its slot and its outputs in memory. It parks only on the root
canvas of a root run in Single or Restart mode with no debugger, recorded run log, execution timeout or
multi-attempt retry. Otherwise it sleeps in process. Outputs before the sleep come back as JSON shapes after the wake.
Execution state changes only by compare-and-swap
Execution state is transient state in PostgreSQL, protected only by database backup. Every transition is one conditional
UPDATE on the expected status. A lost race is an answer, and the caller re-reads. Optional fences narrow a swap:
| Fence | Prevents |
|---|---|
| Expected owner replica | A recovered owner flipping back a row a peer legitimately reclaimed |
| Expected block path | A late resume of a wait the run has walked past re-entering it |
| Expected wait key | An old row put back after the run parked again re-running the segment between |
| Expected version | A retry landing on a row other than the one it read |
Ending a row works only while this replica owns it. Only failed runs get audit rows, and audit metadata never carries variables.
Recovery
The library's sweep finds the runs a dead replica left behind. A recovered run is replayed from the start only when
every block in its pinned definition, including every block inside a container, is idempotent. Otherwise it ends
Failed. A replay that admission refuses is retried only for RefusedReplayGiveUpAfterSeconds after the run started,
then ends Failed with not_admitted. Recovery does not run in safe mode. Retention deletes a terminal row after ninety
days, so the journal reconciler first closes the open journal entries that row names.
Structured workflow values pass through the library's bounded redaction, which masks sensitive keys at every depth. The engine checkpoint is never logged. Container deadlines are unset by default, because a guessed deadline can cut a branch between opening and closing a valve.
The workflow debugger
The debugger's pause-and-resume rendezvous lives in one replica's memory, the one narrow exception to no in-memory correctness state. The commands are step, step into, step over, resume and kill. Mutating variables is refused, because an injected value can land in the wrong type slot. A command sent to a replica that does not hold the session is not confirmed, and a lost command leaves the run paused until the orphan timeout (300 s by default) kills it.
Blocks the host provides
Scripts run with full trust behind workflows.scripting
The scripting block compiles and runs C# in process with full host privileges. It is gated by workflows.scripting,
which administrators hold and which is not part of automations.manage. The permission is checked when a workflow is
created, updated, imported or installed from a blueprint, and again at execution against the workflow's owner. Scripts
see a curated typed facade authorized as the owner and never supply a user id. See
scripting is unsandboxed.
Managed:Capabilities:CSharpScripting, read once at start, can switch the block off. It is then missing from the
registry, the palette and the compile, and a plugin cannot register the id CSharpScript.
- Create, update, import, publish of a stored draft, rollback and blueprint install refuse a workflow holding the block
with
409andcapability_switched_off. - A start of a version that holds the block, including via a sub-workflow, is refused with
scripting-switched-off. The refusal leaves no run-history row and raises theworkflow.scripting_switched_offevent alert once per workflow version and process. GET api/workflows/script-holders(behindautomations.manage) lists the caller's workflows that hold the block in the current version (publishedHolderIds) or in the draft (draftHolderIds). A workflow that only calls a holder is not listed, although its start is refused too.
#r is refused, a workflow chain that triggers itself (A triggers B triggers A) is refused, and script blocks are
non-idempotent.
Other block rules
- Notification sinks receive text only, never device ids or media links (a link would need a credential in the URL).
- Each factory states its idempotence, because recovery replays only idempotent graphs and the default is
false. Set-property commands an absolute value, never a flip. A raw vendor-property write is non-idempotent. - A Room or DeviceType filter that is present but unresolvable throws instead of broadening the set. Raw vendor-property blocks are a labelled escape hatch: pass-through, no coercion, audited.
- Camera blocks apply the media route's own rules, so a workflow cannot address a camera its owner may not view.
- The HTTP block is SSRF-guarded at connect time and reports a boundary refusal separately from a network failure (egress, guarded clients).
Helpers
A helper is its own entity, addressed by name
A helper is named persistent state, standalone or attached to a logical device, never a device source. Its slug is
immutable. ${helper.*} resolves one segment as a standalone helper and two as a live device's helper. An expression
can name a device only by a friendly name unique among live devices, so a device rename wakes every helper registered
against the old name. Attached helpers cascade away with their device. Helper writes ride the device event sink as
synthetic events, which is how ordinary state-change triggers fire on them.
A write that changes a helper's expression is checked for cycles under a transaction-scoped advisory lock that reads the whole graph, so a helper another replica committed meanwhile is visible. A cycle is refused with 422 naming the path. Expressions are parsed and size-checked at write time.
Evaluation
- Evaluation is trailing-edge debounced: a request inside a helper's debounce window is kept and one evaluation runs when the window ends. A request during an evaluation marks the helper dirty and one more pass follows.
- Every pass takes a per-helper PostgreSQL advisory lock before it reads the helper, its inputs and its stored value, because every replica runs a dispatcher and a worker. The change event is emitted after the commit, and the value is written only when it changed.
- The dispatcher dispatches only when a helper in the current generation's graph depends on the device or the event comes from a helper, and never on a replica that is not serving. The freshness gate runs before dispatch, so a stale replay cannot chain into automations.
- Counter increments are debounced per replica (200 ms) and flushed under a per-helper cluster-wide advisory lock, so none is lost across replicas.
Changing a helper's value type is refused, listing the blockers, while any of these names the helper: an unfinished
run or parked suspension of a version that reads or writes it, a SetHelperValue or IncrementHelper node, a state-change trigger
comparing a value, an expression helper that would not type-check against the new type, or a row that cannot be read.
Stored values are never rewritten or converted, and scripts are graded at run time. The check is a snapshot: a run or
version landing meanwhile is refused at its own admission, compile or resume.
Model errors and missing references
An automation is blocked by open model errors, and only scans release it
An automation is blocked when an open Error finding sits on it, on its workflow, or on any workflow it reaches through static sub-workflow nodes. A block disables the automation and records the cause, decided under the automation row locks in the caller's transaction, so two scans cannot both report one disable. A publish or delete only blocks or releases. A scan resumes an automation only when it was enabled when the model disabled it and is untouched since (every operator write clears the resume marker). See device model disable and re-enable.
Removing a device or helper deletes nothing that refers to it. A reference is missing when its device has no
logical_devices row or its helper no helpers row (a retired device is still a row). One batched reader computes this
on read for scene actions, automation triggers, bound inputs, the literal device and helper blocks of the bound
workflow's current version, and dashboard widgets. Scene actions keep their device id with no foreign key.
Every object with a missing reference shows it in its list and detail, and a one-minute pass reconciles one Condition
alert per automation, scene and shared dashboard. Sub-workflows, wired or expression targets, raw vendor blocks and
custom-widget bindings are not scanned and surface when a run fails. Device ids are never reused, so re-pairing or a
merge leaves the old references missing until re-pointed. Activation skips a removed device's action with
DeviceNotFound.
Scenes
Activation is access-checked per user and partial by design
Scene access is checked per user and per scene, with optional hidden overrides and time windows in the household time zone. A scene the user cannot see answers not found, and a visible scene outside its window is forbidden.
An action that cannot be applied is reported in a skipped list instead of aborting the rest. The reasons are device removed, offline, access denied, typed commands unsupported, value unparseable, and command failed or unanswered. Dispatched plus skipped always equals the stored action count, and every activation surface must show the skips. New reasons are appended, so readers treat an unknown one as a generic skip.
A command the plugin did not carry out is a failure
A device command the plugin reports as failed is recorded Failed, and every command endpoint answers 502 with
errorCode device.command.failed, the plugin's reason and the command log id. 200 means the plugin took the command.
An unanswered command is TimedOut and 504, and a device with no active source is a 400 worded as offline. In a scene a
failed action is skipped as CommandFailed, and a Set Property step fails. A device-side failure is alerted on from the
per-plugin command failure counter, not the server-error alert.
Dispatch and capture
Activation dispatches different devices concurrently, at most 8 at a time, each in its own DI scope. A device's actions
stay one batched command in saved order, and order across devices is not guaranteed. Typed refusals and timeouts are
skips. Any other fault or a caller cancellation aborts the activation and cancels in-flight siblings, which can leave up
to eight command-log rows Pending.
"Capture current state" takes controllable capabilities whose catalogue role resolves to Control (no role also does),
and only resting tokens of command capabilities, since replaying "stop" halts a cover part-way. A Setting or
Diagnostic is left out, because replaying a calibration or schedule rewrites the device's configuration. A new action
must name an existing device, and its value JSON is checked for shape only.
Utility metering and tariffs
Counter use is computed from time-ordered readings
The last reading at or before a window's start is the baseline for its first step.
- A fall to under half the previous reading is a reset, and the new reading is the use since.
- A smaller fall counts no use and becomes the baseline. A negative reading is skipped.
- Buckets are
(start, end]on a fixed UTC epoch grid, and a bucket with no step is absent.
One read feeds the total, the tariff and the buckets.
Tariffs
An advanced tariff stores a variable-cost expression, evaluated per time bucket while a scheduled coefficient is active, and a fixed-cost expression, evaluated once per billing period. A standing charge in the variable expression would be multiplied by the bucket count, and nothing validates that a term belongs in the fixed one. A hand-written parser reads both. The gas volume-to-energy factor is a user-configured constant with no default. Expressions are parsed at write time (blank is a legal no-op), and a stored one that reaches evaluation unvalidated is a 400.
- A period variable is evaluated once per period only if it is additive. Non-additive ones are seeded with the real value. Non-finite results are coerced to 0 with a data-quality warning.
- A
CumulativeCounterbucket takes a baseline.DeltaUsageandInstantaneousPowerdo not.
Utility enums are parsed strictly, because they are stored as ordinals. A missing meter reference is a 404, and an
invalid date range or one too wide for its granularity is refused. The Utilities widget shows costs in its tariff's currency, or the home's without a tariff. A stored USD override is
ignored when the tariff or home has another currency, because USD is the picker's stored default.
Blueprints
Repository entries are verified against a declared checksum
Administrators register repositories fetched over plain HTTP, and every entry is verified against its declared checksum. A mismatch marks the entry tampered: it is listed for diagnostics and is never installable, updatable or repairable. A community-trust blueprint carrying a script node needs explicit approval at every install, update, repair and rollback.
Install remaps identifiers first, then substitutes placeholders once
Install first replaces every GUID-shaped string outside inputs.* with a fresh id. It then replaces every placeholder
({{input.X}}) in one pass by the bound value as its native JSON type, without recursing into a bound value and without
the expression engine, so install-time placeholders and runtime expressions never mix. A declared default is not merged
into the bindings, so an unbound input ships its literal placeholder text. A time_range input does not wrap midnight.
Install, update, repair and rollback go through one apply gate
The gate refuses, with the same 403 on every door: tampered entries, missing or unreadable content, a script node
without workflows.scripting, and a community-trust script node without approval. A script node is a CSharpScript
node or a node of any block type the block registry marks privileged, plugin blocks included. The gate looks on every
canvas, in the stored template and again after the input bindings are substituted, so an input that supplies a block
type cannot bring a script past it.
A re-render runs in one transaction. The workflow revision moves first, so a concurrent editor publish waits on the row
lock, and the new version becomes current only if it compiles and the secret rules accept it. Install and rollback are
imports. Update and repair are edits by the user who runs them, who needs secrets.bind for newly bound references.
Repository sync is fail-closed and crash-safe
The swap of the live catalogue depends solely on the sync cycle's explicit outcome, never on the staged row count. An empty upstream that changed still swaps, and an unresolvable commit counts as unchanged and leaves the catalogue untouched. The recorded commit advances only after the swap and blob promotion, so a failure before the swap leaves the catalogue as it was, and a failure during blob promotion is healed by the next sync.
Background sync and the daily binding re-validation each run on the one replica owning that kind and write one audit row. A manual "Sync now" runs the same cycle on the replica that serves it. Every sync of a repository holds that repository's cluster mutex, and a sync whose lease is lost stops where it is.
Re-validation resolves entities with the entity-level validator, because a schema-only check never notices that a
device is gone. A stale installation flips to BindingError, and its workflow, when it was on, is switched off. A
blueprint that left the catalogue flips none of its installations. Blueprint content is read as a workflow export, and
any member outside the published schema is refused by name.