Skip to content

Focus: separate saved-output transport pages from prompt allocation - #5576

Closed
joelteply wants to merge 36 commits into
canaryfrom
codex/focus-tools
Closed

joelteply wants to merge 36 commits into
canaryfrom
codex/focus-tools

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

A saved-output read currently derives its page size from the model window. This couples transport memory to perception and leaves a second context-sizing path outside the shared focus allocation.

This follow-up to #5574 uses a provisional 64 KiB encoded transport page, preserves byte continuation, and adds a multi-page Unicode reconstruction test. The returned page still enters the action source, where the shared view chooses its level. It also removes an obsolete observation-only tool affordability recalculation; allocation window and component costs remain in the existing render receipt.

Validation: diff check passed. Native tests pending CI; no local build beside serving. The page size is not a measured optimum or proof of aggregate RAM accounting. Full response-lifetime custody is tracked in e42d74ce; this draft joins the shared focus integration, not a standalone deployment.

joelteply and others added 30 commits October 28, 2026 10:18
…ill rate, not the whole slot: prefill per request ~3x lower on the dyno

ContextBudget::working_window: 2 x INTERACTIVE_TTFT x the measured prefill rate (a turnover's
cold half fits the interactive minute), snapped to 8k so the rate's EMA does not move it act to
act, never above the served slot, the served window when nothing is measured. On the M5 the rate
reads 396 tok/s, so 48k.

The dyno found the same knee independently (continuum-context replay --append-tail 300 over
the residents' own captures): prefill per request Benchy 110 -> 41 s, Aiko 81 -> 24, Aris 113 -> 33,
Atlas 94 -> 20, zero handles dropped; 32k doubled turnovers.
The simulator forecasts model calls 79 -> ~45 s.

- prompt_fit fits to it. The result and room-update shares and the tool surface scale with it.
- The binding keeps the served window (serving reads it). The plan's demand samples are
  unchanged: a trimmed turn already records her untrimmed demand.
- Required input past the working window is fitted to the served window, once
  (delib.prompt.working_window_exceeded), never refused while the slot has room.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ble under load, never moves mid-epoch

f45f090a6 derived it from the live prefill-rate EMA. Contention lowered the rate 396 -> 354 tok/s
and briefly lower, so the window moved 48k -> 40k -> 32k mid-epoch: Aris was refused twice at 32k
and epochs turned over 74 times in 37 minutes. That build was rolled back. The knee is a token count
of her own traffic (where turnovers start costing more than the smaller context saves), so it holds
whatever the engine's speed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…e, so the behavior live on the M5 is tested; and it compiles (Codex and Cormac on #5564)

working_window referenced Self::WORKING_WINDOW_TOKENS, a module-scope const: no such
associated item (Codex). The rule moves to working_window_when(served, serving), using
the const directly; working_window reads whether a model is served and delegates. The test
ran only the no-model branch; it now asserts 159,232 -> 49,152, 32,768 -> 32,768 (never
above the slot), not serving -> served, and 0 -> 0.

Not compiled locally (an Intel serving node, empty target); CI is the receipt.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…all them through Self (corrects my f7ebc79 on #5564)

context_budget.rs keeps column-0 items inside impl ContextBudget (lines 85-570), so the
const at 319 and the helper at 323 are associated. b1acb40's Self::WORKING_WINDOW_TOKENS
was right; the 'module-scope' reading (Codex's, and mine in f7ebc79) was wrong, and
f7ebc79 broke the build (CI: E0425 cannot find WORKING_WINDOW_TOKENS / working_window_when,
'consider using the associated constant on Self'). The pure helper and its four asserts
stay; they now call Self:: and ContextBudget::.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…t size decided outside the one flexbox allocation (~40 today; may only fall; deleted at 0 when the sizing methods go private)

FLOW-IMPLEMENTATION-PLAN §2d. Predicate tests: recall's from_window(...).recall_tokens() and
compose_for_turn's adapter.allocate(...) count; the allocation in prompt/view.rs and the
definitions in context_budget.rs do not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…atalog, tool_summary, ToolCatalogEntry) and its catalog_summary_chars fraction are deleted

No caller anywhere; the fraction existed only for it (prompt_self_sizing -1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ency is not visibility)

Item.stored: Option<StoredWhole { chars, handle }>. The allocation prices a stored whole from its
measured size (whole_chars) and never reads it; only an item granted WHOLE is loaded, through its
own source's Source::load (default None: a source that spills bodies overrides it). Evicting a body
from RAM no longer changes what she can see (Cormac's proposal on FLOW plan §2d). Every literal Item
construction carries stored: None; Item::whole for the common case.

Uncompiled: built and tested in the next serving-down window with the conversation step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…moves on the read receipt of a sent prompt (FLOW §2d)

The airc source no longer sizes the conversation. Deleted: the per-turn cap and its head cut,
the anchor/natural/HISTORY_SLACK second view, grounding_for_budget (the staged depth is the
recipe grounding, at least the fetch window), and mark-read at delivery. pack_digest becomes
digest_items: receipt runs folded, quarantine kept, every unit whole. Her one view decides
what she sees.

Mark-read moves to after a sent prompt: BurstTurn carries its TurnSource {room, event,
lamport}; the view keys room turns by event (fixes same-ms/author key collisions);
View::renders(source, key) answers whether her view shows an item (collapsed = not read);
the deliberation faculty's ReadReceipt hook (read_receipt.rs) marks each room read through
the newest event the accepted prompt rendered. The supervisor installs her airc source as
the receipt; forks and evals mark nothing. A refused act or a collapsed turn stays unread,
and rag_inspect no longer moves a resident's real cursor.

Staged-digest reuse: served only when it holds at least what a rebuild would (the room's
events after any top-up), replacing the budget-derived proxy.

Codec: Item.stored (db36673) compiles; whole() keeps the start loop's fingerprint key.
Tests: codec renders/stored-whole contracts; whole delivery at any budget; delivery marks
nothing read and the receipt marks exactly the named event; rewritten packing pins.

Local, 19:53Z serving-down window on the M5: check --tests ok (context, cognition, mind);
context 35/0, cognition 1199/0, hygiene 69/0, mind 848/1 (serves_prestaged_digest: fixed by
the reuse rule above, re-run in the next window).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… level kept for the epoch (FLOW §2d, FLEX_TOOLS)

On Codex's tools API (#5574, merged into this base): the view prices her hands as the claim
'tools' (priority 7): floor = core hands (unconditional), target = the level this view epoch
already chose (min_tokens, given up only when the window cannot hold it, probed as
delib.tools.epoch_level_lost), want = her whole surface (claim_with_head). The surface is
selected from the grant after the allocation (select_tool_surface_granted); a grant below
core hands is a capacity refusal, never a handless send. The level is retained per view
epoch after fit_view (prompt/tools_epoch.rs), so the schemas ahead of every message stay
byte-identical within an epoch.

One decision: DeliberationPromptView carries the selection (tools) and its grant
(tools_grant); contribute sends exactly that, and a server refusing tail_tools gets the
activity surface at the same grant. Before, contribute re-selected against a window share
(ContextBudget::tool_surface_tokens) the allocation never saw. The pre-allocation room math
subtracts the core floor; the budget ledger's framing grant includes the tools grant.

Production no longer calls select_tool_surface or tool_surface_tokens; their deletion with
the test migration is Codex's slice. Test: an epoch keeps the level its allocation bought.

Uncompiled: built and tested in the next serving-down window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…evels; no source takes a size (FLOW §2d)

RagSource::deliver(ctx) takes no budget and no resolution; floor_tokens and budget_claim
leave the trait. RagItem gains a stable key and summary/pointer levels (RagItem::whole,
with_summary, with_pointer); RagDelivery::of/empty; old captures still read.

All 11 production sources migrated: no packing to a budget, no head cuts (doctrine, map,
wall), no 12-card cap (board), no budget-coupled state (active-work loss notice). The 7
grounding faculties no longer cut to a quarter of the window each (grounding_budget_for,
with_budget deleted); the contribution carries the source's units and her view's block
takes whole/summary/pointer from them (context_streams/blocks.rs). Recall drops its
window-share token ceiling (the measured count-by-capability ladder stays) and gives each
memory a gist and a handle. compose_for_turn's second flexbox is gone: it delivers airc and
the roster whole.

Deleted as dead: FlexboxRagBudgetAdapter, RagBudgetAdapter, ReservedTokens,
BudgetAllocation, ResolutionPreference, RagSourceBudget::retrieval/floorless_share,
ContextBudget::grounding_tokens/recall_tokens, EngramSource (its delivery was read by
nothing), RoomRosterSource (no production constructor), the BudgetAllocated capture event,
rag-inspect's allocation (inspection is now side-effect free).

Fixed: the awareness strip never reached her prompt (bound only to compose_for_turn, whose
delivery of it nothing read); it is now a grounding faculty.

Uncompiled at this commit; built and tested in the next serving-down window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…n left dead

Typed literals in the ported allocator tests; Contribution literals carry units; the refit
fixture takes an empty tool surface (SelectedSurface::none is pub); the wall tests' stray
brace. Deleted: viewstate_rag's private estimate_tokens (a second chars/token estimator) and
roster_slot_from_member (only the deleted legacy roster used it).

Local, 20:19-20:25Z serving-down window on the M5: check --tests ok (context, cognition,
mind, academy, core); tests context 35/0, cognition 1199/0, mind 1138/0, academy 190/0,
source-hygiene 69/0 (new tests confirmed in the logs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ly-size default goes

Room messages that arrived during a turn rode the fresh tail as required input under a
quarter-of-the-window share (ROOM_UPDATE_SHARE_DENOM, split_room_updates): a second budget.
They are conversation turns now, keyed by their airc event after the burst (one already in
the burst keeps its place), so they append to her view like any turn and can never inflate
the required input (the 2026-09-09 mute: 53k of room payload on a 23k window). The read
receipt counts a room update only when her view shows it. Deleted: split_room_updates,
ROOM_UPDATE_SHARE_DENOM, PromptMessages.room_updates, RequiredParts.room_updates/_count.
Tests: the busy-room test keeps its no-mute guarantee and checks the updates ride her view.

SamplingProfile.max_new_tokens and its window-derived default were read by nothing (reply
length is the reply's claim in the one allocation): deleted, with
ContextBudget::default_response_tokens; TS binding updated. Orphaned RagInspectAllocation.ts
removed.

Uncompiled at this commit; built and tested in the next serving-down window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ontinuum into fable/working-window

# Conflicts:
#	core/continuum-cognition/src/cognition/context_budget.rs
…r than her window never vanishes

As a conversation turn, a room update had no pointer level: one too large for her window
would leave her view unseen (it used to refuse the turn). Turn gains an optional pointer
that only room updates set: peer and event (shown_form), its size, and chat/history to
reread it. The burst's turns are unchanged (collapsed, they leave the view; the room's
history holds them). Not rendered whole, the update is not marked read.

Tests: the capacity test's room-update part now thinks instead of refusing and asserts the
handle reaches her prompt; only the oversized stimulus still refuses.

Window 20:29-20:31Z on 13ba365: check ok; context/mind/academy/hygiene green; cognition
1196/1 (this test, fixed here).

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

A handle per update put every update in the conversation's floor and crowded out the
newest (the busy-room test: 40 handles took its room). Updates keep no pointer; one index
line after them (its own pointer) says how many arrived and to reread any not shown with
chat/history, so an update too large to show is never unknown and the newest keeps its
room. Capacity test: part 2 reaches the model, so its script carries a response.

Window 20:33-20:35Z on e687458: cognition 1195/2, the two tests this fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…hown_form, never a hand slice

Eight hand-built 8-char prefixes (to_string().chars().take(8), simple()[..8]) become
shown_form, the one producer of the short id (same 8 hex, so the readers that decode these
lines are unaffected). Uncompiled; rides the next window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…eply reaches working memory whole

ContextBudget::echoed_arg_chars (a 64th of the window) sized how much of the arguments she
wrote is echoed in a result's header, and her intent line. Her tool call already carries
them whole, so this is a rule for showing her own words: ECHOED_ARG_CHARS, the fixed 600 it
was before it became a window share, beside recall's fixed 80. render_recency and
render_summary_part drop their budget parameter (callers in apply.rs, working_memory/ledger.rs
and two tests updated). settle_step recorded the head of her settled reply cut at
trail_head_chars; it records the whole and the trail's levels in her view decide.

Uncompiled; rides the next window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Base automatically changed from fable/working-window to canary October 29, 2026 19:00
@joelteply

Copy link
Copy Markdown
Contributor Author

Closing this stacked draft after architecture review at 332f102. It still carries the fixed quarter epoch start, 49,152-token working-window knee and provisional 64 KiB output transport page. These are not the final ONE-BUDGET/L3 contract and must not ship as an independent sizing path. Existing landed focus changes remain in #5564/#5573/#5606. The remaining saved-output paging work stays owned by Codex: re-cut against current canary with a transport-class resource grant and full response-lifetime custody, preserving Unicode continuation coverage. Closing preserves this branch and its evidence; it does not claim that remaining work is complete.

@joelteply joelteply closed this Oct 30, 2026
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