Skip to main content

Crate trusty_memory

Crate trusty_memory 

Source
Expand description

The trusty-memory daemon: one resident process, one Unix socket.

Why: Claude Code and other MCP-aware clients reach trusty-memory through the Model Context Protocol, and the daemon owns redb’s exclusive write lock, so every client has to go through it rather than open the store itself (#1078). trusty-memory serve --stdio is the canonical integration: it forwards each JSON-RPC request to the running daemon and never opens redb.

#6286 (ADR-0032) retired the HTTP half. The daemon bound 127.0.0.1:7070, walked to :7079 when that was taken, published the winner in an http_addr discovery file, and served forty axum routes plus an /sse broadcast. It now serves trusty_common::daemon_socket_path’s hardened Unix socket and nothing else; trusty-console is the workspace’s only HTTP surface.

What: transport::uds::serve is the daemon body, and AppState carries the shared PalaceRegistry, the on-disk data root and a lazily-initialised embedder. Test: cargo test -p trusty-memory — transport::uds::tests for the wire, tests/serve_stdio_e2e.rs for the bridge end to end.

Re-exports§

pub use activity::ActivityEntry;
pub use activity::ActivityFilter;
pub use activity::ActivityLog;
pub use activity::ActivitySource;
pub use attribution::CreatorInfo;
pub use attribution::CreatorSource;
pub use transport::serve;
pub use transport::socket_path;
pub use mcp_service::MemoryMcpService;
pub use tools::MemoryMcpServer;

Modules§

activity
Persistent activity log for the trusty-memory daemon (issue #96).
attribution
Drawer creator-attribution tag helpers.
authz
Minimal authorization seam for privileged operations (issue #1714).
bm25_backfill
Lossless BM25 backfill for a palace’s existing drawers.
bm25_index
Persistent per-palace BM25 index — the in-process owner of a palace’s lexical corpus.
bm25_lane
In-process BM25 lexical lane — one resident index per hot palace.
bm25_repair
Runtime repair for palaces whose BM25 coverage is known to be broken.
bootstrap
Knowledge-graph bootstrap helpers.
chat
The chat surface: a streaming completion and the tool loop behind it.
client
The one way anything in this crate calls the running daemon (#6286).
commands
Per-subcommand handlers for the trusty-memory binary.
console_metrics
MCP console_metrics tool handler for trusty-memory.
discovery
Automatic project alias discovery.
dream_scheduler
Autonomous Dreamer scheduler — spawns per-palace dream loops on daemon startup.
fd_metrics
File-descriptor usage and limit reporting for the /health endpoint.
hook_emit
Cross-process hook activity emit.
idle_evict
Idle-to-disk eviction ticker — periodically drops cold palace handles.
kg_extract
Deterministic KG triple extraction from drawer content.
kg_write
The one entry point for asserting a caller-supplied KG triple.
mcp_service
ServiceDescriptor impl for the trusty-memory MCP service.
messaging
Inter-project messaging primitive (issue #99).
openrpc
OpenRPC 1.3.2 service description for trusty-memory-mcp.
palace_id_derive
Default palace-ID derivation from project identity (issue #1217).
project_root
Project-root detection, palace-slug derivation, and .trusty-tools/ pin file management (issue #88 + Phase 1 of the .trusty-tools/ convention).
prompt_facts
Prompt-facts surface: hot KG predicates exposed via a per-message tool.
prompt_log
Enriched-prompt logger for the UserPromptSubmit / SessionStart hooks (issue #105).
service
MemoryService — pure business-logic facade over AppState.
session_store_cache
LRU-bounded cache of per-palace ChatSessionStore handles (issue #4639).
startup_scan
Startup-time single-pass pin-file scanner.
tools
MCP tool surface for trusty-memory.
transport
How the daemon is reachable, and what it answers.
ui_assets
The embedded Svelte SPA, kept in the binary with nothing serving it yet (#6286).
wordnet_pos
Part-of-speech membership lookup backed by Princeton WordNet 3.1.
worker_liveness
Live worker-occupancy gauge for the palace open/write path (issue #4001).

Structs§

AppState
Shared application state passed to every request handler.

Enums§

DaemonEvent
Live daemon events broadcast to connected SSE subscribers.
DaemonReadiness
Two-phase daemon readiness state (issues #910/#911, revised by #1970).
HookType
Hook type — labels the Claude Code hook that triggered a submission.
InjectionKind
Injection kind — labels what the hook actually injected (or attempted).

Constants§

HOOK_PROMPT_EXCERPT_CHARS
Maximum bytes retained in the trigger-prompt excerpt embedded on a HookFired event.

Functions§

handle_message
Handle a single MCP JSON-RPC message and produce its response.
hook_prompt_excerpt
Reduce a triggering prompt to the short excerpt embedded on a HookFired activity event.
is_data_dir_override_active
Return true when a non-default data directory is in effect.
resolve_palace_registry_dir
Resolve the directory that actually holds the per-palace subdirectories.