refactor(compact): derive the cache boundary from the shared tracker - #56
Merged
Conversation
/compact fell through to apply's legacy store-backed prevLen, which the chat path had already moved off. So this endpoint kept two properties the chat path had shed: concurrent turns of one session race on a read-then-deferred-write, and the boundary lives in a store key (cg:len:) competing for the pin budget rather than in memory. The motivation is measurement, not a live cache regression -- the chat path was already on the tracker. /compact is the offline replay/eval endpoint, so a boundary derived differently from production means eval measures a different component than the one that ships. Same class of divergence as the window this handler used to hard-code as unknown a few lines above, and unnoticed for the same reason: both are silent. Deliberately NOT claiming to fix the pin-budget fail-open in #47. I could not construct a churn pattern that actually evicts cg:len: -- it survived 40 frozen decisions from distinct sessions plus 40 ordinary puts at MaxEntries 20 -- and I am not going to assert a fix for a failure I cannot reproduce. #47 stays open for the eviction question; this change removes the /compact path's exposure to it by keeping the boundary out of the store entirely, which is a consequence rather than the point. No test: the two paths are behaviourally identical on the boundary they derive, so a test asserting turn-to-turn behaviour passes either way -- I wrote one, watched it pass with the tracker removed, and deleted it rather than keep a test that proves nothing. Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com>
This was referenced Aug 10, 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.
Partially addresses #47. Read the scope note below — this does not claim to fix the pin-budget fail-open.
What this changes
/compactfell through toapply's legacy store-backedprevLen, which the chat path had already moved off (#43). So this endpoint kept two properties the chat path had shed:cg:len:) competing for the pin budget, rather than in memory.Switched to
apply.BodyOptswith the proxy's existingmodes.Tracker— the same one the chat path uses.Why it matters: measurement, not a live cache regression
The chat path was already on the tracker, so production was fine.
/compactis the offline replay/eval endpoint, so a boundary derived differently from production means eval measures a different component than the one that ships.That is the same class of divergence as the context window this handler used to hard-code as unknown — visible a few lines above in the same function — and it went unnoticed for the same reason: both are silent. This repo has now hit that class three times (the hard-coded window,
internal/modelinfonever resolving a window at all, and this), which is why it's worth naming rather than just patching.Scope note — what I am NOT claiming
#47's pin-budget fail-open is not fixed and stays open. I tried to reproduce it and could not:
cg:len:survived 40 frozen decisions from distinct sessions plus 40 ordinary puts atMaxEntries: 20(pin cap 10). The boundary came back intact on both the legacy and tracker paths.I am not going to assert a fix for a failure I cannot demonstrate. This change removes
/compact's exposure to that failure by keeping the boundary out of the store entirely — but that is a consequence, not the point, and the eviction question itself is unresolved.No test, deliberately
The two paths are behaviourally identical on the boundary they derive, so a test asserting turn-to-turn behaviour passes either way. I wrote one, watched it pass with the tracker removed, and deleted it rather than keep a test that proves nothing and would give a future reader false confidence.
What would be worth testing is the eviction scenario itself — but that belongs in #47, once someone can actually trigger it.
Gates
go build -tags cg_skeleton ./...·go test -tags cg_skeleton ./...·go test -race ./proxy/... ./apply/...·gofmt -l— all clean.