Backend engine contract — one implementation per backend (TS, WASM-GC, WASM-serde, future). The TS engine in graph.ts is routed through this interface in #681; the WASM engine plugs in here.

The shape mirrors the seven-method Graph surface plus the second-tier extensions (subscribeCommits, snapshot, hydrate, readAt, snapshotAt, exportModel, dispose, now, plus the #1068 evaluateStatechart SPEC §6 extension point). Cross-backend determinism (#685) is gated against this interface.

interface BackendEngine {
    now: number;
    commit(intent: string, writes: ReadonlyMap<string, unknown>): Commit;
    dispose(node: string): void;
    evaluateStatechart(input: StatechartInput): StatechartResult;
    exportModel(opts?: ExportModelOptions): CauslModel;
    hydrate(snap: GraphSnapshot): void;
    read(node: string): unknown;
    readAt(node: string, time: number): RetentionResult<unknown>;
    snapshot(): GraphSnapshot;
    snapshotAt(time: number): RetentionResult<GraphSnapshot>;
    subscribe<T>(node: string, observer: Observer<T>): Unsubscribe;
    subscribeCommits(observer: (commit: Commit) => void): Unsubscribe;
}

Properties

now: number

Methods

  • Parameters

    • intent: string
    • writes: ReadonlyMap<string, unknown>

    Returns Commit

  • Parameters

    • node: string

    Returns void

  • SPEC §6 composite-statechart extension point. Issue #1068 (deferred from #698). The WASM backend implements this via the Rust-side engine-rs-core::statechart_reducers enums (gated behind feature = "future") once Sub-D of EPIC #680 wires the bridge through.

    Parameters

    Returns StatechartResult

  • Parameters

    • node: string

    Returns unknown

  • Parameters

    • node: string
    • time: number

    Returns RetentionResult<unknown>

  • Parameters

    • observer: (commit: Commit) => void

    Returns Unsubscribe