Memory layers and their lifecycles

This document explains exactly what mneme stores, where it lives, when it's embedded, and which schedules move data between tiers. Read this if you're trying to understand why a memory you stored yesterday is or isn't surfacing today, or whether your machine is about to do disk I/O while you're typing.

If you only want the one-page version, read §1 Quick reference. The rest of the doc is layer-by-layer detail.

What's wired today. All three background schedulers run (HNSW snapshots, L3 consolidation on a 5-min idle tick, L1 session checkpoints on 30 s / 5 turns). The L1 read-side fold-in into mneme://context ships — working turns appear in auto-context with WORKING_WEIGHT = 0.9, sorted newest-first. The per-session resource mneme://session/{id} exposes the full session JSON for active or past sessions. The switch_scope tool sets the live default scope so write tools (remember, pin, record_event) without an explicit scope arg land in the session's current scope; the current value surfaces on mneme://stats as working.current_scope.


1. Quick reference

LayerWhat it holdsEmbedded?Where on diskAuto-schedule (today)Auto-schedule (v1 design)
L0 ProceduralAlways-on pinned rules (pin / unpin)No~/.mneme/procedural/pinned.jsonlLive: file watched every 500 ms; external edits picked up in <1 sSame
L1 Working sessionThe current session's turns (tool, user, assistant), scratch stateNo~/.mneme/sessions/<session_id>.snapshot (atomic temp+rename per flush)Checkpoint scheduler running; conversation mirror wired — record_event(kind="user_message"/"assistant_message") pushes a matching turn to L1Same
L3 EpisodicTime-ordered events: tool calls, lifecycle events, conversation turns, curated semantic eventsNo (lexical only)~/.mneme/episodic/ (redb), three prefixes: epi: hot, wepi: warm, cold/ zstdAuto-emit running — tool_call (per-tool enriched payload; write tools only by default, see [episodic] auto_log_tool_calls), tool_call_failed, session_start, session_end. Agent-driven — record_event writes any kind. ConsolidationScheduler fires every 5 min when idleIdle-time pass: hot → warm at age ≥ 28 d, warm → cold at age ≥ 180 d
L4 SemanticLong-term facts, decisions, preferences, conversationsYes — every remember / update re-embeds~/.mneme/episodic/ (redb), prefix mem: + ~/.mneme/index/hnsw.idx snapshot + ~/.mneme/wal/ deltasLive writes; HNSW snapshot scheduler runs: every 1000 inserts OR every 60 min, whichever firstSame
Auto-context resourcePinned + working turns + recent events, packed to a token budget; plus L4 hits when the read carries ?q=Reads only (embeds the ?q= seed)(assembled on demand)On read of mneme://contextSame
Cold archiveQuarter-bundled JSON, zstd-compressedNo~/.mneme/cold/<YYYY-Q>.zstWritten only when L3 consolidation runsSame as L3

The defaults in the table come from ~/.mneme/config.toml; every threshold is user-overridable. See §7 Configuration knobs.


2. L0 Procedural — always-on rules

What it is. A small JSONL file of pinned items. Each call to pin appends a line; unpin rewrites the file without it. Procedural memory exists to surface high-priority rules ("always run cargo fmt before commit", "we never push to main") on every recall context without semantic search needing to find them first.

Embedding. None. Procedural is exact-match by id, with content returned verbatim. No vectors are computed.

Storage. ~/.mneme/procedural/pinned.jsonl. One JSON object per line. Human-readable; you can edit it in a text editor with mneme running.

Hot-reload schedule. A notify::PollWatcher polls the file every 500 ms and reloads the in-memory cache when the content hash changes. This is faster and more uniform across platforms than FSEvents (macOS), which coalesces events for tens of seconds. External edits are reflected in the running server in under 1 second.

Surfaced via:

  • Tool: pin (write), unpin (write).
  • Resource: mneme://procedural (read).
  • Auto-context: every pinned item is in every mneme://context read; pins are never trimmed to fit the token budget. A read scoped with ?scope= returns the pins of those scopes plus the pins of [auto_context] pin_scopes (default global).

What runs today: All of the above. No deferred features.


3. L1 Working session — the current turn(s)

What it is. The active session's working state — turn history, scratch notes, the agent's own self-reminder buffer. Designed to survive crashes by checkpointing to disk on a schedule.

Embedding. None.

Storage. ~/.mneme/sessions/<session_id>.snapshot (atomic temp+rename per checkpoint). Single file per session.

Designed schedule. Per spec §8.3 and [checkpoints] in config.toml:

  • session_interval_secs = 30 — checkpoint at most every 30 s.
  • session_interval_turns = 5 — and at least every 5 turns.
  • Whichever fires first.

L1 is session-local. Every MCP session has its own working session and its own checkpoint scheduler: one per mneme run process (stdio), one per accepted daemon connection, one per HTTP Mcp-Session-Id. Agents sharing a daemon share L0, L3 and L4, never L1. (Up to 1.5.x the daemon and HTTP transports shared one working session between all clients.) A per-client session is flushed and its scheduler stopped when the connection closes, on DELETE /mcp, when an idle HTTP session is evicted, and at server shutdown; a session with no turns writes no snapshot.

What runs today:

cli::run spawns a CheckpointScheduler that writes the active session to ~/.mneme/sessions/<session_id>.snapshot on the first of two triggers: every session_interval_secs (30 s default) when there are pending turns, OR every session_interval_turns (5 default) turns, whichever fires first. A turn is a message recorded with record_event, or a successful call to a tool that changes something; read-only tools (recall, recall_recent, stats, list_scopes, export) do not add turns. A clean shutdown writes a final snapshot with clean_shutdown = true. Per-session counters land on mneme://stats and the stats tool under the working key: session_id, started_at, last_checkpoint_at, turns_total, checkpoints_total.

Practical implication. Working-session state survives restart; the active session and any prior snapshot are reachable via the mneme://session/{id} template resource (in-memory for the active session, on-disk for past sessions). The L3 episodic store remains the structured "what did we just do?" surface — it ranks by recency; L1 is a turn log, not a search index.


4. L3 Episodic — recent events and turn checkpoints

What it is. Time-ordered events: tool calls, user messages, agent-emitted checkpoints, session summaries. Fundamentally a log, not a search corpus — recall_recent returns events ordered by (last_accessed, retrieval_weight, created_at), not by semantic similarity.

Embedding. None (ADR-0007). Episodic recall is lexical/temporal — recall_recent returns L3 hits only, never L4. If you want semantic search over what happened, the close-of-loop is: summarize_session (returns a prompt template populated with recent L3 events) → fill it via the host LLM → record_event(kind="summary", payload={text, covers}) to land the digest as a single L3 event → remember durable facts into L4 for similarity retrieval. Mneme itself never calls an LLM (cardinal rule #3); the agent owns the host completion path.

Storage. All in ~/.mneme/episodic/ (redb), distinguished by key prefix:

  • epi:<ulid> — hot tier (default home for new events)
  • wepi:<ulid> — warm tier (after promotion)
  • Cold tier lives outside redb in ~/.mneme/cold/<YYYY-Q>.zst (zstd-compressed JSON bundles, one per calendar quarter).

Designed lifecycle. From memory/consolidation.rs:

hot  (epi:)   ──┐
                │  age ≥ hot_to_warm_days  (default 28)
warm (wepi:)  ──┐
                │  age ≥ warm_to_cold_days (default 180)
cold (zstd)

Nothing moves for the first four weeks, by design. An event is promoted only once its last_accessed is at least hot_to_warm_days (28) old, and archived only at warm_to_cold_days (180). A fresh install therefore shows runs_total climbing (the scheduler wakes every 5 minutes) with last_promoted_to_warm at 0 for four weeks. Zero promotions in the first four weeks is expected, not a fault. To tell "idle because nothing is old enough" from "stuck", read the consolidation object in stats / mneme://stats:

"consolidation": {
  "runs_total": 754, "errors_total": 0, "last_promoted_to_warm": 0,
  "thresholds": { "hot_to_warm_days": 28, "warm_to_cold_days": 180 },
  "hot_oldest_age_days": 3.41,
  "hot_eligible_for_warm": 0,
  "next_promotion_in_days": 24.59
}
FieldMeaning
thresholdsThe [consolidation] values this server is running with.
hot_oldest_age_daysAge of the oldest hot event, on last_accessed (the field consolidation uses). null when the hot tier is empty.
hot_eligible_for_warmHot events already at or past hot_to_warm_days. These move on the next pass that finds a quiet window.
next_promotion_in_dayshot_to_warm_days minus hot_oldest_age_days, never below 0; 0 once something is eligible. null when the hot tier is empty.

stats also carries a top-level version (the server's crate version). Eligible events that never move mean the idle gate hasn't closed: every remember / forget / record resets it (see the FAQ).

The pass is idempotent and crash-safe: hot→warm writes the new key before deleting the old; warm→cold writes the cold bundle (atomic temp+rename) before deleting warm rows. A kill -9 mid-pass leaves duplicates that the next run cleans up. Until it does, readers return such a row once (the hot copy) and forget removes both copies.

Reading each tier.

TierRead by
hot (epi:)recall_recent, mneme://recent, mneme://context, summarize_session, export
warm (wepi:)recall_recent when since is older than hot_to_warm_days, when only until is set, or with include_warm: true; export (tool and mneme export) by default; recall with layers containing episodic; forget by id
cold (cold/*.zst)recall_recent and export with include_cold: true, mneme export --include-cold. Not searched by recall. mneme backup copies the files.

Rows from recall_recent and export carry "tier": "hot", "warm" or "cold".

Searching L3. Events are not embedded, but the ones whose kind is in [episodic] index_kinds are covered by an in-memory keyword index (BM25, the same code as L4's lexical half) over the hot and warm tiers. recall(layers=["semantic","episodic"]) merges those matches with L4's on one rank scale. The index is built from redb on first use and kept in step on record, forget and consolidation; nothing extra is written to disk. A row's move from hot to warm does not change it. Kinds in [consolidation] cold_exempt_kinds never go to cold, so a decision stays searchable however old it gets; everything else leaves the index when it is archived. Hot events that recall returns get their last_accessed refreshed (at most daily, [episodic] touch_on_recall), which is what keeps a still-used event from being promoted on age. Before 1.5.2 nothing read the warm tier, so an event dropped out of every read path at 28 days and export was not a complete backup. export still leaves out the cold tier: for a full copy use mneme backup, which tars the data dir and so restores every row into the tier it was in.

Designed schedule. [consolidation] schedule = "idle" in the default config — meant to run when the server is idle. v1.0 honours the "idle" mode only: the scheduler wakes every 5 min; if no remember / forget / record happened in the prior tick, it fires a pass and refreshes its idle gate. Future modes (every_<n>m, cron, on_demand) belong to v1.1.

What runs today:

Server-side auto-emit (ADR-0009). Server::handle_tools_call and cli::run::async_main emit:

  • tool_call after a successful dispatch — payload is enriched per-tool with the value-bearing arg (e.g. remember.content, recall.query); diagnostic tools keep just {tool: <name>}. The full arguments JSON is never mirrored (privacy). Which calls are mirrored is [episodic] auto_log_tool_calls: "writes" (default) skips tools that declare readOnlyHint: true (recall, recall_recent, summarize_session, stats, list_scopes, export) and keeps the rest, forget included, so deletions stay auditable; "all" mirrors reads too (the 1.4.1 behaviour); "off" mirrors nothing.
  • tool_call_failed when a dispatch errors (carries error_kind and a truncated message string). Mirrors the success-path emit but does NOT push a turn to L1. Logged in writes and all, not in off. A secret-guard rejection records only the code secret_detected, never the content.

Because the tool_call payload carries remember / pin / update content, a credential stored under [guardrails] secrets = "warn" (or "off") is copied into this log too; "reject", the default, never stores it in either place.

  • session_start on mneme run boot.
  • session_end on graceful shutdown (clean_shutdown=true).

Agent-driven via record_event (ADR-0008). The agent calls mneme.record_event(kind, payload, ...) for any kind beyond the auto-emits. Canonical kinds: user_message, assistant_message (server also pushes a matching turn to L1), decision, problem, resolution, milestone, preference, pivot, observation, summary. Free-form: agents can invent new kinds without a schema migration.

Tier promotion runs in the background (memory::consolidation_scheduler::ConsolidationScheduler, spawned by cli::run). Per-pass observability (runs_total, errors_total, last_consolidation_at, last_promoted_to_warm, last_archived_to_cold) lands on the mneme://stats resource and the stats tool under the consolidation key. A burst of writes still inside its idle window suppresses the next pass — consolidation only fires after the system goes quiet. The same object reports the tier thresholds and the age of the oldest hot event (see above).

Surfaced via:

  • Tools: recall_recent, summarize_session, record_event.
  • Resource: mneme://recent.

5. L4 Semantic — long-term facts (the embedded layer)

What it is. The semantic layer. Every memory is embedded into a vector and indexed with HNSW for sub-50 ms semantic search. This is where remember, recall, update, and forget live.

Embedding. Yes. Every remember and every update that changes content calls the embedder. updates that change only tags / scope / kind skip the embedder.

The active embedder is set in [embeddings] model in config.toml:

  • bge-m3 (default) — ~1.5 GB, 1024-dim, multilingual, top-tier recall. Best quality.
  • minilm-l6 — ~80 MB, 384-dim, English. Faster startup, smaller footprint, lower recall on edge cases.
  • stub (via MNEME_EMBEDDER=stub env var, not config) — deterministic 32-dim dummy (see STUB_DIM in src/embed/stub.rs). Tests + offline boots only; stored vectors aren't portable to real models — the 32-dim choice is deliberate to force a loud dim-mismatch the moment you switch back to a real model.

Model swap behavior. Changing [embeddings] model in config.toml between runs triggers an automatic re-embed of every stored memory on the next mneme run. This is logged loudly. The migration is atomic through the WAL — interrupted re-embeds resume on the next boot.

Embedding cadence. Synchronous on the write path. remember returns only after the vector is written. Production p95 budget per spec §13: 150 ms per remember (cold cache), 50 ms per recall on a 100K-memory dataset.

Storage.

  • Memories: ~/.mneme/episodic/ (redb), prefix mem:. (Yes, the redb file is shared with episodic; only the key prefix distinguishes layers.)
  • HNSW index: ~/.mneme/index/hnsw.idx (atomic snapshot, postcard with magic prefix, schema v2 carries the embedded applied_lsn).
  • WAL: ~/.mneme/wal/<segment>.wal. Append-only. Group-committed with fdatasync. Replayed on boot from applied_lsn forward.

Snapshot schedule (this is the one running schedule today). The snapshot scheduler in memory/semantic.rs::scheduler_loop wakes on either:

  • Insert count threshold — default [checkpoints] hnsw_snapshot_inserts = 1000 (set in config.toml).
  • Time interval — default [checkpoints] hnsw_snapshot_minutes = 60.

When either fires, the scheduler:

  1. Takes the write lock (so no remember/forget is mid-flight).
  2. Rewrites hnsw.idx from the in-memory index, atomically.
  3. Truncates WAL segments fully covered by the new snapshot.

Time-based wakes without insert pressure are deliberate no-ops — the scheduler exists to bound the worst-case gap between snapshots, not to write empty ones.

A final snapshot is forced on graceful shutdown (mneme stop, SIGTERM, Ctrl-C) so the next boot skips WAL replay.

Crash recovery. On mneme run:

  1. Load hnsw.idx if present (gives applied_lsn).
  2. Replay WAL forward from applied_lsn.
  3. Open MCP server.

A kill -9 mid-snapshot leaves the old snapshot intact (atomic temp+rename); WAL replay covers the gap. Verified by tests/crash_recovery_semantic.rs.

Surfaced via:

  • Tools: remember, recall, update, forget.
  • No L4-specific resource; semantic results reach auto-context through mneme://context?q=<text> (see §6).

Filters and how they're satisfied. recall accepts scope, kind, tags (all must match), and min_similarity (a cosine- similarity floor, 1.0 = identical). The HNSW indexes vectors only, so these are applied after the search — and because a selective filter would otherwise leave the result short, recall widens its index probe geometrically until it has limit survivors or the index is exhausted. Unfiltered recall still issues exactly one probe.

What runs today: All of the above.

Changed in v1.3. tags and min_similarity are new, results now carry a similarity field alongside the raw cosine score, and the widening probe replaced a fixed limit × 4 fetch that silently underfilled whenever the requested scope or kind was a minority of the corpus. remember also now reports a duplicate_advisory in _meta when new content closely restates an existing memory — advisory only; the write still lands.

Changed in v1.5. remember names the closest current memory from similarity 0.80 up (related_memory, or duplicate_advisory at ≥ 0.95), in the reply text as well as _meta. remember and update take supersedes; superseded memories drop out of recall and auto-context unless include_superseded: true. recall is hybrid: vector search fused with BM25 keyword search over an in-memory index, so exact names are found reliably; mode selects hybrid (default), semantic, or keyword, and each row reports match.

Changed in v1.6. A memory has an updated_at: the last time update changed its content (never edited means created_at). update(id, status: "archived") takes a memory out of recall and auto-context while keeping it in the store and in export; status: "active" brings it back. Both are stored in side tables next to the mem: row (mts:<id> → big-endian i64 milliseconds, st:<id> → one byte, present only when archived), so the on-disk memory format and schema_version are unchanged and forget removes them with the memory. recall rows gain rank, updated_at and status.

Also in v1.6. A memory can carry typed relations and a provenance.

  • Relations. remember / update take relations: [{type, id | ref, reason}] with type supersedes, refines, contradicts or evidence_for. The target is a memory, an event (evidence_for only) or an external reference string (evidence_for only, opaque, at most 128 bytes). supersedes hides the target as before. refines and contradicts demote it while the refiner is current and newer: it stays in recall, flagged demoted, with its keyword evidence dropped and its rank lowered by [recall] demote_margin; auto-context leaves it out unless [auto_context] include_demoted. recall(ref=…) returns the memories citing a reference; recall(expand=1) quotes linked memories.
  • Provenance. provenance (user_stated, observed, inferred, imported) and a free-form source. Filterable in recall, counted in stats, no effect on ranking.
  • Storage. More side tables, so still no change to the memory format or schema_version: rel:<from><type><tag><target> and its mirror rrel:<tag><target><type><from> hold a relation's reason and creation time, prov:<id> the provenance; each value is a version byte followed by postcard. tag distinguishes a memory id, an event id and a reference. forget removes a memory's relations in both directions and its provenance, and a relation whose source memory is gone is ignored on read.
  • From the timeline. record_event(promote: {type, tags}) stores the event's text as a memory with an evidence_for link to the event. Still agent-driven: nothing is promoted unless asked.

6. Auto-context resource (mneme://context)

What it is. A pre-assembled context blob the agent can read at session start. Combines:

  • All pinned items from L0 (every one — they're a small set, and they are never trimmed).
  • The most recent turns from L1, the active working session.
  • Events from L3: the most recent ones, plus (with a ?q= seed) the best lexical matches for the query, de-duplicated and clipped.
  • L4 semantic hits, when the read carries a ?q= seed (see Parameters below).

Packed to a token budget ([budgets] auto_context_token_budget = 4000 by default) that is divided by layer shares from [auto_context]:

LayerShare
L0 pinsnever trimmed
L1 turnsat most 5% (working_max_share)
L3 eventsat most 35% (episodic_max_share)
L4 memoriesat least 30%, or 5 rows if smaller (semantic_min_share, semantic_min_items); no ceiling

Scoring. Scores order rows inside those shares.

  • A memory scores rank × 0.7 × freshness. rank is similarity plus keyword evidence, as recall reports it. freshness is max(0.75, 2^(−age/90d)), with age counted from the memory's last content edit (updated_at), not from when it was created.
  • An event scores retrieval_weight × 0.8 × recency × (β + (1−β)·lex). recency has a 14-day half-life on last_accessed; lex is how much of the query the event contains; β is 0.3. With no query lex is 1.
  • A working turn scores 0.9 × recency.

Event selection. Events of kind archived and events with retrieval_weight ≤ 0.3 are left out. Of the rest, exact duplicates and near-duplicates (word overlap ≥ 0.6) are dropped, at most 6 of one kind are kept, and payloads over 400 characters are clipped and flagged truncated. All of these are [auto_context] keys.

Parameters. resources/read hands the server a URI and nothing else, so parameters ride on the URI's query string:

ParamEffect
q (or query)Natural-language seed for L4. Without it the semantic array is empty — a vector search needs something to be similar to. Percent-encoded.
scopeOne scope or a comma-separated set (scope=a,b). Restricts L3 / L4 to those scopes; L0 returns their pins plus those of [auto_context] pin_scopes. L1 turns are session-local and always included.
limitSemantic over-fetch before the budget pass trims. Clamped server-side.
kindsComma-separated event kinds; the L3 section holds only these. Naming an auto-logged kind opts back in to it.
exclude_kindsComma-separated event kinds to hide from L3, on top of the default exclusions.

By default the L3 section leaves out the server's own tool_call, tool_call_failed, session_start and session_end events: in one deployment 56 of 61 context events were tool_call rows and they used most of the token budget. ?kinds=tool_call brings them back; recall_recent and mneme://recent still return every kind. Each L3 row also carries its retrieval_weight.

mneme://context                                  → L0 + L1 + L3
mneme://context?q=how%20do%20we%20deploy          → + L4 hits
mneme://context?q=deploy&scope=work               → all four layers; work, plus global pins
mneme://context?q=deploy&scope=work,infra         → two scopes, plus global pins

Unknown parameters and malformed values are ignored rather than rejected: auto-context is read unattended, and failing it closed would strand the session with no memory at all.

Embedding. Reads-only, except that a ?q= seed embeds the query string (once) before the HNSW search.

Schedule. None. The resource is assembled on demand when the agent reads mneme://context. Latency budget per spec §13: p95 < 200 ms, p99 < 400 ms.

Determinism. Given the same DB state and the same instant, the assembly is deterministic: the assembler takes the clock as a parameter. Verified by orchestrator::tests::build_context_is_deterministic and build_context_at_is_reproducible_for_a_fixed_now.

Surfaced via: Resource mneme://context (fixed form) and mneme://context{?q,scope,limit,kinds,exclude_kinds} (advertised via resources/templates/list).

What runs today: All of the above.

Changed in v1.3. Before v1.3 this resource passed no query and emitted a hardcoded empty semantic array, so no remembered memory could ever reach auto-context, and the working section was omitted from the response body entirely even though its turns were charged against the token budget. Both are fixed; ?q= and ?scope= are new.

Changed in v1.6. The flat 1/16-per-layer reserve is replaced by the layer shares above. Memories are scored on updated_at with a 90-day half-life and a 0.75 floor (it was 14 days from created_at). Events are ranked against the query, de-duplicated, capped per kind and clipped. ?scope= takes a set, and a scoped read also returns the pins of pin_scopes: before, ?scope=x dropped every global pin.


7. Configuration knobs

Every threshold above is overridable in ~/.mneme/config.toml. The defaults shown here come from Config::default in src/config.rs.

# Tier transitions (L3 episodic).
[consolidation]
hot_to_warm_days  = 28
warm_to_cold_days = 180
schedule          = "idle"   # only "idle" today; reserved for future modes

# Snapshot + checkpoint cadences (L4 + L1).
[checkpoints]
session_interval_secs   = 30
session_interval_turns  = 5
hnsw_snapshot_inserts   = 1000
hnsw_snapshot_minutes   = 60

# Active embedder (L4).
[embeddings]
model      = "bge-m3"        # or "minilm-l6"
device     = "auto"          # "cpu" / "metal" / "cuda" override
batch_size = 32

# Auto-context budget.
[budgets]
default_recall_limit       = 10
auto_context_token_budget  = 4000

# Which tool calls are mirrored into L3 as `tool_call` events.
[episodic]
auto_log_tool_calls = "writes"   # "writes" | "all" | "off"

# What write tools do with credential-shaped content.
[guardrails]
secrets = "reject"               # "reject" | "warn" | "off"

Pick a smaller model (minilm-l6) and a tighter snapshot cadence (hnsw_snapshot_inserts = 200) on resource-constrained machines. Pick larger thresholds (e.g. hnsw_snapshot_minutes = 240) on heavy write workloads where snapshots are starting to dominate I/O.


8. What gets embedded — at a glance

OperationEmbedder called?Why
rememberYesEvery L4 memory needs a vector for recall.
update (changes content)YesRe-embed via WalOp::VectorReplace.
update (only tags/scope/type)NoMetadata-only path skips the embedder.
forgetNoTombstone the vector; no new embedding.
pin / unpinNoL0 is exact-match.
recall_recent / summarize_session / record_eventNoL3 is lexical/temporal (ADR-0007).
recallYes (query side)Embeds the query string before the HNSW search.
Reading mneme://contextSometimesOnly if you pass a query parameter.
Reading mneme://stats / mneme://procedural / mneme://recentNoDirect lookups.
Booting mneme run after model swapYes — for every stored memoryembed::migrate::migrate_if_needed. Logged loudly.

The embedder is a synchronous, batched worker (default batch_size = 32). On bge-m3 cold-cache, expect ~70 ms per embedding on Apple Silicon Metal; on minilm-l6, ~5 ms. Recall adds the query-embed step + the HNSW search.


9. Where memory lives on disk

~/.mneme/
├── config.toml                     # all thresholds; user-editable
├── schema_version                  # plain integer; bumped by migrations
├── .lock                           # PID file, exclusive lock
│
├── procedural/
│   └── pinned.jsonl                # L0; watched every 500 ms
│
├── sessions/                       # L1; one snapshot per session
│   └── <session_id>.snapshot
│
├── episodic/                       # redb file shared by L3 + L4
│                                   #   epi:<ulid>  → hot L3
│                                   #   wepi:<ulid> → warm L3
│                                   #   mem:<ulid>  → L4 memory rows
│
├── wal/
│   └── <segment>.wal               # L4 write-ahead log
│
├── index/
│   └── hnsw.idx                    # L4 snapshot (atomic temp+rename)
│
├── cold/
│   └── 2026-Q1.zst                 # L3 cold tier, one bundle per quarter
│
├── models/
│   └── <model-id>/                 # downloaded weights + tokenizer
│
└── logs/
    └── mneme.log                   # human-readable, rotated at 100 MB × 5

mneme stats reports per-layer counts plus the applied_lsn of the most recent snapshot. mneme inspect <ulid> reads any single row. mneme export dumps everything to JSON (semantic / procedural / episodic keyed) for grepping or piping to jq.


10. FAQ

Q: I remember'd something five minutes ago. Will I lose it if my laptop crashes right now? No. remember is synchronous; it returns only after the WAL has fsynced the vector + content. Worst case after a crash is up to 60 minutes of WAL to replay (or 1000 inserts since the last snapshot, whichever came first). The data is durable, restart is just slower without the snapshot.

Q: Why isn't my old episodic event being archived to cold tier even though it's two years old? Two reasons it can stall: (1) the system never went idle long enough for the scheduler's idle gate to close — every remember / forget / record resets the window, so a constantly-active mneme delays consolidation; (2) the event hasn't yet aged past hot_to_warm_days / warm_to_cold_days. Inspect mneme://stats under the consolidation key: last_consolidation_at is the wall-clock of the last pass, runs_total confirms the scheduler is actually firing, and hot_oldest_age_days, hot_eligible_for_warm and next_promotion_in_days say how far the oldest event is from the threshold.

Q: consolidation.runs_total is in the hundreds but nothing was ever promoted. Is it broken? No. A run with nothing old enough to move promotes nothing. With the defaults the first promotion cannot happen before an event is 28 days old, so zero promotions in the first four weeks is expected. Check next_promotion_in_days for the countdown.

Q: Does mneme embed my pinned items so they show up in semantic recall? No. Pinned items are L0 procedural — they're returned verbatim from mneme://procedural and packed into mneme://context on every read. If you want a pinned item also searchable semantically, call both pin and remember with the same content (or pin it and let the agent decide to also remember notable rules).

Q: I changed model = "bge-m3" to model = "minilm-l6" in config.toml. What happens on the next mneme run? On boot, embed::migrate::migrate_if_needed notices the embedder identity changed, re-embeds every L4 memory under the new model through the WAL, and writes a new HNSW snapshot. If you have 10K memories under MiniLM, expect a few minutes of one-time work; the log line is loud (re-embedded memories under new embedder identity). After that, recall uses the new model.

Q: What happens to vectors during mneme backup and mneme restore? mneme backup tar+gzips the data directory. The model cache (models/) is excluded by default — re-downloadable, big, not worth the bytes. The HNSW snapshot, WAL, redb file, and procedural JSONL are all included. mneme restore is atomic (temp+rename) and refuses to overwrite a directory where another mneme is running. After restore, the next mneme run boots from the restored snapshot + WAL exactly as if the original process had just stopped.


11. See also

  • docs/CLAUDE_CODE_SETUP.md — getting mneme wired into Claude Code, plus the patterns that make it pay off.
  • The crate-level rustdoc (cargo doc --open) — MnemeError, the three trait seams (Storage / Embedder / VectorIndex), and per-module documentation cover the implementation in detail.