fix compaction kept-tail mapping after prior summaries#2646
Open
rumpl wants to merge 1 commit intodocker:mainfrom
Open
fix compaction kept-tail mapping after prior summaries#2646rumpl wants to merge 1 commit intodocker:mainfrom
rumpl wants to merge 1 commit intodocker:mainfrom
Conversation
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
One likely bug was found in the changed code.
| Severity | Count |
|---|---|
| 🟡 Medium (LIKELY) | 1 |
Summary: The PR correctly fixes the core compaction index-mapping bug (raw session indexes instead of filtered message indexes). One issue was identified in the new function: the guard cannot distinguish between "FirstKeptEntry unset" and "FirstKeptEntry legitimately equals 0" (compaction kept everything from the start). The same pattern exists in the unchanged in .
Rebuild the compactor input with provenance back to raw session item indexes instead of mapping filtered GetMessages indexes directly onto sess.Messages. Previous compactions inject a synthetic session summary message, so repeated compaction could compute a FirstKeptEntry that pointed at already-summarized history and resurrect old messages. Honor the documented FirstKeptEntry sentinel by using -1 for no kept tail and treating 0 as a valid raw session index. Apply the same reconstruction rule in the session and compactor paths, update SQLite defaults, and preserve FirstKeptEntry when branching sessions. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
e9d6efc to
56b7b6e
Compare
Member
Author
|
/review |
derekmisler
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebuild the compactor input with provenance back to raw session item indexes instead of mapping filtered GetMessages indexes directly onto sess.Messages. Previous compactions inject a synthetic session summary message, so repeated compaction could compute a FirstKeptEntry that pointed at already-summarized history and resurrect old messages.
Expose a safe Session.SnapshotItems helper for the compactor and add a regression test covering compaction after a prior summary.