Expand description
The one durable transition protocol: prepare → CAS append → commit (spec §8.2, §8.3, §15.2).
This module is the state machine that sits between a WireEnvelope and a
KernelRecord. It owns exactly the decisions that must not be re-implemented per host:
whether an input is a replay, whether it may be accepted at all, which record it becomes, and
when the effects that record’s step planned become visible.
Four properties shape the API, and each is meant to be unrepresentable-if-violated rather than merely documented:
- Abort’s boundary is strictly before the append (§8.3). There is no state in which a
record is durable and still sits in the candidate slot, because
KernelTransaction::commitis the call a host makes after its CAS append succeeded, and it consumes the candidate. A host that gets an error out ofcommit, or crashes inside it, therefore has noabortto reach for — the transaction poisons itself and the only way forward isKernelTransaction::rebuild_from_records. “Append succeeded, commit failed, so we rolled back” is not a control flow this type can express. - Every rejection is byte-for-byte zero mutation (§15.2).
preparemutates nothing until the very last statement, which is the one that fills the candidate slot; the tests assert this by cloning the whole transaction and comparing it after a rejected prepare. - Idempotency is anchored on
input_id+ the durable journal (DEC-2), never on a bounded in-memory window. The lookup goes throughRecordIndex, whose production implementation reads the journal; the historical 256-entry FIFO turned “the same delivery arrived twice” into a fail-closed rejection as soon as the run got long enough. - An already-resolved effect resolves to
Replayed, never to a second record (DEC-1). Reporting that case asPreparedwhile returning the oldstep_seqis the live dead end this protocol exists to remove.
What this layer deliberately does not do: it never plans a step itself (the caller passes a planner, and Phase 3/4 supplies the real one), and it never rebuilds itself after a conflict — rebuild/retry is the host-side loop of Task 7b, and this module only offers it a verified entry point.
Structs§
- Checkpoint
Advice - The soft-watermark crossing of §12.3, with the numbers that justify it.
- Checkpoint
Boundary - The prefix a checkpoint would cover (§12.3).
- Committed
Transition - One durable transition, after the host’s append and this runtime’s commit.
- Durable
Head - The journal head this runtime believes in: the CAS precondition of the next append.
- InMemory
Record Index - In-memory
RecordIndex, for tests and for hosts whose journal is itself in memory (§8.4). - Kernel
Transaction - The prepare/commit/abort state machine of §8.2.
- Plan
Context - What the planner is given. Everything it needs to decide, and nothing that would let it depend
on the host’s wall clock or on a default that may drift between binaries:
configis the configuration this operation froze in its genesis record. - Tail
Usage - How much tail the operation is carrying since its last acked checkpoint.
Enums§
- Tail
Pressure - Where the tail sits against its bounds.
Fullis not a latch — an acked checkpoint moves it straight back toNominal.
Traits§
- Record
Index - Lookup from an
input_idto the record it already produced. - Transition
Step - The one thing the transaction layer needs to know about a planned step.