Skip to content

fix: gateway controls preserve Linux PATH in WSL - #1227

Merged
shanselman merged 1 commit into
mainfrom
shanselman-wsl-gateway-stdin
Aug 25, 2026
Merged

shanselman merged 1 commit into
mainfrom
shanselman-wsl-gateway-stdin

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Closes #911

What Problem This Solves

Fixes an issue where users controlling the local gateway in WSL could have Linux shell variables such as $PATH rewritten by wsl.exe, causing gateway start, stop, or restart commands to run with Windows path semantics.

Why This Change Was Made

Gateway control scripts now run through bash -s and are sent over stdin, which wsl.exe does not rewrite. The WSL command runner accepts optional stdin while preserving authoritative process exit/stderr results and existing cancellation and timeout behavior.

User Impact

Local WSL gateway start, stop, and restart operations retain the intended Linux executable search path instead of inheriting a rewritten Windows $PATH.

Evidence

  • Focused tests assert all three gateway verbs use bash -s, keep $PATH in stdin, and pass the script through IWslCommandRunner.
  • Full repository build and required Shared/Tray suites pass.
  • Blocker-only rubber-duck review found no blockers.
  • The six changed files are byte-for-byte identical to source snapshot commit afa4ed08b8555b0fc230df990d33f132a914f2b2; no unrelated paths are present.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --filter "FullyQualifiedName~WslGatewayControllerTests|FullyQualifiedName~StartupSetupStateTests|FullyQualifiedName~LocalAiGatewayProviderCoordinatorTests" --logger "console;verbosity=normal": 58 passed, 0 failed, 0 skipped.
  • .\build.ps1: passed; documentation validation and all five Debug build targets succeeded.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --logger "console;verbosity=minimal": 3,813 passed, 0 failed, 32 skipped, 3,845 total.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --logger "console;verbosity=minimal": 2,712 passed, 0 failed, 0 skipped.

A fresh-worktree Shared test invocation initially lacked project.assets.json; the project was restored once, then the complete required build and both --no-restore suites were rerun successfully.

Real Behavior Proof

  • Environment tested: Windows 11, WSL 2 available.
  • PR head or commit tested: 6bcb6c63.
  • Exact steps or command run: wsl.exe --list --verbose after current-head automated validation.
  • Evidence after fix: current-head focused tests verify bash -s argv plus an stdin script containing the Linux $PATH prefix for start, stop, and restart.
  • Observed result: automated command-contract proof passed for all three verbs.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A.
  • Not verified or blocked: real gateway invocation is blocked because this host has Ubuntu, AlmaLinux-9, MacComfort, and docker-desktop WSL distros, but no OpenClawGateway distro. No live gateway result is claimed.

Security Impact

  • New permissions or capabilities? (Yes/No): No.
  • Secrets or tokens handling changed? (Yes/No): No.
  • New or changed network calls? (Yes/No): No.
  • Command or tool execution surface changed? (Yes/No): Yes.
  • Data access scope changed? (Yes/No): No.
  • If any answer is Yes, explain the risk and mitigation: the existing WSL process runner can now receive explicit stdin. Only the fixed gateway control script uses it; arguments remain structured, timeout and cancellation still kill the process tree, and broken-pipe failures preserve the process exit code and stderr.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes.
  • Config or environment changes? (Yes/No): No.
  • Migration needed? (Yes/No): No.
  • If yes, list the exact upgrade steps: N/A.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper

clawsweeper Bot commented Aug 25, 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 merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. 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 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 7:16 PM ET / 23:16 UTC.

ClawSweeper review

What this changes

This PR sends WSL gateway start, stop, and restart scripts to bash -s over standard input so their Linux PATH expression is not rewritten by wsl.exe.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for normal collaborator and maintainer review. The focused change correctly moves the three gateway control verbs off the WSL argv path, but a real managed-distro smoke is still unavailable and the linked broad path-confusion report may include an unchanged Doctor command path.

Priority: P2
Reviewed head: 6bcb6c636fe6b211b64099a06fd5ca111348ca18
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The small, source-aligned patch has focused coverage, with a managed-WSL smoke remaining the material confidence reducer.
Proof confidence 🌊 off-meta tidepool Not applicable: This collaborator-authored PR is outside the external-contributor proof gate. Its focused test evidence is supplemental, and the body candidly records that an actual OpenClawGateway invocation was unavailable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This collaborator-authored PR is outside the external-contributor proof gate. Its focused test evidence is supplemental, and the body candidly records that an actual OpenClawGateway invocation was unavailable.
Evidence reviewed 7 items Current-main baseline: Current main still passes the PATH-bearing gateway script as a bash -lc argv argument, the exact pattern the repository WSL guidance identifies as rewritten before Bash receives it.
Head implementation: The PR supplies only bash -s as argv and puts set -e, the Linux PATH export, and the selected fixed verb in standard input.
Process boundary: The runner enables redirected standard input only when a script is provided, writes it before waiting for exit, and retains the existing timeout, cancellation, stdout, and stderr flow.
Findings None None.
Security None None.

Live Verification

Command: dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter "FullyQualifiedName~WslGatewayControllerTests" --logger "console;verbosity=normal"

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

Connection-page and repair actions control an app-managed WSL gateway through a small command controller. The controller gives structured arguments and a script to wsl.exe, then returns its exit code and diagnostics to the tray workflow.

flowchart LR
  A[Connection and repair actions] --> B[Gateway control builder]
  B --> C[WSL command runner]
  C --> D[wsl.exe]
  D --> E[Managed WSL gateway]
  E --> F[Start stop or restart]
  F --> G[Exit code and diagnostics]
Loading

Decision needed

Question Recommendation
Should the linked path-confusion report close after this PR, or does it also need the unchanged WSL Doctor launch path fixed? Keep the broader report open: Merge this narrow control fix only after retargeting its closing reference, then track the remaining Doctor launch path separately or in the same report.

Why: The PR explicitly links the report, but current source still constructs a Doctor bash -lc argv script containing $PATH, which the repository's WSL guidance says can be rewritten.

Before merge

  • Resolve merge risk (P1) - Gateway start, stop, and restart now depend on actual WSL stdin propagation; current evidence is focused contract coverage, and no managed OpenClawGateway runtime invocation is available.
  • Resolve merge risk (P1) - The linked report may be broader than these three verbs: the unchanged Doctor launcher still sends $PATH through a bash -lc argv script.
  • Complete next step (P2) - Confirm the linked report's remaining scope and obtain the available managed-WSL smoke before merge; there is no narrow automated repair to dispatch.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change surface 6 files affected: production +47/-16, tests +27/-13, docs +1 The patch is narrowly concentrated in the WSL runner, gateway controller, and their focused tests.

Merge-risk options

Maintainer options:

  1. Capture managed-WSL control proof (recommended)
    Before landing, run start, stop, and restart on an OpenClawGateway distro and retain a redacted command or UI result showing the controls complete with Linux PATH semantics.

Technical review

Best possible solution:

Keep the stdin-based control implementation, verify all three controls on a managed WSL gateway, and either retain the broader linked report for the Doctor path or explicitly scope it to control verbs before it closes.

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

Yes, at source level: current main constructs a bash -lc argv script containing $PATH, and the repository document records the corresponding WSL rewrite mechanism. A live managed-distro reproduction was not run in this read-only review.

Is this the best way to solve the issue?

Yes for the three control verbs: stdin is the documented maintainable route and preserves the existing structured command, timeout, and cancellation boundary. It is unclear whether this alone fully resolves the linked broader report because Doctor remains on the argv path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ff0353919cf.

Labels

Label changes:

  • add P2: This repairs existing WSL gateway controls for affected local-gateway users without evidence of a broad runtime outage.
  • add merge-risk: 🚨 availability: The patch changes the process boundary used to start, stop, and restart the managed gateway, but lacks a real managed-distro invocation.
  • 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: This collaborator-authored PR is outside the external-contributor proof gate. Its focused test evidence is supplemental, and the body candidly records that an actual OpenClawGateway invocation was unavailable.

Label justifications:

  • P2: This repairs existing WSL gateway controls for affected local-gateway users without evidence of a broad runtime outage.
  • merge-risk: 🚨 availability: The patch changes the process boundary used to start, stop, and restart the managed gateway, but lacks a real managed-distro invocation.
  • 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: This collaborator-authored PR is outside the external-contributor proof gate. Its focused test evidence is supplemental, and the body candidly records that an actual OpenClawGateway invocation was unavailable.

Evidence

What I checked:

Likely related people:

  • Ranjesh: Introduced the WSL-only gateway control feature and its start, stop, and restart behavior in the merged feature history. (role: introduced gateway controls; confidence: high; commits: 0b2f9fea3dd9; files: src/OpenClaw.Connection/WslGatewayController.cs, tests/OpenClaw.Tray.Tests/WslGatewayControllerTests.cs)
  • Barbara Kudiess: Prior history on the same controller and runner paths includes the WSL gateway dependency-recovery work. (role: WSL gateway recovery contributor; confidence: medium; commits: 1e6951331f1c; files: src/OpenClaw.Connection/WslCommandRunner.cs, src/OpenClaw.Connection/WslGatewayController.cs)

Rank-up moves

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

  • Capture a redacted managed-distro start, stop, and restart result before merge.

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.

@shanselman
shanselman merged commit 6ae9c6a into main Aug 25, 2026
25 checks passed
@shanselman
shanselman deleted the shanselman-wsl-gateway-stdin branch August 25, 2026 23:50
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. P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway commands mix Linux vs Windows semantics + path confusion

1 participant