Repository navigation
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
Conversation
…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
|
Review of head ac5e17e: two remaining correctness gaps in the promised recent-action protection.
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
Astra's review — both gaps answered at
|
…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
Astra's tests are in, unmodified —
|
…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
Your two regressions are greenFrom the Neither of the two failures was behaviour — both were the hygiene guards catching the new guard itself, fixed at
|
|
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 — The instance it fixes, for the record: 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. |
The instance (card 7d044c91)
cognition/llm_deliberation_faculty.rs:2496const 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:
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:ingest_tok_per_sSo 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):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:UNMEASURED_FILL_FLOOR_TOKENS, a named floor documented as one. Its value is the substrate's ownserving_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_SECONDSstays: 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:
Tests (
inference/prefill_rate.rs)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_messagesfront-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_updatesandlatest_resultare 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"), thenpersona.act.no_deliverable_yet, then an hour line with zero writes that reads as a lazy persona. That is therepeat_short_circuitedrows in tonight's M5 captures.Three changes:
fit_messagesholds 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.shed_messages,shed_tokens,shed_own_moves,shed_move_results, besidekept_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_messageshad 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< 6becameCLUSTER_SCAN_MESSAGES.Test
a_binding_fill_budget_keeps_her_own_last_move_and_its_resultpins: 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]returnedRecentMove::default()and the act the follow-up was asking about had no protection — the commonest shape in a room.recent_move_evidencenow 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_messagesused to fall back to ordinary dropping when the unit did not fit, which is the disease wearing the cure's clothes. It now returnsPromptCapacityError, the same outcome the irreducible stimulus andlatest_resultalready produce, on the path the caller already handles — and the error carries the real requirement, which is what the untruncated demand receipt feedsserving_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 existingprompt_viewfixture carries a ~21.8k-token demoted result and assertscapacity_error.is_none().So
EvidenceFithas four arms, and the line between the last two is structural, not a threshold:NoMoveProtectedCannotFitTooLargeToCarryBoth are named on
delib.fill.evidence_cannot_fitwithverdict,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 seamRecentMove::fit_within(history_budget) -> EvidenceFit, and that probe class. If aCondensablerung is wanted,TooLargeToCarryis 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_MESSAGESis 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 bythe_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_msover two samples). The derivation here is already gated:prefill_rate::MIN_SAMPLES = 4guards every rung —trusted_atfor fresh,samples >= MIN_SAMPLESfor stale, and the conservative rung only considers points that already cleared one of those. One sample isMeasuredRate::UNKNOWNand 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:
cognition/llm_deliberation_faculty.rs:2496—PREFILL_TARGET_SECONDS * CONSERVATIVE_PREFILL_TOKENS_PER_SAfter 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:
cognition/llm_deliberation_faculty.rs:222CONSERVATIVE_PREFILL_TOKENS_PER_S = 500cognition/llm_deliberation_faculty.rs:214PREFILL_TARGET_SECONDS = 30prefill_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:44ACT_REASONING_BUDGET = 1024cognition::working_setalready measures herreasoningneed per persona (it is theneed_termofoutput_allowance). Not small-and-safe:apply_act_reasoning_budgetis a wire-level function with no persona in scope, so threading the measured need there is its own slice.cognition/llm_deliberation_faculty.rs:1068ACT_OUTPUT_CAP = 12_288needtreatment eventually.cognition/llm_deliberation_faculty.rs:1077-8ACT/PASS_LATENCY_BUDGET_SECSoutput_allowance. This is the right shape and the model for the fix above.inference/lane_send.rs:22PRE_STREAM_HEADER_TIMEOUT_SECS = 300turn_bound::effective_bound; the measured expectation governs above it.inference/sse_stream.rs:54STREAM_IDLE_TIMEOUT_SECS = 90effective_bound.inference/lane_process.rs:231LANE_PROBE_BOUND_S = 5(×LANE_PROBE_ATTEMPTS = 3)inference/decode_knee.rs:57DECODE_FLOOR_TPS = 10.0inference/llama_server.rs:452,458,465cognition/recall_faculty.rs:120MIN_RECALL_TOKENS = 256inference/backends/llamacpp.rs:440EMBED_MAX_TOKENS = 2048cognition/competitor.rs:62HERMES_MIN_SERVED_CONTEXT = 64_000cognition/eval.rs:294ANSWER_CAPTURE_CHARS = 24_000cognition/resource_admission.rs:551IDLE_SHARE_WAIT_MS = 30_000Nothing 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_boundsFour 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):
30 × 500were individually exempted withcontext-budget-exempt:, in good faith, each with a true sentence about itself — and their product was a bound nothing had ever measured.WINDOW/CONTEXT/CTX/TOKEN/PROMPT/CHARS), and explicitly excludes_MSas "categorically not a size bound". True, and beside the point: this class hides in time and rate units.How it works. Textual, like
unwrap_justificationandproduction_reachability, on the sameSourceRuleseam. It reports a violation when either: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; orconston 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 aconstcarries 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::productionsplit. That split cuts at the first#[cfg(test)]anywhere, andllm_deliberation_faculty.rsgates a test-only helper inside animplat 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), anda_mid_file_cfg_test_helper_does_not_blind_the_scanpins exactly that.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo