mirror of
https://github.com/gorules/zen.git
synced 2026-11-28 16:06:26 +00:00
* feat(engine): compiled engine for columnar graphs and policies 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 * refactor(engine): isolate compiled engine from release node and graph code Release code outside core/engine/src/compiled is restored to release/2.2. The compiled engine keeps its own copy of the node, graph and JS function implementation under compiled/host and reaches release only through types and pure helpers. Release files gain only additive hooks: the ZEN_CONFIG.compiled runtime flag (off by default), per-instance interpreted()/compiled_engine() on Decision, DecisionEngine and PolicyWorkspace, and the batch and columnar entry points. - the driver feature and the modified old engine are removed; tests compare the compiled engine against the unmodified release engine - compiled-only behaviour (#7 empty collect columns, #16 collect order, BC1 thrown-object message) is allowlisted in the comparisons - #14 (policy whitespace cells) is dropped: release analysis rejects it - goldens re-recorded from the release engine - spec 42 nested-chain case lowered to depth 200: the release engine's JS conversion overflows a 2 MB debug thread at depth 500 * fix(engine): keep interpreted engines interpreted and tighten engine comparisons - DecisionEngine::interpreted() now holds while ZEN_CONFIG.compiled is on: decisions it creates (get_decision, create_decision, evaluation) carry its engine, and its release path runs in an interpreting scope so the Workspace built by the lazy policy path stays interpreted too - policy batches (DecisionEngine and PolicyWorkspace) deep-copy their inputs like graph batches, so callers' contexts are no longer written into - release test files run on the release engine again: the compiled-by-default ctor moved out of tests/support into tests/compiled_default, included only by the compiled test suites - spec `engines` notes are structured ({modes, intended, why}); unlisted modes are still compared with the reference, intended modes are checked against the spec, and open differences fail once they match the reference again. Stale notes found this way were removed; golden skips are per mode, and generated rows no longer inherit the first case's note * fix(engine): platform-independent spec suite ids and rustfmt - spec suite file paths are joined with '/', so suite ids and golden keys match on Windows (backslash paths missed every recorded golden) - engine spec json5 files are checked out with LF line endings - cargo fmt
229 lines
3.3 KiB
JSON
229 lines
3.3 KiB
JSON
{
|
|
"nodes": [
|
|
{
|
|
"id": "in",
|
|
"type": "inputNode",
|
|
"position": {
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"name": "Request",
|
|
"content": {
|
|
"schema": "{\"type\": \"object\", \"required\": [\"customer\"], \"properties\": {\"customer\": {\"type\": \"object\", \"required\": [\"age\", \"tier\"], \"additionalProperties\": false, \"properties\": {\"age\": {\"type\": \"integer\"}, \"tier\": {\"type\": \"string\", \"enum\": [\"gold\", \"silver\"]}, \"name\": {\"type\": \"string\"}, \"active\": {\"type\": \"boolean\"}, \"tags\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}, \"address\": {\"type\": \"object\", \"properties\": {\"zip\": {\"type\": \"string\"}, \"floor\": {\"type\": \"number\"}}}}}, \"order\": {\"type\": \"object\", \"properties\": {\"total\": {\"type\": \"number\"}}}, \"note\": {\"title\": \"free\"}}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "e1",
|
|
"type": "expressionNode",
|
|
"position": {
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"name": "Calc",
|
|
"content": {
|
|
"passThrough": true,
|
|
"expressions": [
|
|
{
|
|
"id": "a",
|
|
"key": "doubled",
|
|
"value": "customer.age * 2"
|
|
},
|
|
{
|
|
"id": "b",
|
|
"key": "vip",
|
|
"value": "customer.tier == 'gold'"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"id": "out",
|
|
"type": "outputNode",
|
|
"position": {
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"name": "Response"
|
|
}
|
|
],
|
|
"edges": [
|
|
{
|
|
"id": "x0",
|
|
"sourceId": "in",
|
|
"targetId": "e1",
|
|
"type": "edge"
|
|
},
|
|
{
|
|
"id": "x1",
|
|
"sourceId": "e1",
|
|
"targetId": "out",
|
|
"type": "edge"
|
|
}
|
|
],
|
|
"tests": [
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold",
|
|
"name": "A",
|
|
"active": true,
|
|
"tags": [
|
|
"x",
|
|
"y"
|
|
],
|
|
"address": {
|
|
"zip": "1",
|
|
"floor": 2.5
|
|
}
|
|
},
|
|
"order": {
|
|
"total": 10
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "silver"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30.5,
|
|
"tier": "gold"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "bronze"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"tier": "gold"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold",
|
|
"extra": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": "30",
|
|
"tier": "gold"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold",
|
|
"active": "yes"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold",
|
|
"tags": [
|
|
"x",
|
|
1
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold",
|
|
"address": {
|
|
"zip": 5
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold"
|
|
},
|
|
"order": {
|
|
"total": "x"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 30,
|
|
"tier": "gold"
|
|
},
|
|
"note": {
|
|
"anything": [
|
|
1,
|
|
2
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"order": {
|
|
"total": 1
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": null
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": null,
|
|
"tier": "gold"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"input": {
|
|
"customer": {
|
|
"age": 4.0,
|
|
"tier": "gold"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
} |