Skip to content

[Repo Assist] fix(setup): add Windows-side gateway health check to pair-operator step - #743

Merged
shanselman merged 1 commit into
mainfrom
repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68
Jun 21, 2026
Merged

shanselman merged 1 commit into
mainfrom
repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Closes #662

Root Cause

PairOperatorStep.ExecuteAsync() was missing the Windows-side HTTP gateway health check that PairNodeStep already has (line 2086). Both steps attempt WebSocket connections to (localhost/redacted) but only pair-node` first verified the gateway was reachable from the Windows host.

After StartGatewayStep confirms the gateway is up (by running curl inside WSL to 127.0.0.1:{port}), WSL port forwarding may take a few seconds to propagate to the Windows loopback interface. PairOperatorStep immediately tried the WebSocket connect with no probe, resulting in:

  • v0.6.0: SocketException 10061 (Connection refused) — port not yet forwarded
  • v0.6.3: HTTP 5-second timeout — same forwarding lag, just surfaced differently

Fix

Added the same Windows-side probe that PairNodeStep uses, immediately before the WebSocket connect:

// Verify gateway is reachable from Windows before connecting (WSL port forwarding may lag)
try
{
    using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
    var resp = await http.GetAsync($"(localhost/redacted) ct);
    ctx.Logger.Debug($"Gateway health check: HTTP {(int)resp.StatusCode}");
}
catch (Exception ex)
{
    return StepResult.Fail($"Gateway not reachable before operator pairing: {ex.Message}");
}

The step already has RetryPolicy Retry => new(MaxAttempts: 3, InitialDelay: TimeSpan.FromSeconds(3)), so if the health check fails on the first attempt the step will retry up to 3 times with increasing delays, giving WSL port forwarding time to propagate before the WebSocket connect.

Trade-offs

  • The HTTP probe adds one extra network round-trip (~5s max) to the happy path when the gateway is already reachable. Given this is a setup step, the extra latency is acceptable.
  • The probe is a GET to (localhost/redacted) so it doesn't require a token. Any HTTP response (200, 401, 403) is treated as "reachable" — matching PairNodeStep`'s pattern.
  • No new dependencies or interfaces added.

Test Status

Added a new regression test PairOperatorStep_FailsWhenGatewayNotReachableFromWindows that allocates a free TCP port, releases it, and verifies the step returns StepOutcome.Failed with a "not reachable" message.

SetupEngine tests: Failed: 0, Passed: 248 (1 new test), Skipped: 0

Pre-existing failures on Linux CI:

  • OpenClaw.SetupEngine.Tests: 1 pre-existing failure (Constructor_SetsLocalDataDirFromLocalAppDataRootEnvironment — Windows path separator in Linux test environment)
  • OpenClaw.Shared.Tests: 8 pre-existing failures (Windows sandbox/networking tests)
  • OpenClaw.Tray.Tests: ✅ 1038 passed, 0 failed

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

@github-actions

Copy link
Copy Markdown
Contributor Author

🤖 Repo Assist maintenance note.

This PR has a merge conflict in tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs — both this branch and main added new tests after the same insertion point (DefaultConfig_NoPairingScopeFields), so they conflict. The conflict is straightforward: both tests should be kept.

Automated rebase attempts in the last three runs have been blocked by the protected-files check: the diff between the original branch history and a rebased history includes ci.yml (because main advanced past commits that modified that file), which the push system flags as a protected file even though the fix itself never touches ci.yml.

To resolve manually (requires push access):

git fetch origin
git checkout repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68
git rebase origin/main
# Conflict is in tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs
# Resolution: keep both ValidateWslLockdown_RetriesWslConfReadAfterStartupTimeout
# AND PairOperatorStep_FailsWhenGatewayNotReachableFromWindows
git add tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs
GIT_EDITOR=true git rebase --continue
git push --force-with-lease origin repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68

I've verified this rebase locally — after resolution, the diff vs main is exactly 2 files (SetupSteps.cs and SetupStepsTests.cs) with no ci.yml changes, and all tests pass (248 SetupEngine, 2229 Shared, 1049 Tray).

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

@github-actions

Copy link
Copy Markdown
Contributor Author

Commit pushed: f721763

Generated by 🌈 Repo Assist, see workflow run. Learn more.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed June 18, 2026, 5:56 AM ET / 09:56 UTC.

Summary
The PR adds a shared Windows-side localhost HTTP reachability probe before operator pairing, reuses it for node pairing, and adds a SetupEngine regression test for an unreachable gateway port.

Reproducibility: no. high-confidence runtime reproduction was performed in this read-only Linux review environment. Source inspection plus the linked issue logs make the missing operator-side Windows reachability wait source-reproducible.

Review metrics: 1 noteworthy metric.

  • Diff scope: 2 files changed, +48/-11. The change is confined to SetupEngine pairing code and one regression test, so review can focus on setup reachability behavior.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #662
Summary: This PR is the current narrow candidate fix for the pair-operator setup failure; older broad slow-machine work only partially overlaps and is closed unmerged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Run or attach a redacted Windows WSL setup smoke before undrafting if maintainers want proof of the exact port-forwarding lag scenario.

Mantis proof suggestion
A Windows WSL setup recording or redacted log would prove the timing-sensitive loopback propagation behavior that unit tests cannot show. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: run local Windows WSL setup and verify pair-operator succeeds after gateway start without connection-refused or HTTP-timeout failure.

Risk before merge

  • [P1] The new unit test covers the unreachable-port failure path, not a live slow WSL port-forwarding recovery; a Windows setup smoke would still improve confidence before undrafting or merging.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow probe and regression test if maintainers accept the CI signal plus any desired Windows WSL setup smoke, then let Step 'pair-operator' fails due to a connection error #662 close after merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; maintainers should review the draft PR and decide whether to request a live Windows setup smoke before merge.

Security
Cleared: No concrete security or supply-chain concern was found; the diff adds a local reachability probe and a focused test without changing credentials, dependencies, workflows, or permissions.

Review details

Best possible solution:

Land the narrow probe and regression test if maintainers accept the CI signal plus any desired Windows WSL setup smoke, then let #662 close after merge.

Do we have a high-confidence way to reproduce the issue?

No high-confidence runtime reproduction was performed in this read-only Linux review environment. Source inspection plus the linked issue logs make the missing operator-side Windows reachability wait source-reproducible.

Is this the best way to solve the issue?

Yes, this is a narrow maintainable fix direction: it mirrors the existing node-side reachability probe and relies on the existing setup retry policy. A live Windows WSL smoke would be the safer final proof for the timing-sensitive case.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 234fa8ff097f.

Label changes

Label changes:

  • add P1: The PR addresses a user-blocking first-run pair-operator setup failure already triaged as urgent on the linked issue.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is authored by repository automation, so the external-contributor real-behavior proof gate is not applied; CI and any maintainer smoke remain supplemental review evidence.
  • remove rating: 🌊 off-meta tidepool: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The PR addresses a user-blocking first-run pair-operator setup failure already triaged as urgent on the linked issue.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is authored by repository automation, so the external-contributor real-behavior proof gate is not applied; CI and any maintainer smoke remain supplemental review evidence.
Evidence reviewed

What I checked:

Likely related people:

  • ranjeshj: Introduced the out-of-process SetupEngine, authored recent gateway/pairing hardening, and recently refactored SetupSteps on current main. (role: feature owner and recent area contributor; confidence: high; commits: cefce3952ab1, ea36b12f9e4c, d4284d43fb6a; files: src/OpenClaw.SetupEngine/SetupSteps.cs, src/OpenClaw.SetupEngine/SetupContext.cs, tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs)
  • shanselman: Recent hardening work touched SetupSteps, GatewayRegistry, and WebSocket-related setup paths that overlap this pairing behavior. (role: recent adjacent hardening contributor; confidence: medium; commits: d23f8ca50013; files: src/OpenClaw.SetupEngine/SetupSteps.cs, src/OpenClaw.Connection/GatewayRegistry.cs, src/OpenClaw.Shared/OpenClawGatewayClient.cs)
  • Keith Mahoney: Recent local development setup work touched SetupSteps and SetupStepsTests, making this a plausible secondary routing candidate for setup flow review. (role: recent local setup contributor; confidence: medium; commits: 9106725567af; files: src/OpenClaw.SetupEngine/SetupSteps.cs, tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 14, 2026
Add the same Windows-side localhost gateway reachability probe to PairOperatorStep that PairNodeStep already uses before connecting over WebSocket. This lets the setup retry policy absorb WSL port-forwarding propagation lag instead of immediately failing operator pairing.

Add a regression test for an unreachable Windows gateway port.

Fixes #662

Co-authored-by: Copilot <[email protected]>
@ranjeshj
ranjeshj force-pushed the repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68 branch from f721763 to 960994d Compare June 18, 2026 06:19
@ranjeshj

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@ranjeshj
ranjeshj force-pushed the repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68 branch from 960994d to c320136 Compare June 18, 2026 06:41
@ranjeshj

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 Urgent regression or broken agent/channel workflow affecting real users now. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 18, 2026
@shanselman
shanselman marked this pull request as ready for review June 21, 2026 06:16
@shanselman
shanselman merged commit edf06da into main Jun 21, 2026
19 checks passed
@shanselman
shanselman deleted the repo-assist/fix-issue-662-pair-operator-gateway-health-check-69d5305cd33dda68 branch June 21, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. repo-assist status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Step 'pair-operator' fails due to a connection error

2 participants