feat(fleetnode): carry concurrent commands over the ControlStream#389
Draft
ankitgoswami wants to merge 1 commit into
Draft
feat(fleetnode): carry concurrent commands over the ControlStream#389ankitgoswami wants to merge 1 commit into
ankitgoswami wants to merge 1 commit into
Conversation
Groundwork for routing operator miner commands to fleet-node-paired miners (RFC 0001's remote-node Miner adapter). No behavior change to discovery. - Wrap the ControlStream payload in a typed pairing.v1.AgentCommand envelope so the node can tell command kinds apart; discovery migrates into the `discover` arm. Fields 2 and 3 are left for the upcoming miner-command and pairing arms so the discovery payload is migrated exactly once. - Registry: replace the single-in-flight-command-per-node model with a command_id-keyed map. Report-bearing commands (discovery, later pairing) stream batches + a terminal ack on an events channel; ack-only commands take the terminal ack on a per-command channel via a new blocking SendCommand. The outbound queue is buffered and teardown frees every in-flight command. - Node: replace the single command worker with a bounded worker pool, so a long discovery no longer head-of-line-blocks quick commands; BUSY is acked only at the pool ceiling. handleCommand dispatches on envelope kind. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔐 Codex Security Review
Review SummaryOverall Risk: HIGH Findings[HIGH] ControlCommand payload change breaks mixed-version fleet nodes
[MEDIUM] In-flight command map is unbounded before enqueue succeeds
[MEDIUM] Discovery commands can now saturate the fleet node worker pool
NotesNo cryptostealing, pool hijacking, SQL injection, auth bypass, or frontend XSS issues were evident in the reviewed diff. Generated by Codex Security Review | |
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.
Summary
Groundwork for sending commands to miners paired via fleet nodes. Today the
fleet-node
ControlStreamcarries exactly one thing: server-initiated discovery(#235). This PR generalizes the control plane so it can carry many concurrent
commands per node, which is the prerequisite for routing operator miner commands
(reboot, curtail, …) down a node's stream via RFC 0001's remote-node
Mineradapter (a later PR).
No behavior change to discovery. This is Phase 1 of a 3-phase effort; it ships
no user-visible capability on its own.
What changed
AgentCommandenvelope (proto/pairing/v1): theControlCommand.payloadis now a
pairing.v1.AgentCommandoneof so the node can tell command kinds apart.Discovery migrates into the
discoverarm (done exactly once, on both the adminsend side and the node decode side). Fields
2/3are left for the upcomingminer-command and pairing arms, coordinated with the parallel pairing effort so the
discovery payload is never migrated twice.
internal/domain/fleetnode/control): replaces thesingle-in-flight-command-per-node model with a
command_id-keyed map.Report-bearing commands (discovery, and later pairing) stream batches + a terminal
ack on an
eventschannel and admit device reports against the existing scope/quota;ack-only commands (per-miner commands) take their terminal ack on a per-command
channel via a new blocking
SendCommand. The outbound queue is buffered, and teardownfrees every in-flight command. Channel-ownership invariants are preserved.
cmd/fleetnode/control.go): replaces the single command worker with abounded (16) worker pool, so a long (up to 10-min) discovery no longer
head-of-line-blocks quick commands and many commands run concurrently;
BUSYis ackedonly at the pool ceiling.
handleCommanddispatches on envelope kind.Test plan
go test -race ./internal/domain/fleetnode/control/... ./cmd/fleetnode/...— green.New/updated coverage: many concurrent commands not rejected, ack-routing by kind,
SendCommandblock/disconnect/ctx-cancel/teardown, node worker pool runs a quickcommand while a long discovery is in flight,
BUSYpast the pool ceiling, unknownenvelope kind →
BAD_REQUEST.DiscoverOnFleetNodeintegration suite — green (end-to-end enveloperound-trip through the real handler + registry).
serverbuild,golangci-lint, and pre-pushtsc— clean.Follow-ups (later PRs)
MinerCommandproto + remote-nodeMineradapter +fleet_node_deviceresolution branch + node-side executor (end-to-end for the
virtualdriver).🤖 Generated with Claude Code