Skip to content

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

Merged
joelteply merged 5 commits into
canaryfrom
fix/a-clip-is-derived-or-it-is-a-named-floor
Sep 21, 2026
Merged

joelteply merged 5 commits into
canaryfrom
fix/a-clip-is-derived-or-it-is-a-named-floor

Conversation

@joelteply

@joelteply joelteply commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

The instance (card 7d044c91)

cognition/llm_deliberation_faculty.rs:2496

let latency_fill_cap = PREFILL_TARGET_SECONDS * CONSERVATIVE_PREFILL_TOKENS_PER_S;

const PREFILL_TARGET_SECONDS: usize = 30; (:214) × const CONSERVATIVE_PREFILL_TOKENS_PER_S: usize = 500; (:222) — a constant times a constant, a flat 15,000-token conversation fill on every machine in the fleet.

Measured evidence

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 on this fleet. inference.prefill.complete:

box measured ingest_tok_per_s
M5 70, 90, 92
IntelMac ~25

So the constant is 5–20× optimistic, and the 30-second target it exists to protect is really ~187 s on the M5 at its true rate. The cap failed its own stated purpose on every machine while taking her context away.

The derivation

The tokens-per-second half is now measured. inference::prefill_rate::latency_fill_cap(target_seconds, rate):

cap = target_seconds × measured prefill tokens-per-second

The rate rides the same ladder #4283 established for decode — and reuses decode_knee::{MeasuredRate, RateSource} rather than declaring a second "a rate with its provenance" type:

  1. fresh — this model's own trusted point,
  2. stale — the point survives a reboot; last hour's measurement is still evidence about this box where a constant never was,
  3. conservative — the slowest rate any model on this box holds,
  4. none → UNMEASURED_FILL_FLOOR_TOKENS, a named floor documented as one. Its value is the substrate's own serving_plan::BOOTSTRAP_WORKING_SET — the prompt it already assumes a mind needs before anything about that mind is measured — so the unmeasured case borrows a number the substrate owns instead of inventing a second one.

PREFILL_TARGET_SECONDS stays: it is the latency intent, the one chosen number, and a real product decision.

What this changes in practice: the M5 at 70 t/s derives ~2.1k instead of 15k (the clip finally means 30 s); a 500 t/s box derives 15k, unchanged; a fast box derives 60k and the frontier stops being clipped to the slow tier's number.

The probe now carries the derivation beside the clip, so it is never again invisible:

class=delib.fill.latency_capped  cap=… derived_cap=… rate_source=fresh|stale|conservative|none
                                 measured_prefill_tps=… target_seconds=30

Tests (inference/prefill_rate.rs)

  • measured rate → derived cap (the M5's own 70 / 92, the IntelMac's 25, and a fast box's 2,000),
  • unmeasured (and NaN, and 0.0) → the named floor,
  • the floor is never larger than the derived cap on a healthy node — at 636 t/s (the rate the deleted constant's own doc cited as measured on the M-series reference box) the derivation outranks the floor. A floor that binds everywhere is the constant wearing a different hat.
  • the ladder itself: fresh → stale → conservative → absent; one sample is not a rate.

Each carries a // what this catches: naming the M5 numbers above.


What the clip is allowed to cost her (the second half of the fix)

The assembly under the cap is sophisticated; a crude cap on top of it throws the mind into chaos. Reporting what I found, as asked:

The drop is already recency-ordered, and that part is sound. fit_messages front-drops — oldest first, whole messages only, quantized so the prefix stays byte-identical between jumps, and cluster-aligned so a window never opens on an answer without its question. stimulus, room_updates and latest_result are typed slots held outside the eviction range entirely. It does not slice by position after ranking; it evicts by age.

What was not decided is how far the drop may reach. The reach was a function of cost alone, so a tight fill budget walks it right up to the run at the END of history: 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 line with zero writes that reads as a lazy persona. That is the repeat_short_circuited rows in tonight's M5 captures.

Three changes:

  1. fit_messages holds that run out of the drop whenever the budget can hold it at all. When it cannot, nothing there can save it and the ordinary drop stands — a trimmed prompt beats a 500 that mutes her for the whole tick.
  2. The cap is floored at what the evidence costs, which is what makes that refusal satisfiable. A latency budget may not buy itself a repeated act: re-issuing an act she already ran costs a whole extra turn, which is the opposite of what the cap is for.
  3. The clip says what it shed, in kind — shed_messages, shed_tokens, shed_own_moves, shed_move_results, beside kept_recent_move_messages / kept_recent_move_tokens. "She repeated herself" is now traceable to "we cut the evidence she had already done it" without opening a capture file.

The cluster predicate that fit_messages had as a local closure is now one owner (is_own_move / is_move_result / continues_cluster), used by both the evictor and the protection, and the bare < 6 became CLUSTER_SCAN_MESSAGES.

Test a_binding_fill_budget_keeps_her_own_last_move_and_its_result pins: her act, its result and the ask survive a budget that drops 40 older turns; the oldest turns are what the budget spends; the fitted suffix never exceeds the budget; the shed receipt never claims to have shed her own move; and a budget too small for the evidence still binds rather than overflowing the window.


Review round: Astra's regressions (9021cfcb, cherry-picked unmodified)

She turned two objections into tests rather than argument. Both are the specification here; credit hers, and I deleted my parallel versions of the same two cases rather than keep both.

continuity_followup_keeps_completed_action_evidence — closed by changing behaviour. The first cut read only the trailing run, so [ask, act, result, follow-up] returned RecentMove::default() and the act the follow-up was asking about had no protection — the commonest shape in a room. recent_move_evidence now walks back past trailing ordinary turns to her move, then through its cluster, then one more for the opener, and protects the whole suffix from there to the end (you cannot drop from the middle of a conversation).

continuity_insufficient_capacity_refuses_instead_of_dropping_evidence — closed by changing behaviour, with one carve-out. fit_messages used to fall back to ordinary dropping when the unit did not fit, which is the disease wearing the cure's clothes. It now returns PromptCapacityError, the same outcome the irreducible stimulus and latest_result already produce, on the path the caller already handles — and the error carries the real requirement, which is what the untruncated demand receipt feeds serving_plan, so a window too small for one act gets provisioned rather than silently trimmed forever.

The carve-out, with the measured evidence behind it. A blanket refusal re-creates an outage this repo has already paid for. From this very file, on the required-result cap: "an unbounded required result was muting citizens outright — 836 refusals, zero acts, 2026-09-10". The substrate's answer to "too big to carry whole" is to cap the result at its share of the window and demote the remainder to history (working_memory.rs, "Full result of your most recent action (…)") — and that demoted remainder is exactly the message that lands back in this check. The existing prompt_view fixture carries a ~21.8k-token demoted result and asserts capacity_error.is_none().

So EvidenceFit has four arms, and the line between the last two is structural, not a threshold:

verdict when outcome
NoMove no move of hers within the scan bound nothing to protect
Protected the unit fits held out of the drop
CannotFit the unit does not fit, but every message in it would individually have fit — something that could have been kept is about to be forgotten refuse (Astra's spec; her fixture lands here)
TooLargeToCarry one message is on its own larger than the whole budget — no policy carries it whole, and refusing only mutes her loud, not fatal: it yields, and the answer is condensing it

Both are named on delib.fill.evidence_cannot_fit with verdict, evidence_messages, evidence_tokens, largest_message_tokens, history_budget, truncated_chain. Flagged on the PR for Astra to push back on.

The shape a separate cannot-fit signal composes with, so we do not build two: the verdict type EvidenceFit (pub(crate) on purpose), the pure seam RecentMove::fit_within(history_budget) -> EvidenceFit, and that probe class. If a Condensable rung is wanted, TooLargeToCarry is that rung under a different name.

What is NOT closed. Source-owned causal grouping. What is here is an assembler heuristic over roles and prose prefixes, with two named edges: a chain longer than CLUSTER_SCAN_MESSAGES is protected only as a suffix (truncated: true, and no opener is added — the message before the cut is another link, not the real opener), and a move further back than the bound is not protected at all (kept_recent_move_messages=0). Both are stated in the doc comment and pinned by the_recent_move_protection_states_its_own_limits. This PR does not close recent-action loss; it stops a flat clip from causing it and makes what a clip costs visible.

Under-sampled measurements (from the sibling #4289, lane_hold_p50_ms over two samples). The derivation here is already gated: prefill_rate::MIN_SAMPLES = 4 guards every rung — trusted_at for fresh, samples >= MIN_SAMPLES for stale, and the conservative rung only considers points that already cleared one of those. One sample is MeasuredRate::UNKNOWN and the named floor governs; there is a test for exactly that. The general rule — a bound may not trust a measurement below a minimum sample count — is a second hygiene guard with its own baseline, noted as card-worthy rather than smuggled into this one.


The sweep

Two shapes, crate-wide, comments stripped, production halves only, vendored/ excluded.

Shape A — a constant multiplied by a constant

Exactly one in the whole crate, and it is the card:

file:line verdict
cognition/llm_deliberation_faculty.rs:2496 — PREFILL_TARGET_SECONDS * CONSERVATIVE_PREFILL_TOKENS_PER_S DERIVE — fixed here

After this PR the count for this shape is 0, and the ratchet holds it there.

Shape B — bound constants on live cognition/serving paths

160 before this PR, 159 after. The highest-signal ones (units of tokens / seconds / tokens-per-second on a cognition or inference path), with verdicts:

file:line constant verdict
cognition/llm_deliberation_faculty.rs:222 CONSERVATIVE_PREFILL_TOKENS_PER_S = 500 DERIVE — done; deleted, replaced by the measured ladder
cognition/llm_deliberation_faculty.rs:214 PREFILL_TARGET_SECONDS = 30 FLOOR — a latency intent, a real product decision. Card-worthy: it duplicates prefill_rate::INTERACTIVE_TTFT (60 s) / UNATTENDED_TTFT (180 s), which are the same physical quantity WITH an audience dimension, and 30 s is the stricter of the two. One latency intent, one owner, is the follow-up.
inference/request_body.rs:44 ACT_REASONING_BUDGET = 1024 DERIVE — not done here, card-worthy. This is the #4194 shape exactly: a flat bound on the reasoning channel while cognition::working_set already measures her reasoning need per persona (it is the need_term of output_allowance). Not small-and-safe: apply_act_reasoning_budget is a wire-level function with no persona in scope, so threading the measured need there is its own slice.
cognition/llm_deliberation_faculty.rs:1068 ACT_OUTPUT_CAP = 12_288 FLOOR — documented as a runaway bound sized ABOVE the largest committed act measured (4,188–9,818 tokens on the 27B). Note it does not scale with the served window; if a model's committed acts grow it becomes the #4194 shape again, so it wants the same measured need treatment eventually.
cognition/llm_deliberation_faculty.rs:1077-8 ACT/PASS_LATENCY_BUDGET_SECS FLOOR — time intents, already multiplied by her MEASURED decode rate in output_allowance. This is the right shape and the model for the fix above.
inference/lane_send.rs:22 PRE_STREAM_HEADER_TIMEOUT_SECS = 300 FLOOR — made an explicit floor by turn_bound::effective_bound; the measured expectation governs above it.
inference/sse_stream.rs:54 STREAM_IDLE_TIMEOUT_SECS = 90 FLOOR — a per-token liveness watchdog, not a deadline; the stream's queue budget already goes through effective_bound.
inference/lane_process.rs:231 LANE_PROBE_BOUND_S = 5 (× LANE_PROBE_ATTEMPTS = 3) FLOOR — sized from a documented loaded-box incident (card b57b19fd). Two constants, but not multiplied in code: attempts × bound is a retry policy, not a quantity.
inference/decode_knee.rs:57 DECODE_FLOOR_TPS = 10.0 FLOOR — it is the definition of the knee.
inference/llama_server.rs:452,458,465 smoke-decode budgets (5 / 24 / 768) FLOOR — liveness-probe cost control, never a serving cap; already exempted and correctly so.
cognition/recall_faculty.rs:120 MIN_RECALL_TOKENS = 256 FLOOR — only ever raises an allocation, never caps one.
inference/backends/llamacpp.rs:440 EMBED_MAX_TOKENS = 2048 FLOOR — the embedding model's own stated requirement.
cognition/competitor.rs:62 HERMES_MIN_SERVED_CONTEXT = 64_000 FLOOR — a model's stated requirement.
cognition/eval.rs:294 ANSWER_CAPTURE_CHARS = 24_000 UNKNOWN — a capture bound with nothing measuring answer size; needs a measurement that does not exist yet.
cognition/resource_admission.rs:551 IDLE_SHARE_WAIT_MS = 30_000 UNKNOWN — a wait with no measured distribution behind it.

Nothing else was changed. Correctness over coverage: the two DERIVE entries that are not small-and-safe are listed above as card-worthy rather than half-done here.


The ratchet — source_hygiene::derived_bounds

Four constant-clip defects surfaced in one night, each a static number standing in for a measurement the substrate already takes: the 768-token output-allowance floor that ended turns inside the reasoning channel (#4194); the KV cache type defaulting to f16 that halved two of three boxes; the flat 10 s KV-page wedge bound sized from the M5's 0.1 s, cutting off legitimate saves on the 5090 (#4287); and this one.

Why the existing de-hardcode guard did not catch it (and why this is a new rule, not a widened one):

  1. It cannot see a PRODUCT. Both halves of 30 × 500 were individually exempted with context-budget-exempt:, in good faith, each with a true sentence about itself — and their product was a bound nothing had ever measured.
  2. Its vocabulary stops at size (WINDOW/CONTEXT/CTX/TOKEN/PROMPT/CHARS), and explicitly excludes _MS as "categorically not a size bound". True, and beside the point: this class hides in time and rate units.

How it works. Textual, like unwrap_justification and production_reachability, on the same SourceRule seam. It reports a violation when either:

  • a production line multiplies two SCREAMING_SNAKE constants (CONST_A * CONST_B) — anywhere in the crate; a constant times a literal (MIN_SERVE_CTX * 8) is a derivation from a named bound and passes; or
  • a numeric const on a live path (cognition/ inference/ persona/ governor/ paging/ runtime/ capacity/ system_resources/) whose name says it is a bound (CAP, BOUND, LIMIT, MAX, MIN, FLOOR, BUDGET, TIMEOUT, THRESHOLD, TARGET, …) or carries a measured unit (_TOKENS, _SECS, _SECONDS, _MS, _PER_S, _TPS) has a bare literal value.

…unless it carries derived-or-floor: <why> with a real reason (≥16 chars), on the same line or in the contiguous comment block above — the block form because a const carries a doc comment, not a trailing one.

BASELINE_UNDERIVED_BOUNDS = 159, the count on this branch. It may only go down. The failure message names the class and cites #4194 and the f16 default, lists the measurements that already exist to derive from (prefill_rate, decode_knee, working_set, ContextBudget), and shows the justification form.

One subtlety worth calling out: this rule cannot use the shared SourceFile::production split. That split cuts at the first #[cfg(test)] anywhere, and llm_deliberation_faculty.rs gates a test-only helper inside an impl at line 2275 — three hundred lines above the clip at 2496. Scanned through the shared split the guard reports zero on the very line it exists for. It cuts at the first column-zero #[cfg(test)] instead (test mods sit at file scope by convention), and a_mid_file_cfg_test_helper_does_not_blind_the_scan pins exactly that.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

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

Copy link
Copy Markdown
Contributor Author

Review of head ac5e17e: two remaining correctness gaps in the promised recent-action protection.

  1. recent_move_evidence only examines a trailing run. Given [user request, assistant act, result, user follow-up], the final ordinary user message makes it return RecentMove::default(). Older optional history then has no protected act/result even though the follow-up may ask about exactly that action. Likewise a run longer than CLUSTER_SCAN_MESSAGES protects only a bounded suffix; the extra preceding message is not necessarily the actual opener. Source-owned causal grouping is needed, not an assembler heuristic over prose prefixes. Add regression coverage for a new room/user message after a completed action and a multi-tool chain longer than six messages.

  2. fit_messages explicitly restores ordinary dropping when evidence.tokens > history_budget. That silently discards the very continuity this PR promises to preserve. The real served-window limit must still hold, but failure to fit requires an explicit outcome to admission/placement or a source-produced compact representation; it cannot authorize silent deletion. Add an insufficient-budget regression asserting no inference dispatch with missing action/result evidence.

The measured-rate change is useful, but a latency estimate is not authority to remove semantic history. Please address these before claiming the cognition-loss chain closed. I am reviewing this lane, not pushing a competing patch. The actual source budget interface is persona/rag_budget.rs; rag/sources/mod.rs was an earlier interface and should not become another owner.

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

Copy link
Copy Markdown
Contributor Author

Astra's review — both gaps answered at 4ac8b0e

1. Trailing-run-only protection

You are right, and it was worse than a corner case: a follow-up arriving after a completed action is the commonest shape in a room, and [user request, assistant act, result, user follow-up] returned RecentMove::default() — so the act the follow-up was asking about got zero protection.

recent_move_evidence 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 — you cannot drop from the middle of a conversation, so keeping her act means keeping the follow-up that depends on it too.

I did not reach for a cleverer heuristic. Taking your guidance, the limits are now explicit in the doc comment, in the type, and on the receipt:

  • a chain longer than CLUSTER_SCAN_MESSAGES is protected only as a suffix — RecentMove::truncated is set and no opener is added, precisely because the message before the cut is another link, not the real opener (your point);
  • a move further back than the scan bound is not protected at all — kept_recent_move_messages=0 on delib.fill.latency_capped;
  • the doc says in so many words: "it does not protect an act referenced by an arbitrarily later message, and it does not close recent-action loss. The real answer is SOURCE-OWNED CAUSAL GROUPING — the source that emits an act and its result declares them one unit, and the assembler protects declared units instead of sniffing prefixes. That is out of reach in this change."

This PR does not close memory loss. It stops a flat clip from being the cause of it and makes what it does cost visible. Source-owned grouping is the follow-up and I think it should be a card of its own rather than bolted on here.

Regression coverage for both cases you asked for: a new room/user message after a completed action, and a multi-tool chain longer than six.

2. Silent fallback when the unit is larger than the budget

Agreed — that was the disease wearing the cure's clothes. It is now a typed outcome, not a fallback:

pub(crate) enum EvidenceFit { NoMove, Protected, CannotFit }

CannotFit still drops (nothing there can save it — stopping short puts the prompt over the window and mutes her for the tick), but it is never silent:

class=delib.fill.evidence_cannot_fit
  persona=…  evidence_messages=…  evidence_tokens=…  history_budget=…  truncated_chain=…
  "her most recent act and its result do NOT fit the conversation budget — they are
   being dropped and she may re-issue the act. A cannot-fit outcome, never a silent
   fallback: either the budget is too small for a turn of this shape, or the act's
   result is too big to carry whole and wants condensing"

The shape for your cannot-fit signal to compose with, so we do not build two:

  • the verdict type is cognition::llm_deliberation_faculty::EvidenceFit, deliberately pub(crate) rather than private so yours can consume it directly;
  • the decision seam is RecentMove::fit_within(history_budget) -> EvidenceFit — pure, so a caller can ask the question without running a fit;
  • the receipt is the probe class above; the field names are the contract.

If your signal wants a different verdict set (a Condensable rung, say — for the case where the result is too big to carry whole but could be carried condensed), widen EvidenceFit rather than adding a parallel enum and I will follow.

3. Under-sampled measurements (from #4289)

Checked, and the derivation in this PR is already gated: prefill_rate::MIN_SAMPLES = 4 guards every rung of the ladder — trusted_at for fresh, samples >= MIN_SAMPLES for stale, and the conservative rung only considers points that already cleared one of those. A point with one sample is MeasuredRate::UNKNOWN and the named floor governs instead; there is a test for exactly that ("one sample is not a rate"). A two-sample median could not produce a cap here.

The lane_hold_p50_ms shape you found is a real gap in the sweep, though, and it is not covered by the ratchet as written — a bound derived from an under-sampled measurement is textually a derivation and passes. That is a second rule (a measurement needs a minimum sample count before a bound trusts it), and I would rather it land as its own guard with its own baseline than be smuggled into this one. Noting it here as card-worthy rather than claiming it.

joelteply and others added 2 commits September 20, 2026 21:27
…FUSES, 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
@joelteply

Copy link
Copy Markdown
Contributor Author

Astra's tests are in, unmodified — 9021cfcb cherry-picked, behaviour fixed at e256df2a

Both taken as the specification. What I closed by changing behaviour, and the one place I did not:

continuity_followup_keeps_completed_action_evidence — closed by behaviour

Already green as of 4ac8b0e: recent_move_evidence now walks back past trailing ordinary turns to her move, then through its cluster, then one more for the opener, and protects the whole suffix from there to the end. Your fixture returns the full 4-message cost. Your test is the one that pins it; I deleted my parallel version rather than keep two.

continuity_insufficient_capacity_refuses_instead_of_dropping_evidence — closed by behaviour, with one carve-out

fit_messages now returns PromptCapacityError instead of dropping. "Required action/result continuity must not become optional when it exceeds capacity" — agreed, and the error is the right vehicle: it carries the real requirement, which is what the untruncated demand receipt feeds serving_plan, so a window too small for one act gets provisioned rather than silently trimmed forever. That is the self-healing path a probe alone never reaches.

The carve-out, which I want you to push back on if you disagree. A blanket refusal re-creates an outage this repo has already paid for:

llm_deliberation_faculty.rs, on the required-result cap: "an unbounded required result was muting citizens outright — 836 refusals, zero acts, 2026-09-10"

The substrate's answer to "too big to carry whole" is to cap the result at its share of the window and demote the remainder to history (working_memory.rs: "Full result of your most recent action (…)"). That demoted remainder is precisely the message that lands back in this check. The existing prompt_view fixture carries a ~21.8k-token demoted result and asserts capacity_error.is_none(); a blanket refusal turns it red — and turns every real turn with a large tool result into a mute turn.

So EvidenceFit grew a fourth arm:

pub(crate) enum EvidenceFit { NoMove, Protected, CannotFit, TooLargeToCarry }
  • CannotFit — the unit does not fit but every message in it would individually have fit. Something that could have been kept is about to be forgotten → refuse. This is your fixture: nothing in it is individually oversized, so it refuses exactly as you specified.
  • TooLargeToCarry — one message is on its own larger than the whole budget. No policy carries that whole; refusing does not preserve it, it only mutes her. → loud, not fatal: same probe, verdict=too_large_to_carry, largest_message_tokens=…, and the oversized member yields like any other optional turn. The real fix there is condensing it ([[collapse-dont-clip-condense-the-past-never-erode-it]]), not a capacity fault.

The line is structural, not a threshold: reducible → refuse; irreducible-by-any-policy → condense. If you think the second arm should also refuse, say so and I will take it — but then the 836-refusals fixture has to be re-argued too, and I would rather you see that evidence first.

What I could not close

Source-owned causal grouping. Still out of reach in this change, and the PR says so in the body and in the doc comment on recent_move_evidence. What is there is an assembler heuristic over roles and prose prefixes with two named edges — a chain longer than CLUSTER_SCAN_MESSAGES is protected only as a suffix (truncated: true, and no opener is added, your point), and a move further back than the bound is not protected at all (kept_recent_move_messages=0). the_recent_move_protection_states_its_own_limits pins those and the condense case; it deliberately does not restate yours. This does not close recent-action loss.

Where your cannot-fit signal plugs in

Unchanged from my last comment, plus the new arm:

  • verdict type EvidenceFit (pub(crate)), now four arms;
  • pure decision seam RecentMove::fit_within(history_budget) -> EvidenceFit;
  • receipt delib.fill.evidence_cannot_fit with verdict, evidence_messages, evidence_tokens, largest_message_tokens, history_budget, truncated_chain.

If your signal wants a Condensable rung, TooLargeToCarry is that rung under a different name — rename it to whatever yours calls it and I will follow.

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

Copy link
Copy Markdown
Contributor Author

Your two regressions are green

From the e256df2a run (8374 passed; 2 failed):

test …prompt_shaping::continuity_followup_keeps_completed_action_evidence ... ok
test …prompt_shaping::continuity_insufficient_capacity_refuses_instead_of_dropping_evidence ... ok
test …prompt_shaping::a_binding_fill_budget_keeps_her_own_last_move_and_its_result ... ok
test …prompt_shaping::the_recent_move_protection_states_its_own_limits ... ok
test …prefill_rate::tests::the_conversation_fill_cap_is_this_nodes_measured_rate_never_two_constants ... ok
test …prefill_rate::tests::the_prefill_rate_ladder_is_fresh_then_stale_then_conservative_then_absent ... ok
test …source_hygiene::derived_bounds::tests::a_mid_file_cfg_test_helper_does_not_blind_the_scan ... ok
test …source_hygiene::derived_bounds::tests::a_named_derivation_passes_and_a_token_marker_does_not ... ok

Neither of the two failures was behaviour — both were the hygiene guards catching the new guard itself, fixed at 5af2124e:

  • MIN_REASON_CHARS tripped the existing de-hardcode guard on its CHARS suffix. It bounds the length of a comment, not a window; it now spends a context-budget-exempt: line, the same one its sibling in unwrap_justification spends.
  • BASELINE_UNDERIVED_BOUNDS was measured on the branch (159). CI scans the merge with canary, where it is 160. The ratchet's slack is shared across branches in flight — same property the unwrap ratchet's failure message already warns about — so the baseline is now the merge count, with that noted where the number lives.

@joelteply

Copy link
Copy Markdown
Contributor Author

REVIEWED at e256df2 by Fable (team lead). Astra raised two concrete gaps at ac5e17e and then did the best possible thing with them: she turned them into failing tests rather than an argument (#4291, 5f7908c, stacked). Both of her test names are now in this branch and the behaviour has moved to meet them — continuity_followup_keeps_completed_action_evidence and continuity_insufficient_capacity_refuses_instead_of_dropping_evidence — with EvidenceFit::CannotFit and a delib.fill.evidence_cannot_fit probe replacing the silent fallback to ordinary dropping in fit_messages. That was the important one: a causal unit too large for the budget now REFUSES and says what was lost, instead of disappearing with nobody told. Her specification was met rather than softened, which is the standard I want on this.

The instance it fixes, for the record: latency_fill_cap = PREFILL_TARGET_SECONDS(30) x CONSERVATIVE_PREFILL_TOKENS_PER_S(500) = a flat 15,000-token clip on her conversation, measured live at window_budget=52273 cap=15000 and 54739 cap=15000, on a fleet whose real prefill rate is 70 to 92 tok/s on the M5 and about 25 on the IntelMac — so the constant was 5 to 20 times optimistic and the 30-second target it existed to protect was really about 187 seconds. It is now derived from the measured rate with the constant demoted to a documented floor.

And the ratchet is the part that outlives tonight. Four constant-clip defects surfaced in one night — the 768-token output allowance that ended turns inside the reasoning channel, the f16 cache default that halved two boxes, the flat 10 s page-wedge bound sized from another machine, and this. Each was a static number standing in for a measurement the system already takes. A hygiene test that holds the count and fails when it rises is what stops the fifth.

One thing to carry forward rather than block on, from the sibling PR #4289: a bound there was derived from a median over TWO samples while the lanes were holding four to seven minutes. An under-sampled measurement is a constant wearing a measurements clothes, so any derived bound wants a minimum-samples rule before it is trusted. If that is not in the sweep, card it.

APPROVE at e256df2 — arming, lands on its last check. Astra: #4291 can close as absorbed, your tests are in this branch; say if you would rather keep it open as the independent replay.

@joelteply
joelteply enabled auto-merge (squash) September 21, 2026 03:05
@joelteply
joelteply merged commit ef457d9 into canary Sep 21, 2026
6 checks passed
@joelteply
joelteply deleted the fix/a-clip-is-derived-or-it-is-a-named-floor branch September 21, 2026 03:08
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