Skip to content

fix: preserve Core updates across restart timeouts - #1181

Closed
TheAngryPit wants to merge 1 commit into
openclaw:mainfrom
TheAngryPit:fix/update-timeout-no-force-terminate
Closed

TheAngryPit wants to merge 1 commit into
openclaw:mainfrom
TheAngryPit:fix/update-timeout-no-force-terminate

Conversation

@TheAngryPit

Copy link
Copy Markdown
Contributor

Related: openclaw/openclaw#99666

What Problem This Solves

Fixes an issue where the Windows Companion could interrupt a supported OpenClaw Core update when its automatic gateway repair timed out. After waiting 30 seconds for an in-distro restart, the Companion treated the timeout as a definitive failure and terminated the entire WSL distro, killing the detached Core updater.

Why This Change Was Made

The WSL command runner now carries an explicit timeout result through the gateway controller. Automatic repair treats that result as indeterminate and skips forced distro termination. Definitive non-timeout restart failures retain the existing terminate-and-cold-restart recovery path.

This stays on the Windows Companion boundary. Core already owns the managed-service update handoff and its parent wait budget; the destructive escalation happened later in the external Windows supervisor.

User Impact

Long-running Core updates are no longer killed merely because the Companion's host-side restart wait expired. Users still retain automatic recovery when an in-distro restart fails definitively.

Evidence

Observed before the fix:

  • 21:02:57: Core accepted update.run and started the managed-service handoff.
  • 21:03:21: Companion auto-repair invoked an in-distro gateway restart.
  • 21:03:51: the 30-second wait timed out and Companion invoked wsl.exe --terminate, killing the detached updater.
  • Core remained clean at the old commit while only FETCH_HEAD advanced.
  • With the Companion stopped, the supported CLI update completed successfully.

The regression test now proves that a timed-out in-place restart makes zero terminate calls, while existing tests continue to prove that a definitive failure performs the terminate-and-cold-restart path.

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 --no-restore --filter "FullyQualifiedName~WslGatewayControllerTests": 11 passed, 0 failed, 0 skipped.
  • .\build.ps1: all 5 projects built; 46 documentation files validated.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,698 passed, 0 failed, 32 intentional environment/integration skips.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,621 passed, 0 failed, 0 skipped.
  • git diff --check: clean apart from Git line-ending conversion notices.

Real Behavior Proof

  • Environment tested: Windows 11 with WSL 2; isolated source worktree based on Windows Companion origin/main 12b84457a46492b8e3f4df99ea1ea17370f75992.
  • PR head or commit tested: e4dd1735b47eb7cadc19e0c73e9fea1c93d87e09.
  • Exact steps or command run: focused regression plus the required full repository validation commands listed above.
  • Evidence after fix: the timeout regression returns failure with completion unknown, records zero distro terminations, and records one in-distro restart attempt. The existing definitive-failure regression still records one termination and the cold restart.
  • Observed result: test_proven for the timeout decision and preserved definitive-failure path.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A.
  • Not verified or blocked: the installed official Companion remains unmodified, so the fixed source path is not yet runtime_proven or end_to_end_proven.

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: automatic repair no longer invokes the destructive host-side terminate command after an ambiguous timeout. The existing forced recovery remains available after a definitive non-timeout failure.

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 19, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

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

ClawSweeper review

What this changes

The PR carries WSL command timeout status into gateway restart recovery so an ambiguous timeout skips forced distro termination while definitive failures still cold-restart.

Regression provenance

Possible regression — probable (reproduction; failure trace; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep open, but do not merge this head unchanged: its timeout fix is useful, while its WSL command delivery conflicts with current main’s later stdin-based PATH repair.

Priority: P2
Reviewed head: e4dd1735b47eb7cadc19e0c73e9fea1c93d87e09

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The runtime proof is strong, but the current head retains a now-obsolete WSL command transport that would regress main.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The contributor supplied current-head disposable-WSL runtime proof for timeout and definitive-failure paths; repeat it after rebasing onto the current command transport.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The contributor supplied current-head disposable-WSL runtime proof for timeout and definitive-failure paths; repeat it after rebasing onto the current command transport.
Evidence reviewed 6 items Current-main command transport: Current main sends the gateway script through bash -s standard input, preserving the Linux PATH expression rather than placing it in WSL argv.
Main-history provenance: Blame attributes current main’s stdin command builder to the later Linux-PATH repair commit.
Repair diff: Commit 6ae9c6a replaces the argv bash -lc gateway script with bash -s plus standard input across the runner, controller, and tests.
Findings 1 actionable finding [P1] Retain stdin delivery for the WSL gateway script
Security None None.

Live Verification

Command: dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore --filter "FullyQualifiedName~WslGatewayControllerTests"

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 Windows Companion invokes gateway recovery inside WSL, then decides whether to preserve or terminate the distro. That decision affects gateway availability and whether an ongoing Core update handoff can complete.

flowchart LR
  A[Gateway reconnect failure] --> B[WSL in-distro restart]
  B --> C[Command result]
  C --> D{Timed out?}
  D -->|Yes| E[Keep distro running]
  D -->|No, failed| F[Terminate and cold restart]
  E --> G[Later repair observes outcome]
  F --> G
Loading

Before merge

  • Retain stdin delivery for the WSL gateway script (P1) - This restores bash -lc with $PATH in argv. The repository documents that wsl.exe expands argv variables before Bash receives them, and current main fixed this exact command path in 6ae9c6a. Rebase the timeout handling onto the current stdin-based transport so gateway controls keep their Linux PATH.
  • Resolve merge risk (P1) - Merging the branch’s argv-based bash -lc form could restore the documented WSL variable-expansion failure, leaving gateway controls unable to retain the intended Linux PATH.
  • Complete next step (P2) - A narrow mechanical rebase can retain the timeout fix while preserving current main’s WSL command transport.

Findings

  • [P1] Retain stdin delivery for the WSL gateway script — src/OpenClaw.Connection/WslGatewayController.cs:37-43
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 4 files changed, production +21/-4, tests +23 The timeout behavior is narrow and has focused regression coverage, but two production files overlap a newer main repair.

Merge-risk options

Maintainer options:

  1. Retain the current WSL transport (recommended)
    Rebase the timeout propagation onto current main and preserve the stdin-based gateway script path before merge.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, preserve stdin-based WSL gateway script delivery, retain timeout propagation, and rerun focused WSL recovery proof.

Technical review

Best possible solution:

Land the timeout distinction on top of current main while retaining stdin-based WSL script delivery and proving both timeout and definitive-failure recovery paths again.

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

Yes. The timeout branch is source-reproducible, and the contributor supplied a current-head disposable-WSL runtime trace for timeout versus definitive failure behavior.

Is this the best way to solve the issue?

No. The timeout distinction is appropriate, but the branch must preserve current main’s stdin transport instead of restoring a documented argv-expansion hazard.

Full review comments:

  • [P1] Retain stdin delivery for the WSL gateway script — src/OpenClaw.Connection/WslGatewayController.cs:37-43
    This restores bash -lc with $PATH in argv. The repository documents that wsl.exe expands argv variables before Bash receives them, and current main fixed this exact command path in 6ae9c6a. Rebase the timeout handling onto the current stdin-based transport so gateway controls keep their Linux PATH.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The contributor supplied current-head disposable-WSL runtime proof for timeout and definitive-failure paths; repeat it after rebasing onto the current command transport.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a bounded gateway recovery bug with concrete but limited availability impact.
  • merge-risk: 🚨 availability: The changed WSL command form can prevent gateway controls from running correctly for existing managed local gateways.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The contributor supplied current-head disposable-WSL runtime proof for timeout and definitive-failure paths; repeat it after rebasing onto the current command transport.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor supplied current-head disposable-WSL runtime proof for timeout and definitive-failure paths; repeat it after rebasing onto the current command transport.

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.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore --filter "FullyQualifiedName~WslGatewayControllerTests".

What I checked:

Likely related people:

  • Scott Hanselman: Authored the current-main repair that owns the same WSL command transport and PATH behavior. (role: recent area contributor; confidence: high; commits: 6ae9c6a5ea0f, 4206611f2b2e; files: src/OpenClaw.Connection/WslCommandRunner.cs, src/OpenClaw.Connection/WslGatewayController.cs)
  • Ranjesh: Introduced the earlier gateway terminal-control surface that this recovery path builds upon. (role: feature introducer; confidence: medium; commits: 0b2f9fea3dd9; files: src/OpenClaw.Connection/WslGatewayController.cs)

Rank-up moves

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

  • Rebase the timeout handling onto current main without restoring bash -lc argv script delivery.
  • Repeat the disposable-WSL timeout and definitive-failure proof on the rebased head.

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-19T23:44:29.070Z sha e4dd173 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-21T20:48:07.152Z sha e4dd173 :: needs maintainer review before merge. :: none

@TheAngryPit

Copy link
Copy Markdown
Contributor Author

Exact-head real Windows/WSL recovery proof (e4dd1735)

Fresh runtime proof now exercises the exact production recovery chain on Windows with WSL 2:

WslExeCommandRunner -> WslGatewayController -> WslManagedLocalGatewayRestarter

Environment: Windows 10.0.26200.9267, WSL 2.7.12.0, uniquely imported disposable distro OpenClawTimeoutLab-1181. The source was the already disposable OpenClawUpdateLab. No production Gateway, Companion settings, credentials, pairing, provider request or proof listener was used.

Timeout path

  • Exact 30-second runner timeout observed at 30,140 ms.
  • Result propagated as timed out and the restarter returned completion is unknown without force termination.
  • The PID 1 plus mount-namespace lifetime fingerprint remained unchanged immediately, after the detached 35-second handoff completed, and through a later successful recovery invocation.
  • Detached completion marker: present.
  • Cold-restart marker: absent.

Definitive-failure path

  • First real in-distro restart invocation exited 42, not timed out.
  • The same production restarter retained host-side terminate plus cold restart.
  • Final result: success.
  • Distro lifetime fingerprint changed, the pre-terminate sentinel was gone, and both attempt markers were present.

Fresh validation

  • Full repository build: all five projects passed; 46 documentation files validated.
  • Shared: 3,698 passed, 0 failed, 32 environment-only skipped.
  • Tray: 2,621 passed, 0 failed.
  • Scoped structured review: TruffleHog clean; no accepted/actionable findings; patch correct at confidence 0.99.

Redacted runtime artifact SHA-256: EA4EDE3EC62854BB60AABEEF61B1E3317AC7A775CA21D417287297A5D11B7FA9.

Cleanup completed: only OpenClawTimeoutLab-1181 was unregistered; its generated export and VHDX were removed. Final readback shows Ubuntu, OpenClawUpdateLab and OpenClawGateway stopped, no OpenClaw process, and no checked proof/Gateway listener.

Proof level: runtime-proven for the exact timeout-versus-definitive-failure owner boundary on a real disposable WSL 2 distro. This does not claim full Companion UI end-to-end proof or installed-package promotion.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 21, 2026
@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
@shanselman shanselman removed 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 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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix: preserve Core updates across restart timeouts 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.

@shanselman

Copy link
Copy Markdown
Collaborator

Superseded by the current-main replacement #1231, which preserves your fix and contributor attribution while avoiding the workflow-scope branch-update blocker.

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. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants