Skip to content

KV cache as a shared base layer — stop paying for repetition between persona (#266) - #2345

Merged
joelteply merged 15 commits into
canaryfrom
feat/kv-shared-base-layer
Aug 21, 2026
Merged

joelteply merged 15 commits into
canaryfrom
feat/kv-shared-base-layer

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Two commits: a serving fix that is already live-validated, and the architecture doc for the prefill economy it exposed.

fix(serving) — --flash-attn needs an explicit value. Upstream llama.cpp changed it from a bare boolean to -fa, --flash-attn [on|off|auto], so our bare flag ate --mmproj as its value and the lane refused to spawn — serving sat at 0 lanes. Found the first time anyone ever set SERVING_FLASH_ATTN=1: the flag shipped, was never exercised because it was opt-in and nobody opted in, and rotted against upstream in the meantime.

An opt-in that has never once been switched on is untested code with a config-shaped trigger.

docs(architecture) — KV-CACHE-AS-SHARED-BASE-LAYER.md, the design for keeping prefill instead of discarding it.

Why now

Prefill is 96.3% of persona compute and the cache serves 5.5% of it (#266). Two of four citizens sit at 0.0%.

The standing constraint: "We won't pay the price for repetition between persona." Today we pay it N times over — N citizens × 7,013 tokens of byte-identical tool schemas, prefilled independently, every cold turn. That scales linearly with population, so it is not constant overhead to absorb; it is a tax on having more citizens, and it gets worse exactly as the grid gets more interesting.

Two stacked defects — both verified by reading, neither yet proven causal

  1. No persona→slot affinity exists anywhere in inference/. llama.cpp keeps KV per slot and --cache-reuse reuses a prefix within a slot, so reuse requires the same persona landing on the same slot. Nothing arranges that.
  2. Identity is first. deliberation_prompt.rs:48,128 puts identity at the head of the cacheable prefix — byte-stable per persona across turns (what Rust Module Consolidation Phase 2: Optimization & Compute Migration #266 wanted, and it delivers) but byte-unique across personas, so the shared tool block behind it can never be shared.

Fix 1 alone → each citizen reuses her own prefix. Fix both → the population shares one prefill.

The design

A Docker base image, not a compression scheme. Prefill the universal span once, llama_state_seq_save_file it, load it into each slot. The primitives already exist in our fork (include/llama.h:898,905).

The second-order win is bigger than the first: base.kv is file-backed, so citizens come back warm across reboots instead of every restart re-prefilling everyone cold. Two citizens have cited "the ongoing rebuilds and interruptions" verbatim in withdrawal messages (#390) — this is part of that cost.

The durable part: what compression can and cannot do

Block-level KV dedup cannot work. K/V at layer L is a function of the hidden state, which carries the entire causal history; only layer-0 K/V is pure in (token, position). A chunk's KV is genuinely not a function of that chunk. This is why the industry does prefix caching and not block caching — it is the intuitive move and it stays wrong.

The NVIDIA cross-model paper (arxiv 2608.03893) contributes "strip RoPE, fit position-free, re-apply" — but that removes position dependence, not causal dependence, so it does not make a block relocatable. It also excludes hybrid/MLA attention, which excludes K3. It becomes ours when shared KV geometry stops being discovered post-hoc and becomes a forge constraint in the recipe (#180/#268).

Epistemic shape

Written as design-with-hypotheses, not settled architecture. A table at the top separates MEASURED / VERIFIED-BY-READING / HYPOTHESIS, and every hypothesis names the measurement that would kill it. Three of my own diagnoses were retracted the day this was written; a doc that read as settled would have been the wrong artifact.

Step 1 is the hit-rate probe. prompt_tokens vs cached_tokens come back on every llama-server response and we discard them. Zero KV-cache probe classes exist tree-wide — which is why every claim here had to be reasoned rather than read, and how 5.5% survived this long.

Not to be confused with

COGNITION-CACHE-HIERARCHY.md is engrams — what a persona remembers (L1–L5). This is the KV cache — what the model has already computed. Orthogonal; the doc says so at the top so nobody merges them later.

Validation

  • cargo check -p continuum-core --features metal,accelerate — green
  • flash-attn fix live-verified: ps -o command= on the running llama-server shows --flash-attn on + --cache-type-k q8_0 applied; served window 23,040 → 54,272
  • Doc-only otherwise; all five cross-linked docs confirmed to exist

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits August 20, 2026 23:13
…e --mmproj and took serving to 0 lanes

Upstream llama.cpp changed this from a bare boolean switch to
`-fa, --flash-attn [on|off|auto]`. Our bare `--flash-attn` therefore consumed the
NEXT argument as its value and the server refused to start:

  error while handling argument "--flash-attn": unknown value for
  --flash-attn: '--mmproj'

Found 2026-08-20, the first time anyone ever set SERVING_FLASH_ATTN=1. The flag
shipped, was never exercised because it was opt-in and nobody opted in, and rotted
against upstream in the meantime. The whole lane failed to spawn and serving sat at
0 lanes.

An opt-in that has never once been switched on is untested code with a
config-shaped trigger — the same shape as [[an-absence-is-an-unfinished-measurement]],
where the absence of a failure signal was really the absence of an execution.

LIVE-VERIFIED: `ps -o command=` on the running llama-server shows both
`--flash-attn on` and `--cache-type-k q8_0` applied. Served window 23,040 -> 54,272.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… repetition between persona

Prefill is 96.3% of persona compute and the cache serves 5.5% of it (#266). Two of
four citizens sit at 0.0%. This doc is the design for keeping that work instead of
discarding it, and the honest boundary around what we actually know.

THE CONSTRAINT (Joel, 2026-08-20): "We won't pay the price for repetition between
persona." Today we pay it N times over — N citizens x 7,013 tokens of byte-identical
tool schemas, prefilled independently, every cold turn. That scales linearly with
population, so it is not constant overhead to absorb; it is a tax on having more
citizens, and it worsens exactly as the grid gets more interesting.

TWO STACKED DEFECTS, both verified by reading, neither yet proven causal:
  1. No persona->slot affinity exists anywhere in inference/. llama.cpp keeps KV per
     slot and --cache-reuse reuses a prefix WITHIN a slot, so reuse needs the same
     persona landing on the same slot. Nothing arranges that.
  2. deliberation_prompt.rs:48,128 puts identity at the head of the cacheable prefix.
     Byte-stable per persona across turns (which is what #266 wanted, and it delivers)
     but byte-UNIQUE across personas — so the shared tool block behind it can never be
     shared. Four citizens, four private copies.

THE DESIGN is a Docker base image, not a compression scheme: prefill the universal
span once, llama_state_seq_save_file it, load it into each slot. The primitives exist
in our fork (include/llama.h:898,905). Second-order win is larger than the first —
base.kv is file-backed, so citizens come back WARM across reboots instead of every
restart re-prefilling everyone cold. Two citizens have cited "the ongoing rebuilds
and interruptions" verbatim in withdrawal messages (#390); this is part of that cost.

WHAT COMPRESSION CAN AND CANNOT DO — the part worth keeping even if every hypothesis
above dies. Block-level KV dedup (chunk the prompt, cache per chunk, reassemble)
CANNOT work: K/V at layer L is a function of the hidden state, which carries the whole
causal history. Only layer-0 K/V is pure in (token, position). A chunk's KV is
genuinely not a function of that chunk. That is why the industry does PREFIX caching
and not BLOCK caching, and it is the intuitive move that will stay wrong.

THE NVIDIA PAPER (arxiv 2608.03893) is cross-MODEL transfer. Its transferable idea is
"strip RoPE, fit position-free, re-apply" — but that removes POSITION dependence, not
CAUSAL dependence, so it does not make a block relocatable. It also excludes hybrid /
MLA attention, which excludes K3, our flagship. It becomes ours when shared KV geometry
stops being discovered post-hoc and becomes a FORGE CONSTRAINT in the recipe — foundry
work (#180/#268), not this doc.

Written as design-with-hypotheses, not settled architecture: a table separates MEASURED
from VERIFIED-BY-READING from HYPOTHESIS, and every hypothesis names the measurement
that would kill it. Three of my own diagnoses were retracted the day this was written;
a doc that read as settled would have been the wrong artifact.

Step 1 is the hit-rate probe. prompt_tokens vs cached_tokens come back on every
llama-server response and we discard them — zero KV cache probe classes exist tree-wide,
which is why every claim here had to be reasoned rather than read.

Distinct from COGNITION-CACHE-HIERARCHY.md (engrams — what a persona REMEMBERS).
This is the KV cache — what the model has already COMPUTED. Orthogonal; the doc says so
at the top so nobody merges them later.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…n 08-09 and never pushed

Found while sweeping the tree for unsaved work: fix/system-prompt-cache-stability,
9 commits from 2026-08-09, local-only for 11 days, 158 commits behind canary. It
already implements the SELF-stability reorder this doc proposed as new, with sharper
forensics (7,607 of ~14,706 chars shared; the framing block flips DIRECTED/WORKING/
SILENCE every turn and truncated the prefix at that point), two VDD gates that were
RED before the fix, and 947 cognition tests green.

It also named this doc's central hypothesis eleven days earlier — verbatim: "slot-KV
eviction is a CO-cause the prompt fix alone won't move — settle with a stable-prompt
A/B before claiming the 10x." So Defect 1 is independent corroboration, not a
discovery, and the doc now says so.

The two are NOT duplicates and the doc now distinguishes the axes: that branch did
SELF stability (one persona across turns); step 2 here does CROSS-PERSONA sharing.
Step 2 belongs on top of it, not instead of it — and the build order now says to
rebase that branch first.

This is [[read-the-code-you-intend-to-replace-before-designing-its-replacement]]
landing again: I searched for my own concept ("slot affinity", "shared base") and
not for the job's name ("prefix stability"), so I did not find work that was sitting
in a local branch named for exactly the thing I was designing.

Its sibling spec, docs/cognition/TYPED-OBSERVATION-REFACTOR.md, was untracked for the
same 11 days (preserved separately). Spec and implementation were both one `git clean`
from gone.

Branch pushed to preserve only — unrebased, unvalidated against the drift, no PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot added size: L and removed size: M labels Aug 21, 2026
joelteply and others added 3 commits August 20, 2026 23:41
…o the UI (#266)

`cache_n` was parsed, typed, threaded through TurnMetrics — and dropped at turn end.
The ONLY consumer that ever turned it into a number was the eval harness
(`cache_hit_rate()` had exactly three callers, all in cognition/eval.rs; zero in
persona/, modules/, commands/). So #266's "5.5% cache hit, two of four citizens at
0.0%" is an EVAL-HARNESS number. Nobody has ever measured the cache behaviour of a
citizen doing real work in a room.

Components green, wiring to the place it matters absent — the same shape as the
DiskPressureMonitor logging `level=high [no reporters]` while nothing owned eviction.

THREE PIECES, one writer each:

1. `WorkspaceCycle` gains lifetime `kv_cached_tokens` / `kv_prefill_tokens`,
   interior-mutable exactly as `cycle_counter` already is.
   LIFETIME, NOT LAST-TICK: `Workspace::metrics()` is the winning verdict of ONE
   tick, and one sample of a live system is not a fact about it — a single cold turn
   reads 0%, a single warm one 90%. SEPARATE COUNTERS, ratio derived on read, never a
   stored rate: averaging rates lies, the rule `TurnMetrics::accumulate` already
   states for tok/s.

2. `note_generation()` folds one generation in and emits `serving.kv.reuse` with both
   the per-turn and lifetime split. Called from `act_observe/settle.rs` — the single
   place a completed generation's metrics are known — and called BEFORE the
   inference-fault early return, because a faulted turn still burned real prefill on
   the lane and a measurement that counts only successes would flatter precisely the
   failure mode we are hunting.
   A generation with no reported timings (cloud provider, older endpoint) moves
   NEITHER counter: absent stays absent instead of being recorded as a miss, which
   would slander a lane that simply never told us.

3. `kv_reuse()` → `Option<f64>`, radiated as the `kv_reuse` vital. `None` until a
   generation has actually reported, so an idle citizen radiates NO meter rather than
   a fabricated 0% — the honest-empty rule the neighbouring meters already follow for
   a dark cognition axis and an un-paged genome. That distinction is load-bearing
   here: 0% is ALSO the value of a real total-miss, so fabricating it on an idle
   persona would manufacture the exact alarm this meter exists to raise.

Joel's constraint (2026-08-20): "We won't pay the price for repetition between
persona." This is the instrument that will show whether we still are, per citizen,
live, in the positronic UI rather than only in a harness run.

PURE OBSERVABILITY — nothing routes, budgets, or gates on these counters.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…AME model (#266)

syv-ai/qwen38-27b-rtx3090 serves Qwen3.8-27B — our exact model — on one RTX 3090 via
vLLM. Different stack, and half that repo is patches against vLLM internals with no
llama.cpp counterpart. But the measurements are on OUR model, and three change this doc.

1. PREFIX CACHING CONFIRMED AND NOW PRICED. Their note: "Turn-2+ of a chat with a 24k
   document goes from ~23 s to ~1 s; costs one extra state page per request (~16% of the
   KV pool). Hybrid models keep this opt-in upstream." Independent confirmation of this
   doc's thesis from someone who measured it, plus the thing the doc lacked — a COST
   SHAPE. Step 4 stops being "unknown cost, probably worth it" and becomes a known trade.

2. NEW ITEM, absent from this doc: DRAFT-VOCABULARY CALIBRATION. A draft vocab counted
   over the model's OWN outputs covers 97.5% of what it generates (96% on CODE); a
   generic web-text list gets 92% (83% on code). Every miss is a forced rejection: 108 vs
   98 tok/s. ~10% throughput from calibration alone, widest gap exactly on our workload.
   Ours by construction — we capture every turn and we have a foundry. This is the
   frozen-backbone/own-corpus thesis applied to DRAFTING instead of weights.

3. LOOKUP DRAFTING IS THE AGENTIC-CODING MULTIPLIER, and they reached it independently:
   "Worth setting for a coding assistant applying edits or a RAG front-end quoting
   sources." With the honest cost: 8 request slots -> 4, 64k -> 56k.

WHERE WE STAND ON THEIR LADDER: ~46 tok/s no-spec -> ~108-114 MTP -> ~259 DFlash2 ->
~381 lookup+16-token verify (document reproduction only; ~133 ordinary chat). Our live
lane carries --spec-draft-model + --spec-draft-n-max 4 (#440) and a direct probe of the
running server returned draft_n: 2, draft_n_accepted: 2 — speculative decode is LIVE and
accepting. We are at their MTP rung. We lack lookup drafting.

NO SIDE-BY-SIDE tok/s COMPARISON APPEARS HERE, deliberately. We have no clean
single-stream measurement; theirs is 250W CUDA and ours is Metal. Publishing the two next
to each other would be exactly the benchmaxx that thread's skeptic was right to distrust.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…measurement heal)

MEASURED 2026-08-21 on this box: 20 SWE runs, 7 graded, 13 lost to infrastructure —
and 8 of those 13 (40% of every run ever attempted here) died to `killed by a core
restart`. Reboots are doctrine, so the answer is not fewer restarts; it is that a
killed run has to be recoverable.

It was not, for a reason that is pure discard. `reap_orphaned_solve_runs_in` reads the
instance, WRITES it into the failed record, then returns bare run ids — and the boot
probe could therefore say only that A run died, never WHICH TASK went unmeasured.
Recovering a round meant hand-opening ledger files. The reaper had the fact the whole
time and dropped it on the way out.

Now it returns `(run_id, instance)` — the same pair `in_flight_solve_runs_in` already
returns, for the identical reason stated in that function's own doc: the caller has to
be able to NAME what it is talking about. The boot probe carries `instance` and
`needs_redispatch`.

WHAT THIS DELIBERATELY DOES NOT DO: re-dispatch. The probe says so out loud rather than
implying recovery happened. The instance goes back on the board through
`benchmark/dispatch` — the ONE adapter into kanban — never from here: this is the
SERVING daemon, and a serving daemon that posts work cards is exactly the parallel-runner
shape docs/architecture/BENCHMARKS-ARE-ADAPTERS-NOT-A-RUNNER.md forbids. Auto-re-post
belongs on the benchmark side, consuming this report. That is the next slice, and it is
now unblocked because the report finally carries the instance.

Test premise updated, not weakened: `a_run_still_marked_running_at_boot_is_journaled_as_killed`
now asserts the pair, and its comment names the regression it catches — a reap that
reports only an id. Green: 1 passed. `cargo check --tests` clean.

ALSO MEASURED, and the more interesting half — the 7 graded runs are NOT noise. Every
one of the six failures is f2p 0/N with p2p near-perfect (40/40, 39/40, 40/40, 6/6).
The citizens write patches that break nothing and fix nothing. Only sympy-24152 resolved
(#366). That is a capability signal, not a plumbing one, and it only became readable
once the infra losses were separated out.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot added size: XL and removed size: L labels Aug 21, 2026
joelteply and others added 9 commits August 21, 2026 04:51
… doc promised and never had (#419/#412 family)

`cognition_pulse.rs` documents two writers — "called at spawn (grace window
covers the post-boot deaf period, #412) and at every service-loop turn start" —
and rests its `None`-is-not-earned posture on the first one: "spawn stamps
immediately, so live citizens are always stamped."

The spawn writer did not exist. Grep across the crate found exactly one caller of
`touch()`, at service_loop.rs:758 beside `persona.turn.start`. So a citizen who
had not yet taken her FIRST turn was indistinguishable from one silent for hours:
`idle_ms` → None, `renewal_earned(None, _)` → false, claim renewals denied from
birth.

Measured live before the fix: four hosted citizens, `idle_ms` = None on every one
(the 18446744073709551615 on `persona.claim.renewal_skipped_idle` is the probe's
`unwrap_or(u64::MAX)` sentinel, not a duration), and
`persona.claim.renewal_resumed` at ZERO rows ever — no citizen has earned a
renewal back since the gate landed. What surfaced it: one bench card claimed by
the same citizen three times in one evening — claim → never pulse → 30-min lease
lapses un-renewed → card returns to claimable → re-claim. Activity on the wire,
nothing produced.

The stamp goes after `prime()` succeeds, the instant the substrate's own
"hosted = ready" invariant holds. This does NOT reopen the lease-immortality
regression the pulse exists to prevent (2026-08-16): it buys exactly one
lease-length of grace — which is what #412's ~10-minute deaf window needs — after
which a citizen who still has not thought lapses normally.

The renewal GATE itself is untouched and correct. The defect was a missing
writer, not a wrong policy.

Guard: a source-level assertion that host.rs calls `cognition_pulse::touch`, with
comments stripped so this module's own prose can never again stand in for the
wiring (the #344 audit predicate). A semantic test cannot catch this class — the
renewal contract is fully satisfied by an unwired module, which is exactly how it
shipped. Positive control: pre-fix, host.rs contained no mention of
cognition_pulse at all, so the guard fails on the old tree.

NOT fixed here, and not claimed: turns are still not starting (#462). This
restores honest lease accounting for citizens who have not yet thought; it does
not make them think.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… a working citizen's claim under her own live run

Sibling of c91423a, and the half that actually explains the spin.

`cognition_pulse::touch` had ONE caller (service_loop turn start), plus spawn as
of c91423a. A detached `agent/solve` is NEITHER: it drives acts for hours and
produces no airc turn at all (#425). So the renewal gate — whose stated predicate
is "the substrate observes that she is WORKING" — read a citizen in the middle of
a real solve as silent, denied her renewals, and let the 30-minute lease lapse
UNDERNEATH the live run. The card returned to claimable and was re-claimed,
spawning a fresh run that started over at `acts: 0`.

MEASURED LIVE 2026-08-21, pallets__flask-4045: Atlas re-claimed card df9f4ad5
three times in one evening. `benchmark/runs` caught the newest one at
`age_secs: 8, acts: 0, files_changed: []` seconds after the third claim landed —
a brand-new run replacing work that had been in flight. All four hosted citizens
showed `renewal_skipped_idle` with `idle_ms` = None, and
`persona.claim.renewal_resumed` has ZERO rows in the ledger's entire history.

THIS SHARPENS c91423a's CAVEAT. That commit said the spawn stamp "does not make
them think," which framed the citizens as idle. On this card at least, the
opposite: she was working the whole time, on a path the pulse could not see.
Spawn grace alone would NOT have fixed it either — a multi-hour solve outlives a
30-minute lease no matter how it starts.

The stamp goes in the run-pulse tick that already exists for #371 law 2, and is
unconditional there ON PURPOSE: `select!` only reaches that arm while the drive
future is pending, so a tick firing proves the drive is live at that instant.
That is a strictly stronger witness than the act counter written just below it,
which legitimately reads 0 or None early in a run and would deny a renewal to a
citizen mid-first-act.

Identity comes from `persona_uuid`, already resolved at the top of `solve_body`
through the shared `id_resolve` primitive. `PersonaRef` is deliberately not
parsed to a Uuid here — its doc is explicit that "a reference is not an identity
until a roster says which one it is," and that rule is honored rather than
routed around.

The renewal gate's policy is untouched in both commits. It was never wrong; it
was blind on two of the three paths where a citizen works.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… a deleted regression; fix the stale doc that caused it

Reverts c91423a entirely, and fixes the actual defect it should have been.

WHAT I GOT WRONG. `cognition_pulse.rs` documented two writers ("called at spawn
… and at every service-loop turn start") and justified its `None`-is-not-earned
posture with "spawn stamps immediately, so live citizens are always stamped."
Only one writer existed. I read that gap as missing wiring and added the stamp.

It is not missing wiring. It is a DELIBERATE DELETION, and the removal site says
so in full, at airc_runtime.rs:571-581 — the exact place a birth stamp would go:

    NO birth stamp — renewal is earned ONLY by cognition, never by booting. The
    grace stamp that used to sit here (one lease-length per spawn, meant to cover
    the post-boot deaf window #412) made convergence structurally impossible
    across restarts: every core restart re-armed 30 minutes of "earned" renewals,
    and the renewal loop below resurrected already-lapsed claims faster than the
    180s lapsed-claim sweeper could observe them — an entire overnight round
    (2026-08-16) sat "actively held" with zero turns because of it.

So c91423a reintroduced a known round-killer, and its "guard" was worse than
useless: it pinned the regression into CI as if it were the contract. Both gone.

THE REAL DEFECT, fixed here: the doc. It still described a writer that had been
removed, and a doc describing a deleted writer reads EXACTLY like missing wiring
— which is how it talked me into re-adding it. `touch` now states there is no
spawn stamp and why, and points at the removal site; `idle_ms` now states that
`None` is the EXPECTED reading for a booted-but-not-yet-thinking citizen and
that her holds lapsing within one TTL is designed, not broken.

WHAT THE LIVE RUN ACTUALLY SHOWED, and it was the tell I nearly explained away:
after deploying c91423a, all four resident citizens STILL reported
`idle_ms` = None. I had a fix that provably did not do what I claimed, and the
correct next question was "why", not "how do I make it fire".

KEPT: eb69061 (the solve run-pulse tick). It is a different thing and survives
the reasoning above — it stamps only while a drive future is actively pending,
which is work, not booting, and a restart kills the run rather than re-arming a
grace window. It is NOT yet live-verified; the honest status is unproven.

LESSON, and it is one already in my own guardrails:
[[read-the-code-you-intend-to-replace-before-designing-its-replacement]]. I
searched for my concept ("who calls touch") instead of the job's name ("what
decides renewal, and what did it used to do"). The answer was one screen above
the code I was reading.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…-claim (STOPGAP, named as one)

THE MEASUREMENT. `run_id` is deterministic per card (`claim-<uuid>`) and
`dispatch_staged_swe_solve` had no idempotence guard, so every re-claim of the same
card fired ANOTHER detached solve. Two runs then shared, simultaneously:

  - ONE LEDGER FILE — their pulse ticks overwrite each other, so `benchmark/runs`
    reports whichever wrote last. The `acts: 0` I read on Atlas's third flask-4045
    claim was very likely run B stomping run A's marker, not a fresh run.
  - ONE WORKSPACE — two sets of hands editing the same repo. A live candidate for
    the empty `files_changed` this box keeps producing.
  - ONE EXCLUSIVE WARM SLOT, which each asks to quiesce the other out of.

Observed 2026-08-21: Atlas re-claimed df9f4ad5 three times in one evening;
`benchmark/runs` caught the third at `age_secs: 8, acts: 0`.

A re-claim is LEGAL — airc permits claiming a lapsed card, and #331/#2286 both
depend on it. What is not legal is a second RUN. The claim is the citizen's intent;
the run is machinery, and machinery must be idempotent under a repeated intent.

WHAT THIS FIX ACTUALLY IS, and the commit says so rather than letting the code imply
otherwise: a doorman with a clipboard. A citizen re-affirming a claim is an ordinary
act — a student saying "this one's mine" a second time. Today the school seats a
SECOND her at a second desk with a copy of the same worksheet. This gate refuses at
the door. It stops the damage; it does not remove the incoherence.

THE INCOHERENCE, which is the defect underneath: TWO REGISTRIES FOR ONE FACT. The
board holds "this citizen holds this card" (enrollment); a JSON file holds "run
claim-<id> is running" (attendance). Two records of one truth, free to disagree, and
this gate is a clerk reconciling them on every claim. The structural answer is that
the ENROLLMENT IS THE SESSION — re-affirming a claim finds the work already under way
and continues it, because the fact lives in one place and there is nothing to
duplicate. That is #371 (round lifecycle as recipe-owned state) plus #49 (workspace
held for the life of the claim, so the worksheet is HERS rather than a directory two
runs can both open). Neither is built.

REUSE, NOT A PARALLEL PREDICATE: keyed on `in_flight_solve_runs`, the same
`state: "running"` reader the boot reaper uses, so the gate and the reaper can never
disagree about what "live" means. That also supplies the release valve for free — a
run whose core died is reaped to `state: "failed"` at next boot, so a dead run never
blocks its card forever. Refusal, not a kill: the live run continues untouched and
nothing touches the citizen's claim.

`run_id` is now built ONCE and shared by the gate and the dispatch params, so the
guard can never check a different id than the dispatch uses.

TEST: no new test — both halves the gate depends on were already pinned by
`a_run_still_marked_running_at_boot_is_journaled_as_killed` (in-flight detection, and
"after the reap nothing is in flight"). That second assertion is now load-bearing for
TWO consumers, so it says so: if a reap ever stopped clearing `state`, the failures
compose into every restart-killed card being permanently un-dispatchable while the
board looks busy forever.

NOT live-verified — needs a real re-claim against a live run to see the refusal probe.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… and the adapter that has no consumer

Answers the question ROUND-LIFECYCLE-AS-RECIPE-OWNED-STATE-MACHINE leaves open. That doc
specifies the round's STATES and treats grading as one of them; it never says who judges
or how an activity declares it.

JOEL'S CONSTRAINT (2026-08-21), which kills two tempting designs: "Grading isn't part of
all recipes either. It's just benchmarks recipe" … "a lot of activities, especially since
we're learning, will have formulaic grading for score. It's just a lot of different ways
here and some rooms will be more open ended, take general chat for example."

So: `grader` does NOT belong on `ExperienceRecipe` — that stamps an exam concept onto
every chat room and drawing class forever. And not every judge is CODE: forcing a Rust
adapter to score a drawing exercise is "integrations adapt to us" violated in reverse.

THREE TIERS: none (chat — a forced score would be a lie), FORMULAIC (the common case for
learning; a scoring expression over facts the room already observes; pure recipe DATA),
and ADAPTER (`BenchmarkAdapter::grade`, for judgment that genuinely needs execution).

WHERE IT LIVES: `params`, not the base type. `benchmark.json` already declares `suite`
(the adapter-IN), `instances`, `team`, `budget` this way — typed, defaulted, invisible to
recipes that don't declare them (#433). The judge is another param of the same kind, so
the base type does not change and chat/profile/video-chat never grow a field to ignore.

THE AUDIT THAT MOTIVATED IT — `BenchmarkAdapter` exists, is correctly shaped
(dataset in, tasks normalized to EvalTask, grade out, backend-neutral TaskOutcome),
self-registers via `inventory` keyed by name — and has ZERO production consumers. Every
reference tree-wide is the definition site, `humaneval-rs` registering itself, or that
adapter's own test. The module header names `benchmark/dispatch` as its runner;
`commands/benchmark.rs` never references it. SWE grading goes through hardcoded
`swe_bench::grade`, bypassing the interface entirely.

Recorded with its confidence: no marker suggests deliberate removal (unlike the
`NO birth stamp` comment in airc_runtime.rs, which documents its own deletion), but that
is an inference from an ABSENT comment — flagged as likely, not certain. That distinction
is exactly what I got wrong once already this session.

BUILD ORDER: formulaic first (common, pure data, no adapter needed); then route the
adapter tier through the existing registry, DELETING the hardcoded SWE branch rather than
adding a field; grow `TaskOutcome` only when a real second modality forces it.

Design only — nothing built here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… never read as the whole history

MY OWN BUG REPORT, and the fix is for the thing that produced it.

This morning I ran `benchmark/runs`, got 20 rows carrying 1 resolved instance, and
concluded (a) that was the system's entire history and (b) grades were being lost
between the grader and the board. BOTH WRONG, and I nearly shipped a "fix" for the
second one.

What is actually true: `scan_run_cards` already reads the `.grade.json` sibling, folds
it through `fold_run_card`, AND adds `scan_verdict_cards` (durable per-instance
verdicts, which emit their own rows) AND `scan_workspace_artifact_cards` for work no
grade has seen. The projection is correct and has been. The last line is
`cards.truncate(limit)` with `limit.unwrap_or(20)`, sorted newest-first — so what I
saw was a PAGE.

Reading the grade files directly: 94 grades across 37 distinct instances, and TWO
resolved — `sympy__sympy-24152` (the known #366 milestone) and `sympy__sympy-13480`,
which nobody knew about because its rows are older than the 20-row window. The real
rate is 2/37 = 5.4% on the graded set, not the 1-pass history the board implied.

So the defect is not lost grades. It is that a bounded page is INDISTINGUISHABLE from
the complete set on the exact command an operator uses to ask how the benchmark is
going. Silent truncation reads as "that's everything."

`debug/probes/query` already solved this and says so in its own summary ("how many
events MATCHED versus how many were returned, so a page is never mistaken for the
whole"). This adopts the same convention rather than inventing a second one:

  - `scan_run_cards` now returns `RunScan { cards, matched }`, counting BEFORE the
    truncate. A struct rather than a tuple so neither caller can silently drop the
    count — which is precisely how this fact went missing in the first place.
  - `benchmark/runs` reports `matched` plus a `summary` that says, in words, whether
    this is a page or the whole set, and names `--limit` as the way to see more.
  - the positron board takes `.cards` only, with a comment stating WHY: `BOARD_LIMIT`
    is a display bound for a fixed-height rail, not a claim about how many runs exist.
    If that rail ever grows a "+N more" affordance, `matched` is what it reads.

ts-rs binding regenerated (`export_bindings_benchmarkrunsresult` green) and committed
alongside, per the Rust↔TS rule — shipping the Rust without its generated TS is the
drift #457 exists to catch.

NOT live-verified yet — the running core predates this. Reboot + a real
`benchmark/runs` receipt is the proof, and it is next, not deferred.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…st-valued, empty allowed), not three tiers

Joel, correcting the draft committed an hour ago:

> "Or just always adapter(s) with none as an option and maybe an ability to chain or
> interlink them. So formulaic or not, anything can plug in. Just build the ones you
> initially need is my motto."

MY VERSION WAS A FALSE TRICHOTOMY. I had proposed three tiers — none / formulaic /
adapter — as if they were different kinds of thing. They are not:

  - "none" is the EMPTY LIST, not a tier. Nothing special-cases it.
  - "formulaic" is an ADAPTER THAT EVALUATES A FORMULA — one implementation among many,
    written once, then named by any recipe that wants it.
  - several adapters COMPOSE, which is where #371's "gates multiply, objectives weigh"
    actually lives.

WHAT THE TRICHOTOMY WOULD HAVE COST: a scoring-expression DSL in the substrate, designed
up front, with no live consumer — because "formulaic grading declared as data" means
inventing a formula language. Joel's motto kills it before it starts. One interface, N
implementations, runtime selection by name is the polymorphism rule this codebase already
runs on (CLAUDE.md § POLYMORPHISM PATTERN), and it was sitting right there.

Also corrected: the judge param is a LIST defaulting to empty, so "no judge" costs zero
code rather than a third branch; and the acceptance test now names the chat room
explicitly — declaring no judge must be as ordinary as declaring one.

Chaining/interlinking is deliberately left OPEN. Sequential composition is obvious;
whether adapters feed each other, and how gate-vs-objective results combine, gets settled
by the first activity that needs it. Writing that down now would be the same speculative
mistake one layer up.

Build order rewritten around the motto: route the EXISTING adapter through the registry
first (a subtraction — delete the hardcoded `swe_bench::grade` branch), then write a
second adapter only when a second activity exists, then composition only when two are
genuinely named together.

Design only — still nothing built.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… symlinks

Three untracked things, all of which would have been lost on a clean checkout.

1. `.ignore` — REAL WORK, authored per Joel 2026-08-14 ("if you're finding code that
   misleads you we need to move it to legacy or somewhere out of path so you cant keep
   finding it") and never committed. It quarantines from the SEARCH path what #83/#318
   quarantined by directory: `legacy/` (2,865 .ts decoys whose SidebarWidget/MainWidget
   look exactly like the live UI and outnumber it ~20:1), `.claude/worktrees/` (6 full
   tree copies, so every find returned 7 answers), and `core/vendor/*/build/` (llama.cpp
   ships a whole web UI that answers index.html searches).

   Its own header records what it cost to learn: an agent spent an hour concluding the
   Continuum UI had been LOST — a fabricated regression reported as fact about an app
   that was running fine. "A decoy you can still grep is not quarantined." Losing this
   file means losing the fix AND the reason, and re-learning it the same expensive way.

2. FOUR MISSING AVATAR SYMLINKS — and this one is a latent BUG, not just hygiene.
   `models/avatars/` carries six `.glb -> .vrm` symlinks so a renderer that resolves by
   `.glb` finds the VRM. Only TWO were tracked (`vroid-darkness`, `vroid-male-base`).
   On any fresh clone, `vroid-female-base`, `vroid-sakurada`, `vroid-sample-e` and
   `vroid-shino` have no `.glb` at all — so 4 of 6 avatars fail a `.glb` lookup while 2
   succeed, which is exactly the kind of works-on-my-box asymmetry #291 (fresh-clone →
   running system) exists to stop. They are symlinks (15-21 bytes each, the length of
   the target filename), so this costs nothing.

3. `.gymtool/` → .gitignore. Ad-hoc agent probes (shot/rowcount/msgcount/nav-restore)
   plus a COMPILED `_check_bin`. Scratch instruments, regenerated on demand, and a
   committed binary is never right. Ignored rather than committed.

Found while auditing untracked files under an explicit "do NOT lose code" instruction.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Same guard that reddened #2344, same cause here: `the_unjustified_unwrap_count_never_rises`
at 2268 vs baseline 2267. Three new sites, all this branch's:

- `solve.rs` run-pulse stamp — `duration_since(UNIX_EPOCH)` errs only on a pre-1970
  clock. 0 then reads as "never pulsed", which DENIES a renewal. That is the
  conservative direction and the same state as no stamp at all; a wall clock behind
  the epoch must not hand out lease extensions.
- `benchmark.rs` page size — `limit` is an OPTIONAL param, so None means "caller
  didn't ask", not "unknown quantity". 20 is the documented default page. The count
  that must never be defaulted is `matched`, which comes from the scan and is
  reported separately.
- `positron_bench_source.rs` ×2 — scan error (progress dir absent on a fresh node)
  and JoinError both fold to the honest EMPTY board. The module header already states
  the rule: never a fabricated row. Panicking in the emitter would take the board down
  for every viewer instead.

Note for the next person hitting this guard: the comment must be on the SAME LINE as
the unwrap. A block comment above it does not register — that cost a round trip here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply enabled auto-merge (squash) August 21, 2026 13:02
@joelteply
joelteply merged commit 50ed63d into canary Aug 21, 2026
4 checks passed
@joelteply
joelteply deleted the feat/kv-shared-base-layer branch August 21, 2026 13:11
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