Commit Graph
109 Commits
Author SHA1 Message Date
Stefan a7446057c9 feat: batch evaluation APIs for decisions and standalone expressions
DecisionEngine::evaluate_many wraps evaluate_batch (compiled columnar plan with row
fallback) and returns results only; evaluate_batch now resolves keys with or without
.json like evaluate. BatchExpression compiles one expression for the lane VM (stack VM
fallback when the lane refuses it) and evaluates rows or Columns. batch_rows example
benchmarks 100k rows.
2026-10-20 22:01:23 +02:00
Stefan 718ccde978 feat(expression): host function registry, count_distinct alias, null-skipping mode and statistics
Ports register_host_function/HostFunction from 3def2637 onto the lane VM branch:
FunctionKind::Host is parsed, type-checked, completed, compiled by the stack VM and
driven by the lane VM through the registry definition. mode, stddev, variance,
percentile and percentileApprox over plain lists skip nulls like their callback forms.
2026-10-20 21:44:01 +02:00
Ivan Miletic fa520af6de feat(engine): prepare policy input as columns (dates, defaults, references) 2026-10-13 15:46:58 +02:00
Stefan Miljakovic 08bc977727 perf: wider typed lowering coverage with census tooling
Typed lowering now covers contains/some/all/none over literal lists,
ordering compares against an absent input (lenient tables fold the cell
to no-match and drop the rule; constant one-input tables stay native),
text tests on absent operands, list-valued table inputs, lists of
scalars from static list slots, input slots of unknown shape (resolved
per batch like Dyn) and literal tables with composite output cells.
A unit using new coverage is lowered as its own typed group. The typed
date-to-text and generic host paths reuse the result while consecutive
rows pass identical arguments. ZEN_CENSUS records why a unit stays on
the lane and times lane fallbacks (cold paths, off by default).
2026-10-12 18:02:58 +02:00
Stefan Miljakovic 8d41eab863 perf: learned row dedup for typed groups
Typed groups without list inputs (graph: 16+ local rows, not already on
the long-program dedup; policy: root groups) learn per group whether to
run the program on distinct input rows only: warm-up, a deferred probe
of the coded run, then a measured trial against the plain run, repeated
every 64 calls. Rows are keyed by exact value codes (table hints, Dict
keys, numbers by mantissa and scale, text through Coder::keys, cached
per call in the graph store). Graph outputs stay dict-coded (reps plus
ids through widen/expand); policy spreads rep outputs back to rows
(Outputs::spread) because its sinks take row-shaped outputs.
2026-10-12 16:07:51 +02:00
Stefan Miljakovic 3a86b14876 fix: absent vs null cells in generic table matching 2026-10-11 12:49:12 +02:00
Stefan Miljakovic 07e5b70586 perf: lane lowering of $ reads in closures, indexed reads and computed loop input fields in graph expression nodes, row-wise census 2026-10-10 12:37:29 +02:00
Stefan Miljakovic 66992d1e93 perf: shared per-row errors and graph columnar buffer reuse 2026-10-10 04:00:48 +02:00
Stefan Miljakovic 2b00b41980 feat: lane session mirroring the isolate API (exact compile errors, shared program sets, fallback detector) 2026-10-09 10:20:59 +02:00
Stefan Miljakovic 42905d6e34 perf: typed dates (date registers on lane date builtins, date compares and coercion, legacy date functions, dates in closures) 2026-10-09 07:59:12 +02:00
Stefan Miljakovic e6d20cb28f perf: typed runtime strings (text registers, string(), templates, concatenation, string builtins, text outputs and closures) 2026-10-09 06:35:25 +02:00
Stefan Miljakovic 5ac70742ae perf: typed lists and closures (list values, membership, primitive and nested lists, member closures) 2026-10-09 04:57:35 +02:00
Stefan Miljakovic 14332639ce perf: typed coverage for math builtins, list folds and member tables; exact wide-value slow path; table rule lookup 2026-10-09 03:03:33 +02:00
Stefan Miljakovic d3832d75d1 perf: columnar graphs on typed-mask (shared table lowering, deferred dynamic slots, learned typed/lane switch, one input normalizer) 2026-10-08 23:48:07 +02:00
Stefan Miljakovic 742f8a62bc perf: typed-mask executor under columnar policies (typed IR, scale-exact lowering, per-unit lane fallback) 2026-10-08 18:04:23 +02:00
Stefan b13121731b perf: columnar policies and struct-list columns (pre-compiled policy plan, flat input shredding, fused lane programs)
- lane: list-of-struct columns, closures over struct lists, compile_fused/evaluate_columns_many, Fold and Switch ops, dictionary-coded outputs, faster number and string kernels
- graph: list-of-struct inputs and outputs, native struct-list loops, mixed plans with hosted rows, native sub-decisions and schema checks
- policy: Workspace::evaluate_columns with a pre-compiled plan per goals and layout (entity struct lists, native tables, columnar validation, fused groups, constant folding), shredding of untyped entity lists
- anchor benchmark: struct-list inputs 101x and flat inputs 63x vs the policy driver
2026-10-08 11:15:06 +02:00
Stefan c5c1ef1fd3 feat: lane VM (register-based batch/columnar expression VM in zen-expression, value shapes in zen-types, differential tests against the stack VM) 2026-10-06 15:42:30 +02:00
Ivan Miletic 20d88e398d fix: decision table verification and diagnostic (#537) 2026-10-02 12:20:06 +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 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 0b6c6a709a fix: nested scopes and any cascade (#513) 2026-08-20 17:39:45 +02:00
stefan-gorules 792e77a82e fix: panic hardening (#509) 2026-08-19 12:04:15 +02:00
stefan-gorules 32f7fb875c fix: end of week boundary (#508) 2026-08-19 11:15:21 +02:00
stefan-gorules 13722740a1 fix: number out of range panics (#506) 2026-08-19 11:01:36 +02:00
stefan-gorules ed0c286d9f fix: v1 behaviour hardening (#502) 2026-08-07 10:30:43 +02: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 1cb74e6f59 feat: add date natural language (#493)
* feat: add date natural language

* add coverage for date methods
2026-07-22 15:55:43 +02:00
stefan-gorules 63b560c526 feat: workspace lints and type fixes (#492)
* feat: workspace lints and type fixes

* fix fmt
2026-07-22 11:17:49 +02:00
stefan-gorules 8d1910cc4e feat: graph workspace and static analysis (#483) 2026-07-16 23:42:13 +02:00
stefan-gorules 9a11ae4f48 feat: policy table output type (#481) 2026-07-10 10:13:47 +02:00
stefan-gorules b4b59eb7c5 feat: policy dictionary (#479)
* feat: policy dictionary

* remove enum references

* improve tests

* reset index.js and package.json
2026-07-08 13:21:03 +02:00
stefan-gorules 6858c1bd04 feat: natural language (#477)
* feat: natural language

* fix cargo fmt
2026-07-07 13:12:46 +02:00
stefan-gorules 602d214b96 feat: expression static analysis (#449)
* feat: expression static analysis

* fix: cargo fmt

* fix: python workflow

* fix: python workflow

* fix: python workflow

* fix: ignore miri test bound by clock

* fix: memory leaks
2026-06-22 15:48:05 +02:00
stefan-gorules 53f3b5a430 feat: merge function (#438)
* feat: merge function

* add mergeDeep function

* default merge to return empty object instead of empty array
2026-03-15 14:44:32 +01:00
stefan-gorules 6beecb423f fix: simplify compilation (#429)
* fix: simplify compilation

* improve opcodecache structure
2026-02-11 16:07:34 +01:00
stefan-gorules 73d5d5c6cb feat: function scope alias (#426)
* feat: function scope alias

* fix types
2026-01-19 10:44:16 +01:00
bcrevar-gorulesandStefan 7bfebd90fe feat: precompile decision content (#401)
* precompile first

* test

* add Opcode cache through Option<T>

* Compiled support for decisionTable,
default compile of new DecisionContent for node.js and py bindings

* format

* DecisionContent refactored to model module

* fmt

* added back BaseDecisionContent

* tests and benchmark

---------

Co-authored-by: Stefan <stefan@gorules.io>
2025-11-21 14:44:24 +01:00
stefan-gorulesandIvan Miletic 922a262e98 feat: wasm support (#404)
* feat: wasm support

* add http callback

* streamline structs

* fix: wasm workflow

* fix: wasi path

* fix: wasm

* fix: wasm path

* fix: clang dev

* fix: libclang static

* fix: build

* fix: node

* fix: wasm

* fix: wasm wasi

* fix: npm dirs

* fix: node workflow

* fix: testing

* fix: test

* update version

* fix: targets

* fix: wasm fix

* fix: commit files

---------

Co-authored-by: Ivan Miletic <vnmiletic@gmail.com>
2025-11-13 12:36:59 +01:00
stefan-gorules 91509821be feat: refactor engine (#390)
* temp: refactor engine

* temp

* implement remaining nodes

* resolve snapshot tests

* improve decision graph implementation

* implement changes in bindings

* implement changes in bindings

* fix function impl gaps

* update cargo.toml

* fix issues with trace
2025-09-04 18:54:32 +02:00
stefan-gorulesandbojancrevar 80fe4021c2 feat: compact trace (#384)
* feat: compact trace

* align with changes

* add deserialization

* add tests and deserializer

* fix bindings

* first draft

* mock time; update snapshots

* fix

* Node.js test fix

* fix merge

* fix utc override

* fix cross-env

* fix workflow

* fix

---------

Co-authored-by: bojancrevar <bojan.crevar@gorules.io>
2025-08-25 12:33:07 +02:00
bcrevar-gorulesandStefan 4a59f222db feat: add snapshot tests (#385)
* first draft

* mock time; update snapshots

* fix

* Node.js test fix

---------

Co-authored-by: Stefan <stefan@gorules.io>
2025-08-20 16:30:28 +02:00
stefan-gorules 09f59e9bb2 fix: timezone caching (#371) 2025-07-04 10:05:35 +02:00
stefan-gorules f2fcb95ad9 feat: assignment (#366)
* feat: assignment

* add tests
2025-06-18 10:43:01 +02:00
stefan-gorules bdf51dec11 fix: safe division (#365)
* fix: safe division

* add test
2025-06-16 09:47:35 +02:00
stefan-gorules 815729aca4 fix: update rounding strategy (#361)
* fix: update rounding strategy

* add test
2025-06-03 12:04:47 +02:00
stefan-gorules a911a623cb fix: align date diff with dayjs (#360) 2025-06-03 09:48:57 +02:00
stefan-gorules c9d11f12dd fix: normalize number during serialization (#359) 2025-06-02 14:47:16 +02:00
stefan-gorules 173d7bcb79 feat: improve stack resiliency (#357) 2025-05-27 17:46:00 +02:00
stefan-gorules 29ce060ac7 feat: number scientific notation (#355)
* feat: number scientific notation

* add tests
2025-05-23 11:46:33 +02:00
stefan-gorules 34de232d3a feat: dates min/max (#353) 2025-05-23 11:18:50 +02:00