[PR #6680] [MERGED] fix(memory): recall distinctive details and allow partial scene access #7283

Closed
opened 2026-10-23 04:18:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6680
Author: @SpicyMarinara
Created: 9/25/2026
Status: ✅ Merged
Merged: 9/25/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/advanced-memory-scene-recall


📝 Commits (9)

  • 6cbaf9a docs: record advanced memory recall and scene-summary fixes
  • f6f5352 fix(memory): recall distinctive cues and allow partial scene access
  • cebe9aa Merge branch 'staging' into codex/advanced-memory-scene-recall
  • 33fda7b fix(memory): guard stale recap visibility and cache source readers
  • 3346a24 fix(memory): exclude disabled sources from partial recall ranking
  • fbdba5d fix(memory): refresh scene conditions after character renames
  • ed7e650 fix(memory): keep hidden dates out of recalled timelines
  • 0b3c4d8 Merge branch 'staging' into codex/advanced-memory-scene-recall
  • fd8f408 fix(memory): preserve shared scene dates and hidden-history coverage

📊 Changes

10 files changed (+518 additions, -70 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/agents/memory.md (+3 -1)
➕ packages/server/src/services/advanced-memory-ranking.ts (+38 -0)
📝 packages/server/src/services/advanced-memory.ts (+158 -60)
📝 scripts/regressions/advanced-memory-audience.regression.ts (+31 -3)
📝 scripts/regressions/advanced-memory-core.regression.ts (+4 -1)
📝 scripts/regressions/advanced-memory-history-start.regression.ts (+2 -2)
📝 scripts/regressions/advanced-memory-recall.regression.ts (+80 -0)
📝 scripts/regressions/advanced-memory-recovery.regression.ts (+3 -0)
📝 scripts/regressions/advanced-memory-summary.regression.ts (+197 -3)

📄 Description

Linked issue

Closes #6679

Why this change

Advanced Memory can miss a scene despite a distinctive detail appearing in both the new message and the saved recap. A character who witnessed most of a shared scene is also excluded from its recap if even one message was hidden from them.

What changed

Codex is handling this for @SpicyMarinara. Local lexical scoring gives distinctive latest-turn cues more weight and searches indexed messages even with excerpt output disabled. Normal recall adds no helper or embedding calls.

Partial participants can share scene access; entirely hidden scenes remain unavailable. The summary helper receives message-visibility annotations and instructions to keep shared prose plain while conditioning private sections. Saved recaps track source visibility and reader names, so partial readers cannot receive stale or unreviewed legacy text. Targeted preparation repairs generated recaps; manual text requires an explicit reviewed save. Reader visibility sets are cached once per preparation context.

Scene dates and timeframes are shared metadata for every assigned participant, including partial readers. Constant Chat Summaries retain messages hidden from AI, with character conditions controlling access to private details. Existing narrator-only excerpt protection for conditional recaps remains in place.

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

Completed local validation (final revision fd8f408d41f06e12c2f80911e56a03de82f5235a):

  • pnpm check, all 10 Advanced Memory regression suites, and pnpm regression:prompt passed after the final fixes.
  • Desktop browser smoke: 7/7 passed. Focused e2e/advanced-memory.e2e.ts coverage: 10/10 passed after the partial-visibility fix. Later rename and timeline fixes are covered by the memory regressions.
  • Regressions fail before the relevant fixes and pass afterward for distinctive-cue selection, stale visibility, and character renames. Coverage also includes audience PATCH requests, conditional recap rendering, constant reuse, entirely hidden negative controls, and no added recall-model calls. A shared-scene fixture marks both archived messages hidden from AI and verifies both reach the summarizer, every message ID remains covered by constants, private text stays scoped, and all assigned readers retain the scene date, including excerpt labels.
  • Local CodeRabbit reviews are complete; the final review reports zero further findings. Findings about repeated visibility scans, stale recaps, disabled excerpt sources and character renames were fixed. The suggestion to hide scene dates was declined after the maintainer clarified that record.timeline is shared scene metadata: access to private recap text and source excerpts remains separately enforced. The shared-date and hidden-history regressions pin that intended behavior.
  • Local ranking benchmark (23 query terms, 203 distinct terms per record; median of 25 runs): added scoring takes 0.31 ms for 1,000 records and 11.96 ms for 10,000. Existing tokenization measured 13.04 ms and 140.46 ms. These are scoring measurements, not an end-to-end latency guarantee. The existing 1,000-message archive performance regression also passes.

An initial overlapping-build invocation and a browser trace save affected by local disk exhaustion were rerun successfully. The clean browser rerun used --trace off.

Provider responses in regressions are mocked. A real-model replay of the maintainer's private chat and manual browser verification were not performed. GitHub CI and GitHub CodeRabbit remain merge gates.

Manual verification notes

  • Manually verify a distinctive cue recalls the intended archived scene in Roleplay, including with excerpts disabled.
  • Manually verify a shared scene with one hidden conversation allows both participants, retains private character conditions, and recalls only the appropriate recap sections. For existing saved text, prepare the affected generated scene or review and save its private sections before partial access; changing only the audience does not acknowledge old text. The change never silently rewrites authored recaps.
  • Manually verify Constant Chat Summaries include globally hidden messages and preserve character conditions, and that partial scene readers still receive the shared scene date.

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
  • Version/release files updated (only if this PR includes a version bump)

Changelog and docs/agents/memory.md updated. Translation follow-up: #6681. No version or storage-format change.

UI evidence (if applicable)

Server-side recall and summary generation; no visual changes planned.

Summary by CodeRabbit

  • New Features
    • Scene discovery can use distinctive details from recent messages, even when excerpts are disabled, without additional recall-model calls.
    • Characters can access shared scenes when at least one source message is available to them. Hidden messages remain excluded, and scenes with no accessible source messages remain unavailable.
    • Recaps and Constant Chat Summaries can preserve private details under character-specific conditions.
  • Bug Fixes
    • Changes to message visibility or character names require scene preparation or review before affected recap access is restored. Restricted content remains withheld until then.

🔄 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/6680 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/25/2026 **Status:** ✅ Merged **Merged:** 9/25/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/advanced-memory-scene-recall` --- ### 📝 Commits (9) - [`6cbaf9a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6cbaf9ae765bb493356a9ccbf8c1fb135938d782) docs: record advanced memory recall and scene-summary fixes - [`f6f5352`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f6f5352371f4bd01e9c8478ad27474baaaae9c53) fix(memory): recall distinctive cues and allow partial scene access - [`cebe9aa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cebe9aa583e0e2b5a41f17f8927a93ac97814b2e) Merge branch 'staging' into codex/advanced-memory-scene-recall - [`33fda7b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/33fda7b69f1a9c0ccc70c162d48ca41e7eb41339) fix(memory): guard stale recap visibility and cache source readers - [`3346a24`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3346a24a3cd2354e5b0cec19924e2d63bd25af42) fix(memory): exclude disabled sources from partial recall ranking - [`fbdba5d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fbdba5d35cb6467f310c12430485c6c22681dd60) fix(memory): refresh scene conditions after character renames - [`ed7e650`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ed7e650b9be919a5a9a6e06f2c4da75980c32833) fix(memory): keep hidden dates out of recalled timelines - [`0b3c4d8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b3c4d8582b72e54a648669209c220f38804c49a) Merge branch 'staging' into codex/advanced-memory-scene-recall - [`fd8f408`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fd8f408d41f06e12c2f80911e56a03de82f5235a) fix(memory): preserve shared scene dates and hidden-history coverage ### 📊 Changes **10 files changed** (+518 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/agents/memory.md` (+3 -1) ➕ `packages/server/src/services/advanced-memory-ranking.ts` (+38 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+158 -60) 📝 `scripts/regressions/advanced-memory-audience.regression.ts` (+31 -3) 📝 `scripts/regressions/advanced-memory-core.regression.ts` (+4 -1) 📝 `scripts/regressions/advanced-memory-history-start.regression.ts` (+2 -2) 📝 `scripts/regressions/advanced-memory-recall.regression.ts` (+80 -0) 📝 `scripts/regressions/advanced-memory-recovery.regression.ts` (+3 -0) 📝 `scripts/regressions/advanced-memory-summary.regression.ts` (+197 -3) </details> ### 📄 Description ## Linked issue Closes #6679 ## Why this change Advanced Memory can miss a scene despite a distinctive detail appearing in both the new message and the saved recap. A character who witnessed most of a shared scene is also excluded from its recap if even one message was hidden from them. ## What changed Codex is handling this for @SpicyMarinara. Local lexical scoring gives distinctive latest-turn cues more weight and searches indexed messages even with excerpt output disabled. Normal recall adds no helper or embedding calls. Partial participants can share scene access; entirely hidden scenes remain unavailable. The summary helper receives message-visibility annotations and instructions to keep shared prose plain while conditioning private sections. Saved recaps track source visibility and reader names, so partial readers cannot receive stale or unreviewed legacy text. Targeted preparation repairs generated recaps; manual text requires an explicit reviewed save. Reader visibility sets are cached once per preparation context. Scene dates and timeframes are shared metadata for every assigned participant, including partial readers. Constant Chat Summaries retain messages hidden from AI, with character conditions controlling access to private details. Existing narrator-only excerpt protection for conditional recaps remains in place. ## 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` Completed local validation (final revision `fd8f408d41f06e12c2f80911e56a03de82f5235a`): - `pnpm check`, all 10 Advanced Memory regression suites, and `pnpm regression:prompt` passed after the final fixes. - Desktop browser smoke: 7/7 passed. Focused `e2e/advanced-memory.e2e.ts` coverage: 10/10 passed after the partial-visibility fix. Later rename and timeline fixes are covered by the memory regressions. - Regressions fail before the relevant fixes and pass afterward for distinctive-cue selection, stale visibility, and character renames. Coverage also includes audience PATCH requests, conditional recap rendering, constant reuse, entirely hidden negative controls, and no added recall-model calls. A shared-scene fixture marks both archived messages hidden from AI and verifies both reach the summarizer, every message ID remains covered by constants, private text stays scoped, and all assigned readers retain the scene date, including excerpt labels. - Local CodeRabbit reviews are complete; the final review reports zero further findings. Findings about repeated visibility scans, stale recaps, disabled excerpt sources and character renames were fixed. The suggestion to hide scene dates was declined after the maintainer clarified that `record.timeline` is shared scene metadata: access to private recap text and source excerpts remains separately enforced. The shared-date and hidden-history regressions pin that intended behavior. - Local ranking benchmark (23 query terms, 203 distinct terms per record; median of 25 runs): added scoring takes 0.31 ms for 1,000 records and 11.96 ms for 10,000. Existing tokenization measured 13.04 ms and 140.46 ms. These are scoring measurements, not an end-to-end latency guarantee. The existing 1,000-message archive performance regression also passes. An initial overlapping-build invocation and a browser trace save affected by local disk exhaustion were rerun successfully. The clean browser rerun used `--trace off`. Provider responses in regressions are mocked. A real-model replay of the maintainer's private chat and manual browser verification were not performed. GitHub CI and GitHub CodeRabbit remain merge gates. ### Manual verification notes - Manually verify a distinctive cue recalls the intended archived scene in Roleplay, including with excerpts disabled. - Manually verify a shared scene with one hidden conversation allows both participants, retains private character conditions, and recalls only the appropriate recap sections. For existing saved text, prepare the affected generated scene or review and save its private sections before partial access; changing only the audience does not acknowledge old text. The change never silently rewrites authored recaps. - Manually verify Constant Chat Summaries include globally hidden messages and preserve character conditions, and that partial scene readers still receive the shared scene date. ## 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 - [ ] Version/release files updated (only if this PR includes a version bump) Changelog and `docs/agents/memory.md` updated. Translation follow-up: #6681. No version or storage-format change. ## UI evidence (if applicable) Server-side recall and summary generation; no visual changes planned. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Scene discovery can use distinctive details from recent messages, even when excerpts are disabled, without additional recall-model calls. * Characters can access shared scenes when at least one source message is available to them. Hidden messages remain excluded, and scenes with no accessible source messages remain unavailable. * Recaps and Constant Chat Summaries can preserve private details under character-specific conditions. * **Bug Fixes** * Changes to message visibility or character names require scene preparation or review before affected recap access is restored. Restricted content remains withheld until then. <!-- 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-23 04:18:14 +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#7283
No description provided.