polix.evaluator

Policy evaluation engine.

Evaluates AST nodes against documents and contexts, transforming parsed policies into concrete values. Uses the Either monad for error handling and supports pluggable evaluators via the Evaluator protocol.

default-eval

multimethod

Default evaluation multimethod dispatching on AST node type.

Does not recurse - recursion is handled by the evaluate function. Takes a node (with children already evaluated to thunks), a doc/Document, and a context map.

Returns Either[error-map, value].

default-evaluator

The default Evaluator instance.

evaluate

(evaluate ast document)(evaluate ast document evaluator)(evaluate ast document evaluator context)

Evaluates an AST node with a doc/Document and optional context.

Uses postwalk to traverse the AST, converting each node’s children into lazy thunks that return evaluated values. Does not recurse in evaluators.

Takes: - ast - The AST node to evaluate (typically from a polix.policy/Policy) - document - The doc/Document to evaluate against - evaluator - Optional Evaluator (defaults to default-evaluator) - context - Optional context map with :uri, :environment, etc.

Returns Either[error-map, value] - Right with result on success, Left with error on failure.

Evaluator

protocol

Protocol for evaluating AST nodes.

Evaluators receive an AST node, a doc/Document, and optional context, and return an Either[error, value].

members

eval-node

(eval-node this node document context)

Evaluates an AST node with the given document and context.

Returns Either[error-map, value] - Right with result on success, Left with error on failure.