Skip to content

server: auto-discard reload-loop checkpoints (frontier-contradicted) - #1021

Open
nazerim wants to merge 1 commit into
antirez:mainfrom
nazerim:feat/kvstore-reload-loop-guard
Open

server: auto-discard reload-loop checkpoints (frontier-contradicted)#1021
nazerim wants to merge 1 commit into
antirez:mainfrom
nazerim:feat/kvstore-reload-loop-guard

Conversation

@nazerim

@nazerim nazerim commented Sep 10, 2026

Copy link
Copy Markdown

Problem. The text-keyed disk tier validates text, not tokens. When a checkpoint's stored tail diverges from how future prompts re-tokenize the same bytes (BPE boundary variants across sampled thinking/DSML regions - the familiar two-variant equilibrium), the file restores fine, misses again next turn, and re-restores forever: pinned reason=token-mismatch at the same common= on every following turn, growing re-prefill each time. Production evidence from my fork running this same tier: clusters at common=118557 (43 turns), 273833 (18), 451784, 325177 - the only cure observed was a manual turn-abort, which routes through the existing prefill-failed discard and lets the fallback chain land on a lower valid file.

Fix. Same recovery, automated and provable: each slot remembers its last disk-restored (file, frontier). A second consecutive restore of the same file at the same depth means the session cannot have advanced between restores - the tail is dead weight by construction. Unlink it under kv_mu (exactly the prefill-failed discard semantics already in this file), log reason=frontier-contradicted, and retry the load once: the refresh pass walks to the next candidate or a cold rebuild, which rewrites fresh under the key. Any successful memory-tier continuation clears the tracker, so legitimate re-restores of the same correct file after real progress are never punished; disagreement falls back to today's behavior verbatim.

Blast radius: ~40 lines, one helper beside kv_cache_discard_failed_disk_entry, one two-attempt loop at the existing call site, one clear on memory-tier success. No format, no key, no session-state changes; worst case is one wasted reload per poisoned file instead of an unbounded loop.

Validation: optimized build clean (0 errors/0 warnings, M5 Max); ds4-server unit suite green on this head; the mechanism it automates (unlink + invalidate + fallback walk + fresh re-store) is the same one two production manual-abort recoveries exercised end-to-end, and the fork build with the automated detection self-healed two live loops on its first day (discarded at frontier 322155 -> adopted 321371 same second; 338690 -> 331026 same second).

A disk checkpoint whose stored tail contradicts fresh prompt
tokenizations restores cleanly yet re-misses every following turn:
the text-keyed tier loads the exact same file to the exact same
frontier because its text key matches, while the memory tiers can
never carry the session past that depth. Observed repeatedly in
production on a fork carrying this same text tier (pinned miss
clusters at common=118557 x43, 273833 x18, 451784, and 325177 - the
last healing only when a manual turn-abort triggered the
prefill-failed discard and the fallback chain walked to a lower
valid file).

Automate exactly that recovery: track the last disk-restored file
and frontier per slot; a second consecutive restore of the same file
at the same depth proves the tail is dead weight, so unlink it under
kv_mu (same semantics as the prefill-failed discard beside it) and
retry the load once, landing on the next candidate or a cold rebuild
that rewrites fresh under the key. Any successful memory-tier
continuation clears the tracker, so a legitimate later restore of
the same correct file after real progress is never punished. The
detection is provable-by-construction (same file + same frontier +
same slot = the state cannot have advanced between restores) and the
worst case is one wasted reload per poisoned file instead of an
unbounded loop.
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.

1 participant