pub struct Database { /* private fields */ }Expand description
Database connection wrapper with thread-safe access
Implementations§
Source§impl Database
impl Database
Sourcepub fn insert_artifact(&self, artifact: &Artifact) -> Result<()>
pub fn insert_artifact(&self, artifact: &Artifact) -> Result<()>
Sourcepub fn insert_spans(&self, spans: &[Span]) -> Result<()>
pub fn insert_spans(&self, spans: &[Span]) -> Result<()>
Sourcepub fn get_vector_index(&self) -> Result<Arc<VectorIndex>>
pub fn get_vector_index(&self) -> Result<Arc<VectorIndex>>
Get or build the cached vector index
The index is cached and only rebuilt when data changes (on ingest). Phase 2.1: Tries to load from disk first, then builds if needed.
§Returns
A reference-counted vector index
Sourcepub fn get_vector_index_with_kind(
&self,
) -> Result<(Arc<VectorIndex>, IndexLoadKind)>
pub fn get_vector_index_with_kind( &self, ) -> Result<(Arc<VectorIndex>, IndexLoadKind)>
Get or build the cached vector index and return how it was obtained
Returns the index and an indicator of whether it was loaded from cache or freshly built from spans.
Sourcepub fn get_all_spans(&self) -> Result<Vec<Span>>
pub fn get_all_spans(&self) -> Result<Vec<Span>>
Sourcepub fn get_artifact_by_path(&self, path: &str) -> Result<Option<Artifact>>
pub fn get_artifact_by_path(&self, path: &str) -> Result<Option<Artifact>>
Get artifact by path
Returns the artifact row matching the unique path, if present.
Sourcepub fn determine_ingest_action(
&self,
path: &str,
content_hash: &str,
) -> Result<IngestAction>
pub fn determine_ingest_action( &self, path: &str, content_hash: &str, ) -> Result<IngestAction>
Determine what action to take when ingesting a document
Compares content hash to detect if document needs update or can be skipped.
§Arguments
path- The document pathcontent_hash- SHA256 hash of the new content
§Returns
IngestAction::Skipif document exists with same content hashIngestAction::Updateif document exists but content changedIngestAction::Createif document doesn’t exist
Sourcepub fn delete_artifact(&self, artifact_id: &str) -> Result<usize>
pub fn delete_artifact(&self, artifact_id: &str) -> Result<usize>
Sourcepub fn create_session(
&self,
user_id: Option<&str>,
title: Option<&str>,
) -> Result<Session>
pub fn create_session( &self, user_id: Option<&str>, title: Option<&str>, ) -> Result<Session>
Sourcepub fn list_sessions(
&self,
user_id: Option<&str>,
limit: Option<usize>,
) -> Result<Vec<Session>>
pub fn list_sessions( &self, user_id: Option<&str>, limit: Option<usize>, ) -> Result<Vec<Session>>
Sourcepub fn update_session(
&self,
session_id: &str,
title: Option<&str>,
metadata: Option<&Value>,
) -> Result<()>
pub fn update_session( &self, session_id: &str, title: Option<&str>, metadata: Option<&Value>, ) -> Result<()>
Sourcepub fn delete_session(&self, session_id: &str) -> Result<()>
pub fn delete_session(&self, session_id: &str) -> Result<()>
Sourcepub fn add_message(
&self,
session_id: &str,
role: MessageRole,
content: &str,
metadata: Option<&Value>,
) -> Result<Message>
pub fn add_message( &self, session_id: &str, role: MessageRole, content: &str, metadata: Option<&Value>, ) -> Result<Message>
Sourcepub fn associate_working_set(
&self,
session_id: &str,
message_id: Option<&str>,
working_set: &WorkingSet,
query: &str,
config: &CompilerConfig,
) -> Result<SessionWorkingSet>
pub fn associate_working_set( &self, session_id: &str, message_id: Option<&str>, working_set: &WorkingSet, query: &str, config: &CompilerConfig, ) -> Result<SessionWorkingSet>
Associate a working set with a session
§Arguments
session_id- The session IDmessage_id- Optional message ID that triggered this compilationworking_set- The working set to associatequery- Query that generated this working setconfig- Configuration used for compilation
§Returns
The newly created SessionWorkingSet
Sourcepub fn get_session_full(
&self,
session_id: &str,
) -> Result<Option<SessionWithMessages>>
pub fn get_session_full( &self, session_id: &str, ) -> Result<Option<SessionWithMessages>>
Sourcepub fn register_agent(&self, agent: &Agent) -> Result<Agent>
pub fn register_agent(&self, agent: &Agent) -> Result<Agent>
Sourcepub fn get_agent_by_name(&self, name: &str) -> Result<Option<Agent>>
pub fn get_agent_by_name(&self, name: &str) -> Result<Option<Agent>>
Get an agent by name within a session (looks up by session participants)
Sourcepub fn list_agents(&self) -> Result<Vec<Agent>>
pub fn list_agents(&self) -> Result<Vec<Agent>>
List all registered agents
Sourcepub fn add_agent_relation(
&self,
session_id: &str,
message_id: &str,
from_agent_id: &str,
target_message_id: &str,
stance: Stance,
) -> Result<AgentRelation>
pub fn add_agent_relation( &self, session_id: &str, message_id: &str, from_agent_id: &str, target_message_id: &str, stance: Stance, ) -> Result<AgentRelation>
Add an agent relation (agreement, disagreement, etc.)
Automatically resolves message IDs to agent IDs for proper tracking
Sourcepub fn get_agent_relations(
&self,
session_id: &str,
) -> Result<AgentRelationSummary>
pub fn get_agent_relations( &self, session_id: &str, ) -> Result<AgentRelationSummary>
Get all agent relations for a session with resolved names
Sourcepub fn get_session_agents(&self, session_id: &str) -> Result<Vec<Agent>>
pub fn get_session_agents(&self, session_id: &str) -> Result<Vec<Agent>>
Get agents participating in a session (from their messages)
Sourcepub async fn as_storage_backend(&self) -> Result<SqliteBackend>
pub async fn as_storage_backend(&self) -> Result<SqliteBackend>
Convert this Database to a SqliteBackend for use with the StorageBackend trait
This allows existing code using Database to interoperate with code expecting a StorageBackend implementation.
§Returns
A SqliteBackend wrapping this database’s path
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more