Skip to content

fix(setup): stop WSL inspection flake from dead-ending onboarding - #1235

Merged
karkarl merged 2 commits into
mainfrom
fix/wsl-inspection-flake-and-dead-end
Aug 27, 2026
Merged

karkarl merged 2 commits into
mainfrom
fix/wsl-inspection-flake-and-dead-end

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Problem Selecting the recommended Install a local gateway (WSL) option could end the setup flow with a Could not inspect WSL dialog whose only action was Close, telling the user to run wsl --list --quiet by hand. There is no way forward from that state on the recommended path. It reproduces on a machine where that exact command succeeds every time when run manually, which is what makes it confusing to diagnose from a bug report. Three separate defects combine to produce it. ### 1. CommandRunner can report a process that wrote output as silent After the child exits, the redirected pipes were given a flat 250 ms grace to reach EOF. The OutputDataReceived / ErrorDataReceived callbacks are queued to the thread pool, so on a saturated pool (a WinUI cold start is exactly that) they can miss that window even though the process already exited and wrote its output. The command is then reported with an exit code but empty stdout and stderr. Every caller that classifies command output shares this exposure, so this is fixed at the runner. Reproduced by starving the thread pool and looping the call: iter 0: THREW exit=1 timedOut=False outLen=0 errLen=0 elapsed=1916ms ok=39 threw=1 emptyOutput=1 The EOF wait is now bounded by a short cap instead of a flat grace, clamped by whatever remains of the caller's own deadline so the accepted timeout is never exceeded. The cap preserves the existing protection against a surviving descendant holding inherited pipe handles open, which RunAsync_ReturnsWhenDescendantKeepsOutputPipesOpen covers. ### 2. InterpretDistroList discarded a conclusive answer Both success paths were gated behind !result.TimedOut: csharp if (!result.TimedOut && result.ExitCode == 0) return ContainsDistro(...); if (!result.TimedOut && LooksUnavailable(result)) return false; throw new InvalidOperationException(...); A run that timed out after wsl.exe had already reported that WSL is not installed therefore threw, while holding stderr that reads The Windows Subsystem for Linux is not installed and with LooksUnavailable returning true. Observed directly: ExitCode : -1 TimedOut : True Stderr : len=332 (fully captured) LooksUnavailable => True Detect => THREW InvalidOperationException That output proves no distro can exist, and WslViabilityInspector already classifies the state as Installable rather than a blocker (PreflightWslStep.cs), so the conclusive answer is now kept. Fail-closed behaviour is unchanged when the output is empty or genuinely unrecognised. ### 3. The wizard destroyed context and offered no way forward WelcomePage replaced the option's title with Checking existing setup... for the duration of the check, so the user could not see which option was being acted on, and offered only Close when inspection failed. The progress ring beside the title already carries the busy state (its automation name is Checking existing WSL setup), so the title now stays put, and a failed inspection offers Try again instead of ending the flow. ## Validation Required closeout subset from AGENTS.md, all run on this branch's content: | Check | Result | |---|---| | ./build.ps1 | Pass (Shared, Cli, WinNodeCli, SetupEngine, WinUI) | | dotnet test ./tests/OpenClaw.Shared.Tests | 3813 passed, 0 failed, 32 skipped | | dotnet test ./tests/OpenClaw.Tray.Tests | Prior head: 2724 passed. Current-head local rerun was blocked by a pre-existing Windows TCP-listener enumeration hang; the GitHub Build and Test workflow passed on rerun. | | dotnet test ./tests/OpenClaw.SetupEngine.Tests | 1003 passed, 0 failed | Targeted tests added or updated: - OutputDrainBudget_ClampsToDeadlineAndCap (new maintainer follow-up) covers the remaining review finding by proving the drain wait uses the caller's actual remaining deadline, including the under-250 ms and exhausted-deadline boundaries. - ExistingConfigDetector_KeepsConclusiveUnavailableAnswerWhenRunAlsoTimedOut (new) covers defect 2. The existing ExistingConfigDetector_FailsClosedWhenDistroStateIsUnknown cases still throw, so the fail-closed contract is intact. - SetupWelcomePage_RunsExistingConfigDetectionOffUiThread updated for the new busy-state contract, with regression guards added: Assert.DoesNotContain("InstallTitle.Text", method) and a required PrimaryButtonText = "Try again". - RunAsync_ReturnsWhenDescendantKeepsOutputPipesOpen is unchanged and still passes, which is what bounds the cap in defect 1. An earlier attempt that charged the full remaining timeout to the EOF wait failed this test at 20.28s against its 5s budget. Environment: Windows 11 ARM64 (NVIDIA GB10 class), .NET SDK 10.0.400, Windows SDK 10.0.26100. ## Real behavior proof Captured from a build of this branch's content, launched isolated with OPENCLAW_TRAY_DATA_DIR and OPENCLAW_FORCE_ONBOARDING=1, on a machine with WSL not installed (Microsoft-Windows-Subsystem-Linux and VirtualMachinePlatform both disabled), which is the configuration that triggers the bug. Before (release build, same machine): selecting the recommended option and pressing Next left the wizard on a dialog reading Could not inspect WSL with the option title stuck at Checking existing setup... and Next disabled. UI Automation, sampled at 1s, 3s, 6s and 10s after the click, showed no change at any point: [Text] 'Could not inspect WSL' [Text] 'OpenClaw could not safely inspect existing WSL distributions. Run `wsl --list --quiet` in ...' [Text] 'Checking existing setup...' [Button] 'Next' IsEnabled = False After (this branch): the same flow proceeds past WSL inspection to the next step rather than dead-ending, and the option title is preserved throughout: [Text] 'Set up OpenClaw' [ListItem] 'Install a local gateway (WSL), recommended' [Text] 'Install a local gateway (WSL)' <- title intact, not clobbered [Button] 'Next' ... [Text] 'Set up the WSL gateway' <- advanced past inspection [Text] 'Windows permissions' Runner timing after the fix, from the app log: cmd.done: C:\Windows\System32\wsl.exe exit=1 (67ms) Not verified / blocked: the end-to-end WSL gateway install itself is not exercised here, because WSL is not installed on this host and installing it is out of scope for this fix. The change is scoped to inspection and its failure handling.

Selecting the recommended "Install a local gateway (WSL)" option could end the
setup flow with "Could not inspect WSL" and no way forward, telling the user to
run `wsl --list --quiet` by hand. It reproduces on a machine where that command
succeeds every time when run manually.

Three separate defects combine to produce it.

CommandRunner gave the redirected pipes a flat 250ms grace to reach EOF after
the process exited. The OutputDataReceived callbacks are queued to the thread
pool, so on a saturated pool (a WinUI cold start is exactly that) they can miss
that window even though the process already exited and wrote its output. The
command is then reported with an exit code but empty stdout and stderr, and
every caller that classifies command output reads that as silence. The EOF wait
is now bounded by a short cap instead, clamped by whatever remains of the
caller's own deadline so the accepted timeout is never exceeded. The cap keeps
the existing protection against a surviving descendant holding the pipes open,
which RunAsync_ReturnsWhenDescendantKeepsOutputPipesOpen covers.

InterpretDistroList gated both of its success paths behind !result.TimedOut, so
a run that timed out after wsl.exe had already reported that WSL is not
installed threw instead of using that answer. The output proves no distro can
exist, and WslViabilityInspector already treats that state as Installable rather
than a blocker, so the conclusive answer is now kept.

WelcomePage replaced the option's title with "Checking existing setup..." for
the duration of the check, hiding which option was being acted on, and offered
only Close when inspection failed. The progress ring already carries the busy
state (its automation name is "Checking existing WSL setup"), so the title now
stays put, and a failed inspection offers Try again instead of ending the flow.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YbwoyZNVT3qnRexUnCLZUx
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 26, 2026, 8:57 PM ET / August 27, 2026, 00:57 UTC.

ClawSweeper review

What this changes

This PR makes WSL setup inspection retain conclusive results, keeps the selected setup option visible, and lets onboarding retry an inspection failure.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. The previous timeout-boundary blocker remains at the current PR head, although the WSL classification and retry UX changes address the reported onboarding dead end.

Priority: P0
Reviewed head: c4d68f6dec25b0c40f7e3ef0d25e259593a370a7

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The supplied isolated UI proof is useful, but the unchanged timeout-boundary defect prevents merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external contributor proof gate. Its body nevertheless includes isolated before-and-after UI Automation output from the changed onboarding flow.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external contributor proof gate. Its body nevertheless includes isolated before-and-after UI Automation output from the changed onboarding flow.
Evidence reviewed 4 items Current main still has the reported dead end: Current main uses a fixed 250 ms output-drain wait, rejects an unavailable WSL result when it also timed out, and presents an inspection dialog with only Close.
Prior blocker remains unchanged: The PR head is unchanged since the prior review. It initializes the drain delay to 250 ms and only replaces it when the remaining deadline is larger, so a smaller remaining deadline is exceeded.
Relevant feature history: Setup and WSL behavior has recent contributions from Scott Hanselman and earlier deterministic-setup work from Ranjesh Jaganathan.
Findings 1 actionable finding [P2] Clamp the drain grace to the remaining timeout
Security None None.

Live Verification

Command: dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore --filter FullyQualifiedName~CommandRunnerTests

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

Assertions:

  • FAIL expect_output: Passed!

How this fits together

The setup wizard inspects local WSL state before moving to gateway installation. It uses the shared command runner’s output to either continue setup or show a recoverable inspection error.

flowchart LR
  A[User selects WSL setup] --> B[Setup wizard]
  B --> C[WSL inspection]
  C --> D[Command output drain]
  D --> E{Result conclusive?}
  E -->|Yes| F[Continue setup]
  E -->|No| G[Retry inspection]
Loading

Before merge

  • Clamp the drain grace to the remaining timeout (P2) - This prior blocker remains at the same head. When the child exits with less than 250 ms remaining and a descendant retains the redirected pipe handles, bounded is below the initial 250 ms and the condition leaves drainBudget unchanged. The later delay can therefore exceed the caller deadline. Use the smaller of the remaining time and cap, and cover this boundary.
  • Resolve merge risk (P2) - Merging leaves a shared command-runner path able to return after a caller-supplied timeout when less than 250 ms remains and inherited output pipes stay open.

Findings

  • [P2] Clamp the drain grace to the remaining timeout — src/OpenClaw.SetupEngine/CommandRunner.cs:212-221
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 5 files affected, production +60/-22, tests +25/-3 The change spans shared command execution, WSL result interpretation, and onboarding recovery.

Merge-risk options

Maintainer options:

  1. Enforce the caller deadline (recommended)
    Use the smaller of the actual remaining deadline and the output-drain cap, then add a test for a child that exits near deadline while a descendant retains pipe handles.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Bound the output-drain wait by the remaining caller deadline even when it is below 250 ms, then add a regression test for an exited child whose descendant retains output pipes.

Technical review

Best possible solution:

Bound the post-exit output drain to the smaller of the remaining caller deadline and the cap, then cover the under-250 ms inherited-pipe case with a regression test.

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

Yes. Source inspection shows that an under-250 ms remaining deadline still retains a 250 ms output-drain delay when a descendant holds the redirected pipes open.

Is this the best way to solve the issue?

No. The WSL result and retry changes are narrow, but the shared runner still needs the remaining-deadline clamp corrected.

Full review comments:

  • [P2] Clamp the drain grace to the remaining timeout — src/OpenClaw.SetupEngine/CommandRunner.cs:212-221
    This prior blocker remains at the same head. When the child exits with less than 250 ms remaining and a descendant retains the redirected pipe handles, bounded is below the initial 250 ms and the condition leaves drainBudget unchanged. The later delay can therefore exceed the caller deadline. Use the smaller of the remaining time and cap, and cover this boundary.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 911f36860b2d.

Labels

Label justifications:

  • P0: The reported failure blocks first-time users on the recommended onboarding path.
  • merge-risk: 🚨 availability: The PR changes timeout behavior in the shared setup command runner.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored PR is exempt from the external contributor proof gate. Its body nevertheless includes isolated before-and-after UI Automation output from the changed onboarding flow.

Evidence

Acceptance criteria:

  • [P1] ./build.ps1.
  • [P1] dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore.

What I checked:

  • Current main still has the reported dead end: Current main uses a fixed 250 ms output-drain wait, rejects an unavailable WSL result when it also timed out, and presents an inspection dialog with only Close. (src/OpenClaw.SetupEngine/CommandRunner.cs:195, 911f36860b2d)
  • Prior blocker remains unchanged: The PR head is unchanged since the prior review. It initializes the drain delay to 250 ms and only replaces it when the remaining deadline is larger, so a smaller remaining deadline is exceeded. (src/OpenClaw.SetupEngine/CommandRunner.cs:212, c4d68f6dec25)
  • Relevant feature history: Setup and WSL behavior has recent contributions from Scott Hanselman and earlier deterministic-setup work from Ranjesh Jaganathan. (src/OpenClaw.SetupEngine/CommandRunner.cs:1, 98d0760cb5b6)
  • Automated review helper could not construct its branch bundle: The required helper was invoked but the checkout lacks a merge base between the supplied main revision and HEAD; the line-level finding was independently verified from the available commits.

Likely related people:

  • shanselman: Recent commits in the central setup paths include WSL cleanup and setup hardening work. (role: recent setup-area contributor; confidence: medium; commits: fd8901d85f44, 787db18f3874; files: src/OpenClaw.SetupEngine/CommandRunner.cs, src/OpenClaw.SetupEngine/ExistingConfigDetector.cs)
  • ranjeshj: The relevant feature history includes the deterministic WSL setup commit and the SetupEngine redesign. (role: original deterministic-setup contributor; confidence: high; commits: 98d0760cb5b6, cefce3952ab1; files: src/OpenClaw.SetupEngine/CommandRunner.cs, src/OpenClaw.SetupEngine.UI/Pages/WelcomePage.xaml.cs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Clamp the output-drain wait to the remaining deadline and add the inherited-pipe boundary regression.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-26T21:05:30.234Z sha c4d68f6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T23:48:49.971Z sha c4d68f6 :: needs changes before merge. :: [P2] Clamp the drain grace to the remaining timeout

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 27, 2026
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 27, 2026
Ensure a successfully exited process never waits past the caller's remaining timeout while draining redirected output, and cover the deadline and cap boundaries.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 142acc51-2688-41cf-8442-67a33ef49c59
@shanselman

Copy link
Copy Markdown
Collaborator

Pushed maintainer fix 1cae216 for the remaining output-drain deadline finding. The drain budget is now bounded by the caller's actual remaining deadline and the existing cap, with deterministic boundary coverage. Full build, Shared tests (3,813 passed), and SetupEngine tests (1,003 passed) are green locally. The required Tray suite hit a pre-existing hang in BrowserProxyEndpointScopingTests while enumerating Windows TCP listeners; the isolated test reproduces unchanged, so CI is the clean full-suite signal for this head. @clawsweeper re-review

@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(setup): stop WSL inspection flake from dead-ending onboarding This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@karkarl karkarl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review verdict: SHIP TODAY

Dual-model review found no CRITICAL or HIGH defects and no release blockers. The change materially improves onboarding availability by preserving delayed WSL diagnostics, accepting timed-out but conclusive "WSL not installed" evidence, and providing explicit retry/cancel recovery. Destructive confirmation and app-ownership safeguards remain intact.

Both reviewers identified one non-blocking LOW-severity gap: the new redirected-output drain behavior does not have a focused regression test reproducing delayed callbacks or thread-pool pressure. Existing process coverage and the green build, test, setup-connect, recovery E2E, and CodeQL checks keep overall regression risk low.

@karkarl
karkarl merged commit cb610b2 into main Aug 27, 2026
30 of 32 checks passed
@karkarl
karkarl deleted the fix/wsl-inspection-flake-and-dead-end branch August 27, 2026 21:37
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants