Documentation
¶
Overview ¶
Package rules compiles and evaluates the boolean expressions used by choice nodes. Expressions are written in expr-lang and evaluated against the invocation context, exposed as three variables: `input` (the start payload), `results` (each visited node's output, keyed by node id) and `signals` (received signal payloads, keyed by signal name).
when: "results.triage.risk_score > 80" when: "input.tier == 'pro' && signals.approval.granted"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is a compiled choice expression.
func Compile ¶
Compile compiles a boolean expression that may reference `input`, `results`, `signals`, `branches` and `last_node`.
func (*Program) Match ¶
func (p *Program) Match(contextDoc json.RawMessage) (bool, error)
Match evaluates the program against the assembled context document ({"input": …, "results": {…}, "signals": {…}}). A false result and a non-nil error are returned when evaluation fails (e.g. a referenced field is missing); callers typically treat that as "no match" and fall through to the default rule.
func (*Program) MatchContext ¶ added in v0.1.0
MatchContext is Match using ctx for pre/post evaluation cancellation checks. Choice expressions are intentionally compiled to straight-line predicates and run with an explicit VM memory budget; expr does not provide a preemptive VM deadline, so compile-time restrictions are the primary CPU bound.