Commit Graph
77 Commits
Author SHA1 Message Date
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 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
stefan-gorules ec108e8069 ci: on-demand beta releases from release/* branches (#554) 2026-10-27 18:31:54 +01: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
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
stefan-gorules efb213c9c8 chore: align binding versions with core in releases (#531) 2026-09-29 12:17:11 +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
stefan-gorules f4e32deb9a fix: windows gnu ffi (#515) 2026-08-20 23:24:48 +02:00
stefan-gorules 7259ab28c3 fix: repair uniffi release pipeline and bump uniffi to 0.31 (#504) 2026-08-18 23:03:23 +02:00
Aleksej Komnenovic 09cda3bf4e use s3 sccache in go workflow 2026-06-26 15:11:18 +02:00
Aleksej Komnenovic 966816e1de add s3 backend for sccache 2026-06-26 14:21:27 +02:00
stefan-gorules bb53a5298f fix: switch releases to tag based workflow triggers (#465) 2026-06-25 21:53:52 +02:00
stefan-gorules a4cafd0346 chore: add benchmarks (#459)
* chore: add benchmarks for tier 1 languages

* improve fixtures

* fix cargo fmt
2026-06-25 13:38:33 +02:00
stefan-gorules fc9ab1269f chore: improve release process (#457)
* chore: improve release process

* fix locked build on node.js

* fix release naming

* fix .node bindings

* revert node.yaml

* fix

* add locked param

* fix: node
2026-06-25 11:19:46 +02:00
stefan-gorules 7f31af809d chore: improve release pipeline (#451)
* chore: improve release pipeline

* fix pipelines

* fix sccache

* update workflows

* fix workflow

* update workflow

* remove sccache and cross

* bring back sccache

* fix pipelines

* fix nodejs build

* fix pipelines

* move python to abi3 for future proofing

* fix workflow ordering bug

* gate releases via environment - configure go via release

* set release as 1.0.0-beta
2026-06-24 20:44:35 +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
bcrevar-gorules 63957b7010 fix(GRL-517): bump reqsign to 0.20 to drop vulnerable jsonwebtoken (#446)
* dep update

* lld fix

* lld fix 2

* lld fix 3

* lld fix 4

* lld fix 6

* lld fix 7

* lld fix 8

* lld fix 9

* lld fix 10
2026-05-29 14:16:48 +02:00
bcrevar-gorules 4db41be0d7 fix: s390x removed for kotlin and c# uniffi bindings(#440)
trimmed non release android build
2026-03-18 15:34:38 +01:00
bcrevar-gorules f915bd8bee fix(GRL-442): bindings - upgrade nmcp and gradel build (#439)
* add workflow dispatch

* do build

* do build

* android and kotlin release

* upgrade nmcp version

* upgrade gradle build version (validation now included)
Separate publish for java and kotlin

* comment publish to test re-validation

* remove workflow dispatch testing
2026-03-18 14:06:05 +01:00
Ivan Miletic ab4cf0b90d fix: add java s390x support (#436)
* fix: java s390x support

* fix: bindgen

* fix: clang version

* fix: cross.toml
2026-03-17 16:48:09 +01:00
stefan-gorules 46688a4d4c feat: configurable arbitrary precision (#433)
* feat: configurable arbitrary precision

* fix workflow

* fix workflow

* set version of docker run action to v1

* set arbitrary_precision as opt-in

* revert making arbitrary_precision non-default

* update cargo version action and add features in Cargo.toml for deps

* add tests for arbitrary precision and make it non default. add warnings for compilation when arbitrary precision not enabled

* simplify conversion

* remove build.rs
2026-03-03 16:57:22 +01:00
bojancrevar 045ed44f6b remove workflow dispatch 2026-02-27 11:59:25 +01:00
bojancrevar 74ba5d455b trusted publishing 2 2026-02-25 14:15:47 +01:00
bojancrevar b886d972f6 trusted publishing 2026-02-25 13:01:49 +01:00
bojancrevar 65743dec5d testing NuGet publish 2026-02-24 16:10:27 +01:00
bojancrevar 245d0d5534 uncomment NuGet publish 2026-02-24 16:07:38 +01:00
bojancrevar fa85ac8d1a revert workflow_dispatch, fork used for async generation cs bindings issue 2026-02-24 11:34:51 +01:00
bojancrevar 2ec9961df3 point to forked cs-bindings 2026-02-24 11:07:37 +01:00
bojancrevar af102de5ba config fix 2026-02-23 12:53:30 +01:00
bojancrevar 81d5c8f2cb fixed cs-bindgen url 2026-02-23 11:11:48 +01:00
bojancrevar fc3ecaede7 upload nuget artifact 2026-02-23 11:04:25 +01:00
bojancrevar eecd5c2041 testing with dispatch 2026-02-23 10:19:55 +01:00
bojancrevar 9fcde9d5ce C# CI 2026-02-23 09:41:36 +01:00
Ivan Miletic 18d9b143c5 fix: node workflows contents write (#427) 2026-01-19 15:25:21 +01:00
stefan-gorules a6ad0a7894 fix: clean variable before validation (#409)
* fix: clean variable before validation

* bump workflow to macos-14

* move to macos latest

* update runners

* improve performance of implementation
2025-11-19 11:59:51 +01:00
Ivan Mileticandbojancrevar 95154b72f1 feat: mobile support initial (#399)
* feat: mobile support

---------

Co-authored-by: bojancrevar <bojan.crevar@gorules.io>
2025-11-19 10:33:20 +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 1e4135f5fb fix: rust version bump (#387)
* fix: rust version bump

* add publish cmd
2025-08-25 16:52:34 +02:00
stefan-gorules 5cb11dc34b fix: update node version in ci (#386) 2025-08-25 14:24:41 +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
Ivan Miletic fec0c40ca0 fix(GRL-189): rustup install 1.88.0 (#383)
* fix: rustup install 1.88.0

* fix: default version
2025-08-04 17:28:16 +02:00
stefan-gorules 503d912b3f fix: uniffi workflow paths (#382) 2025-07-31 17:22:10 +02:00
stefan-gorulesandLars Werkman 91eec8029c feat: kotlin and java bindings (#319)
Huge thanks to: Lars Werkman <lars@bitvavo.com>

* feat: add support for kotlin bindings

* chore: build kotlin bindings version

* build: add proper lib dir for jna

* chore: rename kotlin directory to uniffi

* update kotlin files

* update kotlin

* fix workflow

* fix workflow

* fix

* fix upload path

* fix

* fix

* fix fmt

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix charset

* fix

* fix

* fix

* fix

* update env variables

* fix

* add pipelines for release

* debug

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix build

* add javadoc

* improve bindings

* feat: separate artifact for java and kotlin source code

* feat: add custom JsonBuffer type with fromString and toString abbilities

* fix workflows

* fix pipeline

* fix gradle

* fix: java bindings

* update java

* include kotlin in publish; bump version

* fix release

* fix

* fix publication

* fix missing dep

* fix dep chain

* add expression compilation

* bump version

* improve performance

* improve expression api

* fix: restore interfaces

* cleanup and add preliminary csharp support

* prepare for release

---------

Co-authored-by: Lars Werkman <lars@bitvavo.com>
2025-07-31 12:37:00 +02:00
stefan-gorules de6d13e1c7 feat: date v2 (#345)
* feat: date v2

* implement more date functions

* improve type safety

* add more methods for dates

* update utc to tz and add support

* add unary node behaviour for date methods

* add tests; fix errors in bindings

* add date operators

* fix types

* change set date signature

* update nightly
2025-05-12 22:39:08 +02:00
stefan-gorules f0a3c75129 fix: nodejs versioning (#344)
* fix: nodejs versioning

* update package.json
2025-04-28 11:20:19 +02:00
stefan-gorules f9d9b1342c fix: change nodejs versioning system (#342) 2025-04-28 09:10:02 +02:00
stefan-gorules 3b139e9245 chore: update packages (#334)
* chore: update packages

* update lerna

* fix

* revert nodejs changes

* fix

* fix

* fix

* update minimum node to 18
2025-04-15 13:21:55 +02:00
Ivan Miletic 945d3eb1c3 fix: add merge multiple (#311) 2025-02-08 22:19:40 +01:00
stefan-gorules 5b50fd57da fix: python pipeline (#310) 2025-02-08 21:47:31 +01:00