Skip to content

fix(process): keep old cleanup failures from blocking Gateway shutdown - #196823

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-service-child-cleanup-poisons-shutdown-20260919
Nov 10, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-service-child-cleanup-poisons-shutdown-20260919

Conversation

@steipete

@steipete steipete commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Gateway shutdown rejecting an old service-child cleanup error after the originating run has already finished, even when its native process tree has subsequently disappeared.

User Impact

Later shutdown reports the earlier cleanup failure as a warning and can finish draining current work. The original run and scope still receive their failed cleanup result. A failure while shutdown is joining a current run still rejects shutdown.

Why This Change Was Made

The supervisor already removes terminal cleanup attempts from its owned-run set, but its process-wide first-error latch was rethrown on every later shutdown. That historical diagnostic was therefore reported as live plugin-runtime ownership. Keep the diagnostic without replaying it as a new shutdown failure. Native signaling, descendant reaping, receipts, output drainage, and deadlines are unchanged; runtime production LOC is -3. Shutdown now calls the existing complete admission join once instead of wrapping it in a redundant outer retry loop.

The deadline's pending fields are negated conditions: stdoutEnd:false means stdout already ended. Linux descendant extinction is established by the subreaper's kernel wait returning ECHILD, independently of pipe EOF. Background sleep, setsid, and nohup remain owned and are reaped on cancellation.

Evidence

Final Codex autoreview of the full local diff against 6d811790acb43 is scoped-clean through P2, with complete supervisor context and no accepted/actionable findings. The originating production native stall is not established by this fixture. No production deployment or live-data copying occurred.

The initial PR CI exposed five stale historical-shutdown assertions. Commit 192617895f7d0 updates the CLI construction, one-shot tools, forced settlement, and source-loaded matrix consumers to retain failure on the original run/scope and let later shutdown finish. The awaited-output fixture now starts shutdown before injecting failure, preserving active-join rejection coverage. All five files pass locally on Linux (16 tests); final awaited-output also passes all eight tests on macOS. Focused lint, formatting, tooling typecheck, and fresh Codex autoreview through P2 pass. This follow-up adds zero test lines and changes no production code.

Initial CI run 42884793648 also fails the test-line ratchet by 128 lines on merge 656842736defbeab7a3351a3672c5e465e586bad. This is independently reproduced on exact main parent 924a3bc9ffb3d359fc3a8709768ef0e2fa305d91 (6,635,176 total / 6,635,048 ceiling). Causal proof: #196346 / b91520c16b620adf2222b6f9aa245d61b3e0d139 adds 138 test lines without allocation; its parent e2c3702f6758760842dc649232188873e273b100 passes with ten lines slack, and the introducing commit fails by 128. This PR adds exactly 81 lines and 81 allocation, preserving that debt. This is a main regression for follow-up, not a passing broad gate.

Final-head status at 192617895f7d0065115abe7f4c95683f8ffc75bc: CI run42887726734 is complete. All test, lint, and security-fast jobs pass; only test-lines in baseline-ratchets and its downstream CI gate fail. Final CI checkout 5da4f97bfc79bce785d66b782a64f9f29a1bf75f merges this head into exact main 0c5c4754c33dd9a9e7f4eb4493d4472d458a4609; the canonical ratchet reproduces the same128 debt on that exact main parent (6,635,176 /6,635,048), with the green-to-red introducing commit above. The pinned-head inherited-failure exception is selected; failed CI is not represented as green. ClawSweeper final-head review reports zero findings/open items and no before-merge requirements. Full deployed Gateway stop/restart remains production follow-through.

Preserve failed cleanup for its original run and scope, but warn instead of replaying that terminal failure as live ownership at a later shutdown. Keep current-run cleanup rejection and use the existing complete admission join once.

Prove the deadline failure with a real Linux subreaper and background descendants, then verify native retirement before clean shutdown. Correct the related realtime-signal fixture for Node runtimes that ignore signal 34.
@clawsweeper

clawsweeper Bot commented Nov 10, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T19:43:05.213995Z 1926178 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab83dc12d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/process/supervisor/supervisor.ts Resolved
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Nov 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review final head 192617895f7d0065115abe7f4c95683f8ffc75bc. The follow-up fixes the five historical-shutdown test consumers found by CI and preserves error assertions on their originating run/scope. The active-shutdown fixture starts its join before injecting failure. All five files pass locally on Linux (16 tests), final awaited-output passes eight tests on macOS, and fresh Codex autoreview is clean through P2. Production code is unchanged from the prior review request; runtime LOC remains -3.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR warns about historical process-cleanup failures while preserving original run errors and failures encountered during shutdown.

Example: A Linux command exceeds a 100ms cleanup deadline, then its owner and descendant disappear before Gateway shutdown.

  • Before: Shutdown rethrows the earlier hard-deadline error despite the process tree having retired.
  • After: Shutdown warns about the earlier failure and completes; the originating run and scope still reject cleanup.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is source-consistent with no actionable findings; evidence is strongest at the native supervisor boundary rather than the shipped Gateway lifecycle.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its reported Linux native-owner probe and regression exercise historical failure retirement, while inspected screenshots concern unrelated browser pairing.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Gateway shutdown can report an old cleanup failure after the corresponding process tree has disappeared.
Reason: The maintainer-authored direction explicitly separates historical diagnostics from current ownership, and the focused patch preserves the original run/scope failures.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current shutdown failure, and the final head addresses the earlier consumer-test findings without introducing a new actionable defect.

Priority: P2
Reviewed head: 192617895f7d0065115abe7f4c95683f8ffc75bc

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A full Gateway stop/restart after the historical cleanup failure is not demonstrated; supplied evidence exercises the real supervisor and native descendants.
Agent review details

How this fits together

The process supervisor owns subprocess admissions, cancellation, and extinction joins; Gateway lifecycle cleanup consumes its shutdown result.

flowchart TD
  A[Gateway lifecycle] --> B[Process supervisor]
  B --> C[Admission fence and cancellation]
  C --> D[Current process extinction joins]
  D --> E[Shutdown result]
  B --> F[Historical cleanup diagnostic]
  F --> G[Warning log]
Loading

Technical review

Best possible solution:

Keep historical errors with their originating owners, warn during later shutdown, and continue rejecting cleanup failures observed by the active shutdown join.

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

Current main retains and rethrows a terminal cleanup failure after removing its admission; the supplied Linux regression reports base failure and fixed success, but no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing supervisor and complete admission join, preserves original failure ownership, and removes redundant shutdown looping without adding another cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 474b4cebd95f.

Provenance checked

  • Historical supervisor cleanup failure changes intended behavior with a stated reason (220578b: Retain cleanup uncertainty after adapter retirement so later shutdown cannot incorrectly certify successful cleanup.)
  • Shutdown cancellation and admission draining keeps the original intent (35c11ae: Fence admissions and drain supervised process trees before Gateway restart; the existing join already rechecks pending startups.)
  • Native subreaper signal fixture keeps the original intent (698cac4: Verify native adopted-child reaping through proc-safe; the fixture correction preserves extinction assertions while using a signal the tested Node runtime does not ignore.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 220578b adds src/process/supervisor/supervisor.ts:456 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 220578ba3408; files: src/process/supervisor/supervisor.ts)
  • Alix-007: Raw commit 35c11ae adds src/process/supervisor/supervisor.ts:149 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 35c11ae4ae2a; files: src/process/supervisor/supervisor.ts)

PR surface

Source -3, Tests +81, Docs +3, Other +2. Total +83 across 16 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 13 16 -3
Tests 12 107 26 +81
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 16 125 42 +83

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +13/-16; tests/support +107/-26 Production shrinks by three lines; the 81 net test lines cover native descendant retirement, background-process controls, and historical-warning behavior, with matching allocation.

Labels

Label changes:

  • add P2: A prior cleanup failure can incorrectly reject a later Gateway shutdown; the repair is focused and preserves active cleanup failure reporting.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A prior cleanup failure can incorrectly reject a later Gateway shutdown; the repair is focused and preserves active cleanup failure reporting.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 10, 2026, 2:48 PM ET / 19:48 UTC.

@steipete
steipete merged commit 22b29a7 into main Nov 10, 2026
152 of 157 checks passed
@steipete
steipete deleted the steipete/perf-micro-service-child-cleanup-poisons-shutdown-20260919 branch November 10, 2026 19:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
openclaw#196823)

* fix(process): keep old cleanup failures from blocking Gateway shutdown

Preserve failed cleanup for its original run and scope, but warn instead of replaying that terminal failure as live ownership at a later shutdown. Keep current-run cleanup rejection and use the existing complete admission join once.

Prove the deadline failure with a real Linux subreaper and background descendants, then verify native retirement before clean shutdown. Correct the related realtime-signal fixture for Node runtimes that ignore signal 34.

* test(process): account for formatted cleanup regression lines

* test(process): retain cleanup errors on their originating owners
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…penclaw#196823)

Backport of 22b29a7.

Release adaptation: supervisor current-owner join, historical warning and affected consumer regressions only; omit docs and allocation. Preserve current cleanup rejection and native identity proof.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 8595eacf8932bea50351ee2f4ade74617c1647ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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