Skip to content

fix: finish process-owned shutdown within its cleanup deadline - #187090

Merged
steipete merged 1 commit into
mainfrom
codex/shutdown-bounded-followups
Oct 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/shutdown-bounded-followups

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes shutdowns that remain blocked in native wrapper cleanup after the bounded Gateway close has finished, and maintenance handoffs that can expire before the native service stop.

User Impact

Process-owned shutdown respects its existing cleanup deadline and identifies retained sidecar owners. Embedded hosts still join cleanup fully. Subagent termination finishes its internal cleanup after admission closes, and the deployment controller commits shutdown before stopping the service.

Why This Change Was Made

The wrapper now bounds read-only-worker and Linux admission/broker cleanup with the process owner's existing deadline, while the underlying ordered cleanup continues. Fatal core close errors survive an additional cleanup timeout. Existing shutdown tracing supplies sidecar names; no new shutdown subsystem, configuration, dependencies, or persisted shapes are introduced.

The controller uses the existing commit: true handoff after its live custody checks, including READY suspensions, and stops polling the retired reversible lease. The public armed-only RPC contract remains supported. Native watchdog budgets are unchanged: the 90-second supervisor case reserves five seconds and adds a two-second watchdog grace, targeting 87 seconds after accepted signal handling. Worker startup latency remains an unproven source of drift; this change does not promise native handle extinction.

Evidence

  • Base-red regressions: wrapper close remained pending past the injected deadline; held sidecar errors omitted the owner; closed admission skipped synthetic attachment cleanup; controller handoffs omitted commitment or rejected committed acknowledgement.
  • Node focused tests: wrapper 9/9; shutdown diagnostics/runtime 4/4; subagent worker 21/21. Wrapper's last run took 39.86s wall (mostly compiled native fixtures); subagent/shutdown test time stayed below five seconds per file.
  • Controller custody 27/27; focused handoff/source-stop ordering 7/7. Linux/root-only controller cases were skipped on macOS; full installed-controller activation was unavailable in this isolated environment.
  • test/gateway-restart-resume.e2e.test.ts: PASS, 63.07s test time. Busy SIGTERM shutdown 475ms; committed maintenance shutdown 583ms. Proves graceful resume, FIFO delivery, and intentionally lossy SIGKILL handling through isolated Gateway processes and a synthetic provider.
  • Targeted production/test typechecks, lint, format, diff checks, line-cap/max-lines ratchets passed. Test-lines ratchet: 6,242,707 / 6,320,000; test/fixture LOC delta is zero. Overall: production +78, docs +8.
  • Independent Codex autoreview against base 283532b6071c8c424eeb9abd5bbd6789283a0933: final P0–P2 assessment clean after fixing fatal-error masking. The configured local ClawSweeper checkout was unavailable because it contained unrelated edits; using the documented autoreview fallback.

No live Gateway, deployment, release, or real user state was touched. CI timing is pending.

Bound native wrapper cleanup by the existing host deadline while preserving embedded joins and fatal close failures. Name retained sidecar owners, keep terminated-subagent cleanup under its caller, and commit deployment suspension handoffs before the native stop. No configuration or persisted data changes.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T23:38:25.158143Z 805831e PR opened
ℹ️ 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 gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete merged commit a968dc1 into main Oct 28, 2026
133 of 141 checks passed
@steipete
steipete deleted the codex/shutdown-bounded-followups branch October 28, 2026 23:45
steipete added a commit that referenced this pull request Oct 29, 2026
b8c02c5 removed an incidental maintenance await, which exposed a race in the cron failure-alert notification tests; they now wait for the real fallback receipt before asserting acceptance, execution and routing. Separately, #187090 edited the module-isolation mocks in the Gateway shutdown and spawn-broker tests, which invalidated their grandfathered mock-exports baseline entries and failed the baseline ratchet for every PR; those mocks now carry explicit mock-isolation reasons and the stale baseline entries are pruned. Production is unchanged.
steipete added a commit that referenced this pull request Oct 29, 2026
The subagent registry supersession test still asserted a nested Gateway root operation that #187090 deliberately removed (red on main as `0 > 0`). Remove only the obsolete root-counter assertions; keep the overlapping-successor setup and the lifecycle-overwrite assertions. Test-only (+1/-7), no runtime change. Local: subagent-registry.test.ts 77/77 on the exact head. The only failed check was a superseded PR-body format run; its rerun passed.
roboclaw-bot added a commit that referenced this pull request Oct 29, 2026
#187090 reshaped the shutdown and spawn-broker test mock factories without
updating the mock-export ratchet, so their grandfathered entries no longer
matched and every pull request merged with main failed the ratchet.

These factories intentionally keep the real modules unloaded: the shutdown
test records which runtime modules preparation loads, and the spawn-broker
test replaces core startup to observe only broker and admission ownership.
Mark them with mock-isolation reasons and prune the stale baseline entries.

Co-authored-by: hannesrudolph <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…law#187090)

Process-owned Gateway shutdown now finishes within its cleanup deadline:
- The Linux wrapper's database-admission, read-only-worker and spawn-broker close runs under the process-owning shutdown deadline (exitAfterClose only); embedded close still joins fully.
- Timed-out cleanup steps name the retained owner (step plus sidecar or callback), so the next forced kill identifies it.
- Subagent cleanup no longer goes through admission after it closes (12 handled "Gateway is shutting down" errors per shutdown).
- The Team deploy controller commits the maintenance handoff before service stop (gateway.suspend.handoff commit:true, supported by the deployed d87c507), so the 45 s drain lease cannot expire and reopen admission before the stop.
- The native hard-exit watchdog arithmetic was verified correct and left unchanged.

Root cause and evidence: two Team stops on 2026-10-28 ran ~90 s and ended in systemd SIGKILL, waiting on an unbounded lifetime-sidecar stop, received-connection work, and an armed-but-uncommitted handoff.

Proof at exact head 805831e: red-on-base regressions for all four behavior changes; focused tests, the restart-resume acceptance e2e, targeted typechecks, lint and format pass locally; no CI job failed. Merged at the pinned head without waiting for the full CI queue, per Peter's local-proof merge rule.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
1465250 removed an incidental maintenance await, which exposed a race in the cron failure-alert notification tests; they now wait for the real fallback receipt before asserting acceptance, execution and routing. Separately, openclaw#187090 edited the module-isolation mocks in the Gateway shutdown and spawn-broker tests, which invalidated their grandfathered mock-exports baseline entries and failed the baseline ratchet for every PR; those mocks now carry explicit mock-isolation reasons and the stale baseline entries are pruned. Production is unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
The subagent registry supersession test still asserted a nested Gateway root operation that openclaw#187090 deliberately removed (red on main as `0 > 0`). Remove only the obsolete root-counter assertions; keep the overlapping-successor setup and the lifecycle-overwrite assertions. Test-only (+1/-7), no runtime change. Local: subagent-registry.test.ts 77/77 on the exact head. The only failed check was a superseded PR-body format run; its rerun passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant