# `Runic.Workflow.Condition`
[🔗](https://github.com/zblanco/runic/blob/main/lib/workflow/condition.ex#L1)

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)
    end

The 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.

# `meta_ref`

```elixir
@type meta_ref() :: %{
  kind: atom(),
  target: atom() | integer() | {atom(), atom()},
  field_path: [atom()],
  context_key: atom()
}
```

# `t`

```elixir
@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
}
```

# `check`

# `check_with_meta_context`

```elixir
@spec check_with_meta_context(t(), term(), map()) :: boolean()
```

Checks a condition with meta context available.

When a condition has meta references, its work function is arity 2,
receiving `(input, meta_context)`.

# `has_meta_refs?`

```elixir
@spec has_meta_refs?(t()) :: boolean()
```

Returns whether this condition has meta references that need to be resolved
during the prepare phase.

# `new`

# `new`

# `try_to_run_work`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
