Repository navigation
fix(connection): retry promptly while the Gateway is starting - #1917
Conversation
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR honors bounded Gateway startup retry hints and reports typed startup unavailability when native setup reaches its existing deadline. Example: A Gateway rejects three operator handshakes with startup-sidecars and retryAfterMs=100 before accepting.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this collaborator-authored draft adds useful startup retry handling absent from main; source review found no definite introduced defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherNative setup and the connection manager use the shared operator client, which interprets Gateway handshake responses and delegates socket recovery to WebSocketClientBase. flowchart TD
A[Connection manager or native setup] --> B[Operator Gateway client]
B --> C[WebSocket transport]
C --> D[Gateway handshake response]
D --> E[Structured startup classification]
E --> C
C --> F[Fresh endpoint authorization]
F --> B
Technical reviewBest possible solution: Retain the bounded startup hint in the existing operator and transport owners while preserving authorization, credential precedence and caller deadlines. Do we have a high-confidence way to reproduce the issue? Main deterministically applies ordinary backoff to the verified startup rejection shape; the supplied loopback regression reports failure without the new branch and success with it, but this review executed no target code. Is this the best way to solve the issue? The patch is a small complete protocol fix: one parser, generation-bound state and an existing reconnect-loop hook preserve ordinary backoff and native setup ownership without introducing HTTP gating or extending deadlines. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1912df7e2f97. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 29, 2026, 4:57 PM ET / 20:57 UTC. |
fea2adb to
c9c3137
Compare
Honor bounded structured startup retry hints without changing auth, pairing, provenance or caller deadlines. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
c9c3137 to
ac75809
Compare
Co-authored-by: Copilot App <[email protected]>
Related: #1735 (feat(setup): stream live native Gateway activity log and typed failure diagnosis). This is an independent protocol-handling change, not a replacement for that contributor's diagnostics or UI work.
What Problem This Solves
Fixes: Companion can exhaust its connection window while a starting Gateway explicitly asks it to retry sooner.
User Impact
User impact: Companion retries supported startup rejections without treating them as authentication or pairing failure; native setup still stops at its existing deadline and reports typed startup unavailability when that state remains current.
This is the bottom of the requested Companion stack. Real native Gateway, WSL/MXC and UI proof remains blocked by runtime authority. The additional full Setup suite also has 15 host execution-policy failures, so this draft is not a ready-to-merge claim.
Why This Change Was Made
The existing connection owners now recognize only a correlated current-handshake
UNAVAILABLEresponse withretryable: trueanddetails.reason: startup-sidecars, without a competing structured detail code. A generation-bound retry hint is floored and clamped to 100 through 2000 ms, with a 500 ms fallback matching the pinned Gateway contract.Ordinary transport backoff, terminal auth/protocol failures, exact pairing, accepted device tokens, pre-credential native ownership checks and cancellation remain intact. No default timeout, HTTP readiness gate, Gateway admission policy or UI copy changes.
Evidence
The real managed-loopback WebSocket regression sends three structured startup rejections with close code 1013, checks all reconnect and handshake authorizations, then completes hello-ok. With the new rejection branch removed, this regression failed on the original backoff path with a connection-window timeout. With the fix restored it passes, without auth, pairing or Error events.
Parser and native-owner tests also cover invalid/bounded hints, unrelated responses, terminal structured-code precedence, preservation of an accepted device token, ownership drift, cancellation and the unchanged finite setup deadline. Synthetic fixture proof does not establish the cause of the earlier released Companion/Store Gateway failure.
Change Type
Scope
winnodeRequired proof pools
windows-wsl-gateway-e2e: operator protocol/reconnect and setup connection behavior changed. Not run, runtime provisioning is not authorized.windows-wsl-mxc: Gateway setup/connect changes require the real Gateway-to-node MXC closeout. Not run, WSL/MXC provisioning is not authorized.Validation
Automatic CI remains blocked: run 40951646643, attempt 1 for head
fea2adbba185db491d37a2b6192eecb941b96cc4failed the UI lane and CI Gate. Job 123722840914 completed the preceding integration suite with 34 passed, then the Gateway fixture suite with 38 passed / 1 failed. At 2026-10-29 21:04:44Z,SharedRootDialog_DefersNavigationAndRejectsNativeBinding(destination: Chat, settingsOrigin: True)failed atGatewayFixtureSettingsModalUiTests.cs:153: the retained composer control had an empty value instead ofKeep this draft behind the shared-root dialog. Core/CLI, Tray/setup/integration and all three WSL Latest E2E jobs (setup/connect, network recovery, revocation recovery) succeeded. These automatic results do not turn unrun native/MSIX/MXC proof into a pass.Failure classification: evidence points to the unchanged shared-root UI/composer draft-retention path, not this startup-retry branch. In fixture run
abc25bcd79ff47feb9fbeff2100bb1c6, the sanitized log records immediate hello-ok at 21:04:39.901Z; both recorded connect requests andopenclaw.setup.verifycompletedok. There were no startup rejections, reconnects or startup retry delays. The added fixture rejection switch defaults to zero and this UI case does not enable it. The failing test and chat/composer owners are unchanged from base; the same-control runtime-ID assertion immediately before the text assertion passed. An exact UI timing/root cause or pre-existing baseline failure has not been reproduced, so this is not labeled a proven flake. No unrelated UI edits, test weakening, app launch, CI rerun or workflow dispatch was performed. Branch remains unchanged.Windows ARM64, .NET SDK 10.0.403.
OPENCLAW_REPO_ROOTpointed at this task worktree. Test processes used isolated tray data/AppData/local-AppData overrides, cleared the competing local-data override, and left integration/GPU/E2E/MXC opt-ins unset. No installed app or shared Gateway was launched or changed..\build.ps1: passed all five projects, nativewin-arm64target, including documentation validation.dotnet build .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --verbosity quiet: passed, zero warnings/errors; prevents fresh-worktree test no-op.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: passed 4,834, skipped 24, failed 0. Skipped opt-in/native cases are not runtime proof.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: passed 4,754, skipped 0, failed 0.dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj: passed 1,700, skipped 1 (distinct-volume migration fixture not configured), failed 0.dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: failed, 2,473 passed / 15 failed / 1 skipped. All 15 failures are unchangedGatewayPackageCleanupTestsfixture scripts refused by Windows PowerShell execution policy before the cleanup guards run. The focused changed-owner suite passes. Host policy was not changed and these failures were not skipped or weakened.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~GatewayStartupUnavailableTests|FullyQualifiedName~StartupUnavailable|FullyQualifiedName~StartupReason': passed 26, skipped 0, failed 0.dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore --filter 'FullyQualifiedName~NativeGatewaySetupConnectionTests': passed 43, skipped 0, failed 0..\scripts\validate-agent-skills.ps1: passed 15 skills / 24 Markdown files..\scripts\test-agent-skills-validator.ps1: passed 27 fixtures plus repository skills.git diff --check: passed.Independent P0-P3 source/rubber-duck review covered all 11 changed files, unchanged transport/credential owners, tests and proof plan. No blocking findings. Codex CLI is unavailable, so the canonical installed autoreview skill's independent Copilot subagent route was used, with model/host identity unverified. It is a narrative assessment, not helper-validated status or helper-owned isolation/frozen-input evidence.
Two non-blocking observations were retained intentionally: startup classification is current-state only, so a deadline during a newly opened, unanswered handshake can still be an ordinary timeout; and the transport attempt counter is not reset before hello-ok, even after hinted startup retries. Retaining those choices avoids stale startup diagnoses and preserves the existing backoff reset contract.
Real Behavior Proof
Environment tested: native Windows ARM64; real loopback TCP/WebSocket with synthetic Gateway input and isolated signing identity.
PR head or commit tested:
fea2adbba185db491d37a2b6192eecb941b96cc4. Checks ran against its exact task diff before commit on base1912df7e2f976314d82baa88a5decf31218b33a1; local diff and new-file hashes were recorded with validation. No product or test source changed between validation/review and commit.Exact steps or command run:
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-build --no-restore --filter 'FullyQualifiedName~StartupUnavailable_RetriesFreshAuthorizedSockets' --logger 'console;verbosity=detailed'.Evidence after fix, copied from the passing test output:
Observed result: three fresh reconnects with three reconnect authorizations and four pre-credential handshake authorizations; typed startup clears after acceptance.
Screenshot or artifact links verified? (
Yes/No/N/A): N/A, copied synthetic socket output, no UI claim.Not verified or blocked: automatic CI UI fixture/CI Gate failure documented above; the full Setup suite's 15 host execution-policy failures; real packaged/native Gateway connect, visible UI, WSL Gateway E2E and MXC proof. App launches, runtime registration/provisioning, process stopping and workflow dispatch are outside this task's authority. No claim that this fixes either historical startup incident or makes an indefinitely starting Gateway healthy.
Security Impact
Yes/No): NoYes/No): NoYes/No): YesYes/No): NoYes/No): NoYes, explain the risk and mitigation: existing reconnects can occur sooner, but only for the exact structured startup reason and bounded hint. Every native reconnect and credential-bearing handshake still revalidates provenance. No additional endpoint, credential fallback or RPC is introduced.Compatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations