Behaviour for the event-history journal.
Two adapters ship with v0.1:
Continuum.Runtime.Journal.InMemory— process-level state for tests and single-node hello-world. No durability.Continuum.Runtime.Journal.Postgres— Ecto-backed durable journal with transactional appends and lease-token fencing.
All append operations carry a lease_token (or nil for unleased
in-memory / pre-dispatch execution). The Postgres adapter rejects writes
whose token does not match the run row's fencing token; nil only writes
to unleased rows.
Summary
Callbacks
Journal the parent's view of a child's terminal state, or report :pending.
Look up the run record. Returns nil if no such run, or a map with at
least :state, :result, :error keys (atoms / terms — already decoded).
Start a child run and journal child.started_event on the parent.
Callbacks
@callback await_child_terminal!( instance :: Continuum.Runtime.Instance.t(), parent_run_id :: binary(), child_run_id :: binary(), command_id :: term(), seq :: non_neg_integer(), lease_token :: integer() | nil ) :: {:completed, term(), map()} | {:failed, term(), map()} | {:cancelled, map()} | :pending
Journal the parent's view of a child's terminal state, or report :pending.
Returns the winner event alongside the outcome so the parent can advance its cursor over exactly the event that was appended.
Look up the run record. Returns nil if no such run, or a map with at
least :state, :result, :error keys (atoms / terms — already decoded).
@callback load_with_snapshot( instance :: Continuum.Runtime.Instance.t(), run_id :: binary(), lease_token :: integer() | nil ) :: {Continuum.Snapshot.t() | nil, [map()]}
@callback start_child!( instance :: Continuum.Runtime.Instance.t(), parent_run_id :: binary(), child :: map(), lease_token :: integer() | nil ) :: :ok
Start a child run and journal child.started_event on the parent.
Optional: a journal that does not export it makes await child and
start_child/3 unavailable, and the effect raises with that explanation
rather than silently doing nothing.
child carries :child_run_id, :workflow, :input, :parent_command_id,
:trace_context, and :started_event.
@callback take_snapshot!( instance :: Continuum.Runtime.Instance.t(), snapshot :: Continuum.Snapshot.t() ) :: :ok