Skip to content

fix: preserve Core updates across restart timeouts - #1231

Merged
shanselman merged 1 commit into
mainfrom
shanselman-core-update-timeout
Aug 26, 2026
Merged

shanselman merged 1 commit into
mainfrom
shanselman-core-update-timeout

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Supersedes #1181 because the contributor branch cannot be updated after main changed a workflow file and the available OAuth token lacks workflow scope.

This app-owned replacement preserves the final validated implementation from source commit 3aebd2fe while rebasing it cleanly onto current main. Original design, investigation, and contribution credit belong to @TheAngryPit; the replacement commit also retains co-author attribution.

What Problem This Solves

Automatic gateway repair previously treated a 30-second in-distro restart timeout as a definitive failure and force-terminated the WSL distro. That could kill a supported detached OpenClaw Core updater that was still running.

The WSL runner now carries explicit timeout and indeterminate outcome signals through the gateway controller. Automatic repair fails closed for ambiguous outcomes and skips destructive distro termination. Definitive non-timeout failures retain terminate plus cold restart.

The existing #1227 bash-stdin behavior is preserved and strengthened: stdin closure remains in finally, so bash -s receives EOF even when the write path fails.

Validation

  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --filter "FullyQualifiedName~WslGatewayControllerTests": 13 passed, 0 failed, 0 skipped.
  • .\build.ps1: all 5 projects built; documentation validation passed for 46 files.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,813 passed, 0 failed, 32 intentional integration/environment skips.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,722 passed, 0 failed, 0 skipped.
  • git diff --check: clean.
  • All four changed file blobs were verified byte-for-byte against 3aebd2fe before commit.
  • Hanselman adversarial review: Claude Opus 5 and GPT-5.3-Codex found no blockers after proof; final merge-readiness confidence was 98% and 97%.

Real behavior proof

Current-head proof used the production WslExeCommandRunner against Ubuntu on WSL 2 with read-only commands only. No terminate, restart, update, or gateway mutation command was invoked.

stdin.exit=0
stdin.timedOut=False
stdin.indeterminate=False
OPENCLAW_RUNNER_STDIN_PROOF=ok

timeout.exit=-1
timeout.timedOut=True
timeout.outcomeIndeterminate=False
timeout.isIndeterminate=True
timeout.stderr=wsl.exe timed out

definitive.exit=7
definitive.timedOut=False
definitive.indeterminate=False
cancellation.threw=True

Focused tests prove the consumption side of those outcomes:

  • Timed-out or otherwise indeterminate restart: failure is reported, with zero distro termination calls.
  • Definitive in-place failure: one termination and a subsequent cold restart are retained.
  • Cancellation before escalation: OperationCanceledException is propagated, with zero termination calls.

Not verified / blocked: no destructive real-gateway outage was induced because proof was intentionally constrained to safe read-only WSL behavior.

Preserve ambiguous WSL timeout and launch outcomes through automatic gateway repair so detached Core updates are not killed by forced distro termination. Definitive failures still use the existing cold-restart recovery path.

Co-authored-by: TheAngryPit <[email protected]>

Co-authored-by: Copilot App <[email protected]>
@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.

@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. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 maintainer review before merge. Reviewed August 25, 2026, 9:17 PM ET / August 26, 2026, 01:17 UTC.

ClawSweeper review

What this changes

The branch marks WSL restart timeouts and launch failures as indeterminate so automatic local-gateway repair skips distro termination while retaining cold restart for definitive failures.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This collaborator-authored replacement is a focused fix for behavior still present on current main, with no blocking correctness finding in the proposed patch.

Priority: P2
Reviewed head: e2fb619425ab64eff77784a722685f2e9132592b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and tests are solid, while the submitted live output proves the runner boundary rather than a controlled end-to-end repair timeout.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The collaborator-authored PR is not subject to the external-contributor proof gate; it nevertheless includes current-head WSL runner output and focused decision-path tests, while explicitly noting that no destructive gateway outage was induced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The collaborator-authored PR is not subject to the external-contributor proof gate; it nevertheless includes current-head WSL runner output and focused decision-path tests, while explicitly noting that no destructive gateway outage was induced.
Evidence reviewed 5 items Current-main behavior: Current main escalates every unsuccessful in-place restart to ForceRestartAsync, so the requested timeout distinction is not already implemented.
Outcome propagation: The branch adds explicit timeout and indeterminate-result state in the WSL runner and carries it through the gateway controller.
Repair decision coverage: Focused tests cover timed-out and launch-indeterminate results with zero termination calls, preserve definitive-failure cold restart, and preserve cancellation before escalation.
Findings None None.
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 tray app invokes WSL to restart its managed local gateway, then uses the result in automatic repair. The repair path either reports an uncertain outcome safely or terminates and cold-restarts the distro after a confirmed failure.

flowchart LR
A[Gateway repair request] --> B[WSL command runner]
B --> C[Restart outcome]
C -->|Success| D[Gateway available]
C -->|Indeterminate| E[Report failure without termination]
C -->|Definitive failure| F[Terminate distro]
F --> G[Cold restart]
Loading

Before merge

  • Resolve merge risk (P1) - After merge, an ambiguous WSL failure intentionally avoids immediate cold recovery, so a genuinely wedged gateway can remain unavailable until a later repair attempt or manual recovery.
  • Complete next step (P2) - The patch has no discrete automated repair finding and should remain in its normal collaborator-owned landing path.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch size production +50 / -11, tests +74 The production change is limited to WSL outcome propagation and repair escalation, with focused coverage for the new decision branches.

Root-cause cluster

Relationship: canonical
Canonical: #1231
Summary: This is the current-main replacement for the same timeout-recovery fix proposed in the earlier contributor branch.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept conservative timeout recovery (recommended)
    Land the deliberate availability tradeoff: uncertain completion skips termination, while the tested definitive-failure path still performs a cold restart.
  2. Add controlled repair-path evidence
    If a non-destructive managed test gateway is available, capture a current-head trace showing timeout classification reaches the no-termination branch before merge.

Technical review

Best possible solution:

Keep indeterminate outcome propagation explicit, avoid destructive escalation for uncertain completion, and retain the existing cold-restart path for confirmed failures.

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

Yes, source-reproducible. Current main escalates an unsuccessful restart directly to forced termination, while the branch's focused tests construct timeout and indeterminate results and assert zero termination calls.

Is this the best way to solve the issue?

Yes. Carrying an explicit indeterminate outcome to the sole repair escalation point is narrower and safer than inferring timeout state from an exit code or disabling cold restart for definitive failures.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded local-gateway recovery correction that prevents a destructive restart escalation.
  • add merge-risk: 🚨 availability: The patch deliberately changes when automatic repair terminates and cold-restarts the WSL gateway.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 collaborator-authored PR is not subject to the external-contributor proof gate; it nevertheless includes current-head WSL runner output and focused decision-path tests, while explicitly noting that no destructive gateway outage was induced.

Label justifications:

  • P2: This is a bounded local-gateway recovery correction that prevents a destructive restart escalation.
  • merge-risk: 🚨 availability: The patch deliberately changes when automatic repair terminates and cold-restarts the WSL gateway.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 collaborator-authored PR is not subject to the external-contributor proof gate; it nevertheless includes current-head WSL runner output and focused decision-path tests, while explicitly noting that no destructive gateway outage was induced.

Evidence

What I checked:

Likely related people:

  • shanselman: Authored the reviewed outcome-classification commit and the preceding merged WSL gateway stdin change. (role: recent area contributor; confidence: high; commits: e2fb619425ab, 6ae9c6a5ea0f; files: src/OpenClaw.Connection/WslCommandRunner.cs, src/OpenClaw.Connection/WslGatewayController.cs, src/OpenClaw.Tray.WinUI/Services/ManagedLocalGatewayRepairAdapters.cs)
  • TheAngryPit: The PR credits the prior focused investigation and retains co-author attribution for the replacement implementation. (role: original investigation contributor; confidence: high; commits: e4dd1735b47e, e2fb619425ab; files: tests/OpenClaw.Tray.Tests/WslGatewayControllerTests.cs, src/OpenClaw.Tray.WinUI/Services/ManagedLocalGatewayRepairAdapters.cs)

Rank-up moves

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

  • If a safe managed test gateway is available, add a redacted trace that shows the repair adapter skips termination after a real timeout.

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 1e18866 into main Aug 26, 2026
25 checks passed
@shanselman
shanselman deleted the shanselman-core-update-timeout branch August 26, 2026 01:45
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. 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.

1 participant