Adapter contract and guarded invocation facade for Domain ledgers.
Store adapters must make each batch atomically visible, enforce
expected_revision, and treat an uncertain append acknowledgement as
{:error, :ambiguous}. A successful append may only be returned after the
adapter's advertised durability boundary has acknowledged the batch.
ExGAM.Ledger.Store.Support contains portable shape and option helpers for
adapter authors. It deliberately does not abstract transactions, locks,
encoding, recovery or durability: those guarantees stay visible in each
concrete store.
Summary
Callbacks
Atomically appends a batch at its expected predecessor revision and returns the committed revision.
Exports one coherent Domain snapshot in the canonical GAM ledger format.
Captures the committed head without loading historical entries.
Loads a coherent history snapshot for the Domain, or returns :not_found.
Optionally reads entries strictly after a revision and returns the corresponding snapshot head.
Looks up a previously committed idempotency batch by its Domain and batch ID.
Reads exactly one complete batch beginning at first_revision.
Functions
Whether an adapter implements native batch paging and a lightweight head read.
Reads the advertised head; it does not authenticate a projection checkpoint.
Reads a coherent suffix after a revision, with the captured ledger head.
Normalizes a Store module or {module, options} pair.
Reads one indexed batch; unsupported adapters return an explicit error.
Types
Callbacks
@callback append(domain_ref(), batch_id(), [map()], non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, :conflict} | {:error, :ambiguous} | {:error, term()}
Atomically appends a batch at its expected predecessor revision and returns the committed revision.
@callback export(domain_ref(), keyword()) :: :not_found | {:ok, map()} | {:error, term()}
Exports one coherent Domain snapshot in the canonical GAM ledger format.
@callback head(domain_ref(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.cursor()} | {:error, term()}
Captures the committed head without loading historical entries.
@callback load(domain_ref(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.snapshot()} | {:error, term()}
Loads a coherent history snapshot for the Domain, or returns :not_found.
@callback load_from(domain_ref(), non_neg_integer(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.snapshot()} | {:error, term()}
Optionally reads entries strictly after a revision and returns the corresponding snapshot head.
@callback lookup_batch(domain_ref(), batch_id(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.batch_info()} | {:error, term()}
Looks up a previously committed idempotency batch by its Domain and batch ID.
@callback read_batch(domain_ref(), pos_integer(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.snapshot()} | {:error, term()}
Reads exactly one complete batch beginning at first_revision.
This is the paging unit: a batch is already bounded by Entry's admission limits and must never be split across semantic folds. Implementations must use indexed reads, not load the entire ledger and slice it. The returned snapshot describes the batch end, not the current Domain head. Its chain must still be verified against the caller's trusted predecessor.
Functions
Whether an adapter implements native batch paging and a lightweight head read.
@spec head(config(), domain_ref(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.cursor()} | {:error, term()}
Reads the advertised head; it does not authenticate a projection checkpoint.
@spec load_from(config(), domain_ref(), non_neg_integer(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.snapshot()} | {:error, term()}
Reads a coherent suffix after a revision, with the captured ledger head.
Native adapters can use their revision index. Adapters without this optional
callback fall back to a verified full read. The caller must verify the suffix
against its trusted predecessor; use ExGAM.Ledger.load_from/4 for that.
Normalizes a Store module or {module, options} pair.
@spec read_batch(config(), domain_ref(), pos_integer(), keyword()) :: :not_found | {:ok, ExGAM.Ledger.snapshot()} | {:error, term()}
Reads one indexed batch; unsupported adapters return an explicit error.