[PR #2385] [MERGED] Prune chat memories after message delete #5572

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2385
Author: @Promansis
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/issue-2293-memory-delete-cleanup


📝 Commits (8)

  • bb08c6a Prune chat memories after message delete
  • 54b96df Fix atomic message memory pruning
  • 59b5137 Merge branch 'refactor' into fix/issue-2293-memory-delete-cleanup
  • 33a3c2c Fix atomic chat memory pruning for message edits
  • 33c7b59 Merge refactor into memory cleanup branch
  • 808118b Refresh PR review base
  • 0d8bf60 Keep conditional message edits atomic
  • b048f14 Preserve fresh state during conditional message edits

📊 Changes

4 files changed (+2143 additions, -372 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+1417 -227)
📝 src-tauri/src/commands/storage/commands/entities.rs (+509 -48)
📝 src-tauri/src/commands/storage/game_state_snapshots.rs (+59 -30)
📝 src-tauri/src/commands/storage/message_swipes.rs (+158 -67)

📄 Description

Linked issue

Closes #2293

Why this change

  • Message deletion removed message rows, swipe sidecars, tracker snapshots, visible tracker state, and timeline/count cache inputs, but left Memory Recall chunks stored on the chat. Those stale chunks could still be recalled into future prompts after their source message was deleted.

What changed

  • Added chat memory pruning for deleted message rows, matching the legacy behavior of invalidating chunks at or after the deleted message timestamp.
  • Wired the cleanup into both single-message entity delete and chat bulk message delete.
  • Added focused Rust coverage for single-message delete and bulk delete so overlapping Memory Recall chunks are removed while older unaffected chunks remain.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Chat message delete
  • Chat bulk message delete
  • Memory Recall chunk storage on chats.memories
  • Existing tracker snapshot cleanup and visible tracker sync

Boundary notes:

  • Change stays inside src-tauri storage commands.
  • No React, engine, shared API, or remote-runtime contract changes.

Pressure points touched:

  • src-tauri/src/commands/storage/chats.rs
  • src-tauri/src/commands/storage/commands/entities.rs

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo fmt --manifest-path src-tauri/Cargo.toml
  • cargo test --manifest-path src-tauri/Cargo.toml deleting_message_prunes_overlapping_chat_memories
  • cargo test --manifest-path src-tauri/Cargo.toml bulk_delete_messages_prunes_overlapping_chat_memories
  • cargo check --manifest-path src-tauri/Cargo.toml
  • git diff --check
  • pnpm check

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Storage consistency bugfix only; no new user-discoverable workflow.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

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/2385 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/issue-2293-memory-delete-cleanup` --- ### 📝 Commits (8) - [`bb08c6a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bb08c6ab27a56f6c8b08d764e23ce746634c131c) Prune chat memories after message delete - [`54b96df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/54b96dfd05992d2ea169081df13999e3363b5c6a) Fix atomic message memory pruning - [`59b5137`](https://github.com/Pasta-Devs/Marinara-Engine/commit/59b513787cfba349c205ac2e0844ec68baed469c) Merge branch 'refactor' into fix/issue-2293-memory-delete-cleanup - [`33a3c2c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/33a3c2c08bdfa9480a28274a9bd1415fa5866e9a) Fix atomic chat memory pruning for message edits - [`33c7b59`](https://github.com/Pasta-Devs/Marinara-Engine/commit/33c7b593c99dee824b0c794849a5fc2cfc6a2771) Merge refactor into memory cleanup branch - [`808118b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/808118b488538042fb2d44266a6387d8e8c8eed6) Refresh PR review base - [`0d8bf60`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0d8bf6073b1e4bf017974760852f7167d0bb687c) Keep conditional message edits atomic - [`b048f14`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b048f14079f67219f77765efebf8e1fd661cfd3a) Preserve fresh state during conditional message edits ### 📊 Changes **4 files changed** (+2143 additions, -372 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+1417 -227) 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+509 -48) 📝 `src-tauri/src/commands/storage/game_state_snapshots.rs` (+59 -30) 📝 `src-tauri/src/commands/storage/message_swipes.rs` (+158 -67) </details> ### 📄 Description ## Linked issue Closes #2293 ## Why this change - Message deletion removed message rows, swipe sidecars, tracker snapshots, visible tracker state, and timeline/count cache inputs, but left Memory Recall chunks stored on the chat. Those stale chunks could still be recalled into future prompts after their source message was deleted. ## What changed - Added chat memory pruning for deleted message rows, matching the legacy behavior of invalidating chunks at or after the deleted message timestamp. - Wired the cleanup into both single-message entity delete and chat bulk message delete. - Added focused Rust coverage for single-message delete and bulk delete so overlapping Memory Recall chunks are removed while older unaffected chunks remain. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Chat message delete - Chat bulk message delete - Memory Recall chunk storage on `chats.memories` - Existing tracker snapshot cleanup and visible tracker sync Boundary notes: - Change stays inside `src-tauri` storage commands. - No React, engine, shared API, or remote-runtime contract changes. Pressure points touched: - `src-tauri/src/commands/storage/chats.rs` - `src-tauri/src/commands/storage/commands/entities.rs` ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo fmt --manifest-path src-tauri/Cargo.toml` - `cargo test --manifest-path src-tauri/Cargo.toml deleting_message_prunes_overlapping_chat_memories` - `cargo test --manifest-path src-tauri/Cargo.toml bulk_delete_messages_prunes_overlapping_chat_memories` - `cargo check --manifest-path src-tauri/Cargo.toml` - `git diff --check` - `pnpm check` ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Storage consistency bugfix only; no new user-discoverable workflow. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence 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-22 04:17: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#5572
No description provided.