Skip to content

fix(gateway): name the shutdown trigger in admission and lifecycle logs - #148910

Merged
steipete merged 1 commit into
mainfrom
upd/admission-drain-reason-148866
Sep 15, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/admission-drain-reason-148866

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Refs #148866

What Problem This Solves

Ordinary Gateway stops log restart drain, making externally initiated stops look like self-initiated restart loops and leaving operators without a recorded trigger.

Reported by @mtoko (#148866).

User Impact

Operators debugging restarts can distinguish a stop from a restart, see the signal and available config/update reason, and inspect the last recorded shutdown with openclaw gateway status --deep. Repeated signals or recorded plain stops produce a supervisor-check hint. Deep Linux status also exposes the existing competing systemd scope diagnosis for the native service target.

Why This Change Was Made

The run loop already knows the accepted action, signal, and restart intent. It now carries that reason into admission logging and the existing lifecycle reason field. The repeated-stop diagnostic reads the existing five-minute history; it does not change crash-loop breaker decisions, shutdown ordering, exit behavior, update handoff ownership, schema, or retention. Signal callbacks do not expose a sender PID or command, so diagnostics do not claim one.

This repairs misleading diagnostics; it does not establish or fix the external cause of the restart loop in #148866. Failure completions keep their specific failure reasons, older retained rows may still say gateway.stop, and an unrecorded hard kill cannot supply a stop reason. Production grows by 133 lines to include the missing read-only status plumbing and cross-process history diagnostic.

Evidence

  • Test-first regression run: eight expected failures, including admission closed: restart drain instead of admission closed: stop (SIGTERM), missing repeated-signal guidance, missing last-shutdown output, and missing dual-systemd diagnosis.
  • Separate cross-process regression: two expected failures before the history diagnostic; both pass after it. Expired stops are excluded, and clean stops do not trip the crash-loop breaker.
  • Focused suites: 380 passed, one existing skipped test across run-loop, admission, command queue, lifecycle, and status tests.
  • node scripts/check-changed.mjs: passed, including lint, core/test typechecks, import-cycle, schema, and repository guards. One test-only Promise-executor lint issue was fixed before the passing rerun.
  • Rebased without patch changes onto main at ed264cc3ca59b51648a366d7ed86df9e58c76390. Current PR head: 531faaa391fbbfc748105adf192b9858c9dc7a9a.
  • Exact-head CI run 34968896233 passed at 531faaa391fbbfc748105adf192b9858c9dc7a9a, and the full check rollup is green. Earlier unrelated main failures were handled by rebasing onto their main corrections; no diagnostic code changes or CI reruns were needed.
  • The campaign lead's Codex autoreview was scoped-clean at P1 on 1a248fe53023722e684f9cacf41d334cb1648793; git range-diff confirms all subsequent rebases preserved that patch exactly.

No live operator Gateway was restarted. Linux scope discovery is tested through the existing owner with synthetic installed-unit facts; no live Linux supervisor or published-updater installation campaign was run for this diagnostic change.

ClawSweeper review

Completed review found no actionable findings on exact head 531faaa391fbbfc748105adf192b9858c9dc7a9a. No items required applying or skipping. The rebases preserve the patch; no code fixup or manual re-review request was needed.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Sep 15, 2026
@steipete
steipete marked this pull request as ready for review September 15, 2026 08:15
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 9:41 AM ET / 13:41 UTC (Revision 10).

ClawSweeper review

What this changes

The PR names stop and restart triggers in Gateway logs and shutdown history, adds repeated-signal hints, and exposes shutdown and competing-service diagnostics in deep CLI status.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful diagnostic repair absent from inspected main. No actionable patch defect was found, and the broader restart-loop report remains unresolved.

Priority: P2
Reviewed head: 531faaa391fbbfc748105adf192b9858c9dc7a9a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused diagnostic repair with meaningful regression coverage and no actionable correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as maintainer-authored, so the external-contributor proof gate does not apply. Run-loop, history, and status tests support the diagnostics; the body explicitly discloses that no live Gateway or Linux supervisor campaign was run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies this as maintainer-authored, so the external-contributor proof gate does not apply. Run-loop, history, and status tests support the diagnostics; the body explicitly discloses that no live Gateway or Linux supervisor campaign was run.
Evidence reviewed 7 items Pinned patch and unchanged review head: Reviewed the introduced base-to-head changes. The current head matches the previous completed review, which recorded no findings; git diff --check passed and the checkout remained clean.
Main still has misleading admission text: Fetched main still logs the fixed string 'restart drain'. Its inspected lifecycle and run-loop files match the pinned base for this change. Direct release-source inspection could not complete because the required historical blob was unavailable; no shipped-fix claim is made.
Diagnostic change preserves lifecycle decisions: The run loop formats accepted requests for logging and completion reasons. Restart routing still uses the original restartReason, and failure completions retain their specific reasons. Admission fencing, authorization, handoff ownership, and exit decisions are unchanged.
Findings None None.
Security None None.

How this fits together

The Gateway run loop accepts shutdown signals and restart requests, closes admission to new work, and records lifecycle outcomes. Deep CLI status reads those outcomes and installed-service information to help operators diagnose unexpected stops.

flowchart TD
  A[Signals and restart requests] --> B[Gateway run loop]
  B --> C[Close work admission]
  C --> D[Trigger-specific logs]
  B --> E[Existing shutdown history]
  E --> F[Deep CLI status]
  G[Installed systemd services] --> F
  F --> H[Operator diagnostics]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +133, Tests +261, Docs +10. Total +404 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 152 19 +133
Tests 3 265 4 +261
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 427 23 +404

Review metrics

Metric Value Why it matters
Production versus test growth Production net +133 lines; tests net +261 lines The PR explains production growth as status plumbing and history diagnostics, with regression coverage for the added behavior.

Technical review

Best possible solution:

Keep shutdown diagnostics with the existing lifecycle and service owners, while investigating schema-specific attribution separately in the linked issue.

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

Yes, for the misleading diagnostic: current main sends ordinary stops through admission code that logs 'restart drain', and the related discussion records that sequence on the released Gateway. This review did not execute the path.

Is this the best way to solve the issue?

Yes, for the stated diagnostic scope: passing the already-known trigger through existing owners avoids changing shutdown policy or introducing another state store.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 49c1bc4d6ee9.

Labels

Label justifications:

  • P2: This repairs misleading operational diagnostics without claiming to fix the reported availability failure.
  • 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: The supplied repository state identifies this as maintainer-authored, so the external-contributor proof gate does not apply. Run-loop, history, and status tests support the diagnostics; the body explicitly discloses that no live Gateway or Linux supervisor campaign was run.

Evidence

What I checked:

  • Pinned patch and unchanged review head: Reviewed the introduced base-to-head changes. The current head matches the previous completed review, which recorded no findings; git diff --check passed and the checkout remained clean. (531faaa391fb)
  • Main still has misleading admission text: Fetched main still logs the fixed string 'restart drain'. Its inspected lifecycle and run-loop files match the pinned base for this change. Direct release-source inspection could not complete because the required historical blob was unavailable; no shipped-fix claim is made. (src/process/gateway-work-admission.ts:302, 49c1bc4d6ee9)
  • Diagnostic change preserves lifecycle decisions: The run loop formats accepted requests for logging and completion reasons. Restart routing still uses the original restartReason, and failure completions retain their specific reasons. Admission fencing, authorization, handoff ownership, and exit decisions are unchanged. (src/cli/gateway-cli/run-loop.ts:521, 531faaa391fb)
  • Existing storage and service owners reused: Shutdown lookup uses the existing read-only database owner; repeated-stop counting uses the existing completion transaction. The schema, retention, and crash-loop classifier remain unchanged. Deep status restricts systemd diagnosis to the native local target and sanitizes terminal output. (src/infra/gateway-boot-lifecycle.ts:89, 531faaa391fb)
  • Focused regression coverage: Inspected cases cover signal-specific reasons, repeat-window expiry, persisted clean-stop counting without tripping the breaker, last-shutdown selection, and local/native status targeting. The supplied PR body reports 380 passing tests and passing changed-file checks; no tests were executed during this read-only review. (src/infra/gateway-boot-lifecycle.test.ts:78, 531faaa391fb)
  • Related discussion distinguishes diagnostics from root cause: At [Bug]: Gateway permanent restart loop when gateway.bind=lan (2026.9.1 + 2026.9.4, Ubuntu/systemd) #148866 (comment), steipete reports reproducing the misleading label with an external SIGTERM on the published release. Later discussion proposes schema-specific attribution, but the pinned PR body explicitly limits this patch to diagnostics. The reporter subsequently qualifies the plugin-loop hypothesis as unisolated. This patch must not be treated as resolving those broader claims.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-15T10:17:28.805Z sha dd77304a2a53f00161ee5bfbd5ca2c4c2cf1b2c2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T10:31:55.120Z sha 741981550a09e59419979eb95d25907f8d48026c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T10:54:04.847Z sha 741981550a09e59419979eb95d25907f8d48026c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T11:12:43.932Z sha bdde166cf423ca544b3739703527b5298fe8e941 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T11:25:46.766Z sha 3c0a84f7a4bd095cb551329a8ac816dea8756a54 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T11:46:14.197Z sha 5947c13 :: blocked before merge. :: none
  • reviewed 2026-09-15T12:24:10.083Z sha 5947c13 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T12:43:40.509Z sha 531faaa :: needs maintainer review before merge. :: none

Carry accepted stop/restart signals and intent reasons into admission logging
and retained lifecycle outcomes. Show the last shutdown and existing systemd
scope warning in deep status, with hints for repeated signals and clean stops.

Release-note context: operators debugging restarts can distinguish external
stops from Gateway-requested restarts without changing lifecycle behavior.

Reported by @mtoko (#148866).
@steipete
steipete force-pushed the upd/admission-drain-reason-148866 branch from 5947c13 to 531faaa Compare September 15, 2026 12:26
@steipete
steipete merged commit 57c5dc3 into main Sep 15, 2026
196 checks passed
@steipete
steipete deleted the upd/admission-drain-reason-148866 branch September 15, 2026 13:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…gs (openclaw#148910)

Carry accepted stop/restart signals and intent reasons into admission logging
and retained lifecycle outcomes. Show the last shutdown and existing systemd
scope warning in deep status, with hints for repeated signals and clean stops.

Release-note context: operators debugging restarts can distinguish external
stops from Gateway-requested restarts without changing lifecycle behavior.

Reported by @mtoko (openclaw#148866).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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