[PR #6744] [MERGED] feat(memory): make semantic summary recall configurable per chat #7306

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

📋 Pull Request Information

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

Base: staging ← Head: feat/issue-6705


📝 Commits (5)

  • 8a9e104 feat(memory): configure semantic summary recall and cache vectors (#6705)
  • 2836938 fix(memory): place recall controls beneath existing switches
  • 7b8b28b Merge remote-tracking branch 'origin/staging' into codex/merge-6744
  • 23320fc test(memory): clean up semantic recall chats when setup fails
  • 90372e4 Merge remote-tracking branch 'origin/staging' into codex/merge-6744

📊 Changes

20 files changed (+807 additions, -22 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
➕ e2e/semantic-recall-controls.e2e.ts (+180 -0)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+20 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+20 -0)
➕ packages/client/src/components/chat/SemanticSummaryRetrievalControls.tsx (+81 -0)
📝 packages/client/src/components/chat/SummaryPopover.tsx (+22 -0)
📝 packages/client/src/localization/locales/en.json (+6 -1)
📝 packages/server/src/routes/chats.routes.ts (+12 -0)
📝 packages/server/src/routes/generate/conversation-history-runtime.ts (+34 -10)
📝 packages/server/src/services/generation/roleplay-summary-retrieval.ts (+21 -10)
➕ packages/server/src/services/generation/summary-document-embeddings.ts (+75 -0)
📝 packages/server/src/services/memory-recall-embedding.ts (+34 -1)
📝 packages/server/src/services/memory-recall.ts (+2 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/chat.ts (+3 -0)
➕ packages/shared/src/types/semantic-summary-retrieval.ts (+17 -0)
📝 scripts/regressions/prompt.regression.ts (+27 -0)
📝 scripts/regressions/regeneration-context.regression.ts (+49 -0)
➕ scripts/regressions/semantic-summary-cancellation.regression.ts (+46 -0)
➕ scripts/regressions/semantic-summary-settings.regression.ts (+155 -0)

📄 Description

Linked issue

Closes #6705

Why this change

Semantic summary retrieval already exists, but its fixed recent-summary count, older-match count, and relevance threshold cannot be tuned for an individual Roleplay chat. This extends the existing retrieval path and settings drawer rather than replacing either system.

What changed

  • Add Roleplay Chat Settings controls for recent summaries (0–20), older matches (0–20), and relevance threshold (0–1). Defaults remain 2, 3, and 0.15; retrieval remains opt-in. The four-message query window stays unchanged.
  • Validate the three metadata fields before saving. Roleplay and Conversation retrieval consume the same bounded settings; this PR adds the controls to Roleplay.
  • Reuse unchanged summary document vectors in a bounded, 512-entry process-local cache. Cache identity includes the document content and embedding configuration; credential/routing changes invalidate reuse without exposing those values in the cache key. No persistent vector-storage migration is introduced.
  • Preserve full-summary fallback when embeddings are unavailable. Reject late embedding responses after cancellation so cancelled work cannot populate the cache.
  • Add localized English labels, regression coverage, and an Unreleased changelog entry. This branch is independent of #6708's batching work.

Validation

  • CodeQL alert #571 was traced and dismissed as a false positive: SHA-256 keys only the private bounded in-memory summary-vector cache; it is not a stored password verifier, authentication check, API response, or log. Credential/tenant-change cache invalidation is covered by the semantic-summary regression. The CodeQL rule concerns password storage.

Maintainer integration validation on 90372e47a (base 3af58b06b):

  • pnpm check and pnpm regression:prompt passed.
  • Both semantic-summary regression files and the regeneration-context regression passed: settings validation, defaults, caching, cancellation, and context selection.
  • All six semantic-control UI cases passed across desktop Chromium, mobile Chromium, and mobile WebKit, covering Roleplay and Conversation persistence/reload and enable/disable behavior.
  • pnpm smoke:ui: 7/7 passed.
  • Integrated #6746 by retaining its shared batching/cancellation helper and adding the cache identity field; prompt, semantic-summary and memory-recall regressions pass together.
  • Resolved the staging changelog conflict and moved fallible roleplay setup into the test cleanup scope.
  • Local CodeRabbit was attempted but blocked by the service's hourly review quota. Current hosted CodeRabbit and all required GitHub checks must pass before merge; no successful local review is claimed.

Human verification checklist:

  • 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

Manual verification notes

Manually verify enable/disable and saved values after reload, recent-only selection with zero older matches, provider-unavailable fallback, and cancellation followed by a successful retry. Confirm both themes and a mobile viewport. Automated browser evidence is described above; no human verification is claimed.

Docs and release impact

Unreleased changelog updated. No version bump or changes under docs/.

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs updated or follow-up issue opened, if applicable
  • Version/release files updated, if applicable

UI evidence (if applicable)

Before/after screenshots in dark and light themes, desktop Chromium and iPhone-sized WebKit. Download the self-contained HTML gallery from the gist to view its embedded original PNG captures. All screenshots use disposable synthetic data; browser emulation is not a physical-device test.

Summary by CodeRabbit

  • New Features
    • Roleplay and conversation chats offer configurable semantic summary recall: set how many recent summaries to retain, how many older summaries to match, and the minimum relevance threshold.
    • Settings appear alongside summarization controls and persist per chat. Recall can be turned off.
  • Bug Fixes
    • Summary recall falls back to the full summary context when embeddings are unavailable or retrieval fails. Embedding results received after cancellation are not used.

🔄 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/6744 **Author:** [@SirAdoni](https://github.com/SirAdoni) **Created:** 9/27/2026 **Status:** ✅ Merged **Merged:** 9/27/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/issue-6705` --- ### 📝 Commits (5) - [`8a9e104`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a9e1040f04700ae9f91a442ba44977cd2e74e74) feat(memory): configure semantic summary recall and cache vectors (#6705) - [`2836938`](https://github.com/Pasta-Devs/Marinara-Engine/commit/28369382946b418d20c3216ca05cb554d83f72c9) fix(memory): place recall controls beneath existing switches - [`7b8b28b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7b8b28b16b7b0ee1f8a17877f64221f41b629993) Merge remote-tracking branch 'origin/staging' into codex/merge-6744 - [`23320fc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/23320fc4aa358f3b509a3736be4f440df9172bee) test(memory): clean up semantic recall chats when setup fails - [`90372e4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90372e47ae726f1416f71ae15f9b6b8802d377fe) Merge remote-tracking branch 'origin/staging' into codex/merge-6744 ### 📊 Changes **20 files changed** (+807 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) ➕ `e2e/semantic-recall-controls.e2e.ts` (+180 -0) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+20 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+20 -0) ➕ `packages/client/src/components/chat/SemanticSummaryRetrievalControls.tsx` (+81 -0) 📝 `packages/client/src/components/chat/SummaryPopover.tsx` (+22 -0) 📝 `packages/client/src/localization/locales/en.json` (+6 -1) 📝 `packages/server/src/routes/chats.routes.ts` (+12 -0) 📝 `packages/server/src/routes/generate/conversation-history-runtime.ts` (+34 -10) 📝 `packages/server/src/services/generation/roleplay-summary-retrieval.ts` (+21 -10) ➕ `packages/server/src/services/generation/summary-document-embeddings.ts` (+75 -0) 📝 `packages/server/src/services/memory-recall-embedding.ts` (+34 -1) 📝 `packages/server/src/services/memory-recall.ts` (+2 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/chat.ts` (+3 -0) ➕ `packages/shared/src/types/semantic-summary-retrieval.ts` (+17 -0) 📝 `scripts/regressions/prompt.regression.ts` (+27 -0) 📝 `scripts/regressions/regeneration-context.regression.ts` (+49 -0) ➕ `scripts/regressions/semantic-summary-cancellation.regression.ts` (+46 -0) ➕ `scripts/regressions/semantic-summary-settings.regression.ts` (+155 -0) </details> ### 📄 Description ## Linked issue Closes #6705 ## Why this change Semantic summary retrieval already exists, but its fixed recent-summary count, older-match count, and relevance threshold cannot be tuned for an individual Roleplay chat. This extends the existing retrieval path and settings drawer rather than replacing either system. ## What changed - Add Roleplay Chat Settings controls for recent summaries (0–20), older matches (0–20), and relevance threshold (0–1). Defaults remain 2, 3, and 0.15; retrieval remains opt-in. The four-message query window stays unchanged. - Validate the three metadata fields before saving. Roleplay and Conversation retrieval consume the same bounded settings; this PR adds the controls to Roleplay. - Reuse unchanged summary document vectors in a bounded, 512-entry process-local cache. Cache identity includes the document content and embedding configuration; credential/routing changes invalidate reuse without exposing those values in the cache key. No persistent vector-storage migration is introduced. - Preserve full-summary fallback when embeddings are unavailable. Reject late embedding responses after cancellation so cancelled work cannot populate the cache. - Add localized English labels, regression coverage, and an Unreleased changelog entry. This branch is independent of #6708's batching work. ## Validation - CodeQL alert #571 was traced and dismissed as a false positive: SHA-256 keys only the private bounded in-memory summary-vector cache; it is not a stored password verifier, authentication check, API response, or log. Credential/tenant-change cache invalidation is covered by the semantic-summary regression. The [CodeQL rule](https://codeql.github.com/codeql-query-help/javascript/js-insufficient-password-hash/) concerns password storage. Maintainer integration validation on `90372e47a` (base `3af58b06b`): - `pnpm check` and `pnpm regression:prompt` passed. - Both semantic-summary regression files and the regeneration-context regression passed: settings validation, defaults, caching, cancellation, and context selection. - All six semantic-control UI cases passed across desktop Chromium, mobile Chromium, and mobile WebKit, covering Roleplay and Conversation persistence/reload and enable/disable behavior. - `pnpm smoke:ui`: 7/7 passed. - Integrated #6746 by retaining its shared batching/cancellation helper and adding the cache identity field; prompt, semantic-summary and memory-recall regressions pass together. - Resolved the staging changelog conflict and moved fallible roleplay setup into the test cleanup scope. - Local CodeRabbit was attempted but blocked by the service's hourly review quota. Current hosted CodeRabbit and all required GitHub checks must pass before merge; no successful local review is claimed. Human verification checklist: - [ ] `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) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Manually verify enable/disable and saved values after reload, recent-only selection with zero older matches, provider-unavailable fallback, and cancellation followed by a successful retry. Confirm both themes and a mobile viewport. Automated browser evidence is described above; no human verification is claimed. ## Docs and release impact Unreleased changelog updated. No version bump or changes under `docs/`. - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs updated or follow-up issue opened, if applicable - [ ] Version/release files updated, if applicable ## UI evidence (if applicable) [Before/after screenshots in dark and light themes, desktop Chromium and iPhone-sized WebKit](https://gist.github.com/SpicyMarinara/2fcb9a8f4e2f377ee141ea1e67940b54). Download the self-contained HTML gallery from the gist to view its embedded original PNG captures. All screenshots use disposable synthetic data; browser emulation is not a physical-device test. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Roleplay and conversation chats offer configurable semantic summary recall: set how many recent summaries to retain, how many older summaries to match, and the minimum relevance threshold. * Settings appear alongside summarization controls and persist per chat. Recall can be turned off. * **Bug Fixes** * Summary recall falls back to the full summary context when embeddings are unavailable or retrieval fails. Embedding results received after cancellation are not used. <!-- 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:29 +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#7306
No description provided.