Skip to main content

Database

Struct Database 

Source
pub struct Database { /* private fields */ }

Implementations§

Source§

impl Database

Source

pub fn open(path: &Path) -> Result<Self, DbError>

Source

pub fn conn(&self) -> &Connection

Source

pub fn path(&self) -> &Path

Source

pub fn insert_drawer(&self, drawer: &Drawer) -> Result<bool, DbError>

Source

pub fn taxonomy_entries(&self) -> Result<Vec<TaxonomyEntry>, DbError>

Source

pub fn upsert_taxonomy_entry( &self, entry: &TaxonomyEntry, ) -> Result<(), DbError>

Source

pub fn top_drawers(&self, limit: usize) -> Result<Vec<Drawer>, DbError>

Returns top drawers sorted by importance (descending), then recency.

Source

pub fn drawer_exists(&self, drawer_id: &str) -> Result<bool, DbError>

Source

pub fn insert_vector( &self, drawer_id: &str, vector: &[f32], ) -> Result<(), DbError>

Source

pub fn upsert_drawer_and_replace_vector( &self, drawer: &Drawer, vector: &[f32], ) -> Result<(), DbError>

Source

pub fn drawer_count(&self) -> Result<i64, DbError>

Source

pub fn stale_drawer_count( &self, current_normalize_version: u32, ) -> Result<i64, DbError>

Source

pub fn drawer_count_by_normalize_version( &self, ) -> Result<Vec<(u32, i64)>, DbError>

Source

pub fn diary_rollup_days(&self) -> Result<u32, DbError>

Source

pub fn reindex_sources_stale( &self, current_normalize_version: u32, ) -> Result<Vec<ReindexSource>, DbError>

Source

pub fn reindex_sources_force(&self) -> Result<Vec<ReindexSource>, DbError>

Source

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.

Source

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.

Source

pub fn taxonomy_count(&self) -> Result<i64, DbError>

Source

pub fn scope_counts( &self, ) -> Result<Vec<(String, Option<String>, i64)>, DbError>

Source

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.

Source

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.

Source

pub fn get_drawer(&self, drawer_id: &str) -> Result<Option<Drawer>, DbError>

Source

pub fn update_knowledge_lifecycle( &self, drawer_id: &str, status: &KnowledgeStatus, verification_refs: &[String], counterexample_refs: &[String], ) -> Result<bool, DbError>

Source

pub fn update_knowledge_anchor( &self, drawer_id: &str, anchor_kind: &AnchorKind, anchor_id: &str, parent_anchor_id: Option<&str>, ) -> Result<bool, DbError>

Source

pub fn insert_knowledge_card(&self, card: &KnowledgeCard) -> Result<(), DbError>

Source

pub fn get_knowledge_card( &self, card_id: &str, ) -> Result<Option<KnowledgeCard>, DbError>

Source

pub fn list_knowledge_cards( &self, filter: &KnowledgeCardFilter, ) -> Result<Vec<KnowledgeCard>, DbError>

Source

pub fn knowledge_card_count(&self) -> Result<i64, DbError>

Source

pub fn insert_runtime_adoption_event( &self, event: &RuntimeAdoptionEvent, ) -> Result<(), DbError>

Source

pub fn list_runtime_adoption_events( &self, filter: &RuntimeAdoptionFilter, limit: usize, ) -> Result<Vec<RuntimeAdoptionEvent>, DbError>

Source

pub fn list_knowledge_drawers_for_card_backfill( &self, filter: &KnowledgeCardFilter, ) -> Result<Vec<Drawer>, DbError>

Source

pub fn update_knowledge_card( &self, card: &KnowledgeCard, ) -> Result<bool, DbError>

Source

pub fn append_knowledge_event( &self, event: &KnowledgeCardEvent, ) -> Result<(), DbError>

Source

pub fn knowledge_events( &self, card_id: &str, ) -> Result<Vec<KnowledgeCardEvent>, DbError>

Source

pub fn neighbor_chunks( &self, source_file: &str, wing: &str, room: Option<&str>, chunk_index: i64, ) -> Result<ChunkNeighbors, DbError>

Source

pub fn soft_delete_drawer(&self, drawer_id: &str) -> Result<bool, DbError>

Source

pub fn purge_deleted(&self, before: Option<&str>) -> Result<u64, DbError>

Source

pub fn deleted_drawer_count(&self) -> Result<i64, DbError>

Source

pub fn search_fts( &self, query: &str, wing: Option<&str>, room: Option<&str>, limit: usize, ) -> Result<Vec<(String, f64)>, DbError>

Source

pub fn insert_triple(&self, triple: &Triple) -> Result<(), DbError>

Source

pub fn query_triples( &self, subject: Option<&str>, predicate: Option<&str>, object: Option<&str>, active_only: bool, ) -> Result<Vec<Triple>, DbError>

Source

pub fn invalidate_triple(&self, triple_id: &str) -> Result<bool, DbError>

Source

pub fn triple_count(&self) -> Result<i64, DbError>

Source

pub fn timeline_for_entity(&self, entity: &str) -> Result<Vec<Triple>, DbError>

Source

pub fn triple_stats(&self) -> Result<TripleStats, DbError>

Source

pub fn find_tunnels(&self) -> Result<Vec<(String, Vec<String>)>, DbError>

Source

pub fn create_tunnel( &self, left: &TunnelEndpoint, right: &TunnelEndpoint, label: &str, created_by: Option<&str>, ) -> Result<ExplicitTunnel, DbError>

Source

pub fn list_explicit_tunnels( &self, wing: Option<&str>, ) -> Result<Vec<ExplicitTunnel>, DbError>

Source

pub fn delete_explicit_tunnel(&self, tunnel_id: &str) -> Result<bool, DbError>

Source

pub fn follow_explicit_tunnels( &self, from: &TunnelEndpoint, max_hops: u8, ) -> Result<Vec<TunnelFollowResult>, DbError>

Source

pub fn explicit_tunnel_hints( &self, wing: &str, room: Option<&str>, ) -> Result<Vec<String>, DbError>

Source

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.

Source

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.

Source

pub fn all_active_drawers(&self) -> Result<Vec<(String, String)>, DbError>

Returns all active (non-deleted) drawer IDs and their content for re-embedding.

Source

pub fn database_size_bytes(&self) -> Result<u64, DbError>

Source

pub fn schema_version(&self) -> Result<u32, DbError>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.