feat(connection): enforce gateway protocol compatibility - #1127
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 10:50 AM ET / 14:50 UTC. ClawSweeper reviewWhat this changesAdds Gateway wire-protocol validation and exposes incompatible-Gateway recovery through connection state, WinUI, local MCP diagnostics, telemetry, documentation, and regression tests. Merge readinessThis PR remains necessary: current main advertises the v3-v4 range but accepts a Priority: P1 Review scores
Verification
How this fits togetherThe operator and Windows-node clients connect to a Gateway through the shared connection manager. Handshake results become connection state, then drive reconnection behavior, the Connection page, local MCP diagnostics, and opt-in telemetry. flowchart LR
A[Gateway handshake response] --> B[Operator and node clients]
B --> C[Protocol range validation]
C --> D[Connection state manager]
D --> E[Reconnect policy]
D --> F[Connection page recovery]
D --> G[Local MCP diagnostics]
D --> H[Opt-in telemetry]
Decision needed
Why: The implementation changes failure and retry behavior for existing remote Gateways, which is a support-policy decision beyond ordinary code correctness. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one shared v3-v4 contract, reject incompatible handshakes before connected state or token persistence, and retain clear manual recovery controls with compatibility-safe local MCP diagnostics. Do we have a high-confidence way to reproduce the issue? Yes, source reproducible: current main advertises v3-v4 but does not validate the successful handshake protocol before publishing connection success. This read-only review did not execute the loopback reproduction. Is this the best way to solve the issue? Yes, conditional on maintainer confirmation of the v3-v4 support policy. A shared contract and sanitized compatibility state avoid divergent operator and node handling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 582a44713860. LabelsLabel 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 (19 earlier review cycles; latest 8 shown)
|
c493b00 to
f63e7a2
Compare
f63e7a2 to
6e09cea
Compare
f9ca1c2 to
775f044
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
6b6b875 to
9f55849
Compare
Related: #1105
Note
This was developed as the next layer over #1105 and rebased onto
mainafter #1105 merged.What Problem This Solves
Resolves a problem where an incompatible Gateway could be treated as a generic connection failure or continue 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 protocol v3-v4 range and validate the minimal
hello-okshape before publishing connection success or persisting handshake tokens. Successful hello values at or above the supported floor remain forward-compatible becausehello-ok.protocolis the Gateway's current constant, while structured mismatch responses drive too-old/too-new recovery. Structured compatibility state drives diagnostics, MCP, telemetry, and directional Connection-page recovery without changing setup, WSL lifecycle, or Gateway package selection.User Impact
Supported v3-v4 Gateways connect normally. Gateways below that range show Gateway update required. Newer Gateways that reject the offered range show Windows app update required. Deterministic protocol mismatches do not reconnect indefinitely, but the operator retains explicit Connect and Disconnect recovery controls after updating software.
Gateway package version and wire protocol remain separate diagnostics.
Evidence
Gateway update required
Windows app update required
Both screenshots are from the source-identical proof build represented by final commit
9f558495cd8a4323f86b54391e6e9209eb0a4231, use unique isolated roaming and local-data roots, and render a loopback fake Gateway with no real credentials.Live isolated
winnode --command app.connection.status --params '{}'proof:{ "schemaVersion": 2, "effectiveMode": "LocalMcpOnly", "gateway": { "packageVersion": null }, "protocol": { "selectedProtocol": null, "currentProtocol": 4, "minimumSupportedProtocol": 3, "maximumSupportedProtocol": 4, "compatibility": "gateway_too_new", "source": "operator", "gatewayExpectedProtocol": 5, "gatewayMinimumProtocol": 3, "retryable": false }, "mcp": { "enabled": true, "running": true, "error": null } }gateway.packageVersionis intentionally null because the incompatible hello is rejected before Gateway self-information is published.Live OTLP collector proof
Exact current-head commit
9f558495cd8a4323f86b54391e6e9209eb0a4231exported to a test-owned loopback collector athttp://127.0.0.1:54946using OTLP HTTP/protobuf. Six requests were decoded with the officialExportTraceServiceRequest,ExportMetricsServiceRequest, andExportLogsServiceRequestschemas.Affected trace:
{ "name": "openclaw.connection.operator.connect", "status": "STATUS_CODE_ERROR", "eventPayloadCount": 0, "attributes": { "openclaw.connection.role": "operator", "openclaw.connection.operation": "connect", "openclaw.source": "gateway_connection", "openclaw.outcome": "failure", "openclaw.protocol.client": 4, "openclaw.protocol.gateway": "newer", "openclaw.protocol.compatibility": "gateway_too_new", "openclaw.error.category": "protocolmismatch" } }Affected metric:
{ "name": "openclaw.connection.attempt.duration", "type": "histogram", "unit": "ms", "count": 1, "attributes": { "openclaw.connection.role": "operator", "openclaw.connection.operation": "connect", "openclaw.outcome": "failure", "openclaw.protocol.client": 4, "openclaw.protocol.gateway": "newer", "openclaw.protocol.compatibility": "gateway_too_new", "openclaw.error.category": "protocolmismatch" } }Logs were also decoded. By design they contain only finite connection event and role-state fields and do not carry protocol tags.
Privacy inspection found no collector/Gateway URL, Gateway/device/pairing ID, credential/token, raw error message/frame, Gateway package version, or user content in exported application attributes. Standard pre-existing OTLP resource metadata such as tray
service.version, process ID, service instance ID, and SDK identity was redacted from this proof. Sanitized collector artifact SHA-256:be52c76d229480f4d71db57840ada22f2107a112454872a1a0e5196df5a41737.Change Type
Scope
winnodeValidation
$env:OPENCLAW_REPO_ROOT = (Get-Location).Path; .\build.ps1: 5/5 projects and 46 docs succeeded, 0 warnings/errorsSettingsPage.xaml:OpenClaw Windows CompanionHubWindow.xaml:Disconnectedtestjob passed, including Tray integration and AccessibilityReview:
9f558495:Real Behavior Proof
9f558495cd8a4323f86b54391e6e9209eb0a4231OPENCLAW_TRAY_DATA_DIRandOPENCLAW_TRAY_LOCALAPPDATA_DIRwinnode --list-toolsandwinnode --command app.connection.status --params '{}'YesSecurity Impact
NoNoNoNoNoYes, explain the risk and mitigation: N/AThe change fails closed before token persistence or connected state when the Gateway rejects the offered protocol range.
Compatibility and Migration
Yes; preserves the documented protocol v3-v4 range and adds explicit handling outside itNoNoReview Conversations