Skip to content

[dotnet-code] Consolidate truncation removable count#396

Merged
gdams merged 2 commits into
mainfrom
dotnet-code/truncation-removable-count-2305220f28c523ce
Jun 30, 2026
Merged

[dotnet-code] Consolidate truncation removable count#396
gdams merged 2 commits into
mainfrom
dotnet-code/truncation-removable-count-2305220f28c523ce

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

Reuse the message index helper for counting included non-system groups before truncation and add a preservation test for skipped system and pre-excluded groups.

Reuse the message index helper for counting included non-system groups before truncation and add a preservation test for skipped system and pre-excluded groups.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 22:08
@michelle-clayton-work
michelle-clayton-work requested a review from a team as a code owner June 29, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns Go truncation compaction internals with the existing “included non-system groups” concept (matching the .NET reference noted in #379) by reusing the shared message-index helper for removable-group counting, and adds a regression test to ensure truncation preserves system groups and respects pre-excluded groups.

Changes:

  • Replaced truncation’s inline removable-group counting loop with MessageIndex.IncludedNonSystemGroupCount().
  • Added TestTruncationStrategy_SkipsPreExcludedAndSystemGroups to validate behavior around system groups, pre-excluded groups, and the minimum-preserved floor.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
agent/compaction/truncation.go Reuses the shared index helper to compute removable non-system group count, reducing duplicated logic.
agent/compaction/compaction_test.go Adds a focused test ensuring truncation skips system and pre-excluded groups while still excluding the oldest eligible group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown
Contributor

Cross-Repo API Consistency Review

Result: ✅ No parity issues — internal refactor only.

Both changed files are out of scope for public-contract parity review:

  • agent/compaction/truncation.go: Replaces a 5-line inline loop with a call to the existing index.IncludedNonSystemGroupCount() helper. The TruncationStrategy exported struct, its fields, and its Compact method signature are all unchanged. Observable behavior is identical.
  • agent/compaction/compaction_test.go: Adds a test for the pre-excluded and system-group skip edge case. No API changes.

Upstream alignment note: The .NET CompactionMessageIndex already exposes the equivalent property (public int IncludedNonSystemGroupCount), so the underlying helper concept is shared. The .NET TruncationCompactionStrategy still uses the inline loop rather than calling that property, but that is an internal implementation detail — not a public-contract divergence.

No inline comments needed.

Generated by Go API Consistency Review Agent for #396 · 173.6 AIC · ⌖ 12.5 AIC · ⊞ 28.8K ·

@gdams
gdams added this pull request to the merge queue Jun 30, 2026
@gdams gdams linked an issue Jun 30, 2026 that may be closed by this pull request
Merged via the queue into main with commit 9125350 Jun 30, 2026
19 checks passed
@gdams
gdams deleted the dotnet-code/truncation-removable-count-2305220f28c523ce branch June 30, 2026 07:33
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.

[dotnet-code] Consolidate truncation removable count

3 participants