Repository navigation
fix(setup): complete wizard on terminal hosted TUI SIGTERM - #1132
Conversation
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]>
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 1:56 PM ET / 17:56 UTC. ClawSweeper reviewWhat this changesThe PR treats one exact terminal hosted-wizard SIGTERM response as successful completion only immediately after the authoritative final acknowledgement step. Merge readinessKeep this collaborator-authored PR open for normal maintainer review. Current main does not contain this SIGTERM completion path; the implementation is narrowly guarded and well covered by deterministic tests, but direct after-fix proof against the pinned gateway build is still blocked. Priority: P2 Review scores
Verification
How this fits togetherThe setup engine answers a gateway-hosted configuration wizard, restores the gateway reload mode, and verifies the restarted gateway. Terminal wizard responses decide whether setup completes or retains the failure and cancellation path. flowchart LR
A[Gateway wizard step] --> B[Setup answer]
B --> C[Final-step tracker]
C --> D[Terminal gateway response]
D --> E{Exact SIGTERM after final done step?}
E -->|Yes| F[Complete wizard]
E -->|No| G[Fail and cancel]
F --> H[Restore gateway and verify]
G --> H
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow compatibility rule only after a pinned-gateway run shows the reported SIGTERM response completing setup while rejected terminal errors still fail. Do we have a high-confidence way to reproduce the issue? Unclear. The pre-fix upstream trace is specific and the branch has deterministic payload coverage, but the exact SIGTERM-producing gateway build was not exercised after the fix. Is this the best way to solve the issue? Yes, provisionally. A stateful final-step tracker plus exact error matching is the narrowest maintainable repair, subject to direct pinned-gateway confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 77141d27ee69. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Problem
The gateway tears down its in-process hosted wizard TUI when the configuration applied by the final wizard step triggers a gateway restart. Setup answered every step through the final
doneacknowledgement, then received a terminal payload that parsed asIsDone=truewith error exactlyError: TUI exited from signal SIGTERM.SetupWizardRunnerreturned failure, leftwizardCompleted=false, issued a best-effortwizard.cancelagainst a gateway that was already restarting, and preserved that failure even after successful reload-mode restoration, managed restart, HTTP 200 health, and managed provenance verification.This is not startup-migration lease contention and not a structured
PROTOCOL_MISMATCH.Evidence
Exposed by openclaw/openclaw PR #119762 at exact head
167c030cf9229ca5dcb6ea7c0de877f733185367(immutable refrelease-ci/167c030cf922-1786207973).93130477022, stable job9313047702577141d27ee69728da6c3509fb116de63bd176da4(merged fix(setup): retry wizard startup migration lease handoff #1129) and failed identically.Both logs show the same transcript immediately before the failure:
Step ids are GUIDs (hence
[REDACTED_ID]); the stable answer key comes from the normalized step title, so the final step is anotetitledDone.Behavior contract
A terminal wizard payload carrying
Error: TUI exited from signal SIGTERMcompletes the wizard only when all of the following hold:done: true);note, with no options, whose normalized step id or title equalsdone, and which is last in order when the gateway suppliesstepIndex/totalSteps(accepting both zero-basedn-1and one-basedn);Everything else keeps the wizard failure and keeps best-effort cancellation: an earlier
SIGTERM, a progress-poll acknowledgement, a replayed wizard session, any answerable or option-bearing step, any other step id or title, the stepmessagetext (no longer consulted), a non-terminal payload, a different signal, extra text, different casing, other terminal errors,PROTOCOL_MISMATCH, timeouts, exceptions, and cancellation.#1129 behavior is preserved exactly: reload-mode restoration still retries only the exact startup-migration-lease diagnostic within the existing 15 second monotonic deadline, unrelated failures do not retry, cancellation and restoration ordering are unchanged, and the one-shot managed restart stays fail-closed. Wizard replay bounds, credential precedence, and provenance/ownership guards are untouched. The exact Gateway 2026.7.1
model-checkterminal-restart path is unchanged.Files changed
src/OpenClaw.SetupEngine/GatewayWizardRestartRecoveryPolicy.cs- generalized the private step-key matcher; addedIsAuthoritativeFinalWizardStepandIsHostedWizardTerminationAfterFinalStep.src/OpenClaw.SetupEngine/WizardFinalStepTracker.cs(new) - owns the final-step flag withResetForNewSession/RecordProgressAcknowledgement/RecordAnsweredStep.src/OpenClaw.SetupEngine/SetupWizardRunner.cs- pureDecideTerminalWizardErrorseam returningWizardTerminalDecision(MarksWizardCompleted, Result, LogWarning); the terminal-error branch assignswizardCompletedfrom the decision, so cancel suppression happens only on accepted paths.tests/OpenClaw.SetupEngine.Tests/GatewayWizardRestartRecoveryPolicyTests.cstests/OpenClaw.SetupEngine.Tests/WizardFinalStepTrackerTests.cs(new)tests/OpenClaw.SetupEngine.Tests/SetupWizardTerminalCompletionContractTests.cs(new)tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.csdocs/ARCHITECTURE.md(ledger invariant),docs/ONBOARDING_WIZARD.mdValidation
All commands run locally at PR head
a92eb8c788c93c66733e6b9b1b1cff3f331e75b0.dotnet format --verify-no-changes --include <changed files>.\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\...dotnet test .\tests\OpenClaw.Tray.Tests\...dotnet test .\tests\OpenClaw.SetupEngine.Tests\...dotnet test .\tests\OpenClaw.Connection.Tests\....\scripts\validate-mxc-e2e.ps1 -NoBuild(strict, no-AllowSkip)MXC validation completed successfullyNew deterministic coverage: exact accepted path; early SIGTERM before the final step; non-terminal payload;
SIGKILL; missingError:prefix; trailing extra text; lowercase variant; embedded newline plus extra text;PROTOCOL_MISMATCH; empty and null errors; whitespace-only tolerance;text/confirm/select/progresssteps nameddone; option-bearingnotenameddone; message-onlydone; non-final and impossible position metadata (5/42,43/42) plus both final forms (41/42,42/42); progress poll after the final step; replay after the final step; a later step after the final step; and thatMarksWizardCompletedis false on every rejected path so cancellation is preserved.Real behavior proof
Real paired gateway, current head.
scripts\validate-mxc-e2e.ps1ran the real WSL Gateway to Windows node path twice on this branch (once before and once after the review hardening), both green with no skips:Its setup engine journal (
TestResults\E2E\4fd5ffa0\setup-engine.jsonl) shows the full real flow at current head, including operator and node pairing,verify-e2e, and the wizard step itself completing with unchanged behavior:That run exercised the pre-existing finalization-prompt acceptance path, proving the refactored decision seam preserves it end to end on a real gateway.
Not verified / blocked. The SIGTERM finalization path itself could not be reproduced on this host: the locally installed gateway release does not terminate its hosted wizard TUI at the final step, and forcing that teardown would require pinning the exact candidate build from openclaw/openclaw #119762. The accepted and rejected paths are instead proven deterministically against the exact payload shape and step transcript captured in jobs
93130477022and93130477025. Final confirmation belongs to the repin and rerun of #119762, which is owned by the requester.Review
rubber-duck: first pass raised one blocking finding (the final step was inferred from untrusted text alone, so a non-final or answerable step nameddonecould be accepted) plus two non-blocking findings. All were fixed: the step must now be an options-free acknowledgement note,messageis no longer consulted, position metadata is enforced when present, sequencing moved into a tracker with behavioral tests, and whitespace tolerance is documented and tested. The follow-up pass confirmed no blocking issues remain and verified against upstream167c030cthat itsoutrostep is anotetitledDonewith no options and no position metadata, so both failing lanes are still accepted. Its last non-blocking suggestion (reject impossible indexes such as43/42) was applied.autoreview(Codexgpt-5.6-sol,high, branch mode vsorigin/main):autoreview clean: no accepted/actionable findings reported,overall: patch is correct (0.87).