Archived
A staged pass copies whole layers into the pool at block-id identity: block b of layer l goes to base + b * block_bytes. The ring addresses its slots at base + l * slots * block_bytes + s * block_bytes, so the stage row of a later layer is the ring row of an earlier one. The copy never touches `res` or `slot_block`, so every block the map still calls resident names bytes that some later layer has since overwritten. Block ids are recycled between requests, so this is not theoretical. The second request's prefill writes its mirror and -- gated on `res`, which is still valid from the first request -- its ring slots; the rest of the layers' stage rows then overwrite those slots. The first decode trusts `res`, skips the resolve, and reads another layer's, or another request's, KV. Fluent, no fault. Measured with --kv-resident 32768 on 2x16 GB gfx1201, exact compose flags: ring off: an arithmetic probe answers 15:55 on every round; ring on (before): 15:55, then 16:40 for rounds 2-4, on spec 0 and spec 3; ring on (after): 15:55 on every round. The same sequence previously answered a 3k system passphrase as Q97/Q&A and an unrelated weather question with the previous request's filler text. Clear `res`, `slot_block` and `slot_state` when the binding leaves the stage view for the ring, for streams whose ring is smaller than their id space. The first ring pass then resolves every live block out of the mirror -- the cold-map path the first request already takes -- and the ring is self-consistent for the decode steps that follow. One memset per prefill, not per step. A stream whose ring covers its id space is left alone: there the staged bytes and the ring's bytes are the same bytes at the same offsets. Tests: kv_window_test 8/8, p4b_kv_ring_test 3/4 (one skipped: no in-tree test kernels in this build), sched_test 142 cases green. arch_test has 15 pre-existing graph-pin failures on this tree, identical with and without this change. The 47-case streaming battery is clean on both ring arms (spec 0 and 3).