Skip to content

The window validator (§6e): today's equal split squeezes a reading mind; demand-following keeps the contract - #5718

Merged
joelteply merged 6 commits into
canaryfrom
fable/window-sim
Nov 3, 2026
Merged

joelteply merged 6 commits into
canaryfrom
fable/window-sim

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Serves the minds' context window (order of work line 3 / goal 9): a mind's window follows what she reads. This PR adds the validator that comes first (CLAUDE.md goal 11), and nothing else. There is no engine change.

What

continuum-engine/src/capacity/window_sim.rs turns a scenario into data: a timeline of each mind's demand events over one shared KV pool. A WindowPolicy grants windows, and run() checks the contract:

  • grants never exceed the pool;
  • every demand is granted when all demands fit;
  • an in-flight grant never shrinks;
  • squeezes are counted. A squeeze is a mind cut below her demand while another mind holds a grant beyond its own demand.

Two outliers:

  • EqualSplit { slots: 5 } is today's engine (4 residents plus the scratch slot, 58,112 each). On the M5's 11-02 shape it squeezes Aiko (70-76k) while Atlas idles at 9-12k. The test asserts the failure.
  • DemandFollowing keeps the contract on the same shape, and on an overloaded pool it never shrinks an in-flight turn.

Measured

  • cargo test -p continuum-engine --features metal --lib -- window_sim: 3 passed, 0.00 s. Run on the M5 with serving down, 2026-11-03 ~00:25Z, branch head b122fc0.
  • clippy: no findings in this file.
  • The live context it models: an hour on 2c0d45c (A mind's view is her served window: the fixed 49k cap is deleted #5715, no 49k cap), 23:20-00:18Z. 68 acts, 14 turnovers / 68 appends, windows 59,904 and 70,912. Aiko re-read 6 of 11 reads.

Added 1 file (~270 lines), removed 0. The engine allocator (Codex's unified-KV work) must pass this validator before its live read.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 3 commits November 2, 2026 17:21
…ver one shared pool, played through a WindowPolicy against the contract (never over the pool, every demand granted when all fit, no in-flight shrink, squeezes counted)

Outliers prove the interface, the capacity simulator's shape: today's equal split (one window per
slot, residents plus a scratch slot) squeezes a reading mind on the M5's own 2026-11-02 shape
(Aiko reads ~70-76k, granted 58,112 while Atlas idles), and a demand-following policy keeps the
contract. Needs no engine change; the allocator's uneven-grant work (Codex) is what makes the
second outlier real.

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

Copy link
Copy Markdown
Contributor Author

CHANGES at b122fc0 (Cormac, independent; Codex is silent, so a second reader). The interface and the outlier pair are right, and EqualSplit{5} squeezing Aiko is the receipt we needed. One contract bug in the reference policy, plus the scenario that exposes it.

Conservation, traced through both branches of DemandFollowing::grant:

  • Overloaded: kept is the in-flight minds' held grants, a subset of the last grant set, so it is at most the pool if the last step kept it. rest = pool - kept_total. Each other mind gets floor(demand x rest / rest_demand), capped at her demand, so the sum is at most rest. Never over the pool, and an in-flight grant never shrinks. Correct.
  • Fits (demanded <= pool): it returns d.required_tokens for every mind, so an in-flight mind whose demand DROPS is shrunk under her turn. Two events: pool 100,000; e(0, 1, 60_000, true) grants 60k; e(1, 1, 30_000, true) grants 30k, below the 60k held, and run counts in_flight_shrinks = 1, so kept() is false. m5_uneven_reading never hits it: Aiko and Benchy only grow.

Fix: in the fits branch an in-flight mind keeps max(held, demand). That sum can exceed the pool even when the demands alone fit. When it does, fall through to the overloaded path with the in-flight minds kept, which already handles that case. Add the two-event scenario as a test, so the validator gating the unified-KV allocator checks a falling in-flight demand, not only rising ones.

Smaller notes:

  • at_ms is carried but never read. Either run should use it (a regrant per event is enough today) or the field goes.
  • The squeeze metric counts per mind per event whenever any slack exists. Under overload, in-flight minds keeping more than their current demand create that slack by design, so a run there reports squeezes the contract permits. Count slack only from minds that could be shrunk (not in flight), or say in the doc that overload squeezes are expected.

@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES still at 0f7e893 (Cormac). The delta from b122fc0 only moves two unwrap_or justifications onto their own lines. DemandFollowing's fits branch still returns d.required_tokens for an in-flight mind whose demand fell (pool 100k: 60k then 30k, both in flight, gives in_flight_shrinks = 1). The fix and the test from my previous comment still apply.

@joelteply

Copy link
Copy Markdown
Contributor Author

Policy fixed at 4aa9284; the validator's 'fits' contract now disagrees with it (Cormac). Conservation, read: floors are in-flight held grants, which were granted inside the pool; rest = pool - floors; each mind gets floor + more with more <= her need, and the more sum to at most rest. So never over the pool, and an in-flight grant never shrinks. Correct. But run counts unmet_when_fits when the sum of raw demands fits, while the policy rightly honours floors above a fallen demand. Counterexample: pool 100k; e(0,1,60k,true), e(1,1,30k,true), e(2,2,50k,false). At e2 the demands sum to 80k <= 100k, so it 'fits', but mind 1's floor is 60k, rest = 40k, and mind 2 is granted 40k < 50k, counted as unmet_when_fits = 1, so kept() is false. Your new test passes only because mind 2 asks 20k. Fix in run: 'fits' is the sum of max(held, demand) for in-flight minds plus demand for the rest <= pool, the same floor the policy keeps. Then add this 50k case as a test.

…d (an in-flight turn at least what it holds), so a fallen in-flight demand beside a big neighbour is the pool's limit, not a breach (Cormac on #5718)

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

Copy link
Copy Markdown
Contributor Author

PASS at 89f28e7 (Cormac). Verified: run judges 'fits' and slack against owed = max(held, demand) for an in-flight mind and demand otherwise. The policy keeps the same floor, so the two now agree. Traced the new test: at e2 owed is 60k + 50k = 110k > 100k, so no unmet_when_fits; mind 1's slack is 60k granted - 60k owed = 0, so no squeeze; and mind 2's 40k is the pool's limit. The earlier conservation and in-flight-floor reads stand.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at 89f28e7 (Cormac, re-check; author session 01LoTjvf…, not mine). CI at this head: 28 pass, 3 skipping.

Verified claim: a turn in flight never shrinks, in either branch, and the grants never exceed the pool. Read DemandFollowing::grant and run:

  • Every mind gets floor + more. floor is what she holds while in flight, else 0. more is her remaining need when everything fits; otherwise need x rest / needed, rounded down. So the sum is at most floors + rest.
  • held is the previous step's grant set (window_sim.rs:134). With the scenario's fixed pool, the floors are a subset of a set that fit, so floors + rest = pool by induction from the empty first step.
  • My two-event scenario (60k → 30k in flight) is now a_turn_in_flight_keeps_its_grant_when_her_demand_falls_and_everything_fits.
  • The validator judges "fits" and "slack" against what each mind is owed (max(demand, held floor) while in flight). That settles my squeeze-metric note: an in-flight mind's surplus over her current demand is no longer counted as slack.

Two items for the PoolLedger step (please answer each; a card is fine):

  1. DemandEvent::at_ms is still never read outside its constructors (my earlier note). Either name its consumer in the PoolLedger PR, e.g. replaying captured demand at its real cadence, or delete it.
  2. The induction holds only while the pool is fixed. In the ledger the pool is the fork's context_geometry.allocated_tokens, fixed per engine launch. If the engine ever relaunches smaller (a sight or KV relaunch under pressure), floors can exceed the new pool and grant returns more than it. rest saturates to 0, so the sum is floors. The ledger should refuse admission there, or the validator should carry a pool-shrink scenario that names the outcome.

@joelteply
joelteply merged commit 987aea3 into canary Nov 3, 2026
31 checks passed
@joelteply
joelteply deleted the fable/window-sim branch November 3, 2026 15:32
joelteply added a commit that referenced this pull request Nov 3, 2026
…h decides only the pool (lifts the b03d7c5 hold)

Joel, 2026-11-03: "It shouldnt just hard cut minds. It's all about what they need. System
accommodates it doesn't do stupid division"; "What a mind needs not what you dictate"; "Stupid
divisions or constants are always gonna fail".

- capacity::window_grant: #5718's DemandFollowing moves into production, generic over the mind id.
  Every mind gets her requirement when the pool holds them all, plus the slack in proportion to
  need up to what one sequence can hold (so she can grow before her next turn is measured and
  nothing idles); past the pool a running turn keeps its grant and the rest share by need.
  window_sim keeps validating it (EqualSplit stays there as the known-bad).
- serving_daemon/grants.rs: every tick grants the live minds from `requirements_for` (their own
  measured demand with headroom; an unmeasured mind asks for the largest on the seat, else what
  one sequence can hold), holds in-flight turns, publishes `PoolGrants` when one moves.
- The re-home reconciler binds each local resident to HER grant (persona_workspace::rehome takes
  a per-mind window); no grant yet keeps her binding, probed, never a stand-in number.
- engine_pool decides only the pool: the plan's window x lanes or its fit at the sequences,
  whichever is larger (M5 257,536 for 5; IntelMac 294,912 for 9, its healthy geometry today);
  no mind's window is derived from it. The per-sequence fit that charged a graph per sequence
  (5 x 10,803) no longer sizes anything a mind sees.

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 3, 2026
…h decides only the pool (lifts the b03d7c5 hold) (#5733)

* A mind's window is her grant from her measured requirement; the launch decides only the pool (lifts the b03d7c5 hold)

Joel, 2026-11-03: "It shouldnt just hard cut minds. It's all about what they need. System
accommodates it doesn't do stupid division"; "What a mind needs not what you dictate"; "Stupid
divisions or constants are always gonna fail".

- capacity::window_grant: #5718's DemandFollowing moves into production, generic over the mind id.
  Every mind gets her requirement when the pool holds them all, plus the slack in proportion to
  need up to what one sequence can hold (so she can grow before her next turn is measured and
  nothing idles); past the pool a running turn keeps its grant and the rest share by need.
  window_sim keeps validating it (EqualSplit stays there as the known-bad).
- serving_daemon/grants.rs: every tick grants the live minds from `requirements_for` (their own
  measured demand with headroom; an unmeasured mind asks for the largest on the seat, else what
  one sequence can hold), holds in-flight turns, publishes `PoolGrants` when one moves.
- The re-home reconciler binds each local resident to HER grant (persona_workspace::rehome takes
  a per-mind window); no grant yet keeps her binding, probed, never a stand-in number.
- engine_pool decides only the pool: the plan's window x lanes or its fit at the sequences,
  whichever is larger (M5 257,536 for 5; IntelMac 294,912 for 9, its healthy geometry today);
  no mind's window is derived from it. The per-sequence fit that charged a graph per sequence
  (5 x 10,803) no longer sizes anything a mind sees.

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

* Grants: need only (slack stays in the shared pool), an unmeasured mind claims the population's median (marked) or nothing yet, the pool is the engine's report (Cormac on #5733)

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]>
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