pub struct LineageGraph { /* private fields */ }Expand description
The Lineage Graph - stores and infers causal relationships
Implementations§
Source§impl LineageGraph
impl LineageGraph
Sourcepub fn with_config(db: Arc<DB>, config: InferenceConfig) -> Self
pub fn with_config(db: Arc<DB>, config: InferenceConfig) -> Self
Create with custom inference config
Sourcepub fn store_edge(&self, user_id: &str, edge: &LineageEdge) -> Result<()>
pub fn store_edge(&self, user_id: &str, edge: &LineageEdge) -> Result<()>
Store a lineage edge
Sourcepub fn get_edge(
&self,
user_id: &str,
edge_id: &str,
) -> Result<Option<LineageEdge>>
pub fn get_edge( &self, user_id: &str, edge_id: &str, ) -> Result<Option<LineageEdge>>
Get an edge by ID
Sourcepub fn delete_edge(&self, user_id: &str, edge_id: &str) -> Result<bool>
pub fn delete_edge(&self, user_id: &str, edge_id: &str) -> Result<bool>
Delete an edge (for rejection)
Sourcepub fn get_edges_from(
&self,
user_id: &str,
memory_id: &MemoryId,
) -> Result<Vec<LineageEdge>>
pub fn get_edges_from( &self, user_id: &str, memory_id: &MemoryId, ) -> Result<Vec<LineageEdge>>
Get all edges from a memory (outgoing)
Sourcepub fn get_edges_to(
&self,
user_id: &str,
memory_id: &MemoryId,
) -> Result<Vec<LineageEdge>>
pub fn get_edges_to( &self, user_id: &str, memory_id: &MemoryId, ) -> Result<Vec<LineageEdge>>
Get all edges to a memory (incoming)
Sourcepub fn list_edges(
&self,
user_id: &str,
limit: usize,
) -> Result<Vec<LineageEdge>>
pub fn list_edges( &self, user_id: &str, limit: usize, ) -> Result<Vec<LineageEdge>>
List all edges for a user
Sourcepub fn store_branch(&self, user_id: &str, branch: &LineageBranch) -> Result<()>
pub fn store_branch(&self, user_id: &str, branch: &LineageBranch) -> Result<()>
Store a branch
Sourcepub fn get_branch(
&self,
user_id: &str,
branch_id: &str,
) -> Result<Option<LineageBranch>>
pub fn get_branch( &self, user_id: &str, branch_id: &str, ) -> Result<Option<LineageBranch>>
Get a branch by ID
Sourcepub fn list_branches(&self, user_id: &str) -> Result<Vec<LineageBranch>>
pub fn list_branches(&self, user_id: &str) -> Result<Vec<LineageBranch>>
List all branches for a user
Sourcepub fn create_branch(
&self,
user_id: &str,
name: &str,
parent_branch: &str,
branch_point: MemoryId,
description: Option<&str>,
) -> Result<LineageBranch>
pub fn create_branch( &self, user_id: &str, name: &str, parent_branch: &str, branch_point: MemoryId, description: Option<&str>, ) -> Result<LineageBranch>
Create a new branch from current state
Sourcepub fn ensure_main_branch(&self, user_id: &str) -> Result<()>
pub fn ensure_main_branch(&self, user_id: &str) -> Result<()>
Ensure main branch exists for user
Sourcepub fn infer_relation(
&self,
from: &Memory,
to: &Memory,
) -> Option<(CausalRelation, f32)>
pub fn infer_relation( &self, from: &Memory, to: &Memory, ) -> Option<(CausalRelation, f32)>
Infer causal relationship between two memories
Sourcepub fn detect_branch_signal(content: &str) -> bool
pub fn detect_branch_signal(content: &str) -> bool
Detect branch point from memory content (pivot language)
Sourcepub fn trace(
&self,
user_id: &str,
memory_id: &MemoryId,
direction: TraceDirection,
max_depth: usize,
) -> Result<LineageTrace>
pub fn trace( &self, user_id: &str, memory_id: &MemoryId, direction: TraceDirection, max_depth: usize, ) -> Result<LineageTrace>
Trace lineage from a memory
Sourcepub fn find_root_cause(
&self,
user_id: &str,
memory_id: &MemoryId,
) -> Result<Option<MemoryId>>
pub fn find_root_cause( &self, user_id: &str, memory_id: &MemoryId, ) -> Result<Option<MemoryId>>
Find the root cause of a memory (trace all the way back)
Sourcepub fn find_effects(
&self,
user_id: &str,
memory_id: &MemoryId,
max_depth: usize,
) -> Result<Vec<MemoryId>>
pub fn find_effects( &self, user_id: &str, memory_id: &MemoryId, max_depth: usize, ) -> Result<Vec<MemoryId>>
Find all effects of a memory (trace all the way forward)
Sourcepub fn confirm_edge(&self, user_id: &str, edge_id: &str) -> Result<bool>
pub fn confirm_edge(&self, user_id: &str, edge_id: &str) -> Result<bool>
Confirm an inferred edge
Sourcepub fn reject_edge(&self, user_id: &str, edge_id: &str) -> Result<bool>
pub fn reject_edge(&self, user_id: &str, edge_id: &str) -> Result<bool>
Reject (delete) an inferred edge
Sourcepub fn add_explicit_edge(
&self,
user_id: &str,
from: MemoryId,
to: MemoryId,
relation: CausalRelation,
) -> Result<LineageEdge>
pub fn add_explicit_edge( &self, user_id: &str, from: MemoryId, to: MemoryId, relation: CausalRelation, ) -> Result<LineageEdge>
Add an explicit edge
Sourcepub fn edge_exists(
&self,
user_id: &str,
from: &MemoryId,
to: &MemoryId,
) -> Result<bool>
pub fn edge_exists( &self, user_id: &str, from: &MemoryId, to: &MemoryId, ) -> Result<bool>
Check if an edge already exists between two memories
Sourcepub fn stats(&self, user_id: &str) -> Result<LineageStats>
pub fn stats(&self, user_id: &str) -> Result<LineageStats>
Get lineage statistics for a user
Auto Trait Implementations§
impl Freeze for LineageGraph
impl RefUnwindSafe for LineageGraph
impl Send for LineageGraph
impl Sync for LineageGraph
impl Unpin for LineageGraph
impl UnsafeUnpin for LineageGraph
impl UnwindSafe for LineageGraph
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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