feat(orchestrator): C2 real-time command dispatch#43
Merged
Conversation
Implements component C2 of the orchestrator MVP — domain-neutral command broadcast plane. The dispatcher fans out OrchestratorCommand values (SetPlayers, SetSpawnDelayMs, Stop) from any submitter to every Active driver concurrently, bounded by a configurable wall-clock deadline, and records per-driver acks + missing in an append-only command log keyed by submitter identity. Design notes: - Generic over a DriverChannel trait so production wires per-driver mpsc channels populated by the WS server, while tests inject MockDriverChannel. - Slow drivers don't block the broadcast: fan-out collects acks via mpsc and breaks at the deadline, leaving partial results intact (no all-or- nothing timeout cancellation). - Stale drivers are filtered out at submit time; if no driver is Active the dispatcher returns DispatchError::NoActiveDrivers without logging. - Multiple controllers can submit concurrently; each entry in the log carries the submitter id and a monotonic seq. WS server wiring (driver-side ack push, channel registration on Register) is intentionally a follow-up — keeps this PR's blast radius to the dispatcher logic itself, with mock-driven tests as the spec. Closes #22. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
martinjms
added a commit
that referenced
this pull request
May 2, 2026
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.
Implements #22 — orchestrator component C2 (real-time command dispatch). Makes the `tests/command_dispatch.rs` acceptance tests pass.
What this does
`CommandDispatcher` fans out `OrchestratorCommand` values from any submitter to every `Active` driver concurrently, bounded by a configurable wall-clock deadline, and records per-driver acks + missing in an append-only command log keyed by submitter identity.
What's deliberately out of this PR
Test plan
Acceptance tests covered
All 7 scenarios from issue #22 + 1 wire-fairness test:
Closes #22.
🤖 Generated with Claude Code