pub trait RuntimeSessionPersistence: Send + Sync {
// Required method
fn save_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn checkpoint_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn load_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn append_token_usage_record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
json_line: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Port for runtime (non-authoritative) session persistence.
Implementors must:
- Serialize concurrent saves per session ID.
- Merge on-disk authoritative metadata (
title,pinned,title_version,metadata_version) before writing, so UI edits are never clobbered.
Required Methods§
Sourcefn save_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn save_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Persist the session, merging any newer authoritative metadata from disk.
Provided Methods§
Sourcefn checkpoint_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn checkpoint_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Append-safe checkpoint used at the shared engine execute boundary.
Unlike save_runtime_session, this must
preserve messages that were appended durably by a concurrent writer
after the runner loaded its snapshot. Implementations that can provide
a per-session transaction should override this method and perform the
load/merge/save under one lock. The default still reconciles against a
latest snapshot for lightweight/custom SDK persisters; the built-in
storage implementation supplies the atomic variant.
Sourcefn load_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn load_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Load the latest runtime-visible session snapshot when the persistence implementation can coordinate reads. Tools may update a repository-owned clone while an agent loop holds its own live Session; the loop uses this hook to merge narrowly-scoped tool side effects before its next save.
Sourcefn append_token_usage_record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
json_line: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn append_token_usage_record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
json_line: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Append one JSON-line analysis record to the session’s append-only
token-usage log (see Storage::append_token_usage_record). Defaults to
a no-op so non-file-backed persisters are unaffected.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl RuntimeSessionPersistence for LockedSessionStore
Infrastructure implementation of the domain runtime-persistence port.
Server should assemble this as Arc<dyn RuntimeSessionPersistence> and must
not define a separate adapter layer for the same behavior.
impl RuntimeSessionPersistence for LockedSessionStore
Infrastructure implementation of the domain runtime-persistence port.
Server should assemble this as Arc<dyn RuntimeSessionPersistence> and must
not define a separate adapter layer for the same behavior.
fn save_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
LockedSessionStore: 'async_trait,
fn checkpoint_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
LockedSessionStore: 'async_trait,
fn load_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
LockedSessionStore: 'async_trait,
Source§impl<T> RuntimeSessionPersistence for Arc<T>where
T: RuntimeSessionPersistence + ?Sized,
impl<T> RuntimeSessionPersistence for Arc<T>where
T: RuntimeSessionPersistence + ?Sized,
fn save_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Arc<T>: 'async_trait,
fn checkpoint_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Arc<T>: 'async_trait,
fn load_runtime_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Arc<T>: 'async_trait,
fn append_token_usage_record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
json_line: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Arc<T>: 'async_trait,
Implementors§
impl RuntimeSessionPersistence for SessionRepository
SessionRepository is the canonical RuntimeSessionPersistence: the runtime
can persist a session through the same coordinator (merge-on-write + cache
refresh) instead of a bespoke adapter.