Skip to main content

Crate memory

Crate memory 

Source
Expand description

Durable memory: facts worth keeping across agent sessions and harnesses.

A Provider keeps memories in four scopes (user, host, project, session) and finds them again by words. The daemon serves the memory.* API through whichever provider the settings name; this crate holds the interface, the deterministic full-text ranking every provider can share (search), and the providers: Files, one markdown file per memory plus a MEMORY.md index, the layout Claude Code’s memory uses; Sqlite, one SQLite database per user with memories, their links as edges with valid times, vectors, collector rows, and session summaries; and, with the kosmonaut feature, Kosmonaut, the same kept on a Kosmonaut server over gRPC. transfer copies memories from one provider to another. See docs/memory.md.

Headless: no GUI, and no model unless an embed embedder is configured. Calls do blocking I/O; the daemon runs them off its event loop. Only the Kosmonaut server client runs an async runtime, a small one of its own.

Modules§

embed
Embedders: text to vectors, for a provider that can recall by meaning as well as by words. None is used unless the settings name one.
search
Full-text ranking without a model: the same query over the same memories always gives the same order.

Structs§

Change
A change to a memory: None keeps what is there.
CollectorRow
A row a collector kept: what the daemon’s collectors write when a database provider keeps memory, so rows can be found next to the memories, panes, and sessions they came from.
Context
Who is asking: what the project and session scopes are resolved from.
Files
Found
Memories, and what could not be read on the way.
Memory
One memory.
Moved
What transfer copied, and what it could not read on the way.
New
A new memory.
Problem
A stored memory that could not be read. It is left alone and skipped.
Sqlite
Summary
What an agent session came to: one per session, replaced on each write.

Enums§

Error
Kind
What a memory is about: Claude Code’s four kinds.
Scope
Where a memory applies.

Constants§

DEFAULT_LIMIT
Default and largest number of memories recall returns.
INDEX_BYTES
The index’s size at most, in bytes.
INDEX_HEAD
What the index says before its lines.
INDEX_LINES
Memories the index lists at most.
MAX_LIMIT

Traits§

Provider
A memory store. Every method resolves the project and session scopes from cx; scope: None means every scope cx reaches. Providers keep no cache that could go stale against their store.

Functions§

index
The index of items (in the order given, newest first), or None when there are none. At most INDEX_LINES lines and INDEX_BYTES bytes; the rest are counted in a last line.
project_root
The project a working directory belongs to: the nearest directory at or above it that holds .dreamer/memory or .git, else the directory itself.
reach
The scopes cx reaches: user and host always, project with a working directory, session with a session id.
transfer
Copy every memory from holds in scope (every scope cx reaches when None) into to, keeping ids, kinds, text, links, and times. A memory to already holds under the same id is replaced; nothing is removed from either side. Import from files and export back to it are this, with the providers swapped.