@visiq/core-wasm
v0.1.14
Published
VisIQ governance core for Node.js — the one compiled Rust rule engine behind every VisIQ SDK, prebuilt to WebAssembly; evaluate(event, bundle) takes plain objects and synchronously returns a decision object.
Maintainers
Readme
@visiq/core-wasm
The VisIQ governance evaluation core (experiments/matrix-v2/visiq-core-rs, the ONE
compiled Rust engine) exposed to JavaScript/TypeScript via WebAssembly — so the TS SDK
evaluates through the same core the Go / Java / Ruby / Python bindings use, instead
of a parallel TS implementation that can drift.
const { evaluate } = require('@visiq/core-wasm');
// PLAIN OBJECTS IN, PLAIN OBJECT OUT — `evaluate` does the JSON marshalling
// itself. Do NOT pre-stringify: `evaluate(JSON.stringify(event), …)` double-
// encodes, the core sees a JSON *string* where an object belongs, and the
// decision comes back with `allowed: true` for an event policy DENIES.
const decision = evaluate(event, bundle);
if (!decision.allowed) {
// blocked by policy — do not execute the tool call
}- Synchronous, no async init.
--target nodejsglue instantiates the wasm from bytes atrequiretime (new WebAssembly.Module/Instance) — a drop-in for a sync call. (Node/server only; a browser build would need--target web+ async init.) evaluate(event, bundle) → decisiontakes and returns plain objects; the language-neutral seam underneath isevaluate_json(JSON string in, JSON string out), and this package's wrapper is what stringifies/parses around it. Fail-closed (G001) on malformed input — never throws.- Faithful.
node conformance.mjsproves it reproduces the frozen golden corpus (sdk-corpus/GOLDEN-oracle-vectors.json) — the same vectors every other binding reproduces. 118/118, 0 diverge.
Rebuild
./build.sh (needs rustup + wasm32-unknown-unknown + wasm-bindgen-cli =0.2.100;
the crate pins wasm-bindgen = "=0.2.100" so CLI/schema versions match).
Scope
evaluate returns the full decision object — {decision, allowed, reason, ruleId,
ruleCode, enforced, agentMode, action:{decision,argRedactionRules},
retrieval:{action,redactionRules}}. Matched-rule attribution (reason prose,
ruleId, ruleCode) IS emitted in-core; decisionId is not — it is minted by the
caller. @visiq/runtime declares this package a REQUIRED dependency and calls it the
sole decision engine, so the harness cutover is done, not pending. Remaining seams are
tracked in experiments/matrix-v2/visiq-core-rs/PARITY-GAPS.md.
