Repository navigation
fix(gateway): gate operator RPCs until hello-ok - #1472
Conversation
Prevent application RPC sends from treating a transport-open WebSocket as gateway-ready before the connect/hello-ok handshake completes on the current connection generation. Update loopback tests to prove pre-handshake sends are withheld and post-handshake sends still work. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 23, 2026, 7:34 PM ET / 23:34 UTC (Revision 11). ClawSweeper reviewWhat this changesThe Windows Companion Gateway client binds operator readiness and application requests to the socket generation that received hello-ok, with loopback coverage for pending handshakes and reconnects. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 6 items remain Keep this PR open. Current main already blocks RPCs before hello-ok through a merged fix, but this branch adds distinct protection when a socket is replaced. A completed write can still be reported as unsent, and the required Windows WSL proof pool failed its preservation guard. Priority: P2 Review scores
Verification
How this fits togetherThe Windows Companion operator client receives actions from tray, session, and chat surfaces and sends them to the Gateway over a WebSocket. Its handshake determines when those actions may reach the Gateway. flowchart LR
A[Tray and chat actions] --> B[Operator client]
C[Gateway socket] --> D[Hello-ok handshake]
B --> E{Current socket ready?}
D --> E
E -->|Yes| F[Gateway request]
E -->|No| G[Unavailable result]
Decision needed
Why: The Gateway cases passed, but the required wrapper failed after a host maintenance fingerprint change; deciding how to investigate the host and authorize another attempt is outside code review. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the generation-bound handshake gate, distinguish unwritten requests from completed or indeterminate writes, cover replacement immediately after a write, and complete the required Windows validation under an approved host disposition. Do we have a high-confidence way to reproduce the issue? No failing current-main reproduction of the original early-RPC bug remains after the merged baseline fix. The PR-head completed-write race has a clear source-level trigger, but no replacement-after-write run was supplied. Is this the best way to solve the issue? No. Binding requests to the handshake's socket generation is useful, but a completed write must not be classified as definitely unsent when the socket changes before the final check. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 42c562f91a42. LabelsLabel changes: No label 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 (10 earlier review cycles; latest 8 shown)
|
Reuse the shared handshake-pending marker without changing generation-bound admission. Prove all five payload readers remain unavailable until correlated hello-ok, succeed afterward, and still throw after disconnect. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 52343117-04d9-4dcc-866b-6a015204133d
Integrate exact main fb8b9e7 without changing the reviewed operator repair or its contracts. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 52343117-04d9-4dcc-866b-6a015204133d
Integrate exact main 42c562f; retain reviewed operator fix and contract blobs unchanged. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 52343117-04d9-4dcc-866b-6a015204133d
|
Maintainer merge disposition for exact head The earlier disposition conflated two different results:
The task-owned distro and processes were cleaned up. Normal startup, settings, Gateway, WSL configuration, service and normal-distro checks remained unchanged. No product assertion failed, and no evidence attributes the maintenance-queue change to this bounded operator-handshake fix. The unchanged head also has the complete passing local validation floor, focused real WebSocket regressions, two successful native official-Gateway connection cycles, clean bounded source reviews, and a successful required CI Gate in run 35927629541 attempt 2. There are no unresolved review threads. The passing product evidence is sufficient for this code-only merge. The separate host-safety warning continues to block further local WSL proof unless separately dispositioned. This does not waive a failed required CI check or substitute a skip for product proof. Live main is |
Fixes #1418
Summary
HandshakePendingErrormarker so command-catalog, session-file, and compaction payload readers return unavailable while hello-ok is pending instead of throwing. Generation-bound admission is unchanged.Required proof pools
windows-wsl-gateway-e2e: Attempted once at this head, FAILED overall. All 19 mandatory real Gateway cases and 3 teardown guards passed, with 1 ordinary optional Ollama skip. The pinned wrapper nevertheless exited 1 at its final preservation guard because the maintenance fingerprint changed. Passing tests or green hosted CI do not override this failed pool result. No repeat, maintenance repair/clear, reboot, or new attempt is authorized implicitly.The exact-head/fingerprint-bound one-use approval was consumed. Initial admission explicitly retained unresolved maintenance as a warning, not a harmless-queue or reboot-free claim. The maintenance value remained
MultiStringbut changed from 172 to 180 elements. Retained snapshots contain only kind/count/whole-value hash, so ordered-prefix, appended/new/reordered/removed counts and affected task-root/system/other categories are unknown, not inferred from the net increase. Raw paths were not retained, read for this closeout, or interpreted. The difference is established across the run interval, not causally attributed to tests or another actor. Other normal-host hashes, distro state, and process cleanup checks passed. Parent owns the failed pool disposition; WSL policy remains blocked for new runs.Validation
Current head:
d5529dc15b42909d8b011df971a50a1b8e9a48b3Ordinary merge and normal push only. Parents are prior validated head
14ca9617b82988ad16bde89a4e8035533104f104and exact main42c562f91a42ae0251ac971c44f6ce0f8028e88d; resulting tree isdb084a10c1a096914e811c98da715d239e5f7f78. All six reviewed operator/client/test blobs remain byte-identical. No new operator source repair or broad source review was needed.Native Windows ARM64, private .NET SDK 10.0.400, isolated worktree.
OPENCLAW_REPO_ROOTpoints to the worktree.OPENCLAW_TRAY_DATA_DIRandOPENCLAW_TRAY_APPDATA_DIRare isolated; outerOPENCLAW_STATE_DIR,OPENCLAW_TRAY_LOCALAPPDATA_DIR,OPENCLAW_TRAY_LOCAL_DATA_DIR, and E2E flags are unset for unit runs..\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~GatewayProtocolLiveRoundTripTests|FullyQualifiedName~GatewayRequestShutdownClassificationTests|FullyQualifiedName~OpenClawGatewayClientTests|FullyQualifiedName~OpenClawGatewayClientAssistantMediaTests|FullyQualifiedName~GatewayProtocolModelsTests'The initial local Shared run is preserved: 4,101 passed, 35 skipped, 1 failed in unchanged
McpHttpServerTests.Dispose_DuringInFlightHandler_DoesNotSurfaceObjectDisposedException. Its process-global unobserved-task assertion capturedSafeFileHandle/StreamReader.ReadToEndAsyncInternaldisposal exceptions. Historical CI run 35617173469, job 106391193895 has the same assertion/stack; test/owner blobs match main. After inspecting the evidence, the isolated full MCP HTTP class passed 26/26 and one complete required-floor rerun passed. No MCP source change or unsupported root-cause attribution was made.Hosted CI: one bounded replay passed
Run 35927629541, attempt 2 completed success, including CI Gate, at the unchanged head above. This was the single expressly authorized failed/cancelled-jobs replay. Core/CLI and UI reran; already-passing substantive jobs retained their original timestamps/results. The attached finite monitor required cancellation at 20 minutes in Tray UI or 35 minutes overall. Neither limit was reached and no replay cancellation was needed. No further replay is authorized.
Fresh attempt-2 artifact IDs were selected explicitly so earlier artifacts were not mistaken for replay results: Core
10781767319, UI10782285831. All listed TRX run outcomes are Completed with 0 failures.Core/CLI job
107423584735, UI job107423584652, and CI Gate job107425760359all succeeded. The replay's Tray UI step completed in 70 seconds. The original Piper cancellation test passed in the replay (109.6 ms whole-test duration).Attempt 1 remains recorded as cancelled, not erased by the replay. Core/CLI failed
PiperVoiceExtractionTests.ExtractTarBz2Async_CancellationIsBoundedAndKillsExtractorbecause its fixture did not publish its PID within the three-second startup wait, before cancellation was requested. The test/owner blobs match main. Separately, Tray UI completed discovery and loggedStarting: OpenClaw.Tray.UITests, then produced no individual Tray result for 50m17s. The only UI artifact was Functional UI's 19 passing tests; no Tray TRX or stalled test identifier was available. After fresh verification that only UI remained active, a single parent-authorized normal cancellation bounded excessive resource use. No confirmed hang/root cause was claimed. The old rerun watcher was stopped before cancellation; only the subsequent expressly authorized attempt-2 replay was issued.Review provenance: the bounded marker repair at
5d2345db7ef322385afcd6e7016058a1c079ffdfpassed focused rubber-duck and structured Codex 0.156.1 ARM64 autoreview (gpt-5.6-sol,high, exit 0, no actionable findings). Command:python .agents\skills\autoreview\scripts\autoreview --mode commit --commit 5d2345db7ef322385afcd6e7016058a1c079ffdf --engine codex --codex-bin <verified-session-private-codex.exe>. No broad repeat review was run because the six reviewed blobs remain unchanged. Guarded-runner artifact checks passed 26 synthetic maintenance cases plus 15 unsafe-condition rejection checks and 4 positive AST guard checks.Author-provided validation at prior head
de8c5cfc$env:OPENCLAW_REPO_ROOT='C:\Users\biilai\.copilot\repos\copilot-worktrees\openclaw-windows-node\karkarl-laughing-happiness'; .\build.ps1: passed. All builds succeeded.$env:OPENCLAW_REPO_ROOT='C:\Users\biilai\.copilot\repos\copilot-worktrees\openclaw-windows-node\karkarl-laughing-happiness'; dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: passed. 4094 passed, 32 skipped, 4126 total.$env:OPENCLAW_REPO_ROOT='C:\Users\biilai\.copilot\repos\copilot-worktrees\openclaw-windows-node\karkarl-laughing-happiness'; dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: passed. 3064 passed, 0 skipped, 3064 total.$env:OPENCLAW_REPO_ROOT='C:\Users\biilai\.copilot\repos\copilot-worktrees\openclaw-windows-node\karkarl-laughing-happiness'; dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~GatewayProtocolLiveRoundTripTests: passed. 7 passed, 0 skipped, 7 total.$env:OPENCLAW_REPO_ROOT='C:\Users\biilai\.copilot\repos\copilot-worktrees\openclaw-windows-node\karkarl-laughing-happiness'; dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore: failed on existing host prerequisite.ManagedLocalGatewayPortProvenanceServiceTests.VerifyMicrosoftSignedFile_AcceptsWindowsWslBinaryreportsWSL relay Authenticode verification failed (Unsigned). 792 passed, 1 skipped, 1 failed, 794 total.code-reviewagent inspected the final staged diff and reported no significant issues.Real behavior proof
GatewayProtocolLiveRoundTripTests.ApplicationRpc_BeforeHelloOk_DoesNotReachWireconnects to a loopback gateway with no challenge or hello-ok, callsRequestNodesAsync, verifies nonode.listframe is captured, callsGetUpdateStatusAsync, verifies noupdate.statusframe is captured, then verifies direct wizard send fails withGateway handshake has not completedand still captures noupdate.statusframe.GatewayProtocolLiveRoundTripTests.HandshakeGate_Reconnect_SuppressesEarlyMutationThenSendsAfterHelloOkcovers a real WebSocket trace where a mutation returns false while the challenge is withheld, the same mutation succeeds after challenge/connect/hello-ok, readiness clears after server close, and the mutation succeeds again after reconnect handshake.SendRawAsync(..., connectionGeneration, ...)path is now used for application RPC sends, so a ready snapshot from an old socket cannot authorize a send on a replacement socket.Current-head withheld-hello payload-reader proof
PayloadReader_HelloOkPending_ReturnsUnavailableThenSucceedscoverscommands.list,sessions.files.list,sessions.files.get,sessions.compaction.list, andsessions.compaction.get. The five cases failed before the marker repair and pass at this head. The production client receives a real challenge and sends connect; the server withholds hello-ok, then delivers a valid response correlated to that connect ID on the same socket.Observed for each reader:
Current-head native product Gateway smoke
Official OpenClaw 2026.9.5 (
ec9c1a1), native Windows, foregroundgateway run --bind loopback --port 21472 --auth token --tailscale off. Own home/state/workspace/config and fresh token, OS-only environment whitelist, no inherited provider credentials, and disabled channels/plugins/cron/browser/desktop/hooks/updates/telemetry. Fresh synthetic identity approved through the ordinary exact-request device command in that disposable profile. This native smoke involved no service installation, Companion UI, WSL, or real user profile.The probe asserted full head
d5529dc15b42909d8b011df971a50a1b8e9a48b3in productionOpenClaw.Shared.dll. SHA256:DD9FA2CDF037225C38C384270DA6DC5CD5E9AB12327A0D1EBB397765992F8F92.The same client was reused across both connections. The native Gateway was stopped, port 21472 closed, and disposable credentials/state removed. This exact-head native proof remains credited separately from the failed WSL preservation gate.
One authorized Win11 WSL class attempt: test success, overall proof failure
Exact head above, native
win-arm64, unchanged authoritative command under the pinned guarded wrapper:prepare-win11-wsl-proof.ps1:403, final cleanupFailures guard. FAILED.Canonical maintenance comparison (
OpenClawPendingMaintenance/v1):The snapshots deliberately retained no raw entries, so the unknown fields cannot be reconstructed from the hashes. No causal attribution was made. The one-use approval is consumed; the wrapper was not invoked again. No queue mutation, normal-state repair, rollback, reboot, or repeat attempt occurred. Read-only closeout confirmed original owned registration/process cleanup finished. Raw logs/TRX remain private;
safe-closeout-summary.jsonpreserves the failed overall result alongside passing test counts. No MXC containment or optional Ollama proof is claimed. Build/desktop capacity is released. The lane is paused for parent disposition of the failed custom pool; the PR remains draft without merge authorization, notwithstanding green hosted CI.