feat(engine): pluggable memories storage backend - #2917
Draft
nicoloboschi wants to merge 1 commit into
Draft
Conversation
nicoloboschi
force-pushed
the
feat/pluggable-memories-provider
branch
5 times, most recently
from
July 28, 2026 18:04
3349b45 to
a5aecde
Compare
…ts/chunks Squashes the feat/pluggable-memories-provider work into one commit. - Carve the `memory_units` + link slice out from behind raw SQL into a pluggable MemoriesExtension (engine/memories/), so a different engine (memlake) can own memories, links, retrieval, consolidation and curation while documents, chunks, banks and the entity registry stay in Postgres. The default PostgresMemories keeps everything exactly where it was; every call site routes through the store interface rather than branching on the implementation. - Route recall (semantic+BM25+graph), scan/get, stats/counts, consolidation writes, curation edits, bank/document deletion, entity postings and graph reads through the store. - Cross-store write-group transactions (begin/decide/mint/witness + recovery sweep) so a store that keeps memories elsewhere commits atomically with the Postgres side of a retain/consolidation/curation/delete. - Documents & chunks: when the store owns a dedicated document store (owns_document_store), a document's bulky extracted text + chunk texts move out of Postgres into it (Postgres keeps thin rows: id, content_hash, chunk_index, tags); reads overlay the text from the store; the original file goes through a memlake FileStorage backend. All gated so the Postgres path is unchanged.
nicoloboschi
force-pushed
the
feat/pluggable-memories-provider
branch
from
July 28, 2026 18:47
a5aecde to
9a4a917
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The
memory_unitstable and the joins around it (memory_links,unit_entities) are as much a search index as a store — every recall arm (semantic, BM25, graph, temporal) is a query over them. Today that's hard-wired to Postgres SQL, scattered across the retain, recall, consolidation, curation and graph-maintenance paths.This makes that slice a pluggable extension point, so a different engine can own memory storage and retrieval without touching how documents, chunks, banks, operations or the entity registry are stored. It's loaded like every other Hindsight extension:
With nothing configured, behaviour is identical to today — the default is now an explicit
PostgresMemoriesimplementation rather than the absence of one.Shape of the change
MemoriesExtension(engine/memories/base.py) covering the write path, the recall arms, addressed reads, the graph view, observations and the maintenance passes. An implementation may be the sole store: it mints its own unit ids and carries entity postings / causal edges inline, so nothing memory- or link-shaped need reach Postgres.PostgresMemoriesis a thin delegator; its SQL moves unchanged intoengine/memories/pg/{curation,graph,reads,writes}.py, grouped by what calls it. Because it's an explicit store, the default path stays the one the whole suite exercises.observation_historydrops its FK tomemory_units, which assumed every observation is a row there — true only while Postgres is the store.Compatibility & risk