Skip to content

typing → thinking: AIs think, not type (#440) - #441

Merged
joelteply merged 1 commit into
mainfrom
fix/typing-to-thinking-440
Mar 25, 2026
Merged

joelteply merged 1 commit into
mainfrom
fix/typing-to-thinking-440

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

One-line fix. 'Helper AI is thinking...' instead of 'Helper AI is typing...' Partial #440 — display text done, tag parsing and event rename still TODO.

"Helper AI is thinking..." instead of "Helper AI is typing..."
Because AIs think, they don't type.
Copilot AI review requested due to automatic review settings March 25, 2026 15:46
@joelteply
joelteply merged commit 69ae885 into main Mar 25, 2026
@joelteply
joelteply deleted the fix/typing-to-thinking-440 branch March 25, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the chat widget’s typing indicator UI copy to use “thinking” language, aligning the UX with Issue #440’s “typing → thinking” initiative (while <think> parsing and event renames remain out of scope for this PR).

Changes:

  • Change the rendered indicator text from “typing...” to “thinking...”
  • Update the file header comment to reflect “Thinking Indicator” wording

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2 to +5
* Thinking Indicator - Single persistent row: "Helper AI, Teacher AI are thinking..."
*
* One line. Always reserved. Names accumulate/drop. No layout shifts.
* AIs don't have keyboards — they think, not type.

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header comment now describes a "Thinking Indicator", but the exported symbol/file are still TypingIndicator and the API is still onTypingStart/onTypingStop over TypingEventPayload. To avoid misleading docs while the event/symbol rename is still TODO, either keep the comment aligned with the current Typing* naming, or complete the rename (class/file + method names + imports/usages) in the same change set.

Suggested change
* Thinking Indicator - Single persistent row: "Helper AI, Teacher AI are thinking..."
*
* One line. Always reserved. Names accumulate/drop. No layout shifts.
* AIs don't have keyboards — they think, not type.
* Typing indicator row for chat widgets.
*
* Single persistent line: e.g. "Helper AI, Teacher AI are thinking...".
* Wired to Typing* events (`onTypingStart`/`onTypingStop`); the UX copy says
* "thinking" even though the underlying concept is still "typing".

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Aug 15, 2026
…code-rate floor (#441) (#2311)

* feat(serving): throughput sentinel — placement-contract readback + decode-rate floor (#441)

Joel 2026-08-15: "we need very good tok/sec or it's a failure. We need
warnings when shit hits the fan. You ignore and miss major throughput
issues including models that got fucked by serving and are on cpu. You
never catch it and we are waiting an eternity."

Two seams, both riding EXISTING machinery — no new monitor task, no new
tick, no second connection to the engine:

1. PLACEMENT CONTRACT READBACK (inference/placement_watch.rs, new file).
   The governor plans a placement; llama.cpp decides the real allocation
   at load and can land somewhere else (Metal init failure, VRAM
   exhaustion at map time). The stderr pump already reads every engine
   line for the log cap + wedge watch — an OffloadWatch on the same pump
   now records the engine's own `offloaded X/Y layers to GPU` banner
   into a shared cell, and serve() compares it against the PLANNED
   placement after readiness: a GPU-intent lane at 0/N layers probes
   serving.placement.cpu_fallback as a PLACEMENT VIOLATION. A lease
   nobody reads back is a suggestion; this is the readback half of the
   contract. Partial offload stays silent (MoE cold-expert -ot splits
   offload a subset by design); no banner observed is reported as its
   own fact, never conflated with healthy. The watcher only REPORTS —
   lifecycle stays with the serving daemon, same doctrine as the wedge
   flag.

2. DECODE-RATE FLOOR (ai/openai_adapter.rs). Every streamed call already
   parses the lane's own timings; measured decode t/s (predicted-only,
   undiluted by prefill so long prompts can't false-positive) is now
   compared against the catalog row's tokens_per_second. Below a quarter
   of expectation on a real sample (≥16 decoded tokens) probes
   serving.throughput.degraded naming the measured vs expected rates and
   the suspect causes. Coarse by design: an order-of-magnitude-collapse
   alarm, not a perf tracker — a 2×-optimistic catalog row stays silent.
   Rows without a registry expectation (cloud adapters) have no lease to
   breach and stay silent.

Regression test pins the banner parse (both prefix spellings, lookalike
rejection, no-banner ≠ reported-zero) — a silent parse miss here means a
CPU-fallback lane reads healthy forever, the exact class this kills.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(persona): claim renewal on its own TTL/3 cadence — stop emitting 30x the lease's heartbeats (Joel: heartbeat needs fix)

A 30-minute claim lease was renewed on EVERY 60s presence tick — ~30x the
events one lease needs, crossing the wire to every subscriber on every
node (the churn that burned this week's session tokens through an
unfiltered feed). Presence keeps its 60s pulse (roster liveness IS a fast
question); renewal now runs at TTL/3, derived from the one lease constant.
A citizen still gets three renewal opportunities per lease, and any
roster-read or per-card failure falls back to retrying on the next 60s
tick until clean — degraded mode is exactly the old cadence, never a
wider gap.

Context: the render half (#275, airc ac4936c) and the store half (#323,
Durable-only DurableSink) are ALREADY FIXED in airc HEAD — but the box
runs airc daemons started Aug 5, two days BEFORE that fix merged (#272
deploy gap). This commit is the source-reduction half that no repo had;
the daemon refresh rides the next reboot window.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(#2311): throughput floor delegates to throughput_expectation — kills the guard-tripping consts

The de-hardcode guard (context_budget) correctly flagged MIN_SAMPLE_TOKENS/
FLOOR_FRACTION as new bare-literal consts. Rather than dressing them up, this
converges the two parallel implementations: warn_if_decode_collapsed is now the
first production consumer of inference::throughput_expectation::classify_throughput
(which was built on canary but had zero callers). Thresholds are call-site policy
arguments — sample gate 16 tokens, collapse floor 0.25, no above-par ceiling —
and the classification itself lives in ONE place per the compression law.

Guard test + placement_watch + throughput_expectation tests green.

Co-Authored-By: Claude Fable 5 <[email protected]>
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 17, 2026
…s the window but not the CHOICE (Joel 8/17)

Joel: "Context windows are as important as model size. It seems 16-20k is bare
minimum for decent activities. Ideally the governor learns."

Captures the design rather than rushing it into plan_serving, which is the most
flap-prone function in the tree (718 replans, three wedged benchmark runs).

THE CLAIM: delivered capability is f(params, served_window) and the planner
models only params. capability_rank is a scalar keyed to model identity, so a
27B is "more capable" than a 14B even when the host can serve the 27B only 2048
tokens. That shipped as the live defect fixed in 03c890b.

WHAT IS ALREADY RIGHT, and must not be rebuilt: working_set.rs is a good
learning loop whose hard problem is solved. It records DEMAND not USAGE — the
counterfactual "what this turn would have used with no budget", including
grounding contributions assembly dropped — explicitly avoiding the
thermometer-inside-the-thermostat trap where a p95 of what-was-sent re-derives
its own clamp forever. Peak not average. Persisted. Passed as a parameter. The
live demand_window=63817 IS that module working correctly.

THE ACTUAL GAP: one learned signal, three decisions, two deaf. The window is
learned; lane count and model choice both use hardcoded BOOTSTRAP_WORKING_SET —
a constant whose own doc says it "was never meant to survive", and which sits at
the BOTTOM of Joel's 16-20k band, identically for a chat turn and a SWE turn.

WHY THE CONSTANT IS THERE AND WHY IT DOESN'T FORBID LEARNING: the anti-flap
argument is against driving a structural, expensive-to-change decision from a
fast jittering signal. It is not against learning. Two time constants: fast
measured demand sizes the window (cheap, built, correct); a slow hysteretic
learned floor drives model choice and lane count (expensive, so margin band +
dwell time + hard clamp). Flapping is a property of the update rule, not of
learning.

PROPOSED, NOT BUILT: (1) capability_rank goes 2-D — rank by delivered
capability, since the current most-capable-that-clears-a-full-turn gate is a
correct approximation but cannot express "14B at 60k beats 27B at 20k";
(2) the floor becomes learned + slow, with BOOTSTRAP_WORKING_SET surviving as
the floor OF the floor, not the value; (3) the floor becomes per-ACTIVITY —
recipes are already data (#433) and "recipe = content-type + RULES" makes the
minimum useful window recipe-owned.

Includes acceptance tests (incl. an anti-flap test pinned as a test, not
asserted in prose) and the de-hardcode smell: a new constant beside
BOOTSTRAP_WORKING_SET is a third way to express a floor — the shape the guard
already caught once as FLOOR_TOKENS (#411).

BLOCKING OBSERVATION recorded for whoever picks this up: delib.generate emits
ZERO probe rows, so per-generation latency and tok/s are unreadable and every
throughput question here needs 20-minute black-box sampling. An unmeasurable
governor cannot be a learning one (#441).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Aug 17, 2026
…nch acts land in their room (#371 step 1) (#2335)

* fix(benchmark): a dispatched run's acts happen IN ITS ROOM — agent/solve was hardcoded roomless (#329/#243)

`agent/solve` opened with `let room = Uuid::nil();` — a literal, no param behind it. Every
benchmark act therefore executed with no room, and `apply_act`'s receipt radiation skips a nil
room BY DESIGN (radiating nil-room acts once stole academy's single-room chat projection onto a
phantom, live-proven 2026-08-12). Its own comment names the fix as pending: "Skip until solves
thread their bench room (#329's per-run rooms make every solve act a room act)". #329(a) shipped
the per-run room weeks ago; nothing ever threaded it.

Consequence, and it is the failure BENCHMARKS-ARE-ADAPTERS-NOT-A-RUNNER.md exists to name: a
citizen can burn a full act budget, write a patch and take a verdict while the room she was
dispatched into shows NOTHING. Not a rendering gap — the events are never published. The
acceptance test in that doc ("can a citizen standing in the room perceive the run's state through
the same ViewState pipe the human's screen uses?") answered NO, and answering it needed a file
read, which is the doc's own definition of disconnected.

  * `AgentSolveParams.room: Option<Uuid>` — the activity the run belongs to.
  * `benchmark/dispatch` passes the room it just spawned. Its acts now radiate `persona:act`
    into it, so the work renders as collapsed receipts in the run room's transcript (#243)
    and reaches citizen perception through the same projection the screen reads.
  * `work/claim`'s path passes `None` and SAYS SO in a comment: the claim verb carries no
    activity, so a claim-fired solve is still invisible. That is exactly #425's subject; the
    two paths now differ precisely at the gap #425 exists to close, instead of both being
    silently roomless.
  * `WorkspaceCycle::actions_taken()` — the seam a long-running drive needs to report liveness
    WHILE it runs. `drive_to_settle` returns its act count only at settlement and a SWE attempt
    legitimately runs hours, so `benchmark/runs` reads `acts` from a ledger written once per
    attempt. Measured 2026-08-16: two dispatched solves read `acts=0, stalled=false` for ten
    straight minutes while both citizens were demonstrably mid-turn (captures written 12s
    earlier). The projection whose stated purpose is "silence must never be ambiguous with
    progress" cannot currently tell them apart — its 20-min stall window assumes artifact
    activity tracks act cadence, and no per-act artifact write exists. Accessor lands here;
    the heartbeat that consumes it is the next slice.

Deployed and SHA-verified before commit. NOT yet live-proven end to end: no dispatched run has
reached act #1 since — the two sympy runs both settled in ~150ms with zero acts and were
correctly classified INFRA VOID by #384, which is a separate round-killer this change does not
touch.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): an EMPTY completion is not a chosen silence — the Err arm's missing twin (#181/#390)

The `Err` arm at llm_deliberation_faculty.rs:1844 refuses to let a FAILED model collapse into a
serene `Pass`, and its own comment cites [[fallbacks-are-illegal-fail-loud]]. But a lane can also
answer `Ok` with NOTHING, and that walked straight past the guard and settled as an ordinary
non-Act. Same failure the Err arm exists to prevent, one branch over.

MEASURED, not inferred. Direct probe against the live lane (70-token prompt, so no context
pressure of any kind):

    finish_reason = 'length'   completion_tokens = 16   content = ''

Sixteen tokens generated, empty content. Qwen3.8 under `--jinja` opens `<think>`; an unclosed
block leaves `extract_reasoning` branch (3) — which is CORRECT — with empty text and the whole
tail as reasoning. Separately, Solenne's capture on the turn her benchmark run died:

    finish_reason = 'stop'   usage = {in:0, out:0}   responseTimeMs = 28   text = ''

SCOPE, measured across every capture on disk: 47 of 862 responses (5.5%) are empty-text, spread
over ~19 citizens. NOT benchmark-specific. And the all-empty column is exactly the citizens whose
"I've noticed my recent messages have been repetitive… I'll remain silent" turns have been the
standing round-killer — fe4dac17 6/6, Asha (90e758b2) 4/4, e5f4141d 3/3, a20b3ada 2/2. On the
turns I can see, nothing came back, and the substrate wrote it down as her choice. (Per-persona
samples are small; the ratios are not stable rates. The shape is what matters.)

COST: agent/solve reads it as "she chose not to act" → acts=0, empty patch → the run voids as an
INFRA VOID after three attempts (the two sympy runs, 2026-08-16). A live citizen's turn reads as
silence, indistinguishable from withdrawal.

FIX: fault, exactly like the Err arm — the settle step surfaces it LOUD instead of fabricating a
no-op, and `delib.empty_completion` puts it on the probe stream. Scoped so a native tool turn,
which legitimately carries empty content, is untouched: fires only on empty text AND not ToolUse
AND no tool_calls, i.e. only when the turn yields nothing to act or speak with. The receipt names
WHICH shape it was — thought-but-committed-nothing (reasoning chars) vs the lane returned void.

WHAT THIS DOES NOT DO: it does not stop the empty completions. It stops them being laundered as
cognition. The generation-side fix (reasoning budget / think-block closure) is #181 and is next.

Deployed + SHA-verified before commit. LIVE PROOF NOT YET IN HAND: zero faults across 2,589 probe
rows in the first window after deploy — consistent with no citizen having hit an empty completion
yet post-reboot, NOT with the guard being confirmed. A watcher is running; the owed evidence is
one `delib.empty_completion` row from a real turn.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): the round lifecycle as a recipe-owned state machine (#371 design)

Joel 2026-08-16, after a full session of a driver getting lost: "It's way too hard to rig up.
Clearly." This writes the design down so the next agent inherits a paved road instead of tire
tracks.

THE DEFECT, stated exactly: a benchmark round is not a thing in the system, it is a RITUAL an
agent performs. The agent picks when to dispatch, picks the watch window, hand-queries probes to
learn what is happening, and when the session ends the process ends with it.

Every failure this session is downstream of that ONE fact, and they all have the same shape — the
question has no owner, so the driver guesses from an absence:

  is serving ready?     nothing owns readiness      → dispatched and hoped
  has it started?       nothing announces started   → read acts=0, called it stalled
  is this run alive?    liveness = a file mtime     → flagged a healthy run quiet
  is the round done?    nothing announces done      → never knew
  did my fix work?      no green/vacuous distinction → reported a vacuous green

Five instances of [[an-absence-is-an-unfinished-measurement]] in one session, by a driver that had
that lesson in its own guardrails. Not a knowledge gap — a missing owner.

THE SHAPE: staging → ready → working → grading → done, every transition an event from the
component that KNOWS (env builder, supervisor, card store, round entity) — never a timeout, never
a poll, never an agent's judgement. Every stage a ViewState on the one pipe humans and citizens
already read. Recipe is data, so the process is identical every round on every machine.

THREE LAWS: transitions announced by the knower; liveness is a pulse never a terminal artifact
(today's projection cannot distinguish silence from progress, which is its stated purpose);
an absence is never a state.

SUBSUMES #329(b) no-END, #442 readiness gate, #374 pulse, #425 in-room work, and the unbuilt RULES
half of [[recipe-is-content-type-plus-rules]].

Carries the acceptance test from BENCHMARKS-ARE-ADAPTERS-NOT-A-RUNNER.md plus one earned tonight:
can a fresh driver answer ready/started/stuck/done using ONLY queries — zero log reads, zero probe
archaeology, zero inference from an absence?

Build order is smallest-true-cause first; step 1 (pulse the run) consumes the
WorkspaceCycle::actions_taken seam c9ba5f9 already landed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(benchmark): the run PULSES while it runs — liveness stops being a terminal artifact (#371 law 2, #374)

First build step of ROUND-LIFECYCLE-AS-RECIPE-OWNED-STATE-MACHINE.md.

THE DEFECT: the run ledger was written ONCE per attempt, at settlement. For the entire attempt —
legitimately HOURS on a full SWE budget — `benchmark/runs` read `acts: 0` and a `last_activity`
frozen at run start. RUN_STALL_WINDOW_SECS is 20 minutes. So a HEALTHY first attempt is guaranteed
to read `quiet`/stalled, every single time, and the projection whose own doc comment says its
purpose is "silence must never be ambiguous with progress" was STRUCTURALLY unable to tell them
apart. Its stall window assumes artifact activity tracks act cadence (~4-6 min); no per-act
artifact write has ever existed.

MEASURED 2026-08-16: two dispatched solves read `acts=0, stalled=false` for ten straight minutes
while the driver watching them could not distinguish working from wedged — which is precisely how
a vacuous "no faults observed" gets reported as a green.

THE FIX: `select!` over the drive future and a 60s interval. No spawn, so the cycle stays BORROWED
— no 'static bound, no Arc juggling, no parallel allocator, and the pulse cannot outlive the work
it reports on. Each tick reads `WorkspaceCycle::actions_taken()` (the seam c9ba5f9 landed) — a
wait-free atomic load on the persona's own monotonic counter — and rewrites the running marker,
which moves BOTH `acts` and the mtime `last_activity_ms` folds from.

Cadence is well under the stall window (a live run can never age into `quiet`) and far above act
cadence (one small JSON write per tick, nothing else). Every field derives exactly as the detached
wrapper's `state: running` marker derives them, so a pulse can never contradict the marker it
refreshes. `None` run_id → no ledger → no pulse, correct: nothing polls a run that returns inline.

WHY THE COUNTER AND NOT A SEPARATE TALLY: it is the same monotonic counter perception renders to
her, so the board and her own proprioception cannot disagree — and it is the counter whose
capacity-bounded-ring sibling caused the retracted "they never act" premises on #390/#211.

Deployed + SHA-verified. LIVE PROOF OWED: a dispatched run showing acts CLIMB mid-attempt. Until
that row exists this is compiled-and-deployed, not confirmed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(swe): astropy env builds — a 1990s vendored zlib stubs out fdopen on every modern Apple SDK (#383)

THE FOURTH HEAD of #383, and the reason two dispatched rounds died at env-build TONIGHT even
though #2329's jinja2 + build-requires fixes are both merged and in this tree. Not pyerfa, not
Cython, not Python 3.11 — I guessed all three before reading the error.

astropy vendors cfitsio, which vendors an ancient zlib. `cextern/cfitsio/zlib/zutil.h:140`:

    #if defined(MACOS) || defined(TARGET_OS_MAC)
    #  define OS_CODE  7
    #    ifndef fdopen
    #      define fdopen(fd,mode) NULL /* No fdopen() */

`TARGET_OS_MAC` means "some Apple platform" on every modern SDK — it does NOT mean "classic Mac
OS", which is what this zlib was written to test. So the branch fires, `fdopen` is macro-replaced
by `NULL`, and the SYSTEM header's own declaration

    FILE *fdopen(int, const char *)      →      FILE *NULL(int, const char *)

becomes `error: expected identifier or '('` inside `<stdio.h>`, thousands of lines from anything
astropy wrote. (The adjacent `'OS_CODE' macro redefined` warning is the same branch firing.)

FIX: the guard is `#ifndef fdopen`, so pre-defining it is the entire repair. `-Dfdopen=fdopen`
makes the guard FALSE — the NULL stub is never emitted — and the macro is the identity, so every
real call still compiles to `fdopen`. No source patched, nothing stubbed, nothing renamed, and a
repo that doesn't vendor this zlib never notices the flag.

POSITIVE + NEGATIVE CONTROL against the real staged checkout, both run before committing:

    cc -c -I<checkout>/cextern/cfitsio/zlib  →  error: expected identifier or '('
                                                error: expected ')'
    cc -c -Dfdopen=fdopen -I<same>           →  clean, exit 0

Placed in ERA_CFLAGS beside its three siblings rather than a per-repo table, because it is not an
astropy fact — it is an ERA fact (old vendored C vs a modern SDK), same shape as the others: the
compiler is HARNESS, the C is SUBJECT, and the subject built fine on the compilers of its day.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(governor): shed CAPABILITY, never starve the window — model choice was floored at bare survival (#438-class)

Glass-boxed live on the M5 2026-08-17: a 27B served at usable_gb=5 with
served_window=2048 against a MEASURED demand_window=63817. Every SWE act ran
against a context that could not hold the task statement — the "machine is
allowing sludge" Joel reported, and the arithmetic behind ~4 acts/hour.

The defect was an inconsistency INTERNAL to plan_serving. Two floors, two
different standards:

  lane COUNT  -> BOOTSTRAP_WORKING_SET (16384, "one full turn")
  model CHOICE -> MIN_SERVE_CTX        (2048, bare survival)

The lane loop already refuses to add a slot that cannot hold a full turn
(1 lane @ 30k beats 2 lanes @ 2k), then falls back to .unwrap_or(1) and calls
it "honest starvation, surfaced downstream" — while the MODEL is never
reconsidered. Shedding a lane and shedding capability are the same move for
the same reason; only the first was implemented. So `fits_one_lane` crowned
the most capable model that cleared a TRIVIAL bar and let the window collapse
to it. A model that fits only at 2048 is not more capable on this host — it is
unusable on this host.

Viability is now tested at the same "one full turn" standard the lane floor
uses, with a documented degrade: if NO candidate clears it, fall back to the
old MIN_SERVE_CTX bar so a genuinely tiny host still serves something rather
than nothing (honest starvation is then real, not a selection artifact).
Deliberately the STABLE bootstrap constant, not the moving measured p95 —
coupling model CHOICE to a jittering demand signal is the 718-replan flap that
wedged three benchmark runs.

This ran on EVERY node, so a grid of peers would each independently crown its
biggest technically-holdable model and starve its own window, with no single
node's numbers looking anomalous.

LIVE, deploy-verified: 27B/2048/bound_by=host-fit -> 14B/16384/bound_by=demand,
lanes 1 -> 4. bound_by flipping to `demand` is the signal: the plan now meets
the working set instead of being cut by the host.

Tests: model_choice_sheds_capability_rather_than_starve_the_window pins all
three arms — the starve case, a NEGATIVE CONTROL that a roomy host still picks
the 27B (this fix must not silently downgrade capable boxes), and the degrade
fallback. 27 serving_plan / 139 serving / 178 capacity green.

Also repaired stable_keeps_incumbent_when_upgrade_lacks_headroom, whose fixture
had encoded the old bar: with pair() at 10GB, big was "viable" only on 184MB of
KV, so "fresh would pick big" meant a 2048-token 9GB model. Given a local
fixture where big genuinely clears a full turn (19.5 <= 20) yet still fails the
0.9x switch-up headroom bar, so the test asserts what it always meant to.

KNOWN RESIDUAL: selection tests weights + kv_at(ctx) against raw usable_bytes
while window_for sizes against `effective` (minus co-consumer headroom) and
subtracts compute buffers, so the two floors are near-consistent, not identical
(observed 16025 vs 16384). The 8x collapse is gone; unifying the last 2% is a
follow-up.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): context is a capability axis — the governor learns the window but not the CHOICE (Joel 8/17)

Joel: "Context windows are as important as model size. It seems 16-20k is bare
minimum for decent activities. Ideally the governor learns."

Captures the design rather than rushing it into plan_serving, which is the most
flap-prone function in the tree (718 replans, three wedged benchmark runs).

THE CLAIM: delivered capability is f(params, served_window) and the planner
models only params. capability_rank is a scalar keyed to model identity, so a
27B is "more capable" than a 14B even when the host can serve the 27B only 2048
tokens. That shipped as the live defect fixed in 03c890b.

WHAT IS ALREADY RIGHT, and must not be rebuilt: working_set.rs is a good
learning loop whose hard problem is solved. It records DEMAND not USAGE — the
counterfactual "what this turn would have used with no budget", including
grounding contributions assembly dropped — explicitly avoiding the
thermometer-inside-the-thermostat trap where a p95 of what-was-sent re-derives
its own clamp forever. Peak not average. Persisted. Passed as a parameter. The
live demand_window=63817 IS that module working correctly.

THE ACTUAL GAP: one learned signal, three decisions, two deaf. The window is
learned; lane count and model choice both use hardcoded BOOTSTRAP_WORKING_SET —
a constant whose own doc says it "was never meant to survive", and which sits at
the BOTTOM of Joel's 16-20k band, identically for a chat turn and a SWE turn.

WHY THE CONSTANT IS THERE AND WHY IT DOESN'T FORBID LEARNING: the anti-flap
argument is against driving a structural, expensive-to-change decision from a
fast jittering signal. It is not against learning. Two time constants: fast
measured demand sizes the window (cheap, built, correct); a slow hysteretic
learned floor drives model choice and lane count (expensive, so margin band +
dwell time + hard clamp). Flapping is a property of the update rule, not of
learning.

PROPOSED, NOT BUILT: (1) capability_rank goes 2-D — rank by delivered
capability, since the current most-capable-that-clears-a-full-turn gate is a
correct approximation but cannot express "14B at 60k beats 27B at 20k";
(2) the floor becomes learned + slow, with BOOTSTRAP_WORKING_SET surviving as
the floor OF the floor, not the value; (3) the floor becomes per-ACTIVITY —
recipes are already data (#433) and "recipe = content-type + RULES" makes the
minimum useful window recipe-owned.

Includes acceptance tests (incl. an anti-flap test pinned as a test, not
asserted in prose) and the de-hardcode smell: a new constant beside
BOOTSTRAP_WORKING_SET is a third way to express a floor — the shape the guard
already caught once as FLOOR_TOKENS (#411).

BLOCKING OBSERVATION recorded for whoever picks this up: delib.generate emits
ZERO probe rows, so per-generation latency and tok/s are unreadable and every
throughput question here needs 20-minute black-box sampling. An unmeasurable
governor cannot be a learning one (#441).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): my empty-completion guard was standing in front of the #181 recovery — reasoning-bearing empties are not faults

REGRESSION I INTRODUCED in ce82f00, caught by its own test suite.

That guard faulted on "empty text + no tool call + not ToolUse" — which is the
EXACT precondition of the two recovery paths immediately below it:

  persona.act.reasoning_lift — a tool call sitting in the reasoning tail gets
    lifted out and EXECUTED (json_in_prompt_tools::parse_tool_calls over the
    reasoning channel).
  persona.act.think_only    — #181's teacher sentinel: she spent the whole
    generation inside <think>, so route the #159 reported-never-executed
    mechanism and let drive_to_settle hand her another generation that starts
    from her own conclusions (the reasoning is already in working memory).

Faulting first made BOTH unreachable. Measured live 2026-08-17: 40
delib.empty_completion faults against 87 persona.turn.start while three SWE
runs sat at the SAME act count for 1,357 seconds. Every one of those turns had
15k+ chars of reasoning and finish_reason: length at exactly 4096 output tokens
— i.e. the shape the recovery exists for. The machinery was already built and
correct; I put a dead end in front of it.

FIX: fault ONLY when nothing is left to recover — the lane returned genuine
void (no text, no reasoning, no call), or she has no tools for the sentinel to
teach through. A reasoning-bearing empty falls through to the lift/think-only
owners. The guard's purpose is preserved: an empty is still never read as
chosen silence, it is just routed to the component that can act on it.

Restores 2 tests that had been RED since ce82f00 and that I shipped without
running — think_only_turn_routes_the_teacher_sentinel_not_empty_speak and
empty_content_with_reasoning_tool_intent_lifts_the_final_call. Both name this
exact contract; both now pass. 62/62 deliberation tests green.

NOT YET LIVE-PROVEN. Deployed and unit-green, but the owed evidence is a real
reasoning_lift or think_only probe row with empties falling — measurement in
flight. Recorded here so the claim is not read as stronger than it is.

ALSO CORRECTED, and NOT shipped: completion_budget_for is window/4, so a 16k
window caps generation at 4096 and a thinking model exhausts it inside <think>.
Raising it to window/2 broke prompt_plus_completion_cap_never_exceeds_the_
served_window (prompt 525 + completion 512 > window 1024) — the prompt sizer
overshoots its own target by ~13 tokens, which /4 had slack to hide. The
OVERSHOOT is the defect, not the fraction; shipping /2 on top of it would push
prompt+completion past n_ctx and 500 every turn with context-shift off. Left
at /4 until the sizer is fixed. Bounding the reasoning channel
(--reasoning-budget) was considered and REJECTED: it lobotomizes the model to
fit a fraction we invented (Joel, 2026-08-17).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): the reserve must YIELD to the incompressible prompt floor — why raising window/4 is a refactor, not a constant

Records the measured blocker on the #181 output starvation so the next attempt
does not repeat either of the two wrong fixes.

MEASURED: completion_budget_for = window/4, so a 16k window caps generation at
4096. A reasoning model spends output on thinking, exhausts the cap inside
<think>, and never reaches the tool call — 7 of 20 captured turns at
finish_reason: length, output_tokens: 4096 exactly, ~15k reasoning chars, empty
text, zero tool calls.

WRONG FIX 1, rejected on Joel's instruction: --reasoning-budget. Capping <think>
shrinks the model to fit a fraction we invented. Their thinking is the product.

WRONG FIX 2, tried and reverted: window/2. Breaks
prompt_plus_completion_cap_never_exceeds_the_served_window, the invariant that
keeps prompt+completion under n_ctx. With context-shift off that is a 500 per
turn — every citizen muted. Trading a 35% empty rate for a 100% mute rate.

THE ACTUAL DEFECT, from reading prompt_view_within: the budget derivation
(window − reserve − tool_tokens) is correct. What breaks is that three sibling
tests pin content that must survive budget pressure unconditionally — held work
card, most recent burst, newest message. Those are INCOMPRESSIBLE FLOORS. Grow
the reserve and the budget drops under the floor; the packer admits the
mandatory content anyway and overshoots (prompt 525 + completion 512 > 1024).
The overshoot is the floor correctly refusing to compress. Holding the reserve
FIXED is the error.

FIX SHAPE: reserve = min(desired_share, window − mandatory_floor). Invariant
then holds at every window, including the synthetic sub-MIN_SERVE_CTX windows
the tests use and production never serves, while the share stays generous at
real 16k+ windows where the floor is hundreds against thousands.

NOT A ONE-LINER, and that is why this is a doc and not a patch: the dependency
is circular (reserve → budget → packing → floor → reserve). The floor must be
computable before the reserve is chosen — hoist the mandatory-section
measurement ahead of budgeting, or two-pass size-then-resize. Sequence recorded:
hoist the floor, make the reserve yield, THEN raise the share, and re-run all
four prompt_shaping tests at both a synthetic small window and a realistic 16k
one. Those four tests are the only thing between a generous reserve and a 500 on
every turn; none of them may be weakened to make the change pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(bench): ENFORCE the gold gate — an env that cannot score its own gold patch disqualifies itself (#380 keystone)

The spine check RAN and enforced NOTHING. `benchmark/swe-grade --gold` has always
substituted `instance.patch` as the candidate and graded it, so the mechanism
existed. But it returned a bare `resolved: false`, which downstream is
byte-identical to a citizen's capability zero. The `gold` param's own doc states
the requirement — "It MUST resolve — if it does not, the environment is wrong
and no other number from it means anything" — and that sentence was addressed to
a human and enforced by nobody.

WHY THIS IS THE KEYSTONE FOR EVERY NUMBER WE REPORT. Without it a failure has
two indistinguishable causes: the patch was wrong, or the environment cannot
score a correct patch at all. Measured on this box 2026-08-17 (build fc8964b,
deploy-verified): a 2019-era django env carries pytest 8.4.2, and this module's
own notes record era suites importing pytest internals modern pytest deleted
(flask 2.2: `from _pytest.monkeypatch import notset`). So an unknown fraction of
our zeros are harness artifacts tallied as capability — noise with a number
attached. That is why #383's 114/300 and #380's era drift cannot be told apart
from model failure by reading scores.

`swe_bench::gold_gate` is a THIN caller over `grade(.., Some(&instance.patch))`,
deliberately not a parallel scorer: it must exercise the exact clone → apply →
test path a real attempt takes or it proves nothing about that path. A second
implementation agreeing with itself is the classic dead instrument. What it adds
is the enforcement: on a non-resolve it stamps `verdict.error` naming the gate,
the f2p/p2p counts, and the era-dep suspects to check. `error` is contractually
an ABSENCE and "must never be tallied as a failed attempt" (SweVerdict::error),
so the disqualification propagates through every existing consumer with no
further wiring.

The command's gold arm now routes through it, so there is ONE path and every
caller inherits the labelling — not a second spelling of gold grading.

Explicitly NOT conflated: `gate_ok == false` means FAIL_TO_PASS already passed on
the pristine tree (the instance carries no bug here). That is a different fact
from a broken environment and the doc says so.

NOT era-pinning pytest in this commit. That fraction is deliberate and
documented at swe_bench.rs:692-706 ("harness is deliberately MODERN"), with the
breakage it causes documented at :907. Inverting a decision with a stated
rationale is Joel's call; this commit builds the instrument that MEASURES which
envs it breaks, which is the prerequisite either way.

Verified: cargo check clean. Live gold-gate run against a known-gradeable and a
suspect env is the owed proof and is next.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): grade django from CANONICAL test ids, not from prose (#383 root cause)

The gold gate (943b8a2) caught django-10914 failing its OWN gold patch:
FAIL_TO_PASS 0/1, PASS_TO_PASS 35/40, reported as "REGRESSION — your changes
BROKE 5 test(s)" while the quoted output showed all five passing `... ok`.

ROOT CAUSE, in `parse_django_report`: it required `" ... "` AND `" ("` on the
SAME line. unittest puts the outcome on the id line ONLY when a test has no
docstring; with one it prints two lines and the `... ok` lands on the SECOND:

    test_skip_if_db_feature (test_utils.tests.SkippingTestCase)
    Testing the django.test.skipIfDBFeature decorator. ... ok

Both lines fell through the `continue`s — the id line has no `" ... "`, the
docstring line has no `" ("` — so every docstringed django test was recorded
NOWHERE, and absent-from-map reads downstream as not-passed. The 5 "broken" were
the 5 docstringed ones. django is 114/300 of Lite, so django scores were never
measuring django, and every django zero on record is retro-actively
uninterpretable.

THE FIX IS NOT A BETTER PARSER. I first extended the state machine to stitch the
two-line form; Joel called it correctly — "fragile, needs cleaner fixes". It is,
because unittest's verbose output is a RENDERING, not a data format: docstrings
can contain " ... " and " (", django ≥4.1 changed the class-path shape, and every
one of those is a way to mis-attribute silently. Mis-attribution here does not
look like a bug; it looks like a citizen who failed.

So django is now graded from CANONICAL ids. `install_django_json_runner` drops a
`DiscoverRunner` subclass into the clone's `tests/` dir; `--testrunner` selects
it; it emits one `CONTINUUM_TEST {"id": ..., "ok": ...}` row per test keyed by
`test.id()` — the id unittest itself uses. No line shapes, no docstring
ambiguity, no version drift. The dataset's `method (module.Class)` spelling is
derived from the canonical `module.Class.method` by deterministic surgery, not
guessed from output.

Skips and expected failures are PASSES, unexpected successes FAILURES — the same
rule as the prose path, now expressed once in `django_outcome` (it was inlined
twice, which is how a `skipped` becomes a pass in one shape and a non-outcome in
the other).

FALLBACKS ARE LOUD, NEVER SILENT: if the runner cannot be installed, or emits
zero rows (django too old for --testrunner, import error, crash before any test),
we fall back to the prose parser AND warn. A silent fallback that scores is
indistinguishable from one that lies.

`parse_django_report` is KEPT as that fallback, with the two-line handling, since
it is now the degraded path rather than the only path.

Verified: cargo check clean. Live gold-gate re-run on django-10914 is the owed
proof and is next — the same instance whose failure produced this diagnosis, so
the fix is falsifiable by the evidence that motivated it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): select django's JSON runner through SETTINGS — runtests.py has no --testrunner (#383)

The canonical-id grader (13fd357) was correct about WHAT to read and wrong about HOW to
ask for it. It passed `--testrunner=continuum_json_runner.JsonRunner` to
`tests/runtests.py`. That flag does not exist in ANY django era — runtests.py reads
`settings.TEST_RUNNER` and only defaults it when unset (verified in-tree at 1.11, 2.2,
3.2, 4.2, 5.2 and main: the same three lines throughout).

An unknown flag there is not ignored. argparse rejects the whole invocation before a
single test runs, so the live gold gate on django-10914 came back in 4.4 seconds with
`PASS_TO_PASS passes 0 of 40 on the PRISTINE tree`. The fix I shipped to stop
mis-attributing django tests made django strictly less gradeable than the prose parser
it replaced.

Fix: install a settings module beside the runner —

    from test_sqlite import *
    TEST_RUNNER = "continuum_json_runner.JsonRunner"

— and pass `--settings=continuum_json_settings` instead of `--settings=test_sqlite`. Both
files are pure additions to the clone; django's own test_sqlite stays untouched and still
supplies every database/hasher setting, so the shim cannot drift from whatever the era's
suite settings happen to be. The invocation now differs from the plain one in exactly one
argument, which is what the new test asserts.

WHAT WORKED, and is worth keeping: the zero-rows fallback. `run_tests` warns and falls
back to `parse_django_report` when the JSON runner emits nothing, and that is the only
reason a broken invocation surfaced as an env fault instead of 40 capability failures.
A silent fallback here would have read as a citizen's zero.

Mechanism proven live in the 2019-era env BEFORE this commit — the settings shim run by
hand emits 30 canonical rows (`CONTINUUM_TEST {"id": "file_uploads.tests.FileUploadTests
.test_base64_upload", "ok": true}`) where the flag emitted zero. Those hand-written files
were then deleted so the owed gold-gate re-run exercises the install path, not my copies.

15/15 swe_bench tests green (metal,accelerate).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): django's dataset ids include DOCSTRINGS — the runner must emit its own (#383)

Gold gate on django-10914 after the settings seam: FAIL_TO_PASS 1/1 (was 0/1),
PASS_TO_PASS 38/40 (was 35/40), gate_ok true. The two remaining misses were not tests
and not env — they were SPELLING:

    "An exception is setUp() is reraised after disable() is called."
    "assertRaisesMessage shouldn't interpret RE special chars."

Those are the dataset's own PASS_TO_PASS entries, verified by reading the cached Lite
JSON: 2 of django-10914's 98 p2p ids are docstring prose with no test id in them at all.
The cause is upstream and structural — SWE-bench harvested django ids from unittest's
verbose log, and unittest prints a test's DOCSTRING in place of its id when it has one.
So a canonical id, however correct, can NEVER resolve those rows.

Fix: the runner emits the docstring alongside the id (`test.shortDescription()`, the same
string unittest itself renders), and the parser registers THREE spellings for one outcome
— canonical id, unittest rendering, docstring. Docstrings are not unique, so they are
AND-folded (a docstring shared by a pass and a fail reads as a fail) and never overwrite a
real id. Only the test object knows its own docstring; having the runner report it is what
removes the guess, which is the same reason the canonical id came from `test.id()`.

CORRECTION to what I wrote on 13fd357: I described the old prose parser as
"mis-attributing" docstringed tests. It DROPPED them. For a docstringed test the id line
carries no `... ok` suffix and the docstring line does not match the `name (class)` shape,
so neither line produced an entry. The parser was not confused about which test passed; it
had no row for that test at all. That distinction matters because it is why the docstring
must be emitted as DATA rather than recovered by a better regex.

16/16 swe_bench tests green (metal,accelerate). Live re-run of the gold gate is next and
is the falsifiable claim: p2p 40/40 and resolved=true, or the docstring path is not the
whole remainder.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5 <[email protected]>
joelteply added a commit that referenced this pull request Aug 20, 2026
…#441) (#2339)

* fix(ids): UUIDs are not strings — mint real ones, and stop typing ids as text (#274/#396)

Joel, 2026-08-13: "Always use uuid and never corrupt them with random prefixes" and
"UUID's are NOT strings. If you're using strings for id you are writing slop."
Both landed on code written minutes earlier, and the grep that followed found the
same defect older and wider than my one file.

Three fixes, in order of how badly they were wrong:

1. The four shipped recipe ids were hand-drawn patterns (c0de0001-0000-4000-...),
   a name wearing a UUID's costume — readable, collidable, and fake. Replaced with
   genuine v4s in both the authored JSON and the `shipped::` constants, written
   grouped (0xfed332c3_383c_45bb_...) so the two are checkable by eye.

2. comms::{MessageId, CorrelationId} were `String` newtypes. `MessageId::new("msg-1")`
   let any caller invent a namespace that collides with every other caller's. Both
   are now `Uuid`: MessageId::new() MINTS (no caller-supplied form exists), and
   CorrelationId::of_exchange(id) states the derivation the old
   `CorrelationId(id.0.clone())` left implicit. Still distinct TYPES — the compiler,
   not a naming convention, is what stops one being passed as the other.

3. EndpointId is deleted. Its values were `EndpointId::new("browser")` and
   `("rust-core")` — a client-kind label standing in for an identity, and with it
   the assumption that the web client is a distinguished endpoint. It is one client
   among many (mobile, SDK, TUI, another node's core). TransportEnvelope.source and
   .target are now PeerId, the substrate's one actor identity per identity/mod.rs.
   Zero callers outside comms/mod.rs; the stale generated binding goes too.

Also closes the on-disk authoring hole the required `id` field opened: a recipe file
that names no id now gets one DERIVED from its purpose (RFC 4122 v5 under a frozen
namespace), so "author a file, zero code" keeps meaning zero code — no uuidgen — and
every node that loads the same file agrees on its identity with nothing to reconcile.
A recipe that DOES carry an id keeps it verbatim.

Tests: comms 23 pass (envelope wire shape now asserts ids round-trip as their own
UUIDs; minted_message_ids_are_unique pins the collision fix), experience 43 pass
including the previously-failing an_experience_authored_on_disk_needs_no_rust.

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

* docs(CLAUDE.md): headless Rust core is the system — Node is ONE client, not the deploy path

Joel, 2026-08-13: "Headless rust period. No need for node to run everything except
for the web interface which is one of many, including mobile apps/sdk." — and then,
because I kept treating the correction as a code-only matter: "Fix these severe
misunderstandings ... regardless of where they are."

This file is where the misunderstanding REPRODUCES. It is loaded into every agent
session, and it opened with "EVERY TIME YOU EDIT CODE: Run `npm start` (MANDATORY)"
under `cd src` — a directory that no longer exists — plus "ALL Rust binaries MUST be
built via npm start". A fresh agent under amnesia reads that and concludes Node runs
the system. It doesn't, and `continuum --help` has been saying so in its own first
line the whole time: "build + run the headless Rust core".

Rewrote the CRITICAL WORKFLOW section around what is actually true, and swept the
other 11 Node-as-deploy claims scattered through the file:

- The core is Rust and boots with no Node. Node builds the WEB desktop, which is one
  client among several (mobile, SDK, TUI, MCP, another node's core over the grid).
  Named the consequence, because it already cost us: a feature that lives in a client
  exists only for that client — how voice ended up web-only with every other citizen
  structurally mute (#58). Behaviour goes in the core; clients render.
- The deploy path is `continuum reboot` (Rust build + relaunch + running-SHA verify),
  with `deploy-verify` and the version trio called out — that verification exists
  because a reboot once shipped a stale binary and reported success (#194).
- `cargo build` stays discouraged for the RIGHT reason (a hand-built binary exists
  only on your machine, and a fresh clone must work with no manual steps, #291) —
  not the old implication that Rust must be built through npm. `cargo check` is
  named as the correct type-check-while-you-work tool, with the shared CARGO_TARGET_DIR.
- `npm run build:ts` now says what it actually covers: the web client, and nothing
  about whether the core compiles.
- Flagged `./jtag` inline as the legacy Node CLI. Left the invocations that follow,
  since their command NAMES are still accurate — it is the driver that is stale.

No code change; the one surviving "npm start" is the sentence warning you off it.

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

* fix(cli): `uu` is the alias — `cu` is UUCP, and every harness defaulted to a binary that does not exist

Joel: "Cu conflicts with some Unix program. Fix for all cases including windows"
and "It's a bug Claude" — it is, and worse than doc drift.

`cu` is /usr/bin/cu (UUCP call-unix) on every Unix. `uu` — the double-U of
contin-UU-m — is THE official short alias, and start-server.sh has installed
exactly that (plus a squatter guard) since 2026-08-01, with a comment naming this
very collision. Nothing in the tree installs `cu`. But the REFERENCES never
followed:

- Six benchmark harnesses defaulted to `~/.continuum/cache/cargo-target/{release,debug}/cu`.
  Neither file exists — the only built CLI is `release/continuum`. So the default
  resolved to nothing and every default-args run died at the first invocation.
  matrix.py even carries a comment about this exact class of failure biting once
  before (2026-07-22, stale debug-only default silently no-opping the sweep).
- Fixed by RESOLVING rather than renaming: a shared `_resolve_cli()` prefers what
  is actually installed on PATH (`uu`, then `continuum`) and falls back to the
  release build — so it works from a fresh clone, an installed box, or a dev tree,
  on any platform, instead of hard-coding one machine's layout.
- Flag renamed `--cu` → `--uu` with all in-repo call sites updated
  (sweep_all → matrix → headtohead → preflight_gpu chain).

Also swept 53 `cu <command>` occurrences in docs, Rust comments, and generated-TS
doc comments to `uu`. Left the ones that are ABOUT the collision (memory-bridge
README's "never bare `cu`", WAKEUP-AND-JOIN's rename note) — those are correct as
written, and legacy/ stays quarantined.

README dev section reworked in the same pass: the boot path is `continuum start` /
`continuum reboot` / `continuum ping`, with Node named as what it actually is —
the web client's build dependency, one client among mobile/SDK/TUI/MCP, not the
thing that runs the system.

Verified: all six harnesses compile (py_compile), cargo check clean, zero
`target/{release,debug}/cu` paths left in the tree.

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

* fix(core): the last Python in the runtime path — one vestigial, one silently swallowing the job

Joel: "Fix all nodejs and python dependencies that are breaking our headless rust
core ... we must find all smell all the time and never ignore it."

AUDIT RESULT FIRST, because one half is good news:

  Node spawns from the running core: ZERO. `Command::new("node"|"npm"|"npx"|
  "deno"|"bun")` has no occurrences anywhere in continuum-core. The core is
  genuinely headless Rust at runtime; Node exists only to build the web client.

  Python spawns from the running core: FOUR sites, and neither kind was honest.

1. THREE were vestigial and were hiding untested code. `file_engine.rs` had three
   `#[test]`s opening with `if Command::new("python3").arg("--version").output()
   .is_err() { return; }` — a skip-guard from when the syntax gate shelled out to
   `python3 -m py_compile`. That interpreter is GONE: the production path is
   `code::syntax::validator_for` → `unbound_calls`, pure Rust. So on any box
   without python3 — a CI runner, a fresh clone — three tests reported PASS while
   asserting nothing at all. Guards removed; all 55 file_engine tests pass without
   an interpreter present, which is the proof they never needed one.
   Also corrected the doc on `introduced_undefined_calls`, which still told the
   reader the analysis returns None when there is "no python". There is no python.

2. ONE is a REAL runtime dependency, and it was failing silently. `forge/start`
   spawns `python3 <alloy_executor>` — a script that lives in the SIBLING
   sentinel-ai repo, which a fresh clone of continuum does not have. When
   `find_alloy_executor()` returned None the handler used pid 0 and wrote
   `state: "queued"` — indistinguishable from a job legitimately waiting its turn.
   So on every machine that had only cloned this repo, `forge/start` returned
   SUCCESS for work that nothing would ever run. Now it fails loud, names the
   missing script, says where to get it, and states plainly that the job was NOT
   queued. The dependency itself is still there — excising it to Rust is #52/#99
   — but it can no longer pretend to have worked.

The pattern in both: a Python dependency that had already been removed or had
never been satisfiable, still shaping behaviour through a stale guard and a
fallback. `[[fallbacks-are-illegal-fail-loud]]`.

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

* feat(identity): PersonaRef vs PeerId — a reference is not an identity, and the compiler now knows

Joel: "UUID's are NOT strings … Well defined and named structs by reference must be
used." Chasing that through persona_id turned up something sharper than the count.

THE FINDING. `PersonaWorkspaceRegistry::resolve_persona` exists specifically to close
what its own doc calls "the loose-`String` id boundary … the defect class that fed a
dead id to a doomed eval." It has SEVEN call sites. SIX are its own tests. ONE is
production (eval.rs). Against 55 `persona_id: String` fields. The check was correct
and essentially nothing called it — a correct check nothing calls is nastier than a
missing one, because it reads as covered.

Nothing forced the call, because both sides were `String`.

THE FIX — two types, one door:
- `PersonaRef` (new, in identity/): what a CALLER writes — full UUID, 8-char short-id,
  or name. Explicitly NOT an identity. Its only accessor is `as_str()`; there is no
  `as_peer_id()`, because a name is ambiguous, mutable, and meaningless without a
  roster.
- `PeerId` (existing canonical actor identity): what everything downstream holds.
- `resolve_persona(&PersonaRef) -> Result<PeerId, _>` is now the ONLY bridge. Taking
  the newtype rather than `&str` is what makes resolution unskippable.

`From<PeerId> for PersonaRef` exists (an identity is always a valid reference to
itself); the reverse deliberately does not — it requires a roster.

Wire shape is unchanged: `#[serde(transparent)]` over the same string callers already
send, so no client, recipe, or stored payload changes. Short-id and name PX (#161)
keeps working — that ergonomics is the whole reason a reference type has to exist
separately rather than everything becoming a UUID.

Converted, types pushed DOWN rather than laundered at the seam:
- `CognitionEvalParams.persona_id` → `PersonaRef`
- `restore_persona_workspace(&PersonaRef)` (was `&str`)
- `append_failed_ledger(&PersonaRef, …)` (was `&str`)

HELD, and stated rather than fudged: `CognitionEvalResult.persona_id` stays `String`.
The struct derives `Default` across 21 fields and a persona reference has no sensible
default — an empty one is a nonsense value that reads as a real answer. The real fix
is splitting the fire-and-poll HANDLE from the completed RESULT (a handle knows only
the requested ref; a result knows the resolved id), which is its own slice. Inventing
a default to satisfy the type checker is the `unwrap_or` reflex: compiler quiet,
runtime wrong. The reason is recorded at the field.

Tests: persona_workspace 10, eval 22, identity 23 — all pass; full lib test build clean.

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

* refactor(memory): the memory layer takes PersonaRef, not loose text — 21 sites

Second slice of the id-typing migration. All ten `commands/memory/*` params plus the
`MemoryManager` API they call now carry `PersonaRef` instead of `String`/`&str`:
append_memory, append_event, load_corpus, has_corpus, get_corpus, multi_layer_recall,
consciousness_context, persona_db_handle, hydrate_corpus_if_missing.

Types went DOWN into the layer rather than being unwrapped at each call — the whole
point of the previous slice. `.as_str()` now appears only where the value is genuinely
being USED as text (a map key, a `starts_with` shape check, a directory handle), never
to satisfy a signature one call later.

Two `Default` derives removed (`ConsciousnessContextParams`, `LoadCorpusParams`)
rather than giving `PersonaRef` a default. No caller used `::default()` on either, and
an empty persona reference is a nonsense value that reads as a real answer — same
reasoning as the eval result field held in the previous commit.

What this makes visible, and does not yet fix: these commands still never RESOLVE.
They accept a reference and hand it straight to the storage layer as a key, so a name
or short-id reaches the DB unresolved. That was invisible while everything was
`String`; it is now legible in the signatures. Wiring `resolve_persona` into the memory
command path is the next slice (#164/#396).

Tests: memory 219, rag 150 — all pass. Full lib test build clean.

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

* refactor(commands): persona params carry PersonaRef — agent/solve, persona/*, cognition/observe

Third slice. Seven more command param structs stop typing a persona reference as
`String`: agent/solve, persona/identity/{get,set}, persona/instances/{get,despawn},
persona/wall/pin, cognition/observe (params + the `assemble` signature + its `Meta`,
so the type is consistent through the result rather than converted on the way out).

Same discipline as the memory slice: `.as_str()` appears only where the value is
being USED as text — `id_resolve::resolve` takes a `&str` by design because it also
serves rooms and cards — never to satisfy a signature.

Running total across the three slices: 39 persona params + the memory API + the
resolver itself. `persona_id: String` is down from 55 to 16 in the crate, and every
one that remains is an internal struct holding an already-resolved id (those want
`PeerId`, the next slice) rather than an unresolved caller reference.

Tests: full lib test build clean, commands suite passes.

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

* refactor(rag/introspect): last persona PARAMS typed — and the RAG source path carries it down

Fourth slice. `CognitionTraceParams`, the four other introspect params,
`CognitionReplayParams` + result, `RagComposeRequest`, and `DatasetFromTurnsParams`
now carry `PersonaRef`.

The RAG one went two levels deep rather than stopping at the param: `load_source`,
`load_memory_source`, and `load_consciousness_source` all take `&PersonaRef` now, which
deleted the two `&persona_id.into()` conversions the memory slice had left at those
call sites. That is the shape to aim for — when the type reaches the bottom, the
adapters in the middle disappear rather than accumulating.

`persona_id: String` in continuum-core: 55 → 8. Every remaining one is an internal
RECORD (memory/types, should_respond's AIDecisionContext, live/types, projection,
shell_types, ai/types, sentinel) holding a value copied from a param.

Those are deliberately NOT converted to `PeerId` yet. They hold whatever the caller
sent, and nothing on those paths resolves — typing them as an identity today would
assert something the code does not do, which is worse than leaving them `String`.
They become `PeerId` in the same slice that wires `resolve_persona` into those paths,
not before (#164/#396).

Tests: replay 3, rag 18, full lib test build clean.

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

* fix(test): 5 supervisor tests have been panicking since #398 slice 3 — the stub's premise expired

`StubAircCitizen::subscribe_all_rooms` was an `unreachable!()` justified by a comment
that said no test drives it. That was true when written and stopped being true at
bf11a66a7 (#398 slice 3), which gave `PersonaSupervisor::materialize` a
`subscribe_all_rooms` call to wire the doctrine/wall cache invalidators. Every
supervisor test that materializes an adapter has been dying in that panic since —
5 of the 10, and they only surface on a FULL-suite run, which is how they sat unnoticed.

Found while verifying my own id-typing slices: full suite came back 7073 passed /
5 failed, and the first question was whether I caused it. I did not — the diff of my
five commits touches `commands/persona/*` only, never `persona/supervisor.rs` or
`persona/airc_citizen.rs`, and `git log` on those two files points at #398.

Fix: return `AircError::Transport` instead of panicking. This is NOT a fallback —
the caller already handles that exact case explicitly (keeps both sources uncached,
"correct, just slow", logs loud), so the tests now exercise the real degradation
branch rather than aborting, and a stub still never pretends to hold a live stream.
An empty stream WOULD have been the fallback: it would have looked like a working
subscription that silently never invalidates.

Comment rewritten to state what is true now, including why the old assertion was
right when it was written. An assertion that outlives its premise is worse than no
assertion — it reads as a guarantee.

persona::supervisor: 10/10 pass.

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

* fix(test): pin the stub's REFUSAL contract — the old test asserted the panic I removed

`stub_subscribe_panics_loudly` existed to prove the `unreachable!()` fired, so removing
that panic left the assertion failing for the right reason. Rewritten to pin what the
contract actually is now:

  Err(Transport) — required
  Err(anything else) — fail (the caller branches on Transport specifically)
  Ok(stream) — fail LOUDEST, because that is the real fallback: a stub handing back a
               stream looks like a live subscription that silently never invalidates

Matched rather than `expect_err`d because `FilteredEventStream` is not `Debug`.

FULL LIB SUITE NOW GREEN: 7078 passed, 0 failed, 42 ignored. Before this session's
last two commits it was 7073/5 — five supervisor tests panicking since #398 slice 3,
only visible on a full run.

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

* test(identity): CI guard — a String-typed identity field must be DECLARED, or the build fails

Joel: "eliminate all smell or you will copy it." That is literally the mechanism —
a model reading this tree learns its conventions FROM it, and `persona_id: String`
was 55 sites teaching that ids are text. I did exactly that this session: minted
`c0de0001-…` fake UUIDs because fake-looking ids were already normal here. Prose in
CLAUDE.md does not stop that. A failing test does.

Three tests in identity/mod.rs, running on every PR via the existing
`cargo test -p continuum-core --lib` workflow (no skip pattern matches them):

1. `every_string_typed_identity_field_is_declared` — walks src/, finds any
   `<identity-name>_id: String | Option<String>` field, and fails unless it appears
   in LOOSE_IDS. Comments stripped first, so a doc line can never register as a
   field. The error names the file:field and tells the reader which typed form to
   reach for (`PeerId` for an actor, `PersonaRef` for an unresolved reference, a
   `*Id(Uuid)` newtype otherwise).
2. `no_declaration_outlives_its_defect` — a declaration whose field HAS been fixed
   fails too. Learned directly from `StubAircCitizen::subscribe_all_rooms`, whose
   comment stayed true-sounding for months after its premise expired and cost 5
   silently-failing tests.
3. `declarations_carry_a_real_reason` — every entry starts with external:/pending:/
   defect: and is longer than a shrug, the same bar the module-wiring audit (#344)
   holds.

73 declarations, honestly categorized:
- **external** — LiveKit participant/room ids, log-envelope correlation fields.
  Another system owns the wire format.
- **pending** — ours, but nothing on that path RESOLVES yet. Typing it as an
  identity today would assert something the code does not do. Converts in the slice
  that wires resolution (#164/#396).
- **defect** — `peer_id: String` × 5. These ARE `PeerId`. I attempted the conversion
  in this session and reverted it: `PeerId` has no `JsonSchema` impl and the
  construction sites hold `&str`, so it needs its own slice rather than a rushed
  cascade. Declared as a defect so it stays visible instead of blending in.

POSITIVE CONTROL, because a guard nobody has watched fail is the exact shape of
defect I found earlier today: added `struct PositiveControlProbe { pub owner_id:
String }`, confirmed the guard failed naming `identity/mod.rs: owner_id`, removed it,
confirmed green. The guard also caught 12 sites my own inventory grep had missed —
it is already strictly better than the method I was auditing with.

Full lib suite: 7081 passed, 0 failed.

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

* fix(cli): `continuum start` execs the installed server — building is now --from-source

`start` shelled unconditionally into tools/scripts/start-server.sh, which runs a
full cargo build. A "governed" lifecycle verb was a wrapper around a bash file
that only exists inside a repo checkout (BigMama's find, 2026-08-13):

  - a user holding ONLY the installed binary, with no source tree, could not
    start a core at all;
  - the CLI printed one line then went silent for the length of a compile —
    called hung three separate times;
  - the façade's honesty depended entirely on the script underneath.

Same class as the rest of the night's defects: a governed surface over a
hand-rolled path.

Now: `launch_core` locates the installed `continuum-core-server`
(CONTINUUM_CORE_SERVER override → next to the running exe → ~/.continuum/bin →
target/{release,debug} walking up) and execs it directly, keeping the existing
detach/log/pidfile handling unchanged. Building is an EXPLICIT request
(`continuum start --from-source`), never the silent default, and the
no-binary fallback says WHY it fell back and that it compiles first, rather
than going quiet for minutes.

The override refuses loudly when set but not a file — a wrong override must not
look like an absent one.

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

* fix(core): tree is GREEN again — 7081/0 (peer_id → PeerId finished, guard debt cleared)

The working tree could not build tests. This finishes the identity-typing work
that broke it and clears the guard debt it left behind. `cargo test -p
continuum-core --lib --features metal,accelerate`: 7081 passed, 0 failed.

PEER_ID IS A TYPE, NOT TEXT. The production conversions landed earlier; the
test fixtures were left holding `&str`, so the crate compiled and the test
target did not. Fixtures now derive a real UUID from the literal they used to
carry (v5 under NAMESPACE_OID), which preserves every cross-site equality the
tests depended on — "peer-a" in two places is still the same peer, it is just
an id now instead of a name in costume.

CAUGHT BY DOING IT: contracts/verification had the manifest keyed by a derived
PeerId while the EVENT still claimed a raw string signer. The lookup is BY that
signer, so converting one side made every verification test fail as
MissingPeerManifest. One `test_peer_id` / `test_peer_str` pair now feeds both
sides — the same shape of defect the newtype exists to prevent, reproduced in
the fixtures while removing it from production.

REAL HARDENING, not just fixture churn: `AircPeerManifest::validate` had DROPPED
its empty-peer_id check on the theory that typing the field made it impossible.
Typing killed `""`. It did NOT kill `Uuid::nil()`, which is still constructible
and still means nobody — the type narrowed the hole rather than closing it. The
guard is back, at the remaining expressible form.

GUARD DEBT CLEARED: loose_id_guard's `no_declaration_outlives_its_defect` went
red, correctly — four `peer_id` entries in LOOSE_IDS described fields that are
now `PeerId`. Removed. The guard failing here is it working: a declaration list
that can rot into a graveyard is worth nothing.

Also includes the accumulated session tree: the Joel→Operator fixture sweep (no
person's name hardcoded in test data), ts-rs regeneration, and rustfmt across
the crate. That is why this touches ~717 files; the behavioural change is the
identity typing and the nil-PeerId guard.

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

* fix(tests): a subsystem-named room does not belong in a fixture either

`k3-serving` had no lifetime because it was named for a SUBSYSTEM, so it
never died — a month-old durable subscription whose board reads were all
corpses. Parted from both scopes.

It also sat in TEST FIXTURES, which is the transmission vector: fixtures
teach the next reader the convention, so a fixture naming a room after a
subsystem teaches that rooms are named for subsystems. Renamed to
`bench-swe-run-1` — an activity with a lifetime, which is what a room IS.

The two remaining mentions in work.rs are the INCIDENT RECORD (4 of 12
cards there carried a 134h-expired lease) and are kept, now annotated
RETIRED so nobody copies the naming from them.

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

* fix(benchmark): an UNGRADEABLE grade is an ABSENCE, not a capability zero — carry it on the wire and the board

`SweGradeResult.error` documents its own contract: "a result with `error` is an
ABSENCE, not a zero, and must never be tallied as a failed attempt." The grader
earns that honestly — for the env class it re-runs the PRISTINE tree before
declaring a fault, so a genuinely broken patch is never mislabelled.

Then both consumers dropped the classification:

- `benchmark.attempt.end` / `benchmark.autograde` published `resolved=false
  gate_ok=false` and nothing else. Every wire consumer (probe router → rooms,
  exam-room widgets, pulse monitors) reads that as a citizen who tried and lost.
- `fold_run_card` read the RESULT's `infra_error` but never the GRADE's `error`,
  so the board folded `resolved: false` + phase `failed` for the same runs.

The attempt loop already broke correctly on `g.error.is_some()` (attempts 2 and 3
were never burned) — the loss was purely in what got PUBLISHED, which is the part
anything downstream can actually read.

Measured on this box 2026-08-13: 8 of 36 distinct instances (14 of 91 receipts,
22%) grade UNGRADEABLE — requests, pylint, pytest and sympy. Every one of those
zeros was indistinguishable from a capability failure on the wire, so the
denominator of any rate computed off this stream was poisoned. Found by digging
into sympy__sympy-11400: p2p 0/29 on the PRISTINE tree, i.e. the suite does not
run in that environment at all. (#380/#383 own fixing the environments; this
commit owns never again reporting their faults as scores.)

- attempt.end + autograde now carry `ungradeable` + `grade_error`
- `infra_error` takes the grade's error too — one field meaning "no valid
  verdict, and why", fed by both sources rather than a second parallel field
- `resolved` returns to `None` when ungradeable — the same "no verdict" a
  pre-grade card carries, because that is the truth
- new phase `ungradeable`, ordered ahead of `failed` (a run can carry both a
  failed marker and an ungradeable grade; the absence is the truer of the two)

Test asserts absence-not-zero on the real sympy-11400 shape, with a positive
control (same shape, no grade error) that must still fold as a capability zero
— so the test cannot pass by simply never reporting failure.

This is the #384/#386 class one layer up: those classified INFRA at the solve
level, this classifies it at the GRADE level and gets it onto the wire.

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

* fix(swe): gold-gate the harness — refuse an env whose pytest cannot RUN, instead of caching a tree that grades every attempt UNGRADEABLE

Root cause of the 22% ungradeable rate, glass-boxed on sympy__sympy-11400.

The era pin at the top of this block downgrades pytest to the instance's own
date, which is right when the era INTERPRETER rung (#2253) found a matching
interpreter. When it can't — no Python 3.5 on a modern macOS — the venv falls
back to a modern interpreter while pytest stays pinned to the instance's year,
and the resulting PAIR can be structurally unable to run.

Measured: pytest 2.9.2 (correct for 2016) on Python 3.9.6 dies in
`pytest_configure` with INTERNALERROR before collecting anything — reproduced on
a two-line trivial test, outside the repo, no conftest, no sympy involved. Every
test then "fails", the pristine p2p reads 0/29, the tree grades UNGRADEABLE.
8 of 36 distinct instances on this box are in that state.

So: prove the harness executes before handing the env to a citizen. A version
pin is a GUESS about compatibility; running it is the evidence. `--version` is
not enough — it answers happily for a pytest that dies on any real run.

This REFUSES rather than self-heals, and that is measured, not assumed. The
obvious repair (reinstall a modern pytest) was tried against this exact tree and
does NOT work:

  pytest 8.4.2 → loads, dies in sympy 1.0's 2016 conftest on the `py.path` hook
                 API removed in pytest 7
  pytest 6.2.5 → dies on `py.test.mark.slow`, removed in pytest 4
  pytest 2.9.2 → cannot run on Python 3.9 at all

The band that both RUNS on 3.9 and LOADS a 2016 conftest is EMPTY. No version
choice rescues this class, so an auto-repair would silently trade one void tree
for another.

What DOES work, verified on this tree — 30/30 passing — is sympy's OWN runner
(`sympy.test(...)`) on the same interpreter. That is #383's shape ("django needs
its OWN test runner") generalised: the runner is a property of the repo era, not
a pytest version to search for. `run_tests` is pytest-only today, so until it
grows a runner seam this env genuinely cannot produce a verdict — and it now says
so loudly, naming the incompatibility and pointing at the runner gap, instead of
caching a broken env for every later run to inherit.

[[brittleness-is-the-highest-priority-work-there-is]] — heal what is known-safe,
REPORT what needs a human decision.

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

* docs(arch): benchmarks are ADAPTERS into recipes/activities — never a parallel runner (Joel's ruling, + STOP gate)

The consequence that makes it law: the learning flywheel consumes ROOM TURNS (L1
lifts tool-traces from captured turns, L2 triggers on turn-completion). A detached
agent/solve writing progress/<run>.grade.json produces NO turns — so a citizen can
burn 12 acts, write a patch, take a graded verdict, and none of it reaches the
curriculum. Maximum effort, zero learning. That, not the pass rate, is why
benchmarks have failed.

Names what is parallel today (ledger files, scraped probes, a second board
projection in fold_run_card, private grade.json), the target shape (import
task+oracle only → project into a recipe → the ROOM is the runner → grading is the
activity outcome → learning falls out because the work happened as turns), and a
one-line acceptance test: can a citizen standing in the room perceive the run's
state through the same ViewState pipe the human's screen uses?

Adds a CLAUDE.md STOP gate over benchmark.rs / agent/solve.rs / swe_bench.rs so an
agent arriving under amnesia must read it before touching run state. Written
because that is exactly what happened: this session shipped two correct fixes that
HARDEN the parallel path instead of dissolving it, including adding a field to a
benchmark probe so external consumers could parse it better — which is the smell
the doc now names.

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

* feat(activity): a room's recipe binding finally has a READER — every room resolves to what it IS (#6/#274/#329)

`activity/spawn` has always published a room→recipe binding to the wall, and its own
doc says why: "Without this the room forgets which recipe it is and every client falls
back to projecting it as a plain chat room." That was accurate. The binding had NO
READER. `RECIPE_WALL_CATEGORY` appeared in exactly one file — the writer — plus a test
asserting the string equals "recipe".

So the whole recipe layer was live and inert at once: recipes authored as data, a
`RecipeExperienceSource` projecting them, four shipped manifests including a benchmark
carrying scoreboard/central/feed regions — and `DefaultRoomPurpose` answering "chat"
for every room in existence, so none of it ever resolved. A benchmark run's room and a
chat room were the same object to every renderer AND to the citizen standing inside
one. That is what "benchmarks are a parallel system" looks like at the substrate: not
a missing feature, a write with no reader
([[a-correct-check-that-nothing-calls-is-nastier-than-a-missing-one]]).

- `experience/binding.rs` — `RoomRecipeBinding` + `project_binding`, the typed body and
  the one rule for turning a room's wall into its identity. Sibling of `standing.rs`,
  same shape and the same fail-loud stance: no binding is `Ok(None)` (a bare `airc
  join` makes a chat room), an UNREADABLE binding is an error, never a silent downgrade
  to chat.
- `ipc/recipe_room_purpose.rs` — `RecipeRoomPurpose`, the `RoomPurposeSource` impl the
  seam's own doc has been waiting for. Event-invalidated cache, not a per-read fetch:
  `purpose_for` is sync and sits on the projection's store path, so an owner task folds
  `wall:changed` and re-reads the authoritative binding (the supersede chain is
  airc-owned and cannot be reconstructed from a delta — same discipline as the wall
  projector). Seeds every subscribed room at boot so an activity spawned before this
  core booted resolves without waiting for someone to re-pin something.
- `activity/spawn` now SERIALIZES the shared type instead of a hand-authored `json!`.
  Both sides agree by construction — which mattered exactly zero while nothing read it,
  and matters permanently now.
- `positron_source::spawn` takes the purpose source by injection; boot passes the live
  index when a daemon is present, `default_source()` (every room → chat) when headless.

Honest edges, all pinned by tests: an unbound room, an unreadable binding, and a failed
read all resolve to "chat" — the seam is total — but the two failures say so LOUDLY on
the probe stream (`activity.purpose.unreadable_binding`, `activity.purpose.read_failed`).
A binding naming a purpose no recipe declares resolves verbatim, and
`RecipeExperienceSource` then honestly returns no manifest rather than substituting one.

Known follow-up, named rather than hidden: this adds a FOURTH node airc reader
(presence/wall/kanban/purpose). Consolidating them onto one attach is real work and is
not this commit.

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

* fix(activity): the purpose index must SAY it ran — a silent fold is indistinguishable from a dead one

First live test of the purpose index produced zero probes, and I could not tell from
the evidence whether that meant "attached, seeded, nothing bound" or "never spawned".
The store on disk settled it, but only because I went looking for a sqlite file — the
component itself said nothing either way. That ambiguity is the defect
([[a-correct-check-that-nothing-calls-is-nastier-than-a-missing-one]]).

- attach logs like its three sibling node readers (presence/wall/kanban all do)
- `activity.purpose.seeded` on every boot with {rooms, bound} — "0 bound of 1" is a
  FACT, and a different fact from silence
- `activity.purpose.refreshed` on every wall-change cue, so the invalidation path is
  observed rather than inferred (wall changes are rare; the probe costs nothing)

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

* feat(persona): RAG is a RenderTarget — one ViewState renders to eyes AND mind (the pattern)

`ACTIVITY-ROOM-PATTERNS.md` has said this since it was written:

  "the same transform serves a human's eyes and a persona's mind, because RAG is a
   render target, not a separate pipeline" … "the human's UI and the persona's
   grounding are the same projection rendered two ways — they cannot drift, because
   there is one definition" … "Never render the two from separate code."

The code rendered them from separate code anyway. The human's roster comes from
`RosterViewState` on the served Substrate; the citizen's came from
`persona::room_roster_source` — a second reader, own fetch, own freshness, own
failure modes. Same for the board (`KanbanViewState` vs `room_board_source`) and the
wall. Three parallel pairs, and one of them was MEASURED delivering a live peer's
name ZERO times into a citizen's prompt while the browser rendered that peer fine.

This is the compression, not new architecture:

- `RagRenderable` — a tiny per-kind impl: KIND (the SAME const the web subscribes
  to), block label, expand verb, measured floor, salience-ordered units, room scope.
- `ViewStateRagSource<V>` — ONE generic adapter making any such kind a `RagSource`.
  Budgeting, packing, cursors, token estimation, honest-empty, and the room gate are
  written once. N kinds cost N small impls and zero new plumbing.

Properties that fall out rather than being bolted on:
- **Cannot drift** — the adapter reads the SAME Substrate the WS server serves.
- **Freshness** — no second fold to lag, so the #346 staleness class (citizen trusts
  an empty board while the announcement is fresh) can't recur here by construction.
- **Degrades** — units pack most-salient-first, so a tight window yields FEWER
  members, never a chopped one (the property `floor_tokens` exists to protect).
- **One room gate** — reuses `room_scope_allows`, the shared predicate, rather than
  a second copy of the same decision.

Outlier-validated per CLAUDE.md's methodical process, both in one file so a bad
abstraction fails immediately:
- A: `RosterViewState` — people, identity, room-scoped. The measured defect's cure.
- B: `BenchViewState` — numbers, no identity, per-row verdicts, node-scoped.

B needed ZERO adapter changes, which is the whole test. chat / kanban / wall /
serving / nav / foundry are now registrations, not builds.

5/5 tests green, each with a `// what this catches:`. One test's arithmetic was wrong
on the first run (budget 12 fit all three ~4-token member lines); the PACKING was
correct and the test was fixed to 8 — noted in the test itself, because "make the
failing assert pass" is how a real invariant gets quietly weakened.

NOT YET WIRED into prompt assembly — the seam exists and is proven; swapping the
three bespoke sources over is the next commit, so the swap can be reviewed as a
behavior change on its own.

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

* docs(persona): name the substrate prerequisite IN the module, before someone swaps a source onto it

The obvious next move on `viewstate_rag` is to rebind `room_roster_source` at
supervisor.rs onto the new adapter. Reading the substrate first showed that would
be a REGRESSION, so the module now says so at the top where a future reader will
actually be standing.

The `Substrate` cache is keyed by KIND ALONE — positron's own `revisions.rs` names
the `(room_id, kind)` tuple as a future extension. So the node substrate holds ONE
room's roster: the focused room's. Swapping today means this adapter's room gate
correctly abstains for every persona whose turn is in a different room, and personas
are first-class MULTI-room subscribers. Most citizens would go BLIND rather than
mis-sighted — trading "sometimes wrong" for "reliably empty" is not a repair.

Filed the prerequisite as #408 (per-room substrate key) with the acceptance test:
two personas in DIFFERENT rooms each receive THEIR room's roster in one tick.

This is the note I would have wanted before shipping the swap, not after.

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

* feat(positron): per-ROOM substrates — the keystone that lets a citizen read HER room (#408)

The node's cache is keyed by KIND ALONE. `scoping.rs` said it in its own words —
"Everything else is per-room and stays on the node substrate" — which is the bug in
one sentence: those kinds are TREATED as per-room but share ONE store, so the node
holds whichever room wrote last (the FOCUSED room) and every other room reads empty.

That is what blocks the citizen side of positron. `persona/viewstate_rag.rs` makes
any ViewState a RagSource so a citizen and a browser read ONE definition — but a
persona is a first-class MULTI-room subscriber, so under one shared slot most
citizens would get an EMPTY roster rather than a wrong one. "Reliably blind" is
worse than "sometimes wrong", which is why that swap was NOT made first.

The fix is not new machinery — it is the SECOND INSTANCE of a pattern already here:
`PER_USER_KINDS` + `PerUserSubstrates` already solve "N scopes share a kind
namespace" for citizens (nav). This adds the room axis in the same shape:

- `PER_ROOM_KINDS = [chat, roster, kanban, wall]` — open by data, like PER_USER_KINDS
- `PerRoomSubstrates::for_room(room)` — one substrate per room, created on first use
- `CompositeCache` routes THREE scopes: per-user → citizen store, per-room → room
  store, everything else (bench, serving, system-metrics) → the node store, because
  those describe the NODE and have no scope to route to.

ADDITIVE ON PURPOSE. `CompositeCache::new` is preserved verbatim and still resolves
room kinds from the node store, so every existing caller keeps today's behavior;
scoping is opt-in via `CompositeCache::scoped`. A migration that silently re-pointed
every reader would make "did this change anything?" unanswerable.

8/8 green. The acceptance test is the one that matters:
`two_rooms_each_keep_their_own_state_in_the_same_tick` — two rooms, each reads ITS
OWN state, neither overwritten. Plus: writer and reader of one room share ONE store
(no second fold to go stale — the #346 class), the unscoped constructor is unchanged,
and the three-way route neither merges nor leaks across scopes.

No positron-core change, no wire change, no tag bump — entirely in-tree. My first
estimate of this task understated it and my second overstated it as a cross-language
contract change; reading `scoping.rs` settled it as an in-tree application of an
existing pattern.

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

* feat(positron): the chat projection writes per-ROOM as well as node — one fold, two sinks (#408)

Per-room substrates existed as of the previous commit and were EMPTY: nothing wrote
to them, so they were a correct mechanism with no data — the same write-with-no-reader
shape as the recipe binding, inverted.

`ChatProjection::store` now mirrors every per-room envelope (chat, roster, the
Experience manifest) into that room's own store via ONE helper, `store_room_scoped`.
One place decides the dual-sink rule, so a future kind cannot be added to one sink and
forgotten in the other.

ONE FOLD, TWO SINKS — not two folds. The projection computes the view once and the
SAME `StateEnvelope` (same revision) lands in both stores. A second FOLD is what goes
stale (#346, where a citizen trusted an empty board while the announcement was fresh);
a second SINK of one fold cannot drift from itself.

Web behavior is untouched: the node substrate still receives everything exactly as
before, so the focused-room session reads what it always read. The per-room stores are
additive and, until a consumer names its room, unread. `rooms: None` in tests and
headless keeps today's path.

19/19 green. The new test is the crux: two rooms speak, B last; the NODE ends on B
(unchanged focused-room behavior) while room A's OWN store still holds A's view with
A's message. That is precisely the state the single-slot cache used to destroy, and
it is what `ViewStateRagSource` needs in order to hand a citizen HER room.

Still not wired to a consumer — ipc/mod.rs must construct the registry and pass it in,
then the roster source can flip. Kept separate so the wiring is reviewable as its own
behavior change.

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

* feat(persona): a citizen reads WHO IS PRESENT from the same projection the browser renders (#408)

The last two wires. The roster a persona grounds on is no longer a second reader of
airc — it is `ViewStateRagSource<RosterViewState>` over HER room's own store, which
is the SAME `RosterViewState` the web roster renders.

- `ipc::global_room_substrates()` — the process-global `PerRoomSubstrates`, same
  `OnceLock` shape as `global_nav_focus`. The WRITER (the chat projection, in the WS
  boot block) and the READER (a persona's grounding, bound at spawn in supervisor)
  are constructed in different places and MUST land on one registry; two registries
  would be two stores, which is the exact defect being removed.
- `positron_source::spawn` takes the registry and threads it to the projection.
- `supervisor` binds the ViewState-backed roster instead of `RoomRosterSource`.

This is the repair for the measured defect: a live peer's name appeared ZERO times in
a citizen's prompt while the browser rendered that peer fine, because the two read
different code. Now there is one definition and two render targets — eyes and mind
cannot drift, because there is nothing to drift from.

`room_roster_source` is left in the tree untouched (still used by the presence
emitter and the experience resolver); it is simply no longer the persona's roster.
No dead-code scaffolding was added to "preserve a rollback" — `git revert` is the
rollback, and a dead fn kept for comfort is clutter.

24/24 green across positron_source + viewstate_rag. NOT yet live-verified — the
acceptance test is a real turn's prompt capture containing a peer's name, which is
the next step and the only evidence that counts here ([[never-blind]]: a fix I cannot
prove reached the running binary is a fix I have not made).

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

* fix(cli): restore the deploy path — reboot builds again, and the socket reaches the server

Two defects, both introduced by 7e0c5469a ("`continuum start` execs the installed
server"), both in the ONE function `start` and `reboot` share. The change was right
for `start` and wrong for `reboot`, and `launch_core` had no way to tell them apart.

1. THE SOCKET WAS NEVER PASSED. The direct-exec path handed the socket to the server
   over CONTINUUM_CORE_SOCKET and omitted the positional argument. `main.rs` requires
   argv[1] and exits 1 with its usage text without it — so on any machine with an
   installed binary, every `start` and every `reboot` died ~2s in, having written

     Usage: continuum-core-server [--mode=<MODE>] <socket-path>

   into the start log and nothing else. Measured here tonight: the reboot killed the
   old core's claim on the swap, the new one never came up, and only the surviving old
   process kept the system answering.

2. REBOOT STOPPED BUILDING. `reboot` is THE deploy path ("edit → reboot → exercise").
   Preferring the installed artifact made it structurally unable to ship an edit: it
   printed "building fresh binary, then swapping" and exec'd a binary from Jul 13.
   Every fix made since would have been invisible to the running core, and the only
   thing standing between that and a false success line was #194's provenance check.

The fix makes the source policy an explicit argument instead of an ambient default,
because the two callers want opposite things: `start` wants a core RUNNING (installed
artifact is correct, and the no-source-tree user 7e0c5469a was written for keeps
working), `reboot` wants the core built FROM THIS CHECKOUT. `plan_launch` resolves
(policy, env override, script?, artifact?) as a pure function — 7 tests, one per branch,
each naming the failure it prevents. A reboot on an installed node with no checkout
still restarts the artifact, but through a distinct variant that forces the CLI to SAY
nothing was rebuilt rather than let a restart pass as a deploy.

Server side: `continuum-core-server` was the one component in the tree hand-rolling its
own socket resolution (argv or die) while `continuum`, `continuum-mcp` and every library
caller go through `endpoint_paths::core_socket_path()`. argv[1] still wins; absent it,
the server now agrees with everyone else instead of exiting. That disagreement is what
let defect 1 exist at all — the launcher communicated over a channel the listener had
never been told to read.

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

* fix(deploy): publish the verified core binary to the installed path every deploy

`continuum start` execs the INSTALLED continuum-core-server (building is reserved for
`reboot`), and the resolver checks ~/.continuum/bin BEFORE any cargo target dir. But
that copy was written once by install.sh and never refreshed by a deploy — so on a
machine that has been deploying for a month, `continuum start` silently boots a
month-old core while the freshly-built one sits unused in the cache.

Measured on the M5 tonight: installed artifact dated Jul 13, running build 4705, HEAD
4712. And it was not theoretical — a stray auto-start off that stale copy during a
reboot is exactly what tripped the #194 deploy-provenance mismatch and cost an hour of
misreading a deploy that had actually built fine.

This script already publishes the CLI into ~/.local/bin on every deploy, with a comment
arguing precisely this ("refreshes each deploy so PATH always points at the current
build"). The core-server was simply omitted from that reasoning. Now it isn't.

Placed AFTER the #194 freshness guard and before exec, so the installed artifact is only
ever replaced by a binary just proven to match source — never a stale or half-built one.
Atomic temp+mv so a concurrent `continuum start` cannot exec a half-written file.
Non-fatal, and it says out loud when it cannot publish, because the consequence the
operator needs to hear is "`continuum start` may boot an OLDER core than this one".

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

* fix(persona): one contract, one spelling — a ViewState states its floor the way every other RagSource does

CI red on PR #2282, my defect. `cargo test -p continuum-core --lib` failed one test out
of 7,042:

    cognition::context_budget::tests::no_new_hardcoded_context_or_prompt_size_constant_anywhere_in_the_crate

The guard (context_budget.rs:356-365) matches any `const` whose name contains
WINDOW|CONTEXT|CTX|TOKEN|PROMPT|CHARS, of an integer type, assigned a bare decimal
literal. `const FLOOR_TOKENS: u32 = 10` (roster) and `= 18` (bench) matched on TOKEN.

The number was never the problem — it is a per-UNIT content floor ("one roster line
costs ~10 tokens"), not a context bound, and it does not scale with the served window.
The problem is that I expressed it in a SHAPE nobody else uses. Every other source
states the same fact as a function:

    room_board_source.rs:293    fn floor_tokens(&self) -> u32 { 32 }
    room_roster_source.rs:286   fn floor_tokens(&self) -> u32 { 0 }
    room_doctrine_source.rs:151 fn floor_tokens(&self) -> u32 { 0 }
    rag_budget.rs:475           fn floor_tokens(&self) -> u32;      // the contract

So `RagRenderable` grew a SECOND spelling of one contract — an associated const beside
the trait method it feeds. That is the duplication the compression principle forbids,
and it landed in the very file meant to be the template every future ViewState source
gets copied from. The guard fired on the new shape, which is exactly its job.

Fix: `const FLOOR_TOKENS: u32` becomes `fn floor_tokens() -> u32`, matching the
established idiom. One contract, one spelling; the guard passes as a CONSEQUENCE of
saying it the normal way rather than as the goal.

Deliberately NOT done: no `// context-budget-exempt:` line (the escape hatch exists, but
an exemption would preserve the second spelling — the actual defect), and no weakening
of the guard.

Guard test: 1 passed. viewstate_rag tests: 5 passed. Clean `cargo check --lib`.

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

* glass-box(persona): say WHAT the rejected event was, not just which branch refused it (#410)

Measured today: every `airc msg` a human sends reaches EVERY citizen's subscribe stream
(12/12 raw_events, sender 7711fe60) and is dropped as `no_continuum_body_hint`. Cause is
in `realtime_wire::envelope_from_event` (:58-68) — it returns Ok(None) unless
HEADER_FORGE_BODY_HINT == CONTINUUM_BODY_HINT, a stamp only continuum's OWN clients
apply. The message is refused before its content is ever read, so a human talking to the
room over the CLI is structurally unheard while the browser renders it fine
(`airc.chat.projected` fires every time).

The fix is one more arm in `room_turn_from_event`. It needs the CLI's actual body shape,
and the probe could not supply it: `reason` names the BRANCH that refused the event,
never the SHAPE that was refused. Attempts to recover the shape out-of-band failed —
`airc events list --kind message` returns 0 in BOTH the project and machine-account
scopes while returning 60 system-kind events, so the persisted view disagrees with what
delivery demonstrably did.

So instrument rather than guess. A decoder arm written against a GUESSED body is exactly
how presence and control frames become fabricated perception — the hazard the existing
named-skip contract exists to prevent. Next session reads one real body and writes the
arm against a fact.

Adds `event_kind` (the TranscriptKind, which IS the receive-side discriminator — note
FrameKind lives on Frame and does NOT survive to TranscriptEvent) and a 160-char
`body_preview` to the ALREADY-firing filtered_non_turn line. No new probe class, no new
event, and the stream-chunk skip above stays deliberately unprobed — this cannot
reintroduce the flood that skip removes.

Behaviour unchanged: diagnostics only.

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

* feat(serving): a throughput baseline carries the WINDOW it was measured at (#440/#441)

MEASURED 2026-08-20, Qwen3.8-27B live on the M5. MTP spec-decode is working:
80.3/82.3/84.3% draft acceptance across 3 samples, lane running
`--spec-type draft-mtp --spec-draft-n-max 4 --spec-draft-p-min 0.7`. That
half of #440 is proven end-to-end.

What is NOT comparable: the catalog's 17.2 tok/s was taken at a 19,712
window; the live lane serves 89,280 — 4.5x the KV to walk per decoded token
on UMA. Samples came in at 2.7/6.2/7.8 tok/s. The #441 collapse alarm is
correctly calibrated (0.25 floor: it stays silent at 0.36/0.45 and FIRES at
0.16) but its warning text names CPU fallback, pager thrash and GPU
contention as the suspects — so a reader would hunt a defect that is not
there.

Decode rate is a function of resident KV. A rate without its window is not a
comparable quantity. ThroughputBaseline already refuses to "present an
unsourced baseline as fact"; an unwindowed one is the same class, so the
window joins source as provenance.

- `measured_at_window: Option<u32>` — None means genuinely not recorded, an
  honest absence rather than a 0 sentinel ([[unknown-is-not-a-quantity]]).
- `comparable_at(live_window)` — false means "this baseline cannot say",
  NOT "healthy". A caller that alarms anyway must state the window gap.
- Existing seed rows get None: their windows were never recorded and I will
  not invent them.

8/8 module tests green; cargo check exit 0 (verified by exit code — a
grep-filtered check hid failures from me earlier today).

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

* fix: restore 33 core files to canary's version — repair my bad #2282 merge

My merge 9e2389f59 shipped union-merge damage (duplicated lines, orphaned
closers) in 33 files and I reported it as compiling clean. It did not: I was
validating with `cargo check | grep ": error"` and reading empty output as
success, which silently hid the failures. Reading $? gave 101.

Every one of those files is superseded by canary anyway — canary won all 46
conflicts in that merge, verified file by file — so restoring them loses
nothing and repairs the tree.

VERIFIED THIS TIME BY EXIT CODE, not by grep:
  cargo check -p continuum-core --lib --features metal,accelerate -> 0
  cargo test  ... throughput_expectation -> 8 passed, 0 failed

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

* fix: restore 4 ts-rs generated bindings corrupted by the union merge

THE CI FAILURE. `cargo test -p continuum-core --lib` regenerates ts-rs
bindings and compares against what is committed; these four had union-merge
damage and could not match.

The damage is the same class I spent the night repairing in the Rust — I just
never looked at the generated files, because "generated" read to me as "not
mine to inspect". RoomRecipeBinding.ts closes the type declaration MID
DOC-COMMENT (`parent?: string, };` with the rest of the comment dangling
after it); the three memory params files import the same symbol TWICE from two
different paths.

Why the compile check stayed green while this was broken: nothing compiles
`.ts`. windows-msvc passed `lib + tests` the whole time.

Why the guard built for exactly this said nothing: `ts-rs binding drift
detector` is `needs: cargo-test-continuum-core`, so when that job failed the
detector reported `skipping`. The check designed to catch binding drift was
gated behind the job the drift broke — worth its own card.

Restored from canary. The branch is now exactly canary + the throughput
change, nothing else.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Aug 21, 2026
…440/#441) (#2341)

* docs(catalog): the 27B's contended rate, recorded as contended (#440/#441)

MEASURED 2026-08-20, 6 samples of 150 tok on the live M5 lane: 4.74 / 5.25 /
6.55 / 6.57 / 6.66 / 6.67 tok/s, median 6.56, at a 22,528 PER-SLOT window
with `busy_slots = 2` of 4 on EVERY sample.

NOT written into `tokens_per_second`, deliberately. That field is what #441's
collapse alarm reads as the SINGLE-STREAM expectation, and 6.56 is a contended
rate — `ThroughputBaseline`'s own doc says "single sequence". Putting it there
would drop the alarm's floor from ~4.3 to ~1.6 tok/s and let a genuine collapse
pass silently. The pinned 17.2 stays.

Both numbers are true; they measure different machines. THE GAP IS THE POINT:
the sentinel cannot currently tell "contended" from "degraded" because nothing
records concurrency at measurement time. That is the sibling of the window axis
landed in #2339, and it is #441's remaining half.

MTP held 83.9-84.8% draft acceptance across all six, and 80.3-84.3% across
three earlier samples on a different prompt. Acceptance is FLAT while t/s moves
1.4x, so the draft head is not the variance source.

Also corrects my own earlier reading: I took `-c 89280` off the lane argv and
called it the live window. It is the TOTAL across 4 slots; per-slot is 22,528
against the catalog's 19,712 — 1.14x, not the 4.5x I claimed. The window was
never the explanation.

cargo check exit 0; model_registry tests exit 0 (both read by exit code).

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

* feat(serving): the collapse alarm reports concurrency, so a reader can attribute it (#441)

The alarm compared a live decode rate against a SINGLE-STREAM expectation and
named three suspects — CPU fallback, pager thrash, GPU contention — with no
evidence for any of them. Measured 2026-08-20 on the 27B: 6.56 t/s against a
17.2 pinned expectation, ratio 0.38, with TWO model calls in flight. That is
real contention, and a reader handed only the ratio would have gone hunting a
CPU fallback that does not exist.

Now the warning carries `inflight_model_calls` and says what it means: >1 in
flight and the expectation is not like-for-like; at 1 in flight the original
suspects stand.

ANNOTATE, NOT GATE — deliberately. This alarm's own contract lists "contended
GPU" as something it EXISTS to catch, so suppressing on concurrency would
defeat its purpose and weaken a guard. The firing decision is untouched; only
the evidence attached to it changed.

REUSES the existing gauge rather than counting again:
`resource_admission::inflight_model_calls()` is already public, already
maintained by an RAII guard, and its doc says it "reflects exactly the
model-call window (lane-queue + prefill + decode)" — precisely the axis needed.
The concurrency sibling of the window axis landed in #2339.

cargo check 0; throughput + resource_admission tests 0 (read by exit code).

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

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Aug 21, 2026
… through it (#124/#441) (#2342)

* revert(serving): remove comparable_at + its invented 2.0 factor — speculative interface, zero callers (#441)

Landed and removed the same day. Three defects in one small addition:

1. MAGIC CONSTANT. `WINDOW_COMPARABILITY_FACTOR: f64 = 2.0` was invented.
   Nothing derives it. The doc rationalised 2x after the fact.

2. ZERO PRODUCTION CALLERS. `comparable_at()` was never called anywhere in
   the tree. A predicate built for consumers that do not exist.

3. A LYING COMMENT, which is the worst of the three. Each of the three seed
   rows carried "consumers get `comparable_at() == false` rather than a
   silent assumption" — asserting a reader that was never written. Same
   class as #151/#357, authored while fixing that class.

ARCHITECTURALLY it was also the wrong shape (Joel): whether two operating
points are comparable is a CONSUMER's judgement, made against the lease/handle
it already holds. It is not a rule a data struct asserts for every caller in
the tree. We have consumer/handle interfaces for this; I bolted on a bespoke
free predicate instead of using them.

`measured_at_window` STAYS. It is provenance — it says what the number
describes, and its absence caused a real live mis-attribution. A field that
records a fact is not the same as a predicate that judges one.

cargo check 0.

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

* fix(cognition): the de-hardcode guard was blind to floats — and something was already through it (#124)

THE HOLE. The guard fires on `const NAME: <int> = <literal>` when NAME says
WINDOW/CONTEXT/CTX/TOKEN/PROMPT/CHARS. Its type list stopped at the integers,
so ANY window-relative constant typed `f32`/`f64` walked straight past it.
Found the hard way: `WINDOW_COMPARABILITY_FACTOR: f64 = 2.0` (mine, #2339)
matched the name rule, WAS a bare literal, and sailed through on the type.
A guard against invented numbers that a float annotation defeats teaches
exactly one lesson — type your magic number as a float.

A ratio over the window is as much a fresh guess as a count of its tokens.
Now caught the same way: f32/f64 added, and the literal detector accepts a
decimal point (one only, digit-led, so `1.5` matches and `A.b`/`1..2` do not).

WHAT IT CAUGHT ON THE FIRST RUN — not mine, and pre-existing:

    recall_faculty.rs:70 — const RECALL_WINDOW_FRACTION: f32 = 0.10

10% of every citizen's served window, spent on recall, invented and never
derived. Exactly the shape the guard exists to stop, sitting inside the guard's
blind spot. That is the positive control: the hole was real and occupied.

THE FIX is the one the guard's own failure message prescribes — express it as
a fraction on ContextBudget, where it SCALES with the served window instead of
being a 4k-shaped slice a 1M-context model inherits. `ContextBudget::
recall_tokens()` over `RECALL_DENOM`; recall_faculty derives from it via the
existing `from_window` constructor and no longer owns a float.

MIN_RECALL_TOKENS stays as-is — it carries a real `context-budget-exempt:`
receipt saying it only ever RAISES a budget, never caps one.

cargo check --tests 0; context_budget + recall suites 0 (read by exit code).

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

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Aug 21, 2026
…Joel's law)

Joel, 2026-08-21: "STDERR/out is never a place for interfacing, just debug."

Checked rather than agreed, and we violate it in two places, both written in good faith
for real incidents and both making llama.cpp's DEBUG TEXT load-bearing in our control
plane:

  * `inference::wedge::WedgeWatch` parses stderr for an impossible slot progress
    (`progress = 1.10`) and raises a flag THE SERVING DAEMON REAPS A LANE ON.
  * `inference::placement_watch::OffloadWatch` parses llama.cpp's LOAD BANNER for layers
    offloaded, then fires `serving.placement.cpu_fallback` — treated as a lease
    violation (#441).

Why it has to change even though it works today: stderr is unstructured, unversioned, and
drifts with upstream's logging taste. The failure mode when it drifts is not an error — it
is SILENCE. The watcher stops matching, the flag stops rising, and the wedge that burned
four hours on 2026-08-05 becomes invisible again with every component still green. Same
shape as every other defect in this document: an absence that looks like normal operation.
It is also, precisely, the class the #441 sentinel was built to catch — so the sentinel is
currently exposed to the failure it exists to detect.

The structured channels already exist: `/slots` carries per-slot state and progress,
`/props` the load configuration, and the per-request `timings` block already reaches us —
it is what `delib.generate.cache` reports. The tok/s sentinel should read
`prefill_tokens`/`prefill_ms` rather than scrape a banner.

THE LINE, since not all stderr reading is a violation: `stderr_log_tail()` on spawn
failure is CORRECT — a human asks "why did it die" and gets llama.cpp's own last words.
Reading stderr to SHOW is debug. Parsing stderr to DECIDE is an interface. The test is
whether a control path branches on it.

STATUS: named, not fixed. Rewriting both watchers onto /slots + /props needs those payloads
verified against our pinned build (b10196-fa7e0d8e9) first — asserting a field exists
because upstream documents it is the same mistake in a different channel.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Aug 21, 2026
…the round died today

TDD/VDD on a defect measured LIVE forty minutes ago, encoded while it is fresh rather
than remembered later.

THE INCIDENT. Citizen e5f4141d working pallets__flask-4045 in-room. Run reported
state=running, heartbeat every minute, acts frozen at 4 for twelve minutes. Lane answered
/health {"status":"ok"}, /props 200, /v1/models 200, port bound, process up 3h58m. Every
readiness signal in the system said healthy. Her own lane said:

  slot 1 | task 3   | n_decoded = 1092, tg = 2.65 t/s, tg_3s = 0.96 t/s
  slot 1 | task 3   | n_decoded = 1093, tg = 2.53 t/s, tg_3s = 0.05 t/s
  slot 0 | task 605 | prompt processing, progress 0.52, 105 t/s

Slot 1 decoding at 0.05 TOKENS PER SECOND — one token per twenty seconds — still holding
task 3 after six hundred tasks passed on the neighbouring slot. PREFILL WAS FINE (105 t/s,
the expected rate). Only decode collapsed, on ONE slot, and nothing could see it. That is
#386's per-slot wedge and it is the round-killer: a citizen at 1/600th speed burns her
whole 4.3h deadline producing nothing while the board renders a healthy pulse.

WHY LANE HEALTH CANNOT CATCH IT: /health is lane-scoped and the LANE is fine — the other
slot decodes normally, so every aggregate reads healthy. #363 established that readiness
must verify GENERATION not the socket; this is the layer below: generation must be
verified PER SLOT, because a lane is healthy exactly as long as its best slot is.

DESIGN, per the standing rules:
  * PURE function, transport-agnostic. It takes SlotObservation values, so it works the
    instant they arrive from a structured channel. /slots returns HTTP 000 on our pinned
    build — that is the follow-up, and the verdict logic must not wait on it.
  * expected_tps is a PARAMETER, never a constant here. What counts as collapsed depends
    on model and device; the catalog Model row owns that expectation (#441). A constant
    would be a hardcoded LCD clamp — either missing a real wedge on a fast box or crying
    wolf on a slow one.
  * Reads the 3-SECOND rate, not the lifetime average. The same slot read tg=2.53 (bad)
    while tg_3s=0.05 (dead); averaged over hours, a stopped slot looks merely slow.
  * Degraded REPORTS, only Wedged is actionable. #446 is the counter-example: starvation
    stamped as wedge evidence produced a 2-minute relaunch loop that WAS the outage.
  * A slot under 32 decoded tokens gets no verdict — killing cold generations is
    [[an-absence-is-an-unfinished-measurement]] wired to an actuator.

SIX TESTS, the first two carrying the live numbers verbatim: the incident classifies
Wedged; the lifetime average provably would have MISSED it (that test guards the
leading-indicator argument, not just the constant); merely-slow is reported not reaped;
a cold slot is never wedged; no expectation means no verdict; and the same observation
flips healthy/wedged with the device's own expectation.

INSTRUMENT NOTE, recorded in the module: those numbers were read out of stderr BY HAND,
which is the only way they were visible — and that is the exact defect Joel named today
("STDERR/out is never a place for interfacing, just debug"). Reading a log to DIAGNOSE is
correct. A control path depending on it is not. This module is the honest half; wiring it
to /slots is the other.

NOT YET WIRED — no caller, deliberately. The verdict is the testable unit; the actuator
(who reaps, when, under what lease) is a separate decision and belongs with the daemon,
same doctrine as the wedge flag.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Aug 21, 2026
…nd proves nothing

Self-correction. I shipped the phase machine and emitted NOTHING for it, then read
"RETRIES: 0, TURNS: 0" off the ledger and could not say whether prefills now survive
or nothing was running. That is the same unobservable-state defect the design doc in
the previous commit exists to complain about, committed by me one commit later.

Two rows, both at the seam that actually decides:

- `inference.prefill.rescued` — fires ONCE per stream, only when a prefill has
  already outlived the OLD decode budget AND is still advancing. Every row is a turn
  that under the previous flat 90s would have been killed here and retried forever.
  This is a POSITIVE signal for a fix whose symptom is an absence.

- `inference.prefill.complete` — total / cached / fresh / elapsed_ms / tok_per_s /
  would_have_died, at the prefill→decode edge. This is the number the 90s constant
  was implicitly guessing at, and the one the budget should eventually be DERIVED
  from per model+device (#441). It also finally measures the KV cache's REAL
  contribution per stream (`cached` vs `fresh`), which is the instrument the KV
  ordering work has been owed.

Joel, mid-session: "Have to probe better." Correct — a fix I cannot see working is a
fix I have not proven.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Aug 21, 2026
…— a probe that mixes two regimes measures neither

First cut of `inference.prefill.complete` produced absurdities that were the
conflation talking: a 467-token prompt "prefilling at 1 tok/s for 231s". It was
queued ~230 of those seconds waiting for a slot. llama.cpp's 0% progress frame
marks slot ASSIGNMENT, so the honest split is:

  queued_ms  = stream open → first progress frame   (admission/oversubscription, #234)
  ingest_ms  = first frame → prefill complete        (real ingest work)

`ingest_tok_per_s` is now computed over ingest only — the number a derived
per-model budget must come from (#441). `rescued` rows carry `queued_s` for the
same reason.

Source-read while here (vendor llama.cpp): prefills ARE continuous-batched across
slots (`can_batch_with` + cont_batching), so concurrent prefills share compute by
design. The 230s waits mean all 4 slots were OCCUPIED — by window-scale
re-prefills that zero KV reuse makes ~5 minutes each. Queue wait is downstream of
the KV defect; the split makes that attributable per stream instead of argued.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Aug 21, 2026
…d durability, grade-race fix (#2349)

* feat(activity): ONE adapter seam — material in, verdict out (slice 1 of the judge wiring)

An activity adapts the outside world's form into ours and renders a verdict on what the
citizen produced. Benchmarks, a game level, a life-drawing critique, a robot that either
picked up the block or didn't — one interface, N implementations, declaring none is normal.

WHY NOT `BenchmarkAdapter`, WHICH ALREADY EXISTS: it was the right SHAPE and the wrong
SCOPE. It already carried both directions — `dataset()`/`tasks()` in, `grade()` out — so
this is a generalization, not a rewrite. But the NAME is load-bearing: an interface called
`BenchmarkAdapter` cannot plausibly host a game level, so the second activity gets its own
trait, registry and runner, and the substrate ends up with two of everything. Same failure
as naming a room for a subsystem and making it immortal. Named for the JOB, gameplay is a
sibling implementation instead of a fork.

THE GROWABLE OUTCOME, and why the fixed struct was the real blocker: `TaskOutcome` had
`patch` and `workspace` as bare fields, which means SWE-bench OWNS the outcome type. A game
trajectory or a robot's joint log could only arrive by widening a struct every other
activity compiles against — so in practice it would never arrive there; it would grow its
own parallel outcome and its own parallel judge. `Outcome` now keeps the UNIVERSAL facts as
named fields (she spoke; she worked somewhere; the harness had its own opinion) and puts
modality-specific ones in a typed `channels` carrier, the same growable shape this codebase
already uses for adapter capabilities. Gameplay adds a channel without SWE-bench
recompiling; a judge asks for the channel it grades and gets a typed None when the activity
produced none. Growing the enum stays deliberate — a new variant needs a REAL activity — but
the cost of a wrong guess drops from "a second subsystem" to "one unused variant".

WHAT THIS IS FOR (measured today, 450 runs): 253 of them — 56% — ended with NO GRADE AND NO
ERROR. Not a failure, not a verdict: nothing. In classroom terms the exams were sat and
nobody was assigned to mark them. `benchmark.json` declares `suite/instances/team/budget`
and NO judge; `BenchmarkAdapter` has zero production consumers; grading is hardcoded to
`swe_bench::grade` behind four private call sites. When a run doesn't come through one of
those doors, nothing marks it and nothing says so.

`resolve_all` is the seam that makes that unrepresentable: a declared judge that cannot be
resolved is an error AT STAGING, naming the bad key and the known set — never a run that
ends quietly. An EMPTY declaration resolves to empty and is explicitly NOT an error, because
most activities judge nothing and that is normal, not a missing judge.

Five tests, each pinning a contract that failed in the wild: registry round-trip + named
miss; empty declaration is legal; unknown declaration fails loud and names it; the default
judge defers to the harness (so a task whose EvalTask already encodes done-ness needs no
judge code); an absent channel reads ABSENT, not as empty success.

NOT YET WIRED — deliberately, this is slice 1. Next: the recipe declares its judges in
`params`, dispatch resolves them through this registry, and the hardcoded `swe_bench::grade`
branch is DELETED rather than supplemented (a subtraction, per the design doc's build order).

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

* fix(kv): canonical order inside the STABLE tier — the other half of the #266 prefix defect

The tier-split shipped for #266 (stable framing first, volatile grounding last) did not
deliver reuse, and the comment at this sort said why without noticing: a stable sort
"preserves the salience order WITHIN each tier, so attention ranking is untouched". That
was treated as harmless. It is the remaining half of the defect. Salience is recomputed
EVERY turn, so preserving it as EMIT ORDER re-shuffles the very tier whose only purpose
is to be byte-identical across turns.

MEASURED LIVE 2026-08-21, inside Atlas's `pallets__flask-4045` run, from her own prompt
captures — not inferred:

  turn0→1  common prefix 8,216 / 9,906 chars   diverges into [now …]
  turn1→2  common prefix 7,879                 diverges into [active-work]
  turn2→3  common prefix 8,133                 diverges into [workspace-map]

~82% shared prefix, and the divergence points are stable-tier blocks TRADING PLACES.
Because the system prompt is FIRST, a swap at token ~2,000 invalidates the KV for
everything after it — including a 34,000-token conversation tail. `--cache-reuse 256`
was passed the entire time and every turn reported `cachedTokens: 0`. The cache was
correct; we were destroying the prefix ourselves.

Cost at the measured 111 tok/s prefill: ~306 SECONDS OF RE-PREFILL PER ACT, growing as
her conversation grows (9,847 → 36,242 tokens and climbing as tool results accumulate).
One observed turn was 20 minutes of apparent silence that was a single 36k re-prefill —
the run reporting `active`/`not stalled` the whole time, because the pulse is a timer.

THE FIX: within the stable tier, order CANONICALLY (by faculty name). Attention ranking
is genuinely untouched — salience still decides WHICH contributions are selected, which
happened above against the budget. It simply stops deciding WHERE the survivors sit,
which it never needed to. Same set in, same bytes out, every turn.

The volatile tier deliberately KEEPS salience order: it is re-prefilled by construction,
so canonical ordering would buy no reuse and would cost the "most salient nearest the
write point" placement #205 put there on purpose.

VERIFIED: 181 prompt tests pass, including
`framing_flip_never_perturbs_the_cacheable_prefix` — the #266 invariant is intact, this
extends it to the case it did not cover (a FIXED framing with re-ranked context).

NOT YET LIVE-PROVEN: the running core still holds the flask run, so deploy is correctly
blocked. The proof owed is her next captures — common prefix ~82% → ~100%, and
`cachedTokens` 0 → nonzero from turn 2. A regression test pinning "same set, different
salience → identical bytes" follows immediately.

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

* feat(probe): delib.generate.cache — make the KV fix prove itself instead of me diffing captures by hand

Joel: "hopefully it will prove itself via probes." It could not have. `delib` carried
`turn.demand` and `context.render` — how big the prompt WAS — and nothing about what the
lane DID with it. A prompt whose prefix we were destroying every single turn looked
identical in the probe stream to one served entirely from cache. That absence is why the
prefix defect (fixed in 40075d7) survived from #266 to today, and why the only way to
see it on 2026-08-21 was hand-diffing a citizen's raw prompt captures — exactly the manual
step a probe exists to delete.

The row lands in `metrics_from`, the single funnel every generation already passes
through, so one probe covers every turn of every citizen with no caller change:

  delib.generate.cache  cached_tokens prefill_tokens hit_rate prefill_ms decode_ms
                        input_tokens output_tokens latency_ms

`hit_rate` is `TurnMetrics::cache_hit_rate()` — the ratio that already existed and had no
way out of the process. 1.0 = fully warm prefix. Near 0 with a large `prefill_tokens` =
the prefix is being invalidated upstream, which is the measured pre-fix state: ~306s of
wasted re-prefill per act while `--cache-reuse 256` was set and working correctly.

Emitted ONLY when the lane actually reported timings. Cloud and older endpoints omit
them, and a fabricated 0.0 hit-rate for a provider that never measured one is a lying
receipt of the #151/#357 class — those stay silent rather than report a floor they did
not observe.

So the verification of the ordering fix is now a probe query rather than a capture diff:
hit_rate should climb off the floor from the second act of a task onward.

cargo check green (metal,accelerate). Signature and return value unchanged — purely
additive. The --lib gate in CI is the test proof; live proof still waits on the flask run
clearing the core.

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

* test(kv): pin "same set, different salience → identical bytes" — the guard the #266 half lacked

The sibling test `stable_framing_serializes_before_higher_salience_volatile_grounding`
pinned the TIER SPLIT and passed the whole time the prefix was being destroyed. It could
not catch this: it asserts stable-before-volatile, and says nothing about order WITHIN the
stable tier — which is exactly where salience was re-shuffling blocks every turn.

So this is the assertion that makes 40075d7 hold. Three different salience rankings and
three different arrival orders over the SAME three stable contributions must emit
byte-identical blocks. Revert to a salience-ordered stable tier and this fails while the
sibling still passes — which is the whole point of adding it rather than extending that one.

It also pins the rule POSITIVELY (canonical by faculty name), because byte-equality alone
would be satisfied by an insertion-order block that happened to match across this test's
particular arrival orders. An accidental pass is not a guard.

TWO THINGS THE TEST TAUGHT ME WHILE WRITING IT, both worth the next reader's time:

1. My canonical assertion was backwards from its own message. Alphabetically it is
   room-kanban < room-roster < workspace-map — roster sits BETWEEN, and I asserted
   kanban < map < roster. Caught by the test, on the first run.

2. The volatile-tier assertion FAILED, and it was my probe that was wrong, not the code.
   I reached for `active-work` as a volatile example. It is pinned FIRST by an explicit
   rule ABOVE salience (ctx.sort_by, :888-905) because the ctx_floor reservation for a
   citizen's held card only holds if its claimant also leads the greedy selection walk.
   So I had picked the one faculty in that tier where salience is deliberately not the
   deciding key, and the result read as "salience does nothing here" about a tier where
   it does plenty. Swapped to recall-vs-affect, which are genuinely salience-ranked, and
   left the trap written down in the test so the next person does not re-lay it.

That volatile assertion is deliberately `assert_ne!` — it guards the ASYMMETRY. The
volatile tier must keep following salience (#205, most salient nearest the write point);
it re-prefills by construction, so canonical ordering there would buy no reuse and would
cost that placement. If a future "make it all deterministic" pass reaches into that tier,
this fails and tells it why.

182 prompt tests green (was 181). Disk swept-clean, 128 GB free.

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

* docs(kv): the KV cache economy — and the naive "shared tool head" plan is DOMINATED

Joel asked for this DESIGNED, not patched. Reading the serving layer first was the whole
value: most of the machinery we were about to build already exists in llama.cpp and is
already switched on. Two facts read in-file today reverse the plan I would have written
from memory.

WHAT IS ALREADY TRUE (source-read, not inferred):

  * `slot_prompt_similarity` defaults to 0.1 and we never disable it — LCP-based slot
    selection is ALREADY ACTIVE (common.h:687, server-context.cpp:1543). Cross-persona
    head sharing is not a feature to build; it is a behaviour we already get, unmanaged.
  * `cache_ram_mib` defaults to 8192 — an 8 GiB host-RAM prompt cache ALREADY EXISTS, and
    the server already saves an evicted slot's conversation and restores the incoming one
    (prompt_save / prompt_load, server-context.cpp:1620).
  * We never pin `id_slot`, so affinity is emergent from prefix similarity and never
    declared. That is the actual gap: not mechanism, POLICY.

THE ARITHMETIC THAT KILLS THE OBVIOUS PLAN. With Atlas's measured numbers — ~7,600 tok
shared head vs a 36,242 tok tail:

    sim    = 7,600 / 36,242 ≈ 0.21  > 0.1  →  persona B TAKES persona A's slot
    f_keep = 7,600 / 36,242 ≈ 0.21  < 0.5  →  A's 36k is evicted

The shared head is big enough to WIN slot selection and small enough that winning throws
away 4.7× more than it saves. "Make the tool head identical and first so every persona
shares it" is right about token cost (#333) and is a precondition — but as a KV strategy
it is dominated, and shipped alone it makes slot theft MORE likely and would read as a
regression. Tail retention beats head sharing by the tail:head ratio, which grows every
act. Any design that trades a tail for a head is backwards.

So the order inverts: declared slot affinity (`id_slot` per resident citizen, eviction as
a priced decision behind the same seam as every other cache class) is the KEYSTONE, and
the shared head lands AFTER it. "Docker form" is exactly the right instinct for the head —
a shared prefix only stays shared if it is a function of LANE IDENTITY, not of whichever
citizen is calling: same model, flags, tool manifest, template → one head, with an
identity hash so divergence is LOUD rather than silent.

Reconciles with [[kv-prefix-caching-is-the-only-form...]]: that memory is about
CONVERSATION content, which is genuinely unique per citizen. A tool schema head is not
conversation, so sharing it is prefix reuse, not dedup.

FOUND WHILE WRITING, and it is its own defect: that 8 GiB prompt cache is UN-GOVERNED. We
never pass the flag, never budget it, never told the ResourceGovernor. Same shape as the
2026-07-13 incident — every component healthy, the wiring absent — in RAM instead of disk.
`--cache-ram` becomes a governed lease at spawn, like GGML_MOE_HOST_CACHE_GB (#287).

WHAT I DID NOT MEASURE, and the doc says so rather than guessing: the wall-clock of
prompt_save/prompt_load at ~36k tokens. It decides whether eviction is survivable or is a
second re-prefill in a hat, so step 1 is measuring it and step 3 is gated on the number.

Steps 1 (measure) and 2 (govern the RAM) are independent of the live flask run and can
start now.

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

* docs(kv): policy is an ADAPTER not a rule + decompose the 4,190-line server (Joel's steer)

Joel: "not too hard coded into one paradigm — better add proper adapters and break the
module down into concerns. We could do a ton with plugin ML here, especially RL."

Right, and reading first changed the answer for the THIRD time today: the seam already
exists WITH a learned implementation in it.

  * capacity/expert_tier_policy.rs — `trait TierPolicy { fn plan(...) -> ExpertTierPlan }`,
    decisions returned as a PLAN not applied inline; ClassicTierPolicy is the v1 heuristic.
  * expert-pager-policy LEAF CRATE — policy already extracted into its own crate. The
    plugin boundary is already cut.
  * capacity/bandit_plan_controller.rs — a BANDIT CONTROLLER, re-exported from it. RL is
    not greenfield here (#276/#281).
  * expert_predictor / expert_decay_policy / expert_residency / expert_observer — the
    concerns are already separated on the expert side.

So KV slot residency implements that shape rather than inventing a rival. And the
generalisation is now EARNED rather than speculative: CLAUDE.md says generalize at 2-3
instances, and we have three of "paged resource under scarcity with a learnable value
function" — MoE experts (built), LoRA genome paging (built), KV slots (this doc). KV slots
are the ideal outlier B precisely because they are MAXIMALLY DIFFERENT from experts: unit
is a whole conversation not a tensor, a miss costs seconds of prefill not bytes of fetch,
population is 2-8 not thousands. One seam fitting both ends fits everything between.

  - Outlier A, heuristic: cost_of_loss = tail_tokens / prefill_rate. A quantity with a
    UNIT (seconds), not a magic ratio. Ships first, is the permanent floor.
  - Outlier B, RL: state = per-slot (tail, recency, citizen, phase) + arrival; action =
    which slot; reward = PREFILL SECONDS SAVED.

AND THE REWARD SIGNAL IS ALREADY INSTRUMENTED — I shipped it this morning (faf8c07)
without noticing it was one. `delib.generate.cache` emits cached_tokens / prefill_tokens /
prefill_ms / hit_rate on EVERY generation: a labelled transition per turn, continuously, in
production. So the A-vs-B comparison is measurable from day one instead of argued.

Guardrails so "plugin ML" doesn't become unexplainable serving: policies return PLANS
(loggable, replayable, refusable); the heuristic stays callable forever as the floor and a
learned policy that loses on measured prefill-seconds is switched off by the comparison,
not by argument; the deciding policy's identity rides the receipt so a regression is
attributable; and never learn on a broken substrate — before the deterministic head landed
the reward was ~0 for structural reasons and a bandit trained through that would have
learned nothing helps.

DECOMPOSITION: inference/llama_server.rs is 4,190 lines — 8× the decomposition law, and
where every §3 change would otherwise land. Named the six concerns (spawn/args, readiness,
slots, request, lifecycle, policy-as-leaf-crate). Explicitly a MOVE, not a re-architecture:
no new task, no new watch channel, no second registry — and the flag comments travel with
their flags, since those comments are the only record of the incidents that set each value.

ALSO CORRECTED §4: `--cache-ram` is not new work. capacity/host_cache_lease.rs is already
the governed lease, already runs on the governor tick, and its own module doc already says
why that matters here — "KV grows as slots fill". One more term on an existing lease.

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

* refactor(inference): extract the llama-server flag spine into lane_args — decomposition slice 1

Joel: "I hate this file. Decompose it away from slop." llama_server.rs was 4,190 lines
with every concern in it — flags, readiness, request shaping, lifecycle, orphan reaping —
and it is where every change in the KV design would otherwise land. Slice 1 of
docs/architecture/KV-CACHE-ECONOMY.md §7. Net -28 lines there, and a module that can
actually be tested.

WHY FLAGS FIRST. Answering "how do we use upstream llama.cpp" precisely: we consume it
TWO independent ways, and only one touches this file.

  * as a BINARY — llama-server spawned as a subprocess, spoken to over HTTP. ZERO
    linkage: llama_server.rs imports nothing from llama/ggml. Upstream drift reaches us
    as a changed CLI surface (this module) or a changed JSON shape (request/readiness).
  * as a LIBRARY — the `llama` crate links libllama in-process for forge/conversion.
    That is where our fork's C++ lives (K3 KDA, AttnRes, MoE gather). Never passes here.

So a fork rebase should touch this file and the wire shapes and nothing else. It could
not, while the flags were welded into a Command chain in a 4k-line file.

THE INVOCATION IS DATA. `base_invocation` is pure — primitives in, `LaneInvocation` out,
no Command, no process, no I/O. Same shape as `TierPolicy::plan`: return a plan, don't
apply one, so it can be asserted, logged and diffed. `envs` is on the struct because the
invocation genuinely is not args-only (LLAMA_RESIDENT_OVERRIDE, #29); modelling that as
"args plus a side effect someone remembers" is how it gets dropped.

FIVE TESTS THAT COULD NOT PREVIOUSLY EXIST, because asserting them meant launching a real
llama-server on a real GPU with a real model:

  * `-c` == per-lane window x lanes, and `--parallel` is EXPLICIT — the regression where
    inheriting llama.cpp's default of 4 silently served every citizen a QUARTER of the
    planned window. Nothing failed. That is why this is now three lines of pure arithmetic.
  * `--no-context-shift` present on every lane (#139: overflow must 400, never amputate
    the prompt middle and generate from the mutilation).
  * `--cache-reuse 256` still configured (~306s/act when absent, measured).
  * every value-taking flag is followed by a VALUE — the class that broke on 2026-08-20
    when upstream turned `--flash-attn` from a switch into one taking [on|off|auto] and
    the bare form ate `--mmproj`, so the lane failed to spawn and serving sat at 0 lanes.
  * the base invocation needs no environment.

COMMENTS TRAVELLED WITH THEIR FLAGS, verbatim, not paraphrased. Each one is the only
surviving record of the incident that set its value; moving a flag without its comment
destroys the reason and invites the reversion. Added one postscript to --cache-reuse:
the flag was never the defect, WE were mutating our own prefix (fixed in 40075d7) —
so nobody tunes this number looking for the win that already landed elsewhere.

SCOPE, deliberately bounded: the CONDITIONAL flags (KV quant, flash-attn, mmproj, MTP
draft, resident override, CPU placement, jinja, LoRA, MoE -ot) are still assembled by the
caller and are slice 2. This is the unconditional spine, which is also the part carrying
the arithmetic worth pinning.

VERIFIED: cargo check clean (metal,accelerate); 5 new tests pass; llama_server's 38 tests
pass. NOT MINE, flagged not absorbed: `first_free_port_skips_a_taken_port` is FLAKY under
parallel execution — same filter and binary gave FAILED then ok on an immediate re-run,
and it passes in isolation both with and without this diff. It binds a port and races.
Worth its own card; not silently folded in here.

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

* refactor(inference): conditionals behind LaneOptions + a generic AsArg — slice 2

Joel: "Move concerns to proper adapters" and "templates are underutilized by you in both
cpp and rust… it reduces code size a lot sometimes." Both applied here, not just agreed to.

SLICE 2 — the conditional flag surface moves out of the Command chain:
kv-quant / flash-attn / mmproj / MTP draft / CPU placement / resident-override now ride
`LaneOptions` into a pure `LaneInvocation::with_options`. llama_server.rs 4,190 → 4,079.

THE SPLIT THAT MAKES IT AN ADAPTER RATHER THAN A MOVE: every LaneOptions field is an
ALREADY-RESOLVED value, never a thing to look up. Resolution — reading config_env,
probing the registry for an mmproj or an MTP head, deciding placement, and emitting the
vision-capability RECEIPT — stays with the caller, which owns the I/O. lane_args decides
only what a resolved value MEANS on a command line. Gather inputs, then compute a plan:
the same shape as TierPolicy, and the reason the whole surface is unit-testable with no
GPU, no model, no process.

The vision warn stayed behind deliberately. A Vision-capable row with no projector serves
text-only and silently ignores images — a capability LIE — so it warns loud
([[fallbacks-are-illegal-fail-loud]]). That is a receipt about the world, not a flag, and
receipts belong with resolution.

THE TEMPLATE POINT, applied where it actually pays. Before, every value was hand-converted
at its call site — `total_ctx.to_string()`, `p.to_string_lossy().into_owned()`, a bare
`"256".into()` — three spellings of one idea, and three chances to push a VALUE without
its FLAG. So: one `trait AsArg` (impl for &str/String/&Path/u16/u32) plus `pair(args,
flag, value)`, and a valued flag becomes a single indivisible call. Monomorphised exactly
as a C++ template would be — one definition, zero runtime cost.

That is not cosmetic. Orphaning a value from its flag is precisely the class that took
serving to 0 lanes on 2026-08-20, when upstream turned `--flash-attn` into
`[on|off|auto]` and the bare form ate `--mmproj`. `pair` makes it unrepresentable instead
of merely tested for — and the test stays anyway, because a guard you can delete is not
a guard.

FOUR MORE TESTS (9 total in the module):
  * default options emit NO conditional flags and no env — "present when it should be
    absent" is a real defect; the mmproj case literally decides whether a citizen SEES.
  * --flash-attn keeps its value when sitting next to --mmproj: the 8/20 outage as a
    test rather than an outage.
  * resident override rides the ENVIRONMENT, never the args (#29) — the reason
    LaneInvocation models envs at all rather than returning a bare Vec<String>.
  * KV quant sets BOTH -k and -v; one without the other is a silent cache asymmetry.

STILL SLICE 3, deliberately not half-migrated: --jinja / chat-template sidecar, the LoRA
set, and the MoE `-ot` tensor overrides.

VERIFIED: cargo check clean (metal,accelerate); 9/9 lane_args tests pass.

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

* refactor(inference): slice 3 — jinja/LoRA/-ot move out; the flag CONCERN is now closed

Last of the conditional surface: the chat-template sidecar, the genome LoRA set, and the
K3 `-ot` expert placement. llama_server.rs 4,190 → 4,034 (-156); lane_args.rs is 521 lines
that are entirely about one thing. No flag is now built in two places, which was the
compression violation the half-migration would have left behind.

`--jinja` moved to the BASE spine, not to options, because it is unconditional — and the
comment explaining why is the most expensive one in the file. Gating it was a silent
capability kill: the switch used to require a forge-written sidecar to exist, so every
normally PULLED GGUF ran with tools DISABLED. The gateway ignored the `tools` param and
the persona NARRATED tool calls instead of emitting them. A model with hands, holding
them behind its back, because of a file that was never there. The sidecar now OVERRIDES
when present (forged GGUFs whose mlx→gguf conversion left a thin 208-char tool-less
template) and the embedded tool-capable template stands when absent — tools ON either way.

The LoRA join moved WITH its flag rather than staying at the call site, deliberately: the
join IS the flag's semantics. llama.cpp b8784+ deprecated repeated `--lora` and SILENTLY
keeps only the LAST, which was collapsing every multi-layer genome stack to a single
adapter — glass-boxed 2026-07-23 in the lane's own stderr ("DEPRECATED: --lora specified
multiple times... only last value will be used" x4) while a 4-layer stack was supposedly
serving. The genome's whole premise is layers that STACK; this arg SHAPE is what stacks
them. Split the join from the flag and the next person re-introduces the bug.

Resolution stayed with the caller for all three, same rule as slice 2: the sidecar
`is_file()` probe, the adapter paths, and `expert_ot_value()` are lookups; lane_args only
decides what a resolved value means on a command line.

VERIFIED: 351 inference tests pass; cargo check clean (metal,accelerate).

NEXT, and it is the seam Joel actually asked for: `trait LaneBackend` with llama-server as
impl A, so an mlx / vllm / remote-grid-peer lane is impl B rather than a fork of this file.
lane_args is now shaped to BE that impl rather than to be the only way.

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

* docs(serving): STDERR IS NEVER AN INTERFACE — and we break it twice (Joel's law)

Joel, 2026-08-21: "STDERR/out is never a place for interfacing, just debug."

Checked rather than agreed, and we violate it in two places, both written in good faith
for real incidents and both making llama.cpp's DEBUG TEXT load-bearing in our control
plane:

  * `inference::wedge::WedgeWatch` parses stderr for an impossible slot progress
    (`progress = 1.10`) and raises a flag THE SERVING DAEMON REAPS A LANE ON.
  * `inference::placement_watch::OffloadWatch` parses llama.cpp's LOAD BANNER for layers
    offloaded, then fires `serving.placement.cpu_fallback` — treated as a lease
    violation (#441).

Why it has to change even though it works today: stderr is unstructured, unversioned, and
drifts with upstream's logging taste. The failure mode when it drifts is not an error — it
is SILENCE. The watcher stops matching, the flag stops rising, and the wedge that burned
four hours on 2026-08-05 becomes invisible again with every component still green. Same
shape as every other defect in this document: an absence that looks like normal operation.
It is also, precisely, the class the #441 sentinel was built to catch — so the sentinel is
currently exposed to the failure it exists to detect.

The structured channels already exist: `/slots` carries per-slot state and progress,
`/props` the load configuration, and the per-request `timings` block already reaches us —
it is what `delib.generate.cache` reports. The tok/s sentinel should read
`prefill_tokens`/`prefill_ms` rather than scrape a banner.

THE LINE, since not all stderr reading is a violation: `stderr_log_tail()` on spawn
failure is CORRECT — a human asks "why did it die" and gets llama.cpp's own last words.
Reading stderr to SHOW is debug. Parsing stderr to DECIDE is an interface. The test is
whether a control path branches on it.

STATUS: named, not fixed. Rewriting both watchers onto /slots + /props needs those payloads
verified against our pinned build (b10196-fa7e0d8e9) first — asserting a field exists
because upstream documents it is the same mistake in a different channel.

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

* docs(kv): pin the PRE-FIX baseline from a live run — 0% reuse, 57,005 tokens re-prefilled in 4 acts

Measured 2026-08-21 10:57 off a LIVE run rather than argued: citizen e5f4141d, instance
pallets__flask-4045, pre-fix binary b10196-fa7e0d8e9, read from her own prompt captures.

  act 1: cached 0 / prefill  9,847  hit 0.000
  act 2: cached 0 / prefill 11,172  hit 0.000
  act 3: cached 0 / prefill 19,434  hit 0.000
  act 4: cached 0 / prefill 16,552  hit 0.000

57,005 tokens re-prefilled across four acts, zero reuse on every turn, ~513s at the
measured 111 tok/s — 8.5 minutes of a 4.3h budget spent re-reading, four acts in, cost per
act still climbing. That is the number 40075d7 has to move, now pinned to a specific
citizen on a specific instance so the after-measurement is a COMPARISON and not a claim.

METHOD NOTE, recorded because it nearly went wrong and it is the session's recurring
defect class: `pgrep` for a solve process finds NOTHING while a run is live, because
`agent/solve` executes INSIDE the core rather than as a subprocess. I read that absence as
"the run finished, deploy is unblocked" — and would have rebooted the box out from under a
citizen at act 4. Wrong instrument, absence misread, same shape as every retraction in
this document. The authoritative signal is
~/.continuum/progress/agent-solve-claim-<run>.json (state, acts, mtime): it said
state=running, acts=4, written 60 seconds earlier.

Deploy remains correctly blocked. The after-number is owed and is now cheap to collect —
same read, or just query delib.generate.cache once the fix is live.

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

* feat(serving): per-slot throughput verdict — the sensor missing when the round died today

TDD/VDD on a defect measured LIVE forty minutes ago, encoded while it is fresh rather
than remembered later.

THE INCIDENT. Citizen e5f4141d working pallets__flask-4045 in-room. Run reported
state=running, heartbeat every minute, acts frozen at 4 for twelve minutes. Lane answered
/health {"status":"ok"}, /props 200, /v1/models 200, port bound, process up 3h58m. Every
readiness signal in the system said healthy. Her own lane said:

  slot 1 | task 3   | n_decoded = 1092, tg = 2.65 t/s, tg_3s = 0.96 t/s
  slot 1 | task 3   | n_decoded = 1093, tg = 2.53 t/s, tg_3s = 0.05 t/s
  slot 0 | task 605 | prompt processing, progress 0.52, 105 t/s

Slot 1 decoding at 0.05 TOKENS PER SECOND — one token per twenty seconds — still holding
task 3 after six hundred tasks passed on the neighbouring slot. PREFILL WAS FINE (105 t/s,
the expected rate). Only decode collapsed, on ONE slot, and nothing could see it. That is
#386's per-slot wedge and it is the round-killer: a citizen at 1/600th speed burns her
whole 4.3h deadline producing nothing while the board renders a healthy pulse.

WHY LANE HEALTH CANNOT CATCH IT: /health is lane-scoped and the LANE is fine — the other
slot decodes normally, so every aggregate reads healthy. #363 established that readiness
must verify GENERATION not the socket; this is the layer below: generation must be
verified PER SLOT, because a lane is healthy exactly as long as its best slot is.

DESIGN, per the standing rules:
  * PURE function, transport-agnostic. It takes SlotObservation values, so it works the
    instant they arrive from a structured channel. /slots returns HTTP 000 on our pinned
    build — that is the follow-up, and the verdict logic must not wait on it.
  * expected_tps is a PARAMETER, never a constant here. What counts as collapsed depends
    on model and device; the catalog Model row owns that expectation (#441). A constant
    would be a hardcoded LCD clamp — either missing a real wedge on a fast box or crying
    wolf on a slow one.
  * Reads the 3-SECOND rate, not the lifetime average. The same slot read tg=2.53 (bad)
    while tg_3s=0.05 (dead); averaged over hours, a stopped slot looks merely slow.
  * Degraded REPORTS, only Wedged is actionable. #446 is the counter-example: starvation
    stamped as wedge evidence produced a 2-minute relaunch loop that WAS the outage.
  * A slot under 32 decoded tokens gets no verdict — killing cold generations is
    [[an-absence-is-an-unfinished-measurement]] wired to an actuator.

SIX TESTS, the first two carrying the live numbers verbatim: the incident classifies
Wedged; the lifetime average provably would have MISSED it (that test guards the
leading-indicator argument, not just the constant); merely-slow is reported not reaped;
a cold slot is never wedged; no expectation means no verdict; and the same observation
flips healthy/wedged with the device's own expectation.

INSTRUMENT NOTE, recorded in the module: those numbers were read out of stderr BY HAND,
which is the only way they were visible — and that is the exact defect Joel named today
("STDERR/out is never a place for interfacing, just debug"). Reading a log to DIAGNOSE is
correct. A control path depending on it is not. This module is the honest half; wiring it
to /slots is the other.

NOT YET WIRED — no caller, deliberately. The verdict is the testable unit; the actuator
(who reaps, when, under what lease) is a separate decision and belongs with the daemon,
same doctrine as the wedge flag.

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

* fix(inference): prefill is not decode — stop the 90s watchdog killing live prefills (the round-killer)

MEASURED on the M5, and it is why citizens took ZERO room turns across the probe
ledger's 868 minutes while every dashboard read healthy:

  demand        94,370 tok   against a 58,112-token window (over_window 1.62)
  prefill rate     382 tok/s (timed live: 603 tok → 17.7s; 5,728 tok → 31.1s)
  ⇒ first byte    ~170 s     for a window-sized prompt
  watchdog          90 s     ← fires first, every single time

44 `persona.settle.deliberation_retry` rows carry the verdict the watchdog reached:
"the slot HAD started our work and then stopped mid-stream, so the backend is stuck
or dead". It was neither. Atlas re-sent the byte-identical 94,370-token demand 21
minutes later and died the same way.

The cascade is what made it a round-killer rather than a slow turn: the ambient
permit is held across that wait, so three permits sat occupied ~90s each by turns
that could never finish. Measured +4 yields/min, EXACTLY, for 25 consecutive
minutes, zero successes — the perfect periodicity is the tell, since real
contention is bursty.

ROOT CAUSE, one line and not a missing feature. Both budgets already existed and
both were correctly sized for their own job: STREAM_IDLE_TIMEOUT_SECS (90s) is a
DECODE watchdog by its own doc ("a token every few hundred ms"), and
PRE_STREAM_HEADER_TIMEOUT_SECS (300s) is documented as "sized for a worst-case
full-window prefill queued behind co-tenants (minutes)". The adapter switched from
the second to the first the instant ANY progress arrived — and llama.cpp emits a
prompt_progress frame at 0% ingestion purely "to signal the client that the request
has started processing". So the decode watchdog policed the prefill, and the budget
written for exactly this case was skipped past within seconds.

FIX: `inference::stream_liveness` — a pure, transport-agnostic phase machine
(Queued / Prefilling / Decoding) that names the distinction once so no caller
re-derives it. Bulk work gets the bulk budget; the drip gets the drip budget.

Deliberately preserved:
- #385 keeps its teeth. Liveness is still keyed on the GAP BETWEEN PROGRESS EVENTS,
  never elapsed total, and the stamp still requires `processed` to STRICTLY advance
  — so a slot replaying a frozen counter still fails, just at the prefill budget.
- #446 keeps its diagnosis. `has_started()` still separates never-started
  (dead backend vs oversubscribed queue) from started-then-stopped.
- Decoding is TERMINAL, so a late/stray progress frame cannot re-open the generous
  budget mid-decode. My own test caught that the first implementation could.
- Providers that never report prefill (every cloud adapter) go Queued → Decoding on
  first output, so their budgets are bit-for-bit unchanged. Strict addition, never
  a relaxation.

Phase transitions are detected at ONE site per kind rather than repeated at each of
the four output sites, so a new output kind cannot forget to declare itself.

7 new tests carry the live incident numbers verbatim, incl. the 0%-frame case that
IS the outage and a regression guard for no-prefill providers. 36/36 existing
openai_adapter tests green.

Design + the full measured chain: docs/architecture/ADMISSION-IS-UNOBSERVABLE.md
(also records the admission-snapshot gap and the seven wrong reads it took to get
here — two of them my own instruments lying, not the system).

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

* feat(inference): probe the prefill fix — "no retries" is an ABSENCE and proves nothing

Self-correction. I shipped the phase machine and emitted NOTHING for it, then read
"RETRIES: 0, TURNS: 0" off the ledger and could not say whether prefills now survive
or nothing was running. That is the same unobservable-state defect the design doc in
the previous commit exists to complain about, committed by me one commit later.

Two rows, both at the seam that actually decides:

- `inference.prefill.rescued` — fires ONCE per stream, only when a prefill has
  already outlived the OLD decode budget AND is still advancing. Every row is a turn
  that under the previous flat 90s would have been killed here and retried forever.
  This is a POSITIVE signal for a fix whose symptom is an absence.

- `inference.prefill.complete` — total / cached / fresh / elapsed_ms / tok_per_s /
  would_have_died, at the prefill→decode edge. This is the number the 90s constant
  was implicitly guessing at, and the one the budget should eventually be DERIVED
  from per model+device (#441). It also finally measures the KV cache's REAL
  contribution per stream (`cached` vs `fresh`), which is the instrument the KV
  ordering work has been owed.

Joel, mid-session: "Have to probe better." Correct — a fix I cannot see working is a
fix I have not proven.

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

* fix(inference): split queue-wait from ingest in the prefill receipts — a probe that mixes two regimes measures neither

First cut of `inference.prefill.complete` produced absurdities that were the
conflation talking: a 467-token prompt "prefilling at 1 tok/s for 231s". It was
queued ~230 of those seconds waiting for a slot. llama.cpp's 0% progress frame
marks slot ASSIGNMENT, so the honest split is:

  queued_ms  = stream open → first progress frame   (admission/oversubscription, #234)
  ingest_ms  = first frame → prefill complete        (real ingest work)

`ingest_tok_per_s` is now computed over ingest only — the number a derived
per-model budget must come from (#441). `rescued` rows carry `queued_s` for the
same reason.

Source-read while here (vendor llama.cpp): prefills ARE continuous-batched across
slots (`can_batch_with` + cont_batching), so concurrent prefills share compute by
design. The 230s waits mean all 4 slots were OCCUPIED — by window-scale
re-prefills that zero KV reuse makes ~5 minutes each. Queue wait is downstream of
the KV defect; the split makes that attributable per stream instead of argued.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(inference): a loading lane must not latch slot affinity off — the boot race that undid persona pinning every launch

slot_for_persona (2026-07-11) pins each persona's prefix to its own llama-server
slot. It has likely been latched OFF on virtually every boot since: the /props
probe latched SlotAffinity::Unsupported on ANY non-success status, and personas
start deliberating while the lane still answers 503_loading (measured ×93 in this
ledger). One probe racing the load window → pinning dead for the process's life →
prefix-similarity slot theft → cached: 0 mid-conversation, measured today.

Only 404/501 — "no such surface" — may latch. Extracted the verdict as
props_status_proves_endpoint_absent() and pinned it with a regression test carrying
the incident: 503/500/502/429 defer and re-probe; 404/501 latch (without that,
every cloud provider would re-probe per persona request forever). A malformed body
from a live server also defers now — mid-load servers answer partial bodies.

Observability, same lesson as the prefill probes ("no rows" must be distinguishable
from "latched off silently for weeks"):
- inference.slot_affinity.pinned    — once per persona pin, proves affinity is LIVE
- inference.slot_affinity.evicted   — names the victim; cross-persona eviction IS
                                      the KV-clobber event and must be priced
                                      (KV-CACHE-ECONOMY: a decision, not an accident)
- inference.slot_affinity.deferred / .unsupported — the latch decision itself

Measured on the previous build (6dea7c4, 10-min window) with queue/ingest split:
queued=0s on ALL streams — no slot wait; the residual is ingest-share under
continuous batching. First nonzero mid-scale KV reuse ever recorded (cached=2912 of
21002) with affinity still latched off; this fix targets exactly that number. Two
died_old=1 prefills (163s, 192s) completed that the old watchdog would have killed.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(persona): 'never thought' is a state, not a 584-million-year idle — the renewal probe stops stamping u64::MAX

idle.unwrap_or(u64::MAX) printed idle_ms=18446744073709551615 into the ledger
(seen live 2026-08-21). The gate logic was right; only the receipt lied.
[[unknown-is-not-a-quantity]]: the unknown gets a word ('never-thought'), never
a sentinel number a reader must recognize by its astronomical size.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs: resolution log — all four fixes proven live same-day (retries 0, first slot pins ever, 99.7% KV reuse on byte-stable prompt)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs: citizen act observed post-fix; deaf-kickoff scoped to subscription coverage (cursor layer exonerated)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): clone_at serializes per destination — the race that voided sympy-18057's finished artifact at grading

The 2026-08-18 grade loss, root-caused: `clone_at` removes its destination at entry
AND razes/renames it at the commit point, while the protocol legitimately wants the
same instance's tree more than once (her work tree + the pristine score tree; a
lapsed-claim auto-grade racing a re-stage). Concurrent callers deleted each other's
trees mid-use.

The trigger was a Node-era assumption fossilized in a path: staging is
`cloning-{pid}`, unique when every clone was its own process — but in the headless
core every clone shares ONE pid, so two concurrent stages computed the SAME staging
path and the stale-staging sweep deleted a LIVE clone mid-fetch:
"repo.cloning-78289/.git/: No such file or directory" — a finished artifact voided
at scoring.

Fix, constraint-first:
- One live clone_at per DESTINATION: per-repo_dir tokio::Mutex registry (async lock —
  the section awaits git subprocesses throughout; keyed by repo_dir, not instance, so
  a 300-instance sweep does not serialize globally).
- staging_path_for(): pid + per-invocation nonce, extracted pure for testability.
- Dead-staging sweep by `<name>.cloning-` prefix instead of exact-name match — with
  nonced names an exact match can never find a crashed run's leftovers, and unswept
  litter violates the no-cache-dir-without-an-eviction-story rule (2026-07-13).

Two regression tests carry the incident: staging uniqueness + sweepable prefix, and
lock identity per destination.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): a round survives the core that opened it — persist in-flight rounds, reload on first touch

Measured twice on 2026-08-21: the ROUNDS map was process-memory, so a reboot
mid-round (1) blanked `benchmark/rounds` while a staged round was live — the
operator re-derived the round from probe archaeology — and (2) silently flipped
driver_for_card back to DetachedSolve for a Citizen round's remaining cards,
quietly rebuilding the parallel runner the round was configured to avoid. With
"restart freely" as standing doctrine, every deploy was round-murder: 8 of the 20
most recent runs on this box carry "killed by a core restart".

The round is now durable state, same family as the airc attach cursor: one JSON
file per in-flight round under ~/.continuum/state/bench-rounds/, written on every
mutation (open / add_card / settle / seal), removed at Done. First touch of ROUNDS
reloads — no boot hook; the first driver_for_card after a reboot already answers
from the reloaded round. bench.round.reloaded announces each recovery.

Eviction story (the 2026-07-13 rule): files self-evict at Done, and a Done file
surviving a crash window is dropped AND deleted on reload, never resurrected as a
round no event can settle. Persist failure degrades to the old amnesia and WARNS —
durability must never fail a live dispatch.

HONEST LIMIT, stated in code: cards that reached terminal state while the core was
down still read as working until the next event. Re-deriving card state from the
board at boot — and consuming the orphan-reap report (`needs_redispatch: true`,
which nothing consumes today) — is the follow-up reconciler, per
ROUND-LIFECYCLE-AS-RECIPE-OWNED-STATE-MACHINE.md. This commit restores the round's
EXISTENCE, which is what every later reconciler needs first.

Two regression tests carry both measured defects.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): round tests persist to a temp dir, never the operator's real state

Caught within the hour: the persistence layer resolved $HOME unconditionally, so
the EXISTING tests — which exercise the public open_round/add_card — minted four
phantom rounds into ~/.continuum/state/bench-rounds across two cargo test runs,
and the next live core faithfully reloaded them (in_flight: 5 with one real
round). A durable layer's tests must be durable somewhere disposable: cfg(test)
resolves to a per-process temp dir. Verified: full bench_round suite leaves the
real state dir untouched.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Sep 5, 2026
…not served — ready is a verified observation (#3759)

Before: the placement readback (#441) only probed `serving.placement.cpu_fallback` when the
engine's banner said 0 layers offloaded, and nothing parsed the engine's own "no usable GPU
found" line; the daemon then marked the lane ready. BigMama's 5090 (2026-09-05) served Devstral
from system RAM behind `ready:true lanes:3` — the pre-spawn device probe had said CUDA0, the
served process declined the GPU, and every status surface said fine.

- placement_watch: `OffloadReport::gpu_declined()` is set by the same stderr watch when the
  engine prints "no usable GPU found" / "compiled without GPU support" (a distinct fact from
  `offloaded 0/N` — some builds print no banner after it). Test.
- llama_server readiness: on a GPU-placement lane, `declined || offloaded == 0` kills the child
  and returns Err with the evidence and the stderr tail (`serving.placement.refused`) — the same
  shape as the debug-build gate. CPU-by-plan lanes are untouched; partial offload stays legal.

Finder credit: Joaquin (persona), card 0c4317e1 — the serve-time pin-match gap, named hours before
the receipt. Tests: placement_watch + llama_server mods 41/41.


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

Co-authored-by: Claude Fable 5.1 <[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.

2 participants