Repository navigation
A shed source's backlog waits for a start that funds it (Atlas: 270k chars appended, a turnover every other act) - #5815
Merged
Conversation
…ng whole on the next act (Atlas: 270k chars appended, a turnover every other act) The live M5 (build a947e4e, 08:46-09:46Z): when the one allocation could not grant Atlas's thoughts their floor, the start shed them (turn_over_view_with filtered them out), and the next act's advance offered every source again: 287 thoughts the epoch did not hold, not folded, not collapsed, so each arrived whole (thoughts:287/270351). Readmit reduces only an item larger than half the limit, so none of the ~940-char thoughts were. The view then outgrew its grant and turned over; the backlog read as one act's growth (appended_per_act=271019), so start_grants reserved nothing for the start after it. View::withhold records a shed source's items at the start that shed it: like a folded item they wait for a start that funds them, and a start that would show one above its pointer is a restore. Items the source produces after the start arrive as any new item does. A source merely absent from a start (an ended stream, a room she left) still returns whole: only an explicit shed withholds. Validator: view/tests/shed.rs fails before (284,410 chars appended vs 1,020) and passes after. On her real capture + spilled thought bodies (09:44:47Z shed start, start_chars 12,474 matching the live probe): the next act appended 266,857 chars before, 668 after; 95.0% of the next view is the previous one (4.5% before). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Nov 7, 2026
…board tests start and turn over at a cost Rebasing onto canary (7b7d277) brought tests written against the character-unit view API (#5815 shed, #5827 collapsed navigation). They now pass the cost the API requires and read Claim::full. The rebase's conflict in context_streams/tests.rs had dropped this branch's own updates to that file; they are re-applied, minus the tally test #5827 moved into blocks.rs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Nov 7, 2026
… as the final prompt prices it (#5819) * test: reproduce view start exceeding its token grant with uneven message sizes * The view starts by the caller's token oracle: a start keeps its grant as the final prompt prices it Codex's defect: View::start converted a source's TOKEN grant into characters at the source's AVERAGE tokens per character (start_grants: share * full_chars / requested_max), so a source of cheap long old turns and dear short new ones bought characters enough for new turns whose own cost overran the grant. continuum-context::cost::Cost<T> is the caller's price of a block (block, stored), with Chars for callers whose grants are characters and cost::whole as the one owner of an item's whole price (source::whole_chars deleted). View::start / turn_over / start_would_restore / readmit, view::claims, view::floor, the allotment (allot, fold_of) and depth::collapsible all price by it; Claim's sizes (floor, full, newest, logged), depth's Collapsible (whole, saves) and Growing (base, logged) are in the oracle's unit, and Growing::per_char is gone. Motion's order stays in characters. Cognition's oracle is ViewCost(calibration): each block at calibration.charge(message_cost), the function the final prompt is charged with (charged per block it errs high by under a token a block, never low). view_claims prices the plan's claims by the same oracle through view::claims (its own floor/whole pricing removed, view.rs no longer re-charges them); start_grants hands back token shares (the share itself, or the claim's full when granted all), takes one act's growth in tokens from fit_view's next_act_tokens, and reads Claim::newest directly; admit_view hands readmit its token budget. Removed char conversions: start_grants' grant mapping and its newest_of and wanted_tokens/ wanted_chars ratio; depth's per_char (claims[i].growing(share, requested_max / full_chars)); admit_view's budget * view.chars() / view_tokens limit; view_claims' raw-then-charge path; the fold decision in chars (fold_of now decides in the oracle the view allots by). Tests: Codex's regression (previous commit) passes on this base before and after: #5814 removed the per-message template tokens, so his short "ok" turns cost nothing here. a_view_start_keeps_its_token_grant_when_her_newest_turns_are_denser is the same defect on this base (CJK newest turns: a byte-counted estimate makes them three times as dense per char): red before (36 tokens in 3 messages against 32), green after. a_view_start_with_uniform_message_sizes_ keeps_what_it_kept: five newest turns before and after. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * The template's share is measured per kind from the engine and joins her allocation estimate #5814 removed PER_MESSAGE_TEMPLATE_TOKENS (no constant) but nothing measured in its place, so an "ok" turn cost 0 and a start priced by text alone kept twenty of them against a 32-token grant (Codex's 100 > 32). Engine (llama_server/template_overhead.rs): the serving lane's template is measured once per engine process and model, from the reconcile that already reads its build (observe_template beside observe_served_engine). Probe messages per kind (system, user, assistant, native tool result, native tool call with 0-3 parameters) are rendered in the middle of a conversation through /apply-template on the request wire (request_body::wire_messages) and counted by /tokenize (HTTP-thread calls, no slot, no decode); each records the tokens it added. MessageShape is the one owner of how a message is classified (kind, calls or results, parameters). TemplateMeasurement::Unmeasured is a type; the adapter seam reports it (AIProviderAdapter::template_overhead, OpenAI adapter for the serving lane, the placement switch forwards). Probe: serving.template_overhead. Cognition (prompt/template.rs): TemplateEstimate derives each kind's share against her own text estimate (message_cost) at its HIGHEST observation, a call's as the least-overcharging line over its parameters on or above every observation, so the estimate errs high on every observation and states its spread. PromptCalibration carries it (fit_within, from the adapter); estimate(message) = message_cost + its kind's share (unmeasured: text alone, density carries the template, probed on delib.prompt.density); estimated_prompt_tokens counts it, so density calibrates the rest. The view's oracle is renamed for what it is: AllocationEstimate (cognition) over continuum_context::cost::Estimate (the trait, was Cost). Its docs say it decides what to keep, errs high, claims no exact count or token prefix; dispatch still rests on the engine's exact quote. Measured on the M5 engine (Qwen3.6-35B-A3B-Q4_K_M, build b11017-444f386cf, 2026-11-07T11:38Z), tokens each probe added: plain turns 6/12/10/7/11 for every role, tool results 10/16/14/11/15, calls 17/31/43/57 (0/1/2/3 parameters). Beyond her text estimate: system/user/assistant highest 9, lowest 1 (spread 8); tool result 13, lowest 5 (spread 8); call line 17 + 8 per parameter (base lowest 14, spread 3). Tests: Codex's regression stays byte-identical but for the View::start cost argument, and stays green (its "ok" turns are priced by message_cost, which counts text). The template's red/green is a_view_start_keeps_its_token_grant_with_the_measured_template_overhead on his conversation: priced by text alone the start keeps 20 "ok" turns, 120 tokens as the recorded engine counts them (6 each) against 32; priced by the allocation estimate it keeps within every grant 32..512, and the recorded engine count is under the estimate. the_allocation_estimate_errs_high_on_the_recorded_engine: every probe is estimated at or above the engine's count, and a six-message multi-role conversation counted at 97 (92 without the 5-token generation suffix) is estimated at 118. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * One price for a message: the view's start, the final fit and a refusal's refit all estimate through PromptCalibration::estimate The view's start priced each block by her allocation estimate (text plus the measured template share) while the final fit and a refusal's refit priced text alone (LlmDeliberationFaculty:: messages_cost): two pricing paths for one fact. Now PromptCalibration::estimate / estimate_all is the one owner, and every prompt-assembly reader goes through it: - PromptMessages carries its pricing (set by its one builder from the faculty's binding, and by the act's view build to that act's calibration); required_parts, tokens, recent_move_evidence, fit_messages (each message and the quiet-tick minimum) and the newest result's levels price with it. - DeliberationPromptView carries the pricing its messages were estimated with; refit_rejected_prompt reprices and rebuilds with it. - The view build (view tokens, the quiet minimum, the tail budget, the sent sample, the assembled context's used tokens), fit_view (view and admitted tokens) and the budget ledger (estimate_system for the system message) price through it. Removed: LlmDeliberationFaculty::messages_cost (no production caller left; tests use PromptCalibration::default().estimate_all, numerically the same text-only estimate when unmeasured). message_cost stays as the text part estimate builds on, documented as never a price by itself. PromptCalibration derives Debug (the view snapshot carries it). Codex's regression changes one more call for the removal: messages_cost(&rendered) -> PromptCalibration::default().estimate_all(&rendered) (same number; his test stays green). Test: the_final_fit_and_a_view_start_price_a_multi_role_sequence_identically: a user turn, a native call, its result, an assistant turn and a CJK user turn, priced at the recorded engine's template: the view's start (AllocationEstimate per block) and the final fit (its receipt's history_tokens) give the same number, and a budget of that number keeps all of it. The engine's exact quote of the finalized body before generation stays the authority for dispatch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * Canary's new view callers price by the caller's oracle: the shed and board tests start and turn over at a cost Rebasing onto canary (7b7d277) brought tests written against the character-unit view API (#5815 shed, #5827 collapsed navigation). They now pass the cost the API requires and read Claim::full. The rebase's conflict in context_streams/tests.rs had dropped this branch's own updates to that file; they are re-applied, minus the tally test #5827 moved into blocks.rs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves the residents' pace directly: Atlas and Benchy re-prefilled their history on nearly every act (median act 193 s / 248 s). Advances path step 1 (Fast) and order-of-work line 2 (a mind's context as an epoch: reuse). Card eebaade4.
Cause (receipts)
Live M5, build a947e4e, Atlas (e5f4141d), 08:38-09:52Z,
~/.continuum/logs/continuum-core-server.log{,.1..6}:delib.view.turnoveragainst 27delib.view.advanceprobes in the window (the two extra advances are second passes within one act, 08:44:29 and 08:53:42).delib.view.sized shed_sources=1(08:53:42, 09:04:48, 09:18:47, 09:25:44, 09:44:47) is followed on her next act byby_source=...thoughts:278-287/263,032-270,351. Example: 09:44:47 turnoverstart_chars=12474,shed_sources=1, then 09:46:35 advanceappended_chars=271019 ... thoughts:287/270351, thenview_tokens=111165 granted=14353 appended_per_act=271019.turn_over_view_with(epoch.rs) dropped shed sources from the start, butadvance_viewpasses every source. The shed source's items were neither held, folded nor collapsed, soView::appendrendered eachLevel::Full.readmitreduces only an arrival over half the limit, and none of ~940-char thoughts were. Shedding a source that way guaranteed a turnover on the next act.appended_per_act.start_grantsthen sawper_act_tokens >= growableand started the growing sources at the whole growable room with no reserve, so the act after it overflowed on ~700 chars too.fixtures/prompt-captures/e5f4141d...pidx/.jsonl): consecutive prompts share 4-26% of their chars, diverging at message 5-12. Requests alternate between 25-29 messages (~13k chars, thoughts shed: c0a954c6, dbad67e4, 979fce22, c7d0ecbd) and ~310 (~30-35k chars, thoughts restarted as ~280 pointer lines: bc374743, abfa1adf, f6acd922, 41df8cfa).thoughtsandactionsfold or fit, so no source is shed act to act. In the earlier hours she showed the same failure at larger scale:shed_sources=5, thenactions:3308/69155518re-offered whole.Fix
View::withhold(shed)records a shed source's items at the start that shed it. Like a folded item, each waits for a start that funds its source and never arrives on its own mid-epoch. A start that would show one above its pointer counts as a restore, so it returns when a turnover is free. Items the source produces after the start arrive like any new item. A source merely absent from a start (an ended stream, a room she left) still returns whole: only an explicit shed withholds, and #5805'san_absent_sources_log_leaves_with_it_and_comes_back_wholeis unchanged.turn_over_view_withpartitions the sources instead of dropping the shed ones and callswithhold. The stale "a later act offers it again" docs are corrected, including a misplaced doc that describedturn_over_view_withfrom aboveview_would_restore.No constant, no unwrap, one owner (
View). Files after the change: view.rs 871, view/tests.rs 966, epoch.rs 815 lines. Composes with #5814: it changes neither the shed decision (ActPlan::shed_view_sources) nor the allocation, only what a shed means for the epoch's appends.Measured
Validator
core/continuum-context/src/view/tests/shed.rs, using Atlas's measured shape (287 thoughts at a mean 942 chars):assertion left == right failed: only the thought after the start arrives; left: 284410, right: 1020appended_per_actis one act's growth. A second test pins that a funded start restores the backlog (287 receipted asrestored_items).Replay on her real data: the 09:46:29Z capture c0a954c6 as the shed epoch's view, plus her 281 real thought bodies from
~/.continuum/tool-output/e5f4141d.../<outputId>.lognamed by capture bc374743, run through the realView(a throwaway example, not committed, since it holds persona data). The start rendersstart_chars=12474, matching the live probe exactly.appended_per_actBallpark from the live probes (inference, not a receipt): at 09:46:35Z her view priced at 2.716 chars/token (301,960 chars / 111,165 tokens). Without the backlog it would have been ~31.6k chars, about 11.6k tokens, under the 14,353 granted, so that act keeps its epoch instead of turning over.
Tests: continuum-context lib 90/90; continuum-cognition
llm_deliberation_faculty128/128 andcontext_streams21/21 (--features test-fixtures,metal); ratchets vs origin/canary all flat.After deploy (owner Fable, first live read after this merges): per resident
delib.segment.attribution broke_in=historyshare (before: Atlas 14/19, Benchy 13/14),delib.view.turnoverper act, and no advance withthoughts:over ~5k chars after ashed_sources>0start.Not fixed here (named, not orphaned)
delib.window.flexfor Atlas showscontext_window=30566 tools_granted=12332 framing_tokens=3031 unallocated=0, withnewest_grantedswinging 1,036-6,578. Her view's grant moves by thousands of tokens act to act, so the view still overflows on small appends after this fix. That's the grant's share, not the view's.fold(follow-up, owner Fable): her thoughts floor grows by one ~68-char pointer per thought (~280 lines, ~19.5k chars now), which is why it's the source that gets shed. A fold needs a reopen handle by thought number (Reopenhas onlyActandOutput), which is a tool-surface change best made after Every budgeted part collapses by its levels instead of refusing: hands, framing, grounding as consumers in one searched allocation #5814 lands.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo