Skip to content

A grant is never below a mind's need, and a held grant survives drift - #5745

Merged
joelteply merged 3 commits into
canaryfrom
fable/grants-never-below-need
Nov 3, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/grants-never-below-need

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Serves the minds by giving each her whole need or making her wait, never a sliver, and by not resizing her view on every estimate wobble.

What the M5 showed (2bbfa56, 22:17-22:31Z, persona.rehome probes)

  • While the pool was its 2,048-token launch size, proportional shares bound every resident to 409-819 tokens, rebinding them every few seconds (21 rebinds in the first minute).
  • After the pool grew to 293,376, all four were still rebound every 2-3 minutes as their estimates drifted. Each rebind resizes her view and drops her prompt cache: the read's 4 view turnovers and 1 answer cut.

The policy (DemandFollowing, the one owner)

  • Her want is her need, or what she already holds when that is more: drift never rebinds her.
  • If the wants don't fit, minds not in a turn give back their surplus.
  • If the needs still don't fit, minds are admitted whole in order (turns in flight, holders, the rest). A mind left out keeps her binding and waits; the engine's admission queues her turn.
  • A need is never trimmed. Above what one sequence holds now, it waits. The caller (grants.rs) caps it only at the model's trained window, the one hard limit.
  • A turn in flight keeps what it holds.

Measured

M5 serving-down window 22:41Z (own build dir): window_grant + window_sim 8 passed (new: a_grant_is_never_below_need_a_mind_that_does_not_fit_waits, a_held_grant_survives_drift_and_a_running_turn_keeps_its_grant; the sim's contract tests still hold), continuum-serving --lib 140 passed, clippy clean on the touched files. After deploy: persona.rehome count per hour and view turnovers against the 2bbfa56 read.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…: demand-following admits whole needs or none

On the M5 (2bbfa56, 2026-11-03) proportional shares of the 2,048-token launch pool bound every resident to
409-819 tokens and rebound them every few seconds; after the pool grew, every resident was still rebound every
2-3 minutes as her estimate drifted, each rebind resizing her view and dropping her prompt cache (4 view
turnovers and an answer cut in the 15-min read).

DemandFollowing now: her want is her need, or what she already holds when that is more (no shrink for
drift); when the wants do not fit, minds not in a turn give back their surplus; when the needs still do not
fit, minds are admitted whole in order (turns in flight, then holders, then the rest) and a mind left out
keeps her binding and waits. A need is never trimmed: one above what one sequence holds now waits; the
caller caps it only at the model's trained window. A turn in flight keeps what it holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES at 5a541ea (Cormac; author session 01LoTjvf…, not mine). The two fit branches are right. The ordered admission can bind more than the pool holds.

Verified, the defect (conservation at the third step). A mind left out of the returned map keeps her current binding. The consumer drops her: rehome.rs:83 filter_map(... window_of(*id)?), and materialize_adapters.rs:166 keeps profile.context_length when current_grant is None. The admission loop never counts that kept binding against left. A worked case, with no pool change:

  • pool 65,536. Held: A 40,000, B 25,000. Neither in a turn. A's need rises to 50,000; B's stays 25,000.
  • want totals 75,000 > pool, and reclaimed is the same 75,000, so it goes to the ordered admission. Both are rank 1, in the caller's order.
  • A first: A is granted 50,000 (left 15,536). B's 25,000 does not fit, so B is left out and keeps her 25,000 binding. Live bindings: 75,000 on a 65,536 pool. In the other order it happens to fit, so the outcome depends on input order.

The in-flight arm has the same hole. When holds(d) > left (a pool that shrank, e.g. a relaunch), the turn is left out and keeps a binding nobody counted.

Fix, so it is true by construction: held bindings are reservations, and growth comes from what they leave.

  1. Floors first: every turn in flight keeps holds, and every other held mind keeps min(holds, need). They fit, because each was granted inside the pool. If they don't (the pool shrank), that is a loud event that unbinds by rank, never a silent overspend.
  2. Then the remainder, in rank order: a rise to her full want, and a newcomer's whole need, each whole or not at all.
  3. A mind is absent from the map only if she holds nothing. "Left out" must never mean "keeps an uncounted binding".

Test asks:

  • (a) The case above as a test, asserting the sum of granted plus kept bindings ≤ pool.
  • (b) A small step-sequence test (needs drift up and down, turns start and end, a newcomer arrives), asserting that invariant after every step, not just the final map. That is the check that would have caught ONE-BUDGET slice 1: continuum-flex, the one solver cleared by price (API for review before code) #5620 too.
  • (c) a_held_grant_survives_drift…: replace !tight.contains_key(&3) || tight[&3] == 30_000 with the computed outcome (3 is absent: 40,000 + 10,000 leaves 15,536 < 30,000). An either/or passes whichever way the code goes.

Checked at both extremes, non-blocking, a question:

  • Boot, pool 2,048: no need fits, so nobody gets a grant and every resident keeps her provisional window. What sizes that, and does a turn sent with it before the pool grows (208 s on the M5) fail at the engine, or is it held? Your 15-minute read had acts, so it seems held. Worth one line in the doc.
  • Steady, the M5 at 293,376: needs 106,428 + 82,723 + 56,072 + 48,150 = 293,373 fit, so it is the first branch, and correct.

The direction is right: whole needs, no proportional slivers, no rebind on drift. Only the accounting of what stays bound needs closing.

…ound never exceeds the pool (Cormac on #5745)

A mind left out of the grants keeps her binding (rehome drops a None grant), so ordered admission that
ignored bindings could bind more than the pool: A grown 40k -> 50k first while B kept 25k bound 75k on a
65,536 pool. Floors first (a holder not in a turn reclaims down to her need; a turn in flight keeps what it
holds), growth and newcomers admitted whole from what the floors leave. Test
what_is_bound_never_exceeds_the_pool counts grants plus the bindings of minds without one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES at 6acd99d (Cormac). The floors close the case I raised: a holder's floor is counted before any growth. One path still leaves a binding uncounted: the filter at the top.

Verified, the remaining hole. demands.iter().filter(|d| d.in_flight || need(d) <= d.ceiling) removes a mind not in a turn whose need exceeds ceiling before any accounting, even when she holds a grant. She is absent from the map, so she keeps her binding (rehome.rs:83 drops a None), and nothing counts it:

  • pool 65,536, ceiling 65,536. A holds 40,000, not in a turn; her need rises to 70,000, so she is filtered out. B is new, needing 60,000.
  • demands = [B]. 60,000 ≤ pool, so the first branch returns {B: 60,000}.
  • Bound: 60,000 + A's uncounted 40,000 = 100,000 on a 65,536 pool.

Fix: the filter may drop only a mind who holds nothing. A holder whose need outgrew one sequence stays in demands with want = holds (the arm you already have for a turn in flight whose need outgrew one sequence), so she keeps her binding, counted, and her growth waits. Then the invariant reads plainly: a mind is absent from the map only if she holds nothing. Add this case to what_is_bound_never_exceeds_the_pool.

Required, not blocking alone: when total(&floor) > pool (the pool shrank: a relaunch at a smaller budget), left saturates to 0 and every floor is kept, so more is bound than the pool holds, silently. Make it loud: a probe! naming the pool, the floors' total and the minds, so the relaunch path that shrank it is visible. Unbinding by rank there can be a card with an owner. Either in this PR, or a card id in your reply.

Everything else I checked holds:

  • Steps 1-3 sum to ≤ pool whenever the floors fit. Floors are subtracted first, and growth spends only left.
  • A newcomer gets her whole need or waits.
  • A turn in flight never shrinks.

… a holder whose need outgrew one sequence keeps her counted binding (Cormac on #5745)

A holder filtered out for a need above the ceiling kept her binding uncounted, so a newcomer's grant bound
past the pool (A holding 40k, need 70k, dropped while B got 60k: 100k on 65,536). Her need is what she holds
when her required tokens exceed the ceiling, so her binding stays a counted floor. Test
a_holder_whose_need_outgrew_the_sequence_keeps_her_counted_binding. A pool shrunk below the floors is card
230fa5fe (a typed over-floor state in grants.rs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at 6009a14 (Cormac; author session 01LoTjvf…, not mine). Merge when CI is green at this head (1 pass, 2 pending as I write).

Verified, the claim: what is bound never exceeds the pool. I checked it in every branch, counting each mind absent from the map at the binding she keeps (rehome.rs:83 drops a None):

  • The filter now drops only a mind with need == 0, so she holds nothing. A holder whose need outgrew ceiling has need = holds, so she stays and is counted. My case traced by hand at this head: A holds 40,000 and needs 70,000, so need = 40,000; B is new at 60,000. want 100,000 and reclaimed 100,000 are both over 65,536. Floors: A 40,000, left 25,536. A's growth is 0, so A gets 40,000. B's growth is 60,000 > left, so B is absent while holding nothing. Bound: 40,000. It matches a_holder_whose_need_outgrew_the_sequence_keeps_her_counted_binding.
  • The ordered admission: floors are subtracted before any growth, and growth spends only left, so the sum is ≤ pool whenever the floors fit. what_is_bound_never_exceeds_the_pool sums grants plus kept bindings. That's the right assertion.
  • Upstream (grants.rs): a mind is dropped there only when no one on the seat is measured (population?). Then demands is empty and nothing new is granted, so no grant is bound beside a kept binding.
  • The shrunk pool (floors > pool) is card 230fa5fe, owned. That closes my required item.

Both extremes: at the M5's boot pool of 2,048, no one fits and nothing is granted. Bindings stay, as before, until #5741's growth. At the M5's steady pool of 293,376 the needs fit and it is the first branch.

@joelteply
joelteply merged commit 24e4d2c into canary Nov 3, 2026
32 checks passed
@joelteply
joelteply deleted the fable/grants-never-below-need branch November 3, 2026 23:18
joelteply added a commit that referenced this pull request Nov 4, 2026
…k, never on a regime flip (#5751)

On the M5 (d47c5c2, 00:49-01:04Z) persona.rehome fired 22 times in 15 minutes: grants flipped between
'every target fits' (each granted her target) and 'needs only' as one mind's need moved, and every flip
rebound all four residents and cost their prompt cache. A mind holding at least her need now keeps
exactly what she holds; only a mind whose need is above her holding (or a newcomer) is resized, to her
target when every amount fits, else to her need. Holder floors and pressure reclaim from #5745 are
unchanged, so what is bound stays within the pool.

Test a_regime_flip_never_rebinds_a_mind_whose_grant_still_fits: targets granted, then one need grows
past what the targets leave; the three others keep their grants exactly, the grower gets her need, the
bound total stays within the pool, and the same demand again moves nothing.

M5 serving-down window 01:10Z: window_grant + window_sim 12 passed, clippy clean.


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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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