feat(orchestrator): wire C2 command dispatch through the WS server#49
Merged
feat(orchestrator): wire C2 command dispatch through the WS server#49
Conversation
Completes the wire layer that PR #43 (in-process dispatcher) deliberately deferred. A real driver can now register, receive server-pushed Command envelopes, and ack them — and the dispatcher's submit() resolves end-to-end against a real WebSocket. Protocol additions (backward-compatible): - DriverMessage::CommandAck(CommandAck): driver→orchestrator ack frame - OrchestratorResponse::Command(CommandEnvelope { seq, command }): server-pushed command frame - DriverChannel::send takes a `seq` parameter so the dispatcher's monotonic sequence number flows through to the wire envelope and back via the matching ack. Server changes (server.rs): - DriverServer::with_dispatcher constructor wires an Arc<CommandDispatcher> through to handle_connection. Old `new()` (no dispatcher) preserved for call sites that don't need command dispatch. - handle_connection refactored into a reader/writer pair. The writer multiplexes command envelopes + handshake responses onto the WS sink; the reader handles register/heartbeat/deregister/ack messages and routes acks to per-seq oneshots. - WsDriverChannel: production DriverChannel impl backed by a per- connection mpsc + oneshot pair; populated on Register, dropped on Deregister or disconnect. Tests: - Two new e2e tests (tests/ws_command_e2e.rs) drive a real WS round-trip: one asserts the dispatcher's submit returns acks routed back through the wire; the other asserts the dispatcher's channel is dropped when a driver deregisters. This is the orchestrator-side counterpart to issue #27 (driver-side extension); together they form the full C2 wire path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the wire layer that PR #43 (in-process dispatcher) deliberately deferred. A real driver can now register, receive server-pushed `Command` envelopes, and ack them — and the dispatcher's `submit()` resolves end-to-end against a real WebSocket.
This is the orchestrator-side counterpart to #27 (driver-side `--orchestrator-url` extension); together they form the full C2 wire path.
Protocol additions (backward-compatible)
Server changes
Tests
Two new e2e tests in `tests/ws_command_e2e.rs` drive a real WS round-trip:
Test plan
🤖 Generated with Claude Code