Skip to content

fix compaction kept-tail mapping after prior summaries#2646

Open
rumpl wants to merge 1 commit intodocker:mainfrom
rumpl:fix-compaction-kept-entry
Open

fix compaction kept-tail mapping after prior summaries#2646
rumpl wants to merge 1 commit intodocker:mainfrom
rumpl:fix-compaction-kept-entry

Conversation

@rumpl
Copy link
Copy Markdown
Member

@rumpl rumpl commented May 5, 2026

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.

@rumpl rumpl requested a review from a team as a code owner May 5, 2026 21:59
Copy link
Copy Markdown

@docker-agent docker-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .

Comment thread pkg/runtime/compactor/compactor.go Outdated
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>
@rumpl rumpl force-pushed the fix-compaction-kept-entry branch from e9d6efc to 56b7b6e Compare May 5, 2026 22:19
@rumpl
Copy link
Copy Markdown
Member Author

rumpl commented May 5, 2026

/review

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.

2 participants