mirror of
https://github.com/gorules/zen.git
synced 2026-12-04 00:06:41 +00:00
New engine for decisions and policies built on the lane VM: a compiled graph plan that evaluates batches column-wise (typed kernels where expressions allow, lane programs otherwise), a row runner for batch and single-row evaluation, and a compiled policy runtime with a columnar pass. - Decision::evaluate_columns / Workspace::evaluate_columns return one ColumnarOutput type; diagnostics live in zen_engine::diagnostics - rows the plan cannot finish are deferred to the row runner and never re-run nodes; sub-decisions run inside the parent plan; date input schemas stay on the plan - DecisionEngine keeps compiled graphs, sub-decisions and policies per key while the loader returns the same content - failed $dictionary imports are retried, not cached - the old engine stays available behind the driver feature for comparisons; there is no fallback to it - benchmark harness (tests/bench_matrix.rs) comparing old and new across the spec corpus, fixtures and policies
52 lines
1.2 KiB
Rust
52 lines
1.2 KiB
Rust
pub(crate) mod graph;
|
|
pub(super) mod policy;
|
|
mod table;
|
|
|
|
pub(crate) use table::RowTable;
|
|
use zen_expression::Variable;
|
|
|
|
pub(crate) struct Failure;
|
|
|
|
impl Failure {
|
|
pub const EXPRESSION: &'static str = "Failed to evaluate expression";
|
|
|
|
pub fn expression(source: &str) -> String {
|
|
format!(r#"{}: "{source}""#, Self::EXPRESSION)
|
|
}
|
|
|
|
pub fn input(error: impl std::fmt::Display) -> String {
|
|
format!("{}: {error}", Self::EXPRESSION)
|
|
}
|
|
}
|
|
|
|
pub(crate) struct Attributes;
|
|
|
|
impl Attributes {
|
|
pub fn item(pass_through: bool, item: &Variable, output: Variable) -> Variable {
|
|
match pass_through {
|
|
true => item.clone().merge_clone(&output),
|
|
false => output,
|
|
}
|
|
}
|
|
|
|
pub fn finish(
|
|
output_path: Option<&str>,
|
|
pass_through: bool,
|
|
input: &Variable,
|
|
output: Variable,
|
|
) -> Variable {
|
|
let output = match output_path {
|
|
Some(path) => {
|
|
let wrapped = Variable::empty_object();
|
|
wrapped.dot_insert(path, output);
|
|
wrapped
|
|
}
|
|
None => output,
|
|
};
|
|
match pass_through {
|
|
true => input.clone().merge_clone(&output),
|
|
false => output,
|
|
}
|
|
}
|
|
}
|