Repository navigation
test(summarize): pin the cache_state: any configuration on a LIVE cache - #254
Conversation
…ache summarize ships two configurations and they differ in one key. `cache_state: pre_expiry_or_cold` (the default) fires only when the prompt cache is about to expire or already has; `cache_state: any` fires on the fill threshold alone. Every existing subtest exercises `any` against phase UNKNOWN, which is the one phase where CacheAllows has an early return — so the sentence the second configuration actually rests on, "it fires while the cache is still live", was asserted nowhere. It is true today: `p` is not read after that early return, so warm and unknown take the identical route for `any`. That is a claim about control flow, though, and the scoping of that early return has already drifted once in this file. Two tests, each a PAIR run against the same transcript and the same Ctx: - warm phase — `any` fires, the shipped default declines the same turn with `cache_state_declined_warm`. Only showing the first would still pass with the cache gate deleted; only showing the second would still pass with `any` broken into a no-op. - unknown phase over a prefix known to be live (CacheAware, MaxCachedIdx >= 0) — `any` fires, the default is declined by the guard. This is the regression the warm test cannot catch: the guard excludes `any` by name, and dropping that clause makes configuration B stop firing on exactly the raw-API deployments the opt-out exists for. min_request_frac is written in neither, so the 0.9 default is under test as the half the two configurations share, with a precondition asserting it resolved. Preconditions also assert each fixture's phase, since a warm fixture drifting into pre-expiry would make the default fire too and report an agreement the test never demonstrated. Verified by mutation: removing `t.CacheState != CacheStateAny` from the guard fails the second test only; making the `any` branch phase-dependent fails the first only. Clean under -race. Assisted-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Review (single round) — the pair shape is right; one subtest can pass for the wrong reasonTests only, so I verified by inspection rather than by running: no Go toolchain on this machine, and the claimed What checks out. The fixture really does exercise what the PR says it does, which is the part most likely to be quietly untrue:
The finding: the second test's negative row asserts no gate
Your own table in the PR body names the gate — Worth fixing before merge for a reason specific to this PR: it is the same shape as the defect closed in #234's last round, where a counter test re-performed the swap it existed to detect. A regression test whose negative half cannot fail for the thing it names reads as coverage while proving less than it claims — and here the half that is fully pinned is the one that was already true, while the half left loose is the novel guard. Two smaller notes, neither worth a change on its own:
VerdictThe regression is real, the pair discipline is the right shape for it, and the reasoning about why |
…at they declined Review finding on #254, and it is the one the PR body's own argument condemns: the unknown-phase test asserted only wantFires=false on its default row, with no gate name. That passes on ANY decline — window_not_exact, below_request_trigger, a gate nobody has written yet — while the subtest's whole stated purpose is that the LIVE-PREFIX GUARD is what declined it. A negative half that cannot fail for the thing it names reads as coverage without being any, which is the shape closed in #234's last round. It also mattered more here than the shape usually does: the fully pinned half (warm) was already true by control flow, and the loose half was the novel guard. Three changes: - the unknown-phase default row asserts `cache_state_declined_unknown`, the string Offload actually files, mirroring what the warm test already did. - the MessagesTokens precondition is extracted to assertBilledFigureOpenedTheFill and called by BOTH tests. The second was relying on sharing sumTranscript(6) with the first, and its new gate assertion is only meaningful while the shared fill conjunct is open. - each subtest gets its own session id. The async summarizer keys in-flight calls on the session in a package-global registry, so subtests sharing sumCtx's "s" were safe only while sequential; a later t.Parallel() would have had one subtest's commissioned call satisfy another's wait. Verified by a third mutation, which the previous two could not catch: renaming the gate string in Offload keeps wantFires=false true on both declining rows and fails only on the gate assertions — line 82 and line 147, one per test. Mutations 1 and 2 re-run against the final file and still each fail their own test alone. Clean under -race. Reported-by: review-pr234 (Claude Code session) Assisted-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Fixed in 65eeadc. The finding was right, and it is the shape my own PR body argued against — a negative half that cannot fail for the thing it names. That the loose half was the novel guard while the fully-pinned half was the one already true by control flow is the part that makes it worth a round rather than a follow-up. The gate is named. The unknown-phase default row now asserts The precondition is shared rather than inherited. Extracted to The parallel hazard is removed, not commented. Each subtest gets its own session id ( The third mutationWorth stating separately, because it is the one the first two could not catch — I renamed the gate string in Line 147 is the assertion that did not exist before this commit — that subtest passed this mutation as filed. Mutations 1 and 2 re-run against the final file and still each fail their own test alone (lines 137 and 77). Reviewed by inspection on your side and run on mine — noted, and the split is recorded in the commit. |
Why
summarizeships two configurations, and they differ in exactly one key:min_request_fracdefaults to0.9in both, so the cache condition is the only thing an operator writes.B is documented (
docs/components/summarize.md:226), both example configs underexamples/llm-d-service/run it, and #234's own docstring calls it out as the opt-out. What was not asserted anywhere is the sentence B actually rests on: it fires while the prompt cache is still live. Every existing subtest exercisesanyagainst phase Unknown — the one phase whereCacheAllowshas an early return.It is true today.
pis not read after that early return, so warm and unknown take the identical route forany. But that is a claim about control flow, and the scoping of that early return has already drifted once in this file — the review on #234 found the gate opening over a live 8-message prefix on 13 of 26 turns.What landed
Two tests, each a pair run against the same transcript and the same
Ctx, because a single-sided assertion here is worthless:cache_state: anycache_state_declined_warmCacheAware,MaxCachedIdx >= 0)cache_state_declined_unknownA test showing only that
anyfires would still pass with the cache gate deleted outright; one showing only that the default declines would still pass withanybroken into a no-op. The pair is what pins the difference to the one key.The second row is the regression the first cannot catch. That guard excludes
anyby name, because a raw-API harness with nothing capping its context is precisely the deployment that can present a cached prefix and no readable TTL — drop the clause and configuration B silently stops firing on the deployments the opt-out exists for.min_request_fracis written in neither config, so the0.9default is under test as the half the two share, with a precondition asserting it resolved. Preconditions also assert each fixture's own phase: a warm fixture drifting into pre-expiry would make the default fire too, and the test would report an agreement it never demonstrated.Verification
Both tests were mutated to failure, each hitting only its own target:
t.CacheState != CacheStateAnyfrom the unknown-phase guard →TestCacheStateAnyStillFires…/any_fires_despite_the_live-prefix_guardfails (fired=false want true (gates: map[cache_state_declined_unknown:1])); the warm test still passes.anybranch phase-dependent (return p != CachePhaseWarm) →TestCacheStateAnyFiresOnALiveCache…/cache_state:_any_fires_on_a_live_cachefails (fired=false want true (gates: map[cache_state_declined_warm:1])); the unknown test still passes.gofmtandgo vetclean;CGO_ENABLED=1 go test -race ./components/...all green.Tests only — no behaviour change.
Context
Raised while confirming which configuration to run now that
summarizesends a single flattened prompt throughModel.Complete(ctx, string)and therefore shares no prefix with the agent's cachedtools → system → messages. Until a cache-reusing summarizer lands, B is the configuration worth measuring against A, and it needed to be pinned rather than merely documented.🤖 Generated with Claude Code