Skip to main content

evaluate_rule

Function evaluate_rule 

Source
pub fn evaluate_rule(
    rule: &Rule,
    relations: &RefRelationStore,
    order: &dyn VariableOrder,
) -> Result<Vec<Vec<RefValue>>, RefEvalError>
Expand description

Evaluate rule against relations using order for variable binding. Returns the result rows (one inner Vec<RefValue> per row, with one element per term in the rule head) sorted lexicographically and deduplicated.

§Eligibility gating

The rule is structurally analyzed via super::analyze before any evaluation work; if it is Eligibility::Ineligible the function returns RefEvalError::Ineligible carrying the boundary list. Callers wanting type-aware gating should run super::analyze_typed in addition and translate the verdict before calling this function — the evaluator itself does not take a type map (the supplied RefRelationStore is the authoritative type source for the values it operates on).

§Determinism contract

Same (rule, relations, order) → same output. Output rows are sorted (lexicographic over RefValue’s Ord impl) and deduplicated. The variable order affects work done internally but NOT the result set (locked by a test).