Skip to content

fix(storage): delete a session's recall chunks with the session - #485

Merged
mrnasil merged 3 commits into
mainfrom
fix/storage-session-chunks-delete
Nov 25, 2026
Merged

mrnasil merged 3 commits into
mainfrom
fix/storage-session-chunks-delete

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Problem

Database::delete_session removed the session's messages, branches and the session row. It left session_chunks in place: the embedded turns that session recall (session_inject) adds to later prompts. Nothing else ever deleted from that table, so a deleted session kept being recalled into new prompts, together with any secret pasted into it.

Fix

delete_session also runs DELETE FROM session_chunks WHERE session_id = ?1. The existing session_chunks_fts_ad trigger keeps the FTS index in sync.

Tests

  • test_delete_session adds chunks for two sessions and deletes one. An FTS search afterwards finds only the other session's chunk.
  • The broken-schema test covers the error path when session_chunks is missing (storage has a 100% line floor).
  • storage lib tests, clippy and fmt pass.

This does not prune chunks of sessions that still exist. Unbounded growth is a separate question.

🤖 Generated with Claude Code

`delete_session` removed the messages, branches and the session row
but not its `session_chunks`, the embedded turns that session recall
injects into later prompts. A deleted session, and any secret pasted
into it, kept coming back as recalled context. The chunks (and their
FTS rows, through the delete trigger) now go with the session.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil enabled auto-merge (squash) November 25, 2026 13:28
@mrnasil
mrnasil merged commit 6fbd07a into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/storage-session-chunks-delete branch November 25, 2026 20:23
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant