• Construct a fresh Causl graph at GraphTime t₀ = 0.

    Implements the canonical primitive surface — input, derived, commit, read, subscribe, subscribeCommits, explain — plus the second-tier extensions commitLog, exportModel, simulate, snapshot, snapshotAt, hydrate, readAt, and the now accessor. Each non-canonical row earned its slot by naming a concept the engine cannot otherwise express: the commit log realises the "transaction log is a Behavior" promise; export is the bridge to the bounded model checker; simulate is the §5 dry-run API that lets a caller predict a commit's effect without committing; snapshot/hydrate/readAt are SSR transfer, persistence, and time-travel; now lets external observers ask "what time is it?" without firing a commit.

    Parameters

    • options: CreateCauslOptions = {}

      Engine-wide knobs: history cap and observer-error handler.

    Returns Graph

    A Graph instance whose lifetime is owned by the caller.

    The closure returned here owns every piece of mutable state the engine touches. There is no module-level state and no implicit singleton — each call yields an independent universe with its own GraphTime. This is the smallest example the engine must support: an input, a derivation, a subscription, and a commit that fires exactly one notification when the downstream value actually changes. If this works, the engine is real; everything else is downstream of getting it right.

    A WasmEngineUnavailableError (code === 'CAUSL_WASM_ENGINE_UNAVAILABLE') when the @causl/causl-wasm-ts/wasmsubpath was never imported, or when it was and the WasmGC engine cannot instantiate on this host; aCauslWasmNotPreloadedError (code === 'CAUSL_WASM_NOT_PRELOADED') when the subpath is imported but preloadCauslWasm() has not resolved. Branch on error.code, not on instanceof: the never-imported case is thrown by the main bundle's own leak-free twin, which cannot extend a /wasm class.

    const graph = createCausl()
    const a = graph.input('a', 1)
    const b = graph.input('b', 2)
    const sum = graph.derived('sum', (get) => get(a) + get(b))
    graph.subscribe(sum, (v) => console.log(v)) // 3
    graph.commit('bump', tx => tx.set(a, 10)) // 12