Rule files reference
A rule document is thesettings of a rules supervisor: a JSON object with a rules list, checked when it is loaded. A load error names the rule that is wrong and stops the document from being used.
A rule has an id and exactly one of: when with then (a reaction), deny (a veto) or requireApproval (a gate).
Example
Document
schemaVersion
- Type: number
- Default:
1 - Required: no
- Description: Version of the document; any value other than
1is refused.
rules
- Type: list of rules
- Default: empty
- Required: yes
- Description: Rules, in order.
id
- Type: string
- Default: none
- Required: yes
- Description: Names the rule in logs and errors.
when
Every field that is set must match; an omitted field matches any value.
event
- Type: string
- Default: none
- Required: no, except that a rule with
everymust not have it - Description:
NodeStatusChanged,WorkflowStatusChanged,ControlOutcome,LogLine,EventsMissed,InputRequested,InputEscalated,InputAnswered,InputExpiredorInputCancelled.
status
- Type: string
- Default: none
- Required: no
- Description: Status of a status event, for example
FAILURE.
module
- Type: string
- Default: none
- Required: no
- Description: The node’s plugin type, for node events, for example
HTTP_REQUEST.
nodeId
- Type: string
- Default: none
- Required: no
- Description: A specific node, for node and log events.
workflowId
- Type: string
- Default: none
- Required: no
- Description: A specific workflow, for status events.
if
- Type: SpEL expression
- Default: none
- Required: no
- Description: Condition over the event’s fields (below). One that cannot be evaluated counts as not matching.
count
- Type: integer
- Default:
1 - Required: no
- Description: How many matching events trigger the rule.
withinSeconds
- Type: integer
- Default:
60 - Required: no
- Description: Window in which
countevents must occur, counted per execution.
every
- Type: duration text
- Default: none
- Required: no
- Description: Makes the rule timed: it runs on that period over the executions the supervisor owns. Forms
30s,5m,2h; at least one second. A timed rule needs acommandinthenand areason, takes noevent, and itsifcan readread.<STATUS>(the number of owned executions in that status; a status nobody has is0). It acts on its own, so the command must be in the supervisor’sinitiativelist. One tick looks at no more than 200 executions.
then
Exactly one of command, answer and escalate.
command
- Type: string
- Default: none
- Required: one of the three
- Description:
PauseWorkflow,ResumeWorkflow,StopWorkflow,PauseNode,ResumeNode,StopNode,RestartorRestartFromNode. Node commands address the node that triggered the rule; the command goes to the execution that produced the event.
mode
- Type:
DRAIN,CANCELorKILL - Default:
DRAIN - Required: no
- Description: For
StopWorkflow.
reason
- Type: string
- Default:
Stopped by rulefor a stop - Required: only for a timed rule
- Description: Recorded with a stop and shown in the audit.
immediate
- Type: boolean
- Default:
false - Required: no
- Description: For
StopNode: interrupt instead of draining.
from
- Type: string
- Default: the node that triggered the rule
- Required: no
- Description: For
RestartFromNode: a node id, ormetadata.<key>of the event.START, or a key the event lacks, restarts the whole run.
attempt counts the restarts the rules made (0 for a run nobody restarted), so "if": "attempt < 2" bounds a retry loop. The count is kept in memory for the newest 1000 restarted runs.
answer
- Type: object
- Default: none
- Required: one of the three
- Description: Answers the input request of an
InputRequestedorInputEscalatedevent. The rule must name one of those events, or none (then it matches only those two).
The server decides whether an answer counts: the supervisor needs
canAnswer: true and a maxRisk that reaches the request’s risk, and a HIGH request is answered by people only. The answer names the request version the rule saw and is refused if the request changed.
escalate
- Type: object
- Default: none
- Required: one of the three
- Description: Hands the input request up, on the same events as
answer.
deny
Refuses matching commands before they run.
requireApproval
Parks matching commands and raises an APPROVAL input request. A matching deny wins.
Example
Condition fields
A condition is a read-only SpEL expression over one map of fields: no method calls, no types, no assignment. Every field of the kind is present, withnull when it does not apply.
The
prompt and context of a request were written by the asking step, often an AI agent, and are redacted; a condition may compare them but their content is untrusted. context['key'] is null when the key is missing.
Presets
Complete rule documents, fromGET /api/supervisor-engines/rules/presets and list_supervisor_presets.
Where a rule document is read
Try a draft on a past run in dry run with
replay_rules, supervisors rules replay or POST /api/supervisors/{id}/engine/rules/replay.