Skip to content

Context has a price: her act holds the window where her value per second peaks (card 7b7a696a) - #5822

Merged
joelteply merged 2 commits into
canaryfrom
fable/context-has-a-price
Nov 7, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fable/context-has-a-price

Conversation

@joelteply

@joelteply joelteply commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Card 7b7a696a (P0). Stacked on #5819 (fable/view-start-token-oracle, itself stacked on #5814). Do not merge before them.

How this serves the minds: a resident's prompt is charged at what it costs her act in seconds. She keeps the context that is worth its time and collapses the rest, even when her window could hold more. It never prices out what she acts through, and it never prices where nothing was measured. This advances path step 1 (Fast: median act under 60 s at four residents) and goal 7 (one budget).

The regression

The M5 ran build 19426f4 with fork 46c664457. The pool regrew from 152,832 to 755,456 tokens, and grants grew toward untrimmed demand (150k to 557k). Residents' prompts went from about 30k to 35-75k tokens. In the first hour there were 71 acts, against 158 the hour before. The median act took 104 s, against 50 s. The allocation filled whatever window it was served.

Step 1: measure (continuum_context::price)

The fit runs per (provider, model), from her acts' own engine timings (GenerationTiming). It fits three weighted least-squares lines:

  • decode seconds per output token against the context it decoded over;
  • prefill seconds per fresh token against the context it prefilled over;
  • fresh tokens per act against the prompt, because a held token is prefilled again whenever her cache is lost or her view turns over.

Together they give an act's seconds at a held context, T(X), and its derivative, the marginal seconds per held token. A fourth line fits engine seconds per act directly and checks the composed curve. The fit keeps only sufficient statistics. A line that is undetermined, or a marginal within one standard error of zero, is ContextPrice::Unmeasured.

ActTime::measured() is the range of prompt contexts the fit was measured over.

The validator is cargo run -p continuum-context --example replay -- --act-price --since <UTC>.

Step 2: price it (allocation/priced.rs)

The allocation holds the window W that maximizes R(W) = (V(W) - V(least)) / T(W). V is the search's own value (Σ priority x ln(1 + tokens)); T is her measured seconds at W, less the reply's grant.

Exchange rate. No constant is involved. At the peak, dV/dW = R x dT/dW, so the exchange rate between value and seconds is R itself: her optional context's value per second (Dinkelbach's form). The one measured quantity behind it is her act time. Her least plan's value appears in every plan the price can choose, so the rate leaves it out. Counting that value too gives a rate about 7x higher, which priced every optional token out on the M5's numbers.

Why a window instead of a per-token term in the search. Allocating at a smaller window is the same as a higher price on every token, up to level steps. So the priced plan is the existing plan at W, and every downstream reader (her view's start, its room, the turnover depth) sees one window. search.rs is unchanged.

What a price choice never does:

  • Extrapolate. It only chooses windows whose held context lies inside ActTime::measured(). Where no such window exists, the plan is the plan as before, and the receipt says Priced::OutsideMeasured { measured }. The served window competes only when it is measured too; Held.at_window is None otherwise.
  • Show what she acts through below its summary. ladder::Consumer types this per consumer kind:
    • Context: a choice may reach the hard limit.
    • Actionable: a choice never shows an item below its summary.
    • Her tools are an Actionable Head. Her held card is an Actionable view source (Source::consumer), whole under a choice.
    • A pointer is still reachable through the hard-limit path, when the window is too small: Priced::WindowBinds, planned exactly as before.
    • The plan's hard limits stay her claims' own, so her recorded need never reads the price's floor.
  • Price out what she must hold (least):
    • every hard limit;
    • her held head levels;
    • her newest result whole;
    • her reply's measured need;
    • what she acts through, at its summary.

Search. A ternary search over W within the measured part of [least, window], accurate to the token. It takes about 2 ms per act.

Value signal. Value is still priority x ln(tokens). Using the measured re-read hazard (#5806) as the history value is card 4e97192b.

Wiring

  • The live fit is one ActTimeFit per (provider, model) in her working memory (working_memory::act_times). It is checkpointed in her volatile snapshot, so window changes and restarts keep it.
    • Before this, it lived in PromptFeedback, which resets on every window change and deploy. The dyno found it measured on only 14-53% of acts.
  • Each reply's timing folds in through learn_prompt_density.
  • ActClaims.price, ActClaims.view: Vec<ViewClaim { claim, consumer }> and Head.consumer carry the inputs.
  • The delib.window.flex probe logs priced.

Tooling: replay --allocate

This is the allocation's dyno: each captured act's claims are driven through allocate, priced and unpriced. It reuses captures::load and the view replay's cut. Per resident it reports:

  • kept tokens, median and p90;
  • held window over the served one;
  • predicted seconds per act;
  • tools sent and kept;
  • what the price decided;
  • how many acts the live fit priced.

--trace i,j prints every claim for the named acts.

Tests

  • price/tests.rs:
    • the fit recovers known lines;
    • the marginal is the numeric derivative;
    • too few acts, no spread, or noise all give Unmeasured.
  • allocation/priced/tests.rs, on the M5's measured act time:
    • a_large_window_is_not_filled_when_its_tokens_cost_more_than_they_add: inside the measured contexts, and never priced at the served window by extrapolation;
    • the_price_never_chooses_outside_the_measured_contexts: a curve measured over 60k-146k never holds below 60k; one measured only below least plans as before (OutsideMeasured);
    • what_she_acts_through_is_never_priced_below_its_summary: verbs at least at summaries and the held card whole; a window between the names-only floor and the summaries floor binds and plans as before;
    • a_small_window_plans_as_before, her_newest_result_is_never_priced_out, a_cheaper_context_holds_more.
  • working_memory/act_times.rs: a fit is kept per engine and model across a checkpoint round trip, and other models' acts never join it.
  • Local runs on head 1fa12e9:
    • cargo test -p continuum-context --lib --examples: 106 + 21 passed;
    • cargo test -p continuum-cognition --lib --features test-fixtures,metal -- llm_deliberation_faculty working_memory context_streams: 215 passed;
    • cargo check on continuum-cognition and continuum-core tests (test-fixtures,metal): clean;
    • ratchets origin/fable/view-start-token-oracle: every count unchanged.

Measured

The curve. From replay --act-price --since 2026-11-06T13:00Z on the M5's captures: Qwen3.6-35B-A3B, 1,124 completed acts, prompts from 10,840 to 145,858 tokens, read at 2026-11-07 13:04Z.

line intercept slope per context token
decode s/output token 0.0643 (±0.0030) 6.57e-7 (±5.8e-8)
prefill s/fresh token 0.00697 (±0.00091) 2.11e-7 (±2.6e-8)
fresh tokens per act 5,421 (±616) 0.132 (±0.015)
engine s/act, fitted directly 29.0 (±12.7) 3.73e-3 (±3.1e-4)

Marginal seconds per 1k tokens held, from the composed curve:

context marginal s per 1k held
11k 2.66 ± 0.22
28k 3.54 ± 0.30
45k 4.42 ± 0.37
61k 5.30 ± 0.45

The direct line gives 3.73 ± 0.31 s per 1k over the whole range. The composed curve runs high above 80k, where there are only 68 acts.

The dyno. replay --allocate --since 2026-11-07T01:00Z on the four residents' captures, head 1fa12e9, read at 15:07Z. The node fit is over 653 acts; measured contexts are 11,206 to 148,458.

resident acts sent med/p90 kept med/p90 (priced) unpriced kept med held/window med curve s/act at sent → kept tools sent → kept med held/binds/outside/unmeasured live fit priced
Aiko (75ece751) 182 25,084 / 59,512 11,206 / 34,108 24,584 66% 89 → 55 10,427 → 4,567 182/0/0/0 166/182
Aris (8044b75b) 182 12,978 / 91,335 11,206 / 29,788 12,659 85% 59 → 55 7,594 → 6,240 182/0/0/0 88/182
Atlas (e5f4141d) 191 25,900 / 31,670 11,203 / 13,213 25,170 39% 91 → 55 9,711 → 2,932 191/0/0/0 188/191
Benchy (2f50b223) 98 28,653 / 30,158 11,206 / 16,420 28,053 38% 99 → 55 12,146 → 3,339 98/0/0/0 85/98

What the dyno shows. The price now stays inside its measurement, and the kept median sits on the lower bound of the measured range (11,206). The curve's peak for most acts lies below the smallest context it was measured at. It does not choose that peak; it holds the smallest measured context. That is a real limit: the price stops at the edge of its own measurement rather than following the curve further down. Tools never go below their summaries; the remaining tool cut is whole schemas down to name and description. The live fit, now kept per engine and model, priced 46-98% of acts; Aris is lowest because her fit's marginal stays within one standard error longer.

What the dyno cannot show:

  • Quality and the cost of collapse. It predicts seconds from the curve; it cannot measure what she loses. That includes a verb at name and description instead of its full schema, history collapsed to pointers, and the extra acts (help calls, re-reads) any collapse may cost. The value is still priority x ln(tokens), and the re-read weight is card 4e97192b.
  • Contention. The curve is fitted from acts that ran beside other residents. How many residents decode at once is not a covariate, so part of the slope may be contention that grew with everyone's context. A smaller prompt for all four may also reduce contention, which the curve would not predict.
  • The pool bloat. It is not fixed in this stack. The working-set registry still records untrimmed demand, so grants and the pool can keep growing; the plan no longer fills them, but memory is held. Recording her priced need belongs with the governor's owner.
  • The capture approximation. The dyno rebuilds each act's claims from the capture: the framing whole (its menu levels are not captured), view sources from the view replay's cut, and the reply's need from her previous twenty outputs. That is close to the live claims, not identical.

After-deploy check (owner Fable, deadline: first live hour after #5814, #5819 and this PR deploy on the M5): per resident, median act and acts/h at the same window grants as 19426f4, from the captures. Also check each act's priced field on delib.window.flex, which should be mostly Held inside the measured range, and tool grants at or above the summaries. The pass criterion is a median act at or below 60 s with grants unchanged. The card stays open until that receipt is posted.

Rebased onto #5819 at bf0e87c (2026-11-07), head 761369c

The only conflict was continuum-context/src/lib.rs: canary's pub mod nav and this PR's pub mod price are both kept.

Measured on the M5 (local, nice 19, own target dir, serving untouched) at 761369c:

  • cargo test -p continuum-context --lib --examples: 111 + 21 passed.
  • cargo test -p continuum-cognition --lib --features test-fixtures,metal: 974 passed, 0 failed, 1 ignored.
  • cargo test -p continuum-core --lib --features test-fixtures,metal -- deliberation: 19 passed.
  • ratchets p5819 (bf0e87c): exit 0, every count unchanged.

Recording her priced need: the "pool bloat" item above, which said this belongs with the governor's owner, is now #5833, stacked on this PR. Her need is now the window this price chose. It is never a sum of floors and never her view's uncollapsed overflow, and it is never past the model's trained context.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply added a commit that referenced this pull request Nov 7, 2026
…ver untrimmed demand, and a settled holder above it is released (card 7b7a696a, step 1) (#5823)

The M5, 2026-11-07, 19426f4 + fork 46c664457 (Fable's first-hour read): 71 acts vs 158 the hour
before, median 104 s vs 50 s, decode 7-10 t/s vs 15-22, Benchy 392 s, 1 write. The cold-boot plan
regrew the pool from 152,832 to 755,456 and #5816 grew minds toward targets of 150-557k (her untrimmed
wish with headroom), so grants reached 197k and prompts grew from ~30k to 35-75k; every held token
slows every act (Fable measured 3.54 +/- 0.30 s per act per 1k held tokens on 1,124 acts).

Step 1, the stopgap, within the hour of the read:
- grants.rs: a mind's target is her held need x SENT_HEADROOM (the existing named sent headroom),
  never her untrimmed demand. Growing past it is a priced decision (step 2).
- window_grant.rs: a settled mind (served on her grant since it last changed) with no turn in flight
  holds no more than her target as the policy reads it, so what she holds above it is released at her
  next view start in every stage. A mind not yet served on her grant, or mid-turn, keeps all of it.

Step 2 (this card, after #5822 lands): the target reads continuum-context price.rs, the window her
priced plan holds, and SENT_HEADROOM leaves the grant path; 68ffe0f0 (requirements record what the
priced plan holds, so the pool stops growing for unheld demand) rides with it.

Tests: continuum-engine capacity:: 234 pass; continuum-serving --tests check clean; ratchets vs
origin/canary 87/87. New: a_settled_holder_above_her_target_is_released_to_it (197k held, 30k need:
released to 37,500; unserved or mid-turn keeps it). Updated with reasons: the drift test now uses
production-shaped targets (a drift inside the headroom keeps the grant; that headroom is what makes
drift free), and the roomy case asserts release instead of "keeps her surplus". Mutation: without the
holds cap, the release test fails.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@joelteply
joelteply force-pushed the fable/view-start-token-oracle branch from 2654bad to cb3b9a1 Compare November 7, 2026 14:19
@joelteply
joelteply force-pushed the fable/context-has-a-price branch from 293f7ba to 6a36aeb Compare November 7, 2026 14:19
joelteply added a commit that referenced this pull request Nov 7, 2026
… through to names

The dyno on #5822 (the residents' captures driven through allocate) found three defects:

1. Extrapolation: ~80% of the windows priced::hold chose lay below the smallest context ever
   measured (10,840), where the fresh-tokens line clamps. The search now runs only over windows
   whose held context lies inside ActTime::measured(); where none does the plan is the plan as
   before and the receipt says Priced::OutsideMeasured { measured }. The served window competes
   only when it is measured too (Held.at_window is None otherwise).
2. Tools priced to names: the cut was mostly her tool schemas going from 8.5-10.4k tokens to
   245-717, a help call and an extra act each that no value the allocation weighs can see.
   ladder::Consumer types what a consumer is to her: Context (a choice may reach its hard limit)
   or Actionable (a choice never shows an item below its summary; the pointer stays reachable only
   through the hard-limit path, a window too small). Head carries its consumer (her tools are
   Actionable), Source::consumer declares a view source's (her held card is Actionable, whole under
   a choice), and ActClaims.view carries ViewClaim { claim, consumer }. The plan's hard limits stay
   her claims' own, so her recorded need never reads the price's floor.
3. The live fit rarely existed: keyed by her binding's window it reset on every window change and
   deploy (measured on 14-53% of acts). It now lives in her working memory, one ActTimeFit per
   (provider, model) (working_memory::act_times), checkpointed in her volatile snapshot.

Tooling: `replay --allocate [--since] [--trace i,j]` is the allocation's dyno: per resident, sent
and kept tokens, priced and unpriced, held over served window, predicted s/act, tools sent and
kept, what the price decided and how many acts the live fit priced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/view-start-token-oracle branch from cb3b9a1 to bf0e87c Compare November 7, 2026 17:36
joelteply added a commit that referenced this pull request Nov 7, 2026
… through to names

The dyno on #5822 (the residents' captures driven through allocate) found three defects:

1. Extrapolation: ~80% of the windows priced::hold chose lay below the smallest context ever
   measured (10,840), where the fresh-tokens line clamps. The search now runs only over windows
   whose held context lies inside ActTime::measured(); where none does the plan is the plan as
   before and the receipt says Priced::OutsideMeasured { measured }. The served window competes
   only when it is measured too (Held.at_window is None otherwise).
2. Tools priced to names: the cut was mostly her tool schemas going from 8.5-10.4k tokens to
   245-717, a help call and an extra act each that no value the allocation weighs can see.
   ladder::Consumer types what a consumer is to her: Context (a choice may reach its hard limit)
   or Actionable (a choice never shows an item below its summary; the pointer stays reachable only
   through the hard-limit path, a window too small). Head carries its consumer (her tools are
   Actionable), Source::consumer declares a view source's (her held card is Actionable, whole under
   a choice), and ActClaims.view carries ViewClaim { claim, consumer }. The plan's hard limits stay
   her claims' own, so her recorded need never reads the price's floor.
3. The live fit rarely existed: keyed by her binding's window it reset on every window change and
   deploy (measured on 14-53% of acts). It now lives in her working memory, one ActTimeFit per
   (provider, model) (working_memory::act_times), checkpointed in her volatile snapshot.

Tooling: `replay --allocate [--since] [--trace i,j]` is the allocation's dyno: per resident, sent
and kept tokens, priced and unpriced, held over served window, predicted s/act, tools sent and
kept, what the price decided and how many acts the live fit priced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/context-has-a-price branch from 1fa12e9 to 761369c Compare November 7, 2026 17:36
Base automatically changed from fable/view-start-token-oracle to canary November 7, 2026 18:19
joelteply and others added 2 commits November 7, 2026 12:47
…ond peaks

Card 7b7a696a. On the M5 (build 19426f4) the pool regrew 152,832 -> 755,456 tokens, the
grants grew toward untrimmed demand, and her prompts went from ~30k to 35-75k tokens: 71 acts in
the first hour against 158 the hour before, median act 104 s against 50 s. Every held token slows
every act, and the allocation filled whatever window it was served.

Measure (continuum_context::price, validator `replay --act-price`): per binding, from her acts'
own engine timings, three weighted least-squares lines (decode s/output token and prefill s/fresh
token against the context each ran over, fresh tokens per act against the prompt) compose her
act's seconds at a held context; a fourth, engine seconds per act fitted directly, is the check.
Sufficient statistics only; an undetermined line, or a marginal within one standard error of
none, is ContextPrice::Unmeasured.

Price (allocation/priced.rs): the allocation holds the window W in [least, served] that
maximizes (V(W) - V(least)) / T(W): the search's own value above her least plan, per measured
second of her act. The exchange rate is that ratio itself (Dinkelbach), no constant. Allocating
at W reproduces the priced optimum, so her view's start, its room and the turnover depth see one
consistent window. `least` keeps every hard limit, her held head levels, her newest result whole
and her reply's need: never priced out. Unmeasured, or a window no larger than `least`, plans
exactly as before.

Wiring: the faculty folds each reply's timing into an ActTimeFit carried in her PromptFeedback
beside her density (reset with it on a binding change) and passes its price into ActClaims; the
window.flex probe names what the price decided.

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

The dyno on #5822 (the residents' captures driven through allocate) found three defects:

1. Extrapolation: ~80% of the windows priced::hold chose lay below the smallest context ever
   measured (10,840), where the fresh-tokens line clamps. The search now runs only over windows
   whose held context lies inside ActTime::measured(); where none does the plan is the plan as
   before and the receipt says Priced::OutsideMeasured { measured }. The served window competes
   only when it is measured too (Held.at_window is None otherwise).
2. Tools priced to names: the cut was mostly her tool schemas going from 8.5-10.4k tokens to
   245-717, a help call and an extra act each that no value the allocation weighs can see.
   ladder::Consumer types what a consumer is to her: Context (a choice may reach its hard limit)
   or Actionable (a choice never shows an item below its summary; the pointer stays reachable only
   through the hard-limit path, a window too small). Head carries its consumer (her tools are
   Actionable), Source::consumer declares a view source's (her held card is Actionable, whole under
   a choice), and ActClaims.view carries ViewClaim { claim, consumer }. The plan's hard limits stay
   her claims' own, so her recorded need never reads the price's floor.
3. The live fit rarely existed: keyed by her binding's window it reset on every window change and
   deploy (measured on 14-53% of acts). It now lives in her working memory, one ActTimeFit per
   (provider, model) (working_memory::act_times), checkpointed in her volatile snapshot.

Tooling: `replay --allocate [--since] [--trace i,j]` is the allocation's dyno: per resident, sent
and kept tokens, priced and unpriced, held over served window, predicted s/act, tools sent and
kept, what the price decided and how many acts the live fit priced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/context-has-a-price branch from 761369c to 0186968 Compare November 7, 2026 18:47
@joelteply
joelteply merged commit acaaf3f into canary Nov 7, 2026
18 checks passed
@joelteply
joelteply deleted the fable/context-has-a-price branch November 7, 2026 18:58
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