1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! AI agent memory graph — SQLite/PostgreSQL-backed long-term memory with FTS5
//! search, smart recall, and graph-structured relevance boosting.
//!
//! The module is tuned for agent *memory*: nodes carry importance and decaying
//! recency/access signals, and are recalled by composite scoring (recency +
//! importance + access + FTS + graph boost), with CSR algorithms ([`algo`])
//! surfacing structurally central memories. The niche is comparable to
//! **Zep / Mem0 / Letta**, but local-first and vault-based rather than a hosted
//! service.
//!
//! From v0.19 the trait also serves **general directed-graph workloads** —
//! citation networks, document backlinks, dependency graphs — via batch edge
//! writes ([`GraphBackend::append_edges`]), directional / relation-filtered
//! lookups ([`GraphBackend::edges_for_node_dir`],
//! [`GraphBackend::neighbors_weighted`]), and filtered BFS
//! ([`GraphBackend::related_nodes_filtered`]); [`EdgeDirection`] selects
//! out / in / both. For pure topology with no memory semantics, `petgraph` or
//! a graph database remains a better fit.
//!
//! Provides a complete knowledge graph layer on top of SQLite:
//!
//! - **Types**: [`GraphNode`], [`GraphEdge`], [`ScoredNode`], [`GraphStats`]
//! - **Schema**: [`init_graph_schema`] — creates tables, FTS5, indexes
//! - **CRUD**: node/edge insert, read, update, delete
//! - **Search**: FTS5 full-text search and dynamic filtering
//! - **Recall**: [`smart_recall`] — composite scoring with recency, importance, access, FTS, graph boost
//! - **Traversal**: [`graph_neighbors`] (1-hop), [`related_nodes`] (BFS via recursive CTE)
//! - **Algorithms**: pure-Rust CSR algorithms in [`algo`] — [`pagerank()`], [`connected_components()`], [`label_propagation()`], [`dijkstra()`], [`jaccard_similarity()`]
//! - **Lifecycle**: [`decay_importance`], [`tag_stale_nodes`], [`compute_stats`]
//!
//! All functions take `&rusqlite::Connection` — no hardcoded paths.
//!
//! ```no_run
//! use rusqlite::Connection;
//! use llm_kernel::graph::{init_graph_schema, upsert_node, smart_recall, GraphNode};
//!
//! let conn = Connection::open_in_memory().unwrap();
//! init_graph_schema(&conn).unwrap();
//!
//! upsert_node(&conn, &GraphNode {
//! id: "rust-ownership".into(),
//! node_type: "concept".into(),
//! title: "Rust Ownership Model".into(),
//! body: "Ownership, borrowing, and lifetimes...".into(),
//! tags: vec!["rust".into(), "memory-safety".into()],
//! projects: vec!["my-project".into()],
//! agents: vec![],
//! created: "2026-01-01T00:00:00Z".into(),
//! updated: "2026-01-01T00:00:00Z".into(),
//! importance: 0.8,
//! access_count: 0,
//! accessed_at: String::new(),
//! }).unwrap();
//!
//! let results = smart_recall(&conn, Some("my-project"), Some("ownership"), 5).unwrap();
//! for scored in &results {
//! println!("{:.2} — {}", scored.score, scored.node.title);
//! }
//! ```
/// CJK-aware graph search (Rust-side segmentation; no schema change).
/// PostgreSQL `GraphBackend` (feature `graph-pg`).
pub use AsyncPoolGraph;
// Re-export primary types and functions
pub use ;
pub use ;
pub use ;
pub use ;
pub use smart_recall;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use PgGraph;