feat(memory)!: TemplateCompactor caps are literal, with an explicit opt-out - #2370
Open
gamboacarlos wants to merge 1 commit into
Open
feat(memory)!: TemplateCompactor caps are literal, with an explicit opt-out#2370gamboacarlos wants to merge 1 commit into
TemplateCompactor caps are literal, with an explicit opt-out#2370gamboacarlos wants to merge 1 commit into
Conversation
gamboacarlos
marked this pull request as ready for review
August 17, 2026 17:29
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.
Fix #2181
Problem
TemplateCompactor::with_max_bytes(0)previously meant “unbounded”. This made0a special value with semantics that differed from the rest of the API.In particular, the cap was non-monotonic:
0→ unbounded1→ header plus marker2→ slightly more outputThis is especially error-prone when the value is computed rather than explicitly typed. For example:
or a configuration field left at its default value could unexpectedly produce
0, turning a bounded compactor into an unbounded one.This is particularly dangerous when used through
CompactingMemory. The compactor sits outside the wrappedMemoryPolicy's budget, so an accidentally unbounded compactor can cause the rollup to grow without limit: each pass embeds the previous summary verbatim.Changes
with_max_bytes(n)now treatsnliterally. A value of0is a zero-byte cap rather than an unbounded setting.without_max_cap()explicitly opts out of the byte limit and restores unbounded rollup behavior.0as a special value.CHANGELOG.mdhave been updated to describe the literal-0behavior and the new unbounded escape hatch.Breaking behavior
This is a behavioral breaking change for callers that currently pass
0as an “unbounded” switch.The API signature remains unchanged, so existing code will still compile, but callers relying on
with_max_bytes(0)being unbounded will now receive a zero-byte cap.Migrate those callers to:
Verification
All checks pass:
cargo clippy --all-features --all-targetscargo fmt -- --checkcargo test -p rigcargo test -p rig --all-featurescargo test -p rig --test corecargo test -p rig-memory