Gateway Control Plane: Connect, Authorize, Dispatch, Broadcast
Gateway Control Plane: Connect, Authorize, Dispatch, Broadcast
This chapter focuses on deterministic ingress: how requests enter, get authorized, get routed, and how events flow back.
Minimal verifiable loop
openclaw gateway
openclaw dashboardSee: Protocol and Control UI.
The chain
- Handshake: first frame must be
connect(challenge/auth). - Authorization:
role + scopesdecide whether a method is allowed. - Dispatch: route
req(method, params)to a handler. - Broadcast: push execution progress as
eventstreams (with per-event scope guards).
Practical implementation notes
1) connect must be the first frame
Don’t allow any business methods before the handshake completes.
2) Keep authorize separate from dispatch
Treat these as distinct layers:
- authorization decides whether a method is allowed
- dispatch decides which handler runs it
3) Prefer plugin/extra handlers, then core handlers
If you have extension points, resolve extra/plugin handlers first, then fall back to core. Governance notes: Hooks + plugins governance.
4) Broadcast needs scope guards + slow-consumer protection
Some events must be scoped (approvals/pairing/ops). Also protect the server from connections that can’t keep up.
Minimal frame shapes (for logs/packet captures)
Request:
{ "type": "req", "id": "1", "method": "chat.send", "params": { "text": "hi" } }Response (ACK with runId):
{ "type": "res", "id": "1", "ok": true, "result": { "runId": "r_123" } }Event:
{ "type": "event", "event": "agent.delta", "payload": { "runId": "r_123", "delta": "..." } }Code entry points (optional)
src/gateway/server.impl.tssrc/gateway/server-runtime-state.tssrc/gateway/server/ws-connection/message-handler.tssrc/gateway/server-methods.tssrc/gateway/server-broadcast.ts