Repository navigation
Description
Blocked by #4279
Context
Part of #4278.
Since #3726, a governed turn's inference admission first waits for every egress record the turn has submitted so far to commit, then for the session binding (settleOperation, packages/ui-server/src/brain/turn-egress.ts:286-300; settled, :248). The relay admits twice per request (operation.admit(), packages/ui-sdk/src/server/inference-relay.ts:125-129 and :191-194), so the join runs twice. The records commit on the single write worker with full durability, measured at 35 to 85 ms per commit on a hosted install.
Today this is harmless: after a tool result the worker is stopped for 0.3 to 2 s before it can send the next request (see #4292), which gives the write queue time to drain. The relay's span did not rise at the release that introduced the join.
It stops being harmless the moment the hold moves. With the next request arriving about 10 ms after a tool result, the previous response's record and the tool's own bookkeeping are still queued, and the request waits for them inside the relay's span. Part of whatever the deferred freeze saves would reappear there.
Scope
- Measure the join with the marks from ui-sdk: the inference relay records one duration per request, so host time cannot be told from the provider's time to first byte #4279:
admitMsand the interval fromcredentialMstodispatchMs, on turns with back-to-back tool calls, with the hold in place and with it removed in a fixture. - If the join costs more than a few milliseconds without the hold: make inference admission wait only for what it depends on. The comment at
turn-egress.ts:288-291names the purpose (a concurrent session binding must not change a healthy scope under its first admission). Records that cannot change the admission's outcome need not be joined. - If it does not, record the numbers and close this as a documented no.
Out of scope
- The durability level of egress records.
- Admission for non-inference egress, where a pending taint record must be in force first (Epic: nothing on the hosted server's event loop waits for a ui.db fsync #2850).
Acceptance criteria
- The PR reports
admitMsfor requests that follow a tool result by 10 ms, 50 ms and 500 ms on the native fixture, with the write queue loaded as a tool call loads it. - If the join is narrowed: a test shows inference admission still refuses when the session binding is unavailable and still sees a taint or a recording failure submitted before it; a mutation that drops the binding wait fails that test.
- If it is not narrowed: the measured cost and the reason are recorded on this issue.
- A test covering any change fails on the tree before the change and passes after.
Verification
bun run test packages/ui-server/tests packages/ui-sdk/tests
bun scripts/prove-native-host.ts --backend=claude --observation-timingContract impact
None.
2026-11-20 triage at main 63bb400b3. The two admission fences and the session binding are independent checks. Keep both fences and attribute the two joins separately in the fixture. The interval before dispatch also includes header charging and commit. The timing prerequisite is #4279. A throwaway fixture can vary the post-tool hold while #4292 is open.
Activity