Skip to main content

Crate palace

Crate palace 

Source
Expand description

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:

[dependencies]
palace-rs = { version = "0.19", default-features = false }

The library is imported as palace:

use palace::{db, knowledge_graph, store};

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);

Starting points:

Modules§

backend
Backend contracts for storage implementations.
backends
cli
CLI entry point using clap.
closet
Closet layer: compact topical pointers to verbatim drawers.
config
Configuration system for Palace.
convo_miner
Conversation file ingestor.
db
Database layer: SQLite with WAL mode and schema migrations.
dialect
AAAK dialect — compressed memory format for Palace.
embedder
Text embedding using ONNX Runtime and the models in crate::embedding_models.
embedding_eval
Known-item retrieval probes for comparing embedding models on a palace.
embedding_migration
Switching a palace to another embedding model without losing search.
embedding_models
Registry of embedding models Palace can run.
entity_detector
Lightweight entity detection for drawer metadata.
export
Palace export / import — portable JSON snapshots of all drawers.
feedback
Feedback through public GitHub Discussions.
gain
Aggregation and rendering for palace gain.
general_extractor
Extract typed memories from text using regex heuristics.
hall_router
Route drawer content into broad palace halls.
hook_sessions
Per-session activity recorded by the agent hooks.
hooks
Cursor hook response builders for automatic, model-independent memory use.
i18n
Locale metadata for entity detection.
install
knowledge_graph
Temporal Entity-Relationship Knowledge Graph.
layers
4-Layer Memory Stack.
manifest_entities
Detect project entities from common package manifests.
mcp_server
MCP Server — stdio JSON-RPC tool loop for AI coding assistants.
migrate
SQLite-to-SQLite migration helpers for older palace files.
miner
Project file ingestor.
normalize
Conversation format normalizer.
onboarding
Interactive first-run wizard.
origin
Corpus-origin detection for project and conversation mining.
palace
High-level facade for embedding the memory palace as a library.
palace_graph
Palace graph traversal.
preference
Preference sentence detection for improved agent memory recall.
query_intent
Lightweight query intent classification for adaptive retrieval.
query_rewriter
Query rewriting — normalises raw agent queries before embedding/BM25 lookup.
query_sanitizer
Query cleanup for agent-originated memory searches.
ranker
Hybrid retrieval: BM25 keyword scoring plus optional vector similarity.
remote
Remote MCP proxy transport.
reranker
Optional local reranking for top hybrid candidates.
room_detector
Room detection from folder structure and filename patterns. Writes and reads palace.yaml for a project. Port of room_detector_local.py.
searcher
Semantic search over the palace.
split
Split concatenated Claude Code mega-transcript files into per-session files.
store
Drawer CRUD and vector search.
sweep
Message-level transcript sweeper.
time_query
Relative time in queries: “two weeks ago”, “last Tuesday”, “in March”.
usage
Local usage telemetry for Palace MCP calls.
watcher
Incremental file watcher — re-mines changed files into the palace.
wings
Wing names: which wing a write lands in, and renaming or merging a wing.