Facade and independent verifier for an ordered Domain ledger.
A logical append is a non-empty atomic batch. Callers supply both an
expected_revision CAS fence and a stable batch_id. Retrying the identical
logical batch is idempotent; reusing its identity for different contents is
rejected.
The verifier consumes the exported entry chain directly. It does not consult runtime projections, cached authority, or a store-specific index.
Summary
Functions
Returns the stable digest identifying a logical batch request.
Exports a verified Domain ledger as portable plain data.
Exports a runtime snapshot without including store projections.
Returns a verified snapshot of a Domain ledger.
Reads and verifies only the entries after an already verified prefix.
Looks up the durable identity and revision range of a prior batch.
Independently verifies an exported ledger and returns its reconstructed view.
Loads and independently verifies the export produced by a store.
Types
@type batch_id() :: String.t()
@type batch_info() :: %{ batch_id: batch_id(), identity_digest: Spectre.GAM.Ledger.Entry.digest(), expected_revision: non_neg_integer(), first_revision: pos_integer(), last_revision: pos_integer(), entry_count: pos_integer(), head_digest: Spectre.GAM.Ledger.Entry.digest() }
@type cursor() :: %{ revision: non_neg_integer(), head_digest: Spectre.GAM.Ledger.Entry.digest() }
@type domain_ref() :: String.t()
@type snapshot() :: %{ :domain_ref => domain_ref(), :revision => non_neg_integer(), :head_digest => Spectre.GAM.Ledger.Entry.digest(), :entries => [Spectre.GAM.Ledger.Entry.t()], optional(:recovery) => map() | nil }
Functions
@spec batch_identity(domain_ref(), batch_id(), [map()], non_neg_integer()) :: {:ok, Spectre.GAM.Ledger.Entry.digest()} | {:error, term()}
Returns the stable digest identifying a logical batch request.
@spec export(Spectre.GAM.Ledger.Store.config(), domain_ref(), keyword()) :: :not_found | {:ok, map()} | {:error, term()}
Exports a verified Domain ledger as portable plain data.
Exports a runtime snapshot without including store projections.
@spec load(Spectre.GAM.Ledger.Store.config(), domain_ref(), keyword()) :: :not_found | {:ok, snapshot()} | {:error, term()}
Returns a verified snapshot of a Domain ledger.
@spec load_from(Spectre.GAM.Ledger.Store.config(), domain_ref(), cursor(), keyword()) :: :not_found | {:ok, snapshot()} | {:error, term()}
Reads and verifies only the entries after an already verified prefix.
The cursor must identify a complete batch boundary held by the caller. This is not an independent audit or a way to trust an arbitrary persisted cache: only the suffix is checked against that predecessor. Revisions, digests, Domain binding, complete batches and the captured head are still verified.
@spec lookup_batch( Spectre.GAM.Ledger.Store.config(), domain_ref(), batch_id(), keyword() ) :: :not_found | {:ok, batch_info()} | {:error, term()}
Looks up the durable identity and revision range of a prior batch.
Independently verifies an exported ledger and returns its reconstructed view.
Verification covers canonical entry digests, revision continuity, the previous-digest chain, Domain binding, batch contiguity, and export summary.
@spec verify_store(Spectre.GAM.Ledger.Store.config(), domain_ref(), keyword()) :: :not_found | {:ok, snapshot()} | {:error, term()}
Loads and independently verifies the export produced by a store.