Skip to content

fix(cli): restore lightweight help and cleanup test startup - #197936

Merged
steipete merged 2 commits into
mainfrom
fix/2430-gateway-cleanup-boot-fixture
Nov 12, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/2430-gateway-cleanup-boot-fixture

Conversation

@steipete

@steipete steipete commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two CLI boundaries were broken: precomputed root help loaded TLS solely for delayed watchdog diagnostics, and the retained-cleanup fixture skipped the child’s real boot lifecycle before sending SIGUSR2. On a cold worker, that missing setup could consume the accepted one-second intent-settlement budget before cleanup began.

User Impact

Root help avoids unnecessary TLS initialization. Cleanup tests reach the intended retained-resource behavior. CLI output, watchdog diagnostics, shutdown ordering, signal policy, and deadlines remain unchanged.

Why This Change Was Made

Resolve the exact TLS constructor synchronously only when the existing watchdog fires, replacing the unconditional import introduced by #197382. Run the cleanup-test child through the same begin/complete boot hooks as the Gateway CLI, replacing parent-only database seeding and removing the temporary diagnostics that identified the missing setup. Keep real OS signals, durable restart intent, cleanup-custody assertions, and the prohibition on reusing a retained runtime. Production LOC is net zero; test LOC is net −34.

Evidence

  • The original cleanup failure is full run 43299098210, small10: cold worker open 979.867 ms plus intent execution 39.378 ms crossed the documented one-second limit. A local original replay passed below that threshold; it is a non-reproduction, not flake evidence. refactor: resume running sessions after graceful restarts #185730 introduced the incomplete fixture; fix(gateway): preserve graceful shutdown when restart intent stalls #188047 documents the deliberately accepted timeout policy. The recent latency-threshold introducer is unknown.

  • The fixture-only head 41ea5595d78aa passed all three cases on Linux, changed2 job 131525849696, using pinned Bun 1.4.4-canary.1+191755ec1. SIGTERM / SIGUSR2 / historical SIGTERM took 3.770 s / 3.303 s / 27.664 s with unchanged deadlines. This is prior-head evidence because the combined patch changes an imported cleanup owner; new exact-head CI must run it again.

  • The same PR run exposed the root-help TLS import failure. Exact parent 097e6484 contains the same owner introduced by chore: identify slow database shutdown owners #197382 / 32c839b6f0b55. The existing help test establishes the regression without weakening its import guard.

  • Exact-parent help regression: red before the TLS move, green afterward using the unchanged test. All 43 help/finalization and 12 cleanup/watchdog cases passed, including the real Node 24.22.1 TLS/child diagnostic path and pinned-Bun watchdog paths. Required owner pnpm check:changed passed.

  • Combined-source cleanup replay: 3/3 passed locally (3.137 s / 2.123 s / 19.928 s) with unchanged deadlines. The earlier full fixture changed-check and canonical config-cli typecheck also passed; unchanged owner checks are reused with exact source qualification. Fresh combined Codex review of the complete three-file range from 097e6484 through the final local snapshot is P0–P2 scoped-clean, with no findings. Final combined-head CI 43322340111 passed; final-head ClawSweeper has zero findings and zero open items. No performance improvement or infrastructure/flaky-failure claim; no inherited-red merge exemption.

  • Final 336a0ce0f78d actual Linux proof: cleanup changed2 passed all three cases (SIGTERM 4.595 s / SIGUSR2 3.897 s / historical SIGTERM 32.437 s); help changed3 passed all 25 cases, including the unchanged precomputed-root import guard. Both ran on the exact PR merge source 094514eeafc0 with pinned Bun 1.4.4-canary.1+191755ec1 and Node 24.22.1. The existing deadlines and signal policy remain unchanged.

Match the real CLI child startup before exercising retained cleanup custody. Preserve the documented one-second signal settlement policy and original deadlines; remove parent-only database seeding and the temporary diagnostics that identified the missing setup.
@clawsweeper

clawsweeper Bot commented Nov 12, 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 cli CLI command changes size: S labels Nov 12, 2026
@steipete
steipete marked this pull request as ready for review November 12, 2026 22:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T22:05:01.800624Z 41ea559 Draft marked ready
ℹ️ 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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR loads TLS diagnostics only when the exit watchdog fires and gives cleanup-test children the Gateway’s existing boot lifecycle.

Example: Run openclaw --help.

  • Before: Importing the exit-finalization module also initializes TLS solely for watchdog diagnostics.
  • After: TLS loads only if the watchdog fires; help output remains unchanged.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused and source-supported, with reported process-harness validation; combined-head CI is still pending.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored exemption applies; reported process-boundary validation covers help import rejection, real TLS/child watchdog diagnostics, and cleanup signals, with prior-head evidence explicitly qualified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Root help unnecessarily initializes TLS, while the cleanup process test can spend signal-settlement time opening a worker that normal Gateway startup already initializes.
Reason: The maintainer-authored direction restores existing contracts with minimal production changes and less test scaffolding.

Regression provenance

Regression provenance — suspected predecessor, not a causality claim: source commit a25c1f3868aa by Peter Steinberger; no PR verified.

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR makes focused, useful repairs to CLI import loading and cleanup-test startup; no actionable defects were found, and exact-head CI remains pending.

Priority: P2
Reviewed head: 336a0ce0f78d96b53a9e5ce4c68afcbd82e4972a

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI entrypoints share exit finalization and its residual-handle watchdog; Gateway process tests exercise boot, signal handling, and cleanup custody.

flowchart TD
  A[CLI invocation] --> B[Help or command]
  B --> C[Exit finalization]
  C --> D[Watchdog fires]
  D --> E[Load TLS diagnostics]
  F[Cleanup test child] --> G[Gateway boot lifecycle]
  G --> H[Signal and cleanup custody]
Loading

Technical review

Best possible solution:

Keep the existing watchdog and boot-lifecycle owners, with TLS deferred to diagnostics and child-owned boot publication before cleanup signals.

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

Current-main source unconditionally imports TLS through exit finalization, and the existing help guard directly detects it; the cleanup fixture also demonstrably omits the production boot hooks, although its timing failure was not independently replayed.

Is this the best way to solve the issue?

The patch repairs both boundaries through existing owners, removes obsolete diagnostic scaffolding, and preserves the accepted timeout and cleanup contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4efd662cc2c6.

Provenance checked

  • TLS watchdog diagnostics keeps the original intent (32c839b: Identify retained TLS and child-process handles after settled shutdown without changing cleanup or deadlines.)
  • Retained-cleanup process fixture keeps the original intent (9344233: Protect cleanup custody and prevent reuse of a runtime whose cleanup remains retained.)
  • Temporary shutdown timing diagnostics changes intended behavior with a stated reason (27af644: Extend temporary phase tracing from fix(ci): expose which phase stalls in the SIGUSR2 shutdown proof #197392 to distinguish cold worker opening from restart-intent execution; remove tracing with the eventual repair.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 32c839b adds src/cli/one-shot-exit.ts:153 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 32c839b6f0b5; files: src/cli/one-shot-exit.ts)

PR surface

Source 0, Tests -34. Total -34 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 17 51 -34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 18 52 -34

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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded CLI import regression and an incomplete cleanup-test lifecycle warrant a focused repair without evidence of an urgent user outage.
  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-12T22:08:03.232Z sha 41ea559 :: needs maintainer review before merge. :: none

Reviewed November 12, 2026, 5:47 PM ET / 22:47 UTC (Revision 2).

Keep the precomputed help path free of TLS initialization introduced by #197382. Acquire the same constructor synchronously inside the existing watchdog callback; preserve its diagnostics, timer, finalization and exit behavior.
@steipete steipete changed the title fix(ci): boot the gateway fixture before cleanup signals fix(cli): restore lightweight help and cleanup test startup Nov 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 12, 2026
@steipete
steipete merged commit d30e45c into main Nov 12, 2026
145 of 146 checks passed
@steipete
steipete deleted the fix/2430-gateway-cleanup-boot-fixture branch November 12, 2026 23:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

* test(gateway): run boot lifecycle before cleanup signal proof

Match the real CLI child startup before exercising retained cleanup custody. Preserve the documented one-second signal settlement policy and original deadlines; remove parent-only database seeding and the temporary diagnostics that identified the missing setup.

* fix(cli): load TLS diagnostics only when the exit watchdog fires

Keep the precomputed help path free of TLS initialization introduced by openclaw#197382. Acquire the same constructor synchronously inside the existing watchdog callback; preserve its diagnostics, timer, finalization and exit behavior.
RomneyDa added a commit that referenced this pull request Nov 13, 2026
Backport only the cleanup-fixture portion of d30e45c, adapting the existing release boot lifecycle signature. Preserve signal deadlines and custody assertions; do not take the unrelated TLS change.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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