@lemmabase/lemma-engine 0.8.22 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lemmabase/lemma-engine
2
2
 
3
- > [Lemma](https://github.com/lemma/lemma) is a declarative language for business rules. **This package is the engine, compiled to WebAssembly** - runs in the browser, on Node, Bun, Deno, Cloudflare Workers, Vercel Edge, etc.
3
+ > [Lemma](https://github.com/lemma/lemma) is a declarative language for business rules. **This package is the Lemma engine for JavaScript and TypeScript** browser, Node, Bun, Deno, Cloudflare Workers, Vercel Edge, etc.
4
4
 
5
5
  Pricing tiers, tax brackets, leave entitlement, eligibility checks, discount stacks: the rules that change, that auditors ask about, that legal writes in PDFs and engineers re-implement in operational code... Lemma is a language built specifically for your business rules. It is readable by stakeholders, executable anywhere, and impossible to drift out of sync.
6
6
 
@@ -28,22 +28,22 @@ rule total:
28
28
  import { Lemma } from '@lemmabase/lemma-engine';
29
29
 
30
30
  const engine = await Lemma();
31
- await engine.load(pricing, 'pricing.lemma');
31
+ await engine.load({ 'pricing.lemma': pricing });
32
32
 
33
- const response = engine.run(null, 'pricing', null, { quantity: 50, is_vip: false }, null);
33
+ const response = engine.run(null, 'pricing', null, { quantity: 50, is_vip: false }, null, false);
34
34
  // response.results.unit_price → 16 eur
35
35
  // response.results.total → 800 eur
36
36
  ```
37
37
 
38
- The `Response` carries every rule's value (or `veto` if no result could be computed), the input snapshot, and the source location of every rule that fired, allowing you to render an audit trail in your UI.
38
+ The `Response` carries every rule's value (or `veto` if no result could be computed). When inputs are still unbound, that rule includes `missing_data` (`string[]` input keys). Types, prefilled literals, and suggestions are on `engine.show(...)` (`Show.data`) only not on the evaluate response.
39
39
 
40
40
  ## Why use it from JavaScript?
41
41
 
42
42
  - **Deterministic.** `(spec, data, effective_date) → result`. No DB, no clock, no ambient state. Same inputs → same outputs, every time.
43
- - **Explainable.** The `Response` tells you which rules contributed and why; pair it with the [CLI](https://github.com/lemma/lemma) for a full reasoning trace.
43
+ - **Explainable.** Pass `explain: true` (6th `run` argument) to get a per-rule explanation tree; see [explanation.v1.json](https://github.com/lemma/lemma/blob/main/documentation/schemas/explanation.v1.json). Pair with the [CLI](https://github.com/lemma/lemma) for human reasoning tables.
44
44
  - **Time-aware.** Multiple versions of the same spec coexist. Pass an `effective` date and the engine resolves the version in force on that day.
45
45
  - **Statically checked.** Type errors, missing data, cycles, measure-family mismatches - all caught at `load()` time. Bad specs never reach `run()`.
46
- - **Runs anywhere V8 does.** ~2 MB WASM, no native binary, no postinstall script.
46
+ - **Runs anywhere JavaScript does.** ~2 MB package, no native binary, no postinstall script.
47
47
  - **Editor in a tab.** Includes an in-process language server and a Monaco adapter, so you can build a real Lemma editor experience client-side - diagnostics, completion, formatting... even without setting up a server.
48
48
 
49
49
  ## Install
@@ -60,9 +60,9 @@ import { Lemma } from '@lemmabase/lemma-engine';
60
60
  const engine = await Lemma();
61
61
  ```
62
62
 
63
- `Lemma()` initializes the WASM module once and returns an `Engine`. Serve over **http(s)**, not `file://`. For manual control: `init()` then `new Engine()`.
63
+ `Lemma()` initializes the engine once and returns an `Engine`. Serve over **http(s)**, not `file://`. For manual control: `init()` then `new Engine()`.
64
64
 
65
- If your bundler emits IIFE, can't resolve `import.meta.url`, or refuses to ship `lemma_bg.wasm` as a separate asset, use the inlined entry - it embeds the wasm bytes in the JS bundle:
65
+ If your bundler emits IIFE, can't resolve `import.meta.url`, or refuses to ship the engine module as a separate asset, use the inlined entry everything ships in one JS bundle:
66
66
 
67
67
  ```javascript
68
68
  import { Lemma } from '@lemmabase/lemma-engine/iife';
@@ -86,7 +86,7 @@ import { Lemma } from '@lemmabase/lemma-engine';
86
86
  const engine = await Lemma();
87
87
  ```
88
88
 
89
- For zero-fetch startup with a preloaded module: `initSync({ module })` then `new Engine()`.
89
+ For zero-fetch startup: `initSync({ module })` then `new Engine()`.
90
90
 
91
91
  ## In-process LSP + Monaco
92
92
 
@@ -111,39 +111,40 @@ A pre-wired Monaco adapter ships at `@lemmabase/lemma-engine/monaco`.
111
111
 
112
112
  | Method | Description |
113
113
  |--------|-------------|
114
- | `load(code, attribute?)` | Parse and validate a `.lemma` spec set. Resolves on success; rejects with `EngineError[]`. |
115
- | `load_batch(sources, dependency?)` | Load many sources in one planning pass (see `lemma.d.ts`). |
114
+ | `load(code)` | Load inline Lemma source as a volatile workspace source |
115
+ | `load(sources)` | Load multiple sources in one planning pass (`Record<label, text>` or `[label, code][]`; `@org/pkg` keys tag dependencies) |
116
116
  | `fetch(name)` | Download registry source only; resolves with `{ source, id }`. Does not load. Rejects with `EngineError[]`. |
117
- | `list()` | JSON array of `ResolvedRepository`: each has `repository` and `specs` (spec sets). Always includes embedded `lemma` / `spec units`. |
118
- | `format_repository(repo)` | Canonical Lemma source for a loaded repository, formatted from the in-engine AST. Use `"lemma"` for the embedded units stdlib. |
119
- | `schema(repo, name, effective?)` | `SpecSchema`; `repo` null for workspace. |
120
- | `run(repo, name, ruleNames, data, effective?, explain?)` | Evaluate. Omit/`null` `ruleNames` for all rules; pass a non-empty array to scope. `[]` errors. Returns a `Response`. |
117
+ | `list()` | Slim catalog: `ResolvedRepository[]` with `repository` and temporal `specs` rows. Always includes embedded `lemma` / `spec units`. |
118
+ | `show(repo, name, effective?)` | Spec interface + temporal window; `repo` null for workspace. |
119
+ | `source(repo, spec?, effective?)` | Canonical Lemma source text. Omit `spec` for whole repository. |
120
+ | `run(repo, name, effective?, data?, ruleNames?, explain?)` | Evaluate. Omit/`null` `ruleNames` for all rules; pass a non-empty array to scope. `[]` errors. Returns a `Response`. `explain: true` adds per-rule explanation trees. |
121
+ | `remove(repo, name, effective?)` | Remove a temporal spec slice. |
122
+ | `limits()` | Resource limits for this engine. |
121
123
  | `format(code, attribute?)` | Canonical formatting; throws `EngineError` on parse error. |
122
124
 
123
125
  Full TypeScript types are bundled - see `lemma.d.ts`.
124
126
 
125
127
  ### Registry dependencies
126
128
 
127
- Specs that reference `uses … @org/pkg` need that package available. `fetch` only downloads; call `load_batch` to load the dependency, then load your workspace:
129
+ Specs that reference `uses … @org/pkg` need that package available. `fetch` only downloads; call `load` with the dependency id as the source label, then load your workspace:
128
130
 
129
131
  ```javascript
130
132
  import { Lemma } from '@lemmabase/lemma-engine';
131
133
 
132
134
  const engine = await Lemma();
133
135
  const { source, id } = await engine.fetch('@iso/countries');
134
- await engine.load_batch({ '': source }, id);
135
- await engine.load(sourceThatUsesStd, 'app.lemma');
136
+ await engine.load({ [id]: source, 'app.lemma': sourceThatUsesStd });
136
137
  ```
137
138
 
138
139
  In the browser, the registry must allow your origin (CORS). Use `https` or `http://localhost` when using `fetch`.
139
140
 
140
141
  ## Status
141
142
 
142
- Lemma is pre-1.0. The WASM API is stable for most use cases, but breaking changes may occur between minor versions. Pin your dependency version and review the [changelog](https://github.com/lemma/lemma/blob/main/CHANGELOG.md) before upgrading.
143
+ Lemma is pre-1.0. The JavaScript API is stable for most use cases, but breaking changes may occur between minor versions. Pin your dependency version and review the [changelog](https://github.com/lemma/lemma/blob/main/CHANGELOG.md) before upgrading.
143
144
 
144
- ### WASM panic behavior
145
+ ### Runtime traps (internal bugs)
145
146
 
146
- Rust panics cannot unwind on the `wasm32` target, so an internal invariant violation (a bug) traps the WASM instance. The call throws a `RuntimeError` which you can catch with `try/catch` to fail gracefully, but the module's linear memory is poisoned — constructing a new `Engine()` from the same initialized module is not safe. To recover, re-initialize the WASM module (`init()` again) or, for robust containment, run the engine in a Web Worker and respawn the worker on trap. The panic message (prefixed `BUG: ...`) is logged to the console before the trap. All domain-level failures (invalid specs, bad data, impossible rules) are reported as `EngineError[]` or vetoes and never cause traps.
147
+ An internal invariant violation (a bug in the engine) traps the runtime. The call throws a `RuntimeError` which you can catch with `try/catch`, but the loaded module is poisoned — constructing a new `Engine()` from the same initialization is not safe. To recover, call `init()` again or run the engine in a Web Worker and respawn the worker on trap. Domain failures (invalid specs, bad data, impossible rules) are reported as `EngineError[]` or vetoes and never cause traps.
147
148
 
148
149
  ## Related
149
150
 
@@ -13,7 +13,7 @@ export class Engine {
13
13
  [Symbol.dispose](): void;
14
14
  /**
15
15
  * Download Lemma source for a registry identifier via [`crate::registry::LemmaBase`]. Returns `{ source, id }`.
16
- * Does not load this [`WasmEngine`]; call [`Self::load_batch`], etc., yourself.
16
+ * Does not load this [`WasmEngine`]; call [`Self::load`] with `{ [id]: source }`.
17
17
  */
18
18
  fetch(name: string): Promise<any>;
19
19
  /**
@@ -21,43 +21,39 @@ export class Engine {
21
21
  */
22
22
  format(code: string, attribute?: string | null): any;
23
23
  /**
24
- * Canonical Lemma source for `repository`, formatted from the in-engine AST (e.g. `"lemma"`).
24
+ * Resource limits configured for this engine.
25
25
  */
26
- format_repository(repository: string): string;
26
+ limits(): any;
27
27
  /**
28
- * Same data as [`Engine::list`]: grouped [`ResolvedRepository`] JSON without planning.
28
+ * Catalog of loaded repositories and specs (metadata only, no source).
29
29
  */
30
30
  list(): any;
31
31
  /**
32
- * Load Lemma source. Throws with an array of serialized errors
33
- * (same shape as `EngineError` in `engine/packages/npm/lemma.d.ts`).
34
- */
35
- load(code: string, attribute: string): void;
36
- /**
37
- * Load multiple Lemma sources in one planning pass (same as [`Engine::load_batch`]).
38
- *
39
- * `sources` is a plain object mapping path labels to source text. Labels become
40
- * [`SourceType::Path`]; use `""` as a key for [`SourceType::Volatile`].
32
+ * Load Lemma source(s).
41
33
  *
42
- * `dependency`: when non-empty after trim, sources are tagged as that dependency id.
34
+ * - string one volatile workspace source
35
+ * - plain object or `[label, code][]` → labeled sources in one planning pass
43
36
  *
44
- * Throws with an array of `JsError` on failure.
37
+ * Throws with an array of serialized errors on failure. `null` / `undefined` are rejected.
45
38
  */
46
- load_batch(sources: any, dependency?: string | null): void;
39
+ load(sources: any): void;
47
40
  constructor();
41
+ /**
42
+ * Remove a temporal spec slice. `effective`: ISO datetime string or omit for now.
43
+ */
44
+ remove(repository: string | null | undefined, spec: string, effective?: string | null): void;
48
45
  /**
49
46
  * Evaluate spec. Returns [`crate::evaluation::Response`] as a JS object. Throws on planning/runtime error.
50
- *
51
- * `repository`: repository qualifier (`@org/pkg`), or `null`/empty for workspace (same as
52
- * [`Engine::run`] `repo: None`).
53
47
  */
54
- run(repository: string | null | undefined, spec: string, rule_names: any, data_values: any, effective?: string | null, explain?: boolean | null): any;
48
+ run(repository: string | null | undefined, spec: string, effective: string | null | undefined, data_values: any, rule_names: any, explain?: boolean | null): any;
55
49
  /**
56
- * Planning schema for the spec ([`crate::planning::execution_plan::SpecSchema`]). Throws on error.
57
- *
58
- * `repository`: qualifier string or `null`/empty for workspace ([`Engine::schema`]).
50
+ * Spec interface and temporal window at `effective`. Lemma text is [`Self::source`].
51
+ */
52
+ show(repository: string | null | undefined, spec: string, effective?: string | null): any;
53
+ /**
54
+ * Formatted canonical Lemma source. Omit `spec` for whole-repository text.
59
55
  */
60
- schema(repository: string | null | undefined, spec: string, effective?: string | null): any;
56
+ source(repository?: string | null, spec?: string | null, effective?: string | null): string;
61
57
  }
62
58
 
63
59
  export class IntoUnderlyingByteSource {
@@ -123,16 +119,17 @@ export interface InitOutput {
123
119
  readonly __wbg_engine_free: (a: number, b: number) => void;
124
120
  readonly wasmengine_fetch: (a: number, b: number, c: number) => number;
125
121
  readonly wasmengine_format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
126
- readonly wasmengine_format_repository: (a: number, b: number, c: number, d: number) => void;
122
+ readonly wasmengine_limits: (a: number, b: number) => void;
127
123
  readonly wasmengine_list: (a: number, b: number) => void;
128
- readonly wasmengine_load: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
129
- readonly wasmengine_load_batch: (a: number, b: number, c: number, d: number, e: number) => void;
124
+ readonly wasmengine_load: (a: number, b: number, c: number) => void;
130
125
  readonly wasmengine_new: () => number;
126
+ readonly wasmengine_remove: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
131
127
  readonly wasmengine_run: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
132
- readonly wasmengine_schema: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
133
- readonly __wasm_bindgen_func_elem_12297: (a: number, b: number, c: number, d: number) => void;
134
- readonly __wasm_bindgen_func_elem_2740: (a: number, b: number, c: number, d: number) => void;
135
- readonly __wasm_bindgen_func_elem_12302: (a: number, b: number, c: number, d: number) => void;
128
+ readonly wasmengine_show: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
129
+ readonly wasmengine_source: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
130
+ readonly __wasm_bindgen_func_elem_12266: (a: number, b: number, c: number, d: number) => void;
131
+ readonly __wasm_bindgen_func_elem_2732: (a: number, b: number, c: number, d: number) => void;
132
+ readonly __wasm_bindgen_func_elem_12283: (a: number, b: number, c: number, d: number) => void;
136
133
  readonly __wbindgen_export: (a: number, b: number) => number;
137
134
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
138
135
  readonly __wbindgen_export3: (a: number) => void;
package/lemma.bindings.js CHANGED
@@ -13,7 +13,7 @@ export class Engine {
13
13
  }
14
14
  /**
15
15
  * Download Lemma source for a registry identifier via [`crate::registry::LemmaBase`]. Returns `{ source, id }`.
16
- * Does not load this [`WasmEngine`]; call [`Self::load_batch`], etc., yourself.
16
+ * Does not load this [`WasmEngine`]; call [`Self::load`] with `{ [id]: source }`.
17
17
  * @param {string} name
18
18
  * @returns {Promise<any>}
19
19
  */
@@ -49,38 +49,26 @@ export class Engine {
49
49
  }
50
50
  }
51
51
  /**
52
- * Canonical Lemma source for `repository`, formatted from the in-engine AST (e.g. `"lemma"`).
53
- * @param {string} repository
54
- * @returns {string}
52
+ * Resource limits configured for this engine.
53
+ * @returns {any}
55
54
  */
56
- format_repository(repository) {
57
- let deferred3_0;
58
- let deferred3_1;
55
+ limits() {
59
56
  try {
60
57
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
61
- const ptr0 = passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
62
- const len0 = WASM_VECTOR_LEN;
63
- wasm.wasmengine_format_repository(retptr, this.__wbg_ptr, ptr0, len0);
58
+ wasm.wasmengine_limits(retptr, this.__wbg_ptr);
64
59
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
65
60
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
66
61
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
67
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
68
- var ptr2 = r0;
69
- var len2 = r1;
70
- if (r3) {
71
- ptr2 = 0; len2 = 0;
72
- throw takeObject(r2);
62
+ if (r2) {
63
+ throw takeObject(r1);
73
64
  }
74
- deferred3_0 = ptr2;
75
- deferred3_1 = len2;
76
- return getStringFromWasm0(ptr2, len2);
65
+ return takeObject(r0);
77
66
  } finally {
78
67
  wasm.__wbindgen_add_to_stack_pointer(16);
79
- wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
80
68
  }
81
69
  }
82
70
  /**
83
- * Same data as [`Engine::list`]: grouped [`ResolvedRepository`] JSON without planning.
71
+ * Catalog of loaded repositories and specs (metadata only, no source).
84
72
  * @returns {any}
85
73
  */
86
74
  list() {
@@ -99,19 +87,18 @@ export class Engine {
99
87
  }
100
88
  }
101
89
  /**
102
- * Load Lemma source. Throws with an array of serialized errors
103
- * (same shape as `EngineError` in `engine/packages/npm/lemma.d.ts`).
104
- * @param {string} code
105
- * @param {string} attribute
90
+ * Load Lemma source(s).
91
+ *
92
+ * - string → one volatile workspace source
93
+ * - plain object or `[label, code][]` → labeled sources in one planning pass
94
+ *
95
+ * Throws with an array of serialized errors on failure. `null` / `undefined` are rejected.
96
+ * @param {any} sources
106
97
  */
107
- load(code, attribute) {
98
+ load(sources) {
108
99
  try {
109
100
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
110
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
111
- const len0 = WASM_VECTOR_LEN;
112
- const ptr1 = passStringToWasm0(attribute, wasm.__wbindgen_export, wasm.__wbindgen_export2);
113
- const len1 = WASM_VECTOR_LEN;
114
- wasm.wasmengine_load(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
101
+ wasm.wasmengine_load(retptr, this.__wbg_ptr, addHeapObject(sources));
115
102
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
116
103
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
117
104
  if (r1) {
@@ -121,24 +108,28 @@ export class Engine {
121
108
  wasm.__wbindgen_add_to_stack_pointer(16);
122
109
  }
123
110
  }
111
+ constructor() {
112
+ const ret = wasm.wasmengine_new();
113
+ this.__wbg_ptr = ret;
114
+ EngineFinalization.register(this, this.__wbg_ptr, this);
115
+ return this;
116
+ }
124
117
  /**
125
- * Load multiple Lemma sources in one planning pass (same as [`Engine::load_batch`]).
126
- *
127
- * `sources` is a plain object mapping path labels to source text. Labels become
128
- * [`SourceType::Path`]; use `""` as a key for [`SourceType::Volatile`].
129
- *
130
- * `dependency`: when non-empty after trim, sources are tagged as that dependency id.
131
- *
132
- * Throws with an array of `JsError` on failure.
133
- * @param {any} sources
134
- * @param {string | null} [dependency]
118
+ * Remove a temporal spec slice. `effective`: ISO datetime string or omit for now.
119
+ * @param {string | null | undefined} repository
120
+ * @param {string} spec
121
+ * @param {string | null} [effective]
135
122
  */
136
- load_batch(sources, dependency) {
123
+ remove(repository, spec, effective) {
137
124
  try {
138
125
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
139
- var ptr0 = isLikeNone(dependency) ? 0 : passStringToWasm0(dependency, wasm.__wbindgen_export, wasm.__wbindgen_export2);
126
+ var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
140
127
  var len0 = WASM_VECTOR_LEN;
141
- wasm.wasmengine_load_batch(retptr, this.__wbg_ptr, addHeapObject(sources), ptr0, len0);
128
+ const ptr1 = passStringToWasm0(spec, wasm.__wbindgen_export, wasm.__wbindgen_export2);
129
+ const len1 = WASM_VECTOR_LEN;
130
+ var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
131
+ var len2 = WASM_VECTOR_LEN;
132
+ wasm.wasmengine_remove(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
142
133
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
143
134
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
144
135
  if (r1) {
@@ -148,26 +139,17 @@ export class Engine {
148
139
  wasm.__wbindgen_add_to_stack_pointer(16);
149
140
  }
150
141
  }
151
- constructor() {
152
- const ret = wasm.wasmengine_new();
153
- this.__wbg_ptr = ret;
154
- EngineFinalization.register(this, this.__wbg_ptr, this);
155
- return this;
156
- }
157
142
  /**
158
143
  * Evaluate spec. Returns [`crate::evaluation::Response`] as a JS object. Throws on planning/runtime error.
159
- *
160
- * `repository`: repository qualifier (`@org/pkg`), or `null`/empty for workspace (same as
161
- * [`Engine::run`] `repo: None`).
162
144
  * @param {string | null | undefined} repository
163
145
  * @param {string} spec
164
- * @param {any} rule_names
146
+ * @param {string | null | undefined} effective
165
147
  * @param {any} data_values
166
- * @param {string | null} [effective]
148
+ * @param {any} rule_names
167
149
  * @param {boolean | null} [explain]
168
150
  * @returns {any}
169
151
  */
170
- run(repository, spec, rule_names, data_values, effective, explain) {
152
+ run(repository, spec, effective, data_values, rule_names, explain) {
171
153
  try {
172
154
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
173
155
  var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -176,7 +158,7 @@ export class Engine {
176
158
  const len1 = WASM_VECTOR_LEN;
177
159
  var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
178
160
  var len2 = WASM_VECTOR_LEN;
179
- wasm.wasmengine_run(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(rule_names), addHeapObject(data_values), ptr2, len2, isLikeNone(explain) ? 0xFFFFFF : explain ? 1 : 0);
161
+ wasm.wasmengine_run(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(data_values), addHeapObject(rule_names), isLikeNone(explain) ? 0xFFFFFF : explain ? 1 : 0);
180
162
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
181
163
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
182
164
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -189,15 +171,13 @@ export class Engine {
189
171
  }
190
172
  }
191
173
  /**
192
- * Planning schema for the spec ([`crate::planning::execution_plan::SpecSchema`]). Throws on error.
193
- *
194
- * `repository`: qualifier string or `null`/empty for workspace ([`Engine::schema`]).
174
+ * Spec interface and temporal window at `effective`. Lemma text is [`Self::source`].
195
175
  * @param {string | null | undefined} repository
196
176
  * @param {string} spec
197
177
  * @param {string | null} [effective]
198
178
  * @returns {any}
199
179
  */
200
- schema(repository, spec, effective) {
180
+ show(repository, spec, effective) {
201
181
  try {
202
182
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
203
183
  var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -206,7 +186,7 @@ export class Engine {
206
186
  const len1 = WASM_VECTOR_LEN;
207
187
  var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
208
188
  var len2 = WASM_VECTOR_LEN;
209
- wasm.wasmengine_schema(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
189
+ wasm.wasmengine_show(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
210
190
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
211
191
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
212
192
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -218,6 +198,43 @@ export class Engine {
218
198
  wasm.__wbindgen_add_to_stack_pointer(16);
219
199
  }
220
200
  }
201
+ /**
202
+ * Formatted canonical Lemma source. Omit `spec` for whole-repository text.
203
+ * @param {string | null} [repository]
204
+ * @param {string | null} [spec]
205
+ * @param {string | null} [effective]
206
+ * @returns {string}
207
+ */
208
+ source(repository, spec, effective) {
209
+ let deferred5_0;
210
+ let deferred5_1;
211
+ try {
212
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
213
+ var ptr0 = isLikeNone(repository) ? 0 : passStringToWasm0(repository, wasm.__wbindgen_export, wasm.__wbindgen_export2);
214
+ var len0 = WASM_VECTOR_LEN;
215
+ var ptr1 = isLikeNone(spec) ? 0 : passStringToWasm0(spec, wasm.__wbindgen_export, wasm.__wbindgen_export2);
216
+ var len1 = WASM_VECTOR_LEN;
217
+ var ptr2 = isLikeNone(effective) ? 0 : passStringToWasm0(effective, wasm.__wbindgen_export, wasm.__wbindgen_export2);
218
+ var len2 = WASM_VECTOR_LEN;
219
+ wasm.wasmengine_source(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
220
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
221
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
222
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
223
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
224
+ var ptr4 = r0;
225
+ var len4 = r1;
226
+ if (r3) {
227
+ ptr4 = 0; len4 = 0;
228
+ throw takeObject(r2);
229
+ }
230
+ deferred5_0 = ptr4;
231
+ deferred5_1 = len4;
232
+ return getStringFromWasm0(ptr4, len4);
233
+ } finally {
234
+ wasm.__wbindgen_add_to_stack_pointer(16);
235
+ wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
236
+ }
237
+ }
221
238
  }
222
239
  if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
223
240
 
@@ -513,6 +530,10 @@ function __wbg_get_imports() {
513
530
  const ret = fetch(getObject(arg0));
514
531
  return addHeapObject(ret);
515
532
  },
533
+ __wbg_from_fa561fa561dc8031: function(arg0) {
534
+ const ret = Array.from(getObject(arg0));
535
+ return addHeapObject(ret);
536
+ },
516
537
  __wbg_getTime_09f1dd40a44edb30: function(arg0) {
517
538
  const ret = getObject(arg0).getTime();
518
539
  return ret;
@@ -587,6 +608,10 @@ function __wbg_get_imports() {
587
608
  const ret = result;
588
609
  return ret;
589
610
  },
611
+ __wbg_isArray_74b636a53056fecb: function(arg0) {
612
+ const ret = Array.isArray(getObject(arg0));
613
+ return ret;
614
+ },
590
615
  __wbg_isArray_94898ed3aad6947b: function(arg0) {
591
616
  const ret = Array.isArray(getObject(arg0));
592
617
  return ret;
@@ -666,7 +691,7 @@ function __wbg_get_imports() {
666
691
  const a = state0.a;
667
692
  state0.a = 0;
668
693
  try {
669
- return __wasm_bindgen_func_elem_12302(a, state0.b, arg0, arg1);
694
+ return __wasm_bindgen_func_elem_12283(a, state0.b, arg0, arg1);
670
695
  } finally {
671
696
  state0.a = a;
672
697
  }
@@ -825,13 +850,13 @@ function __wbg_get_imports() {
825
850
  return addHeapObject(ret);
826
851
  },
827
852
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
828
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1414, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
829
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12297);
853
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1402, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
854
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12266);
830
855
  return addHeapObject(ret);
831
856
  },
832
857
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
833
858
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IteratorResult<any>")], shim_idx: 7, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
834
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2740);
859
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2732);
835
860
  return addHeapObject(ret);
836
861
  },
837
862
  __wbindgen_cast_0000000000000003: function(arg0) {
@@ -868,10 +893,10 @@ function __wbg_get_imports() {
868
893
  };
869
894
  }
870
895
 
871
- function __wasm_bindgen_func_elem_12297(arg0, arg1, arg2) {
896
+ function __wasm_bindgen_func_elem_12266(arg0, arg1, arg2) {
872
897
  try {
873
898
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
874
- wasm.__wasm_bindgen_func_elem_12297(retptr, arg0, arg1, addHeapObject(arg2));
899
+ wasm.__wasm_bindgen_func_elem_12266(retptr, arg0, arg1, addHeapObject(arg2));
875
900
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
876
901
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
877
902
  if (r1) {
@@ -882,10 +907,10 @@ function __wasm_bindgen_func_elem_12297(arg0, arg1, arg2) {
882
907
  }
883
908
  }
884
909
 
885
- function __wasm_bindgen_func_elem_2740(arg0, arg1, arg2) {
910
+ function __wasm_bindgen_func_elem_2732(arg0, arg1, arg2) {
886
911
  try {
887
912
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
888
- wasm.__wasm_bindgen_func_elem_2740(retptr, arg0, arg1, addHeapObject(arg2));
913
+ wasm.__wasm_bindgen_func_elem_2732(retptr, arg0, arg1, addHeapObject(arg2));
889
914
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
890
915
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
891
916
  if (r1) {
@@ -896,8 +921,8 @@ function __wasm_bindgen_func_elem_2740(arg0, arg1, arg2) {
896
921
  }
897
922
  }
898
923
 
899
- function __wasm_bindgen_func_elem_12302(arg0, arg1, arg2, arg3) {
900
- wasm.__wasm_bindgen_func_elem_12302(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
924
+ function __wasm_bindgen_func_elem_12283(arg0, arg1, arg2, arg3) {
925
+ wasm.__wasm_bindgen_func_elem_12283(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
901
926
  }
902
927
 
903
928