Saga Journal
Pluggable append-only event log for saga executions.
Each saga run appends entries in the following lifecycle order:
EntryPhase.Started — emitted once, seq = 0.
EntryPhase.Intent / EntryPhase.Effect — one pair per successful step.
EntryPhase.Compensation — for each step rolled back (with JournalEntry.reverses set).
EntryPhase.Terminal — emitted once as the final entry.
Implementation contract
Implementations MUST:
Be thread-safe — multiple concurrent saga runs may append simultaneously.
Preserve insertion order within a single RunId.
Assign monotonic, gapless
seqvalues within a RunId starting at 0.Treat
payloadbytes as opaque — never inspect or transform them.
Implementations SHOULD:
Make
appenddurable before returning JournalOutcome.Ok (audit-grade consumers depend on it).Respect coroutine cancellation in all suspend operations.
All operations return JournalOutcome instead of kotlin.Result to avoid historical compiler restrictions on kotlin.Result in suspend-interface positions (critic A2 HIGH).
Parameters
Payload type. InMemorySagaJournal stores P directly; persistent adapters use a PayloadCodec to convert to/from ByteArray.
Inheritors
Functions
Appends entry to the journal.
Returns all entries for runId in insertion order.
Returns up to limit entries for runId whose JournalEntry.seq>= seq.
Verifies the tamper-evident hash chain for runId over entries with seq in [fromSeq, toSeq].