Skip to content

fix(setup): retry wizard startup migration lease handoff - #1129

Merged
shanselman merged 2 commits into
mainfrom
shanselman-fix-wizard-lease-recovery
Aug 8, 2026
Merged

shanselman merged 2 commits into
mainfrom
shanselman-fix-wizard-lease-recovery

Conversation

@shanselman

@shanselman shanselman commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Retry only the exact OpenClaw startup-migration lease contention diagnostic while restoring gateway.reload.mode after the Gateway wizard.
  • Keep retries inside the existing 15-second restoration budget with 250 ms exponential backoff capped at 2 seconds, while reserving at least 500 ms for the final CLI attempt.
  • Preserve fail-closed restoration, wizard plus restoration diagnostics, intentional cancellation ordering, and the one-shot explicit managed Gateway restart.

Failure evidence

Validation

  • dotnet format .\openclaw-windows-node.slnx --no-restore --include .\src\OpenClaw.SetupEngine\SetupWizardRunner.cs .\tests\OpenClaw.SetupEngine.Tests\SetupStepsTests.cs
  • Focused wizard tests: 12 passed, 0 failed, 0 skipped.
  • .\build.ps1: all projects built; documentation validation passed for 46 files.
  • Shared tests: 3,631 passed, 0 failed, 32 environment-gated skips.
  • Tray tests: 2,246 passed, 0 failed, 0 skipped.
  • SetupEngine tests: 814 passed, 0 failed, 0 skipped.
  • Connection tests: 574 passed, 0 failed, 0 skipped.
  • .\scripts\validate-mxc-e2e.ps1 without -AllowSkip: 17 passed, 0 failed, 0 skipped.

Real behavior proof

The strict MXC run used an isolated OpenClawE2E-* WSL distro and isolated tray data. Current-head output showed:

Starting gateway wizard
Restored gateway.reload.mode to hybrid after wizard; restarting gateway to apply wizard configuration
step.completed: run-wizard -> Success
OPENCLAW_GATEWAY_SYSTEM_RUN_MXC_OK
Test Run Successful.

The same run proved mxc-direct-appc; contained=True, containment=mxc for successful and denied-write paths, and 17/17 tests passed. No real user profile, credentials, firewall state, or unrelated process was mutated.

Focused deterministic tests cover exact contention recovery, unrelated failure without retry, full-budget exhaustion preserving wizard plus restoration diagnostics, cancellation restoring before propagation, and one-shot restart ordering.

Hosted CI

  • Exact head: 89a04d544d0b49b855a35ef36b9476fc1418a6b0.
  • Build and Test run 31262216127, attempt 2: aggregate tests, setup-connect E2E, network-recovery E2E, revocation-recovery E2E, repo hygiene, and x64/ARM64 builds all passed.
  • CodeQL actions, C#, and Python analyses passed. No checks remain pending or failed.
  • Attempt 1 had two unrelated hosted flakes: SessionTitleBehaviorProofTests timed out waiting for SessionsPageMarker, and setup-connect exceeded its 45-minute job timeout. The failed jobs were rerun on the same exact SHA without code changes; both passed on attempt 2.

Reviews

  • Rubber-duck review rerun after fixes: no blocking or non-blocking correctness findings.
  • Project autoreview in branch mode against origin/main: initial P2 finding about stopping before the 15-second deadline was accepted and fixed; final rerun reported no accepted or actionable findings with 0.95 confidence.
  • Optional aggregate exhaustion logging was not added because each retry is already logged and the final failure preserves the exact upstream CLI diagnostic plus the wizard failure.

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

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 10:36 AM ET / 14:36 UTC.

ClawSweeper review

What this changes

The PR adds a bounded retry for the exact startup-migration lease diagnostic while the setup wizard restores Gateway reload mode, with focused regression tests.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. Current main has a single restoration attempt, and the reported lease handoff is a plausible bounded reliability gap; this collaborator-authored PR also cannot be auto-closed. The supplied runtime proof does not show the new contention-retry path actually recovering in a real setup.

Priority: P2
Reviewed head: 89a04d544d0b49b855a35ef36b9476fc1418a6b0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 5 items Current main has no retry: The current restoration path invokes the reload-mode CLI once with a 15-second timeout, then fails immediately for every non-zero exit, so it does not recover a transient migration lease handoff.
Existing restoration contract: Current tests establish fail-closed restoration, restart, ownership verification, cancellation ordering, and preservation of both wizard and restoration failures.
Feature provenance: The managed Gateway restart and wizard-recovery path appears to date to the setup hardening commit, which is now part of current main.
Findings None None.
Security None None.

How this fits together

The setup wizard temporarily disables Gateway reloads while applying configuration, then restores the configured reload mode and restarts the managed Gateway. A failed restoration leaves the completed wizard unable to safely hand back a usable Gateway.

flowchart LR
  A[Gateway wizard] --> B[Temporarily disable reload mode]
  B --> C[Apply wizard configuration]
  C --> D[Restore configured reload mode]
  D --> E{Migration lease contention?}
  E -->|Exact transient diagnostic| F[Bounded retry]
  E -->|Other failure| G[Fail closed]
  F --> H[Restart and verify Gateway]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The supplied current-head output shows normal reload restoration, not an actual lease-contention failure followed by the new retry and successful recovery.
  • Resolve merge risk (P1) - The complete PR-head objects were unavailable locally, so branch-level source inspection could not independently confirm all retry-budget and cancellation details.
  • Complete next step (P2) - No code repair is established from this review; the immediate merge blocker is contributor-provided real behavior proof for the changed contention path.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus regression coverage production +86/-7, tests +112/-7 across 2 files The retry policy is accompanied by focused coverage for contention, unrelated failure, exhaustion, cancellation, and restart ordering.

Merge-risk options

Maintainer options:

  1. Add contention-recovery proof (recommended)
    Before merge, provide redacted current-head output from a real Gateway and CLI lease handoff showing the exact diagnostic, bounded retry, and successful restored Gateway.

Technical review

Best possible solution:

Keep the retry limited to the exact lease diagnostic and attach a redacted production-boundary trace showing contention, retry, restoration, one restart, and successful health verification within the 15-second budget.

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

Yes, at source level. Current main makes one restoration attempt, and the PR body supplies a concrete base-SHA failure trace for the exact migration-lease diagnostic; the branch still needs a real after-fix contention recovery run.

Is this the best way to solve the issue?

Yes, conditionally. Retrying only the documented transient diagnostic is narrower and safer than weakening fail-closed restoration, provided the actual recovery path is demonstrated.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: A transient setup-wizard restoration failure can leave the managed Gateway unavailable after otherwise successful configuration.
  • add merge-risk: 🚨 availability: Changing restoration retry and restart timing can affect whether the Gateway returns to a healthy state after setup.
  • 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: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Label justifications:

  • P2: A transient setup-wizard restoration failure can leave the managed Gateway unavailable after otherwise successful configuration.
  • merge-risk: 🚨 availability: Changing restoration retry and restart timing can affect whether the Gateway returns to a healthy state after setup.
  • 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: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Current main has no retry: The current restoration path invokes the reload-mode CLI once with a 15-second timeout, then fails immediately for every non-zero exit, so it does not recover a transient migration lease handoff. (src/OpenClaw.SetupEngine/SetupWizardRunner.cs:550, 9f9a8eda6340)
  • Existing restoration contract: Current tests establish fail-closed restoration, restart, ownership verification, cancellation ordering, and preservation of both wizard and restoration failures. (tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs:2036, 9f9a8eda6340)
  • Feature provenance: The managed Gateway restart and wizard-recovery path appears to date to the setup hardening commit, which is now part of current main. (src/OpenClaw.SetupEngine/SetupWizardRunner.cs:550, 01faa6419b42)
  • PR-head inspection limitation: The checkout is a promisor clone and the local PR-head object could not be fetched because GitHub DNS resolution was unavailable. The review used the supplied two-file patch metadata and PR body, but could not independently read the complete branch files. (89a04d544d0b)
  • Release boundary: The supplied latest release is v0.6.12 at commit 4166e0f, while the affected current-main restoration path is in later main commits; this open PR is not shipped. (9f9a8eda6340)

Likely related people:

  • shanselman: Scott Hanselman authored the current-main setup hardening commit that introduced the relevant wizard restoration path and is also the PR author. (role: introduced the current wizard recovery path; confidence: high; commits: 01faa6419b42; files: src/OpenClaw.SetupEngine/SetupWizardRunner.cs, tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs)
  • RomneyDa: Dallin Romney authored the current main commit that carries the wizard lifecycle and release-candidate validation work. (role: recent area contributor; confidence: medium; commits: 9f9a8eda6340; files: src/OpenClaw.SetupEngine/SetupWizardRunner.cs, tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs)
  • Barbara Kudiess: Feature history shows repeated prior work on the setup wizard and gateway recovery path, including the local gateway recovery commit. (role: prior setup recovery contributor; confidence: medium; commits: bc210e048aa9; files: src/OpenClaw.SetupEngine/SetupWizardRunner.cs)

Rank-up moves

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

  • Tighten the PR description with what changed, how it was validated, and any remaining risk.

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 77141d2 into main Aug 8, 2026
32 of 34 checks passed
@shanselman
shanselman deleted the shanselman-fix-wizard-lease-recovery branch August 8, 2026 15:50
shanselman added a commit that referenced this pull request Aug 8, 2026
The gateway tears down its in-process hosted wizard TUI when the
configuration applied by the final wizard step restarts the gateway. Setup
answered every step through the final `done` acknowledgement, then received a
terminal payload whose error was exactly `Error: TUI exited from signal
SIGTERM`, failed the run-wizard step, and issued a best-effort wizard.cancel
against a gateway that was already restarting. Two independent Windows-node
release-check lanes reproduced this after successful pairing, verify-e2e,
reload-mode restoration, managed restart, health, and provenance checks.

Accept that one terminal result as completion, and only that one. The payload
must be terminal, the request just sent must have answered the authoritative
final step (a plain acknowledgement note with no options whose id or title
normalizes to `done`, last in order when the gateway supplies position
metadata), and the error must equal the exact message apart from surrounding
whitespace. Every other terminal error, an earlier SIGTERM, a progress poll, a
replayed session, an answerable step, and a non-terminal payload keep the
wizard failure and keep cancellation.

Terminal-payload classification now goes through a pure decision seam, and the
final-step flag is owned by a tracker, so the accepted path and each rejected
path are directly testable. #1129 reload-mode restoration, its exact
startup-migration-lease retry inside the 15 second deadline, cancellation and
restoration ordering, and the one-shot managed restart are unchanged.

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

1 participant