Concurrent calls share a single module compile (per chosen bridge) via
modulePromiseByBridge.
This IS the authoritative Rust engine, and it was not until
causl/causl-wasm-ts#279 slice S12a. From Phase 1 (iasbuilt/causl#1065) until that slice
the WasmBackend this returns wrapped a pure-TypeScript Graph as its
#graph and answered nine of its twelve BackendEngine members off it,
which is why the paragraph that stood here said the opposite and told the
reader never to route the real engine through this function. S12a deleted
the wrap: instantiateBackend compiles the artefact, attaches the exports
and enables the authoritative engine, so getAuthoritativeEngine() answers
and __graph is gone. test/wasm-backend-engine-backed-279.test.ts pins
all three claims, including behaviourally: a value committed through this
backend is read back out of the engine that accepted the commit.
It remains a BackendEngine, which is a twelve-member surface with no
derived registration on it, and it remains the shape the cross-backend
determinism gate (#685) and the snapshot/hydrate round-trip (#687) drive.
What changed is which implementation answers, not what the surface is.
An adopter still wants preloadCauslWasm() + createCauslWasmSync() rather
than this: those return a Graph, the seven-method surface the package
documents, and they stamp the per-graph engine identity. #122 retired the
createCausl({ backend: 'auto' }) auto-migration that used to "migrate"
onto this loader, and 'auto' is now a documented alias for the registry
FLIP (wasm-when-preloaded), so this loader is on no adopter
engine-selection path.
The WasmBackendUnavailableError class is retained for the narrow case
where the loader is asked for a bridge id whose host preconditions are not
met.
import { loadWasmBackend } from '@causl/causl-wasm-ts/wasm'
// The determinism-gate surface, over the Rust engine.
const backend = await loadWasmBackend()
const commit = backend.commit('intent', new Map([['x', 1]]))
RemovedEngineOptionError when the bag still carries
engine / backend / fallbackToTs / fallbackToJs. This loader was the
MOST dangerous of the six bag-taking entry points to leave unguarded, and
the reason is now historical: its return value used to be a TypeScript wrap,
so a bag reading { engine: 'rust-ssot' }, a caller explicitly naming the
Rust engine, was answered with the TypeScript closure in silence. S12a
removed the wrap and #279 slice S12 removed the closure, so there is no
second engine for the option to select. The guard stays because the options
are removed rather than ignored, and a bag carrying one is a caller working
from a 0.4.x mental model who is owed a refusal.
Lazy-load a bare WasmBackend
BackendEngine.