[PR #1434] [MERGED] fix(long-term-memory): recall shared-history memories in a new branch (1.4.44) #1460

Closed
opened 2026-10-21 05:11:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1434
Author: @Promansis
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @Promansis

Base: staging ← Head: fix(long-term-memory)/1433-branch-recall


📝 Commits (2)

  • 777ee1f fix(long-term-memory): recall shared-history memories in a new branch (#1433)
  • 61dbb84 chore(long-term-memory): release 1.4.44 (#1433)

📊 Changes

17 files changed (+398 additions, -90 deletions)

View changed files

📝 .github/workflows/ltm-browser.yml (+1 -1)
➕ artifacts/long-term-memory-1.4.44.zip (+0 -0)
📝 catalog/catalog.json (+6 -6)
📝 catalog/notes.json (+6 -6)
📝 catalog/v2/catalog.json (+6 -6)
📝 catalog/v2/notes.json (+6 -6)
📝 catalog/v3/catalog.json (+6 -6)
📝 catalog/v3/notes.json (+6 -6)
📝 packages/long-term-memory/CHANGELOG.md (+4 -0)
📝 packages/long-term-memory/manifest.json (+3 -3)
📝 packages/long-term-memory/server.mjs (+43 -43)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/chat-scope.ts (+41 -1)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/generation-injection.ts (+34 -1)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/interop.ts (+1 -1)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.ts (+7 -3)
📝 scripts/build-feature-packages.mjs (+1 -1)
➕ tests/long-term-memory-branch-recall.regression.ts (+227 -0)

📄 Description

Linked issue

Closes #1433

Why this change

Engine treats a branch as a copy of a chat that shares history up to the branch point. When it creates a branch, it copies every rolling summary entry whose messages all come before that point, and keeps the entry ids. Long-Term Memory saves a memory to the one chat record (branch) it came from, and recall matched only that record. So a new branch recalled none of the memories built from its shared history, even though Engine had copied the summaries those memories came from.

What changed

 prepareGenerationLongTermMemory            (each turn)
   scope = resolveChatLtmScope(chat)
+  inheritedNoteIds = branchInheritedNoteIds(chat)
+    no groupId                                         -> undefined (unbranched chats do no extra work)
+    ids = summaries(chat) minus day/week and game-session ids
+    no ids, or no other branch with this groupId       -> undefined
+    notes = storage.listNotes({ skipInvalid: true })   (cached vault snapshot)
+    inheritedBranchLtmNoteIds(...)                    -> memories where
+      saved to another branch of this conversation
+      and at least one extracted_from link
+      and every extracted_from link is a chat_summary source from this conversation
+          whose entryId is one of this chat's ids     (a missing source fails)
   retrieveLongTermMemory({ ..., inheritedNoteIds })

 retrieveLongTermMemory chunk filter
   status / resolved / mode / noteTypes             unchanged
   exclusiveCharacterIds (targeted reply)           unchanged, ignores the inherited set
-  matchesLtmScope(chunk, scope)
+  matchesLtmScope(chunk, scope) || inheritedNoteIds?.has(chunk.noteId)
  • chat-scope.ts: the pure inheritedBranchLtmNoteIds helper.
  • retrieval.ts: an optional inheritedNoteIds input. Only generation-injection.ts passes it. Extraction update targets, candidate reconciliation, the search route and all other callers behave exactly as before. That is why an inherited memory is read-only in the branch: extraction never picks it as an update target.
  • interop.ts: summaries is exported, so recall reads summary ids the same way Sources does.
  • One choice beyond the issue's Minimal fix: Conversation day and week summaries (day:<date>, week:<date>) and game session summaries (game-session-N) never count as shared.
    • Those ids are dates or sequence numbers. After the split, both branches can write a different summary under the same id, which would break the "after the branch point" rule.
    • Engine drops day and week summaries when it creates a branch.
    • Game sessions keep today's behaviour: a memory made from a game session is not recalled in another branch.
  • long-term-memory 1.4.44: CHANGELOG entry, version, manifest, rebuilt server.mjs, artifact and catalog entries.
  • .github/workflows/ltm-browser.yml: branch-recall is added to the Long-Term Memory regression loop.

Package and security impact

  • Affected package IDs: long-term-memory
  • Engine compatibility impact: none. Engine versions that don't copy summaries into branches, and branches made before they did, share no summary ids, so they recall exactly what they do today.
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact:
    • Storage: none. Notes, scopes, recall.json, backups and the schema are unchanged, and there is no migration. The regression checks that note files and recall.json are byte-identical after recall.
    • Downgrade and rollback: safe. Rolling back only stops the extra recall.
    • Cost: each turn in a branched chat that has rolling summaries lists the host's chats and reads the vault's notes from the cached snapshot. Chats without branches skip both.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

These checks were run by the coding agent, not by a person. Engine checkout 2039583ca, Node v24.15.0.

  • New regression tests/long-term-memory-branch-recall.regression.ts. It runs the issue's table through prepareGenerationLongTermMemory:
    • Fixtures: A and its branch B in group G share E1; A has E2 and B has E3; C is another conversation that reuses E1's id.
    • Expected recall: A gets m1, m2, m3, m5 and m8; B gets m1, m4, m5 and m6; C gets m7.
    • m8 is A's game-session-1. B has its own game-session-1, and B must not recall m8.
    • It also checks that a missing source fails, and so does another conversation's source that reuses E1's id.
    • Note files and recall.json stay byte-identical after recall.
    • A chat without a group, or a group chat with no summaries, never calls listChats.
  • Before: the same test against the unfixed source exits 1 at "branch B recalls A's memories built only from the shared E1", because world_m1 is missing.
    After: exits 0.
  • Mutations: removing the day/week/game-session filter exits 1 (B recalls world_m8). Removing the check on the source's conversation exits 1 (world_cross is inherited).
  • On the source commit, these all passed: test-ltm.sh runtime, index-keys, routes, routes-scope-identity, and reconciliation-recall. So did typecheck-packages long-term-memory and a package build.
  • On the release HEAD these all passed:
    • test-fast.sh (npm run check, git diff --check);
    • test-catalog-lanes, validate-package-locales, validate-catalog and catalog-release-notes;
    • branch-recall;
    • test-ltm.sh installation (installs, restarts, backs up, uninstalls and reinstalls the rebuilt 1.4.44 artifact).
  • Not done: a live check in Engine of branching a chat after an imported summary and recalling the memory in the branch.
  • Known limits, not changed here:
    • If listing chats or notes fails, the branch gets no recall for that turn, like any other retrieval failure.
    • The /api/long-term-memory/search route doesn't include inherited memories.
    • The recall explanation in Debug doesn't mark them.
    • Identity is the summary entry id only. If the summary is edited in place after the split, memories made from the edited text still reach the branch.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

UI evidence (if applicable)

None. Nothing changes on screen. The availability editor and the Vault filter still show stored assignments exactly as before.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Long-Term Memory can now recall eligible memories across branches of the same conversation when their source summaries are shared before the branch point. Memories from later summaries or other sources remain branch-specific, and memories do not carry across conversations.
  • Bug Fixes
    • Improved branch-recall validation to exclude memories with missing or unrelated source summaries.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/1434 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(long-term-memory)/1433-branch-recall` --- ### 📝 Commits (2) - [`777ee1f`](https://github.com/Pasta-Devs/Marinara-Agents/commit/777ee1f39dba003056bee7e45243c571cddffcea) fix(long-term-memory): recall shared-history memories in a new branch (#1433) - [`61dbb84`](https://github.com/Pasta-Devs/Marinara-Agents/commit/61dbb840bfd7087bcd0eb77168a36828ea964db2) chore(long-term-memory): release 1.4.44 (#1433) ### 📊 Changes **17 files changed** (+398 additions, -90 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ltm-browser.yml` (+1 -1) ➕ `artifacts/long-term-memory-1.4.44.zip` (+0 -0) 📝 `catalog/catalog.json` (+6 -6) 📝 `catalog/notes.json` (+6 -6) 📝 `catalog/v2/catalog.json` (+6 -6) 📝 `catalog/v2/notes.json` (+6 -6) 📝 `catalog/v3/catalog.json` (+6 -6) 📝 `catalog/v3/notes.json` (+6 -6) 📝 `packages/long-term-memory/CHANGELOG.md` (+4 -0) 📝 `packages/long-term-memory/manifest.json` (+3 -3) 📝 `packages/long-term-memory/server.mjs` (+43 -43) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/chat-scope.ts` (+41 -1) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/generation-injection.ts` (+34 -1) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/interop.ts` (+1 -1) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.ts` (+7 -3) 📝 `scripts/build-feature-packages.mjs` (+1 -1) ➕ `tests/long-term-memory-branch-recall.regression.ts` (+227 -0) </details> ### 📄 Description ## Linked issue Closes #1433 ## Why this change Engine treats a branch as a copy of a chat that shares history up to the branch point. When it creates a branch, it copies every rolling summary entry whose messages all come before that point, and keeps the entry ids. Long-Term Memory saves a memory to the one chat record (branch) it came from, and recall matched only that record. So a new branch recalled none of the memories built from its shared history, even though Engine had copied the summaries those memories came from. ## What changed ```diff prepareGenerationLongTermMemory (each turn) scope = resolveChatLtmScope(chat) + inheritedNoteIds = branchInheritedNoteIds(chat) + no groupId -> undefined (unbranched chats do no extra work) + ids = summaries(chat) minus day/week and game-session ids + no ids, or no other branch with this groupId -> undefined + notes = storage.listNotes({ skipInvalid: true }) (cached vault snapshot) + inheritedBranchLtmNoteIds(...) -> memories where + saved to another branch of this conversation + and at least one extracted_from link + and every extracted_from link is a chat_summary source from this conversation + whose entryId is one of this chat's ids (a missing source fails) retrieveLongTermMemory({ ..., inheritedNoteIds }) retrieveLongTermMemory chunk filter status / resolved / mode / noteTypes unchanged exclusiveCharacterIds (targeted reply) unchanged, ignores the inherited set - matchesLtmScope(chunk, scope) + matchesLtmScope(chunk, scope) || inheritedNoteIds?.has(chunk.noteId) ``` - `chat-scope.ts`: the pure `inheritedBranchLtmNoteIds` helper. - `retrieval.ts`: an optional `inheritedNoteIds` input. Only `generation-injection.ts` passes it. Extraction update targets, candidate reconciliation, the search route and all other callers behave exactly as before. That is why an inherited memory is read-only in the branch: extraction never picks it as an update target. - `interop.ts`: `summaries` is exported, so recall reads summary ids the same way Sources does. - **One choice beyond the issue's Minimal fix:** Conversation day and week summaries (`day:<date>`, `week:<date>`) and game session summaries (`game-session-N`) never count as shared. - Those ids are dates or sequence numbers. After the split, both branches can write a different summary under the same id, which would break the "after the branch point" rule. - Engine drops day and week summaries when it creates a branch. - Game sessions keep today's behaviour: a memory made from a game session is not recalled in another branch. - `long-term-memory` 1.4.44: CHANGELOG entry, version, manifest, rebuilt `server.mjs`, artifact and catalog entries. - `.github/workflows/ltm-browser.yml`: `branch-recall` is added to the Long-Term Memory regression loop. ## Package and security impact - Affected package IDs: `long-term-memory` - Engine compatibility impact: none. Engine versions that don't copy summaries into branches, and branches made before they did, share no summary ids, so they recall exactly what they do today. - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: - Storage: none. Notes, scopes, `recall.json`, backups and the schema are unchanged, and there is no migration. The regression checks that note files and `recall.json` are byte-identical after recall. - Downgrade and rollback: safe. Rolling back only stops the extra recall. - Cost: each turn in a branched chat that has rolling summaries lists the host's chats and reads the vault's notes from the cached snapshot. Chats without branches skip both. ## Validation - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes These checks were run by the coding agent, not by a person. Engine checkout `2039583ca`, Node `v24.15.0`. - New regression `tests/long-term-memory-branch-recall.regression.ts`. It runs the issue's table through `prepareGenerationLongTermMemory`: - Fixtures: A and its branch B in group G share E1; A has E2 and B has E3; C is another conversation that reuses E1's id. - Expected recall: A gets m1, m2, m3, m5 and m8; B gets m1, m4, m5 and m6; C gets m7. - m8 is A's `game-session-1`. B has its own `game-session-1`, and B must not recall m8. - It also checks that a missing source fails, and so does another conversation's source that reuses E1's id. - Note files and `recall.json` stay byte-identical after recall. - A chat without a group, or a group chat with no summaries, never calls `listChats`. - **Before:** the same test against the unfixed source exits 1 at "branch B recalls A's memories built only from the shared E1", because `world_m1` is missing. **After:** exits 0. - **Mutations:** removing the day/week/game-session filter exits 1 (B recalls `world_m8`). Removing the check on the source's conversation exits 1 (`world_cross` is inherited). - On the source commit, these all passed: `test-ltm.sh runtime`, `index-keys`, `routes`, `routes-scope-identity`, and `reconciliation-recall`. So did `typecheck-packages long-term-memory` and a package build. - On the release HEAD these all passed: - `test-fast.sh` (`npm run check`, `git diff --check`); - `test-catalog-lanes`, `validate-package-locales`, `validate-catalog` and `catalog-release-notes`; - `branch-recall`; - `test-ltm.sh installation` (installs, restarts, backs up, uninstalls and reinstalls the rebuilt 1.4.44 artifact). - Not done: a live check in Engine of branching a chat after an imported summary and recalling the memory in the branch. - Known limits, not changed here: - If listing chats or notes fails, the branch gets no recall for that turn, like any other retrieval failure. - The `/api/long-term-memory/search` route doesn't include inherited memories. - The recall explanation in Debug doesn't mark them. - Identity is the summary entry id only. If the summary is edited in place after the split, memories made from the edited text still reach the branch. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) None. Nothing changes on screen. The availability editor and the Vault filter still show stored assignments exactly as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Long-Term Memory can now recall eligible memories across branches of the same conversation when their source summaries are shared before the branch point. Memories from later summaries or other sources remain branch-specific, and memories do not carry across conversations. * **Bug Fixes** * Improved branch-recall validation to exclude memories with missing or unrelated source summaries. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:11:45 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1460
No description provided.