Repository navigation
refactor(gateway): schedule channel health checks - #158537
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 25, 2026, 10:08 PM ET / September 26, 2026, 02:08 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch moves Gateway channel-health checks from a private timer to the kernel scheduler and updates startup wiring and tests. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain Keep this PR open. The scheduler consolidation remains useful, but the previously reported shutdown stall is still present on the pinned head and blocks merge. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway health monitor reads channel account state and decides when to stop and restart an unhealthy channel. The kernel scheduler supplies its wakeups and joins scheduled work during Gateway shutdown. flowchart LR
A[Gateway startup] --> B[Kernel scheduler]
B --> C[Channel health check]
D[Channel account state] --> C
C --> E{Recovery needed?}
E -- Yes --> F[Stop and restart channel]
E -- No --> B
G[Gateway close] --> H[Scheduled work join]
C --> H
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -14, Tests +84. Total +70 across 11 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep scheduler ownership of health-check wakeups while giving in-flight channel recovery a bounded shutdown handoff; prove Gateway close proceeds and a late stop cannot restart the channel. Do we have a high-confidence way to reproduce the issue? Yes. Source gives a precise path: let a scheduled health check await an unresolved channel stop, then close the Gateway. This review did not execute that path. Is this the best way to solve the issue? No. One scheduler is the right wakeup owner, but returning the entire recovery promise to its global join defeats the monitor's existing bounded shutdown. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b03cf209ea6b. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
c0c960e to
fa7cedf
Compare
|
Merged via squash.
|
What Problem This Solves
Channel health checks own a separate timeout/rearm loop even though the Gateway kernel now owns scheduled work.
User Impact
Channel startup grace, health policy, restart ordering, cooldowns, and hourly limits stay unchanged. The existing kernel scheduler runs checks once after a delayed wake and rearms only after work settles. Retirement cancels future checks; shutdown still prevents a delayed provider stop from restarting a channel.
Existing installs need no migration or operator action. Config, state, schemas, ports and public SDK contracts are unchanged. The existing five-second operation handoff timeout remains with the handoff operation.
Why This Change Was Made
Pass the kernel scheduler as a required dependency through both startup layers to the channel health monitor. Delete the monitor's private timer and rearm helper, and use the scheduler's clock and single-flight cadence. The invariant remains one scheduler instance per Gateway process, enforced by types; no production constructor is added.
Owner tests drive the shared manual clock. Five existing channel integration construction sites use the reviewed shared adapter for their existing fake timers. The standalone QA producer constructs and stops its scheduler explicitly around its synthetic ChannelManager; it never starts a Gateway kernel. Its real-time checks remain existing QA coverage.
Production: +25 / -39 / net -14. Tests/support: +203 / -119 / net +84. Docs: +0 / -0 / net 0. Eleven files, 386 changed lines. Existing test helpers remain at their current locations; the optional reviewed relocation is omitted.
Stack
645f8273a86268c84ec7c3542735e68ecde9c215.52c7502c8613d02e5fda0c7d36dd7ed5d544ba71.362cee12114d8a41b2b5eff42e96d973b6cfc327.Evidence
Current head
fa7cedf4f2c10e042cb0e9927112b894d42f7b52includes the main-owned SDK repair #158520; the scheduler range-diff is identical. Exact-head focused proof passed onblacksmith-testbox, leasetbx_01m3dnnvze1jmxvx1wa5ez2yb1, run 36208976081:pnpm install --frozen-lockfile, then each command below aspnpm test <file> --maxWorkers=1. Detached checkout, commit, full tree, and clean source were verified before testing and unchanged afterward. All 7 files / 280 cases passed; summed command wall 73.871s.src/gateway/channel-health-monitor.test.tssrc/gateway/channel-health-monitor.clock-rollback.test.tssrc/gateway/server-channels.test.tssrc/gateway/server-channels.ownership.test.tssrc/gateway/server-channels.trust-refusal.test.tssrc/gateway/server-runtime-services.test.tstest/e2e/qa-lab/runtime/channel-health-monitor-lifecycle-runtime.test.tsThe earlier event-loop CI typecheck failure reproduced on clean main
d8f726c5e1dfc2b59fdf33549da92d9c26ea4a45: two undefined SDK helper references (TS2552). Main's #158520 fixes that owner. The exact five-graph type lane then passed on clean main06da80236ed49ff262c08e0019a4afb6b20d1a34in 144.172s. No unrelated code was added to these slices. A preceding 18-file focused run also passed, including seven metadata-close fixture consumers on the identical event-loop patch.The current lease is shared with the next slice's proof and remains active. Historical stopped leases and earlier baseline costs are recorded below.
Codex autoreview passed in one round, scoped-clean through P2 with zero findings. Deslop, full-symbol caller inspection, upstream-preservation review, formatter and whitespace checks passed. The unmodified reviewer helper ran with full Git history/index, all changed files and explicit unchanged context; the full candidate tree and patch matched the source before commit.
blacksmith-testbox, leasetbx_01m3dg6t4fqkfxx8stp6b5d413, run 36203182633: detached baseline042ab39f55804a51b2d49e913ada422aa1f4e731and candidate7bb29cfacd90faa111ca12b9d6042919ec7be95e, with exact commits/trees and clean sources verified before testing and source unchanged afterward. Each worktree ranpnpm install --frozen-lockfile, thenpnpm test <file> --maxWorkers=1. All seven files / 280 cases passed on both revisions. Candidate summed command wall: 73.915s. These sequential cold/warm measurements do not establish a performance improvement.src/gateway/channel-health-monitor.test.tssrc/gateway/channel-health-monitor.clock-rollback.test.tssrc/gateway/server-channels.test.tssrc/gateway/server-channels.ownership.test.tssrc/gateway/server-channels.trust-refusal.test.tssrc/gateway/server-runtime-services.test.tstest/e2e/qa-lab/runtime/channel-health-monitor-lifecycle-runtime.test.tsNo test case, Gateway boot, retry, or sleep was added. Existing integration and QA producer coverage is retained. GitHub enforced
openclaw/ci-gatesupplies the changed gate; no separate Testbox changed check is claimed. Final live maintenance/cron/suspend/restart/shutdown proof runs on merged main after the stack finishes.The Testbox lease is stopped; independent provider status confirms completion with no IP.