pub struct ThreadCommit {
pub thread_id: String,
pub message_delta: Vec<Message>,
pub expected_message_count: Option<u64>,
pub run_projection: RunRecord,
pub thread_state_snapshot: Option<PersistedState>,
}Expand description
One atomic thread commit.
The committed message log is append-only: message_delta is always a delta
appended to the thread’s committed log, guarded by expected_message_count
(the committed message count the caller observed, ADR-0042 D5). There is no
whole-list overwrite on the commit path — compaction is itself an append of a
summary message (see MessageRecord::compaction), never a rewrite.
Runtime-facing commits carry only thread durability data: thread id, message
delta, latest run projection, and an optional thread-state snapshot.
Server-side staged event/outbox writes are supplied through
awaken-server-contract.
Fields§
§thread_id: String§message_delta: Vec<Message>The delta appended to the committed log.
expected_message_count: Option<u64>Append version guard: the committed message count the caller observed.
run_projection: RunRecord§thread_state_snapshot: Option<PersistedState>Thread-scoped persisted state to write in the same transaction, if it
changed this checkpoint. None leaves the stored thread state untouched.
Run-scoped state stays on run (RunRecord::state); thread-scoped
state persists across runs (split by KeyScope).
Implementations§
Source§impl ThreadCommit
impl ThreadCommit
Sourcepub fn append_messages(
thread_id: impl Into<String>,
message_delta: Vec<Message>,
expected_message_count: Option<u64>,
run_projection: RunRecord,
) -> ThreadCommit
pub fn append_messages( thread_id: impl Into<String>, message_delta: Vec<Message>, expected_message_count: Option<u64>, run_projection: RunRecord, ) -> ThreadCommit
Build an append-delta commit: message_delta is appended to the
thread’s committed log, guarded by expected_message_count (the
committed message count the caller observed). No staged events.
Sourcepub fn append(
thread_id: impl Into<String>,
message_delta: Vec<Message>,
expected_message_count: Option<u64>,
run_projection: RunRecord,
) -> ThreadCommit
👎Deprecated since 0.6.0: Use append_messages.
pub fn append( thread_id: impl Into<String>, message_delta: Vec<Message>, expected_message_count: Option<u64>, run_projection: RunRecord, ) -> ThreadCommit
Use append_messages.
Compatibility constructor retained for legacy naming.
Sourcepub fn with_thread_state_snapshot(
self,
thread_state: PersistedState,
) -> ThreadCommit
pub fn with_thread_state_snapshot( self, thread_state: PersistedState, ) -> ThreadCommit
Attach thread-scoped state to persist atomically with this checkpoint.
Sourcepub fn with_thread_state(self, thread_state: PersistedState) -> ThreadCommit
👎Deprecated since 0.6.0: Use with_thread_state_snapshot.
pub fn with_thread_state(self, thread_state: PersistedState) -> ThreadCommit
Use with_thread_state_snapshot.
Compatibility setter retained for legacy naming.
Sourcepub fn run_projection_only(
thread_id: impl Into<String>,
run_projection: RunRecord,
) -> ThreadCommit
pub fn run_projection_only( thread_id: impl Into<String>, run_projection: RunRecord, ) -> ThreadCommit
Build an unguarded commit for run/state-only writes that add no
contended message delta. By construction this carries no message_delta: an
unguarded append of real message content could duplicate or reorder
committed messages under retry/concurrency, so the message delta is not
expressible here. To append a message delta, use Self::append_messages with an
explicit expected_message_count guard.
Sourcepub fn checkpoint_only(
thread_id: impl Into<String>,
run_projection: RunRecord,
) -> ThreadCommit
👎Deprecated since 0.6.0: Use run_projection_only.
pub fn checkpoint_only( thread_id: impl Into<String>, run_projection: RunRecord, ) -> ThreadCommit
Use run_projection_only.
Compatibility constructor retained for legacy naming.
Sourcepub fn validate(&self) -> Result<(), CommitError>
pub fn validate(&self) -> Result<(), CommitError>
Pre-commit validation that mirrors the runtime invariants.
Trait Implementations§
Source§impl Clone for ThreadCommit
impl Clone for ThreadCommit
Source§fn clone(&self) -> ThreadCommit
fn clone(&self) -> ThreadCommit
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more