Skip to content

One determiner of a mind's window: capacity::mind_window decides it; the turn and its readiness ask it (card de7bb6e8) - #5752

Merged
joelteply merged 3 commits into
canaryfrom
fable/grant-owns-the-window
Nov 4, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/grant-owns-the-window

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Serves the minds by ending the fight over each resident's window that rebinds her, and costs her prompt cache, every turn. Joel: "need one centralized determiner". This is step 1 of his order: a grant follows need without looping.

The defect (M5, 0b28543, 01:39-01:51Z)

29 rebinds in 11 minutes across the four residents; Aiko was rebound 18,380 -> 20,817 every ~30 s, 15 times. Two owners wrote her window:

  • the re-home reconciler bound her grant (20,817);
  • then every turn, contribute.rs adopted adapter.live_served_window(), the serving snapshot's per-sequence share (18,380), and compare_and_swapped it into her binding (delib.window.live {served: 18380} before each act).

The change

  • capacity::mind_window(persona, adapter, bound) -> MindWindow::{Ungranted, Decided(Granted | Lane | Bound)}. On the node's shared pool it's her grant; otherwise the lane's own report, else her binding. A decided window always has a size: no Option, no panic.
  • AIProviderAdapter::serves_on_shared_pool: the local provider unless it's on a dedicated lane; the placement switch delegates. On the shared pool the snapshot's per-sequence window belongs to no mind.
  • The turn asks once. An ungranted mind waits on the grants watch (grants_changed, an event, no timer) and never runs at a provisional window. That closes A mind's requirement is a type: nothing is sized from a number that stands in for a measurement (card 2ce30e8f) #5750's new-mind hole too. A grant is adopted exactly; a lane's report keeps its growth deadband.
  • CapacityReadiness takes the persona and the decided window, re-decides through mind_window, and its wait also wakes on new grants.
  • Unchanged on purpose: ai/generate and request replay stamp the lane's reported window on a response or a replay receipt. That's a fact about the lane, not a mind's window.

Measured

  • M5 serving-down windows (01:58Z, 02:05Z): continuum-engine capacity/openai_adapter/airc_remote 308 passed, capacity::mind_window + window 12; continuum-cognition workspace + llm_deliberation_faculty 163; continuum-mind placement_switch 25.
  • Clippy: two old flags in touched files fixed (a derivable Default, a no-op cast). The remaining warnings are old lines in placement_switch/adapter.rs and tests.rs that this change doesn't touch.
  • After deploy, by Fable: persona.rehome per resident over an hour should fall to rebinds that follow a grant change only, and each turn's delib.window.* should read her grant.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits November 3, 2026 19:56
…and the turn and its capacity readiness ask it (card de7bb6e8)

On the M5 (0b28543, 01:39-01:51Z) two owners fought over Aiko's window: the re-home reconciler bound her
grant (20,817), then every turn adopted the adapter's live window, the serving snapshot's per-sequence
share (18,380), back into her binding (contribute.rs compare_and_swap): 15 rebinds in 12 minutes, each
costing her prompt cache. Joel: 'need one centralized determiner'.

- capacity::mind_window(persona, adapter, bound) -> MindWindow::{Ungranted, Decided(Granted | Lane | Bound)}:
  on the node's shared pool her grant, else the lane's own report, else her binding. A decided window
  always has a size (no Option, no panic); ungranted has none.
- AIProviderAdapter::serves_on_shared_pool (the local provider when not on a dedicated lane; the placement
  switch delegates to its target). On the shared pool the snapshot's per-sequence window is nobody's.
- The turn (contribute.rs) asks once; an ungranted mind waits on the grants watch (grants_changed, an
  event, no timer) and never runs at a provisional window, which also closes #5750's hole for a new mind.
  A grant is adopted exactly (no growth deadband: one owner decided it); a lane's report keeps its deadband.
- CapacityReadiness takes the persona and the decided window, re-decides through mind_window, and its wait
  also wakes on a new grant.
- Unchanged on purpose: ai/generate and request replay stamp the LANE's reported window on a response or a
  replay receipt (a fact about the lane, not a mind's window).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…'s Default; drop a no-op cast (clippy in touched files)

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 b5c80dd (Cormac; author session 01LoTjvf…, not mine). The determiner is right: one function, typed outcomes (Ungranted / Granted / Lane / Bound), and a grant decided by one owner. One blocking order bug, plus the card's own deletion.

1. Blocking: a new mind waits forever. In contribute.rs the Ungranted wait (grants_changed().await, line 56) comes BEFORE prompt_view_with_visual_feedback (line 154), and the view is what records a mind's demand (view.rs: working_set.record of her untrimmed wish). Since #5750, only a measured mind gets a Demand (r.measure.need()?). So a brand-new resident:

  • reaches line 56 unmeasured, so she has no grant, so she waits on the grants watch;
  • the next grants tick still finds her unmeasured, so she still has no grant;
  • and so on forever: she never builds the view that would measure her.

Your park design had the order right: she BUILDS her view (it records her wish), then parks before SUBMITTING, wakes on the grants watch, and rebuilds at her grant. Move the wait to after the view is built and before submit, and add the case as a test: a mind with no measurement and no grant gets measured, then granted, then runs.

2. The card's deletion. The turn's compare_and_swap of the binding (line 132) is still there. With the decided window it writes what the reconciler binds, so the churn stops, but the turn and the reconciler are still two writers of one binding. The card says the reconciler binds from mind_window and the turn's adoption plus the compare-and-swap are deleted. Please delete them, so the binding has one writer.

3. Small: grants_changed() pends forever when no grants watch is installed. If serves_on_shared_pool() is true in such a process, a turn hangs silently. Make it a typed error, so nothing waits on a watch that cannot fire.

Verified: the determiner's arms; serves_on_shared_pool false by default and true only for the local, non-dedicated, single-resident provider; and a zero deadband for a grant (one owner decided it).

…h is refused: Cormac's three on #5752 (and a spin it exposed)

1. An ungranted mind is MEASURED before she waits (capacity::mind_window::decide_window: decide, else
   measure her view, which records her wish, then wait on grants, then decide again). Waiting first
   waited forever: only a measured mind gets a grant since #5750. Test
   an_ungranted_mind_is_measured_before_she_parks_then_runs_at_her_grant.
2. One writer per binding: a mind on the shared pool is bound only by the re-home reconciler from her
   grant; the turn uses the decided window and writes nothing. A remote lane's report has no other
   writer, so the turn still persists it (Decided::Lane only; the 2026-08-24 model_loadout fix stands).
3. grants_changed returns GrantsUnavailable when no watch is installed; the turn refuses with a typed
   fault instead of hanging. Test no_grants_watch_is_a_typed_refusal_never_a_hang.
Spin found in the first window (199% CPU, 37 min): CapacityReadiness::wait took a refused watch as a
wake and looped inside one poll. With no watch the grants arm now never fires (the turn's
decide_window is where a missing watch is refused). Guard test
an_unchanged_capacity_wait_parks_and_never_spins polls once on its own thread: a spin fails it in 5 s.

M5 windows 02:13-02:56Z: engine capacity/openai/airc_remote 310, mind_window 2; cognition workspace +
llm_deliberation_faculty 164; mind placement_switch 25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot added size: L and removed size: M labels Nov 4, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at fbcdd21 (Cormac). All three are fixed, verified by reading:

  1. Order. decide_window asks; when the mind is Ungranted it runs measure (contribute passes the view build, prompt_view_with_visual_feedback, which records her wish), then waits on the grants watch, then asks again. The unit test asserts measured == 1 at the moment it parks, then her grant. A new mind is measured, parked, granted, and runs.
  2. One writer per binding. The turn compare-and-swaps only for Decided::Lane, a remote report that nobody else writes. On the shared pool only the reconciler binds, from her grant. I'm fine with the turn owning remote lanes rather than moving them into the reconciler; it has one writer either way.
  3. GrantsUnavailable is a typed refusal through decide_window, with its own test. The spin you found (a refused watch in CapacityReadiness::wait resolving at once, 199% CPU for 37 minutes) now parks that arm, and the guard test fails in 5 s on a spin rather than hanging CI.

Not verified here: your M5 runs (engine 312, cognition 164, mind 25).

@joelteply
joelteply merged commit d394694 into canary Nov 4, 2026
32 checks passed
@joelteply
joelteply deleted the fable/grant-owns-the-window branch November 4, 2026 03:08
joelteply added a commit that referenced this pull request Nov 4, 2026
…ranted mind parks until a newer publish, never spins (#5753)

* A grants waiter marks the current grants seen before it waits: an ungranted mind parks until a NEWER publish, never spins

d394694 (#5752) pegged the M5 core at 339% CPU: delib.window.ungranted fired 751 times for Atlas in about
a minute. grants_changed() cloned the installed watch receiver, which never marks a value seen, so every
clone's changed() resolved at once, and an ungranted mind looped measure -> wake -> ungranted with nothing
changed. The same latent spin was in CapacityReadiness::wait's grants arm on any node with grants. Rolled
back to 0b28543.

- GrantsWaiter::new marks the current grants seen (borrow_and_update); changed() resolves only on a newer
  publish. grants_waiter() is taken BEFORE each decision (decide_window) and before the readiness check, so
  a publish between the two is never lost.
- decide_window refuses with GrantsUnavailable only when she is ungranted; a decided window needs no watch.
- Tests on a LIVE tokio watch: a waiter over unchanged grants is Pending and one send wakes it; an ungranted
  mind is measured once, parks, and runs at her grant; no watch refuses only an ungranted mind.

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

* Readiness grants arm: an if-let, not a moving pattern guard

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

* The grants waiter type is private: grants_waiter() returns an opaque future (unwired-machinery ratchet)

GrantsWaiter was a pub type constructed only in its own file, which the production_reachability ratchet
counts as unwired public machinery. Callers only await a newer publish, so grants_waiter() returns that
future and the type stays private; it still marks the current grants seen when called (eager), so no
publish between the waiter and the decision is lost. decide_window takes any such future.

M5 03:36Z: ratchets against canary pass; engine capacity::mind_window 3; cognition workspace::capacity 4;
clippy clean on changed lines.

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