Skip to content

fix(gateway): surface blocking startup progress - #124309

Merged
obviyus merged 42 commits into
mainfrom
fix/issue-78954-core-ready
Aug 17, 2026
Merged

obviyus merged 42 commits into
mainfrom
fix/issue-78954-core-ready

Conversation

@clawsweeper

@clawsweeper clawsweeper commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Related to #78954; intentionally does not close the broader core-ready request.

Problem

Managed Gateway startup waits for plugins, channels, workers, and sidecars. During that wait, presentation clients hid retry state: TUI looked disconnected and Control UI mounted login/error UI. Admitting clients earlier would expose an incomplete capability snapshot.

Root cause

The Gateway correctly reports startup as retryable UNAVAILABLE, but shared clients had no presentation-only startup state. Deferred startup also lacked one coherent lifecycle owner: failure and close races could mask the causative startup error, stop teardown early, double-stop or orphan sidecars, retain rejected cleanup promises, or publish work after close. The final shutdown race was an incomplete barrier: late sidecar cleanup could begin after the initial drain and outlive transport teardown. Plugin services and worker placement also had creation-to-publication gaps, including the plugin service lazy-import boundary. TUI overloaded “connection attempt failed” and “previously connected transport was lost,” so a retry before the first hello later ran reconnect-only recovery.

Fix

  • Keep admission sidecar-gated and make startupSettled truthful through plugin, channel, worker, recovery, sidecar, and ready publication.
  • Notify presentation clients only. MCP remains silent until ready.
  • Show Gateway starting… in TUI and every Control UI startup view, including manual-login retry; dedupe repeated startup snapshots.
  • Track TUI connection lineage from successful hello. Pre-hello startup retries remain startup; only post-hello transport loss triggers reconnect recovery and the reconnect notice.
  • Keep first-generation startup failures fatal and replacement-generation failures recoverable.
  • Make the Gateway lifecycle the sole sidecar owner. Shutdown coalesces concurrent/reentrant stops, drains closing-phase publications, atomically seals after producer fencing, retries rejected handles once, retains persistent failures, and retries those exact handles on a later close without replaying successful peers.
  • Publish worker and post-ready ownership in the creation turn. If close wins slow channel/plugin startup, create no post-ready tasks.
  • Publish a plugin-services proxy before the lazy import. Close intent prevents activation after import and joins any in-flight service start before cleanup.
  • Continue ordered startup-failure and public shutdown through the same final sidecar barrier before transport teardown.
  • Remove retired fire-and-forget and generic-close sidecar owners.
  • Preserve current-main error redaction and localized fallback behavior for non-startup Control UI failures.
  • No config, schema, protocol-version, capability-refresh, or plugin-contract change.

Exact proof

Head: 6dcba54b8909e2cea474eb4a6256fc7af35b2ed9

  • Merged current origin/main 16ecf0098396f522eabf0d3d59291dc5611019ea. One Control UI overlap preserved main's reload-required precedence over retryable startup presentation.
  • Exact merge-head proof: 125 focused Control UI tests passed; the combined regression forces both classifiers and proves reload scheduling, terminal phase, and visible error/code. Oxfmt, type-aware Oxlint, pnpm tsgo, pnpm tsgo:test, and git diff --check passed.
  • Exact merge-head served Control UI E2E: the changed startup-progress case passed and produced .artifacts/control-ui-e2e/gateway-starting-merge-6dcba54b/06-gateway-starting-progress.png (sha256:b6156bb9ddbcc67b3e3c870f7e1f4e60405d8a730cf2332729744aad905dc04f). Visual inspection confirms the centered Gateway starting… splash. One older configured-token case transiently missed its mocked request in the grouped run; its permitted isolation rerun passed 1/1. Hosted exact-head UI E2E is green.
  • Pre-refresh owner/sibling proof remains patch-identical outside that strengthened regression: 459 tests passed across Gateway, plugin services, worker placement, client, CLI, MCP, TUI, and Control UI.
  • Served Control UI E2E: 6 passed. Fresh screenshot: .artifacts/control-ui-e2e/gateway-starting-final-f6825fe8/06-gateway-starting-progress.png (sha256:a118c1c3c5e9b53e39cab50300ce0c48521463469f467bcd14cd0ed614e44bf6). Six matching WebM recordings are in the same evidence directory. Visual inspection confirms the centered retryable Gateway starting… splash before recovery.
  • Owner-boundary regressions cover synchronous reentrancy, publication during close and final join, transport waiting for blocked cleanup, transient retry, persistent-failure retention, later-close recovery, successful-peer non-replay, same-turn ownership transfer, close winning slow channel startup, worker unregister, plugin lazy-import cancellation, and blocked plugin-start cleanup.
  • TUI lineage regression covers startup close → first hello (not reconnect), then real post-hello disconnect → next hello (reconnect).
  • Focused type-aware Oxlint, pnpm deadcode:exports, pnpm tsgo:test, pnpm tsgo, pnpm ui:i18n:baseline, pnpm build, Oxfmt, and git diff --check: passed.
  • Distill: clean. Greybeard: clean on exact merged head.
  • Hosted CI run 31986940395: all selected exact-head jobs passed; required openclaw/ci-gate passed at 6dcba54b8909e2cea474eb4a6256fc7af35b2ed9. No required, pending, or failed checks remain.
  • Freshness resolution: GitHub reports the exact head mergeable against live main. OpenClaw fast-lane policy permits BEHIND drift and forbids refreshing solely because main advanced; refresh remains required only for CONFLICTING.
  • Exact merge-head ClawSweeper passed with zero findings, security concerns, maintainer decisions, and Rank-up moves.
  • Exact merge-head Telegram proof ran last. A fresh Gateway reached gateway ready; a real user DM (1276) received OPENCLAW_E2E_OK (1277) in 3394 ms through one mock-provider request; SIGTERM shutdown completed cleanly in 264 ms. Evidence: .artifacts/telegram-e2e/pr-124309-6dcba54b-final/summary.json (sha256:c5a086aaee2a0d208699d810f0b256c647a7264b9cce59a57e5349748b661d17).
  • Raw production/test surface: production +763/-399 (net +364); tests +1142/-240 (net +902). Production growth is startup presentation plus one canonical lifecycle ownership/barrier capability and explicit TUI connection lineage; duplicate shutdown owners were removed.

Review resolution

  • Removed unsafe early admission; broader degraded-capability design stays in Gateway/TUI startup should reach core-ready before channel/plugin sidecars #78954.
  • Fixed deferred settlement, reverse startup-log failure, shutdown continuation, late cleanup/publication, channel-start, presentation callback, manual-login, worker ownership/retry, registered-sidecar retention, and final-drain races at their lifecycle owners.
  • Addressed ClawSweeper’s sealed-sidecar P1: sealed publication rejects before mutation. Every real startup producer now registers before its first yield, and plugin services register a proxy before lazy import.
  • Addressed ClawSweeper’s TUI P2: startup retry before first hello no longer sets reconnect state; exact lineage regression preserves true transport-loss recovery.
  • Fixed CI's unused-export finding by keeping the sidecar merge helper private and moving regressions onto the canonical owner API.
  • Maintainer decision: Ayaan approved landing startup presentation and the canonical Gateway lifecycle owner as one availability-boundary repair; refreshed exact-head CI completed green.
  • No GitHub review threads remain.
  • Preserved sidecar-gated readiness, MCP behavior, and main's canonical shutdown runner.

Final gates

  • Exact pushed-head hosted CI: required openclaw/ci-gate green; no pending or failed checks.
  • Exact pushed-head ClawSweeper: zero findings, security concerns, maintainer decisions, and Rank-up moves.
  • Exact pushed-head Telegram changed-path proof: fresh startup, real-user DM/reply, and clean canonical shutdown.

No force-push performed.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: XS maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 10:13 PM ET / August 17, 2026, 02:13 UTC.

ClawSweeper review

What this changes

The PR keeps Gateway admission blocked during required startup work, shows retryable startup progress in the TUI and Control UI, and consolidates sidecar shutdown ownership.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer handling. The branch preserves startup-gated admission while adding presentation-only progress and a Gateway-owned shutdown barrier; no discrete patch defect was confirmed, but this availability-sensitive lifecycle change still needs its exact-head checks to finish.

Priority: P1
Reviewed head: 6dcba54b8909e2cea474eb4a6256fc7af35b2ed9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused owner-boundary and UI coverage with no confirmed defect; pending exact-head availability validation remains the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer/bot PR is exempt from the external-contributor proof gate; its body reports a served Control UI E2E screenshot and recordings, but no artifact was present in the supplied review scratch directory.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer/bot PR is exempt from the external-contributor proof gate; its body reports a served Control UI E2E screenshot and recordings, but no artifact was present in the supplied review scratch directory.
Evidence reviewed 7 items Deferred startup remains an owned readiness boundary: The branch creates a startup-settlement promise from sidecar work and startup logging, so the managed run loop can distinguish initial startup failure from a successful server handle.
Lifecycle ownership is centralized: The lifecycle constructs separate post-ready and lifetime sidecar owners, begins closing synchronously, and joins late cleanup before the transport close step.
Control UI preserves the higher-priority reload path: A retryable startup-unavailable close remains in the starting phase only before first connection and only when no reload-required build mismatch applies.
Findings None None.
Security None None.

How this fits together

The Gateway binds its transport, runs plugin/channel/worker sidecars, and only then admits startup-gated work. TUI and Control UI clients consume retryable startup responses to show progress without exposing an incomplete Gateway capability snapshot.

flowchart LR
  A[Gateway transport binds] --> B[Startup sidecars run]
  B --> C[Gateway lifecycle tracks ownership]
  B --> D[Retryable startup response]
  D --> E[TUI progress state]
  D --> F[Control UI progress splash]
  C --> G[Ordered shutdown barrier]
  B --> H[Ready Gateway admission]
Loading

Before merge

  • Resolve merge risk (P1) - The branch adds a single shutdown barrier across Gateway sidecar owners; a missed owner handoff could delay teardown or leave background work live, so exact-head validation remains material before merge.
  • Resolve merge risk (P1) - Reported production growth is positive for a bug-fix PR; it is plausibly justified by replacing scattered lifecycle ownership, but maintainers should confirm the new owner remains canonical rather than parallel cleanup.
  • Complete next step (P2) - This protected maintainer-owned availability PR already has an implementation path; complete exact-head validation rather than dispatching a parallel repair.
Agent review details

Security

None.

PR surface

Source +365, Tests +931. Total +1296 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 20 764 399 +365
Tests 15 1171 240 +931
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 1935 639 +1296

Review metrics

Metric Value Why it matters
Production versus test delta production +763/-399; tests +1142/-240 The reported net production growth implements shared startup presentation and a canonical lifecycle barrier, so it merits availability-focused review before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #78954
Summary: This PR addresses startup progress and lifecycle ownership without implementing the broader core-ready-before-sidecars product request.

Members:

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

Merge-risk options

Maintainer options:

  1. Complete exact-head availability validation (recommended)
    Run the pending exact-head checks and retain the served startup-progress evidence before merging the lifecycle barrier.
  2. Pause if shutdown proof regresses
    Keep the PR open if exact-head validation exposes a teardown ordering failure rather than accepting a partial shutdown guarantee.

Technical review

Best possible solution:

Land one canonical Gateway lifecycle owner only after exact-head validation confirms startup progress, readiness gating, and ordered teardown together.

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

Yes—high-confidence source reproduction exists in the focused Gateway lifecycle and Control UI retry tests, although this read-only review did not execute them.

Is this the best way to solve the issue?

Yes—the branch keeps the existing admission boundary and projects its retryable state to presentation clients, rather than exposing incomplete Gateway capabilities early.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P1: Gateway startup and shutdown behavior affects active operator clients and can make the core runtime appear unavailable.
  • merge-risk: 🚨 availability: The PR changes deferred startup settlement and the ordering of sidecar cleanup before transport teardown.
  • 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: This maintainer/bot PR is exempt from the external-contributor proof gate; its body reports a served Control UI E2E screenshot and recordings, but no artifact was present in the supplied review scratch directory.

Evidence

What I checked:

  • Deferred startup remains an owned readiness boundary: The branch creates a startup-settlement promise from sidecar work and startup logging, so the managed run loop can distinguish initial startup failure from a successful server handle. (src/gateway/server-startup-post-attach.ts:1640, 6dcba54b8909)
  • Lifecycle ownership is centralized: The lifecycle constructs separate post-ready and lifetime sidecar owners, begins closing synchronously, and joins late cleanup before the transport close step. (src/gateway/server-lifecycle.ts:464, 6dcba54b8909)
  • Control UI preserves the higher-priority reload path: A retryable startup-unavailable close remains in the starting phase only before first connection and only when no reload-required build mismatch applies. (ui/src/app/gateway-store.ts:443, 6dcba54b8909)
  • Changed behavior has boundary-level coverage: The branch tests the retryable startup splash and verifies no login gate mounts before automatic recovery; the lifecycle test also exercises reentrant publication, failures, and late cleanup. (ui/src/e2e/initial-connect-splash.e2e.test.ts:232, 6dcba54b8909)
  • Existing Control UI close policy provenance: The current-base close classifier and reload-required precedence date to the current-main commit shown by blame, which the branch explicitly retains. (ui/src/app/gateway-store.ts:431, b8a95e082bbf)
  • Current-main overlap check: The commits between the PR base and current main change dashboard-session and doctor/docs paths, not the reviewed Gateway startup, TUI, client, or Control UI gateway-store paths. (a23d19218c5b)

Likely related people:

  • steipete: Current-base blame attributes the Control UI close/retry/reload decision surface to Peter Steinberger’s merged retryability fix. (role: recent current-main owner of Control UI connection-close behavior; confidence: high; commits: b8a95e082bbf; files: ui/src/app/gateway-store.ts)
  • obviyus: Ayaan Zaidi authored the reviewed branch head and is the recorded assignee for this availability-boundary repair. (role: recent Gateway lifecycle contributor and assigned reviewer; confidence: medium; commits: 6dcba54b8909; files: src/gateway/server-lifecycle.ts, src/gateway/server-sidecar-owners.ts, src/gateway/server-startup-post-attach.ts)

Rank-up moves

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

  • Finish the pending exact-head hosted checks before merge.

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 (30 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-16T15:28:23.657Z sha 36a23a1 :: needs changes before merge. :: [P1] Retain failed sidecars for canonical teardown retry
  • reviewed 2026-08-16T15:55:58.720Z sha 0e858a7 :: needs changes before merge. :: [P1] Join late sidecar cleanup before returning from close
  • reviewed 2026-08-16T16:16:07.353Z sha 5f650dd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T16:51:37.884Z sha 53dd52f :: found issues before merge. :: [P1] Reject post-seal sidecars instead of retaining them
  • reviewed 2026-08-16T17:10:28.630Z sha dc1b1f4 :: needs changes before merge. :: [P1] Reject sealed sidecars before registering them
  • reviewed 2026-08-16T17:42:59.586Z sha 4d65297 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T18:06:58.158Z sha f6825fe :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T18:49:36.994Z sha f6825fe :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Aug 16, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

3 participants