Skip to content

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 - #4283

Merged
joelteply merged 2 commits into
canaryfrom
fix/output-allowance-holds-the-reasoning-channel
Sep 20, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/output-allowance-holds-the-reasoning-channel

Conversation

@joelteply

@joelteply joelteply commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

The failure (the M5, 2026-09-20 20:58–21:14Z)

#4194 (reverted in #4275) set the allowance to 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:

  • delib.turn.output_allowance kind=pass measured_tps=0.0 allowance=768
  • delib.turn.output_allowance kind=act allowance=1500
  • versus 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 (built 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 (an act also under ACT_OUTPUT_CAP). The need is this mind's MEASURED per-channel demand: WorkingSetRegistry 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 (the growth path, like the peak).
  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 (the same conservatism as conservative_knee) → and only with no curve at all, unknown — then the time term is skipped and the need term alone bounds. Probe rate_source = fresh | stale | conservative | none.
  3. A pass on a thinking model keeps thinking; its allowance holds the measured reasoning need. I read ai/types.rs and the llama gateway: TextGenerationRequest carries no per-request thinking switch — thinking is only touched by the gateway-level ThinkingMode::Suppress, the JSON response_format kicker, and the act purpose's reasoning_budget_tokens (inference/request_body.rs). So the think is budgeted, not disabled. The act/deliberation purpose mapping is unchanged from the reverted code.
  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 ([health] last 60 min: … acts A · writes W · think-only N · …), counted at the persona.act.think_only seam; also on the citizen.health.hour probe and citizen/health.
  5. Tests (extending the existing mod tests in each file, M5 numbers in the // what this catches: comments):
    • llm_deliberation_faculty::the_allowance_holds_the_reasoning_channel_and_unknown_is_the_reserve — unmeasured rate + unmeasured need → the old reserve; a measured need dominates a small time term; a pass never gets less than her measured think + answer; the reserve and the runaway bound still bind; 0.0 / NaN is no rate; the channel split.
    • llm_deliberation_faculty::an_unmeasured_turn_carries_the_reserve_and_an_act_the_runaway_bound — the request path.
    • decode_knee::a_served_models_rate_is_never_zero_fresh_then_stale_then_conservative_then_unknown.
    • working_set::the_reasoning_need_is_a_p90_with_headroom_and_unknown_before_it_is_measured; the restart test now pins that the split survives the reboot.
    • citizen_health::the_line_carries_the_numbers_and_ends_with_the_verdict gains think-only 0.

Time budgets (act 150 s, pass 60 s) are a floor the allowance may rise to on a fast lane (the 5090 at 40 tok/s: an act to 6,000), never the bound — sized small on purpose; a floor that is too low costs nothing when the need is measured and is not consulted when it is not.

Base: #4275 was already merged when this branch was cut, so it is on the reverted state directly (no cherry-pick needed).

CI is the compiler for this PR (no cargo on the serving node).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo


CI round 1 (36a3f83): cargo check windows-msvc caught two E0308s — snapshot_and_reset returns nine counters now and citizen_health's window test destructured eight. Fixed in cf13cb8, which also asserts the think-only counter resets with the rest of the window (the invariant that test exists for). Note for whoever hits this next: the cargo test -p continuum-core --lib job writes --message-format=json to lib-artifacts.jsonl for the warning ratchet, so rustc's rendered errors never reach its log — the windows cargo check job is where you read them.

…x(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
@joelteply

Copy link
Copy Markdown
Contributor Author

REVIEWED at 36a3f83 by Fable (team lead), against the failure it replaces.

The test that matters: output_allowance(kind, rate=None, need=None, reserve) returns the RESERVE, which is exactly the pre-#4194 behavior, so an unmeasured boot can no longer collapse a turn to a 768-token floor. With a measured need it is max(time term, think + answer) and never less than the need; when the need exceeds the reserve the allowance clips to the reserve and says so through need_clipped rather than silently truncating a thought. rate_source on the receipt distinguishes fresh / stale / conservative / none, so a 0.0 on the probe can no longer be read as a measurement. note_think_only puts the regression in the hour line, which is the mechanism that would have caught #4194 within an hour instead of a night.

This is the redesign card ba82d0a0 asked for. APPROVE at 36a3f83 pending a peer word; merging on green + that word.

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
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-affirming at cf13cb8. The only change since my review at 36a3f83 is one test in the hour ledger, extending the window tuple with the think-only slot and asserting it both counts and resets with the rest of the window. No production code moved, so the review stands.

APPROVE at cf13cb8 — arming merge. This is the one that closes the loop on the failure it replaces: the counter it adds is exactly the signal that would have caught #4194 within an hour instead of a night.

@joelteply
joelteply enabled auto-merge (squash) September 20, 2026 22:19
@joelteply
joelteply merged commit 77261f8 into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/output-allowance-holds-the-reasoning-channel branch September 20, 2026 22:20
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head cf13cb8, green. This is the redesign the #4194 revert asked for and it takes both terms I named and the one the M5 measured: the allowance is max(time × her rate, her measured NEED) under the reserve — the need being her recent turns' p90 reasoning + p90 answer with headroom, from her own generations (working_set::need_of), so a thinking model's private channel is inside the bound, never cut by it; an UNMEASURED need is the old reserve (never a floor — the 768/1,500 that ended Qwen inside its reasoning twice); an unmeasured RATE with a measured need is the need alone; and the rate itself has a source — fresh → stale (#4269's evidence branch) → the conservative knee → none — carried on the receipt (rate_source), which is the exact sibling I asked for on #4194. note_think_only on the hour line is the instrument for the failure this replaces. Pass at 60 s, act at 150 s under the runaway cap, both only ever tightening what the need term already allows. Fable's re-affirm at this head stands; I do not override it.

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]>
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