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
//! Local-first memory for AI assistants.
//!
//! `palace-rs` stores verbatim text as *drawers* in one SQLite file, embeds it
//! locally with ONNX Runtime, and retrieves it with hybrid (vector + BM25)
//! search. A temporal knowledge graph keeps facts with validity windows.
//! The same crate powers the `palace` CLI and MCP server.
//!
//! # Using it as a library
//!
//! Turn off the default `cli` feature to leave out the CLI dependencies:
//!
//! ```toml
//! [dependencies]
//! palace-rs = { version = "0.19", default-features = false }
//! ```
//!
//! The library is imported as `palace`:
//!
//! ```
//! use palace::{db, knowledge_graph, store};
//!
//! # fn main() -> anyhow::Result<()> {
//! let conn = db::open_in_memory()?;
//! store::add_drawer(
//! &conn,
//! "wing_code",
//! "backend",
//! "We use SQLite with WAL mode for concurrent reads.",
//! None,
//! "architecture.md",
//! 0,
//! "example",
//! 4.0,
//! )?;
//! knowledge_graph::add_triple(
//! &conn,
//! "Palace",
//! "stores_data_in",
//! "SQLite",
//! Some("2026-04-01"),
//! None,
//! 1.0,
//! None,
//! None,
//! )?;
//! assert_eq!(store::count_drawers(&conn)?, 1);
//! # Ok(())
//! # }
//! ```
//!
//! Starting points:
//!
//! - [`db`] opens a palace (`db::open` for a file, `db::open_in_memory` for tests).
//! - [`store`] adds, updates, and lists drawers.
//! - [`palace::Palace`] wraps a palace for search, including
//! [`palace::Palace::search_with_provenance`] for scored, cited results.
//! - [`knowledge_graph`] adds and queries facts.
//! - [`embedder`] embeds text with the active local model.