feat(connection): enforce gateway protocol compatibility - #1127
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 8:26 PM ET / August 19, 2026, 00:26 UTC. ClawSweeper reviewWhat this changesThe PR validates Gateway wire-protocol compatibility during operator and node handshakes, presents directed recovery states, exposes them through local MCP diagnostics, and adds regression coverage. Merge readinessKeep open pending maintainer confirmation that terminal enforcement of the v3-v4 Gateway support window is the intended upgrade policy; current main records the handshake protocol but does not branch on it. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe Windows tray and node clients connect to a Gateway over a WebSocket handshake, then publish connection state to the tray UI and local MCP diagnostics. This change validates the protocol before success, token persistence, and reconnect behavior. flowchart LR
A[Gateway handshake] --> B[Protocol validation]
B --> C{Compatible?}
C -->|Yes| D[Connected state and token handoff]
C -->|No| E[Terminal compatibility state]
E --> F[Tray recovery guidance]
E --> G[Local MCP diagnostics]
D --> H[Node and operator services]
Decision needed
Why: This is an intentional upgrade-policy change: it replaces prior diagnostic-only handling with a non-retrying connection failure for existing deployments outside the declared support contract. Before merge
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Confirm the documented v3-v4 support policy, retain the shared validation boundary and directed recovery, then land only after the current-head Gateway and test jobs finish successfully. Do we have a high-confidence way to reproduce the issue? Not applicable as a feature review. Current-main source confirms the prior behavior only recorded hello-ok protocol metadata, while the PR supplies a concrete WSL-stub and local-MCP validation path for the new behavior. Is this the best way to solve the issue? Yes, subject to maintainer approval of the strict support window. A shared handshake contract is the narrowest maintainable place to keep operator and node behavior aligned. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b37307cbd51f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (20 earlier review cycles; latest 8 shown)
|
c493b00 to
f63e7a2
Compare
f63e7a2 to
6e09cea
Compare
f9ca1c2 to
775f044
Compare
775f044 to
9f55849
Compare
6b6b875 to
9f55849
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3e9101e4-2a42-47ea-97c4-b60603f4e45f
Avoid a redundant node compatibility snapshot rebuild while preserving the paired transition. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3e9101e4-2a42-47ea-97c4-b60603f4e45f
9f55849 to
4ed1464
Compare
Related: #1105
Note
This compatibility delta was restacked onto current
mainafter #1095, #1101, and #1105 merged. The current reviewed head is4ed146409f5472a77a1c275065cbd39f32ae4951.What Problem This Solves
An incompatible Gateway could previously look like a generic connection failure or progress far enough to break Windows-node behavior without telling the operator which component needed updating.
Why This Change Was Made
The Windows operator and node clients now share the documented Gateway wire protocol v3-v4 range and validate the minimal
hello-okshape before publishing connection success or persisting handshake tokens. Successful integer protocol values at or above the client floor remain forward-compatible after the Gateway accepts the advertised range. Structured mismatch responses drive directional recovery for too-old and too-new peers.The restack preserves current architecture ownership:
ConnectEnvelopeBuilderowns connect envelopes,PendingRequestRegistryowns correlated requests,NodeConnectionCoordinatorowns node lifecycle/recovery/compatibility, andGatewayConnectionManagerowns operator lifecycle and state-machine writes.User Impact
Supported v3-v4 Gateways connect normally. Gateways below the supported floor show Gateway update required. Newer Gateways that reject the offered range show Windows app update required. Deterministic protocol mismatches stop automatic reconnect loops while preserving explicit reconnect after software is updated.
Gateway package version and wire protocol remain separate diagnostics.
Evidence
Historical visual reference
These screenshots were captured from old head
9f558495cd8a4323f86b54391e6e9209eb0a4231. They remain useful visual references but are not claimed as current-head visible proof. Current-head recapture was blocked because the Windows desktop was locked.Exact current-head MCP proof
An isolated tray built from
4ed146409f5472a77a1c275065cbd39f32ae4951connected to a test-owned WSL too-new stub.winnode --list-toolsadvertisedapp.connection.status; invocation returned:{ "toolAdvertised": true, "schemaVersion": 2, "connectionState": "Error", "protocol": { "compatibility": "gateway_too_new", "gatewayExpectedProtocol": 5, "gatewayMinimumProtocol": 3, "retryable": false }, "gateway": { "packageVersion": null }, "node": { "intended": false }, "mcp": { "running": true } }gateway.packageVersionis intentionally null because an incompatible handshake is rejected before Gateway self-information is published. The retained proof contains no credentials, device IDs, request IDs, raw frames, or user content.Change Type
Scope
winnodeValidation
Exact current-head local validation at
4ed146409f5472a77a1c275065cbd39f32ae4951:./build.ps1: all projects and documentation passedThe final WSL matrix covered compatible protocol 4, additive future protocol 5, structured too-old, structured too-new, below-floor successful
hello-ok, missing protocol, and malformed string protocol. Each terminal mismatch accepted exactly one connection. Compatible/future sessions retained normal reconnect after the stub intentionally closed the socket.A broader opt-in E2E run on the same restacked runtime before the final logging/snapshot cleanup passed all 38 relevant real gateway setup, connect, revocation, and network recovery tests. Five unrelated MXC/AppContainer cases failed because MXC was unavailable while host fallback was correctly blocked.
Final identical-prompt adversarial review of
99730e75..4ed14640:GitHub CI was triggered for the new head after the lease-protected update and is currently running.
Real Behavior Proof
OpenClawGatewayWSL distro, raw WebSocket compatibility stub, isolated Local MCP4ed146409f5472a77a1c275065cbd39f32ae4951OPENCLAW_TRAY_DATA_DIRwinnode --list-toolsandwinnode --command app.connection.statusgateway_too_oldgateway_too_newHistorical screenshot links resolve; current-head visual proof blockedSecurity Impact
NoNo credential semantics changed; gateway-controlled mismatch text is now sanitized before loggingNo new network callsNoNoThe change fails closed before token persistence or connected state when protocol validation fails. Credential precedence remains device token, shared gateway token, then bootstrap token.
Compatibility and Migration
Yes; preserves protocol v3-v4 and adds explicit handling outside itNoNoReview Conversations