Skip to content

fix(gateway): cancel dashboard preparation during shutdown - #145118

Merged
steipete merged 1 commit into
mainfrom
codex/control-ui-preparation-drain-20260911
Sep 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/control-ui-preparation-drain-20260911

Conversation

@steipete

@steipete steipete commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144252

What Problem This Solves

Fixes an issue where stopping a Gateway soon after startup could wait for background dashboard asset preparation before reaching the cleanup that cancels it. On a busy host this could exceed the process supervisor’s shutdown grace period.

Why This Change Was Made

Each Control UI preparation now observes the current Gateway drain signal alongside its existing stop/disable signal. The Gateway still counts and awaits cleanup; a later preparation captures its own drain generation.

User Impact

Shutdown cancels unfinished dashboard builds and asset retention instead of waiting for that background work to finish normally. Existing cancellation, publication fencing, and dashboard re-enablement remain intact.

Evidence

Both build and retention regressions fail on the original owner. The candidate passes 35 lifecycle, serving-identity, and real-retention tests, plus the selected type, lint, and repository checks. Independent Codex review completed scoped-clean through P2.

Real filesystem integration on this main-based candidate interrupted a copy after 6.1 MiB: cleanup left zero admitted roots, no staging directory or late publication, and no warnings. A fresh generation then retained and hash-verified two assets totaling 80 MiB. The process exited naturally and all synthetic fixtures were removed. This exercises the actual source owner and filesystem, not a compiled full-Gateway run.

The original investigation’s three native scenarios served plugin RPCs and health successfully but exceeded their unchanged ten-second shutdown grace. An observation-only replay identified this asset-preparation root and later exited naturally; those earlier failures remain qualified evidence rather than passing candidate runs.

Production grows by six lines to compose the existing cancellation signals; tests grow by 66. No configuration, schema, or timeout changes.

Exact-head required CI passed on ac36b193 in run 34630743135, attempt 2. Attempt 1 timed out in the unchanged profiler CLI help test; its single retry passed without changing the test or timeout. Follow-up: investigate the profiler-help startup hang if it recurs; its cause remains unattributed.

@steipete steipete self-assigned this Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 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 gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 11, 2026
@steipete
steipete marked this pull request as ready for review September 11, 2026 17:59
@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 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 2:05 PM ET / 18:05 UTC (Revision 2).

ClawSweeper review

What this changes

Cancels background dashboard asset builds and retention when Gateway shutdown begins, with regression coverage for cleanup and subsequent preparation generations.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and v2026.9.4 still lack drain-triggered dashboard preparation cancellation. The reviewed patch preserves cleanup ownership, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: ac36b1933ec202d689586d064affeb1ce9c314bc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and appropriately scoped filesystem observations.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured evidence reports the changed lifecycle using real filesystem retention, successful cancellation cleanup, and recovery in a fresh generation; it does not claim a passing compiled-Gateway shutdown replay.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured evidence reports the changed lifecycle using real filesystem retention, successful cancellation cleanup, and recovery in a fresh generation; it does not claim a passing compiled-Gateway shutdown replay.
Evidence reviewed 9 items Introduced cancellation change: The pinned introduction diff adds the current drain signal to the existing preparation controller. The verified test merge has the supplied main and head as its ordered parents, and its production diff contains the same focused change.
Current main still needs the fix: Current main passes only the lifecycle controller signal to preparation; that controller is aborted by disable or stop, rather than the earlier process drain.
Latest release check: The v2026.9.4 source also uses only the preparation controller signal, so the latest supplied release does not contain this cancellation fix.
Findings None None.
Security None None.

How this fits together

The Gateway prepares dashboard assets in background work after startup. Shutdown must cancel unfinished preparation while continuing to count and await its cleanup before closing the server.

flowchart TD
  A[Gateway startup] --> B[Dashboard preparation]
  C[Shutdown drain] --> D[Combined cancellation signal]
  E[Dashboard disable or stop] --> D
  D --> B
  B --> F[Build or retain assets]
  F --> G[Await cleanup and release admitted work]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +6, Tests +66. Total +72 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 2 +6
Tests 1 66 0 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 74 2 +72

Review metrics

None.

Technical review

Best possible solution:

Keep cancellation in the existing dashboard lifecycle, observe each current drain generation, and await cleanup before releasing admitted work.

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

Yes, source establishes the trigger: stop the Gateway while admitted dashboard preparation is unfinished, and drain waits before the stop hook can cancel it. This read-only review did not execute tests or reproduce the runtime failure.

Is this the best way to solve the issue?

Yes. Composing the existing cancellation signals repairs the ordering gap without bypassing cleanup, adding a competing owner, or changing shutdown timeouts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 58a6953549d0.

Labels

Label justifications:

  • P2: This fixes a bounded shutdown delay when background dashboard preparation is still running.
  • 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. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured evidence reports the changed lifecycle using real filesystem retention, successful cancellation cleanup, and recovery in a fresh generation; it does not claim a passing compiled-Gateway shutdown replay.

Evidence

What I checked:

  • Introduced cancellation change: The pinned introduction diff adds the current drain signal to the existing preparation controller. The verified test merge has the supplied main and head as its ordered parents, and its production diff contains the same focused change. (src/gateway/server-control-ui-root.ts:186, ac36b1933ec2)
  • Current main still needs the fix: Current main passes only the lifecycle controller signal to preparation; that controller is aborted by disable or stop, rather than the earlier process drain. (src/gateway/server-control-ui-root.ts:180, 58a6953549d0)
  • Latest release check: The v2026.9.4 source also uses only the preparation controller signal, so the latest supplied release does not contain this cancellation fix. (src/gateway/server-control-ui-root.ts:180, 3a9d69db306c)
  • Shutdown ordering and signal ownership: The CLI marks drain synchronously for stop and restart before waiting for active work. The admission owner aborts its drain controller, while independent roots remain counted until their operation settles. Dashboard startup uses that independent-root wrapper. (src/process/gateway-work-admission.ts:289, ac36b1933ec2)
  • Cancellation reaches existing filesystem cleanup: Retention checks cancellation during reads and writes, closes file handles in finally, and removes staging directories in finally. The patch reuses this existing contract without changing persisted formats or retention policy. (src/gateway/control-ui-asset-retention.ts:56, ac36b1933ec2)
  • Regression coverage: The added table covers build and retention across two drain generations, asserting immediate cancellation, retained admission through delayed cleanup, stable serving state, and no cancellation warnings. Existing cases cover disable/re-enable and late build publication. (src/gateway/server-control-ui-root.resolve.test.ts:139, ac36b1933ec2)

Likely related people:

  • Peter Steinberger: 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 (1 earlier review cycle)
  • reviewed 2026-09-11T17:58:47.375Z sha ac36b19 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit b78d472 into main Sep 11, 2026
377 of 379 checks passed
@steipete
steipete deleted the codex/control-ui-preparation-drain-20260911 branch September 11, 2026 18:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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