You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 014cd9d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(memory): carry the scope registry and the wiki pages through a JSON export and import
The JSON export now holds the brain's memory_scopes rows (with their compile
watermark) as scopes and its memory_pages rows as pages. The JSON import brings
them back by the rules the SQLite import already follows, now shared in
importPages.ts: a scope the brain registers keeps its own row, a page the brain
holds is kept and the file's chunks of it stay out, any other page comes in
with its chunks written as traces of their own and listed under the ids they
were written under, and a message is never merged into a page chunk of the
same text. Before, a JSON round trip dropped every page row and left the page
chunks in the store with no row that lists them, still recalled.
The docs say what the JSON export carries, and that Brain.importFromSqlite
refuses a file whose page and registry rows name more than one brain.
Signed-off-by: jddunn <[email protected]>
Copy file name to clipboardExpand all lines: docs/MEMORY_OPERATIONS.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -525,7 +525,7 @@ All under [`src/cognition/memory/io/tools/`](https://github.com/framerslab/agent
525
525
## Import and Export
526
526
527
527
528
-
> The Memory I/O subsystem exports to four formats and imports from six. The SQLite and JSON exports carry the whole brain: JSON holds traces, graph rows, documents, chunks, images, conversations, and messages. Markdown and Obsidian exports carry the active traces only. Trace deduplication is on by default on import.
528
+
> The Memory I/O subsystem exports to four formats and imports from six. The SQLite and JSON exports carry the whole brain: JSON holds traces, graph rows, documents, chunks, images, conversations, messages, the registry of conversation scopes and each subject's wiki pages. Markdown and Obsidian exports carry the active traces only. Trace deduplication is on by default on import.
A single structured JSON document containing the full portable brain payload. Designed for programmatic consumption, browser-safe transfer, and cross-runtime restore.
558
+
A single structured JSON document containing the full portable brain payload, with the registry of conversation scopes (`scopes`, each with its compile watermark) and each subject's wiki pages (`pages`, each listing its chunks among `traces`). Designed for programmatic consumption, browser-safe transfer, and cross-runtime restore. Its import brings the scopes and the pages back by the rules of the SQLite import ([Memory storage](memory/MEMORY_STORAGE.md#export-and-backup)).
The `sqlite` export goes through [`Brain.exportToSqlite(targetPath)`](https://github.com/framerslab/agentos/blob/master/src/cognition/memory/retrieval/store/Brain.ts), from a SQLite or a Postgres brain alike: it writes this brain's rows of every portable table to a new file, the registry of conversation scopes (`memory_scopes`) and each subject's wiki pages (`memory_pages`) with them, and throws when the target exists. A Postgres brain, and a SQLite file in WAL mode as `Brain.openSqlite` opens one, are read from one consistent view of the database; a brain on one connection, such as an in-memory SQLite database, is read statement by statement. Its `brain_meta` rows carry the brain's scope-id form record where the brain has one, read before the rows and again after them, and the export copies again when a re-file commits while it reads, so the file's record names the form its rows are in and an import of the file keeps the form ([A Brain's scope-id form](../MEMORY_OPERATIONS.md#a-brains-scope-id-form)).
227
227
228
-
An import of that file (`mem.importFrom('./backup.sqlite')`, or `Brain.importFromSqlite`) brings the pages and the registry back. A scope the brain already registers keeps its own row and compile watermark, and any other comes in with the file's, so its next compile does not read the same traces again; a message the import stores under a scope the brain had compiled past that message's time moves the scope's watermark back to just before it, so its next compile reads it. A message is never matched as a duplicate of a page chunk of the same text. A file whose `memory_scopes` or `memory_pages` table cannot be read is refused before anything is written, with the reason in `errors`, and a file whose rows of any table, the two tables among them, belong to more than one brain is refused as such. A page the brain already holds, by scope and page id, is kept: the file's page is skipped, and so are that page's chunks. Any other page comes in with its chunks, written as traces of their own, and its row lists the ids they were written under. `Brain.importFromSqlite(file, { strategy: 'replace' })` empties both tables for the brain first, as it empties the portable tables. The JSON, Markdown and Obsidian exports carry traces, the chunks of pages among them, and no page row and no registry row: use the `sqlite` format to move a store whose subjects have pages.
228
+
An import of that file (`mem.importFrom('./backup.sqlite')`, or `Brain.importFromSqlite`) brings the pages and the registry back. A scope the brain already registers keeps its own row and compile watermark, and any other comes in with the file's, so its next compile does not read the same traces again; a message the import stores under a scope the brain had compiled past that message's time moves the scope's watermark back to just before it, so its next compile reads it. A message is never matched as a duplicate of a page chunk of the same text. A file whose `memory_scopes` or `memory_pages` table cannot be read is refused before anything is written, with the reason in `errors`, and a file whose rows of any table, the two tables among them, belong to more than one brain is refused as such (`Brain.importFromSqlite` throws, naming the brain ids, when its `brain_meta`, `memory_scopes` and `memory_pages` rows name more than one). A page the brain already holds, by scope and page id, is kept: the file's page is skipped, and so are that page's chunks. Any other page comes in with its chunks, written as traces of their own, and its row lists the ids they were written under. `Brain.importFromSqlite(file, { strategy: 'replace' })` empties both tables for the brain first, as it empties the portable tables. The JSON export carries the registry (`scopes`) and the pages (`pages`) beside the traces, and its import (`mem.importFrom('./backup.json')` or `mem.importFromString(text, 'json')`) brings them back by the same rules. The Markdown and Obsidian exports carry traces, the chunks of pages among them, and no page row and no registry row: use the `sqlite` or `json` format to move a store whose subjects have pages.
229
229
230
230
The facade has no backup schedule; a host that wants one calls `export()` from a timer:
0 commit comments