Skip to main content

Module condition

Module condition 

Source
Expand description

Pure, total evaluator for Condition-node branch expressions.

§Expression grammar

Only three forms are authored in practice (grounding §1c):

expr    := path                        # truthiness
         | path "==" literal           # equality
         | path "!=" literal           # inequality
path    := "state" ("." ident)+        # always rooted at `state`, dotted segments
literal := '"' … '"'                   # double-quoted JSON string
         | "true" | "false" | "null"   # JSON keywords (bare, lowercase)
         | number                       # JSON number

§Truthiness rule

For the bare-path form a value is falsy iff it is:

  • absent (path does not resolve),
  • JSON null,
  • false,
  • the number 0 (or 0.0),
  • the empty string "",
  • an empty array [], or
  • an empty object {}.

Everything else is truthy. This mirrors JS/Python truthiness and matches the budget code that sets __cost_exceeded__ as a bool.

§Total / never-panics contract

A malformed or unsupported expression always returns false — no panic. Unrecognised forms emit a tracing::warn! to aid debugging.

§Path resolution

The path after state. is split on . and each segment descends into the JSON object (or an array by zero-based numeric index when the segment is all digits). A missing or non-traversable segment resolves to absent (treated as null for comparisons and as falsy for truthiness).

Functions§

eval_condition
Evaluate a Condition-node branch expression against committed workflow state.