[PR #7247] [MERGED] fix(memory): a character joining a group chat no longer holds back scenes with hidden messages #7643

Closed
opened 2026-10-24 04:06:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7247
Author: @SpicyMarinara
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/newcomer-scene-visibility


📝 Commits (6)

  • 6c4d962 fix(memory): a character joining a group chat no longer holds back scenes with hidden messages
  • d429a6e Merge origin/staging into fix/newcomer-scene-visibility
  • 4645226 test(memory): keep the newcomer regression valid with per-character merged recall
  • 3cae4bb Merge origin/staging into fix/newcomer-scene-visibility
  • 81fc046 Merge origin/staging into fix/newcomer-scene-visibility
  • 5e826ee Merge origin/fix/newcomer-scene-visibility

📊 Changes

4 files changed (+164 additions, -10 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/agents/memory.md (+1 -1)
📝 packages/server/src/services/advanced-memory.ts (+30 -9)
📝 scripts/regressions/advanced-memory-summary.regression.ts (+132 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7245

Refs #7237 (Discord report by kociol21: "adding a new character midway ... older summaries remained saved, but their content disappeared from the prompt"). #7239 fixes the merged recall rule for newcomers. This PR fixes the other half of that report, which affects both group modes.

Why this change

  • When a character joined a Roleplay group chat, every scene recap that had a message hidden from one of its characters dropped out of the prompt for the characters who could see only part of it. The scenes were listed for Fix, which wrote them again with paid Helper calls. Nothing the original characters could know had changed.
  • Cause: the saved scene-visibility revision (sceneVisibility() in advanced-memory.ts) hashed what every character currently in the chat could see of the scene. Adding a character changed that hash, so hasCurrentSceneVisibility() turned false for all those scenes.

What changed

  • packages/server/src/services/advanced-memory.ts: the revision now names the reader IDs it covers (<hash>:<JSON reader IDs>). hasCurrentSceneVisibility() recomputes the same hash over only those readers, so a newcomer leaves the recap current.
    • A rename or a visibility change for a covered reader still changes the hash and withholds the recap exactly as before. A covered reader who left the chat also still invalidates it.
    • The recap was never written with the newcomer in mind, so it stays current only while each newcomer can see all of the scene's sources or none of them. A newcomer who can see only part of it withholds the recap, as today.
    • Revisions saved before this change contain no : and keep today's comparison over every character, so they are valid in exactly the cases they are valid today. Fix rewrites them once with the new format. I did not add a legacy heuristic: guessing the original reader set (for example from character order) is safe only in the narrow cases a hash happens to match, and the requested behaviour is "exactly as today" for legacy revisions.
    • Individual mode, single chats, narrator rules and the per-reader recall from #7239 are unchanged. They all go through the same hasCurrentSceneVisibility().
  • scripts/regressions/advanced-memory-summary.regression.ts: a merged and an individual group chat with Maukie, Pantalone and a narrator. Each has two scenes with a message hidden from Pantalone before summarising, one of them rewritten to the legacy revision format. The regression checks the following. It fails on origin/staging at the first post-join assertion.
    • After Cara joins, the current recap is still recalled for Pantalone (and for the merged group). The legacy recap is withheld and listed for Fix, as today, and is current again once Cara leaves. Maukie keeps both, the hidden part stays private, and recall makes no Helper calls.
    • Hiding another scene message from Pantalone, or renaming Pantalone, still withholds the recap and lists it for Fix.
    • A newcomer who can see only part of the scene withholds it. A newcomer who saw none of it does not.
  • docs/agents/memory.md and CHANGELOG.md describe the new behaviour. The translation follow-up is linked below.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Commands the agent ran locally (for the reviewer to confirm, not ticked):

  • pnpm check (exit 0)
  • node scripts/run-regressions.mjs --filter advanced-memory: 15/15 passed
  • node scripts/run-regressions.mjs --filter memory-recall: 5/5 passed
  • node scripts/run-regressions.mjs --filter roleplay-user-private-memory: 1/1 passed
  • pnpm regression:prompt: 3/3 passed
  • The new regression fails on origin/staging. Two mutation checks were also run: dropping the newcomer guard fails the "part of the scene hidden from the newcomer" assertion, and skipping the hash comparison for revisions with a reader list fails an existing visibility assertion.

Manual verification notes

  • Manually verify in a merged Roleplay group chat with Advanced Memory on: hide one message of an early scene from one character before it is summarised, finish the scene, and check the Prompt preview shows its recap for the whole group. Then add a new character, send a message, and confirm the recap is still in Recalled Scenes and the Chat Settings badge does not list the scene for Fix.
  • Manually verify the same in an individual group chat: after the new character joins, the partly hidden character's reply still recalls the scene.
  • Manually verify that renaming the partly hidden character afterwards withholds the recap again and lists it for Fix.
  • Manually verify that on an existing chat whose recaps were saved before this change, adding a character still lists those scenes for Fix once, and after Fix a further newcomer no longer does.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs: docs/agents/memory.md (when recaps need review) and CHANGELOG.md. Translation follow-up: #7246.

UI evidence (if applicable)

Not applicable: server-side recall change with no UI changes.


🔄 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-Engine/pull/7247 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/newcomer-scene-visibility` --- ### 📝 Commits (6) - [`6c4d962`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6c4d962db9c9fa3732af2ba4ac8094737d1372b1) fix(memory): a character joining a group chat no longer holds back scenes with hidden messages - [`d429a6e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d429a6ee78ce2c86e6921eaad0e0a8f9bf695c4f) Merge origin/staging into fix/newcomer-scene-visibility - [`4645226`](https://github.com/Pasta-Devs/Marinara-Engine/commit/464522629bce8211800c774fb3b900141bf63464) test(memory): keep the newcomer regression valid with per-character merged recall - [`3cae4bb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3cae4bbca2d053680da3e4b00abb5919afc5c066) Merge origin/staging into fix/newcomer-scene-visibility - [`81fc046`](https://github.com/Pasta-Devs/Marinara-Engine/commit/81fc046899833e940e827c42da7f702c9cca47eb) Merge origin/staging into fix/newcomer-scene-visibility - [`5e826ee`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e826ee0863e5e60f972601d842a48e539c6ac1a) Merge origin/fix/newcomer-scene-visibility ### 📊 Changes **4 files changed** (+164 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/agents/memory.md` (+1 -1) 📝 `packages/server/src/services/advanced-memory.ts` (+30 -9) 📝 `scripts/regressions/advanced-memory-summary.regression.ts` (+132 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7245 Refs #7237 (Discord report by kociol21: "adding a new character midway ... older summaries remained saved, but their content disappeared from the prompt"). #7239 fixes the merged recall rule for newcomers. This PR fixes the other half of that report, which affects both group modes. ## Why this change - When a character joined a Roleplay group chat, every scene recap that had a message hidden from one of its characters dropped out of the prompt for the characters who could see only part of it. The scenes were listed for **Fix**, which wrote them again with paid Helper calls. Nothing the original characters could know had changed. - Cause: the saved scene-visibility revision (`sceneVisibility()` in `advanced-memory.ts`) hashed what **every** character currently in the chat could see of the scene. Adding a character changed that hash, so `hasCurrentSceneVisibility()` turned false for all those scenes. ## What changed - `packages/server/src/services/advanced-memory.ts`: the revision now names the reader IDs it covers (`<hash>:<JSON reader IDs>`). `hasCurrentSceneVisibility()` recomputes the same hash over only those readers, so a newcomer leaves the recap current. - A rename or a visibility change for a covered reader still changes the hash and withholds the recap exactly as before. A covered reader who left the chat also still invalidates it. - The recap was never written with the newcomer in mind, so it stays current only while each newcomer can see all of the scene's sources or none of them. A newcomer who can see only part of it withholds the recap, as today. - Revisions saved before this change contain no `:` and keep today's comparison over every character, so they are valid in exactly the cases they are valid today. **Fix** rewrites them once with the new format. I did not add a legacy heuristic: guessing the original reader set (for example from character order) is safe only in the narrow cases a hash happens to match, and the requested behaviour is "exactly as today" for legacy revisions. - Individual mode, single chats, narrator rules and the per-reader recall from #7239 are unchanged. They all go through the same `hasCurrentSceneVisibility()`. - `scripts/regressions/advanced-memory-summary.regression.ts`: a merged and an individual group chat with Maukie, Pantalone and a narrator. Each has two scenes with a message hidden from Pantalone before summarising, one of them rewritten to the legacy revision format. The regression checks the following. It fails on `origin/staging` at the first post-join assertion. - After Cara joins, the current recap is still recalled for Pantalone (and for the merged group). The legacy recap is withheld and listed for Fix, as today, and is current again once Cara leaves. Maukie keeps both, the hidden part stays private, and recall makes no Helper calls. - Hiding another scene message from Pantalone, or renaming Pantalone, still withholds the recap and lists it for Fix. - A newcomer who can see only part of the scene withholds it. A newcomer who saw none of it does not. - `docs/agents/memory.md` and `CHANGELOG.md` describe the new behaviour. The translation follow-up is linked below. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Commands the agent ran locally (for the reviewer to confirm, not ticked): - `pnpm check` (exit 0) - `node scripts/run-regressions.mjs --filter advanced-memory`: 15/15 passed - `node scripts/run-regressions.mjs --filter memory-recall`: 5/5 passed - `node scripts/run-regressions.mjs --filter roleplay-user-private-memory`: 1/1 passed - `pnpm regression:prompt`: 3/3 passed - The new regression fails on `origin/staging`. Two mutation checks were also run: dropping the newcomer guard fails the "part of the scene hidden from the newcomer" assertion, and skipping the hash comparison for revisions with a reader list fails an existing visibility assertion. ### Manual verification notes - Manually verify in a merged Roleplay group chat with Advanced Memory on: hide one message of an early scene from one character before it is summarised, finish the scene, and check the Prompt preview shows its recap for the whole group. Then add a new character, send a message, and confirm the recap is still in Recalled Scenes and the Chat Settings badge does not list the scene for **Fix**. - Manually verify the same in an individual group chat: after the new character joins, the partly hidden character's reply still recalls the scene. - Manually verify that renaming the partly hidden character afterwards withholds the recap again and lists it for **Fix**. - Manually verify that on an existing chat whose recaps were saved before this change, adding a character still lists those scenes for **Fix** once, and after **Fix** a further newcomer no longer does. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs: `docs/agents/memory.md` (when recaps need review) and `CHANGELOG.md`. Translation follow-up: #7246. ## UI evidence (if applicable) Not applicable: server-side recall change with no UI changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:06 +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-Engine#7643
No description provided.