Commit Graph
62 Commits
Author SHA1 Message Date
Stefan a137fbe6a7 docs: agent batch API; test variadic host functions feeding aggregates
Also ungates serde_json::json in compiled_policy tests, used outside the driver feature.
2026-10-20 22:40:54 +02:00
Ivan Miletic 8eb9d0f971 feat(engine): columnar graphs and policies end to end: prepared inputs, reasons, fallbacks, impact diffs 2026-10-15 15:41:30 +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 5097194f94 perf: one QuickJS context per batch for V1 function nodes
Columnar batches of a V1 function node run in one prepared runtime and
context when the source is proven isolated (Purity::layout, the script
dialect of the shared allow-list analysis). Each row is evaluated on a
layout that keeps line/column positions, inputs go through JSON.parse
unless a literal is needed (__proto__ keys, deep nesting), the 500 ms
limit restarts per row, and any error or pending job drops the context.
Single-row evaluation is unchanged.
2026-10-12 15:23:39 +02:00
Stefan Miljakovic be644af5fb fix: allow-list isolation analysis for batched V2 function nodes
Isolation::shareable treated member writes rooted at a local as local,
so state shared through a call result, an object field or a function
parameter (e.g. const f = () => Math; f().seen = ...) leaked across the
rows of a columnar batch. Shared runtimes now need a closed-world proof
(Purity::module): globals, imports and top-level functions never appear
as values, only whitelisted calls/statics/methods; everything else runs
on a fresh runtime per row.
2026-10-12 14:02:55 +02:00
Stefan Miljakovic 3a86b14876 fix: absent vs null cells in generic table matching 2026-10-11 12:49:12 +02:00
Stefan Miljakovic a65ff37cf2 fix: path-independent policy columnar column order 2026-10-11 11:52:03 +02:00
Stefan Miljakovic 81398d4538 refactor: measured typed/lane switch for policies 2026-10-11 08:13:47 +02:00
Stefan Miljakovic 2da0696345 test: consolidation_snapshot counters probe 2026-10-10 15:27:27 +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 7e875cae16 perf: batched sub-decision resolution and shared resolve faults, direct custom-node adapter calls 2026-10-10 09:38:36 +02:00
Stefan Miljakovic 40498c9c85 perf: struct-list collect tables, lazy templated outputs and columnar record consumers 2026-10-10 05:38:53 +02:00
Stefan Miljakovic 610b4aa78f feat: compiled-only graph engine (native traces, walker and old node handlers behind driver feature, crate-wide isolate ban) 2026-10-09 16:16:48 +02:00
Stefan Miljakovic e7dffa402b feat: native graph rows (lane expression, table and transform executors, refused nodes hosted natively, lazy compile, compiled sub-decision calls) 2026-10-09 14:20:57 +02:00
Stefan Miljakovic b0a375b744 feat: native policy evaluation (lane block executors, compiled traces and extras, driver behind feature flag) 2026-10-09 11:51:43 +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 e0de7cdbef test: golden references for graph and policy evaluation (outputs, errors, traces) and single-row latency benches 2026-10-09 09:47:19 +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 c1f44868dd test: engine conformance suite (graph and policy chapters, walker/driver spec runners, compiled engine differentials) 2026-10-06 15:42:31 +02:00
Stefan c5abfaf2d8 feat: compiled graph and policy engine on the lane VM (single, batch and columnar evaluation, walker/driver differentials) 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 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 0b6c6a709a fix: nested scopes and any cascade (#513) 2026-08-20 17:39:45 +02:00
stefan-gorules c615013a2d feat: graph dt column collect (#505) 2026-08-19 10:44:58 +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
Ivan Miletic 7b4dc3cfbc fix: graph explain dot (#498) 2026-07-26 13:45:39 +02:00
Ivan Miletic 37d5e0baf7 fix: dt no cell defaults to true (#496) 2026-07-24 14:35:55 +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 6c0ca51354 feat: policy engine (#450)
* feat: policy engine

* fix: cargo fmt

* fix: resolve issues with miri
2026-06-23 18:51:47 +02: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-gorules 07040c8a96 feat: lazy load fn nodes (#389)
* feat: lazy load fn nodes

* fix rebase, fix $nodes

* fix

* miri ignore test
2025-11-07 10:53:21 +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 2b73856d55 feat: schema validation (#267)
* feat: schema validation

* fix prettier

* update implementation

* add test cases

* change validator to string

* update tests
2024-12-25 13:00:04 +01:00