[GH-ISSUE #2293] [Issue]: 09-CHAT-STORAGE-delete-derived-state-cleanup leaves stale Memory Recall chunks after message delete #1128

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

Originally created by @Promansis on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2293

Originally assigned to: @Promansis on GitHub.

Summary

09-CHAT-STORAGE-delete-derived-state-cleanup: deleting one chat message or bulk-deleting messages on the refactor branch does not prune or rebuild Memory Recall chunks that were built from the deleted messages. Those stale chunks can still be recalled and injected into later prompts.

Linked parity tracker: #2268.

Expected behavior

Deleting a message or bulk-deleting messages should keep derived chat state coherent. Legacy removes Memory Recall chunks at or after the deleted message timestamp, so deleted message content is not left in recall storage or future prompt recall.

Acceptance criteria:

  • Single-message delete removes, prunes, or rebuilds Memory Recall chunks that reference the deleted message or later affected chat window.
  • Bulk message delete does the same for every affected chat/message set.
  • Existing delete behavior remains intact for visible timeline cache/count updates, message swipe sidecars, tracker snapshots, and visible tracker sync.
  • A focused Rust/storage proof or equivalent local harness covers stale Memory Recall cleanup after single and bulk delete.
  • Target 9 tracker issue #2268 can mark 09-CHAT-STORAGE-delete-derived-state-cleanup as resolved for the memory-delete gap.

Actual behavior

Refactor message/bulk delete removes message rows and swipe sidecars, deletes tracker snapshots for deleted messages, syncs visible tracker state, and refreshes timeline/count caches. It does not update the chat memories array used by Memory Recall, so previously rebuilt/imported chunks can continue to mention deleted messages.

The prompt assembler reads stored chat memories through storage.listChatMemories or chat.memories, ranks them, and emits a <memories> block. That makes the stale chunk user-visible in later generation.

Steps to reproduce

  1. In refactor, create a chat with messages and rebuild/import Memory Recall chunks containing one of those messages.
  2. Delete that message, or bulk-delete a set containing it.
  3. Generate or inspect stored chat memories.

Expected: the chunk that references deleted content is gone or rebuilt from remaining messages.

Actual: the stale memory chunk remains available for recall.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor static trace at refactor@37585ab9 from #2268
  • Run mode: Tauri/refactor storage path, prompt assembly path
  • OS + version: not runtime-tested
  • Node + pnpm versions: not runtime-tested
  • Rust version, if relevant: not runtime-tested
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: Memory Recall / prompt assembly

Logs, screenshots, or video

Static parity proof only; no runtime logs.

Files inspected:

  • Legacy main:packages/server/src/services/storage/chats.storage.ts:140 defines invalidateMemoryChunksFrom.
  • Legacy main:packages/server/src/services/storage/chats.storage.ts:715 calls that invalidation after single-message delete.
  • Legacy main:packages/server/src/services/storage/chats.storage.ts:723 calls that invalidation after bulk message delete.
  • Refactor src-tauri/src/commands/storage/chats.rs:616 bulk-deletes messages/swipes and tracker snapshots, but does not prune chat memories.
  • Refactor src/features/catalog/chats/hooks/use-chats.ts:547 updates visible message cache/count around delete.
  • Refactor src/engine/generation/prompt-assembly.ts:1832 reads stored memories, and src/engine/generation/prompt-assembly.ts:1855 injects recalled memory content into <memories>.

Regression notes

This worked on legacy main: message delete and bulk delete invalidated Memory Recall chunks from the affected message timestamp onward. The refactor changed Memory Recall storage shape from a sidecar table to chat-array records, but the delete path does not mirror the invalidation behavior.

Additional context

Batch 10 parityscan found chat/gallery delete cleanup otherwise stronger in refactor: chat and group delete remove scoped gallery rows/files, message/swipe rows, tracker snapshots, scene references, and related caches. This issue is limited to stale Memory Recall chunks from deleted messages under 09-CHAT-STORAGE-delete-derived-state-cleanup.

Follow-up surfaces not chased: Target 4 broader managed-asset cleanup and Target 2 broad storage cascade proof.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2293 Originally assigned to: @Promansis on GitHub. ## Summary `09-CHAT-STORAGE-delete-derived-state-cleanup`: deleting one chat message or bulk-deleting messages on the refactor branch does not prune or rebuild Memory Recall chunks that were built from the deleted messages. Those stale chunks can still be recalled and injected into later prompts. Linked parity tracker: #2268. ## Expected behavior Deleting a message or bulk-deleting messages should keep derived chat state coherent. Legacy removes Memory Recall chunks at or after the deleted message timestamp, so deleted message content is not left in recall storage or future prompt recall. Acceptance criteria: - Single-message delete removes, prunes, or rebuilds Memory Recall chunks that reference the deleted message or later affected chat window. - Bulk message delete does the same for every affected chat/message set. - Existing delete behavior remains intact for visible timeline cache/count updates, message swipe sidecars, tracker snapshots, and visible tracker sync. - A focused Rust/storage proof or equivalent local harness covers stale Memory Recall cleanup after single and bulk delete. - Target 9 tracker issue #2268 can mark `09-CHAT-STORAGE-delete-derived-state-cleanup` as resolved for the memory-delete gap. ## Actual behavior Refactor message/bulk delete removes message rows and swipe sidecars, deletes tracker snapshots for deleted messages, syncs visible tracker state, and refreshes timeline/count caches. It does not update the chat `memories` array used by Memory Recall, so previously rebuilt/imported chunks can continue to mention deleted messages. The prompt assembler reads stored chat memories through `storage.listChatMemories` or `chat.memories`, ranks them, and emits a `<memories>` block. That makes the stale chunk user-visible in later generation. ## Steps to reproduce 1. In refactor, create a chat with messages and rebuild/import Memory Recall chunks containing one of those messages. 2. Delete that message, or bulk-delete a set containing it. 3. Generate or inspect stored chat memories. Expected: the chunk that references deleted content is gone or rebuilt from remaining messages. Actual: the stale memory chunk remains available for recall. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [x] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor static trace at `refactor@37585ab9` from #2268 - Run mode: Tauri/refactor storage path, prompt assembly path - OS + version: not runtime-tested - Node + pnpm versions: not runtime-tested - Rust version, if relevant: not runtime-tested - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: Memory Recall / prompt assembly ## Logs, screenshots, or video Static parity proof only; no runtime logs. Files inspected: - Legacy `main:packages/server/src/services/storage/chats.storage.ts:140` defines `invalidateMemoryChunksFrom`. - Legacy `main:packages/server/src/services/storage/chats.storage.ts:715` calls that invalidation after single-message delete. - Legacy `main:packages/server/src/services/storage/chats.storage.ts:723` calls that invalidation after bulk message delete. - Refactor `src-tauri/src/commands/storage/chats.rs:616` bulk-deletes messages/swipes and tracker snapshots, but does not prune chat `memories`. - Refactor `src/features/catalog/chats/hooks/use-chats.ts:547` updates visible message cache/count around delete. - Refactor `src/engine/generation/prompt-assembly.ts:1832` reads stored memories, and `src/engine/generation/prompt-assembly.ts:1855` injects recalled memory content into `<memories>`. ## Regression notes This worked on legacy `main`: message delete and bulk delete invalidated Memory Recall chunks from the affected message timestamp onward. The refactor changed Memory Recall storage shape from a sidecar table to chat-array records, but the delete path does not mirror the invalidation behavior. ## Additional context Batch 10 parityscan found chat/gallery delete cleanup otherwise stronger in refactor: chat and group delete remove scoped gallery rows/files, message/swipe rows, tracker snapshots, scene references, and related caches. This issue is limited to stale Memory Recall chunks from deleted messages under `09-CHAT-STORAGE-delete-derived-state-cleanup`. Follow-up surfaces not chased: Target 4 broader managed-asset cleanup and Target 2 broad storage cascade proof. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:27:33 +07:00
  • closed this issue
  • added the
    bug
    label
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#1128
No description provided.