Skip to main content

Module graph

Module graph 

Source
Expand description

Graph backend trait for knowledge graph storage.

The graph layer provides entity and relationship storage with temporal tracking, enabling knowledge graph construction and traversal.

§Available Implementations

BackendUse CaseFeatures
SqliteGraphBackendDefault; embeddedRecursive CTEs for traversal
InMemoryGraphBackendTestingFast, no persistence
Neo4jGraphBackendFutureNative graph operations

§Error Modes and Guarantees

All backends return Result<T> with errors propagated via crate::Error.

§Entity Operations

OperationComplexityNotes
store_entityO(1)Insert or update
get_entityO(1)By ID lookup
query_entitiesO(log n)With filters
delete_entityO(k)k = relationship count

§Relationship Operations

OperationComplexityNotes
store_relationshipO(1)Insert or update
query_relationshipsO(log n)With filters
traverseO(b^d)b = branching, d = depth

§Temporal Queries

Bitemporal queries filter by both valid_time and transaction_time:

  • valid_at: Filter entities/relationships valid at a point in time
  • as_of: Filter by when records were known to the system

§Example

ⓘ
use subcog::storage::traits::GraphBackend;
use subcog::models::graph::{Entity, EntityType, EntityQuery};

// Query all Person entities with confidence > 0.8
let query = EntityQuery::new()
    .with_type(EntityType::Person)
    .with_min_confidence(0.8)
    .with_limit(20);

let people = backend.query_entities(&query)?;

Structs§

GraphStats
Statistics about the knowledge graph.

Traits§

GraphBackend
Trait for graph layer backends.