Condition nodes are predicate checks that gate flow in a workflow.
A Condition receives a fact and evaluates to true/false. If true, downstream nodes become runnable; if false, the fact is consumed without propagation.
Meta Expression Support
Conditions can reference workflow state through meta expressions like state_of(:component).
When a Condition has meta references, the :meta_refs field is populated during
macro compilation, and :meta_ref edges are drawn during Component.connect/3.
During the prepare phase, these edges are traversed to populate meta_context in
the CausalContext, making the referenced state available during execution.
Runtime Context
Conditions can also reference external runtime values via context/1 expressions,
commonly used in rule where clauses:
Runic.rule name: :gated do
given(val: v)
where(v > context(:threshold))
then(fn %{val: v} -> {:ok, v} end)
endThe condition's work function is rewritten to arity-2 when context/1 is detected,
and values are resolved from the workflow's run_context during the prepare phase.
Summary
Functions
Checks a condition with meta context available.
Returns whether this condition has meta references that need to be resolved during the prepare phase.
Types
@type t() :: %Runic.Workflow.Condition{ arity: non_neg_integer(), closure: Runic.Closure.t() | nil, hash: integer() | nil, meta_refs: [meta_ref()], name: String.t() | atom() | nil, work: function(), work_hash: integer() | nil }
Functions
Checks a condition with meta context available.
When a condition has meta references, its work function is arity 2,
receiving (input, meta_context).
Returns whether this condition has meta references that need to be resolved during the prepare phase.