Skip to content

Admission waits wake on the change that admits them, never on a timer (timer audit H3, H4, H14, H17, H18) - #5991

Merged
joelteply merged 1 commit into
canaryfrom
fable/admission-wakes-on-events
Nov 14, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fable/admission-wakes-on-events

Conversation

@joelteply

@joelteply joelteply commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Why this matters for residents: every act goes through engine admission. This change gets them through it sooner, which serves path step 1 (median act under 60 s) and order-of-work line 3 (one admission owner). It applies RTOS rule 10 from #5986: stages announce what they deliver and dependents subscribe; a timeout only ends a wait as an error. Audit: ~/.continuum/evidence/timer-flow-2026-11-14/inventory.md, section 1.

Converted rows

Row Before After
H3 resource_admission/lanes.rs (the three 1 s arms) released.notified() raced with a fixed 1 s re-check. Waiters wait on released alone and register before they check. It now fires on every change that can admit a waiter: a budget permit returned (BudgetPermit), a ticket given up (ProgressGuard::physical) or granted (try_budget), a budget grant that ages an ambient caller (ProgressGuard::granted), a held-work wait ending (WorkWaiting drop), and a pool that grows (set_served_lane_count).
H4 lane_send.rs (linear backoff) A 503 or refused connection mid-relaunch retried after 1 s, 2 s, … (about 21 s total). Resends on the serving daemon's next live publish after this attempt's POST. Only a publish after the POST counts, because the snapshot lags the process. Bounded by DEFAULT_SERVING_WAIT, the bound the pre-flight guard already uses for a transition. With no daemon nothing will relaunch the lane, so the 503 is classified at once. LANE_RELAUNCH_CONNECT_RETRIES and LANE_RELAUNCH_RETRY_BASE are deleted. The result is typed as RelaunchWait {Resumed, NoOwner, Lapsed}.
H14 training_admission.rs:88 SERVING_BUSY_RETRY, 1 s. await_training_change had no production caller since #5925, which made a memory shortfall end the pass instead of wait. The function, its constant and its test are deleted. TrainingWait::Serving(String) becomes Serving(GateRefusal).
H17 embed_lane_memory.rs:89 sleep(2 s), then retry once. Waits on the LeaseBoard change that makes room. available_for is read outside the watch borrow, because the daemon publishes while holding the governor lock. Bounded by the authority's own cadence().
H18 single_purpose_lane/memory.rs:116 Polled every 5 s for up to 180 s. Re-judged on each MemoryPressureMonitor publish. The kernel adds MemoryPressureMonitor::subscribe_published(); every publish happens after the tick has stored level, gate and free bytes. With no monitor the refusal stands at once. The probe fires when the refusal changes instead of on every tick.

Root cause the H3 arms were hiding: ServingLanePermit::drop called notify_waiters() in its body, and a Drop body runs before the fields drop. Every release therefore woke parked callers while its permits were still held. On a multi-threaded runtime, a caller woken on another worker found nothing free and parked with no further wake coming, so the 1 s arm moved it. Now:

  • the struct's fields are ordered so permits drop first;
  • the budget permit wakes callers from its own last field, after it has returned;
  • the three loops register their Notified before checking (acquire_nondirected_as_ambient and acquire_aged_ambient used to register after).

Skipped rows (verified against source; already compliant with rule 10)

  • H1 admission_clock.rs:198-213: waiting_with_probe already resolves on the acquisition through a biased select, so the grant is the event. The monitor only sets stalled, which is the error path. The evidence it samples, holder-slot progress, is an HTTP /slots read with no in-process event. Waking on grants alone removes no probe and changes nothing.
  • H12 llama_server/progress.rs:427-436: same shape. The work finishing wins at any instant (biased). The timer only paces liveness evidence for an external process: /slots fingerprint plus process CPU, the busy-is-not-dead model in cards 8c06f778 and 6f3218ed. Neither has an event today. The paused-clock tests in turn_admission/tests* and llama_server/tests/progress.rs stay with it.
  • Follow-up for both (proposed, not done): an engine-progress watch fed by the slot print_timing stderr lines the LineWatch already drains. It needs an answer for adopted engines with no stderr, and for save/restore phases that print nothing. Needs a card and an owner.

Tests

Each test has a // what this catches: line, and there is one test mod per file.

  • resource_admission/tests.rs a_release_wakes_parked_callers_only_after_its_budget_permit_is_back: a recording Waker reads the free budget permits at the instant of the wake. It reads 0 on the old code and 1 now.
  • resource_admission/tests.rs a_release_grants_the_parked_caller_at_the_same_instant: paused clock. Parked Work, then Ambient, are each granted with zero virtual time elapsed after the release. On the old code the 1 s arm would show up as 1 s.
  • openai_adapter/tests/lane_transport.rs a_relaunch_refusal_resends_on_the_live_publish_and_never_on_a_timer:
    • after a 503, a not-live publish does not resend;
    • the live publish resends at once;
    • with no daemon, the 503 is sent once and classified.
    • The two existing 503-retry tests now publish the relaunch from their fixture.
  • embed_lane_memory.rs a_refused_embed_lease_is_granted_by_the_release_that_makes_room: paused clock; zero elapsed between the release and the grant.
  • seat/tests.rs now follows the production shape: wait for the authority to publish room, then make one new seat attempt.

Test seam: lane_send::publish_serving_for_test, a cfg(test) thread-local stand-in for the serving daemon's snapshots. Without it, tests would read whichever process-global SERVING_STATE another test installed.

Lines

Added Removed
Whole diff 530 202
Tests (in the whole diff) 217 48
Production 313, mostly design comments, the RelaunchWait enum and the test seam 154

Deleted: 5 timer arms or sleeps, 3 constants, 1 dead public function and its test.

Ratchets:

  • swallowed_errors: the removed let _ = timeout(...) is not replaced by any new one.
  • unwrap_justification: no new unwrap or expect in production.
  • file_size: every touched file is under 1,000 lines.

Verification

Not compiled locally: this machine serves live minds, so CI is the compiler.

Measured

Nothing is measured yet. This needs a deploy, and the receipt below is still owed (card open until posted).

  • Admission wait: p50/p90 waited_ms of admission.lane.granted (and lane_tally) over 1 h at 4 residents, before vs after. The prediction is that the 1 s-quantized tail disappears; that is a hypothesis.
  • Median act over the same window.
  • Relaunch receipts: inference.lane_relaunch_retry waited_ms and the count of lane-down act failures.
  • Owner: whoever deploys this to the M5. Read 15 minutes against canary as rule 3 requires; if worse, back to canary.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… (timer audit H3, H4, H14, H17, H18)

H3 lanes: parked non-directed callers wait on `released` alone. It now fires after
every change that can admit (budget permit back, ticket given up or granted, budget
grant aging an ambient caller, held-work wait ending, grown pool), and the release's
wake fires after its permits return (it ran in the permit's Drop body, before the
fields dropped: the missed wake the three 1 s arms hid). Arms deleted.
H4 lane_send: a 503/refused POST mid-relaunch resends on the serving daemon's next
live publish after the POST, bounded by DEFAULT_SERVING_WAIT; linear backoff and its
two constants deleted.
H14 training_admission: await_training_change and SERVING_BUSY_RETRY deleted (no
production caller since #5925); TrainingWait::Serving carries the typed GateRefusal.
H17 embed lease: the retry waits on the LeaseBoard change that makes room, bounded
by the authority's own tick, instead of a fixed 2 s sleep.
H18 lane memory headroom: re-judged on each MemoryPressureMonitor publish
(subscribe_published) instead of a 5 s poll.

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

Copy link
Copy Markdown
Contributor Author

Review finding at c240a9c: H17 in embed_lane_memory.rs still advances work on elapsed time. timeout(bound, room).await.is_ok() is stored only for the probe, then attempt(1)? runs for both publication and timeout. The comment explicitly says either way the second attempt decides. A nominal daemon cadence does not prove a tick ran or pressure relief completed under load.

Please make the wait resolve to an explicit owner-published capacity/terminal outcome and retry only on the appropriate result. Closed publisher must be distinguishable from room available; currently room returns () on both and labels closure as published=true. Add deterministic coverage for authority closure and a stalled/nonpublishing authority, alongside the release case. This is a blocking finding for this slice, not a request to remove custody/error handling.

The storage page API is now grouped borrowed BinaryPageRequest + borrowed output views, with required NonZeroUsize size. I agree with rule11's contract direction; an explicit transfer of native buffer custody to a detached owner still needs ownership semantics rather than hiding a clone behind a borrowed signature.

@joelteply
joelteply merged commit 797c6ae into canary Nov 14, 2026
37 checks passed
@joelteply
joelteply deleted the fable/admission-wakes-on-events branch November 14, 2026 02:22
joelteply added a commit that referenced this pull request Nov 14, 2026
…e ratchets

Rule 10/11 text: canary's #5986 wording kept, plus the shape-ratchet section, its
baselines and the correction that time_bounds and wall_clock never counted sleeps.

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 14, 2026
…mer (Codex on #5991) (#5995)

* A refused embed lease waits on the authority's own answer: room published or the authority closed, never a timer (Codex on #5991)

The H17 wait from #5991 ran the second attempt when one daemon cadence expired, and read
the authority's closure as "published". It now resolves to a typed RoomOutcome from the
owner: Published { available } (the only outcome a retry runs on) or AuthorityClosed (a
terminal refusal). No timeout remains; a silent or still-short authority keeps the wait
pending for the caller's own bound to end. Deterministic test covers closure, silence
across an hour of paused clock, a short publication, and the publication with room.

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

* The release test waits for the authority's first tick before it leases, so its next publication is the release

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

* The release test's authority ticks once a day, so no tick answers the waiting lease before the release does

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

* A refused embed lease marks the authority's board seen when it subscribes, so only a later publication answers it

ResourceDaemon::subscribe hands out a clone of the channel's stored receiver, whose seen
version is the channel's start: changed() returned at once and the wait answered StillShort
from a board older than the refusal.

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