Skip to content

fix(device): sweep wedged dispatches, bound the rvt1 hello, and pin the state deny surface (#312) - #324

Merged
turinglambdaai merged 1 commit into
mainfrom
fix/device-gateway-followups-312
Oct 25, 2026
Merged

turinglambdaai merged 1 commit into
mainfrom
fix/device-gateway-followups-312

Conversation

@turinglambdaai

Copy link
Copy Markdown
Owner

Summary

Fixes #312 (all four findings from the #305 pre-merge review).

  1. Hello read deadline — RivetDeviceAppleRVT1Client.start() now bounds the post-authentication hello read with the RVD1 post-TLS deadline policy (rivetDeviceSessionPostTLSTimeout, injectable as helloTimeout:). A watchdog closes the channel on expiry; a generation token makes the deadline one-shot, so a deadline that races a completed hello cannot close a live session.
  2. Typed handshake failures — pre-hello transport/protocol errors now surface as handshakeTimedOut / handshakeFailed(String) on RivetDeviceAppleRVT1ClientError instead of raw channel errors. No exhaustive switches existed outside the client, so the new cases are additive.
  3. Wedged backend capacity — three layers swept:
    • RivetDeviceAppleRVT1GatewayServer: cancelling a request frees its wire slot immediately; each dispatch carries a token so a late completion from a task that ignores cancellation can neither answer a reused id nor resurrect the slot. cancelledIDs is gone.
    • RivetDeviceGatewaySession: cancel now removes the pending entry instead of only flagging it, reclaiming the session's pending capacity even when the host call never completes. Late responses are still suppressed (the vanished-entry rule in cancellationWasRequested), and a cancel racing an in-flight startRPC still cancels the host call.
    • RivetDeviceRVT1BackendHost: cancelRPC drops the work entry.
  4. Deny surface pins — gateway tests now cover $state/set through the ordinary RPC route (denied), both state routes against ungranted names, the write-capability allow path, and an end-to-end $state/set denial through the RVT1 gateway server.

Validation

  • Red-green: appleRVT1GatewayReclaimsCancelledSlotsWhenBackendIgnoresCancellation fails against the pre-fix code with the rejection error frame (verified locally on the untouched sources) and passes with the fix.
  • Full swift test --package-path platform/macos green locally (10 suites, including the 55-test transport suite).

…he state deny surface (#312)

Follow-ups from the #305 gateway review:

- Hello read deadline: the rvt1 client's post-authentication hello read
  carried no budget, so a silent peer held the session forever. It now
  mirrors the rvd1 post-TLS deadline policy (watchdog closes the channel;
  a racing deadline cannot close a session that already holds the hello).
- Typed handshake failures: pre-hello transport and protocol errors
  surface as handshakeTimedOut / handshakeFailed instead of raw channel
  errors.
- Wedged-backend capacity: cancelling a request now frees its wire slot
  immediately and retires the dispatch by token, so a backend task that
  ignores cancellation cannot keep the slot or answer a reused id; the
  gateway session likewise reclaims the pending entry at cancel (its
  vanished-entry rule already suppresses the late response). The backend
  host drops its work entry at cancel too.
- Deny surface: the gateway tests now pin $state/set denial through the
  ordinary RPC route, both state routes against ungranted names, the
  write-capability allow path, and an end-to-end $state/set denial.

Red-green: the capacity-reclaim test fails against the pre-fix server
(rejection error frame) and passes with the fix; the full swift test run
is green.
@turinglambdaai
turinglambdaai merged commit 434c3ab into main Oct 25, 2026
23 checks passed
@turinglambdaai
turinglambdaai deleted the fix/device-gateway-followups-312 branch October 25, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

follow-ups from the RVT1 device gateway review (#305)

1 participant