pub struct Database { /* private fields */ }Implementations§
Source§impl Database
impl Database
pub fn open(path: &Path) -> Result<Database, DbError>
pub fn conn(&self) -> &Connection
pub fn path(&self) -> &Path
pub fn insert_drawer(&self, drawer: &Drawer) -> Result<bool, DbError>
pub fn taxonomy_entries(&self) -> Result<Vec<TaxonomyEntry>, DbError>
pub fn upsert_taxonomy_entry( &self, entry: &TaxonomyEntry, ) -> Result<(), DbError>
Sourcepub fn top_drawers(&self, limit: usize) -> Result<Vec<Drawer>, DbError>
pub fn top_drawers(&self, limit: usize) -> Result<Vec<Drawer>, DbError>
Returns top drawers sorted by importance (descending), then recency.
pub fn drawer_exists(&self, drawer_id: &str) -> Result<bool, DbError>
pub fn insert_vector( &self, drawer_id: &str, vector: &[f32], ) -> Result<(), DbError>
pub fn upsert_drawer_and_replace_vector( &self, drawer: &Drawer, vector: &[f32], ) -> Result<(), DbError>
pub fn drawer_count(&self) -> Result<i64, DbError>
pub fn stale_drawer_count( &self, current_normalize_version: u32, ) -> Result<i64, DbError>
pub fn drawer_count_by_normalize_version( &self, ) -> Result<Vec<(u32, i64)>, DbError>
pub fn diary_rollup_days(&self) -> Result<u32, DbError>
pub fn reindex_sources_stale( &self, current_normalize_version: u32, ) -> Result<Vec<ReindexSource>, DbError>
pub fn reindex_sources_force(&self) -> Result<Vec<ReindexSource>, DbError>
Sourcepub fn replace_active_source_drawers(
&self,
source_file: &str,
wing: &str,
room: Option<&str>,
) -> Result<u64, DbError>
pub fn replace_active_source_drawers( &self, source_file: &str, wing: &str, room: Option<&str>, ) -> Result<u64, DbError>
Hard-delete the active drawers for a source scoped to a specific room (NULL room matches NULL room), removing their FTS and vector rows too.
Use this when the caller knows the exact room the drawers live in.
For reindex, prefer [replace_active_source_drawers_across_rooms]:
re-ingesting a physical source may re-route it to a different room, and
a room-scoped delete would miss the stale drawers in the old room and
leave duplicates behind.
Sourcepub fn replace_active_source_drawers_across_rooms(
&self,
source_file: &str,
wing: &str,
) -> Result<u64, DbError>
pub fn replace_active_source_drawers_across_rooms( &self, source_file: &str, wing: &str, ) -> Result<u64, DbError>
Hard-delete the active drawers for a source across ALL rooms in a wing.
This is the correct replace semantics for reindex: a physical source file maps to one logical source, so re-indexing it should keep only the freshly produced drawers regardless of which room each previous version was routed into. Without this, a source that auto-routes to a new room on reindex leaves its old-room drawers behind as duplicates.
pub fn taxonomy_count(&self) -> Result<i64, DbError>
pub fn scope_counts( &self, ) -> Result<Vec<(String, Option<String>, i64)>, DbError>
Sourcepub fn distill_field_counts(&self) -> Result<Vec<(String, i64, i64)>, DbError>
pub fn distill_field_counts(&self) -> Result<Vec<(String, i64, i64)>, DbError>
Per-field counts for the P106 distill signal: active evidence drawers and
active promoted-or-canonical knowledge drawers, grouped by field.
Read-only; performs no writes.
Sourcepub fn sample_evidence_drawer_ids(
&self,
field: &str,
limit: usize,
) -> Result<Vec<String>, DbError>
pub fn sample_evidence_drawer_ids( &self, field: &str, limit: usize, ) -> Result<Vec<String>, DbError>
Up to limit active evidence drawer ids for a field, ordered by rowid
for deterministic sampling. Read-only; performs no writes.
pub fn get_drawer(&self, drawer_id: &str) -> Result<Option<Drawer>, DbError>
pub fn update_knowledge_lifecycle( &self, drawer_id: &str, status: &KnowledgeStatus, verification_refs: &[String], counterexample_refs: &[String], ) -> Result<bool, DbError>
pub fn update_knowledge_anchor( &self, drawer_id: &str, anchor_kind: &AnchorKind, anchor_id: &str, parent_anchor_id: Option<&str>, ) -> Result<bool, DbError>
pub fn insert_knowledge_card(&self, card: &KnowledgeCard) -> Result<(), DbError>
pub fn get_knowledge_card( &self, card_id: &str, ) -> Result<Option<KnowledgeCard>, DbError>
pub fn list_knowledge_cards( &self, filter: &KnowledgeCardFilter, ) -> Result<Vec<KnowledgeCard>, DbError>
pub fn knowledge_card_count(&self) -> Result<i64, DbError>
pub fn insert_runtime_adoption_event( &self, event: &RuntimeAdoptionEvent, ) -> Result<(), DbError>
pub fn list_runtime_adoption_events( &self, filter: &RuntimeAdoptionFilter, limit: usize, ) -> Result<Vec<RuntimeAdoptionEvent>, DbError>
pub fn list_knowledge_drawers_for_card_backfill( &self, filter: &KnowledgeCardFilter, ) -> Result<Vec<Drawer>, DbError>
pub fn update_knowledge_card( &self, card: &KnowledgeCard, ) -> Result<bool, DbError>
pub fn insert_knowledge_evidence_link( &self, link: &KnowledgeEvidenceLink, ) -> Result<(), DbError>
pub fn knowledge_evidence_links( &self, card_id: &str, ) -> Result<Vec<KnowledgeEvidenceLink>, DbError>
pub fn knowledge_evidence_links_for_drawer( &self, evidence_drawer_id: &str, ) -> Result<Vec<KnowledgeEvidenceLink>, DbError>
pub fn append_knowledge_event( &self, event: &KnowledgeCardEvent, ) -> Result<(), DbError>
pub fn knowledge_events( &self, card_id: &str, ) -> Result<Vec<KnowledgeCardEvent>, DbError>
pub fn neighbor_chunks( &self, source_file: &str, wing: &str, room: Option<&str>, chunk_index: i64, ) -> Result<ChunkNeighbors, DbError>
pub fn soft_delete_drawer(&self, drawer_id: &str) -> Result<bool, DbError>
pub fn purge_deleted(&self, before: Option<&str>) -> Result<u64, DbError>
pub fn deleted_drawer_count(&self) -> Result<i64, DbError>
pub fn search_fts( &self, query: &str, wing: Option<&str>, room: Option<&str>, limit: usize, ) -> Result<Vec<(String, f64)>, DbError>
pub fn insert_triple(&self, triple: &Triple) -> Result<(), DbError>
pub fn query_triples( &self, subject: Option<&str>, predicate: Option<&str>, object: Option<&str>, active_only: bool, ) -> Result<Vec<Triple>, DbError>
pub fn invalidate_triple(&self, triple_id: &str) -> Result<bool, DbError>
pub fn triple_count(&self) -> Result<i64, DbError>
pub fn timeline_for_entity(&self, entity: &str) -> Result<Vec<Triple>, DbError>
pub fn triple_stats(&self) -> Result<TripleStats, DbError>
pub fn find_tunnels(&self) -> Result<Vec<(String, Vec<String>)>, DbError>
pub fn create_tunnel( &self, left: &TunnelEndpoint, right: &TunnelEndpoint, label: &str, created_by: Option<&str>, ) -> Result<ExplicitTunnel, DbError>
pub fn list_explicit_tunnels( &self, wing: Option<&str>, ) -> Result<Vec<ExplicitTunnel>, DbError>
pub fn delete_explicit_tunnel(&self, tunnel_id: &str) -> Result<bool, DbError>
pub fn follow_explicit_tunnels( &self, from: &TunnelEndpoint, max_hops: u8, ) -> Result<Vec<TunnelFollowResult>, DbError>
pub fn explicit_tunnel_hints( &self, wing: &str, room: Option<&str>, ) -> Result<Vec<String>, DbError>
Sourcepub fn embedding_dim(&self) -> Result<Option<usize>, DbError>
pub fn embedding_dim(&self) -> Result<Option<usize>, DbError>
Returns the current embedding dimension from the vec0 table, or None if the table is empty.
Sourcepub fn recreate_vectors_table(&self, dim: usize) -> Result<(), DbError>
pub fn recreate_vectors_table(&self, dim: usize) -> Result<(), DbError>
Drop and recreate the drawer_vectors table with the specified dimension. All existing vectors are lost — caller must re-embed after this.
Sourcepub fn all_active_drawers(&self) -> Result<Vec<(String, String)>, DbError>
pub fn all_active_drawers(&self) -> Result<Vec<(String, String)>, DbError>
Returns all active (non-deleted) drawer IDs and their content for re-embedding.
pub fn database_size_bytes(&self) -> Result<u64, DbError>
pub fn schema_version(&self) -> Result<u32, DbError>
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl !Sync for Database
impl !UnwindSafe for Database
impl Send for Database
impl Unpin for Database
impl UnsafeUnpin 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> 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