Skip to content

fix: stop Gateway shutdown waiting on abandoned setup prompts - #139783

Merged
steipete merged 1 commit into
mainfrom
codex/wizard-shutdown-drain
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/wizard-shutdown-drain

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where stopping or restarting a Gateway could wait for the full drain budget after an operator left an interactive setup prompt unanswered. Shutdown had already stopped accepting answers, while the wizard still retained its work and setup-lock ownership.

Why This Change Was Made

Wizard admission now binds to the existing Gateway generation and committed drain signal before setup-lock acquisition can yield. Shutdown closes the prompt input lifetime, and the Gateway tracks the existing settlement promise until the runner and target-lock cleanup finish. Ordinary socket disconnects remain reconnectable.

Lifecycle closure is distinct from user cancellation. Writes past their cancellation lock finish normally; pending and future prompts stop waiting for a client that cannot answer. Classic setup can already have saved settings without taking that cancellation lock, so shutdown records its own error rather than claiming a user cancellation. Genuine later write failures retain their diagnostic.

User Impact

An abandoned setup prompt no longer strands Gateway stop or restart. After the Gateway starts again, operators can reopen setup and inspect their saved settings. Configuration, persistence formats, protocol versions and drain budgets are unchanged.

Production grows by 46 lines across the two existing owners; tests grow by 467 lines, including reuse of the existing Gateway fixture, and docs by 5. The new input lifetime and exact cleanup binding require that production growth; there is no new run-loop layer or duplicate shutdown path.

Evidence

  • Captured four failing owner regressions on unchanged code, then additional failing cases for an unlocked real settings write followed by an outro and a provider translating closure into cancellation.
  • Final focused run: 131 tests passed across seven files, including real Gateway WebSocket disconnect/reconnect followed by process drain and direct server close. Original file order and the existing 90-second timeout were preserved. The final combined replay completed the two shutdown cases in 504ms and 433ms.
  • The first cold integration run timed out the existing cancellation baseline during heavy transform/import work. The full original-order replay passed unchanged; its existing baseline completed in 14.4 seconds. The documented source-fixture mode avoids rebuilding unrelated private-QA artifacts and still starts the real source Gateway.
  • The complete changed-file gate passed: core and test types, formatting, lint, dead exports and selected ownership/schema/import guards.
  • Independent review is clean through P2. Exact-head CI passed all 132 checks, with 42 intentional skips and a successful openclaw/ci-gate. The latest ClawSweeper review has no findings or before-merge actions.
  • Prior CI exposed an unrelated stale session-history test fixture already repaired in main by fix(gateway): align history test fixture with projection state #139794; this branch includes that fix through rebase. An unrelated profiler test timed out on the old run; its unchanged file passed 34/34 in 19.38 seconds under the original timeout. No product or test timeout was increased.

Native live proof

Crabbox run 34014138751, provider blacksmith-testbox, lease tbx_01m1tk40syn8mwrdr3k0v0am0p. A real Tauri app opened the Ollama setup wizard and left the Local only choice unanswered. Native tray Stop completed in 1.241 seconds, with the real Gateway process gone and its health port closed; tray Start restored it in 4.128 seconds. The CLI receipt was gateway stop --json --force, non-TTY stdin/stdout, exit 0, ok:true, result:stopped.

This combined candidate used base 883d4d65bad1791755c203a8dfd854e14b4f6e33 with the reviewed changes from this PR and #139664; the two setup runtime owner files are byte-identical to this PR head. Native GUI proof is Linux; no macOS/Windows service-manager claim is made. Screenshots contain only synthetic task data.

Pending real provider prompt:

Unanswered local model setup prompt

After native Stop:

Gateway stopped and app standing by

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority 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 Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 2:49 AM ET / 06:49 UTC.

ClawSweeper review

What this changes

The PR closes interactive setup prompts during Gateway shutdown while preserving in-progress writes, cleanup ownership, and reconnects during normal operation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on the supplied current main and v2026.9.2. No actionable introduced defect was found, and the supplied behavior evidence supports the repair. The maintainer-authored PR remains open for normal landing.

Priority: P2
Reviewed head: eed4ac8fe195008d9b5921259abc5de0f18f7315

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with useful real behavior evidence, extensive lifecycle regressions, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured Linux native run reports stopping an unanswered Ollama setup prompt, process and port termination, and successful restart using matching setup-owner files; real-Gateway socket coverage supplements it. Linked artifacts were unreachable here, and the report explicitly covers a combined candidate rather than isolated cross-platform proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured Linux native run reports stopping an unanswered Ollama setup prompt, process and port termination, and successful restart using matching setup-owner files; real-Gateway socket coverage supplements it. Linked artifacts were unreachable here, and the report explicitly covers a combined candidate rather than isolated cross-platform proof.
Evidence reviewed 9 items Introduced production changes: The pinned merge-base comparison introduces shutdown binding in setup admission and input closure in WizardSession; unrelated base-branch changes were excluded.
Current-main necessity: Current main retains wizard work until settlement but does not bind that wizard to the Gateway close or committed drain signal, leaving unanswered prompts able to retain work during shutdown.
Latest-release comparison: The supplied latest release contains the same admission implementation without shutdown prompt closure; no shipped replacement was established.
Findings None None.
Security None None.

How this fits together

Gateway setup turns client requests into interactive prompts and settings operations. Its lifecycle owner must stop accepting answers during shutdown while retaining responsibility for unfinished operations and lock cleanup.

flowchart TD
  A[Setup client] --> B[Setup admission]
  B --> C[Interactive wizard]
  D[Gateway stop or restart] --> E[Close prompt input]
  E --> C
  C --> F[Finish writes and cleanup]
  F --> G[Release work and setup lock]
  G --> H[Gateway shutdown completes]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +46, Tests +467, Docs +5. Total +518 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 64 18 +46
Tests 2 580 113 +467
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 649 131 +518

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +46 lines; tests net +467 lines Production growth implements input closure and cleanup ownership in existing owners; the larger test delta covers lifecycle races and preserved behavior.

Technical review

Best possible solution:

Keep prompt lifetime under the existing Gateway owner, allowing committed operations and lock cleanup to settle before releasing their resources.

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

Yes, from source: leave an admitted setup prompt unanswered, disconnect, then stop or restart the Gateway; current main retains the runner without closing its pending input. This reviewer did not execute that scenario.

Is this the best way to solve the issue?

Yes. The patch repairs the existing admission and prompt owners without adding a competing shutdown path, changing drain budgets, or releasing cleanup ownership early.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2a488546aabe.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured Linux native run reports stopping an unanswered Ollama setup prompt, process and port termination, and successful restart using matching setup-owner files; real-Gateway socket coverage supplements it. Linked artifacts were unreachable here, and the report explicitly covers a combined candidate rather than isolated cross-platform proof.

Label justifications:

  • P2: An unanswered setup prompt can delay an operator-requested stop or restart until the drain budget expires.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured Linux native run reports stopping an unanswered Ollama setup prompt, process and port termination, and successful restart using matching setup-owner files; real-Gateway socket coverage supplements it. Linked artifacts were unreachable here, and the report explicitly covers a combined candidate rather than isolated cross-platform proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Linux native run reports stopping an unanswered Ollama setup prompt, process and port termination, and successful restart using matching setup-owner files; real-Gateway socket coverage supplements it. Linked artifacts were unreachable here, and the report explicitly covers a combined candidate rather than isolated cross-platform proof.

Evidence

What I checked:

  • Introduced production changes: The pinned merge-base comparison introduces shutdown binding in setup admission and input closure in WizardSession; unrelated base-branch changes were excluded. (src/gateway/server-methods/setup-admission.ts:73, eed4ac8fe195)
  • Current-main necessity: Current main retains wizard work until settlement but does not bind that wizard to the Gateway close or committed drain signal, leaving unanswered prompts able to retain work during shutdown. (src/gateway/server-methods/setup-admission.ts:59, 2a488546aabe)
  • Latest-release comparison: The supplied latest release contains the same admission implementation without shutdown prompt closure; no shipped replacement was established. (src/gateway/server-methods/setup-admission.ts:59, 3928bad9badf)
  • Write and outcome preservation: Closing rejects pending and future answers, preserves the cancellation lock around committed operations, and retains genuine later failures instead of replacing them with a cancellation outcome. (src/wizard/session.ts:412, eed4ac8fe195)
  • Regression coverage inspected: Owner tests cover delayed cleanup, locked writes, saved classic settings, reversible fences, acquisition/construction races, translated cancellation, and listener release. Real-socket tests cover disconnect/reconnect followed by process drain and direct server close. Tests were inspected, not executed during this read-only review. (src/gateway/server-methods/setup-admission.test.ts:131, eed4ac8fe195)
  • Captured live behavior evidence: The supplied body snapshot, sourceRevision f8d6d1083c24e78cc511657f0227727321bd12bd6d7b6c4cec8b6627a25c3f33, reports a real Linux Tauri/Ollama unanswered prompt, native Stop in 1.241 seconds with process disappearance and health-port closure, and Start recovery in 4.128 seconds. It identifies a combined candidate and states both changed runtime owners match this head byte-for-byte. See https://github.com/openclaw/openclaw/actions/runs/34014138751. GitHub API and attachment retrieval failed in this reviewer environment, so linked media and candidate identity were not independently verified; the supplied report remains the evidence source.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-06T05:47:49.194Z sha 7680e0019beb348a44c22209b75439f79eb1b1c8 :: blocked before merge. :: none
  • reviewed 2026-09-06T06:10:30.825Z sha eed4ac8 :: needs maintainer review before merge. :: none

Bind admitted wizards to the existing Gateway lifetime and committed
process drain signal. Keep runner and setup-lock settlement owned until
cleanup finishes, while preserving normal socket reconnect behavior.

Separate lifecycle closure from user cancellation and retain real write
failures. No config, schema, protocol or drain-budget changes.

Validated with 131 owner and real-socket tests, changed-file gates,
and independent review through P2.
@steipete
steipete force-pushed the codex/wizard-shutdown-drain branch from 7680e00 to eed4ac8 Compare September 6, 2026 06:05
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 6, 2026
@steipete
steipete merged commit 9739f45 into main Sep 6, 2026
182 checks passed
@steipete
steipete deleted the codex/wizard-shutdown-drain branch September 6, 2026 06:52
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…39783)

Bind admitted wizards to the existing Gateway lifetime and committed
process drain signal. Keep runner and setup-lock settlement owned until
cleanup finishes, while preserving normal socket reconnect behavior.

Separate lifecycle closure from user cancellation and retain real write
failures. No config, schema, protocol or drain-budget changes.

Validated with 131 owner and real-socket tests, changed-file gates,
and independent review through P2.
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 20, 2026
…39783)

Bind admitted wizards to the existing Gateway lifetime and committed
process drain signal. Keep runner and setup-lock settlement owned until
cleanup finishes, while preserving normal socket reconnect behavior.

Separate lifecycle closure from user cancellation and retain real write
failures. No config, schema, protocol or drain-budget changes.

Validated with 131 owner and real-socket tests, changed-file gates,
and independent review through P2.

(cherry picked from commit 9739f45)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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