Skip to content

fix(admission): the directed reserve is a WAIT guarantee, not a lane count — a card-holder skips the anti-stampede permit, the reserved lane is lent to bounded work, the directed wait rides the health line (card 9a9019b4) - #4250

Merged
joelteply merged 3 commits into
canaryfrom
fix/the-directed-reserve-is-a-wait-guarantee-and-work-is-not-a-stampede
Sep 20, 2026

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The ceiling (M5, first two bounded hours)

resident 4 · lanes 2 @ 67k · lane grants 11 and 11 · acts 6 and 4 · writes 1 and 0. Two lanes, one lane's throughput: the non-directed budget is lanes−1 = 1 (the last lane reserved for a directed call), and a card-holder's work turn woken by room traffic is Ambient attention, so it held the #171 anti-stampede permit (budget 1) and the Work lane inside that same budget — four minds serialized through one lane at 3–6 min a turn while lane two idled for a mention that came once all night.

Cormac's design word, applied as stated

The reserve is a guarantee on the wait a directed call may suffer, in seconds, not a lane count.

  • A card-holder is not a stampede response. service_loop reads her held cards off the board (act_question::card_is_held, the one predicate the work gate also uses) and skips the Revise README to reflect cluttered environment #171 permit for her; LanePriority::Work still bounds her at the lane gate and ambient turns still yield to her. Probe persona.turn.work_holder_bypasses_ambient_permit.
  • The reserved lane is lent to bounded work. reserve_lendable(expected, directed_pending, budget) (pure): only while no directed line is pending for any citizen (directed_pending::any_pending, the re-arm) and only when the call's expected occupancy fits INTERACTIVE_TTFT (60 s). Occupancy = prefill of the prompt she did not have cached last turn at the measured prefill rate + her last output at the measured decode rate (decode_knee::tps_for, lightest trusted point). Unknown = not lent. Probe admission.lane.reserve_lent_to_work.
  • The guarantee in its own unit on the health line: directed wait p50 4s / p90 61s (3 calls), and nothing when no directed call waited.

Honest receipt

A warm work turn on the M5 today costs ~150 s (8k uncached at 105 tok/s + 1,100 tokens at 14 tok/s), past the 60 s budget, so the loan does not fire there yet; the permit bypass is tonight's gain, and the loan pays as card 9a9019b4's cache and prompt levers bring a turn under budget. Later: size the reserve by measured directed demand (Erlang-style).

Tests

the_reserved_lane_is_lent_only_to_bounded_work_while_nothing_directed_is_pending, directed_wait_percentiles_are_nearest_rank, the_lightest_trusted_point_is_one_turns_decode_rate, and the health line pins the directed-wait text and its absence.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…count — a card-holder is not a stampede response, the reserved lane is lent to bounded work while nothing directed is pending, and the directed wait rides the health line

The M5's first two bounded hours (03:39–05:39Z 9/20): resident 4 · lanes 2 @ 67k · lane grants
11 and 11 · acts 6 and 4 · writes 1 and 0. Two lanes, one lane's throughput. Why: the
non-directed budget is lanes−1 = 1, the last lane reserved so a directed call (a human
speaking unnamed, a mention) always finds one; a card-holder's work turn woken by room
traffic is Ambient attention, so it held the #171 anti-stampede permit (budget 1) and the
Work lane inside that same budget of 1 — four minds serialized through one lane at 3–6 min
a turn while the second lane idled for a mention that came once all night.

Cormac's design word, applied as stated: the reserve is a guarantee on the WAIT a directed
call may suffer, in seconds — lanes−1 was the cheapest way to buy it when a turn was 30 s,
and on a 2-lane node at 3–6 min a turn it bought it by idling half the box.

- A card-holder is not a stampede response. `service_loop` reads her held cards off the
  board she keeps (`act_question::card_is_held`, the ONE predicate the work gate also
  uses) and skips the #171 ambient permit for her; the lane gate's `LanePriority::Work`
  still bounds her and ambient turns still yield to her. Probe
  `persona.turn.work_holder_bypasses_ambient_permit`.
- The reserved lane is LENT to bounded work: `reserve_lendable(expected, directed_pending,
  budget)` (pure) — only while no directed line is pending for any citizen here
  (`directed_pending::any_pending`, the re-arm) and only when the call's expected occupancy
  fits inside `INTERACTIVE_TTFT` (60 s). The occupancy is the mind's own bound: prefill
  of the prompt she did not have cached last turn at the box's measured prefill rate
  (`prefill_rate::rate_for`) plus her last output at its measured decode rate
  (`decode_knee::tps_for`, the lightest trusted point). Unknown = not lent. Probe
  `admission.lane.reserve_lent_to_work {expected_ms, budget_ms}`. `acquire_serving_lane`
  takes the bound; Directed and Ambient callers pass None.
- The guarantee is measured in its own unit: `note_directed_lane_wait_ms` at the faculty's
  gate for priority turns, `directed_lane_wait_ms()` as (p50, p90, n), and the health
  line says "directed wait p50 4s / p90 61s (3 calls)" when any directed call waited —
  never a fabricated zero when none did.

Honest receipt on the M5 today: a warm work turn there costs ~150 s (8k uncached at 105
tok/s + 1,100 tokens at 14 tok/s), past the 60 s budget, so the reserve is NOT yet lent
on that box — the permit bypass is the gain tonight, and the loan pays as card 9a9019b4's
cache and prompt levers bring a turn under the budget. Later (Cormac): size the reserve by
measured directed demand, Erlang-style.

Tests: `the_reserved_lane_is_lent_only_to_bounded_work_while_nothing_directed_is_pending`,
`directed_wait_percentiles_are_nearest_rank`, `the_lightest_trusted_point_is_one_turns_
decode_rate`, and the health line pins the directed-wait text and its absence.

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

Copy link
Copy Markdown
Contributor Author

APPROVE with one condition — reviewed at exact head ba181f2 (checks running at read time).

The shape is what I asked for and cleaner than I said it: reserve_lendable pure in the WAIT unit, unknown occupancy lends nothing, any_pending is the re-arm, directed.wait p50/p90 on the health line and never a fabricated zero, the card-holder bypass keyed on the one card_is_held predicate, lightest_trusted_tps as a single turn's decode rate with its own test. On the M5 tonight the bound will refuse to lend (22-35k uncached at ~105 tok/s is 200-330 s against 60 s), which is honest — the lending starts paying when 9a9019b4's cache work lands.

The condition — the loan must never PARK. acquire_serving_lane: when the nondirected try_acquire fails and reserve_lendable says yes, the call returns None for the nondirected permit and then falls into acquire_resized(serving_lanes …).await (resource_admission.rs:882) — the physical semaphore, FIFO. Two-lane node: A (Work) holds the nondirected permit + lane 1; B (Work) is lent lane 2; C (Work) arrives, try_acquire fails, nothing directed pending, lendable → C PARKS on the physical semaphore with no nondirected permit. A directed call D then arrives (any_pending flips true — too late, C's decision is made) and queues BEHIND C on the FIFO: D waits B's remainder + C's whole occupancy, up to 2 × budget, and with two such parked callers, 3 ×. The lend decision is sound only at the instant a physical lane is FREE. So: the lent path takes the reserve with a try_acquire on the physical lanes and returns immediately if it gets one; if no physical lane is free right now, it does NOT lend — it falls back to acquire_nondirected_as_work().await (the queue it always used), so nothing non-directed is ever parked on the physical semaphore ahead of a directed call. Pin it: 2 lanes, A Work + B lent, C Work queued, then D Directed — D gets the next free lane before C (a 250 ms timeout on D after B drops, as the existing reserve test does).

One nit, not a condition: holds_work in the service loop awaits citizen.active_claims() on every ambient turn of every resident before the permit — say in the PR body what that read costs per turn (a projection read is fine; an IPC round-trip per turn is a number Joel's law wants stated).

… by a try-acquire on a physical lane that is free now; no free lane = the ordinary Work wait (Cormac's condition on #4250)

A lent Work call that fell into the FIFO physical acquire would put a later directed
arrival behind its whole occupancy (2× the budget with one parked, 3× with two). Now the
loan is a try_acquire_resized on the physical semaphore; None = no loan, she takes
acquire_nondirected_as_work as before.

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

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head 355a7a1. The condition is taken in the right shape: the loan is a try_acquire_resized on the PHYSICAL semaphore and the lent permit IS the lane; no free lane = no loan = acquire_nondirected_as_work as before, so nothing non-directed can park ahead of a directed arrival. Merge on green. Follow-up, not a condition: the scenario pin (2 lanes, A Work + B lent, C Work, then D Directed; D takes the next free lane before C) is cheap now that the structure makes it pass, and it is the test that catches the next refactor that reintroduces the park.

@joelteply
joelteply merged commit 8104c9a into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/the-directed-reserve-is-a-wait-guarantee-and-work-is-not-a-stampede branch September 20, 2026 08:11
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