Expand description
The request engine (spec §4.3/§4.4/§4.7/§5): the ordered pipeline every tool call runs through.
Returns either a worker result Value (plus a snapshot of the active canonicalizer for the caller
to canonicalize addresses) or a structured ErrorEnvelope.
Structs§
- Booting
Reset 🔒Guard - RAII guard resetting a
Bootingslot back toEmptyif a respawn future is dropped before reaching a terminal state (R5 cancellation-safety). Drop cannot await, so it uses a synctry_lock; on contention it detaches a cleanup task. Idempotent: only resets if the slot is stillBooting.
Enums§
- RpcOutcome 🔒
- Slot
Kind 🔒 - Copyable classification of the worker slot, so a caller can inspect state and THEN take a
&mutborrow without an overlapping-borrow error (R2 seat-D).
Functions§
- attach_
program - Attach a program. The active-program + canon commit happens ATOMICALLY inside the engine under the
worker lock (via
commit_attach_if_needed) — NOT here (R2 seat-C). This wrapper only supplies the poison-key selector and runs the same crash/respawn engine (§4.3). - call_
worker - Run one tool call.
selectoris the poison/short-circuit key component (e.g. thefunctionarg, or theprogram_path); pass""for selector-less calls. Returns(result_value, canon_snapshot). - commit_
attach_ 🔒if_ needed - If the just-succeeded call was
attach_program, commit the new active program + canonicalizer into the holder WHILE THE SLOT LOCK IS STILL HELD (R2 seat-C atomicity). A parse failure leaves the prior attachment intact. - current_
canon - Snapshot the active canonicalizer (for canonicalizing an error-path candidate list).
- poison_
terminal 🔒 - Terminal “reproducible crash” error (spec §4.3 poison-pill).
- publish_
ready 🔒 - Publish a freshly-booted worker into the slot (from
Booting) and wake warming waiters. Disarms the cancellation guard INSIDE the lock, after the write (R6 seat-P). - reset_
booting_ 🔒to_ empty - Reset a
Bootingslot back toEmpty(retryable) after a failed respawn; wake warming waiters. Only resets if stillBooting. Disarms the guard INSIDE the lock, after the write (R6 seat-P). - respawn_
and_ 🔒retry - Reboot a fresh worker (OUTSIDE the lock; slot is
Bootingso concurrent callers get WORKER_WARMING), re-attach last good, and retry ONCE before publishing. A second crash poisons the selector. - rpc_
once 🔒 - One RPC with poison-on-drop (§4.4) + rpc_deadline (§4.7). A transport error OR a deadline overrun is
a crash (respawn); a worker
Failureframe is a domain error (worker alive). - run_
with_ 🔒respawn - Acquire the worker mutex and run the RPC. On a transport crash, respawn OUTSIDE the lock (R3 seat-G) and retry once; a second crash on the same request poisons the selector (§4.3). Attach state commits atomically under the lock (R2 seat-C).
- server_
busy 🔒 - slot_
kind 🔒 - wait_
until_ 🔒ready - Wait until the worker slot is
Ready, kicking a single-flight background boot ifEmpty. Waits up towarming_deadline(in ≤250 ms slices, woken early byboot_done); a boot longer than the budget returnsWORKER_WARMING. Holds the slot lock only for the instantaneous state checks, never across the wait, and never while holding a permit (R2 seat-A). - worker_
warming 🔒