Tide

state.* API

The untyped, ontology-neutral world-state surface.

state.* is the low-level, untyped surface for driving a host-supplied world state — the layer the typed ctx.argon client is built on. Reach for it when you want raw, string-keyed access; for everyday ontology work prefer the typed client (see Driving Argon).

The surface is ontology-neutral: it carries qualified names and JSON payloads, with no hardcoded domain concepts. Every call routes through Tide's journaled, replay-deterministic ops.

Surface

state.dispatchQuery(qualifiedName: string, args?: object, options?: object): Promise<unknown>
state.dispatchMutation(qualifiedName: string, args?: object, options?: object): Promise<unknown>
state.derive(name: string | { name: string }): Promise<unknown>
// A query: read at the run's pinned watermark (read-your-writes within the run).
const employees = await state.dispatchQuery("employment::all_employees", {});

// A mutation: journaled and exactly-once across replays. Run at the TOP LEVEL,
// not inside step().
await state.dispatchMutation("employment::hire", {
  employer: 1,
  employee: 2,
  salary: 120000,
});

// Materialize derived facts.
await state.derive("employment::employments");

qualifiedName is package::name. args is the call's argument object.

Host backing and default posture

state.* is served by a host-supplied StateHost. The shipped binary backs it with the embedded Argon engine (in-process, durable main world, fork-per-run isolation); tide run --argon <url> backs it with a remote ox runtime serve /v1 endpoint instead.

In the argon-free runtime with no state host, every state.* operation refuses deterministically with an unsupported-capability error — so a workflow that performs no state.* calls needs no backend at all.

Determinism rules

The same rules as the typed client apply, because the typed client is this surface underneath:

  • A mutation is journaled; on replay its recorded result is returned verbatim and the mutation never re-runs.
  • A query reads at the run's pinned transaction watermark and sees the run's own writes (read-your-writes).
  • A run's writes land in a per-run fork and reach the durable main world only when the run completes successfully.

Run mutations at the top level, never inside step(...) — a step retry cannot roll back an underlying world-state write, so it would double-apply.

  • Driving Argon — the typed client over this surface, plus durable worlds and testing.
  • Workflow APIctx and the globals.

On this page