Keep::Log
The append-only log of commits, as a C0 stream-mode file.
log = Keep::Log.open("book.log") log.append(at: "2026-09-21 16:26", origin: "cli", kind: "ledger", summary: "…") do |c| c.action("record", 41, "2026-09-03", "Market run", "", ["Expenses:Food", "4820", "Assets:Checking", "-4820"]) end log.each_commit(after: 38) { |commit| … } log.fold(state, after: 38) { |state, action| apply(state, action) }
Layout: a preamble block (GS keep/1), then one block per commit — a
commit record followed by one record per action — each ended by ETB.
Constructors
Instance methods
Append one commit. Assigns the next sequence number under the lock and writes the block and its ETB as a single append.
Commits after after, in order, revert marks resolved over the whole log.
Apply the actions of every non-reverted, non-mark commit after after
to state, in order. Returns the version folded to.
Run the block holding an exclusive advisory lock on the log, so two
processes can't assign the same sequence number. Reentrant on the same
Log instance (an application holding the lock around append-plus-
checkpoint calls append, which locks again). Keep sections short.
True if a mark after after targets a commit at or before it — in
which case a state folded up to after can't be advanced by applying
only later commits; fold from scratch instead.
Mark seq reverted. Raises if it doesn't exist, is itself a mark, or
is already reverted.