Skip to content

feat(memory)!: keep a souled agent's memory and wiki pages per user - #767

Merged
jddunn merged 66 commits into
masterfrom
feat/memory-per-user-wiki
Nov 12, 2026
Merged

jddunn merged 66 commits into
masterfrom
feat/memory-per-user-wiki

Conversation

@jddunn

@jddunn jddunn commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

A souled agent kept one memory for everyone who talked to it: each turn was filed under the agent's id and recalled for whoever spoke next, compiled wiki pages mixed users, and read_memory_page read any page for anyone. This change files, recalls, compiles and reads that memory per subject: the session's user, or the session itself when it names none.

  • A conversation scope with one versioned key per agent and subject (conversationScopeKey, parseConversationScopeKey), matched by equality only. An id that holds a lone surrogate gets no key.
  • A registry of scopes (memory_scopes), written with each scope's first trace, holding each scope's compile watermark; Memory.listScopes().
  • Per-user wiki pages as rows of the store (memory_pages, UserWikiStore) on SQLite and Postgres. Pages under memory/ are the operator's: hand-written, shared, never written by a compile.
  • souledAgent() files each turn under its subject's key, the user's message and the reply alike, and recalls that subject's memory and the operator's pages, and nobody else's.
  • One compile per subject, into that subject's own pages, each with its own watermark. A subject whose compile the spend budget refuses is skipped and the others compile.
  • read_memory_page answers the asker's own pages and the operator's, lists them with { "list": true }, and refuses a call that names a scope or a user.
  • New souledAgent() options: sharedMemory, compile, memoryPolicy, screen. The two hooks fail closed.
  • The paths that could cross subjects are closed: memory_search reads no conversation trace, consolidation leaves the conversation scope out, and a recall of the scope with no key is refused.
  • A SQLite export carries the scope registry and the pages, and an import brings them back.
  • Traces and compiled pages an earlier version stored are left where they are and are no longer read by any user's turn.

Docs: docs/SOUL_FILES.md, docs/getting-started/HIGH_LEVEL_API.md, docs/memory/MEMORY_STORAGE.md, docs/getting-started/EXAMPLES.md, docs/GMI.md, README.md.

Linked issues

Part of #759

Spec, plan and design

None public

Pictures

No visible change

Type of change

  • Bug fix
  • Feature
  • Performance
  • Documentation
  • Refactor
  • Tests
  • Build or CI

How this was verified

CI only, on this pull request's runs. Final head 9a0b0bb0: CI (Test & Lint with the Postgres service, Browser tests, Batch-1 gated tests, Release dry run). The new suites: souledAgent.scoped-memory.gmi.e2e.test.ts (the default runtime and runtime: 'gmi'), Memory.conversation-scope.e2e.test.ts (SQLite and the job's Postgres service), readMemoryPage.asker.e2e.test.ts, conversationScopeKey.test.ts. The breaking change gate stays red until the label it asks for is added.

Each change was pushed test first; the failing run of each tests-only commit, then the passing run of its change:

  • The scope key: tests e5703de0, failing (conversationScopeKey.test.ts could not import the module); change e18641f4, passing.
  • The registry and the column reads: tests 765f3fb1, failing (15 tests of Memory.conversation-scope.e2e.test.ts, on SQLite and on Postgres: no memory_scopes table, a trace with no key stored, both scopes listed); change e5bd377b, passing.
  • Page rows: tests 0a94a8b7, failing (14 "per-user pages" tests of the same suite, on both stores: no UserWikiStore); change ab899471, passing.
  • Operator pages and earlier compiled pages: tests 352158ee, failing (24 tests in 9 files: no operator page in the plain prompt, no memory.legacy_pages line, index.md not refreshed at attach, a soft-deleted chunk left, no chunk under the operator key); change e199a8b5, passing.
  • The page tool: tests cb9054ea, failing (9 tests of readMemoryPage.asker.e2e.test.ts and 2 of ReadMemoryPageTool.test.ts: the asker's own page not found, no refusal line, a scope argument not refused, no listing); change 0b237117, passing.
  • The asker read from the turn's subject first: tests e3d7277c, failing (a session named guest read as nobody); change c403af5d, passing.
  • No key for an id that holds a lone surrogate: tests b4830620, failing (5 tests in 3 files: two ids stored as one key); change cf7e2dad, passing.
  • Filing and recall per subject, sharedMemory: tests 8b5395dc, failing (41 tests in 2 files, on both runtimes: another subject's fact recalled, traces under the agent's plain scope, a one-shot call filed, the shared-memory refusals missing, no .gitignore); change 9e6e8578, passing.
  • One compile a subject: tests 182cc391, failing (36 tests in 6 files, the facade suite on SQLite and on Postgres among them: one compile for the whole store, a page file under memory/, no watermark a scope); change 2e2cc10f, passing.
  • compile, memoryPolicy, screen: tests 5521f831, failing (27 tests of souledAgent.scoped-memory.gmi.e2e.test.ts, on both runtimes: the options were not read); change 53281259, passing in this run, whose only failures are the next item's tests, pushed with it.
  • The paths that cross subjects, and the export: tests 4154e7b7, failing (13 tests of the facade suite's "scopes kept apart on every path" block, 9 on SQLite and 4 on Postgres: memory_search returned a conversation trace, a recall of the scope with no key resolved, the registry row was deleted while a page remained, a message deduped into a page chunk, two page writes at once left two chunk sets, consolidation merged the scope's traces, the import brought no page, an import left the file's chunks, a replace kept the receiving brain's rows); change 8c9e099b, passing.
  • The whole path, end to end: tests d59f0f12, which pin what the changes above already do (the page tool through a model call on both runtimes, the listing, the operator's page shared, a user's page in no prompt and no file, a seat session, cognitive memory on, the agent's export, a later re-file of the other scopes); passing.
  • Docs and fixtures: a9ec9a4b says in docs/SOUL_FILES.md that a compile writes no file under memory/ and refreshes no catalog, and gives three test fixtures a neutral user id; passing.
  • Review round one (Codex, CodeRabbit, Qodo on a9ec9a4): tests de19f6c2, failing (22 tests in 3 files: compile keys sent to another provider, a policy kept across a session close, page writes at once, imports, the compile watermark); change a1973660, passing.
  • Review round two (CodeRabbit on 052a42a): tests a1efb0c1, failing (12 tests in 3 files: overlapping turns, the latest answer, a provider-only compile, a forced re-index, two facades, an import during a compile, a NUL id); change 3bc4fc82, passing in this run, whose only failures are the next item's tests.
  • Review round three: tests 1261ef9c, failing (5 tests: the cognitive-memory refusal on an inline and an optional soul, a duplicate behind 51 page chunks); change dc32d751, passing.
  • Review round four (CodeRabbit on 9543330): tests 1dce1862, failing (10 tests in 2 files: a late answer to an earlier ask, an off answer during the compile's screen, a forced re-index over a summary change, a page write across processes, a registry row under a concurrent write, deletes during a compile); change 485ae591 with 42b137da and 9a0b0bb0, passing.

Not covered: souledAgent() opens SQLite alone, so its suite has no Postgres leg; the registry, the page rows and the per-scope compile run on Postgres in the facade suite. The export and import of the two new tables is tested on SQLite.

Migration notes

  • souledAgent() files each turn under its subject, in a new conversation scope: the session's userId, else the session. Recall across users and across sessions ends. On one person's own machine pass one stable userId, or set sharedMemory: { as, reason }.
  • A one-shot generate() or stream() names no user: nothing is filed for it and it recalls the operator's pages alone, unless sharedMemory is set. One memory.one_shot_unfiled log line an agent says so. Use agent.session(id, { userId }) for turns that should be remembered.
  • The compile writes each subject's pages as rows of the new memory_pages table, never as files under memory/. memory/index.md lists the operator's pages only. close() compiles the subjects its turns wrote to; a trace stored another way waits for agent.memory.compileWiki().
  • A compile the spend budget refuses no longer fails the call: that subject is skipped with one memory.compile_skipped log line and the others compile.
  • Pages an earlier version compiled (front matter with sources) stay on disk, and leave the index, the prompt, recall and every user's reads; a call with no user still reads them, and one log line counts them. Traces stored under the agent's plain scope id stay in the store and are read by no turn; one memory.legacy_traces log line counts them. Nothing existing is moved, rewritten or deleted. To remove them: await agent.memory.deleteScope('persona', agentId), and, when encodePlainScopeId('persona', agentId) differs (an id that holds /, % or :), deleteScope with that encoded id too; then delete those page files.
  • The prompt's memory index is rendered from the operator's pages and the text migrated from MEMORY.md; a line written by hand into memory/index.md outside that block no longer reaches the prompt.
  • Operator pages are indexed again under a new key at the first start; their earlier chunks stay under the old scope and are read by nothing. Re-indexing an edited page deletes its old chunks for good; the wiki no longer calls Memory.forget().
  • read_memory_page takes { id } or { list: true }. It answers not-found for another subject's page and for an earlier compiled page asked by a user, and an invalid-arguments result for a call that carries scope, scopeId, userId, turnUserId or subject.
  • Memory.compileWiki() compiles per scope and takes { scopes }; Memory.attachWiki() takes { storeFor, compiler, beforeScopeCompile?, compileSkipReasonOf? }; WikiCompiler.compile() takes the scope's store (WikiCompilerOptions.store is optional); attachMemoryWiki() returns storeFor beside store, and throws for an empty agentId.
  • recall() matches scopeId on the scope_id column, so a row a release older than the column writes to the same brain after this process opened it is recalled by its scope id only after the next open. recentTraces() takes scopeId. remember() under the conversation scope needs a key conversationScopeKey() built. recall() and recentTraces() with scope: 'conversation' and no scopeId throw.
  • memory_search returns no trace of the conversation scope and answers a search that names it with an error. Memory.consolidate() and memory_reflect leave that scope's traces out.
  • Memory.deleteScope('conversation', key) deletes the scope's traces and its registry row, and keeps the row while a page of the scope remains; delete a subject's pages with UserWikiStore.deleteAll() first.
  • A sqlite export holds memory_scopes and memory_pages, and a JSON export holds them as scopes and pages. An import of either keeps a page and a registry row the brain already holds; a replace import empties both tables first. The Markdown and Obsidian exports carry no page row.
  • memoryPolicy, screen and sharedMemory are refused with a TypeError on an agent whose cognitive memory is on (runtime: 'gmi' with cognition memory): that memory lives in a store none of them reaches.
  • A compile of a subject, Memory.deleteScope('conversation', key) and Memory.deletePageRows(key) run one after the other in a process: a delete made during a compile waits for it.
  • recall(query) and recentTraces(sinceMs) with no scope and no scope id read the whole brain, every subject's conversation traces among them: the host's own read of its store.
  • Types: MemoryScope gains 'conversation' (a Record<MemoryScope, number> gains a key); ReadMemoryPagePort is readPage(id, asker) and listPages(asker); MemoryIndexPort gains deleteTraces; WikiAttachableMemory gains deleteTraces, the page-row members (reindexPageRow among them) and pageExistsOutside, and its attachWiki takes the new shape.
  • New tables, created at open: memory_scopes, memory_pages. memory/.store/.gitignore is written when the store folder is made.

Checklist

  • Tests cover the changed behavior.
  • Docs are updated.
  • The title follows Conventional Commits, with ! before the colon for a change that breaks users (feat!: or feat(api)!:).
  • No secrets or private data are included.
  • Every automated review thread is settled (how).
  • I have read this change and can explain every line.

Summary by CodeRabbit

  • New Features

    • Conversation history and compiled pages are stored separately by user or session, alongside operator-authored wiki pages.
    • Agents can apply memory policies and screening before storing or compiling memory, and optionally share memory in configured single-person setups.
    • Page reading and listing reflect the current subject’s access. Memory exports and imports include scoped pages and related records.
    • Added support for conversation-scoped memory and a public memory policy type. Operator-authored pages appear in the wiki catalog; conversation-compiled pages remain separate.
  • Bug Fixes

    • When compilation exceeds its budget, the affected subject is skipped and its traces remain available for a later attempt.
  • Documentation

    • Updated guides explain memory scopes, one-shot calls, compilation, page access, and policy behavior.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

Souled-agent memory now uses conversation scopes for traces and compiled pages. Operator-authored wiki pages remain shared files, while page access, compilation, indexing, and storage follow subject scope. The change also adds memory policy and screening hooks, SQLite support, tests, and documentation.

Changes: Subject-scoped conversation memory

Layer / File(s) Summary
Conversation scope identity and persistence
src/cognition/memory/retrieval/store/*, src/cognition/memory/io/SqliteImporter.ts, src/cognition/memory/core/types.ts, docs/memory/MEMORY_STORAGE.md
Adds conversation scope keys, scope registry rows, and memory_pages rows. SQLite import and export include the new tables, and the memory scope type adds conversation.
Scoped traces, pages, and compilation
src/cognition/memory/io/facade/*, src/cognition/memory/io/tools/MemorySearchTool.ts, src/cognition/memory/pipeline/consolidation/ConsolidationLoop.ts
Adds scope-aware trace operations, page-row APIs, and per-scope compilation with scoped watermarks. Search and consolidation exclude conversation traces.
Operator and subject wiki pages
src/cognition/substrate/memory/wiki/*, src/cognition/substrate/personas/SoulLoader.ts
Separates operator-authored wiki files from subject page rows. Page origin controls catalog inclusion. The soul loader renders its operator-page index from readable pages and migrated text.
Souled-agent memory and page access
src/api/souledAgent.ts, src/cognition/memory/io/tools/ReadMemoryPageTool.ts, src/core/logging/events.ts, src/api/__tests__/*, src/cognition/memory/io/*/__tests__/*, docs/*, README.md
Routes filing and recall by session subject or configured shared user. Adds policy and screening hooks. The page tool derives access from asker context. Tests, exports, and documentation cover the revised behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Possibly related issues

  • framerslab/agentos#759 — Covers per-user memory, session fallback, per-scope compilation, and asker checks addressed in part by this change.

Possibly related PRs

Merge Risk: High · previous review 95433

This change keeps each user's memory apart, but some privacy controls can still be bypassed. An older policy answer can re-enable compilation after a newer "off" answer. Compilation can proceed after an account turns memory off during screening. Unscoped reads can return other subjects' traces. Concurrent page and registry updates can lose or restore stale data. Resolve these before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(memory)!: keep a souled agent's memory and wiki pages per user" matches the main change in the changeset. The raw summary shows a conversation scope keyed by user or session, per-user …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has Summary, Linked issues, Spec/plan/design, Pictures, Type of change, How this was verified, Migration notes, and Checklist sections. The Summary …
Full details: Title check

Explanation

The title "feat(memory)!: keep a souled agent's memory and wiki pages per user" matches the main change in the changeset. The raw summary shows a conversation scope keyed by user or session, per-user wiki pages, per-subject compilation, and per-subject page reads. The title follows Conventional Commits and marks the breaking change with !. It is specific and does not list files.

Full details: Description check

Explanation

The description follows the repository template. It has Summary, Linked issues, Spec/plan/design, Pictures, Type of change, How this was verified, Migration notes, and Checklist sections. The Summary explains the change and its reasons: memory filing, recall, compile, and reads are now scoped per subject. Linked issues states 'Part of #759', which fits a multi-PR plan. Spec is 'None public', and Pictures is 'No visible change'. Verification lists CI runs and the test suites added, with failing and passing commits for each step. Migration notes are detailed and cover breaking changes for users. The checklist is complete. The template's 'Migration notes' section is required only for breaking changes, and this PR is one, so the content is appropriate. Minor gaps: the Summary's file-level detail is light, and the Spec section does not link a public design. These gaps do not affect the overall completeness of the description.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Add the conversation-scope registry and per-subject wiki-page tables, and register eligible existing conversation scopes during Brain initialization.

  • src/cognition/memory/retrieval/store/Brain.ts L560-606 (+4 small edits)

Data structures

Define the versioned conversation-scope key and the memory and wiki-page data types that depend on it.

  • src/cognition/memory/core/types.ts L27-31
  • src/cognition/memory/io/facade/types.ts L351-381 (+3 small edits)
  • src/cognition/memory/retrieval/store/conversationScopeKey.ts L1-72
  • src/cognition/substrate/memory/wiki/types.ts L47-58

API

Expose the conversation-scope utilities, registry operations, page stores, and new memory facade methods and row types to callers.

  • src/cognition/memory/index.ts L132-138, L316
  • src/cognition/memory/io/facade/index.ts L12-17
  • src/cognition/substrate/memory/wiki/index.ts L13
  • src/index.ts L163, L186-188

Implement the facade's conversation-scope validation, registration, filtered reads, page-row persistence, and deletion behavior.

  • src/cognition/memory/io/facade/Memory.ts L126-201, L1070-1268, L2140-2242 (+15 small edits)

Implementation

Implement registration of conversation scopes from their keys and a wiki-page store whose reads, writes, and chunk operations stay within one subject.

  • src/cognition/memory/retrieval/store/conversationScopes.ts L1-59
  • src/cognition/substrate/memory/wiki/UserWikiStore.ts L1-162

Documentation

Document the scope-key format, registry and page-row tables, page operations, deletion behavior, and initialization changes.

  • docs/memory/MEMORY_STORAGE.md L125-194 (+3 small edits)

Tests

Verify key encoding and parsing, scope registration and equality-based reads, and per-subject wiki-page persistence across SQLite and Postgres.

  • src/cognition/memory/io/facade/__tests__/Memory.conversation-scope.e2e.test.ts L1-480
  • src/cognition/memory/retrieval/store/__tests__/conversationScopeKey.test.ts L1-109

Cover operator-page indexing, cleanup, legacy-page exclusion, and the resulting catalogs and prompts for souled agents.

  • src/api/__tests__/souledAgent.e2e.test.ts L143-152, L165-181, L226-232 (+3 small edits)
  • src/api/__tests__/souledAgent.memory.e2e.test.ts L78-87, L106 (removed lines)
  • src/api/__tests__/souledAgent.scoped-memory.gmi.e2e.test.ts L1-245

Check wiki attachment and page-store behavior, including indexing failures, deletion, page-origin handling, and prompt loading.

  • src/cognition/memory/io/__tests__/attachMemoryWiki.test.ts L8, L32, L92-146
  • src/cognition/memory/io/__tests__/wikiPageId.integration.test.ts L245-255 (+4 small edits)
  • src/cognition/substrate/memory/wiki/__tests__/WikiMemoryStore.concurrent.test.ts L33
  • src/cognition/substrate/memory/wiki/__tests__/WikiMemoryStore.fs.test.ts L13, L105-106, L119
  • src/cognition/substrate/memory/wiki/__tests__/WikiMemoryStore.index.test.ts L24-27, L75-104 (+4 small edits)
  • src/cognition/substrate/memory/wiki/__tests__/WikiPageCodec.test.ts L4-10, L104-156
  • src/cognition/substrate/personas/__tests__/SoulLoader.wiki.test.ts L5, L25-53

Other changes

Files not grouped.

  • src/cognition/memory/AgentMemory.ts L1020
  • src/cognition/memory/CognitiveMemoryManager.ts L1489

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

jddunn added 14 commits November 9, 2026 20:37
…ier version compiled left out of every prompt

Signed-off-by: jddunn <[email protected]>
…rlier compiled pages out of the index, the prompt and recall

Signed-off-by: jddunn <[email protected]>
…en read_memory_page finds its asker

A session whose id or user id is one of the anonymous words was read as no user: it was served and listed the pages an earlier version compiled into the folder, and could not read its own pages. The subject in the tool context is the key the turn's memory is filed under, so it now decides the asker first.

Signed-off-by: jddunn <[email protected]>
@jddunn

jddunn commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Review fix: read_memory_page now takes the subject the runtime put in userContext.memorySubject as the asker before it looks at userContext.userId.

Failing input: a session whose id is one of the anonymous words (guest), or a session opened with userId: 'anonymous' whose context carries memorySubject: { kind: 'session', id: ... }. The tool read the asker as no user: it served and listed the pages an earlier version compiled into the folder, and could not read the session's own pages, while the session's memory is filed under the session key.

…ation key

A store writes text as UTF-8, where a lone surrogate becomes U+FFFD, so a key built from 'm\uD800' is stored and matched as the key of 'm\uFFFD': the two subjects would read one another's pages and recall.

Signed-off-by: jddunn <[email protected]>
…rrogate

The store writes text as UTF-8, where a lone surrogate becomes U+FFFD, so the key of 'm\uD800' was stored and matched as the key of 'm\uFFFD': each subject read the other's pages and recall. conversationScopeKey now refuses such an agent or subject id with a TypeError, and parseConversationScopeKey reads a string that holds one as no key, so remember() and UserWikiStore refuse it too.

Signed-off-by: jddunn <[email protected]>
@jddunn

jddunn commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Review fix: A conversation key is refused for an agent id or a user or session id that holds a lone surrogate.

Failing input: User 'm\uD800' and user 'm\uFFFD' with agent aria-1. conversationScopeKey gave two different JS strings, but better-sqlite3 and pg both bind text as UTF-8, where a lone surrogate is written as U+FFFD, so both keys were stored and matched as one. User 'm\uD800' read the page 'm\uFFFD' wrote (Mallory keeps a ledger.) through read_memory_page, through UserWikiStore, and in recall, on SQLite and on Postgres.

Expected: No key for such an id. conversationScopeKey now throws a TypeError for an agent or subject id that is not well-formed UTF-16, and parseConversationScopeKey reads a string holding a lone surrogate as no key, so remember() and UserWikiStore refuse it as well.

Two compiles of one scope at once (two compileWiki() calls, or close() beside
an explicit compile) both read the watermark before the first entered the
scope's queue. The second then compiled from the old watermark and sent the
same traces to the model again. The watermark is now read once the compile's
turn comes, so a compile that waited starts where the earlier one left it; a
scope deleted meanwhile is skipped.

Signed-off-by: jddunn <[email protected]>
…d changes

.meta/index.json recorded only the key version, so a folder indexed for one
agent id and opened under another (agentId or name edited, or a second agent on
the same folder) skipped every unchanged page: no chunk was filed under the new
operator key and no turn recalled the operator's pages. The index now records
the operator key it filed under. An index of another key is not used: every
operator page is indexed again under the current key and the chunks filed under
the other key are deleted.

Signed-off-by: jddunn <[email protected]>
…pens, and close the store on a failed open

An agent id conversationScopeKey refuses (a NUL or a lone surrogate) threw only
after memory/.store/memory.sqlite was opened, and the handle was never closed.
The key is now built before the store folder is made. Any later step of the open
that throws (reading the store, attaching the wiki, agent() refusing its
options) closes the store before the error reaches the caller.

Signed-off-by: jddunn <[email protected]>
memory.legacy_traces counts the traces under the agent's plain id and under its
encoded form, which differs when the id holds '/', '%' or ':'. The documented
removal deleted the plain form alone, so the line kept counting traces a
learning layer had re-filed. The docs now delete both, and encodePlainScopeId is
exported so a host can name the encoded form.

Signed-off-by: jddunn <[email protected]>
A seat's session id is prefixed seat:, and the memory tools are never among a
seat's tools: a read_memory_page call from a seat is skipped as not available.
The test opens a seat with the id of a user who holds a page and checks the
call is skipped and no page text reaches the model.

Signed-off-by: jddunn <[email protected]>
@jddunn jddunn added the breaking-approved A maintainer approved the breaking change in this pull request label Nov 12, 2026
@jddunn

jddunn commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

Follow-ups from QA and a cold review of 9a0b0bb0, each with a failing test first.

Tests-only commit dccd05fe and its red run, every new test failing for its stated reason: https://github.com/framerslab/agentos/actions/runs/43128152647. Green on head 19307fd3: https://github.com/framerslab/agentos/actions/runs/43129916434 (Test & Lint: 1195 files, 17686 tests passed, the Postgres leg included).

Finding Fix
A JSON export and import dropped the scope registry and every page row, leaving page chunks no row lists, still recalled 014cd9db: the JSON export carries scopes and pages, and the JSON import restores them by the SQLite import's rules, now shared in importPages.ts. Tests on SQLite and Postgres: round trip, a page the brain holds is kept, a message is never merged into a page chunk. Docs: MEMORY_OPERATIONS.md, MEMORY_STORAGE.md
The documented removal of earlier traces missed the encoded form of an agent id holding /, % or :, which memory.legacy_traces counts e061ddba: the docs delete both forms, and encodePlainScopeId is exported. SOUL_FILES.md and the migration note above
Operator page recall stopped silently when the folder's agent id changed, or a second agent opened the folder 975008a0: .meta/index.json records the operator key; an index of another key is not used, every operator page is indexed again under the current key and the old key's chunks are deleted
A souled agent whose id builds no key (NUL, lone surrogate) left its store open, as did any later failure of the open 4f374fd0 and 19307fd3: the key is built before the store folder is made; any later throw of the open closes the store
Two compiles of one scope at once sent its traces to the model twice 2bc3eace: the watermark is read in the scope's own turn of the queue
Brain.importFromSqlite copied pages and registry rows of another brain than the file's brain_meta names 7812d3ac: the single-brain check reads both tables too and throws before any copy

Not changed, with reasons: a seat opened with sessionSeat(a, { sessionId: 'bob' }) cannot read bob's pages. Its session id is seat:bob, and the memory tools are never among a seat's tools: the red run above shows the seat's read_memory_page call answered Skipped: not available in this seat. 9582039a keeps a test that pins this.

The test fixture that used a person's name now uses a neutral id.

@jddunn

jddunn commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19307fd308

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…r process rewrote

deletePageRows deletes the chunks it read, then the row by its id alone. When
another process rewrites the page in between, the row goes and the new chunks
stay with no row that lists them.

Signed-off-by: jddunn <[email protected]>
…leted

deletePageRows deleted the chunks it read and then the row by id alone, so a
rewrite by another process in between left the new chunks live with no row.
The row is now deleted only while it holds the text and the chunk list read
with it; when it changed, it is read again and its chunks go first, up to the
page write's attempt limit.

Signed-off-by: jddunn <[email protected]>
@jddunn

jddunn commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 576e01ff73

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cognition/memory/io/JsonExporter.ts Resolved
…n a page is rewritten meanwhile

The export reads the traces, then the pages, as separate statements; a page
rewritten in between comes out listing chunks the file does not hold.

Signed-off-by: jddunn <[email protected]>
The JSON export read each table in a statement of its own, so a compile or a
page rewrite that committed between the trace read and the page read put a page
row in the file whose chunks the file did not hold. The export now reads every
table through Brain.readConsistently, the view the SQLite export already reads
from: a REPEATABLE READ transaction on Postgres and a read transaction on a
second connection for a SQLite file in WAL mode.

Signed-off-by: jddunn <[email protected]>
…nt view

The tests that re-file a brain while its JSON export reads hooked brain.all,
which the export no longer reads through. The hooks now wrap the reads of
Brain.readConsistently too, so the re-file still lands mid-export.

Signed-off-by: jddunn <[email protected]>
@jddunn

jddunn commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 48267af590

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jddunn
jddunn merged commit 75f0f7a into master Nov 12, 2026
15 checks passed
@jddunn
jddunn deleted the feat/memory-per-user-wiki branch November 12, 2026 03:29
jddunn added a commit to framerslab/agentos-extensions that referenced this pull request Nov 15, 2026
## What changed

Move the workspace's `@framers/agentos` override from `^0.16.0` to
`^0.19.0`, update 31 caret dev dependencies and the browser meeting
capacity measurement dependency, update the meeting scheduler test
image's exact 0.15.19 pin to 0.19.0, and commit the lockfile produced by
the existing Lockfile workflow. The committed workspace previously
resolved 0.16.0 and now resolves 0.19.0. Open peer ranges and
`workspace:^` references keep their existing form; the override resolves
the latter. No package version changes.

## Issue

No issue

## Spec, plan and design

None: dependency update

## Pictures

None: no screen changes

## Docs

No guide changes needed. Reviewed the release notes for
[0.17.0](https://github.com/framerslab/agentos/releases/tag/v0.17.0),
[0.17.1](https://github.com/framerslab/agentos/releases/tag/v0.17.1),
[0.18.0](https://github.com/framerslab/agentos/releases/tag/v0.18.0),
and
[0.19.0](https://github.com/framerslab/agentos/releases/tag/v0.19.0),
including the [per-user memory
migration](framerslab/agentos#767) and
[retrieved-text request
shape](framerslab/agentos#834).

## Type of change

- [x] Build or CI: dependency update

## Tests

Validation runs exclusively in CI. [Lockfile resolution
passed](https://github.com/framerslab/agentos-extensions/actions/runs/43735897379)
using the repository's pnpm 10.34.7. Its artifact was copied unchanged;
the diff contains only AgentOS resolution and peer-reference changes. No
dependencies or validation commands ran locally. No filler tests were
added for this manifest and lockfile change.

All workflow checks passed on
`09d56e10be677e323e7d029efb121413417afb79`:

- [CI: build, extension suites and pack
guards](https://github.com/framerslab/agentos-extensions/actions/runs/43736432139).
The resolver and installed Gmail export check both report AgentOS
0.19.0.
- [Meeting bot image and
lifecycle](https://github.com/framerslab/agentos-extensions/actions/runs/43736432079),
including the scheduler image on 0.19.0.
- [Document parser on Node
24](https://github.com/framerslab/agentos-extensions/actions/runs/43736432131)
and [document parser image
lifecycle](https://github.com/framerslab/agentos-extensions/actions/runs/43736432152).
- [Published source
foundation](https://github.com/framerslab/agentos-extensions/actions/runs/43736432372)
and [published Gmail source on Node 22 and
24](https://github.com/framerslab/agentos-extensions/actions/runs/43736432203).
- [Dependency bump dry
run](https://github.com/framerslab/agentos-extensions/actions/runs/43736432082),
[Links](https://github.com/framerslab/agentos-extensions/actions/runs/43736432107),
and [pull request
title](https://github.com/framerslab/agentos-extensions/actions/runs/43736445549).

Image publish jobs and the scheduled dependency-bump write job are
skipped on pull requests. Superseded runs were cancelled automatically.

## How this was verified

Read every AgentOS manifest, import/use site, workflow and the release
notes above. The existing build, extension suites, installed consumer
contracts, document parser tests, container lifecycle checks and
dependency bump dry run provide the runtime checks.

## Migration notes

- 0.17.0 changes recalled text placement and memory-hook timing. No
extension installs those hooks or depends on the old placement.
- 0.17.1 introduces per-user souled memory and database-backed wiki
pages. Neither memory extension opens a souled store; both keep their
own in-process records. No memory migration is needed here.
- 0.18.0 requires retention for a shared souled store and adds per-user
deletion, export and correction. There is no shared souled-store host
here to configure.
- 0.19.0 removes the implicit date tool and concise prompt profile and
makes `AgentOS.create` preserve the factory's persistence setting.
Production extensions do not construct a full runtime. The five auth
examples use `new AgentOS().initialize` for auth demonstrations, with no
model turn, implicit date-tool call or prompt-profile expectation; no
demonstrated auth behavior needs changing.
- 0.19.0 places retrieved text in an application note before the user's
words. No request-capture parser or assertion here depends on the former
`Context:` / `User Query:` wrapper.

## Checklist

- [x] Existing suites cover the dependency update; no application
behavior changed.
- [x] Documentation impact reviewed.
- [x] Package versions and release settings are unchanged.
- [x] The title follows Conventional Commits.
- [x] No secrets or private data are included.
- [x] The diff has been read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-approved A maintainer approved the breaking change in this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant