Skip to content

fix(gateway): finish cleanup after sidecar failures - #117646

Closed
IWhatsskill wants to merge 1 commit into
openclaw:mainfrom
IWhatsskill:fix/gateway-sidecar-stop-rejections
Closed

IWhatsskill wants to merge 1 commit into
openclaw:mainfrom
IWhatsskill:fix/gateway-sidecar-stop-rejections

Conversation

@IWhatsskill

@IWhatsskill IWhatsskill commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

[AI-assisted]

Summary

Repair Gateway startup and shutdown cleanup at the lifecycle owner boundary.

  • preserve the initiating startup error even when cleanup rejects or throws
  • transfer and clear both registered sidecar groups before stopping them
  • attempt every sidecar stop and every later Gateway cleanup step
  • log every cleanup failure, then throw the first cleanup failure only after explicit close completes
  • keep post-fence close-prelude owners running when the initial fence join rejects
  • contain synchronous and asynchronous failures from late-published sidecars
  • keep Gmail hot reload scoped to post-ready sidecars, preserving gateway-lifetime owners
  • remove the duplicate sidecar-stop loop from server-close.ts

No new sidecar helper module, retry stack, generation framework, or downstream guard is added.

What Problem This Solves

Registered sidecars had split cleanup ownership. A sidecar stop rejection could abort the remaining Gateway cleanup contract, while startup teardown could replace the root startup failure with cleanup noise.

The first repair still had two owner-boundary holes:

  1. runClosePrelude rejoined the memoized close fence after the outer cleanup sequence had already caught its rejection, which could skip node notifications, watch-node HTTP shutdown, metadata cache clearing, and the remaining close prelude.
  2. Gmail hot reload was wired to the full registered-sidecar drain, which could stop gateway-lifetime owners during a watcher restart.

The lifecycle owner now separates the fence join from post-fence cleanup and exposes a post-ready-only drain for hot reload. Full close and startup rollback still drain both sidecar classes. Startup reports its initiating error; explicit close reports the first cleanup error only after every cleanup step has been attempted.

Evidence

Exact base: b5180b68163a0dec24ac7615b81e7f12aadbd5e2
Exact head: 0f2e9064ca10e14bb0920c955c92a73d5654f940

  • lifecycle/start cleanup regressions: 2 files, 6 tests passed
  • exact Gmail hot-reload regressions: 1 file, 2 tests passed
  • structural owner-boundary regression: 1 test passed
  • targeted oxfmt: clean
  • targeted oxlint: clean
  • git diff --check: clean
  • exact-diff autoreview: no actionable findings
  • independent full-branch exact-head review: no actionable findings (0.96)

Hosted exact-head CI and exact-head ClawSweeper remain the final gates.

Scope

  • production: +126 / -70, net +56
  • tests: +394 / -70, net +324

The positive production delta is the lifecycle-owned sequential cleanup contract shared by startup failure and explicit close, sync/async late-stop diagnostics, and the separate post-ready-only reload owner. The connected duplicate close ownership was removed in the same change.

Credit

The editable contributor branch was rebuilt in place. The signed commit preserves IWhatsskill as author and Peter Steinberger as co-author.

Punchcard

Punchcard-Session: amber-workshop-workshop-36

PR attestation receipt:

pc1.cHVuY2hjYXJkLXNlcnZlci1yZWNlaXB0LXYxAGF0dF8wMUtaR1lUMlZYWDRZQ1Q5WlpBRDBUQ1g4NQB0bnRfMDFKMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAAdXNyXzAxSjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxAGRldl9FMDNCQTNBOENDNzdGOUQ5QjFCRTI3RTE5MgB3cmtfMDFLWkFCN1pDVzBHRktKTVI5QTdKRjA2MlQAc2VzXzAxS1pGWE42TVBWRDRBMzM2VlZDWVdHUDQ1AGFtYmVyLXdvcmtzaG9wLXdvcmtzaG9wLTM2AG9wZW5jbGF3L29wZW5jbGF3AAAxMTc2NDYAZGZjNzYwZDFhZmZkYjg5ZGU1Zjc3NmE2NTgxNmFkNjUzNzM3MDg2NTgxNGQ3NTFkMzQyZmRlNTVmMmNiN2ViOABzaWduaW5nLXYxADJTR1hwTUFXS2lsWE9NQVloSVJ1R0xZNDUtQTBqUW9TUHN1Z2VFLXVKNk9HREJCMjJVWFA5ZTFwb3hwWHVuRUZoNVlyakoxS0lCRzB4aUk5SWs1UkJ3ADIwMjYtMDgtMDhUMTU6MTA6MzYuNDEzWgA.fxfOAUlWOOcbEJ22W7TKjJSMMVeSGsHa_CLm_NuLCBjCIoacBFnAjopQ3y-JlLio9G3cGU-W_x49Zs4rWBSuAA

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Aug 1, 2026
@IWhatsskill
IWhatsskill marked this pull request as ready for review August 1, 2026 21:36
@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. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Current main already contains this PR’s head and subsequently strengthens the same Gateway sidecar-cleanup owner boundary, so there is no remaining branch behavior to merge.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Retain current main’s lifecycle-owned stop, seal, and shutdown sequence rather than reviving this obsolete branch.

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

No high-confidence live reproduction is available; the submitted mocked lifecycle tests and current source establish the cleanup path, while current main already contains the repair.

Is this the best way to solve the issue?

Yes: current main solves the central cleanup-continuation problem through a stronger lifecycle-owner design, so merging this stale branch is not the best path.

Security review:

Security review cleared: The diff changes local Gateway lifecycle sequencing only; it adds no dependency, secret, permission, or authority boundary.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • steipete: Recent Gateway lifecycle history includes lifecycle-owned ambient-state and post-ready maintenance work that led into the current owner boundary. (role: recent lifecycle contributor; confidence: medium; commits: 357087b9, 1b841195; files: src/gateway/server-lifecycle.ts, src/gateway/server-start.ts)
  • vincentkoc: Merged the adjacent sidecar ownership and fixture-isolation follow-up. (role: adjacent sidecar-test contributor; confidence: medium; commits: 7f9364c5e1e2; files: src/gateway/server-startup-post-attach.test.ts)

Codex review notes: model internal, reasoning high; reviewed against b7cafbe7e826; fix evidence: commit 0f2e9064ca10, main fix timestamp 2026-08-08T14:08:22Z.

@steipete steipete self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 1, 2026
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 2, 2026
@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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 5, 2026
@vincentkoc
vincentkoc force-pushed the fix/gateway-sidecar-stop-rejections branch from 9a55601 to 2722514 Compare August 8, 2026 14:59
@vincentkoc vincentkoc self-assigned this Aug 8, 2026
@vincentkoc vincentkoc changed the title fix(gateway): contain late sidecar stop failures fix(gateway): finish cleanup after sidecar failures Aug 8, 2026
@vincentkoc
vincentkoc marked this pull request as draft August 8, 2026 15:01
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 8, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Co-authored-by: Peter Steinberger <[email protected]>
Punchcard-Session: amber-workshop-workshop-36
@vincentkoc
vincentkoc force-pushed the fix/gateway-sidecar-stop-rejections branch from 2722514 to 0f2e906 Compare August 8, 2026 15:10
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Aug 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants