[PR #7279] [MERGED] fix(memory): recall message excerpts from scenes with private sections #7659

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

📋 Pull Request Information

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

Base: staging ← Head: fix/excerpts-from-private-scenes


📝 Commits (5)

  • 572039a fix(memory): recall message excerpts from scenes with private sections
  • 5ecbec9 Merge origin/staging into fix/excerpts-from-private-scenes
  • 17ec347 Merge origin/staging into fix/excerpts-from-private-scenes
  • b417056 Merge origin/staging into fix/excerpts-from-private-scenes
  • 1382cf4 Merge origin/staging into fix/excerpts-from-private-scenes

📊 Changes

8 files changed (+169 additions, -47 deletions)

View changed files

📝 CHANGELOG.md (+2 -1)
📝 docs/agents/memory.md (+4 -4)
📝 packages/client/src/components/chat/AdvancedMemoryInspector.tsx (+0 -1)
📝 packages/client/src/localization/locales/en.json (+0 -1)
📝 packages/server/src/services/advanced-memory.ts (+16 -24)
📝 scripts/regressions/advanced-memory-audience.regression.ts (+117 -9)
📝 scripts/regressions/advanced-memory-decisions.regression.ts (+14 -4)
📝 scripts/regressions/advanced-memory-summary.regression.ts (+16 -3)

📄 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

Refs #7269 (follow-up to #7277, which merged while this was being built)

Why this change

Mari, testing Advanced Memory Recall with the Decision model (Jev) on: "only Scene Summaries get included but never message excerpts. Not even if context size allows for it."

#7277 fixed excerpt sizing and added receipt reasons. Its investigation found the bigger cause: canRecallExcerpt in packages/server/src/services/advanced-memory.ts withheld excerpts from every scene whose summary has a {{#if char == "Name"}} section, unless the narrator alone was reading. In group chats, the helper writes such a section in almost every summary, so excerpts almost never appeared. The narrator-only rule was a deliberate shortcut, documented in docs/agents/memory.md and pinned by three regressions.

Maintainer decision (Mari, 2026-10-08)

Mari chose "Allow if they saw the messages": excerpts may come from any scene a character remembers, but they use only the messages that weren't hidden from that character, which is exactly what they saw in the chat at the time, so nothing new is revealed. Private summary sections keep rendering per character, as now. This replaces the old rule, so the regression assertions that encode "no excerpts from conditional recaps" are updated (listed below). Every other privacy assertion is kept.

One consequence to be aware of: in a chat that switches point of view without hiding messages, a character's excerpt can now quote the other POV's lines, because those messages were visible to them. Hiding a message from a character (per-character Hide from AI, or Automatic message visibility) is what keeps it out of their memory.

What changed

  • packages/server/src/services/advanced-memory.ts:
    • Removed canRecallExcerpt. A summary's private sections no longer gate the scene's excerpt or the Decision model's message pass.
    • Unchanged and now load-bearing: each scene's excerpt draws only on sceneSource, which is the reader's eligible messages (not hidden from that reader and inside their knowledge range; in a merged group, readable by every character named as remembering the scene), indexed, and not excluded. Excerpt text comes from messageText, which renders the message body and readable attachments only. Whispers live in extra.roleplayCommandActivity (#7191), and user whisper tags are stripped from content on load, so whisper text never reaches an excerpt for anyone.
    • Removed the now-impossible excerpt-private-scene receipt reason (added in #7277). The excerpt-no-room and excerpt-no-source reasons stay.
    • Bumped the preparation policy revision (scene-timeframe-constants-v22) so swipes of replies prepared under the old rule recall again instead of reusing a snapshot with no excerpts. #7237 bumped it for the same kind of change.
  • AdvancedMemoryInspector.tsx / en.json: removed the excerptPrivateScene reason key. #7277 introduced it and it never shipped in a release, so no saved receipt can carry it.
  • docs/agents/memory.md: replaced the narrator-only excerpt sentences (Optional Decision model, While chatting) with the new rule, dropped the private-scene reason from Moving context, and added that a merged group's excerpt quotes only what every character who remembers the scene saw.
  • CHANGELOG.md: new [Unreleased] entry. Also removed the private-scene reason from the #7277 entry.
  • No model prompt changed. Debug prompt logging is untouched.

Updated assertions (authorized by Mari's decision)

Each of these asserted that a recap with a character condition gives a non-narrator no excerpt. Each now asserts the new rule: the excerpt holds exactly the messages that reader saw.

File Old assertion New assertion
advanced-memory-decisions.regression.ts "private recap conditions withhold raw excerpts" ([]), Decision requests never contain "Cobalt refuge" (the reader's own message), receipt has excerpt-private-scene recalls [#4], which the reader saw. Decision requests and the prompt still never contain CONDITION_SECRET or PRIVATE_SECRET (hidden from the reader). No excerpt-* reason and no diagnostics notes
advanced-memory-summary.regression.ts "raw excerpts cannot bypass a partial knowledge view" ([] for each POV) each POV recalls both scene messages (nothing is hidden from either). The other POV's summary section stays out, as before
advanced-memory-summary.regression.ts "matching the narrator's recap text does not grant a character access to raw private source messages" ([]) message visibility, not the recap's conditions, decides: Maukie recalls the messages he saw
advanced-memory-audience.regression.ts merged group: the shared scene's summary ends the block (MAUKIE_PRIVATE]$) and "raw excerpts still come only from scenes without private sections" the shared scene's private marker is followed by its #3–#4 excerpt, and both scenes' messages are recalled
advanced-memory-audience.regression.ts exclusion checks expected only the Maukie-only scene's messages the same exclusions, plus the shared scene's untouched #3–#4
advanced-memory-audience.regression.ts merged narrator duo: summary ends the block (MAUKIE_PRIVATE$) the summary is still read as Maukie (no DUO_NARRATOR), now followed by an excerpt
advanced-memory-audience.regression.ts individual Maukie and Pantalone: shared summary with no excerpt the same summaries plus the #3–#4 excerpt both saw. MAUKIE_PRIVATE still reaches only Maukie

Kept unchanged: every assertion that a hidden message, another character's summary section, a narrator-only section or PRIVATE_SECRET/CONDITION_SECRET stays out, including !recalledMessageIds.includes(<message hidden from the borrower>) and the exclusion and merged-reader checks.

New regressions (fail on the pre-change code)

  • advanced-memory-summary.regression.ts, individual group chat whose summary has a Pantalone-only section: each reader's excerpt is exactly the scene messages they saw. The ledger message hidden from the borrower stays out of his.
  • advanced-memory-audience.regression.ts, "Private-section excerpts": a scene with a Maukie-only summary section, one message hidden from Pantalone, a user whisper to Maukie (raw tag plus saved activity) and a character whisper to Maukie.
    • Individual: Maukie quotes all three messages, Pantalone quotes only the two he saw, and the narrator quotes all three. No whisper text reaches Pantalone.
    • Merged: only the messages every character who remembers the scene saw (#1, #3). The private marker stays and no whisper text appears.
    • One-character chat: Maukie's private section is shown and the excerpt skips the message hidden from him.

On the pre-change service, the new excerpt assertions fail: individual Maukie and Pantalone, merged, and one-character. The new summary-file assertion expects excerpts where the old code gave []. The whisper and narrator assertions pass both before and after: excerpts never rendered whispers, and the narrator already got excerpts. They guard against regressions.

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 (results for the reviewer to confirm, not ticked boxes):

  • pnpm check: exit 0.
  • node ./scripts/run-regressions.mjs --filter advanced-memory: 15/15 passed.
  • --filter memory-recall 5/5, --filter summary 5/5, --filter whisper 2/2 (roleplay-whisper-generation, roleplay-whisper-hidden-recipient), roleplay-user-private-memory 1/1, native-export-memory 1/1.
  • pnpm regression:prompt: 3/3 passed. pnpm localization:check: exit 0.
  • Pre-change proof: with the #7277 service file swapped back in, all three regression files fail at their first updated assertion. With every new assertion in the "Private-section excerpts" block made non-fatal, each one listed as failing above failed there.
  • Re-ran pnpm check, --filter advanced-memory (15/15), memory-recall (5/5), whisper (2/2), roleplay-user-private-memory (1/1) and pnpm regression:prompt on b41705671, after staging (#7275, #7278) was merged in. All passed.
  • Local CodeRabbit: rate limited on all four attempts, because the shared quota was used up. No local review ran. The GitHub CodeRabbit review found one issue, a duplicate CHANGELOG entry left by a staging merge. It was fixed in 17ec347e5 and the thread is resolved.

Manual verification notes

  • Manually verify in a Roleplay group chat where characters reply one by one, with Advanced Memory Recall and Use Decision model on: after a reply that recalls an earlier scene whose summary has a {{#if char == "Name"}} part, open Peek Prompt and check the recalled scene has an Excerpt under its summary.
  • Manually verify that a message hidden from the replying character (crossed-eye marker) never appears in that character's excerpt, and that whisper text never appears in any excerpt.
  • Manually verify the same in a merged group chat: the excerpt holds only messages that every character named as remembering the scene could see.
  • Manually verify that swiping a reply made before this update recalls again and now shows excerpts.
  • Manually verify that the memory receipt no longer shows a "parts meant only for some characters" reason.

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/agents/memory.md and CHANGELOG.md [Unreleased] are updated. Translation follow-up: added the new sentences to the open #7276.

UI evidence (if applicable)

One receipt line removed; no layout or colour change.

Summary by CodeRabbit

  • New Features
    • Recalled scenes can now include message excerpts even when their summaries contain character-specific private sections.
    • Excerpts show only messages visible to the character recalling the scene. In merged group chats, they include only messages visible to every character who remembers it; whisper content remains excluded.
  • Documentation
    • Updated the memory guide to clarify how excerpt visibility works for individual and merged group chats.

🔄 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/7279 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/excerpts-from-private-scenes` --- ### 📝 Commits (5) - [`572039a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/572039a015f1fad4c6b1055bb5f84600e6648f5b) fix(memory): recall message excerpts from scenes with private sections - [`5ecbec9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5ecbec981861b1cf242d2fc627a3462c13480f02) Merge origin/staging into fix/excerpts-from-private-scenes - [`17ec347`](https://github.com/Pasta-Devs/Marinara-Engine/commit/17ec347e5f04579528e878004034ff613dab2fc2) Merge origin/staging into fix/excerpts-from-private-scenes - [`b417056`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b41705671dfca8eba34da53ebb5d8ac7f1062f8f) Merge origin/staging into fix/excerpts-from-private-scenes - [`1382cf4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1382cf493f4c301fded1263644442b515b399e6c) Merge origin/staging into fix/excerpts-from-private-scenes ### 📊 Changes **8 files changed** (+169 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -1) 📝 `docs/agents/memory.md` (+4 -4) 📝 `packages/client/src/components/chat/AdvancedMemoryInspector.tsx` (+0 -1) 📝 `packages/client/src/localization/locales/en.json` (+0 -1) 📝 `packages/server/src/services/advanced-memory.ts` (+16 -24) 📝 `scripts/regressions/advanced-memory-audience.regression.ts` (+117 -9) 📝 `scripts/regressions/advanced-memory-decisions.regression.ts` (+14 -4) 📝 `scripts/regressions/advanced-memory-summary.regression.ts` (+16 -3) </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 Refs #7269 (follow-up to #7277, which merged while this was being built) ## Why this change Mari, testing Advanced Memory Recall with the Decision model (Jev) on: "only Scene Summaries get included but never message excerpts. Not even if context size allows for it." #7277 fixed excerpt sizing and added receipt reasons. Its investigation found the bigger cause: `canRecallExcerpt` in `packages/server/src/services/advanced-memory.ts` withheld excerpts from every scene whose summary has a `{{#if char == "Name"}}` section, unless the narrator alone was reading. In group chats, the helper writes such a section in almost every summary, so excerpts almost never appeared. The narrator-only rule was a deliberate shortcut, documented in `docs/agents/memory.md` and pinned by three regressions. ### Maintainer decision (Mari, 2026-10-08) Mari chose **"Allow if they saw the messages"**: excerpts may come from any scene a character remembers, but they use only the messages that weren't hidden from that character, which is exactly what they saw in the chat at the time, so nothing new is revealed. Private summary sections keep rendering per character, as now. This replaces the old rule, so the regression assertions that encode "no excerpts from conditional recaps" are updated (listed below). Every other privacy assertion is kept. One consequence to be aware of: in a chat that switches point of view without hiding messages, a character's excerpt can now quote the other POV's lines, because those messages were visible to them. Hiding a message from a character (per-character **Hide from AI**, or **Automatic message visibility**) is what keeps it out of their memory. ## What changed - `packages/server/src/services/advanced-memory.ts`: - Removed `canRecallExcerpt`. A summary's private sections no longer gate the scene's excerpt or the Decision model's message pass. - Unchanged and now load-bearing: each scene's excerpt draws only on `sceneSource`, which is the reader's eligible messages (not hidden from that reader and inside their knowledge range; in a merged group, readable by every character named as remembering the scene), indexed, and not excluded. Excerpt text comes from `messageText`, which renders the message body and readable attachments only. Whispers live in `extra.roleplayCommandActivity` (#7191), and user whisper tags are stripped from content on load, so whisper text never reaches an excerpt for anyone. - Removed the now-impossible `excerpt-private-scene` receipt reason (added in #7277). The `excerpt-no-room` and `excerpt-no-source` reasons stay. - Bumped the preparation policy revision (`scene-timeframe-constants-v22`) so swipes of replies prepared under the old rule recall again instead of reusing a snapshot with no excerpts. #7237 bumped it for the same kind of change. - `AdvancedMemoryInspector.tsx` / `en.json`: removed the `excerptPrivateScene` reason key. #7277 introduced it and it never shipped in a release, so no saved receipt can carry it. - `docs/agents/memory.md`: replaced the narrator-only excerpt sentences (Optional Decision model, While chatting) with the new rule, dropped the private-scene reason from **Moving context**, and added that a merged group's excerpt quotes only what every character who remembers the scene saw. - `CHANGELOG.md`: new `[Unreleased]` entry. Also removed the private-scene reason from the #7277 entry. - No model prompt changed. Debug prompt logging is untouched. ### Updated assertions (authorized by Mari's decision) Each of these asserted that a recap with a character condition gives a non-narrator no excerpt. Each now asserts the new rule: the excerpt holds exactly the messages that reader saw. | File | Old assertion | New assertion | | --- | --- | --- | | `advanced-memory-decisions.regression.ts` | "private recap conditions withhold raw excerpts" (`[]`), Decision requests never contain "Cobalt refuge" (the reader's own message), receipt has `excerpt-private-scene` | recalls `[#4]`, which the reader saw. Decision requests and the prompt still never contain `CONDITION_SECRET` or `PRIVATE_SECRET` (hidden from the reader). No `excerpt-*` reason and no diagnostics notes | | `advanced-memory-summary.regression.ts` | "raw excerpts cannot bypass a partial knowledge view" (`[]` for each POV) | each POV recalls both scene messages (nothing is hidden from either). The other POV's summary section stays out, as before | | `advanced-memory-summary.regression.ts` | "matching the narrator's recap text does not grant a character access to raw private source messages" (`[]`) | message visibility, not the recap's conditions, decides: Maukie recalls the messages he saw | | `advanced-memory-audience.regression.ts` | merged group: the shared scene's summary ends the block (`MAUKIE_PRIVATE]$`) and "raw excerpts still come only from scenes without private sections" | the shared scene's private marker is followed by its #3–#4 excerpt, and both scenes' messages are recalled | | `advanced-memory-audience.regression.ts` | exclusion checks expected only the Maukie-only scene's messages | the same exclusions, plus the shared scene's untouched #3–#4 | | `advanced-memory-audience.regression.ts` | merged narrator duo: summary ends the block (`MAUKIE_PRIVATE$`) | the summary is still read as Maukie (no `DUO_NARRATOR`), now followed by an excerpt | | `advanced-memory-audience.regression.ts` | individual Maukie and Pantalone: shared summary with no excerpt | the same summaries plus the #3–#4 excerpt both saw. `MAUKIE_PRIVATE` still reaches only Maukie | Kept unchanged: every assertion that a hidden message, another character's summary section, a narrator-only section or `PRIVATE_SECRET`/`CONDITION_SECRET` stays out, including `!recalledMessageIds.includes(<message hidden from the borrower>)` and the exclusion and merged-reader checks. ### New regressions (fail on the pre-change code) - `advanced-memory-summary.regression.ts`, individual group chat whose summary has a Pantalone-only section: each reader's excerpt is exactly the scene messages they saw. The ledger message hidden from the borrower stays out of his. - `advanced-memory-audience.regression.ts`, "Private-section excerpts": a scene with a Maukie-only summary section, one message hidden from Pantalone, a user whisper to Maukie (raw tag plus saved activity) and a character whisper to Maukie. - Individual: Maukie quotes all three messages, Pantalone quotes only the two he saw, and the narrator quotes all three. No whisper text reaches Pantalone. - Merged: only the messages every character who remembers the scene saw (`#1`, `#3`). The private marker stays and no whisper text appears. - One-character chat: Maukie's private section is shown and the excerpt skips the message hidden from him. On the pre-change service, the new excerpt assertions fail: individual Maukie and Pantalone, merged, and one-character. The new summary-file assertion expects excerpts where the old code gave `[]`. The whisper and narrator assertions pass both before and after: excerpts never rendered whispers, and the narrator already got excerpts. They guard against regressions. ## 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 (results for the reviewer to confirm, not ticked boxes): - `pnpm check`: exit 0. - `node ./scripts/run-regressions.mjs --filter advanced-memory`: 15/15 passed. - `--filter memory-recall` 5/5, `--filter summary` 5/5, `--filter whisper` 2/2 (`roleplay-whisper-generation`, `roleplay-whisper-hidden-recipient`), `roleplay-user-private-memory` 1/1, `native-export-memory` 1/1. - `pnpm regression:prompt`: 3/3 passed. `pnpm localization:check`: exit 0. - Pre-change proof: with the #7277 service file swapped back in, all three regression files fail at their first updated assertion. With every new assertion in the "Private-section excerpts" block made non-fatal, each one listed as failing above failed there. - Re-ran `pnpm check`, `--filter advanced-memory` (15/15), `memory-recall` (5/5), `whisper` (2/2), `roleplay-user-private-memory` (1/1) and `pnpm regression:prompt` on `b41705671`, after staging (#7275, #7278) was merged in. All passed. - Local CodeRabbit: rate limited on all four attempts, because the shared quota was used up. No local review ran. The GitHub CodeRabbit review found one issue, a duplicate CHANGELOG entry left by a staging merge. It was fixed in `17ec347e5` and the thread is resolved. ### Manual verification notes - Manually verify in a Roleplay group chat where characters reply one by one, with Advanced Memory Recall and **Use Decision model** on: after a reply that recalls an earlier scene whose summary has a `{{#if char == "Name"}}` part, open **Peek Prompt** and check the recalled scene has an **Excerpt** under its summary. - Manually verify that a message hidden from the replying character (crossed-eye marker) never appears in that character's excerpt, and that whisper text never appears in any excerpt. - Manually verify the same in a merged group chat: the excerpt holds only messages that every character named as remembering the scene could see. - Manually verify that swiping a reply made before this update recalls again and now shows excerpts. - Manually verify that the memory receipt no longer shows a "parts meant only for some characters" reason. ## 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/agents/memory.md` and `CHANGELOG.md` `[Unreleased]` are updated. Translation follow-up: added the new sentences to the open #7276. ## UI evidence (if applicable) One receipt line removed; no layout or colour change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Recalled scenes can now include message excerpts even when their summaries contain character-specific private sections. * Excerpts show only messages visible to the character recalling the scene. In merged group chats, they include only messages visible to every character who remembers it; whisper content remains excluded. * **Documentation** * Updated the memory guide to clarify how excerpt visibility works for individual and merged group chats. <!-- 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-24 04:06:16 +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#7659
No description provided.