Commit Graph
8 Commits
Author SHA1 Message Date
Stefan c694bfa904 feat(engine): pin the clock through options instead of the environment
The __ZEN_MOCK_UTC_TIME variable and the ZEN_EXPRESSION_CONFIG lane flag are
gone. Isolate takes with_now and with_lane, and the interpreted engine now
honours the now option in expressions, so tests pass the instant explicitly.
2026-11-21 14:42:04 +01:00
Stefan 83f1c29274 refactor(engine): drop the global compiled switch 2026-11-21 13:54:20 +01:00
stefan-gorules e3d32a210d feat: trace format lane (#573)
* feat(trace): trace format v1 with TraceCollector on the compiled engine

Adds trace format v1 to the compiled engine, recorded by explicit trace
recorders and written natively. The interpreted engine keeps the legacy
trace.

- EvaluationOptions.trace is a TraceFormat (off, v1, legacy). Legacy
  traces are produced directly from the same recording.
- zen_engine::trace exposes convert, restore and inspect for
  stored documents, with redaction and truncation markers.
- The trace header takes evaluatedAt, timezone and seed from the
  evaluation context, so an evaluation replays from its own trace.
- Batch and columnar evaluations record events as columns and write one
  document per row.
- Bindings accept the trace format (true, 'v1', 'legacy'); the Node
  binding ships TypeScript types for the v1 document.
- Golden, fixture and damaged-document tests cover byte identity with the
  legacy trace, restore, interop with the reference fixtures and
  malformed input.

* perf(trace): build columnar request rows once with precomputed paths

* perf(trace): write a node's edits from its written columns

* perf(trace): capture node columns instead of row values in the columnar plan

* perf(trace): reuse a node's rendered body for rows with the same rule and cell values

* perf(trace): size the batch trace buffer up front, key node bodies on typed column words, share request rows as the input

* perf(trace): read the request from input columns and build request rows only on demand

* perf(trace): key node bodies on per-column codes and precompute node heads and result labels

* perf(trace): keep first-hit table facts and their referenced fields as columns

* perf(trace): write per-row expression results in the batch writer

* perf(columnar): write result rows as JSON straight from output columns

* perf(trace): keep collect-policy rule hits as columns and reuse hit text

* perf(trace): pack loop results from columns and resolve result column accessors once per batch

* perf(trace): share row-wise node outputs with the trace when nothing can alias them

* perf(trace): pack lists without a string per distinct item

* perf(trace): write new lists from columns and decide references by where a list came from

* perf(trace): write wide list items from columns while the list has never been built

* perf(trace): read list cells once while rendering

* feat(trace): list table inputs once per node and key rule cells by column id

* feat(trace): name matched policy table rows by rule id

* feat(trace): store loop results as one column per key

* build: optimise test builds
2026-11-21 13:38:43 +01:00
stefan-gorules 9550b33429 feat: lane compiled engine (#555)
* 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
2026-11-03 17:25:56 +01:00
stefan-gorules fe43b4c1d7 perf: general performance improvements (#500)
* perf: general performance improvements

* remove unsafe usages, further improve perf

* perf: add table indexing
2026-08-04 11:12:37 +02:00
stefan-gorules 6c0ca51354 feat: policy engine (#450)
* feat: policy engine

* fix: cargo fmt

* fix: resolve issues with miri
2026-06-23 18:51:47 +02:00
stefan-gorules a03978fbe7 feat: add bigjs to function node; (#77)
* feat: add bigjs to function node;

* fix test

* fix tests

* fix fmt
2023-08-28 17:21:31 +02:00
stefan-gorules fb2fb2e43e chore: move unit tests to integration tests; add more test cases; (#33)
* chore: move unit tests to integration tests; add more test cases;

* fix fmt errors
2023-05-03 01:09:53 +02:00