Commit Graph
647 Commits
Author SHA1 Message Date
stefan-gorules c26c3565ac perf: typed columnar (#581)
* perf(engine): run graph expressions and tables typed on the columnar path

Lower most expression and table shapes found in graphs to typed programs:
fallible membership, mixed-type equality, computed table fields, collect
tables and first-hit collect columns, number() and type(), objects and
arrays produced by expressions, index access, split text, member chains
on computed values, list literals written by tables, and fields of
unknown shape or object lists written by earlier nodes.

Fix the typed results that differed from version 1 along the way:
errors kept through contains, filters, bool() and `?? []`, missing text
against missing dates, fractional division, set items written earlier in
the node, oversized list indexes.

* perf(engine): choose typed plans without timing and run them per distinct key

Replace timing-based path choice with static rules for graphs and
policies, so the same input always takes the same path. Run typed units
once per distinct key with constant key parts left out, re-run one row
per key when a deduplicated unit fails, fall back to the lane when a
64-row sample fails typed, and stop key sampling early on distinct data.

Add faster kernels for numeric ranges, text classes, mixed-scale
comparisons, bool folds, rounding, ASCII trim, legacy date text, wide
decimals between nodes and table choice masks.

* perf(engine): keep policy rows on the columnar path

Validate date columns, dictionary properties and nested lists by column,
delegate a refused block for its own rows instead of sharing every row,
keep blocks whose lazy reads have no writers in one step, run declared
date inputs and strict tables with empty output cells typed, and resolve
references to a pool by columns.

Rows whose delegated block fails are re-run on the row engine, and a
resolved reference stays missing where its key is missing. Rows are
shared again by a static rule when most member blocks would be
delegated.

* feat(expression): borrow Arrow Decimal128 and temporal buffers as columns

Add Values::Decimal128 and Values::Temporal (date32, date64, timestamp,
time32, time64) so Arrow buffers can be handed over without copying.
Values behave exactly like the same data given as decimals or ISO text.

* perf(engine): convert float and date columns once

Convert f64 columns to decimals without printing them, through the new
Values::Float64. Read declared policy dates once per distinct text with
the version 2 parser, type declared date fields of list items, parse
timestamps without a zone on the fast path, and render foreign columns
only when a graph reads them.

* perf(engine): validate and convert policy lists by field

Convert declared dates of entity lists once per field and only when
first read, validate list columns field by field, keep policy columns
when every re-run row fails, and run member blocks that read their own
or another list typed.

* perf(engine): run policy relationships and date methods typed

Run blocks on a single relationship as root blocks under the
relationship's path, keeping version 1's required-input errors for
every goal set. Resolve lists of references onto the pool's columns.
Run date methods with fixed units as typed kernels and share one parse
per date text between validation and typed programs.

* perf(engine): run policy tables typed and cut per-row validation

Run strict collect tables and collect tables with first-hit outputs as
typed units, read optional fields that mix values with nulls as typed
columns, keep selects whose cells read already demanded fields in one
segment, lower powers with computed integer exponents, run membership
in another list of the row typed, and keep lifted declared dates typed.

Validate enums and primitive arrays without the row validator, shred
lists without copying their items, and remember settled selects and
table typability per plan.

* perf(engine): build objects and read validity without converting columns

Build objects from dictionary columns with one shared value per code
and read the validity of float columns without converting them, which
removes the regressions float columns had introduced on graphs that
write coded text or never read a float input.

* style(engine): format with cargo fmt
2026-11-27 10:51:31 +01:00
stefan-gorules 36cd8382ad Merge pull request #579 from gorules/chore/sync-master
chore: sync master
2026-11-23 20:05:15 +01:00
Stefan 38d11a7934 chore: merge master into release/2.2 2026-11-23 19:15:55 +01:00
stefan-gorules 2a65cbde3d fix(engine): accept the string and reference trace modes again (#578) 2026-11-23 18:53:49 +01:00
stefan-gorules 0083a66418 fix: v2 equality gaps (#577)
* fix(expression): copy values that read the node's own output on the compiled path

* fix(expression): match a date against every text cell naming it

* test(engine): cover the fixed version differences on every evaluation path

* fix(engine): keep the table index and compiled plan off tables whose cells read the last tested value

* fix(engine): give batch rows the node values and replaced fields a single row sees

* test(engine): cover the batch and table differences on every evaluation path

* fix(engine): read declared date inputs in the evaluation's time zone

* fix(engine): keep script dates right beyond 2099, at extreme years and for object arguments

* fix(engine): name script modules alike on every traced batch row

* fix(expression): keep typed batch results and errors equal to the row engine

* fix(engine): keep loop items, traced table fields and batch node values equal to version 1

* fix(engine): record table references in batch traces when a rule has a description

* fix(nodejs): convert decision results, policy traces and handler values without aborting on large integers

* fix(nodejs): reject fractional engine versions

* test(engine): cover null leaves in multi-row batches

* fix(engine): keep a null written under a missing or scalar parent in multi-row batches

A layer over an upstream patched shape treated every null leaf as absent,
so obj.a = null over a row without obj (or with obj = 1) never created
{obj: {a: null}} for downstream reads, and an all-null column was dropped
outright. A dotted null leaf now stays present on the rows whose parent
is not an object before the write, matching version 1's merge.

* fix(engine): merge a parent reached by duplicate edges once in multi-row batches

Version 1 merges a node's output onto itself as a no-op when two edges
from the same node meet at a target, so nested nulls survive. The batch
path gathered the parent twice as separate copies and re-applied the
patch, deleting those nulls and letting a dangling node's value win over
a null written on the twice-connected branch. Consecutive duplicate
parents now merge once.

* fix(engine): let a later table output replace an earlier one under it in batches

A rule writing res, res.k and then res again keeps only the last res in
version 1, because the final write replaces the object that res.k went
into. The compiled table folded the duplicate paths into one slot per
path and re-inserted res.k on top. Non-collect outputs that a later
non-collect output of the same rule replaces are now left out.

* fix(engine): share common ancestry when batch rows merge related parents

Version 1 merges parent outputs copy-on-write: a pass-through node shares
every subtree it did not change with its input, and merging two values
that share an object skips it. So a nested null written once and reached
through two branches survives the join, and an input null survives a
pass-through that changed nothing. The batch path rebuilt each parent's
rows separately, lost that sharing and deleted those nulls. When parents
share a base or leading layers and the merged parent can hold a null,
the join now derives their rows from the shared prefix with the same
copy-on-write merge; other joins stay columnar. Traced batch rows derive
pass-through outputs from their merged input the same way.

* fix(engine): keep one materialization per node so batch joins see shared rows

Gathering a node's rows for each consumer, and clearing a table's
unmatched rows before a pass-through, materialized the same node output
more than once, so a pass-through built from one copy no longer shared
objects with the copy merged at the join, and the version 1 rule that a
shared object merges as a no-op could not apply. Gathered copies of a
node on the same rows now share one materialization, a cleared copy
reuses its source's rows, layers keep their identity when picked to a
row subset, and input rows match by object identity. The final output
still materializes its own copy, since cleaning it mutates in place.

* test(engine): cover policy columns for a tested value that fails

* fix(engine): return column traces in the legacy format when it is requested

* fix(engine): return an error instead of building a cyclic value when an expression entry writes an object into itself on version 2

An entry such as `a.c = obj` after `a = obj` wrote the object into itself,
and merging, cloning, comparing, tracing or serialising the result then
overflowed the stack. The hosted expression node now checks, before each
write, whether the value reaches the object it is written into and fails the
row with "cyclic value at <key>". Compiled nodes that write a possibly
container value under a key an earlier entry set are routed through the same
row evaluation, so every path (first call, repeated, compiled, batch,
columnar, traced) reports the error for that row only.

* test(engine): cover a script returning a cyclic object on version 2

Ignored until the version 2 JS runtime rejects cyclic results; it hangs today.

* fix(engine): match version 1 in script globals and dates, stop idle or cyclic scripts, and load date support lazily

* fix(engine): leave version 1 table indexes as released and give version 2 its own

* fix(engine): show the tested value under its key when a table reads the whole root

* fix(engine): copy values read through $ and leave written-back keys alone, as version 1 merges them

* perf(engine): keep tables whose outputs read the tested value on the compiled plan

* test(engine): record pinned Date results across zones, DST gaps and far years

* perf(engine): pin Date in Rust instead of a JavaScript shim on version 2

Function nodes on version 2 replaced Date with a JavaScript module whose
local getters, setters and string methods rebuilt every field through
native calls and allocations, and whose lazy half cost about 45 us to
load on the first Date use of each evaluation.

The pinned constructor, Date.now, Date.parse, Math.random and the zone
dependent prototype methods are now callable Rust classes built with the
safe rquickjs API. They read the time value through the native getTime,
compute fields and offsets with chrono-tz in Rust (fixed offset zones
skip the lookup, the last instant's fields are cached per evaluation)
and keep QuickJS's Date for storage and everything zone independent.
The constructor is a bound function so calls and constructions are
told apart exactly. The prototype methods are still installed on the
first construction or parse, now in about 6 us.

Results are unchanged: recorded per-zone results, version parity and
the isolation spec pass as before.

* fix(engine): keep the machine time zone out of parsed script dates
2026-11-23 17:49:17 +01:00
stefan-gorules d852f71e56 refactor: run handle (#575)
* refactor(engine): carry the depth limit on the evaluation handle

* refactor(engine): name the per-row evaluation handles

* refactor(engine): pass one invocation through the compiled entry points

* refactor(engine): track nesting depth on the evaluation handle

* refactor(engine): drop argument-count allowances that no longer apply

* refactor(engine): pass context and trace probe as one lane value

* refactor(engine): hand the invocation to the policy entry

* refactor(engine): read function timeout and nodes-in-context once per evaluation

* refactor(expression): pass the evaluation context to comparison and table-cell helpers
2026-11-23 12:40:58 +01:00
stefan-gorules 3a25f4f5c3 feat: engine version (#574)
* feat(engine): select the engine with a version option

* ci: run the two feature sets as parallel jobs

* refactor(engine): drop the global compiled switch

* 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.

* test(engine): count trace paths per thread and drop the trace test lock

* ci: run tests with nextest

* test(engine): share golden trace outcomes between variants
2026-11-21 20:09:14 +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
GoRules Team 62cd159858 chore(release): publish (#571) python-v2.1.8 zen-types-v2.1.8 zen-tmpl-v2.1.8 zen-expression-v2.1.8 go-v2.1.8 nodejs-v2.1.12 zen-macros-v2.1.8 zen-engine-v2.1.8 uniffi-v2.1.9 2026-11-19 18:09:09 +01:00
stefan-gorules 1944ebe01f fix: table analysis memory (#570)
* fix(engine): keep decision table analysis memory and time in proportion to the table

Schema queries no longer run table verification; graph table checks are deferred to diagnostics.

Gap search and unreachable-rule cover run on per-dimension bitsets when the table is small enough to index densely, and on the set-based path otherwise. Missing cases are merged on interned ids and rendered lazily.

Compression works on borrowed rows and interned cell ids, assigned once per round. Small string sets are held inline or as a sorted list instead of a tree.

Findings are unchanged: the previous implementations stay as test-only references and are compared on generated tables, and tests/table_scaling.rs bounds peak memory with a counting allocator.

* fix(nodejs): accept bytes and JSON text in Workspace setDocument, setPolicy and enhanceGraphTrace

Documents with more than one million JSON values were rejected by the object conversion limit, which a two-column decision table reaches at 250,000 rows. Buffers and strings are parsed directly, and objects are converted without that limit.

* ci: pin Rust to 1.99.0

Rust 1.100 passes one -L dependency directory per dependency, which pushes the rustc command for zen-engine past the Windows command-line limit when sccache spawns it (os error 206). Every workflow that installed stable now installs 1.99.0; miri stays on nightly.

* ci: pin the UniFFI native build to Rust 1.99.0

actions-rust-cross installs its own toolchain and defaults to stable, so the Windows and macOS UniFFI builds were still on 1.100.
2026-11-19 16:06:29 +01:00
stefan-gorules cd6a3f3adb feat: evaluation context (#568)
* feat(engine): explicit evaluation context with now, timezone and seed

The compiled engine evaluates against an explicit EvaluationContext
instead of the host clock, host zone and an unseeded random source.

- zen_expression::context: EvaluationContext holds now (read once on
  first use, shared by every row of a batch), the time zone (supplied
  or the host zone cached per process), the locale, the seed (drawn on
  the first draw) and per-row and per-item random streams created only
  when a row or item draws. rows/picked/items/item/at narrow it with an
  Rc clone; at and item allocate nothing. RowContext is the borrowed
  per-row view builtins, kernels and function hosts read.
- the context is passed explicitly through the lane VM (LaneRunner,
  Session, kernels, cells, builtins), typed Program::run, graph state,
  rows, loops, sub-decisions, hosted rows, the columnar plan, policies
  and their plans. There are no thread-locals for context data.
- rand draws once per lane, row and item from the row's stream, so
  map(xs, rand(100)) draws per item. rand is never pure, folded,
  memoised or compiled into kernels as a constant; Math.random is no
  longer pure in the function purity analysis.
- function hosts (v1 and v2) install Date, Math.random and a minimal
  Intl.DateTimeFormat once per runtime and read a per-call slot:
  Date.now, new Date, local-time getters and setters, toString,
  toLocale*String and getTimezoneOffset use the context's now, zone and
  locale.
- EvaluationOptions and EvaluationSerializedOptions gain now, timezone,
  seed and locale (en-US by default). Workspace gains evaluate_pinned,
  evaluate_batch_pinned and evaluate_columns_pinned. In a batch, row i
  draws with row_seed(seed, i) and replays alone with that seed.
- bindings: Node and Python accept and validate now, timezone, seed and
  locale; C and uniffi pass them through and ignore invalid values.
- d('...') is folded at compile time only for texts with an explicit
  zone; an invalid __ZEN_MOCK_UTC_TIME is ignored by the context.
- the interpreted engine and the stack VM are unchanged and ignore the
  new options.

* refactor(engine): name evaluation context parameters ctx and context

* feat(engine): derive random draws from their location

A draw is now a pure function of (seed, stream, scope, field, site, n)
instead of a running counter per stream, so reordering, short-circuiting,
dead-code elimination or an extra rand elsewhere in a decision no longer
shifts other draws.

- site: occurrence index of rand( in source order, numbered at compile
  time and carried on the lane call op
- field: stable label from node/rule/column/key/statement/block ids,
  baked into multi-root programs at compile time or set on the context
  by per-source (session) paths
- scope: chained per sub-decision call (caller node + key) and per
  function node; JS Math.random uses a fixed site in that scope
- n: counter per (stream, address) for repeated evaluation only

Tables with draws run on the exact row path; fused cells and fused rules
refuse draws; object-literal expansion is skipped for drawing sources.

* refactor(expression): own the rand integer mapping

Map a draw to 0..=upper with Lemire multiply-shift and rejection, taking
further words from the same address on retry, so a dependency update can
never change rand(n) for a given seed. A negative upper bound now returns
"Invalid upper range" on both VMs instead of panicking, and the unseeded
root seed comes from a hashed counter, which drops fastrand.

* test(engine): keep evaluation context tests independent under cargo test

cargo test runs a crate's tests as threads of one process, so tests that
share process state raced:

- pinned.rs switched the global ZEN_CONFIG.compiled on and off; each
  decision now picks its engine with compiled_engine() / interpreted().
- clock_reads() counted reads from every thread; it now counts the
  current thread only.
- typed exact tests relied on __ZEN_MOCK_UTC_TIME, which is cached on the
  first clock read by any test; they now pin now in the context.

* ci: pin Rust 1.99 for the Windows Node and UniFFI builds

Rust 1.100 makes Cargo's new build-dir layout permanent: every
dependency gets its own directory and its own -L dependency= flag.
For zen-engine with --target x86_64-pc-windows-msvc the rustc command
line passes Windows' 32,767-character limit, and sccache fails to spawn
rustc with os error 206. Cargo itself falls back to an argument file,
but sccache does not.

Other matrix entries stay on stable. Remove the pin once sccache
handles long command lines.

* refactor(engine): remove locale from the evaluation context

The locale option did not make evaluations more reproducible: QuickJS has
no ICU, so function nodes never picked up a host locale. It only added
approximate locale-aware date formatting from a hand-written table, as new
public API in every binding.

Function nodes keep the time zone of the context. toLocaleString,
toLocaleDateString and toLocaleTimeString return QuickJS's fixed format in
that zone and ignore a locale argument, as before. Intl is reduced to
DateTimeFormat().resolvedOptions(), which reports the time zone.

Drops the icu_locale_core dependency.

* test(engine): compare interpreted draws with the pinned ones

The interpreted engine's Math.random is QuickJS's own, seeded from the
clock in microseconds when a context is created. On Windows the clock is
coarser, so two evaluations in a row can get the same seed and the same
numbers. Assert instead that the interpreted engine does not return the
compiled engine's draws for the same seed.
2026-11-17 17:37:10 +01:00
GoRules Team 9c374e1681 chore(release): publish (#566) uniffi-v2.1.8 nodejs-v2.1.11 2026-11-11 23:55:08 +01:00
stefan-gorules d07a610eb3 fix(nodejs): stop committing the generated index.js loader (#567) 2026-11-11 18:55:38 +01:00
stefan-gorules 339bd46e6e fix(nodejs): publish the generated index.js so the version check matches the release (#565) 2026-11-11 18:16:55 +01:00
stefan-gorules c318119c1f feat(uniffi): add linux musl builds for Java, Kotlin and C# (#564) 2026-11-11 18:13:43 +01:00
GoRules Team 3524142505 chore(release): publish (#557) python-v2.1.7 zen-engine-v2.1.7 zen-tmpl-v2.1.7 zen-types-v2.1.7 zen-expression-v2.1.7 go-v2.1.7 uniffi-v2.1.7 nodejs-v2.1.10 zen-macros-v2.1.7 2026-11-10 10:20:26 +01:00
stefan-gorules 99c3511a21 fix(engine): upgrade zip to version 9 and reject cloaked archives (#556) 2026-11-09 17:55:13 +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 19cf437059 Merge branch 'master' into release/2.2 2026-10-28 11:43:01 +01:00
stefan-gorules 4a378bafc4 feat(expression): lane VM and typed-mask engine for batch and columna evaluation (#553)
* feat(expression): lane VM and typed-mask engine for batch and columnar evaluation

Adds a register-based lane VM (core/expression/src/lane) and a typed-mask
engine (core/expression/src/typed) that evaluate ZEN expressions over
batches and columns, matching the stack VM's results. zen-types gains
shape-backed objects and dot-path helpers; existing public APIs only grow.

The lane VM has no expression size limit: deep and wide expressions are
compiled and run with the same stack growth the parser uses.

ZEN_EXPRESSION_CONFIG.lane (off by default) switches Isolate::run_standard
and run_unary to the lane VM at runtime. Lane internals and the typed
module are doc(hidden); the documented entry points are LaneProgram,
LaneRunner, Session, Columns and Output.

Includes an executable specification of the expression language
(core/expression/tests/spec, 28,852 cases) with differential tests that
run every lane path against the stack VM.

zen-expression and zen-types now declare rust-version 1.88.

* refactor(types): remove the shape transition cap

Shapes are freed when nothing uses them, so the 4,096-children cap per
shape no longer bounds memory. Shape::with, Shape::of and Shape::without
now always return a shape; objects only switch to a hash map past
SPILL_AT keys, as on master.

* fix(expression): debug-profile stack safety and Windows test build

CI runs tests in the debug profile, where frames are larger and tail
recursion is not optimised. Recursive lane, typed and parser helpers now
grow the stack like the rest (Const::number, the kernel builder, typed
lowering and lookup, lane compile helpers, Node::member_key).

The parser's closure depth counter is u32 instead of u8, so 256 nested
closures no longer wrap. median([]) and empty templates no longer
overflow in debug builds; release results are unchanged.

The deep/wide test runs on a 256 KiB stack so unprotected recursion
fails quickly in any profile. The conformance helper compares with
as_str(), which is unambiguous on Windows.

* fix(expression): stack checks in the lane executor, LF test data on Windows

In x86-64 debug builds Executor::cold has a ~93 KB frame, so nested
closures (execute -> cold -> body) could use more stack between two
checks than the stack-growth margin and overflow. execute and cold now
check the stack themselves; both run per instruction batch, not per row.

The expression test data is checked out with LF on every platform.
Windows runners converted it to CRLF, which broke multi-line spec cases.
2026-10-28 11:39:54 +01:00
stefan-gorules ec108e8069 ci: on-demand beta releases from release/* branches (#554) 2026-10-27 18:31:54 +01:00
GoRules Team 2e152f3f6e chore(release): publish (#552) zen-expression-v2.1.6 python-v2.1.6 zen-tmpl-v2.1.6 zen-macros-v2.1.6 go-v2.1.6 nodejs-v2.1.9 uniffi-v2.1.6 zen-engine-v2.1.6 zen-types-v2.1.6 2026-10-21 17:48:01 +02:00
Ivan Miletic f2aa773c72 fix(engine): drop rows shadowed by an earlier row when compressing (#551) 2026-10-21 17:05:34 +02:00
GoRules Team 25624e821a chore(release): publish (#550) go-v2.1.5 zen-engine-v2.1.5 python-v2.1.5 uniffi-v2.1.5 zen-expression-v2.1.5 zen-types-v2.1.5 zen-macros-v2.1.5 nodejs-v2.1.8 zen-tmpl-v2.1.5 2026-10-20 19:23:43 +02:00
Ivan Miletic b764040ecf fix(engine): bound table gap analysis memory, analyse expression columns (#549)
* fix(engine): bound table gap analysis memory, analyse expression columns

Missing-case detection built the full atom/row partition for every column
before charging the work budget. Nested ranges (`> 1`, `> 2`, ...) make that
partition quadratic, so large tables (tens of thousands of rows) allocated
gigabytes before giving up, exhausting the 1GB WASM memory. The partition
size is now counted first and the budget checked before building it; results
are unchanged (50k rows: ~10GB/28s -> ~650MB/1s natively).

Columns without a field whose filled cells are all conditions on one field
(`age > 50`, `age > 30`) are now analysed like field columns on that field:
duplicates, unreachable rows, missing cases and compression. Compressed and
missing-case cells are written back as full expressions (`age > 30`).
Columns mixing fields or using non-analysable expressions stay opaque.

* chore(engine): remove comments from table analysis changes
2026-10-20 18:50:50 +02:00
GoRules Team c8a7d89a6b chore(release): publish (#548) nodejs-v2.1.7 2026-10-14 00:55:23 +02:00
stefan-gorules 96af373b62 fix(nodejs): accept ZenDecisionContent returned from the loader (#547)
napi 3.14 decodes a class reference only inside a native borrow scope, which a resolved loader promise does not have, so every loader returning ZenDecisionContent failed with "Value is none of these types". Decode the loader result into LoadedDecision, which copies the content Arc while the JS object is alive and keeps buffers for parsing off the JS thread.
2026-10-13 17:55:09 +02:00
GoRules Team eadf885a8b chore(release): publish (#546) nodejs-v2.1.6 2026-10-13 14:12:25 +02:00
stefan-gorules 73c8fda788 fix: nodejs wasm root package (#545)
* build(nodejs): declare the wasm32-wasip1 package as an optional dependency

cli 3.10 drops WASI packages from the root optionalDependencies when native targets exist, which would leave browser.js importing an uninstalled package. Ignore and clear the root facades pre-publish now generates.

* build(nodejs): keep the root package free of the threadless wasm facade

napi prepublish copies the 15.6MB wasm into the root package and rewrites files and exports for workerd consumers. Run it through prepublish.mjs, which keeps its optionalDependencies but restores files and exports and removes the generated root files, so the root tarball is back to ~20kB.
2026-10-13 13:54:44 +02:00
GoRules Team c747ea2f46 chore(release): publish (#544) nodejs-v2.1.5 zen-tmpl-v2.1.4 go-v2.1.4 zen-expression-v2.1.4 zen-macros-v2.1.4 uniffi-v2.1.4 zen-types-v2.1.4 zen-engine-v2.1.4 python-v2.1.4 2026-10-13 12:51:22 +02:00
stefan-gorules c8692c401d fix: threadless wasm (#543)
* feat(nodejs): replace the threaded wasm build with threadless wasm32-wasip1

The browser binding no longer needs SharedArrayBuffer or cross-origin isolation. napi moves to 3.14 / cli 3.10.8 with emnapi 2.0.0-alpha.6; the wasm build registers napi-async-runtime's current-thread backend and spawns each evaluation as a runtime task. console.sleep goes through a sleep provider so the wasm build waits on the host timer instead of tokio. CI and the Makefile build and publish @gorules/zen-engine-wasm32-wasip1 in place of the threaded package.

* ci(nodejs): test the wasm32-wasip1 binding and load test binaries in place

cli 3.10 rejects napi artifacts when any configured target is missing, so test jobs download their binary next to index.js instead of building npm dirs. A wasm test job runs the suite against the threadless binding and gates the release.

* chore(nodejs): stop tracking generated wasip1 loaders

napi build writes them alongside the wasm and CI ships them through the wasm artifact, like index.d.ts.

* ci(nodejs): build the glibc legs with cargo zigbuild directly

cli 3.10 runs cargo metadata with the requested target, which rejects the zigbuild glibc suffix. Matches the go and uniffi workflows.

* build(nodejs): keep dev dependencies installable on node 20

@octokit/request 10.0.16 (via @napi-rs/cli) pulls content-type 3, which requires node 22; pin the cli's copy to 10.0.14.
2026-10-13 12:30:29 +02:00
GoRules Team 6b2a11ad4d chore(release): publish (#542) nodejs-v2.1.4 2026-10-09 13:53:07 +02:00
stefan-gorules dca7cac7e7 fix: generate nodejs index.d.ts at build time instead of committing it (#541) 2026-10-09 13:40:01 +02:00
GoRules Team 6ccf7f6013 chore(release): publish (#540) zen-engine-v2.1.3 zen-expression-v2.1.3 zen-types-v2.1.3 zen-macros-v2.1.3 go-v2.1.3 zen-tmpl-v2.1.3 nodejs-v2.1.3 python-v2.1.3 uniffi-v2.1.3 2026-10-09 12:24:24 +02:00
stefan-gorules f887b7bad4 fix: rewrite import and decision node paths when documents move (#539) 2026-10-09 11:57:18 +02:00
GoRules Team 7e0b3d1e1f chore(release): publish (#536) python-v2.1.2 nodejs-v2.1.2 zen-types-v2.1.2 zen-engine-v2.1.2 uniffi-v2.1.2 zen-macros-v2.1.2 go-v2.1.2 zen-tmpl-v2.1.2 zen-expression-v2.1.2 2026-10-02 12:40:20 +02:00
Ivan Miletic 20d88e398d fix: decision table verification and diagnostic (#537) 2026-10-02 12:20:06 +02:00
Ivan Miletic d076cab213 fix: prevent self-referencing $ in graph expression nodes from overflowing the stack (#535) 2026-09-30 19:51:46 +02:00
GoRules Team 2e88387e7a chore(release): publish (#533) python-v2.1.1 nodejs-v2.1.1 zen-engine-v2.1.1 zen-types-v2.1.1 zen-macros-v2.1.1 uniffi-v2.1.1 zen-tmpl-v2.1.1 go-v2.1.1 zen-expression-v2.1.1 2026-09-29 23:07:09 +02:00
Ivan Miletic 35d3db620a fix: type hover on graph decision table output columns (#532) 2026-09-29 22:48:32 +02:00
GoRules Team 61862ab9ef chore(release): publish (#526) zen-expression-v2.1.0 zen-macros-v2.1.0 zen-engine-v2.1.0 zen-types-v2.1.0 uniffi-v2.1.0 zen-tmpl-v2.1.0 nodejs-v2.1.0 go-v2.1.0 python-v2.1.0 2026-09-29 12:35:25 +02:00
stefan-gorules efb213c9c8 chore: align binding versions with core in releases (#531) 2026-09-29 12:17:11 +02:00
stefan-gorules 41e3f8ce60 fix: keep decimal fractions when serializing numbers without arbitrary precision (#530)
Without the arbitrary_precision feature, numbers were serialized through
to_u64/to_i64 first, which truncate, so 1.5 became 1 and 0.1 became 0.
Only integral values take the integer path now; the serialization for
Variable and RcValue shares one implementation.
2026-09-29 10:23:43 +02:00
stefan-gorules 39916c9d18 feat: date input (#529)
* feat: declared dates as date values

- graph format:date/date-time inputs and policy date properties arrive as
  dates that keep their original text for output, string() and string
  functions
- d() keeps the instant of offset/Z strings, resolves DST gaps and accepts
  ISO forms without offset, compact, slash-separated, YYYY-MM and YYYY
- dates compare with date strings in ==, !=, <, >, in and contains, and
  concatenate with strings; deprecated date helpers accept dates
- string(date), type() reports date, and date-to-string at string inputs

* fix: close review gaps in date inputs

- parse new date formats by exact shape; keep master formats first and
  guard DST-gap and extreme-year overflows
- text-carrying dates act as strings for object keys, in-object, index,
  slice, concatenation and bool
- deprecated helpers fall back to the date instant; time() accepts dates
- schema-less child inputs receive date text; dates satisfy string
  parameters and slicing in the type checker
- convert policy input before validation so dates are parsed once;
  share rewrite helpers between graph and policy conversion

* fix: align date text, unions, references and child inputs

- every valid date exposes a text form (original or RFC3339), so string
  functions and slicing on computed dates match the type checker
- date and string types merge to string; reference ids typed as dates
  resolve through their text
- input nodes convert declared dates and hand every other converted date
  back as its original text, following combinators only for structure
- date format checks no longer allocate
2026-09-29 09:59:44 +02:00
stefan-gorules 4aba11edd3 fix: tolerate null inputs and enforce required policy inputs (#528)
- graph input and output validation treats null optional properties as
  absent (including inside anyOf/oneOf objects) and reports the real
  error when validation still fails
- remove the NULLABILITY_DIVERGENCE diagnostic
- policies enforce required inputs also without goals; a path is missing
  when absent or null unless a step along it is optional, checked after
  reference hydration, and computed entity fields are not inputs
2026-09-28 22:51:47 +02:00
stefan-gorules ffdfd807d1 feat: implement slots instead of natural language (#527)
* feat: implement slots instead of natural language

Replace the natural-language projection (`nl`) with engine-owned slot
completion: for a cursor position the engine classifies the slot being
edited (operand, operator, literal, member access, ...) and returns typed
options, literal facts and the expected type, for policies and graphs.

- zen-expression: new `slot` module (classification, literals, operators)
  and a lenient lexer mode for incomplete input; `nl` removed
- Intellisense: typed diagnostic codes with arguments, richer inspect for
  hover, dedicated parser error variants (messages unchanged)
- Engine: `Workspace::cursor_scope`, `slot`, `facts`; `rename_from` and
  `references_from`; editor spans in UTF-16 units; renames reach imported
  policies, `$nodes` reads, child graphs and output column heads; no `$root`
  completion in policies
- Node bindings: `slot`, `facts`, `cursorScope`, `slotBatch` replace
  `nl`, `nlTokenize`, `nlEncodeString`, `nlTokenizeBatch`

No change to expression evaluation: the VM, compiler, functions and the
default lexer path are untouched, and parser error messages keep their text.

* fix: harden slot classification, scopes and graph expectations

- restore master execution order; slot scopes hide writes of the edited
  block and its dependents instead of relying on block ranking
- token-start editing gated by slot state; operator, list and operand
  spans no longer splice into neighbouring tokens
- interval-aware bracket pairing for half-open and reversed intervals
- lenient lexer recovers from unknown characters (slots only)
- graph expected type follows switch and pass-through nodes and merges
  compatible output schemas
- sibling inference caps distinct values and analyses lazily
- deterministic overload return type display

* fix: order policy blocks by entity reads through closures and relationships

- record reads for `#.field` in closures so entity fields read through
  lists become dependencies
- link reads through derived lists (filter/map results) to the entity
  fields they carry and order the list after those fields
- evaluate entity blocks on single relationships, and demand entity
  paths for plain reads through relationships
- slot scopes keep the top-level variable when hiding written fields
2026-09-28 21:47:40 +02:00
stefan-gorules a7157f3448 fix: scope policy evaluation to the import closure (#525)
* fix: scope policy evaluation to the import closure

A policy is now analysed and evaluated together with the policies it
imports (transitively), instead of every policy connected to it by imports
in either direction. Importers and siblings no longer leak into each other:
compiled evaluate() of an imported policy used to run its importers' and
siblings' blocks.

- Evaluation gate analyses the entry's import closure as one unit, so a
  child may read fields and reference entities its importer declares when
  evaluated through that importer
- compile() reports a policy that is only valid through an importer with
  kind "policyImportOnly" instead of failing it as a plain "policy"; errors
  are computed once per key
- Scope diagnostics (duplicate writers, input overrides, data model and
  dictionary collisions, cycles) are reported for the whole closure, and
  conflicts introduced by combining imports are reported on the importer
- Single-entity scope checks run per import closure instead of workspace-wide

* fix: unknown import relationship targets and renames across imports

- An unresolved relationship/reference target inside an imported policy now
  blocks the importer's evaluation and compile(), as on master; the check was
  still limited to the policy being analysed, so the importer compiled and
  the broken child was reported as "policyImportOnly"
- Rename and find-references analyse each policy's expressions in every
  importer's context too, so reads of a field declared by an importer are
  found in the imported policy again
2026-09-28 12:17:12 +02:00
stefan-gorules e095189dd6 fix: return errors instead of panicking in memory loader and v1 functions (#524)
* fix: return errors instead of panicking in memory loader and v1 functions

- MemoryLoader recovers from a poisoned lock. Previously a panic during
  one add() (e.g. a failing content conversion) made every later
  add/get/remove/keys call panic for the rest of the process
- v1 function node returns an error when its JS bootstrap fails instead
  of unwrapping. The 500ms interrupt budget starts before the runtime and
  bundled libraries load, so a slow or loaded host could interrupt the
  bootstrap and panic

* chore: bump setup-android to v3 in uniffi workflow

Only platform-tools is installed; Gradle fetches the platform and build tools the AAR build needs.
2026-09-28 11:24:17 +02:00
stefan-gorules adf7cdf44a chore: add uniffi tests (#520)
* chore: add uniffi tests

* fix permissions in pipelines

* fix tests
2026-08-24 12:45:09 +02:00
GoRules Team a1f8c3e470 chore(release): publish (#519) uniffi-v2.0.2 nodejs-v2.0.2 python-v2.0.2 2026-08-24 10:08:40 +02:00