Backplane. AgentRuntime. Store behaviour
(backplane_agent_runtime v1.6.0)
Copy Markdown
Runtime storage contract for versioned run transitions.
A record is accepted only when its expected revision is the currently committed revision. A successful commit returns the next revision and outbox intents. Hosts must execute effects only after that acknowledgement.
Durable adapters also atomically fence an older executor before recovery.
fence/6 compares both the committed revision and incarnation, advances both,
and returns the fenced run. It must not dispatch or replay any effect.
Summary
Functions
Atomically fences the committed incarnation of a durable run.
Callbacks
@callback acknowledge_commit(term(), map(), map()) :: {:ok, %{revision: non_neg_integer()}} | {:error, Backplane.AgentRuntime.Error.t()}
@callback capabilities() :: map()
@callback fence(term(), term(), non_neg_integer(), non_neg_integer(), pos_integer()) :: {:ok, %{revision: non_neg_integer(), run: map()}} | {:error, Backplane.AgentRuntime.Error.t()}
@callback load(term(), term(), keyword()) :: {:ok, map()} | {:error, Backplane.AgentRuntime.Error.t()}
@callback mode() :: :ephemeral | :durable
@callback new(non_neg_integer()) :: {:ok, term()}
@callback store(term(), map(), map()) :: {:ok, %{revision: non_neg_integer(), outbox: list()}} | {:error, Backplane.AgentRuntime.Error.t()}
Functions
@spec acknowledge_commit(module(), term(), term(), map()) :: {:ok, %{revision: non_neg_integer(), outbox: list()}} | {:error, Backplane.AgentRuntime.Error.t()}
@spec fence( module(), term(), term(), non_neg_integer(), non_neg_integer(), pos_integer() ) :: {:ok, %{revision: pos_integer(), run: map()}} | {:error, Backplane.AgentRuntime.Error.t()}
Atomically fences the committed incarnation of a durable run.
The adapter must compare expected_revision and current_incarnation in the
same durable transaction that writes next_incarnation and the next
revision. A stale executor therefore cannot regain ownership after restart.
@spec stage(module(), term(), map(), map()) :: {:ok, %{revision: non_neg_integer(), outbox: list(), stage: term()}} | {:error, Backplane.AgentRuntime.Error.t()}
@spec store(module(), term(), map(), map()) :: {:ok, %{revision: non_neg_integer(), outbox: list()}} | {:error, Backplane.AgentRuntime.Error.t()}
@spec validate_capabilities(module()) :: {:ok, map()} | {:error, Backplane.AgentRuntime.Error.t()}
@spec validate_durable_capabilities(module()) :: {:ok, map()} | {:error, Backplane.AgentRuntime.Error.t()}
@spec validate_mode(module()) :: {:ok, atom()} | {:error, Backplane.AgentRuntime.Error.t()}