Skip to content

Outbound agents: machines connect to the hub, no inbound SSH on machines - #3

Merged
skmp merged 4 commits into
mainfrom
skmp/outbound-agents
Nov 26, 2026
Merged

skmp merged 4 commits into
mainfrom
skmp/outbound-agents

Conversation

@skmp

@skmp skmp commented Nov 26, 2026

Copy link
Copy Markdown
Member

Machines (a WSL box behind NAT, LAN machines) now connect OUT to the hub instead of the hub SSHing into them.

  • Machine: switchboard-remote --serve speaks newline-delimited JSON on stdio and runs the same verbs with the same validation; the policy (sessions, usage, send, permission answers) comes only from the machine's own command line. switchboard-connect runs ssh -T to a relay user on the hub (pinned hub host key, dedicated key, no forwarding, no agent), with capped, jittered reconnects; systemd --user unit example.
  • Hub: the relay user's authorized_keys line forces voice_coding_mcp.remote.relay --machine <name>: identity comes only from which key connected. The relay talks to the service through a Unix socket in a 2750 vcm:sbrelay directory (SO_PEERCRED checked). Newest connection wins; in-flight sends on a replaced connection are never retried. Frame caps, 4 requests in flight, heartbeats, bounded writes.
  • Config: machine transport agent; every remote tool works over it (list, status, pending_input, send/keys/resize with the two-step confirmation, usage, watcher). Offline: "carbi is not connected right now". status / remote-check show connected machines, since when, dispatcher version, peer.
  • Threat model: no inbound port or hub key on machines; machines decide when they are reachable; works behind NAT. A compromised hub can still call exactly the allowed verbs (unchanged); a lying machine can fake its own responses (audit outcomes rest on its word).
  • Docs: SETUP for agent mode, migration from the ssh transport, REFERENCE keys, SWITCHBOARD.md design and threat rows.

Reviews: security + correctness (end-to-end with the real connector, relay, hub and dispatcher on an isolated tmux server: 29/30 checks, the one miss was the reviewer's own assertion). Gate: pytest 1773 passed, 9 skipped; ruff, format and mypy --strict clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh

skmp and others added 4 commits November 26, 2026 21:48
M6 design: dispatcher serve mode over newline-delimited JSON frames, the
switchboard-connect connector with a pinned hub host key and capped
jittered backoff, the sbrelay relay account whose per-key forced command
names the machine, the 2750 vcm:sbrelay socket directory with an
SO_PEERCRED check, newest-connection-wins replacement, heartbeats and
timeouts, the agent transport config, status and remote-check through a
control socket, setup and migration outline, threat model rows and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
Machines behind NAT (a WSL box, laptops, LAN machines) can now connect
out to the hub instead of the hub SSHing into them (transport "agent").

- Dispatcher 0.6.0: --serve, newline-delimited JSON frames on stdin and
  stdout; every request runs through the same run_request as a forced
  command, so validation and refusals are identical; the policy comes
  only from the machine's own argv; refused under sshd; size limits,
  busy, duplicate ids, cancel of usage streams, one-at-a-time sends,
  heartbeat answers, exit codes 0/75/76.
- switchboard-connect (stdlib, byte-identical in remote/connector.py):
  hardened ssh (pinned host key under HostKeyAlias=switchboard-hub, no
  agent, no forwarding, -F /dev/null) cross-wired with the dispatcher,
  capped jittered backoff, long waits after replaced/refused/auth/
  host_key, per-user lock, example systemd --user unit.
- Relay (stdlib, forced command of the dedicated sbrelay account): the
  machine name only from --machine of the per-key command=, socket
  ownership checks, 5 MiB frame cap, fixed stderr lines; agent-relay CLI.
- Hub: AgentHub on a 2750 vcm:sbrelay socket directory with SO_PEERCRED,
  strict preamble/hello, one live connection per machine (newer replaces
  older, read verbs retried once, sends unknown), heartbeats,
  AgentTransport for every tool, control socket for status and
  remote-check, authorized_keys lint, "laptop is not connected right now".
- Config remote.agents and transport agent; deploy/relay files, hub units
  ReadWritePaths, opt-in VCM_AGENT_RELAY in setup.sh.
- Docs: SETUP-AGENTS.md guide, REFERENCE, DESIGN, SWITCHBOARD (M6
  implemented with deviations); tests for serve mode (forced-mode parity
  corpus), relay, hub, every tool over the real chain, connector with a
  fake ssh, config and deploy files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er-only relay hub

- AgentConnection.send waits at most 5 s (WRITE_STALL_SECONDS) for the write
  lock and the drain; a machine that stops reading its channel is closed as
  write_stalled (aborted, not flushed), so pending calls end as disconnected.
  The heartbeat's ping uses the same bounded write; the cancel after a
  deadline (and after an oversize answer) goes out in the background, so the
  caller gets its timeout at the deadline.
- At most 2 unfinished handshakes per machine, so one machine key cannot hold
  every connection slot.
- The relay socket is bound, chmod-ed, then listened on; the process umask is
  no longer changed.
- busy from the dispatcher is spoken "it is busy, try again in a moment".
- The connector gives the dispatcher 1 s to exit after ssh ends, so a bye
  forwarded just before the relay exits keeps its exit code (75/76).
- voice-coding-mcp usage does not read agent machines (only the hub holds
  their connections): cached records with a note, not counted toward exit 1.
- Docs: the hub side of agent mode needs the server layout (the WSL hub's venv
  is in a mode 700 home and its sshd is loopback only); the WSL unit no longer
  claims the relay directory. setup.sh and the guide set sbrelay's password
  field to '*'; restart-after-directory, AcceptEnv check, troubleshooting rows;
  threat-model row for stuck connections rewritten with what is left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skmp
skmp merged commit e711606 into main Nov 26, 2026
2 of 4 checks passed
@skmp
skmp deleted the skmp/outbound-agents branch November 26, 2026 21:08
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.

1 participant