Skip to main content

GraphStore

Trait GraphStore 

Source
pub trait GraphStore: Send + Sync {
Show 26 methods // Required methods fn add_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, layer: Layer, importance: f32, created_at: Timestamp, namespace: Namespace, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn has_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<GraphNodeData>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn node_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<MemoryId>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn node_importance<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<f32>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_node_importance<'life0, 'async_trait>( &'life0 self, id: MemoryId, importance: f32, ) -> Pin<Box<dyn Future<Output = HirnResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn node_layer<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<Layer>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn node_namespace<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<Namespace>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn namespaces_compatible<'life0, 'async_trait>( &'life0 self, a: MemoryId, b: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_edge<'life0, 'async_trait>( &'life0 self, source: MemoryId, target: MemoryId, relation: EdgeRelation, weight: f32, metadata: Metadata, ) -> Pin<Box<dyn Future<Output = HirnResult<EdgeId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_causal_edge<'life0, 'async_trait>( &'life0 self, source: MemoryId, target: MemoryId, relation: EdgeRelation, weight: f32, metadata: Metadata, causal: CausalEdgeData, ) -> Pin<Box<dyn Future<Output = HirnResult<EdgeId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_edge<'life0, 'async_trait>( &'life0 self, edge_id: EdgeId, ) -> Pin<Box<dyn Future<Output = HirnResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_edge<'life0, 'async_trait>( &'life0 self, edge_id: EdgeId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<GraphEdge>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_edges<'life0, 'async_trait>( &'life0 self, node_id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_edges_between<'life0, 'async_trait>( &'life0 self, a: MemoryId, b: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_edges_of_type<'life0, 'async_trait>( &'life0 self, node_id: MemoryId, relation: EdgeRelation, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn all_edges<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_edge_weight<'life0, 'async_trait>( &'life0 self, edge_id: EdgeId, new_weight: f32, co_retrieval_count: Option<u64>, ) -> Pin<Box<dyn Future<Output = HirnResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_neighbors<'life0, 'async_trait>( &'life0 self, start: MemoryId, depth: usize, min_weight: f32, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<MemoryId>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_neighbors_filtered<'life0, 'life1, 'async_trait>( &'life0 self, start: MemoryId, depth: usize, min_weight: f32, namespace: Option<&'life1 Namespace>, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<MemoryId>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn outgoing_weighted<'life0, 'async_trait>( &'life0 self, node_id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<(MemoryId, f32, EdgeRelation)>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn shortest_path<'life0, 'async_trait>( &'life0 self, source: MemoryId, target: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<Vec<MemoryId>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn node_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = HirnResult<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn edge_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = HirnResult<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided method fn get_edges_of_type_many<'life0, 'life1, 'async_trait>( &'life0 self, node_ids: &'life1 [MemoryId], relation: EdgeRelation, ) -> Pin<Box<dyn Future<Output = HirnResult<HashMap<MemoryId, Vec<GraphEdge>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Unified async interface for graph storage backends.

Both the in-memory PropertyGraph and the LanceDB-backed PersistentGraph implement this trait, enabling code to operate on either backend without branching.

All methods are async to accommodate the PersistentGraph path. The in-memory implementation wraps synchronous operations.

Required Methods§

Source

fn add_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, layer: Layer, importance: f32, created_at: Timestamp, namespace: Namespace, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert a graph node. Returns true if newly inserted, false if it already existed.

Source

fn remove_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a node and all its incident edges. Returns true if the node existed.

Source

fn has_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check whether a node exists.

Source

fn get_node<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<GraphNodeData>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve full node data, or None if absent.

Source

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

Return all node IDs in the graph.

Source

fn node_importance<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<f32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the importance score for a node.

Source

fn set_node_importance<'life0, 'async_trait>( &'life0 self, id: MemoryId, importance: f32, ) -> Pin<Box<dyn Future<Output = HirnResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the importance score for a node.

Source

fn node_layer<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<Layer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the layer of a node.

Source

fn node_namespace<'life0, 'async_trait>( &'life0 self, id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<Namespace>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the namespace of a node.

Source

fn namespaces_compatible<'life0, 'async_trait>( &'life0 self, a: MemoryId, b: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check whether two nodes’ namespaces are compatible for auto-edge creation (same namespace, or either is “shared”).

Source

fn add_edge<'life0, 'async_trait>( &'life0 self, source: MemoryId, target: MemoryId, relation: EdgeRelation, weight: f32, metadata: Metadata, ) -> Pin<Box<dyn Future<Output = HirnResult<EdgeId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a directed edge. Returns the new EdgeId.

Implementations should enforce the per-node fan-out cap (MAX_EDGES_PER_NODE).

Source

fn add_causal_edge<'life0, 'async_trait>( &'life0 self, source: MemoryId, target: MemoryId, relation: EdgeRelation, weight: f32, metadata: Metadata, causal: CausalEdgeData, ) -> Pin<Box<dyn Future<Output = HirnResult<EdgeId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a causal edge with associated CausalEdgeData.

Identical to [add_edge] but populates strength, confidence, evidence count, and mechanism on the created edge.

Source

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

Remove an edge by ID.

Source

fn get_edge<'life0, 'async_trait>( &'life0 self, edge_id: EdgeId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<GraphEdge>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a single edge by ID.

Source

fn get_edges<'life0, 'async_trait>( &'life0 self, node_id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all edges incident to a node (both directions).

Source

fn get_edges_between<'life0, 'async_trait>( &'life0 self, a: MemoryId, b: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get edges between two specific nodes.

Source

fn get_edges_of_type<'life0, 'async_trait>( &'life0 self, node_id: MemoryId, relation: EdgeRelation, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<GraphEdge>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get edges of a specific relation type incident to a node.

Source

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

Get all edges in the graph.

Source

fn update_edge_weight<'life0, 'async_trait>( &'life0 self, edge_id: EdgeId, new_weight: f32, co_retrieval_count: Option<u64>, ) -> Pin<Box<dyn Future<Output = HirnResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the weight (and optionally co-retrieval count) of an edge.

Source

fn get_neighbors<'life0, 'async_trait>( &'life0 self, start: MemoryId, depth: usize, min_weight: f32, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<MemoryId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

BFS neighbors up to depth hops, filtering by minimum edge weight.

Source

fn get_neighbors_filtered<'life0, 'life1, 'async_trait>( &'life0 self, start: MemoryId, depth: usize, min_weight: f32, namespace: Option<&'life1 Namespace>, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<MemoryId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

BFS neighbors with optional namespace filter.

Source

fn outgoing_weighted<'life0, 'async_trait>( &'life0 self, node_id: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Vec<(MemoryId, f32, EdgeRelation)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Outgoing edges with (target, weight, relation) tuples.

Source

fn shortest_path<'life0, 'async_trait>( &'life0 self, source: MemoryId, target: MemoryId, ) -> Pin<Box<dyn Future<Output = HirnResult<Option<Vec<MemoryId>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shortest path between two nodes (Dijkstra). Returns None if no path exists.

Source

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

Number of nodes in the graph.

Source

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

Number of edges in the graph.

Provided Methods§

Source

fn get_edges_of_type_many<'life0, 'life1, 'async_trait>( &'life0 self, node_ids: &'life1 [MemoryId], relation: EdgeRelation, ) -> Pin<Box<dyn Future<Output = HirnResult<HashMap<MemoryId, Vec<GraphEdge>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get edges of a specific relation type incident to many nodes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§