ExGAM.Ledger.Reader (ExGAM v0.1.0)

Copy Markdown View Source

Verified, pull-based batch traversal of a captured ledger prefix.

Native adapters read one atomic batch at a time. The captured head fences traversal, so concurrent appends neither extend a recovery indefinitely nor change its result. Memory for ledger input is bounded by a batch, not by the age of the Domain; the reducer's accumulated state is a separate concern.

A missing page before the captured head is corruption, never end-of-stream. This reader does not trust checkpoint state: a caller starting after genesis must already possess a verified predecessor. Full audit remains independent. Reducers must not publish authority or perform external effects: only a successful result establishes agreement with the entire captured prefix.

Summary

Functions

Reduces verified batches from a predecessor cursor through one captured head.

Functions

reduce(store, domain_ref, cursor, initial, reducer, opts \\ [])

@spec reduce(
  ExGAM.Ledger.Store.config(),
  String.t(),
  ExGAM.Ledger.cursor(),
  term(),
  function(),
  keyword()
) :: :not_found | {:ok, term()} | {:error, term()}

Reduces verified batches from a predecessor cursor through one captured head.

The reducer receives (entries, accumulator) and must return {:ok, next} or an error. Missing history before the captured head is an error, not a partial success. :not_found means the store had no Domain at head capture. Starting at a nonzero cursor requires an independently verified predecessor; this function verifies the suffix, not the origin of supplied state.