Expand description
Session persistence layer
Provides pluggable session storage via the SessionStore trait.
§Default Implementation
FileSessionStore stores each session as a JSON file:
- Session metadata (id, name, timestamps)
- Configuration (system prompt, policies)
- Conversation history (messages)
- Context usage statistics
§Custom Backends
Implement SessionStore trait for custom backends (Redis, PostgreSQL, etc.):
ⓘ
use a3s_code::store::{
SessionData, SessionSnapshotV1, SessionStore, SessionStoreCapabilities,
};
struct RedisStore { /* ... */ }
#[async_trait::async_trait]
impl SessionStore for RedisStore {
// Required by AgentSession::save: commit the entire value in one
// backend transaction / atomic replacement.
async fn save_snapshot(&self, snapshot: &SessionSnapshotV1) -> Result<()> { /* ... */ }
async fn load_snapshot(&self, id: &str) -> Result<Option<SessionSnapshotV1>> { /* ... */ }
fn capabilities(&self) -> SessionStoreCapabilities {
SessionStoreCapabilities { atomic_session_snapshots: true }
}
// Legacy fragment APIs remain available for migration compatibility.
async fn save(&self, session: &SessionData) -> Result<()> { /* ... */ }
async fn load(&self, id: &str) -> Result<Option<SessionData>> { /* ... */ }
async fn delete(&self, id: &str) -> Result<()> { /* ... */ }
async fn list(&self) -> Result<Vec<String>> { /* ... */ }
async fn exists(&self, id: &str) -> Result<bool> { /* ... */ }
}Structs§
- Context
Usage - Context usage statistics persisted with saved sessions.
- File
Session Store - File-based session store.
- File
Session Store Wal - Durable append-only JSONL WAL under a FileSessionStore root.
- LlmConfig
Data - Serializable LLM configuration
- Memory
Session Store - In-memory session store for testing
- Session
Config - Serializable session configuration.
- Session
Data - Serializable session data for persistence
- Session
Snapshot V1 - A complete, versioned persistence generation for one session.
- Session
Store AtRest Cipher - AES-256-GCM cipher used by
super::FileSessionStorewhen constructed with an encryption key. - Session
Store Capabilities - Persistence guarantees advertised by a session store implementation.
- Session
Store Commit Event V1 - Notification that one complete session generation was committed.
- Session
Store Commit Watch - Subscription to durable snapshot commit notifications.
- Session
Store WalEntry V1 - One append-only WAL record for a FileSessionStore snapshot commit.
- Session
Store Writer Lease V1 - Durable writer lease published by a session store that advertises
super::SessionStoreCapabilities::lease_fencing.
Enums§
- Session
State - Session state persisted with saved sessions.
- Session
Store WalPhase V1 - Lifecycle phase of one WAL record for a session snapshot commit.
Constants§
- DEFAULT_
AUTO_ COMPACT_ THRESHOLD - Default auto-compact threshold (80% of context window).
- SESSION_
SNAPSHOT_ SCHEMA_ VERSION - Schema version written by
SessionSnapshotV1. - SESSION_
STORE_ COMMIT_ EVENT_ SCHEMA_ V1 - SESSION_
STORE_ WAL_ ENTRY_ SCHEMA_ V1 - SESSION_
STORE_ WRITER_ LEASE_ SCHEMA_ V1
Traits§
- Session
Store - Session storage trait
Functions§
- snapshot_
content_ digest - Digest a complete session snapshot for WAL identity fencing.