Skip to content

store

diapason.memory.store

Persistent stores for automatically extracted long-term memory facts.

A fact is a short, durable statement worth remembering about the user (e.g. "Prefers concise answers"). Facts are produced by the memory service's background extractor and persisted here so they survive across sessions. The store is intentionally small and self-contained: it dedupes, caps the total number of facts, and is safe to call from multiple threads.

Fact dataclass

A single durable memory entry.

FactStore

Bases: ABC

Abstract persistent store for extracted memory facts.

add(text, source='') abstractmethod

Store text as a fact. Returns True if a new fact was stored.

add_many(texts, source='')

Store several facts, returning the count of newly stored ones.

clear() abstractmethod

Remove all stored facts, returning the number removed.

count() abstractmethod

Return the number of stored facts.

list() abstractmethod

Return all stored facts, oldest first.

LocalFactStore

Bases: FactStore

Append-only JSONL fact store on the local filesystem.

Facts are kept human-readable (one JSON object per line) so they can be inspected or edited by hand. Writes are atomic (temp file + rename) and guarded by a lock, so concurrent add calls from the extraction worker and list/clear from the CLI never corrupt the file.

path property

Filesystem location of the JSONL store.

SearchableFactStore

Bases: FactStore

Écrit chaque fait DEUX fois : dans le journal, et là où on le relira.

Constaté le 22 août 2026. Le service d'extraction rangeait ses faits dans memory_facts.jsonl ; l'injection de contexte, elle, interrogeait le magasin vectoriel de memory.db. Deux magasins qui ne se croisaient jamais : Diapason extrayait correctement « le projet Olala doit être publié sur l'App Store avant fin septembre », le rangeait, et ne le retrouvait plus jamais. La mémoire automatique écrivait dans le vide.

Le journal reste : il est append-only, lisible et modifiable à la main, survit à une base corrompue, et c'est LUI qui dédoublonne. Seul un fait réellement nouveau part à l'indexation — réindexer un doublon coûterait un calcul d'embedding pour rien et polluerait les résultats.

Une panne du magasin de recherche ne fait pas perdre le fait : le journal a déjà écrit, et l'échec est journalisé plutôt qu'avalé.

create_fact_store(backend='local', *, path=None, max_facts=1000)

Construct a fact store for the configured backend.

Only the "local" (on-disk JSONL) backend is supported today; the registry-backed constructor exists so additional backends can be added without changing the service or CLI wiring.