Skip to content

fix(cognition): an output allowance is SECONDS × her measured decode rate — every turn bounded in time; a pass costs a pass, never the reserve - #4194

Merged
joelteply merged 1 commit into
canaryfrom
fix/an-output-allowance-is-seconds-times-her-decode-rate
Sep 20, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/an-output-allowance-is-seconds-times-her-decode-rate

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Faster, by this much

Kimi on the 5090 (27B, ~40 tok/s):

turn before after
workspace pass (no card held) 100,704 tokens · 8–10 min · thinking unbounded ≤ 800 tokens · ~20 s · thinking ≤ 1,024
act (tool call + plan) 12,288 only when deliverable, else the whole window ≤ 6,000 · 150 s
message the reserve (~50k) ≤ 3,600 · 90 s

Cycles per hour: from ~2 to as many as her work allows.

What was wrong — the unit, not the number

Fable's derivation, confirmed on the box: delib.act.output_capped had fired 0 times for Kimi. The act cap (card 61b6e54d) was gated on is_work_turn = deliverable && hands, so a citizen holding no card ran her workspace turns on the reserve alone — the turn with the least to do was licensed to generate the most. The reasoning budget (card 12ef9c10, purpose cognition/act) was gated the same way, so she thought without bound and then generated without bound. Two cycles an hour, nothing written: "no 27B working on hard code."

The cap recurred at three magnitudes (5,316 → 12,288 → 100,704) because each fix moved the number. The requirement is time — Joel: "a slow persona is as good as dead"; 1.5× tax acceptable, 5–10× disqualifying.

The change

  • TurnKind { Act, Pass, Message } selects a latency budget in seconds (150 / 20 / 90).
  • output_allowance = budget × measured_tps — the decode knee's own freshest trusted EMA (decode_knee::measured_tps_for), floored at the smallest useful act (768), ceilinged by the runaway bound (12,288) and the reserved room. Unmeasured = the knee's floor rate (10 tok/s): nothing runs on the reserve before the first sample. A slow lane tightens by itself.
  • Act and Pass carry the cognition/act purpose → the reasoning budget applies to both.
  • Probe delib.turn.output_allowance on every request: kind, budget_secs, measured_tps, allowance, reserve — the time-to-act instrument.

Next slice, named: the 27B still thinks ~1k tokens before a call; the act budget can fall to seconds once that thinking is bounded tighter (61b6e54d).

Tests

every_turn_is_bounded_in_time_never_the_reserve — derivation, floor, ceiling, unmeasured, pass < act, and the request carries it. Three window tests relaxed from cap == reserve to cap <= reserve (the invariant they protect). Faculty 70, decode_knee 5, request_body, hygiene green.

Receipt after deploy on the 5090: delib.turn.output_allowance kind=pass allowance≈800, Kimi's cycle time in seconds, persona.turn.metrics output_tokens in the hundreds on pass turns.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

@joelteply
joelteply force-pushed the fix/an-output-allowance-is-seconds-times-her-decode-rate branch 2 times, most recently from fadea03 to c0d0d7e Compare September 18, 2026 20:00
…rate — every turn bounded in time, a pass costs a pass, never the reserve

FASTER, by this much: Kimi on the 5090 (27B, ~40 tok/s), a workspace pass
turn went from 100,704 output tokens / 8-10 min to at most 800 tokens / ~20 s
(and its thinking from unbounded to 1,024). An act turn: at most 6,000 / 150 s
(was 12,288 only when deliverable, else the whole window). A message turn: at
most 3,600 / 90 s (was the reserve, ~50k). Cycles per hour go from ~2 to as
many as her work allows.

Measured 2026-09-18 (Fable's derivation, confirmed on the box): the act cap
(card 61b6e54d) was gated on is_work_turn = deliverable && hands, so a
citizen holding no card ran her workspace turns on the reserve alone — the
turn with the least to do licensed to generate the most — and the reasoning
budget (card 12ef9c10, purpose "cognition/act") was gated the same way, so
she thought without bound and then generated without bound. Two cycles an
hour, nothing written: "no 27B working on hard code".

The unit was the defect. The cap recurred at three magnitudes (5,316 → 12,288
→ 100,704) because each fix moved the NUMBER; the requirement is TIME (Joel:
"a slow persona is as good as dead"; 1.5× tax acceptable, 5-10× disqualifying).
Now: TurnKind {Act, Pass, Message} selects a LATENCY BUDGET in seconds
(150 / 20 / 90); output_allowance = budget × measured_tps (decode_knee's
freshest trusted EMA — the knee's own instrument), floored at the smallest
useful act (768), ceilinged by the runaway bound (12,288) and the reserved
room. Unmeasured = the knee's floor rate (10 tok/s), so nothing runs on the
reserve before the first sample. Act AND Pass carry the act purpose, so the
reasoning budget applies to both. Probe delib.turn.output_allowance carries
kind, budget_secs, measured_tps, allowance, reserve on every request — the
time-to-act instrument Fable's rule #2 asks for.

Next slice, named: the 27B still thinks ~1k tokens before a call; the act
budget can fall to seconds once that thinking is bounded tighter (61b6e54d).

Tests: every_turn_is_bounded_in_time_never_the_reserve (derivation, floor,
ceiling, unmeasured, pass < act, request carries it); three window tests
relaxed from "cap == reserve" to "cap <= reserve" — the invariant they protect.
llm_deliberation_faculty 70, decode_knee 5, request_body, hygiene green.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto canary (a83603b) at 650fde5 — the only conflicts were additive in decode_knee.rs (measured_tps / measured_tps_for beside today's lightest_trusted_tps / conservative_knee / fresh_samples); both sides kept. Verified on the M5 before pushing: decode_knee (8) + every_turn_is_bounded_in_time_never_the_reserve pass locally. This is the M5's throughput lever tonight (10-min acts → many short ones); it earns one restart. @cormac a word at 650fde5 when CI is green (BigMama is away).

@joelteply
joelteply force-pushed the fix/an-output-allowance-is-seconds-times-her-decode-rate branch from c0d0d7e to 650fde5 Compare September 20, 2026 19:45
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact rebased head 650fde5 (CI running at read time; 9/9 local on the M5 per Fable). BigMama's PR; my word stands in.

The unit is the fix: output_allowance = budget_secs × measured_tps, floored at the smallest useful act, ceilinged by the runaway bound and the reserved room, and — the part that closes the 0-fires history of delib.act.output_capped — a workspace turn with no card held is a PASS with its own 20 s budget and the cognition/act reasoning budget, not a licence to run the reserve. TurnKind makes the three shapes one enum with the budget on the type; the probe on every request is the time-to-act instrument the measure lane asked for; the three window tests relaxed from == to <= keep exactly the invariant they protected. Faster by the table in the body, and the rebase onto today's decode_knee is clean (measured_tps reads the freshest TRUSTED point, which is #4269's trust).

One note, not a condition, for the next slice: when no point is trusted — every boot after a gap, until MIN_SAMPLES fresh samples — the rate falls to DECODE_FLOOR_TPS (10 tok/s), which on the IntelMac (measured 2.6 tok/s today, 402 tokens in 151 s) OVER-allows an act by ~4× in time (1,500 tokens ≈ 580 s, not 150). #4269 just established for the knee that a gap resets trust, never the evidence: measured_tps_for wants the same stale branch — the last measured EMA for this model on this box before the floor constant. Still 8× tighter than today on that box, so it rides; the stale read is a one-line sibling.

@joelteply

Copy link
Copy Markdown
Contributor Author

Green at 650fde5. @cormac a word at this head, please — it merges alone tonight for the M5's throughput.

@joelteply
joelteply merged commit 0047d52 into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/an-output-allowance-is-seconds-times-her-decode-rate branch September 20, 2026 20:10
joelteply added a commit that referenced this pull request Sep 20, 2026
… decode rate — every turn bounded in time, a pass costs a pass, never the reserve (#4194)" (#4275)

This reverts commit 0047d52.

Verified on the M5 within 15 minutes of the restart (build 0047d52, 20:58Z–21:14Z):
the decode rate read as unmeasured after the boot, so the allowance fell to its floor —
`delib.turn.output_allowance kind=pass budget_secs=20 measured_tps=0.0 allowance=768`
and `kind=act budget_secs=150 measured_tps=0.0 allowance=1500` — while the reserve that
bounded the turn before this change was 2,172–6,932 tokens. Qwen3.8 reasons before it
answers: `persona.act.think_only reasoning_len=2730` and `=2112` (Benchy, twice) —
"generation ended inside the reasoning channel — no answer, no act". Zero acts by
construction. Even with a measured rate the model is wrong for a thinking model on this
box: 20 s × 12 tok/s = 240 tokens for a pass cannot hold the reasoning channel.

The allowance must be at least the reasoning channel's measured need (or thinking must
be off for a pass), and an unmeasured rate must fall back to the stale/conservative knee,
never to zero. That is a redesign, not a patch; card ba82d0a0 carries it. Revert first,
the fleet cannot sit on a build whose minds cannot finish a thought.


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

Co-authored-by: Claude Fable 5.1 <[email protected]>
joelteply added a commit that referenced this pull request Sep 20, 2026
…x(time × her rate, her measured think + answer); unknown is the reserve; the rate is never 0.0 (#4283)

* fix(cognition): the output allowance holds the reasoning channel — max(time × her rate, her measured think + answer), unknown is the reserve, the rate is never 0.0

Measured on the M5 (2026-09-20, 20:58–21:14Z) after #4194 (reverted in #4275):
the allowance was budget_secs × measured_tps with budgets act 150 s / pass 20 s.
After the restart the rate read 0.0 and the allowance fell to a floor —
`kind=pass measured_tps=0.0 allowance=768`, `kind=act allowance=1500` — against
the reserve of 2,172–6,932 it replaced. Qwen3.8 reasons before it answers;
`persona.act.think_only reasoning_len=2730` and `2112`: two turns ended inside
the reasoning channel — no answer, no act. Even measured, 20 s × 12 tok/s = 240
tokens cannot hold a thinking pass. Joel's law: bounds sized wrong are where AIs
ruin a project; busy is not dead.

The design, on the reverted state (#4194's code is not reintroduced):

1. allowance = max(time_budget × rate, reasoning_need + answer_need), under the
   reserve the prompt left (and an act's runaway bound). The need is this mind's
   MEASURED per-channel demand: `WorkingSetRegistry` now keeps the last 16 turns'
   reasoning / answer tokens beside the emission peak (same `emission.json`, same
   owner, survives a restart like `working_set.rehydrated`); `need_of` is the p90
   with 5/4 headroom, unknown (None) before three turns and for a legacy file.
   Unknown is NOT zero: with no measured need the allowance is the reserve the
   reverted code used, never a constant. The split is the server's output count
   apportioned by the bytes the adapter separated into `reasoning` and `text`; a
   Length stop with no answer doubles the cut think.
2. The rate is never 0.0 for a served model: `decode_knee::rate_for` falls back
   fresh → stale (the record survives the restart) → the slowest curve on the
   box → and only with no curve at all, unknown, in which case the time term is
   skipped and the need term alone bounds. `rate_source` = fresh | stale |
   conservative | none.
3. A pass on a thinking model keeps thinking and its allowance holds the measured
   reasoning need: `TextGenerationRequest` carries no per-request thinking
   switch (only the gateway-level `ThinkingMode`, the JSON `response_format`
   kicker and the act purpose's `reasoning_budget_tokens`), so the think is
   budgeted, not disabled.
4. Receipt: `delib.turn.output_allowance` carries kind, rate_source,
   measured_tps, time_term, need_measured, reasoning_need, answer_need,
   need_term, need_clipped, allowance, reserve. The hour line gains
   `think-only N` (`citizen_health::note_think_only` at the think_only seam).
5. Tests, in the existing mods: unmeasured rate + need → the old reserve; a
   measured need dominates a small time term; a pass never gets less than the
   measured think + answer; rate falls back stale → conservative → unknown, never
   0.0; the need is a p90 with headroom, unknown before measured, survives a
   restart; the hour line carries think-only.

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

* fix(cognition): the hour ledger's window test reads the think-only slot

CI (cargo check windows-msvc, lib + tests): two E0308s — `snapshot_and_reset`
returns nine counters now and `the_tick_reads_a_window_not_a_lifetime`
destructured eight. It reads the ninth and asserts it resets with the rest of
the window, which is the invariant that test exists for.

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

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
joelteply added a commit that referenced this pull request Sep 20, 2026
…red_tps_for` went with the #4194 revert

CI (the compiler) caught the one symbol the rebase carried over from the reverted
output-allowance work. `decode_knee::tps_for` is the rate this box measured at the
LIGHTEST trusted concurrency; the plan's own lane count already respects the measured
knee (`plan_serving` applies `knee_lanes`), so "every lane here decodes at or above
the floor" is the plan's statement and this number says how fast. `None` (never
measured) stays an absence the allocator does not read as a refusal.

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 Sep 20, 2026
…red_tps_for` went with the #4194 revert

CI (the compiler) caught the one symbol the rebase carried over from the reverted
output-allowance work. `decode_knee::tps_for` is the rate this box measured at the
LIGHTEST trusted concurrency; the plan's own lane count already respects the measured
knee (`plan_serving` applies `knee_lanes`), so "every lane here decodes at or above
the floor" is the plan's statement and this number says how fast. `None` (never
measured) stays an absence the allocator does not read as a refusal.

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 Sep 21, 2026
…ry join and plan change; a mind moves to a strictly better seat between turns (card 10bba591) (#4281)

* feat(grid): the allocator daemon — the grid re-seats its minds on every join and plan change, and a mind moves to a strictly better seat between turns (card 10bba591)

Before this the pure allocator had no live caller: minds moved only on FAILURE (a
lane wait past a bound, a seat window below the turn), nobody re-ran the allocation
when a node joined or a plan changed, so a mind on a 32k seat stayed there when a 70k
seat appeared. Joel: "Can it grow to higher capacity as both the M5 and the 5090 come
online, ideally no time lost."

- modules/grid_allocator.rs: `GridAllocatorModule`, the canonical shape — own task,
  `tokio::time::interval` at the gossip beat, woken early by the ledger's new
  `heard_notify` and the plan watch, body under `catch_unwind` with quarantine after
  three panics, an atomic key gate so an unchanged grid publishes nothing, a
  process-global `watch::Sender<Option<Arc<Published>>>`. Inputs are what exists:
  `LanePlan::of` the published ServingPlan + the measured decode, the gossip ledger's
  foreign offers (same rows the grid module folds — no second listener), the live
  roster with the recipe's roles (`roles_from_ids`, the canary-side fold; #4271's
  declared requirements slot in), the operator's hold. Peers' residents are seated as
  anonymous minds homed there so a full peer never reads as open seats. Publishes the
  dormant order (oldest last turn first) and a clip interval derived from the slack.
  Probes: grid.allocation.published, grid.dormant.oldest_turn_age_ms.
- persona/placement_switch.rs: `decide_opportunity` (pure) + `follow_the_allocation`
  — a strictly better seat (requirement, then the allocator's capability / lanes /
  window order) moves her between turns only, inside a cooldown derived from her
  measured turn cadence (never a new constant); a remote seat asks for its slot first,
  a home seat retires her override (`come_home_for_good`). Probe
  placement.move.opportunity. Failure moves now count too.
- cognition/resource_admission.rs: `begin_turn` RAII guard replaces the bare stamp —
  in-flight mark + measured `TurnShape` (turn, cadence) per mind.
- persona/spawner_module.rs + host.rs + ipc/mod.rs: the allocation owns this node's
  lane-side seat count once published (`GridRoster`, told each reconciler pass; the
  reconciler now also wakes on a publish); the warm-slot bound is the prior before it;
  the population bound stays the spawner's.
- modules/citizen_health.rs: the hour line gains "moves: N on opportunity / M on
  failure" and "oldest dormant turn".
- cognition/grid_allocation.rs: `LanePlan::better_than` / `BetterBy`, `GridRoster`,
  `roles_from_ids`.

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

* docs(probes): name the grid allocator and opportunity-move probe classes in the manual

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

* refactor(grid): one requirement notion, one citizens fold — the allocator daemon speaks canary's vocabulary (card 10bba591)

Rebased onto canary (the window allocator #4260, the KV cache decision #4285, the
workspace transfer #4278, `roles_from` over `CitizenRecipe` #4271). Cormac's note on
#4281 was to fold rather than keep a parallel notion; this does that:

- `roles_from_ids` (mine, over `RoleId`) is DELETED. The daemon calls canary's
  `roles_from` over `CitizenRecipe`, so a role's declared `CitizenRequirement` reaches
  the grid allocator as authored instead of being flattened to a measured window.
- `experience::source`: `resident_citizens` / `resident_citizens_embedded` are now the
  ONE fold over the default recipe; `resident_roles` is their projection (`.map(role)`).
  Before this the only reader dropped the requirement on the way out, so #4271's field
  could not reach the allocator at all. Boot reads the citizens once and hands the
  spawner their roles.
- `window_allocator::requirements_for(personas, working_set)` + `largest_known(reqs)`:
  the ONE derivation of what a seat's minds require (untrimmed demand × SENT_HEADROOM,
  `Unknown` until she has turned). The serving daemon's inline copy is replaced by the
  call; the grid daemon's own `sent_median_of + prompt_floor_of` is gone — an
  UNDECLARED role now stands at the largest `LaneRequirement` the seat knows, which is
  exactly what an `Unknown` resolves to in her allocator. One vocabulary, two callers.
- An opportunity move now passes `workspace_transfer::move_blocker_bounded` before the
  reservation ask, like the fall-home / return / spill paths (#4278, card 73eefbbb): a
  better seat is still there next tick, her unpushed work is not.
- Health line merged with canary's `think-only`; the fixture and args carry both.
- New surface is `pub(crate)` (the daemon's types, the opportunity rule, the turn
  ledger, the grid-roster seam) so the crate's public reachability is unchanged.
  `GridRoster` / `BetterBy` stay `pub` in `cognition::grid_allocation` beside their
  neighbours — they appear in that module's own `pub fn` signatures.

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

* fix(grid): the local offer's decode reads canary's `tps_for` — `measured_tps_for` went with the #4194 revert

CI (the compiler) caught the one symbol the rebase carried over from the reverted
output-allowance work. `decode_knee::tps_for` is the rate this box measured at the
LIGHTEST trusted concurrency; the plan's own lane count already respects the measured
knee (`plan_serving` applies `knee_lanes`), so "every lane here decodes at or above
the floor" is the plan's statement and this number says how fast. `None` (never
measured) stays an absence the allocator does not read as a refusal.

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

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
joelteply added a commit that referenced this pull request Sep 21, 2026
…sation fill is 30s × THIS node's measured prefill rate, and it may never cost her the record of her own last act (#4290)

* fix(cognition): a clip is derived or it is a named floor — the conversation fill is 30s × THIS node's measured prefill rate, and it may never cost her the record of her own last act

PART 1 — THE INSTANCE (card 7d044c91)

`latency_fill_cap = PREFILL_TARGET_SECONDS * CONSERVATIVE_PREFILL_TOKENS_PER_S`
— a constant times a constant, 30 × 500, a flat 15,000-token conversation fill
on every machine in the fleet.

Measured live on the M5 tonight:
  delib.fill.latency_capped persona=Aiko   window_budget=56227 cap=15000
  delib.fill.latency_capped persona=Benchy window_budget=47440 cap=15000
Aiko holds a 67,072-token lane and is handed 15,000 of conversation — 27% of her
own context. And the 500 t/s the cap assumed is fiction here:
`inference.prefill.complete` measured `ingest_tok_per_s` of 70, 90 and 92 on the
M5, ~25 on the IntelMac. So the constant was 5–20× optimistic and the 30-second
target it exists to protect was really ~187 s. The cap failed its own stated
purpose on every machine while taking her context away.

The tokens-per-second half is now MEASURED — `prefill_rate::latency_fill_cap`,
on the same rate-source ladder #4283 established for decode: fresh, else stale
(the record survives a reboot), else the slowest rate any model on this box
holds, and only with nothing ever measured a named floor
(`UNMEASURED_FILL_FLOOR_TOKENS` = the substrate's own bootstrap working set).
`PREFILL_TARGET_SECONDS` stays as the LATENCY INTENT — the one chosen number,
and a real product decision. The probe now carries `rate_source`,
`measured_prefill_tps`, `target_seconds` and `derived_cap`, so a clip is never
again invisible.

PART 1b — WHAT THE CLIP IS ALLOWED TO COST HER

The assembly under the cap is sophisticated; a crude cap on top of it throws the
mind into chaos. The drop is already recency-ordered (oldest first, whole
messages, cluster-aligned, with stimulus / room updates / latest result held in
typed slots outside the eviction range) — but HOW FAR it reaches was decided by
cost alone, and a tight fill budget walks it right up to the run at the end: her
act, its result, and the turn that asked for it. That run is the evidence she
already did the thing. Lose it and she re-issues the act —
`persona.act.repeat_short_circuited` ("identical act already satisfied this
turn"), then `persona.act.no_deliverable_yet`, then an hour with zero writes
that reads as a lazy persona.

So: `fit_messages` holds that run out of the drop whenever the budget can hold
it at all (when it cannot, nothing can save it and the ordinary drop stands —
a trimmed prompt beats a 500 that mutes her for the tick), the cap is floored at
what the evidence costs so that refusal is satisfiable, and the receipt says
what the clip DID shed, in kind and amount (`shed_messages`, `shed_tokens`,
`shed_own_moves`, `shed_move_results`, `kept_recent_move_*`).

PART 2 — THE RATCHET (source_hygiene::derived_bounds)

Four defects of one shape in one night: the 768-token output floor that ended
turns inside the reasoning channel (#4194), the KV cache type defaulting to f16,
the flat 10 s page-wedge bound sized from the M5's 0.1 s (#4287), and this one.
Each a static number standing in for a measurement the substrate already takes.

The de-hardcode guard in `cognition::context_budget` could not catch this class:
it cannot see a PRODUCT (both halves of 30 × 500 were individually exempted, in
good faith), and its vocabulary stops at size while this class hides in time and
rate units. The new rule asks that a bound on a live path be derived or carry a
`derived-or-floor: <why>` justification, and ratchets at the current count (159)
the way `unwrap_justification` and `production_reachability` do.

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

* fix(cognition): her move is protected after a follow-up, and a unit too big to fit is a NAMED outcome — Astra's review of #4290

1. `recent_move_evidence` read only the TRAILING run, so the commonest shape in
   a room — a follow-up arriving after a completed action — returned
   `RecentMove::default()` and the act the follow-up was asking about was the
   first thing dropped. It now walks back past trailing ordinary turns to find
   her move, then back through its cluster, then one more for the opener; the
   protected span is the SUFFIX from that opener to the end, because you cannot
   drop from the middle of a conversation.

   The limits are now explicit in code AND on the receipt rather than implied:
   a chain longer than `CLUSTER_SCAN_MESSAGES` is protected only as a suffix
   (`RecentMove::truncated`, and no opener is added — the message before the cut
   is another link, not the real opener), and a move further back than the scan
   bound is NOT protected at all (`kept_recent_move_messages=0`). This is an
   assembler heuristic over roles and prose prefixes; it does not close
   recent-action loss. SOURCE-OWNED CAUSAL GROUPING is the real answer and is
   out of reach in this change — said plainly in the doc comment.

2. When the unit is larger than the whole conversation budget the drop used to
   silently revert to ordinary dropping — precisely the disease this PR exists
   to end. It is now a typed outcome, `EvidenceFit::{NoMove, Protected,
   CannotFit}`, and a `CannotFit` is named on its own receipt
   (`delib.fill.evidence_cannot_fit`: persona, evidence_messages,
   evidence_tokens, history_budget, truncated_chain) with what was lost. The
   enum is `pub(crate)` so a cannot-fit signal elsewhere composes with it rather
   than duplicating it.

Regression coverage for both cases Astra named — a new room turn after a
completed action, and a multi-tool chain longer than six — plus the two limits
and the three fit verdicts.

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

* test(cognition): reproduce context continuity failures in clip fitting

* fix(cognition): adopt Astra's continuity tests — an unfittable act REFUSES, and an oversized result condenses instead of muting

Her two regressions (cherry-picked at 5f7908c, unmodified) are the
specification:

1. `continuity_followup_keeps_completed_action_evidence` — already green at
   4ac8b0e; the follow-up fix landed there.
2. `continuity_insufficient_capacity_refuses_instead_of_dropping_evidence` —
   was RED. `fit_messages` now returns `PromptCapacityError` when her act and
   its result do not fit and every message in the unit would individually have
   fit. Required action/result continuity does not become optional when it
   exceeds capacity; the error carries the real requirement, which is what the
   untruncated demand receipt feeds to `serving_plan`, so a window too small for
   one act gets PROVISIONED instead of silently trimmed forever.

ONE DELIBERATE EXCEPTION, with measured evidence, flagged for Astra on the PR:
refusing when a SINGLE message of the unit is on its own larger than the whole
budget does not preserve it — it mutes the citizen. That refusal is an outage
this repo already paid for: an unbounded required result produced 836 refusals
and zero acts on 2026-09-10, and the answer was to cap the result at its share
of the window and demote the remainder to history — which is exactly the message
that lands back in this check (`working_memory.rs` "Full result of your most
recent action"). The existing `prompt_view` fixture carries a ~21.8k-token
demoted result and asserts `capacity_error.is_none()`; a blanket refusal
re-breaks it and re-creates the outage.

So `EvidenceFit` grew a fourth arm, `TooLargeToCarry`: loud on the same probe
with `verdict=too_large_to_carry` and `largest_message_tokens`, but it yields
rather than faulting, and the real fix for it is condensing
([[collapse-dont-clip-condense-the-past-never-erode-it]]). Her fixture is
unaffected — nothing in it is individually oversized, so it refuses as she
specified.

Also: my own parallel coverage of her two cases is deleted rather than kept
alongside; what remains (`the_recent_move_protection_states_its_own_limits`)
pins only the heuristic's edges — the truncated-suffix case, the
beyond-scan-bound case, and the condense case — none of which her tests cover.

Fixes the CI break at 4ac8b0e: a `prompt_view` fixture still referenced the
deleted `CONSERVATIVE_PREFILL_TOKENS_PER_S` (error[E0425]); it now sizes its
"genuinely oversized result" assertion against
`prefill_rate::UNMEASURED_FILL_FLOOR_TOKENS`. `BASELINE_UNDERIVED_BOUNDS` moved
into the test mod so the new guard costs the monotonic warning ratchet nothing.

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

* fix(hygiene): the new guard's own comment-length floor spends a de-hardcode exemption, and the bounds baseline is the MERGE count

Two ratchet failures at e256df2, both in the guards rather than the behaviour
(8,374 tests passed, Astra's two continuity regressions among them):

- `MIN_REASON_CHARS` tripped the existing de-hardcode guard on its `CHARS`
  suffix. It bounds the length of a COMMENT a human types, not a window — the
  same exemption its sibling in `unwrap_justification` already spends.
- `BASELINE_UNDERIVED_BOUNDS` was measured on the branch (159); CI scans the
  MERGE with canary, where the count is 160. The ratchet's slack is shared
  across branches in flight — the unwrap ratchet documents the same property.

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 Oct 6, 2026
…; her measured need is an expectation, never the ceiling (#4815)

The 5090, 2026-10-06 (BigMama): Kimi's push + PR-comment tool call was cut
mid-output ('tools/<cut at the output limit> ✗') and the whole turn was
lost. Her last four delib.turn.output_allowance receipts: allowance
10,177 / 10,177 / 10,410 / 12,333 = the need term, against a reserve of
12,464 / 15,436 / 13,506 / 25,024. The need is a p90 × 5/4: by
construction about one turn in ten runs past it, and a cut tool call
commits nothing.

max_tokens does not make a turn shorter, it only decides whether a long one
lands. So the allowance is the bound: the reserve the prompt left, and for
an act the runaway cap (12,288). The time and need terms stay on the
receipt as what she is expected to use (need_clipped still says when her
need exceeds the room). A latency budget enforced by truncation buys no
latency; the cut turn re-runs from scratch.

Test: with a measured need and a rate, a pass gets the reserve and an act
gets min(reserve, cap); Kimi's numbers pinned (act 12,288, pass 25,024).
The earlier pins (unknown = the reserve, never #4194's floor, the reserve
and the act cap bind, a 0.0/NaN rate is no rate) all hold.


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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant