Skip to content

perf(cognition): volatile grounding rides trailing turns — the KV run-rate fix - #2415

Merged
joelteply merged 1 commit into
canaryfrom
fix/volatile-grounding-rides-trailing
Aug 23, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/volatile-grounding-rides-trailing

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The wall-clock lever. Diagnosed from her own captures (turn-over-turn contribution diff on the live MirrorCode round): workspace-map content churns act-over-act (her own writes) while sitting in the system message's stable tier; kanban/active-work were volatile-flagged but the volatile tier still renders inside the system message, ahead of every conversation token. Divergence at ~8k chars of a 40k prompt → live KV reuse pinned at 18–33%, ~2min/act, 96% of compute in prefill.

Fix at the constraint using #205's existing trailing-turn mechanism: volatile-content grounding bids are .trailing() (renders after the conversation; churn costs its own tokens), workspace-map is flagged volatile, and the trailing render keeps its [faculty] banner. Expected: prefix reuse = byte-stable system + full conversation; target ≥70% cached on intra-task acts. A/B verdict rides the next round's inference.prefill.complete probes.

Pinned by a routing-contract test; 93+11 batteries green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…-rate fix, measured from her own captures

The single biggest wall-clock lever in the tree, diagnosed with the
glass box, fixed at the constraint (Joel: 'code it elegantly and
efficiently from the start… you're coding webdev horseshit for
performant rtos work' — this is the RTOS fix).

MEASURED (capture round 907390a0, turn-over-turn diff of her real
contribution stream): workspace-map content changed act-over-act (her
own writes mutate it) while sitting in the STABLE tier of the system
message; kanban/active-work were volatile-flagged but the volatile tier
still rendered INSIDE the system message — before every conversation
token. Divergence at ~8k chars of a 40k+ prompt = live KV reuse pinned
at 18-33%, ~35-45k re-prefilled per act, ~2min/act, 96% of compute
prefill. The #266 sort fixed ORDER churn in the stable tier; CONTENT
churn was the remaining killer.

FIX, at the constraint, using the mechanism #205 already built and
documented as KV-correct:
1. rag_source_faculty: volatile-content grounding bids are .trailing()
   — they render as conversation turns nearest generation (the existing
   render loop), so churn costs exactly its own tokens. The volatile
   tier of the system context block was a half-measure.
2. workspace-map flagged .volatile_content() — its churn is every
   productive act by construction.
3. The trailing render keeps the [faculty] banner (one sized
   allocation, no format!) so relocated grounding stays as legible as
   the system block it left.

Expected shape after: prefix reuse = system (now byte-stable) + full
conversation; per-act re-prefill = trailing grounding + working-memory
tail only. Target ≥70% cached on intra-task acts vs the measured
18-33%; A/B rides the next round's prefill probes.

Pinned by volatile_content_grounding_is_trailing_and_stable_grounding_
is_not. Batteries: 93 (deliberation/prompt/workspace/supervisor) + 11
(rag_source_faculty + ratchets) green.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply enabled auto-merge (squash) August 23, 2026 20:11
@joelteply
joelteply merged commit 71c3b6d into canary Aug 23, 2026
5 checks passed
@joelteply
joelteply deleted the fix/volatile-grounding-rides-trailing branch August 23, 2026 20:23
joelteply added a commit that referenced this pull request Aug 23, 2026
…g — the tail order the A/B demanded (#2416)

The #2415 A/B failed: 20-22% cached on 34-42k prefills, the old ceiling
wearing a new hat. Monitor data named why — in eval turns the
conversation barely grows; the prompt's bulk is the working-memory
result history, and the first cut placed the churning trailing
grounding (workspace-map/kanban) AHEAD of it, re-prefilling the whole
append-only history on every grounding change.

Order in the tail IS the fix: recent-results history (byte-stable,
growing head) → churning trailing grounding → pinned newest result.
The history block extends the reusable KV prefix act-over-act; churn
now costs only itself + the pinned tail. (recent_results pop_front
eviction rotates the head only once the window-derived cap fills —
append-only for most of a task on a big lane.)

Batteries: 94 green (deliberation, working_memory, rag_source_faculty,
ratchets).


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Fable 5 <[email protected]>
joelteply added a commit that referenced this pull request Aug 23, 2026
…ff verdict (#2418)

Consecutive-act prompt captures (always-on JsonlPromptCaptureSink) gave
the byte-level verdict on why KV reuse plateaued at ~36% after #2415+
#2416: the system prompt is perfectly byte-stable (8,305 chars = the
cached head), and the divergence is at MESSAGE #1 CHAR 0 — perception
facts whose presence/wording flickers per act rendered ahead of the
21.8k append-only history block, so the prompt's dominant stable mass
never extended the prefix. The message list's SHAPE changed act-over-
act (8 parts vs 4).

Fix: explicit assembly phases replacing insert-before-ask arithmetic —
old turns → history (append-only) → trailing grounding (flickers) →
facts (flicker) → ASK → pinned newest. Stable content is a strict
prefix of the token stream; churn is behind it. Every prior lesson
preserved by construction: facts stay before the ask and the ask after
them (2026-07-20 parrot-loop bisect), pinned stays nearest generation
(#392), grounding stays out of the system prefix (#205/#2415).

Batteries: 130 green (deliberation, perception_facts, act_observe,
working_memory, ratchets) — including the parrot-order pins.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant