StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
Show 28 methods // Required methods fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(usize, usize, usize)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn insert_artifact<'life0, 'life1, 'async_trait>( &'life0 self, artifact: &'life1 Artifact, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_artifact<'life0, 'life1, 'async_trait>( &'life0 self, artifact_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Artifact>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_artifact_by_path<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Artifact>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_artifact<'life0, 'life1, 'async_trait>( &'life0 self, artifact_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn determine_ingest_action<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, content_hash: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<IngestAction>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn insert_spans<'life0, 'life1, 'async_trait>( &'life0 self, spans: &'life1 [Span], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_all_spans<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn search_spans<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_vector_search<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VectorSearchProvider>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn invalidate_vector_index<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: Option<&'life1 str>, title: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Session>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_sessions<'life0, 'life1, 'async_trait>( &'life0 self, user_id: Option<&'life1 str>, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Session>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: &'life1 str, title: Option<&'life2 str>, metadata: Option<&'life3 Value>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn delete_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: &'life1 str, role: MessageRole, content: &'life2 str, metadata: Option<&'life3 Value>, ) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn get_messages<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn associate_working_set<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: &'life1 str, message_id: Option<&'life2 str>, working_set: &'life3 WorkingSet, query: &'life4 str, config: &'life5 CompilerConfig, ) -> Pin<Box<dyn Future<Output = Result<SessionWorkingSet>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait; fn get_session_full<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionWithMessages>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn register_agent<'life0, 'life1, 'async_trait>( &'life0 self, agent: &'life1 Agent, ) -> Pin<Box<dyn Future<Output = Result<Agent>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_agent<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Agent>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_agent_by_name<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Agent>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_agents<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Agent>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_agent_relation<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, session_id: &'life1 str, message_id: &'life2 str, from_agent_id: &'life3 str, target_message_id: &'life4 str, stance: Stance, ) -> Pin<Box<dyn Future<Output = Result<AgentRelation>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait; fn get_agent_relations<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<AgentRelationSummary>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_session_agents<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Agent>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait;
}
Expand description

Main storage backend trait

Implementations must be Send + Sync for use in async contexts. All methods are async to support both sync (SQLite) and async (PostgreSQL) backends.

Required Methods§

Source

fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(usize, usize, usize)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get database statistics

§Returns

Tuple of (artifacts_count, spans_count, total_tokens)

Source

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

Clear all data from the database

Source

fn insert_artifact<'life0, 'life1, 'async_trait>( &'life0 self, artifact: &'life1 Artifact, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert an artifact

Source

fn get_artifact<'life0, 'life1, 'async_trait>( &'life0 self, artifact_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Artifact>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get artifact by ID

Source

fn get_artifact_by_path<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Artifact>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get artifact by path

Source

fn delete_artifact<'life0, 'life1, 'async_trait>( &'life0 self, artifact_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete artifact and associated spans

§Returns

Number of spans deleted

Source

fn determine_ingest_action<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, content_hash: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<IngestAction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Determine what action to take when ingesting a file

Source

fn insert_spans<'life0, 'life1, 'async_trait>( &'life0 self, spans: &'life1 [Span], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert multiple spans in a transaction

Source

fn get_all_spans<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all spans (for index building)

Source

fn search_spans<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search spans by text (lexical search)

Get the vector search provider for this backend

For SQLite, this builds/loads an HNSW index. For PostgreSQL, this uses pgvector queries.

Source

fn invalidate_vector_index<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Invalidate cached vector index (called after data changes)

Source

fn create_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: Option<&'life1 str>, title: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Session>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a new session

Source

fn get_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get session by ID

Source

fn list_sessions<'life0, 'life1, 'async_trait>( &'life0 self, user_id: Option<&'life1 str>, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List sessions with optional filtering

Source

fn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: &'life1 str, title: Option<&'life2 str>, metadata: Option<&'life3 Value>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Update session metadata

Source

fn delete_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete session and all associated data

Source

fn add_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: &'life1 str, role: MessageRole, content: &'life2 str, metadata: Option<&'life3 Value>, ) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add message to session

Source

fn get_messages<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get messages for session

Source

fn associate_working_set<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: &'life1 str, message_id: Option<&'life2 str>, working_set: &'life3 WorkingSet, query: &'life4 str, config: &'life5 CompilerConfig, ) -> Pin<Box<dyn Future<Output = Result<SessionWorkingSet>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Associate working set with session

Source

fn get_session_full<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionWithMessages>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get full session with messages and working sets

Source

fn register_agent<'life0, 'life1, 'async_trait>( &'life0 self, agent: &'life1 Agent, ) -> Pin<Box<dyn Future<Output = Result<Agent>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Register an agent (insert or update)

Source

fn get_agent<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Agent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get agent by ID

Source

fn get_agent_by_name<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Agent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get agent by name

Source

fn list_agents<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Agent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all registered agents

Source

fn add_agent_relation<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, session_id: &'life1 str, message_id: &'life2 str, from_agent_id: &'life3 str, target_message_id: &'life4 str, stance: Stance, ) -> Pin<Box<dyn Future<Output = Result<AgentRelation>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Add agent relation (agreement, disagreement, etc.)

Source

fn get_agent_relations<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<AgentRelationSummary>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get agent relations for session with resolved names

Source

fn get_session_agents<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Agent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get agents participating in session

Implementors§