propose

suspend fun propose(action: A): IndexedAction<A>

Proposes action for Raft replication and returns after a quorum commits it.

Applies action optimistically to speculativeState before suspending, so the UI reflects the move immediately. If the underlying TurnSequencer.propose fails, the speculative apply is rolled back — speculativeState reverts to the authoritative snapshot plus any remaining pending inputs. If SpeculativeGame.apply rejects action, its exception is rethrown here and nothing is proposed.

Throws

if the backing node has a us.tractat.kuilt.raft.ClientIdentity.Durable id, which refuses this form. The speculative apply is rolled back.

if the leader steps down while awaiting commit. The action is removed from the pending buffer and speculative state is rolled back. The outcome of the underlying proposal is unknown — the caller must treat it as lost and retry with an idempotent action or deduplication key.


suspend fun propose(action: A, requestId: Long): IndexedAction<A>

Proposes action with a caller-pinned requestId for cross-crash exactly-once, then returns after a quorum commits it (same semantics as propose).

Mirrors TurnSequencer.propose(action, requestId): replay the same requestId on a post-crash retry and the consumer's ClientSessionTable (and this sequencer's internal table) will skip the duplicate. requestId must be a per-client monotonic serial the caller owns — do not pass a log index or a random value. A retry must resend the same action, which must encode to the same bytes; a requestId names one action. If SpeculativeGame.apply rejects action, its exception is rethrown here and nothing is proposed.

A retry of an attempt that did commit can be answered from the leader's cache with no new commit, and nothing then retires its pending entry, so the prediction keeps the extra apply. That is tracked by #3064.

Throws

if the leader steps down while awaiting commit. The speculative apply is rolled back. The caller may retry with the same requestId.

if the leader still holds a committed result for requestId and action encodes differently. The speculative apply is rolled back; do not retry under the same requestId.