Spectre.Runtime.Persistence (Spectre v0.3.0)

Copy Markdown View Source

State and memory persistence boundaries for Spectre.Runtime.

Loads state through the configured adapter (supporting compare-and-swap and legacy arities), persists advanced state with revision fencing, classifies ambiguous adapter outcomes so they are never blindly retried, and invokes the memory adapter for recall and persistence with bounded payload sizes.

Summary

Functions

Persists the executable state exactly once before an effect runs.

Recalls memory through an explicit option or the configured adapter.

Loads initial state from an explicit option or the configured adapter.

Persists state, then memory, honoring the memory failure policy.

Persists the advanced state revision through the configured adapter.

Functions

ensure_execution_state_persisted(result, ctx)

@spec ensure_execution_state_persisted(Spectre.Result.t(), Spectre.Context.t()) ::
  {:ok, Spectre.Result.t()} | {:error, term()}

Persists the executable state exactly once before an effect runs.

load_memory(agent, input, state, opts)

@spec load_memory(module(), Spectre.Input.t(), Spectre.State.t(), keyword()) ::
  {:ok, term()} | {:error, term()}

Recalls memory through an explicit option or the configured adapter.

load_state(agent, input, opts)

@spec load_state(module(), Spectre.Input.t(), keyword()) ::
  {:ok, Spectre.State.t()} | {:error, term()}

Loads initial state from an explicit option or the configured adapter.

persist(result, ctx)

@spec persist(Spectre.Result.t(), Spectre.Context.t()) ::
  {:ok, Spectre.Result.t()} | {:error, term()}

Persists state, then memory, honoring the memory failure policy.

persist_state(result, ctx)

@spec persist_state(Spectre.Result.t(), Spectre.Context.t()) ::
  {:ok, Spectre.Result.t()} | {:error, term()}

Persists the advanced state revision through the configured adapter.