pub struct SessionStore { /* private fields */ }Expand description
A thread-safe store of investigation sessions.
Cloning shares the same underlying state; clones are cheap. The store is
bounded by a SessionConfig so it is safe to keep alive for the lifetime
of a long-running MCP server without unbounded memory growth.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty store with SessionConfig::default bounds.
Sourcepub fn with_config(config: SessionConfig) -> Self
pub fn with_config(config: SessionConfig) -> Self
Create an empty store with explicit eviction bounds.
Sourcepub fn config(&self) -> &SessionConfig
pub fn config(&self) -> &SessionConfig
The eviction bounds in effect for this store.
Sourcepub fn record(
&self,
session_id: &str,
question: &str,
answer: &str,
) -> (usize, usize)
pub fn record( &self, session_id: &str, question: &str, answer: &str, ) -> (usize, usize)
Record a completed turn for session_id, creating the session if needed.
Returns the new turn index (0-based) and the total turn count.
Eviction bounds from the SessionConfig are enforced here: expired
sessions are pruned, this session’s oldest turns are dropped past
max_turns_per_session, and
least-recently-active sessions are evicted past
max_sessions.
Sourcepub fn history(&self, session_id: &str) -> Vec<InvestigationTurn>
pub fn history(&self, session_id: &str) -> Vec<InvestigationTurn>
Return a snapshot of a session’s turns, or an empty vec if unknown.
Sourcepub fn recent_history(
&self,
session_id: &str,
n: usize,
) -> Vec<InvestigationTurn>
pub fn recent_history( &self, session_id: &str, n: usize, ) -> Vec<InvestigationTurn>
Return up to the n most recent turns of a session in chronological
order, or an empty vec if the session is unknown.
This is the bounded counterpart to history: callers
that only fold a few recent turns into a prompt should prefer it, since
it clones at most n turns rather than the whole (capped) history.
Sourcepub fn snapshot(&self, session_id: &str) -> Option<InvestigationState>
pub fn snapshot(&self, session_id: &str) -> Option<InvestigationState>
Return a full snapshot of a session, if it exists.
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
The number of active sessions.
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Source§fn clone(&self) -> SessionStore
fn clone(&self) -> SessionStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more