Skip to main content

execute_chain

Function execute_chain 

Source
pub fn execute_chain(
    rules: &[RuleDefinition],
    initial_context_json: &str,
) -> RuleEngineResult<(Value, Value)>
Expand description

Execute a sequence of rules where the output of each rule is merged into the context for the next rule (output → "decision" key injection).

The final context — with "decision" set to the last rule’s output — is returned together with the last result value. This enables decision pipelines such as:

  1. score-rule → output "approve" → injected as {"decision": "approve"}
  2. limit-rule reads {"var": "decision"} and {"var": "amount"} → final answer

Returns an error if any rule in the chain fails.