Skip to main content

Checkpointer

Trait Checkpointer 

Source
pub trait Checkpointer<S>:
    Send
    + Sync
    + 'static
where S: Clone + Send + Sync + 'static,
{ // Required methods fn put<'life0, 'async_trait>( &'life0 self, checkpoint: Checkpoint<S>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_latest<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>, Error>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn get_by_id<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, id: &'life2 CheckpointId, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>, Error>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait; fn list_history<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint<S>>, Error>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn update_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, parent_id: &'life2 CheckpointId, new_state: S, ) -> Pin<Box<dyn Future<Output = Result<CheckpointId, Error>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait; }
Expand description

Persistent (or in-memory) store of Checkpoint<S>s addressed by ThreadKey.

Implementors must be Send + Sync so a single instance can serve every concurrent invocation in a multi-pod deployment. The &ThreadKey parameter on every read/write enforces tenant scope at the type level — Invariant 11.

§S: Drop contract

Implementors may evict, replace, or reallocate stored values inside internal locks. S::drop therefore must not block — no block_on, no synchronous IO, no lock acquisition. Spawn a detached task or use a non-blocking sink instead. See §“Amendment 2026-04-30 — State drop semantics”.

Required Methods§

Source

fn put<'life0, 'async_trait>( &'life0 self, checkpoint: Checkpoint<S>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Persist a checkpoint. The checkpoint’s own (tenant_id, thread_id) fields define its addressing.

Source

fn get_latest<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Load the most recent checkpoint for key. Verb-family get per .claude/rules/naming.md — single-item primary- key (most-recent) lookup, returns Option<Checkpoint<S>>.

Source

fn get_by_id<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, id: &'life2 CheckpointId, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Look up a specific checkpoint by id within key’s scope. Verb-family get — primary-key lookup.

Source

fn list_history<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint<S>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Return the thread’s checkpoint history, most recent first. limit caps the result size (usize::MAX for “all”).

Source

fn update_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 ThreadKey, parent_id: &'life2 CheckpointId, new_state: S, ) -> Pin<Box<dyn Future<Output = Result<CheckpointId, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Time-travel write: create a fresh checkpoint that branches off parent_id, replacing only the state. The new checkpoint inherits next_node from its parent and records parent_id so history renders branches correctly.

Returns the new id. Returns Error::InvalidRequest if the parent does not exist for the supplied key.

Implementors§

Source§

impl<S> Checkpointer<S> for InMemoryCheckpointer<S>
where S: Clone + Send + Sync + 'static,

Source§

impl<S> Checkpointer<S> for PostgresCheckpointer<S>
where S: Clone + Send + Sync + Serialize + DeserializeOwned + 'static,

Source§

impl<S> Checkpointer<S> for RedisCheckpointer<S>
where S: Clone + Send + Sync + Serialize + DeserializeOwned + 'static,