Repository navigation
fix(kv-unified): drop the latent-demand ranking cache; #119 follow-ups - #121
Merged
antra-tess merged 3 commits intoSep 26, 2026
Conversation
The cross-compile ranking cache from db8fb06 was keyed on the summary roots and budget only, but the what-if scores also depend on the chunks, policy, presentation and solver options. On a 60-turn replay it only hit when the summarizer stalled, and then replayed "no merges" on 4 of 6 turns where a fresh ranking demanded L2 merges. It was also shared by the production-budget shadow pick (never hit there) and not cleared on branch switches. With fewer than mergeThreshold same-level roots in a row the ranking has no candidates and costs nothing, so it is recomputed on every compile. The what-if certificate stays. - Flip the test that asserted reuse after an append: appended messages and policy changes on the same roots now reach the ranking. - Host guard: the live adapter passes no ranking state between compiles. - selectAdaptive test: tail markers resolve to per-message tail units, including a sharded last message, not the opaque 'tail' fallback. - mergeAdjacentBodyGroupRaw reuses the caller's message listing instead of a second store.getAll(). - Certificate doc: foldable new leaves are enumerated (up to 256 extensions) and certified results list every extension as candidates. - Changelog: the unreleased compile-overhead note no longer claims the cache. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UN6d9TeXZDWNMxQ3dT5uR8
…log fragment Review (TASK-SEGR8, GPT-6 Sol high): - The tail-marker test passed even if mergeAdjacentBodyGroupRaw stopped merging shards. It now checks that the sharded message is one emitted entry listing every shard and carrying the marker. - The changelog gate needs an added fragment when src/ changes; add one for the latent-demand change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UN6d9TeXZDWNMxQ3dT5uR8
Review round 2 (TASK-9G50H, Opus xhigh): - Certificate doc: candidates are the enumerated extensions that fit the hard token wall. - Changelog fragment states the net behaviour, with no reference to the unreleased cache. - Host guard no longer pins the latentDemand key set; it rejects a `cache` key or any object value, with a message naming the regression. - The test override of mergeAdjacentBodyGroupRaw forwards the caller's listing; the doc comment says overrides should. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UN6d9TeXZDWNMxQ3dT5uR8
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.
Follow-up to #119, from the review and benchmark in its thread and @Anarchid's post-merge review.
What changes
Latent-demand ranking cache removed. The cache from
db8fb06was keyed on the summary roots and budget only. But the what-if scores also depend on the chunks, policy, presentation and solver options. Three problems:The ranking is now computed on every compile. It has no candidates, and costs nothing, while fewer than
mergeThresholdsame-level summaries line up. The what-if certificate stays: we checked it gives the same answers as full solves.Kept from
db8fb06: the shard-metadata index.mergeAdjacentBodyGroupRawnow reuses the message listingselectAdaptivealready holds (a third, optional argument, defaulting tostore.getAll()), instead of listing a filtered view a second time. Overrides should forward it; the doc comment says so, and the in-repo test override does.Certificate doc. It now says new foldable leaves are enumerated (up to 256 extensions), and certified results list every extension that fits the hard token wall as
candidates.Changelog. The unreleased compile-overhead note no longer claims the cache (no tag contains
db8fb06). A new fragment states the net behaviour: latent demand keeps no ranking state between compiles.Tests
Each new test was checked by breaking the code it guards; it fails every time.
cachekey or any object value inlatentDemand, so new stateless knobs don't trip it.selectAdaptive(@Anarchid's point 2): a real compile with a sharded last message. Every tail message and shard is its own layout unit, with no'tail'fallback. The shards are one emitted entry carrying the marker, and the marker lands on the last shard's unit.npm test: 864/864.Review rounds
Round 1: GPT-6 Sol, high. Changes needed.
src/changes; we had only edited one. Fixed: new fragment, and the gate condition passes locally.selectAdaptivepasses the same listing as before, and that the doc matcheskv-unified-certificate.ts.Round 2: Claude Opus, xhigh. Approve.
no-changeloglabel wasn't an option for us).cachekey or stored state, with a clear message.mergeAdjacentBodyGroupRawdropped the new listing argument. Fixed: it forwards it, and the doc comment says overrides should._lastKvUnified(only_lastKvStable). This was there before this PR, and nothing insrc/reads that field.Not covered
🤖 Generated with Claude Code
https://claude.ai/code/session_01UN6d9TeXZDWNMxQ3dT5uR8