Agent memory whose dated chat facts live in an append-only valid-time journal, grounded in the user's own words

eimemory

Local-first memory and evidence-gated learning for long-running agents, in MIT Python: scoped SQLite recall, and an append-only valid-time journal for dated chat facts.

LicenceMIT in LICENSE and pyproject.toml
Size245,926 lines of Python in 668 files under eimemory, 82,690 of them the governance and self-improvement layer and about 45,000 the storage, retrieval and recall packages; 21,142 lines of deployment scripts, 6,217 lines of host integrations, and 257,073 lines of tests
Activity2,023 commits on master dated 21 April to 3 December 2026, 1,684 under the maintainer's account and the rest under thirteen other names, among them codex and cursoragent; package version 1.15.105
Tests9,948 pytest functions in 1,025 test files; CI runs every test not marked slow on four xdist workers on each push to master, plus a named business-closure subset; none run here

Carries 4 of 7 rubric mechanisms. Most systems here carry none or one (41%), and a dash means the mechanism was not found at this commit — not that the system needed it. Each mark is one LLM reviewer's reading of the code at this commit rather than a run of it — known limits.

  • Tombstone
  • Trust state
  • Bi-temporal
  • Scope enforced
  • Mutation audit
  • Human review
  • Negative evals

1. Executive Summary

eimemory is a local-first memory runtime for long-running agents, wired into Hermes Agent, Codex and OpenClaw, with a self-improvement layer on top that proposes, evaluates and promotes changes to its own policies and code. Memory is one SQLite database of record envelopes, mirrored to JSONL. Each host turn is captured, and a background worker extracts facts, preferences and instructions from it with a model.

Notable: a fact the user states with a date ("since 2021-06-01, node007's region is East") becomes a row in an append-only journal with a validity interval taken from the user's own characters and a record time from the clock. Recall resolves such facts at the current time or at the date the question names. Corrections and retractions are appended, bounded to an interval, and cannot resurrect what they masked.

Weak: the memory core sits inside about 246,000 lines of Python, a third of it governance. Every other record changes in place, and removing a memory does not stop extraction or a re-add from restoring it. Scope comes from the caller. The project's own receipts record formal recall acceptance at 0 of 3 cases.

Four marks are present and three withheld (section 9).

Licence. MIT in LICENSE (copyright 2026 The eimemory Authors) and in pyproject.toml, with no rider. The core declares no runtime dependencies, and the optional extras bound or pin theirs. There is no SECURITY.md; the README names a maintainer contact. The Hermes host patches ship as .patch files against another project's source, and the tree states no licence for the patched code.

2. Mental Model

Everything is a RecordEnvelope: a kind from a fixed set of 50, a status, a four-part scope, a source partition, links, evidence and metadata (eimemory/models/records.py:22-75, :138-217). A host turn is an L0 conversation record. An L1 record is what a model extracted from one turn. A record is believed while its status is active; supersession, removal and the capture gate move it to superseded, removed or rejected, and recall drops those (eimemory/storage/sqlite_store.py:5621-5623).

Dated chat facts follow a second, stricter model. A grounded fact is an L1 record plus a journal row in a fact family keyed by owner, channel, entity and attribute. The row holds an operation — claim, transition, correction or retraction — an interval, the targets it masks and digests of its evidence (eimemory/contracts/temporal_facts.py:166-198). What is true at an instant is computed by replaying the family: each covering operation masks its targets, retractions add no value, and two values for a single-valued attribute are a conflict (:239-266).

Diagram — a dated statement becomes an append-only journal row; recall keeps a managed fact only when its family resolves to it at the asked time, and a withdrawn source empties the whole answer
Diagram source
%% caption: a dated statement becomes an append-only journal row; recall keeps a managed fact only when its family resolves to it at the asked time, and a withdrawn source empties the whole answer
flowchart TD
    TURN["Host turn<br/>sync_turn"] --> L0["L0 record<br/>active"]
    L0 --> W["L1 worker<br/>every 30 seconds"]
    W --> M["Extraction model<br/>proposes atoms"]
    M --> G{"ground_assertion:<br/>literal date and<br/>fields in user text?"}
    G -- "no" --> J0["Model judge<br/>store, skip, update"]
    G -- "yes" --> F["L1 fact record"]
    F --> JR["Journal row<br/>insert once, CAS<br/>on family head"]
    J0 --> SUP["Supersede by<br/>title key or target"]
    Q["recall query"] --> IDX["Recall index<br/>exact scope,<br/>withdrawn dropped"]
    IDX --> R{"managed<br/>chat fact?"}
    R -- "no" --> OUT["Candidate kept"]
    R -- "yes" --> C{"family resolves<br/>to it at the<br/>asked time?"}
    C -- "yes" --> OUT
    C -- "no" --> DROP["Withheld"]
    OUT --> EV{"every source<br/>current?"}
    EV -- "no" --> EMPTY["Whole bundle<br/>unavailable"]
    EV -- "yes" --> CTX["Delivered"]

3. Architecture

Runtime is the in-process facade; it opens a RuntimeStore and a MemoryAPI, and in the default full profile also capability, evolution, proactive and safety services (eimemory/api/runtime.py:90-140). RuntimeStore owns a single writer connection under a lock, a pool of read-only WAL readers, and a transactional outbox that copies every committed record snapshot to segmented records.jsonl and every record to Markdown after commit (eimemory/storage/runtime_store.py:252-278, :665-685, :2871-2897). SqliteRecordStore is 9,203 lines: records, the recall index and FTS5, edges, events, proactive decisions and migrations.

Hosts reach it three ways. The Codex plugin runs eimemory codex-hook on four lifecycle events and serves an MCP server; Hermes loads a memory provider from integrations/hermes/eimemory; OpenClaw loads a Node plugin. Remote hosts call a loopback HTTP RPC that requires one bearer token for every ordinary method, with separate producer tokens for attestation methods and none for health (eimemory/adapters/eibrain/rpc_server.py:197-267).

The governance plane is most of the code: capability registries, evaluation catalogs, hypothesis and replay packs, code-patch proposal, promotion and rollback, release closure and "L5" readiness assessments (docs/architecture.md:164-195). The architecture's tenth design rule lets a verified local code patch be applied by machine gates without a human approval queue (docs/architecture.md:27-29). This report reads that plane only where it touches memory.

Deployment and ergonomics

pip install -e . and eimemory init give a working local store with no third-party dependency. Production is an immutable release under /opt/eimemory, a user systemd RPC service on port 8091, and fourteen timers (deploy/systemd/). PostgreSQL with pgvector and an OpenAI-compatible embedding service are optional; without them recall is lexical, hashed-vector and graph. Extraction needs a model command configured as a JSON argv array in EIMEMORY_LLM_COMMAND or a per-purpose variant (eimemory/llm/command_client.py:373-382).

4. Essential Implementation Paths

  • Capture a turn. Host hook → AgentRuntimeMemoryService.sync_turn → an L0 conversation record, then either inline extraction or a queued job (eimemory/adapters/runtime/service.py:917-1015).
  • Extract. extract_l1_from_l0_record → extract_l1_atoms with the model, adjudicate_l1_atoms against up to five similar active L1 memories, then persist_l1_atoms (eimemory/knowledge/l1_conflict.py:44-125, eimemory/knowledge/l1_pipeline.py:227-308).
  • Ground a dated fact. ground_observation → ground_assertion checks the model's literals against the user's characters; persist_observation ingests the L1 record and appends the journal row under the family head (eimemory/knowledge/chat_temporal.py:288-378, :714-825).
  • Ingest directly. MemoryAPI.ingest: capture score, persist a reject as rejected, or append and supersede by semantic_key inside one transaction (eimemory/api/memory.py:200-373, eimemory/storage/runtime_store.py:461-634).
  • Mutate from Hermes. Hermes's own memory tool → on_memory_write → adapter.mutate_memory → add, replace or remove under a content-revision check (eimemory/adapters/hermes/provider_core.py:880-915, eimemory/adapters/runtime/service.py:604-915).
  • Recall. MemoryAPI.recall → GovernedRecallEngine.recall → scoped candidates, scoring, graph expansion, final evidence admission, then the chat-temporal resolution (eimemory/api/memory.py:802-892, eimemory/retrieval/engine.py:413-415).

5. Memory Data Model

  • records: one row per record and source partition, with the envelope as JSON and projected columns for kind, status, scope and source. Three times sit on every envelope — created_at, updated_at, occurred_at — all set from the clock unless the writer or a source binding supplies occurred_at (eimemory/models/records.py:163-172, eimemory/api/memory.py:261-266).
  • recall_index and recall_index_fts: a lane, a visibility, quality score, title, anchor terms and body per active record, with the same four scope columns.
  • memory_edges: typed edges with confidence, evidence id, scope and a reason, written for supersession, removal and journal targets.
  • export_outbox: committed snapshots waiting to be appended to JSONL; exported rows beyond the newest 10,000 are pruned (eimemory/storage/sqlite_store.py:2677-2690).
  • Temporal journal rows: kind="unknown", status="inactive", id mem_tf_<digest>, and under living_memory_v1.temporal the operation, interval, targets, family id and sequence, commit_order, recorded_at, authority, request digest and evidence digests (eimemory/storage/runtime_store.py:346-370).

Statuses on memory records are lifecycle values. The recall filter also names refuted and expired, and no writer in the package assigns either literal (recorded search below).

6. Retrieval Mechanics

Candidates come from FTS5 BM25 over the recall index, a LIKE pass over title, anchor terms and body for up to eight query terms, then lane seeds or recent records when both find nothing (eimemory/storage/sqlite_store.py:5144-5256, :5430-5520). Every candidate query carries _recall_index_where: withdrawn statuses excluded, kind, lane and visibility allowlists, raw and conversation types excluded unless evidence is requested, and the scope predicate (:5612-5682).

Scoring hydrates each row, drops any not active or rejected by the capture gate, and combines lexical signal, character-trigram Jaccard, cosine over a 128-bucket hashed token vector, stored quality and source weight (:4886-4990, eimemory/embeddings/local.py:11-49). The hashed vector is lexical in effect; semantic retrieval needs the optional PostgreSQL arm. The default balanced profile expands one hop over links and memory edges (eimemory/api/memory.py:2128-2148, eimemory/retrieval/engine.py:1160-1215).

Two gates run last. The current-evidence check walks each delivered record's sources to depth 32 and, if any is withdrawn, changed or unreadable, returns an empty bundle marked unavailable rather than a partial one (eimemory/knowledge/current_evidence.py:25-42, eimemory/api/memory.py:902-923). Then the chat-temporal pass replaces managed facts with the members their family resolves to at the asked time (eimemory/knowledge/chat_temporal.py:1238-1345). The asked time is the current second, or the single date the query attaches to an operator such as "as of" or "截至"; a question with a relative time word gets no managed fact (:74-97).

7. Write Mechanics

A turn write is synchronous and cheap: one L0 record. Extraction is queued to state/l1_extract_queue.json and drained by the L1 worker every 30 seconds, so an extracted fact is retrievable within about half a minute of the turn (deploy/systemd/eimemory-l1-extract.timer). Under pytest, or with EIMEMORY_L1_EXTRACT_INLINE=1, extraction runs inline; under pytest it also uses a heuristic in place of the model (eimemory/adapters/runtime/service.py:972-975, :1037-1041).

The model judge compares each atom with similar active L1 memories in the same scope and source and answers store, skip, update or merge; with no similar memory it stores without a call. Managed chat facts are excluded from its candidates, because only the journal may mask them (eimemory/knowledge/l1_conflict.py:79-82, :123-124). Direct ingest of a durable type supersedes on semantic_key, a hash of memory type and lowercased title, so the same title replaces and a reworded title does not (eimemory/knowledge/sediment.py:212-214).

A dated fact is accepted only when every model field is a literal span of the user's message in the right order, the date sits in a business-date role, and a correction or retraction carries the word and a closing date (eimemory/knowledge/chat_temporal.py:288-378). Anything else is stored as an unresolved observation and never becomes a current value.

Operational cost

One extraction call per turn, plus one judge call when a similar memory exists. No pass rewrites the whole store; the nightly job runs maintenance and evaluation, and the learning timers write their own record kinds.

8. Agent Integration

The Codex MCP server registers eimemory_recall, eimemory_remember, eimemory_verify_outcome and eimemory_status (eimemory/adapters/codex/mcp_server.py:178-235); the Hermes provider adds eimemory_search_l0 (eimemory/adapters/hermes/provider_core.py:815-870). Hooks do the routine work: prefetch before a prompt, capture after a turn. The Hermes host patch forwards Hermes's own memory tool writes, so the agent's add, replace and remove on its built-in memory become revision-checked mutations here.

Each channel's scope gets its own workspace suffix, so Codex and Hermes do not read each other's memory unless a caller names the other workspace (eimemory/adapters/runtime/channel.py:18-29, README.md:234-236).

9. Reliability, Safety, and Trust

The journal is grounded twice

At write, ground_assertion refuses a model proposal whose subject, attribute, value or date is not a span of the original user text, or whose connective does not match the operation. At read, access_for re-runs the same grounding against the parent turn and requires it to equal the stored one, so an edited parent makes the family unavailable rather than wrong (eimemory/knowledge/chat_temporal.py:399-427). The write is a compare-and-swap on the family head, inside the same transaction as the target reads (eimemory/storage/runtime_store.py:304-381).

A retraction masks its target for its interval and contributes no value, so a retracted later value does not bring back its predecessor; the docstring states that reverting requires a new assertion (eimemory/contracts/temporal_facts.py:239-245).

Removal is not durable

The Hermes remove writes a contentless removal record and marks the target removed (eimemory/adapters/runtime/service.py:864-913). An add of the same text checks the removal's integrity and then creates a new incarnation with a restores link (:695-790). The L1 extractor never consults removals, so the same statement in a later turn is extracted again.

Scope and the RPC

The scope predicate is equality on tenant, agent and workspace and on user or the empty user, for every candidate query (eimemory/storage/sqlite_store.py:5664-5682). The RPC authenticates ordinary methods with one bearer token and takes the scope from the request (eimemory/adapters/eibrain/rpc.py:93-123), so any token holder may name any workspace. For the configured primary agent, hongtu_query_scopes adds legacy agent and workspace ids to the read (eimemory/identity.py:261-291).

Review is a string

Intake candidates move through reviewed, rejected, quarantined and deprecated with a reviewer the caller passes; the CLI defaults it to cli (eimemory/intake/review.py:25-31, :96-127, eimemory/cli/main.py:259). Promotion accepts a candidate that was never reviewed (eimemory/intake/review.py:185).

Marks

  • bitemporal — present. Journal validity from the user's literal date, record time and commit order from the server, and a recall that resolves at the asked time; limited to grounded chat facts, and no as-of-record-time read.
  • scope_enforced — present. Four-part equality predicate on every candidate query; the scope is the caller's.
  • audit_log — present. The temporal journal is insert-once, refused to generic writes, rewrites and scope moves; it covers dated chat facts only.
  • negative_eval — present. Populated absences for corrected and not-yet-valid values through the real capture path, and for another workspace.
  • trust_state — withheld. Record statuses are lifecycle values; the grounding state resolved or unresolved is fixed at write and nothing moves it; refuted is filtered and never written; intake review statuses belong to a source queue before anything becomes memory.
  • tombstone — withheld. The removal record is keyed on the content revision, and the add path uses it to restore the value, not to refuse it.
  • human_review — withheld. The reviewer is a caller-supplied name, the same CLI is open to any shell, and promotion skips review.

10. Tests, Evals, and Benchmarks

9,948 pytest functions in 1,025 files. CI runs every test not marked slow on four xdist workers on each push to master, plus a named business-closure set (.github/workflows/project-validation.yml:1-60, :395-410). I ran none of them.

The temporal tests are the strongest. test_ordinary_chat_temporal_grounding.py drives real turns through sync_turn, the L1 path, the journal and prefetch, with only the model replaced by an echo, and pairs each absence with a presence at the same date (:85-115); test_temporal_facts.py covers CAS winners, cycles, rollback and the append-only guard (:307-379). The fixture runs under pytest, so it exercises the inline path that PYTEST_CURRENT_TEST selects rather than the queued worker production uses (tests/test_ordinary_chat_temporal_semantics.py:103-123).

The Hermes remove tests assert that neither removed record is recalled with all(...) over a store that holds no other match, so an empty result passes them (tests/test_runtime_adapter_rpc.py:227-228, :315-316).

The repository carries LongMemEval and LoCoMo converters and smoke datasets under examples/evaluation/, and no committed result. The README reports deployment receipts and records formal recall acceptance at 0 of 3 cases (README.md:532-546). No paper describes eimemory: CITATION.cff is absent, and the arXiv references in the tree belong to the paper-intake code and its notes.

11. For Your Own Build

Steal

  • Ground a model's fields in the user's characters. Accept a dated fact only when subject, attribute, value and date are spans of the original message, and re-check that on read against the stored parent.
  • Mask, do not resurrect. A bounded retraction that removes a value without restoring its predecessor avoids the "undo brings back the wrong answer" failure.
  • Fail the whole answer on stale evidence. Returning nothing when one delivered record's source was withdrawn is harsher than filtering and cannot leak the withdrawn text through an explanation lane.
  • Make the mutation revision-checked and idempotent. A SHA-256 of the old text plus an idempotency key turns a racing double write into a clean error.

Avoid

  • Do not branch production on the test runner. A pytest variable that selects inline extraction and a heuristic means the suite verifies a path the deployment does not run.
  • Do not let a re-add quietly undo a removal. If removal matters, the extractor and the add path both need to consult it.
  • Do not take scope from a shared-token caller when several users share a deployment.

Fit

Fits an operator running Hermes, Codex or OpenClaw for themselves on one Linux host who wants turn capture, scoped recall and dated facts that answer "as of" questions correctly, and who will run systemd timers and read receipts.

Walk away if you want a memory library to embed: the memory core cannot be taken without the governance plane, the README is a release log, and the deployment is fourteen timers. Walk away too if users must not read each other's memory over the RPC, or a removed memory must stay removed.

12. Open Questions

  • Whether removal is meant to block re-extraction of the same statement.
  • Whether refuted and expired have a planned writer, given the recall filter names both.
  • Whether a known-time read is planned for the journal, which stores recorded_at and commit_order and refuses known_at.
  • How the formal recall acceptance in the README is meant to move from 0 of 3.

Appendix: File Index

  • Model: eimemory/models/records.py
  • Memory facade: eimemory/api/memory.py, eimemory/api/runtime.py
  • Store: eimemory/storage/runtime_store.py, eimemory/storage/sqlite_store.py, eimemory/storage/jsonl.py
  • Temporal facts: eimemory/contracts/temporal_facts.py, eimemory/knowledge/chat_temporal.py
  • Extraction: eimemory/knowledge/l1_pipeline.py, eimemory/knowledge/l1_conflict.py, eimemory/knowledge/sediment.py, eimemory/cli/l1_worker.py
  • Retrieval: eimemory/retrieval/engine.py, eimemory/retrieval/sqlite_source.py, eimemory/knowledge/current_evidence.py, eimemory/embeddings/local.py
  • Host surface: eimemory/adapters/runtime/service.py, eimemory/adapters/runtime/channel.py, eimemory/adapters/eibrain/rpc.py, eimemory/adapters/eibrain/rpc_server.py, eimemory/adapters/codex/mcp_server.py, eimemory/adapters/hermes/provider_core.py, integrations/
  • Review: eimemory/intake/review.py
  • Safety audit chain: eimemory/governance/safety/audit.py, eimemory/governance/safety/kill_switch.py
  • Tests: tests/test_ordinary_chat_temporal_grounding.py, tests/test_ordinary_chat_temporal_semantics.py, tests/test_temporal_facts.py, tests/test_recall_fts_parallel_rrf.py, tests/test_runtime_adapter_rpc.py

Recorded searches

Run from the repository root at the pinned commit with /usr/bin/git grep. .gitmodules is absent.

  • No writer assigns refuted or expired. git grep -n -E 'status *= *"(refuted|expired)"' -- eimemory returns nothing; the same pattern for superseded returns three writers, including eimemory/api/memory.py:397.
  • The hash-chained audit log covers the kill switch only. git grep -n -E 'AuditLog\(' -- eimemory returns the verifier, the reseal tool and one appender, eimemory/governance/safety/kill_switch.py:96.
  • Extraction does not consult removals. git grep -n -E 'removed_by|mutation_state' -- eimemory/knowledge eimemory/api/memory.py returns the supersession writers, the current-evidence reader at eimemory/knowledge/current_evidence.py:39, and the L1 edit path stripping those keys at eimemory/knowledge/l1_pipeline.py:787-800; nothing on the extraction or adjudication path.
  • No actor check on intake review. git grep -n -E 'isatty' -- eimemory/intake eimemory/cli returns nothing; eimemory/cli/main.py:259 sets --reviewer with default cli.
  • No security policy file. git ls-files | grep -i -E '(^|/)security\.md$' returns nothing.
  • No paper. CITATION.cff is absent; git grep -n -i -E 'arxiv|doi\.org|bibtex' -- README.md FAQ.md docs/README.md docs/architecture.md docs/COMPARISON.md CONTRIBUTING.md returns nothing, and the 64 files matching across the tree are the paper-intake code, its tests, and release and audit notes.

History

2026-12-04 — 45d22f1a…. First reading, from the 2026-12-04 triage shortlist, at the head of master reached on 2026-12-04; the shortlist assessed cddce87aa726, which the depth-1 clone does not hold. Screened: no auto-run surface; one build-time execution point (tests/conftest.py); two dependency surfaces inside the cooldown (pyproject.toml, integrations/openclaw/eimemory-bridge/package.json), a count the depth-1 clone inflates; one floating surface (pyproject.toml). Nothing was installed, built or run, and none of the 9,948 test functions was run. Four marks (section 9).