Expand description
The operator command-channel client: JSON-lines over a Unix domain socket (ADR-051 D6;).
degenbot fleet posture [show|set] and degenbot path [add|discover] are
clients of a LIVE bot’s OperatorServer. The versioned wire protocol is
documented in src/degenbot/operator/operator_channel.py; that header +
the server’s framing are read-only contract and this module must not drift
from them.
§Wire shape (one JSON object per line, newline-terminated)
Request lines nest the payload at the top level (the exact shape Python’s
send_command writes and the server’s _decode_request reads):
{"op": "add_path", "payload": {"steps": [...], "directions": [true]}}
{"op": "discover", "payload": {"bound": 5}}
{"op": "set_fleet_posture", "payload": {"cordon_enter_events": 2}}
{"op": "get_fleet_posture", "payload": {}}Response lines:
{"ok": true, "detail": "..."}
{"ok": true, "detail": "", "effective": {...}}
{"ok": false, "error": "..."}§Division of validation
This client adds wire hygiene only - an unknown cordon_* key, an empty
posture patch, an unknown hop-family string - refused BEFORE the socket is
touched by validate_posture_patch / parse_hop_token. The six cordon
values are DOMAIN validation and stay the authority of the server
(PosturePolicyPatch::validate in the workers core); this crate deliberately
does not import or re-implement it, so a client built earlier never second-
guesses a host built later.
§Socket resolution
--socket > DEGENBOT_OPERATOR_SOCKET (the shell-environment layer, read
through the degenbot-config EnvVars seam) > ~/.config/degenbot/operator.sock
(the example driver’s plug-in default). No typed config-file key exists for
the operator socket, so the env layer is the only config surface; a future
typed key would slot in above the env layer at exactly one site.
Structs§
- Path
Step - One hop in an
add_pathstepsarray. - Posture
Patch Entry - One
cordon_*entry in a partial posture patch.
Enums§
- Path
Direction - A
--directionchoice: one bit applied to every hop. - Path
Family - A pool family on the wire (
V2/V3/V4). - Posture
Patch Value - A
set_fleet_posturethreshold value. - Wire
Request - The four ops the live host serves, encoded as one request line.
- Wire
Response - A decoded response frame.
Constants§
- FLEET_
POSTURE_ THRESHOLD_ KEYS - The six fleet-posture threshold key names
set_fleet_postureaccepts (the typedDEGENBOT_FLEET_CORDON_*keys). Anything else is refused at the wire before it reaches the host. - SIM_
INTAKE_ FLOOR_ RESTORE - The documented sentinel for
--cordon-sim-intake-floor: the literalnull(case-insensitive) restores half the slot cap; any other value is a threshold. The host’sPosturePolicyPatchcarries this as theSome(None)override. - SOCKET_
DEFAULT - The plug-in default socket path (the settlement-bot example’s
--operator-socketdefault family). The leading~expands againstHOME. - SOCKET_
ENV - The environment variable naming the live bot’s operator socket (the shell layer of the cascade). Empty is treated exactly like unset.
Functions§
- decode_
response - Decode one response line. A malformed/non-object/missing-
okframe is a protocol error; a well-formed{"ok": false, ...}frame (including the host’s unknown-op reply) isWireResponse::Err, never a panic. - parse_
hop_ token - Parse one
FAMILY:ADDRESS[:HASH]hop token into a wirePathStep(mirrors_parse_hop). Family is case-insensitive; the V4 hash is carried only for V4 and only when non-empty. - parse_
sim_ intake_ floor - Parse the
cordon_sim_intake_floorflag text: the literalnull(case-insensitive) is the documented restore sentinel (SIM_INTAKE_FLOOR_RESTORE), anything else must be an unsigned integer. - render_
json_ sorted - Render an
effectiveobject as one compact JSON object with its top-level keys sorted - the Python CLI’sjson.dumps(effective, sort_keys=True).Nonerenders{}(the Pythonresponse.get("effective", {})default). - resolve_
socket - Resolve the operator socket:
--socket>DEGENBOT_OPERATOR_SOCKET>~/.config/degenbot/operator.sock. The winning value has a leading~expanded againstHOMEthrough the env seam. - send_
request - Send one request to the operator host and decode its single response line.
- validate_
posture_ patch - Client-side wire hygiene for a posture patch: no unknown
cordon_*key and no empty patch. Mirrors the host’shandle_fleet_posture_opguard messages; the host’s typedPosturePolicyPatch::validateremains the value authority.