Repository navigation
refactor(logging): bind diagnostic scheduling to the runtime owner - #159389
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. |
5f49a43 to
a1ad9fa
Compare
|
Codex review: blocked before merge. Reviewed September 27, 2026, 1:20 AM ET / 05:20 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch moves diagnostic heartbeats to the Gateway scheduler, binds public logging helpers to their runtime owner, and gives CLI and MCP services explicit scheduler lifetimes. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: current main still runs diagnostics on a private interval, and the merged scheduler groundwork does not include this lifetime cutover. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway kernel schedules server background work; its diagnostic heartbeat samples activity and emits stability events and recovery requests. CLI and MCP processes can use the same logging API through their own runtime lifetimes. flowchart LR
A[Gateway startup] --> B[Kernel scheduler]
C[CLI or MCP entry] --> D[Resource host]
B --> D
D --> E[Diagnostic heartbeat]
E --> F[Events and recovery]
B --> G[Wake and shutdown tracking]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +90, Tests +377, Docs +5. Total +472 across 28 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep diagnostics on the kernel-owned scheduler with the public logging API intact, backed by a published-driver update and Gateway lifecycle trace. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: current main's private interval and the proposed scheduler path are visible in source, but this PR addresses internal ownership. Is this the best way to solve the issue? Yes in principle: the existing kernel scheduler is the right owner, and explicit standalone lifetimes preserve the public logging calls. Upgrade and lifecycle behavior still needs direct proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ad3103420e40. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…penclaw#159389) * refactor(logging): bind diagnostic scheduling to the runtime owner * test(logging): drive backend liveness with the shared scheduler clock
What Problem This Solves
Diagnostic sampling and cleanup previously maintained a private interval outside Gateway shutdown and next-wake visibility.
Move the diagnostic heartbeat onto the required kernel scheduler. Bind the existing SDK resource host at Gateway startup and resolve public logging helpers through that host. CLI invocations explicitly create and stop their own lifetime scheduler. Public logging signatures remain unchanged.
The invariant is one scheduler instance per Gateway process: kernel composition supplies it, and required internal scheduler dependencies prevent silently creating private owners. Shipped SDK facades resolve the bound host; standalone entry points visibly own creation and stop.
Deleted: The interval and its private start/stop plumbing are removed; diagnostic test fixtures drive the shared injected clock.
User Impact and Update Behavior
Update behavior: Existing installs keep their config, state, ports, and diagnostic settings. Gateway diagnostics follow coordinated scheduler catch-up and shutdown; existing standalone SDK start/stop calls retain their own explicit lifetime. No storage schema, config key, RPC, or public SDK signature changes.
LOC: production +135/−45/net +90; tests +470/−93/net +377; docs +5/−0/net +5. These atomic constructor/caller closures include test migrations; growth is reported directly, without splitting off unused intermediate wiring.
Evidence
Historical focused proof used provider
blacksmith-testboxacross two leases: 21 files / 411 cases / 406.923 s on leasetbx_01m3fm57340p6ettpaa0raecst, run 36267294712, then four files / 50 cases / 87.386 s on leasetbx_01m3fqja9r983kwbphpb3v3g5g, run 36270738491. The total remains 25 passing file executions / 461 case executions / 494.309 s wall. The continuation reused the first lease's completed receipts; it did not rerun those 21 files. Every row usedpnpm test <file> --maxWorkers=1after frozen installation. These source-pinned results cover the reviewed composition, not a new remote run of the refreshed publication head. The four continuation files weresrc/plugin-sdk/provider-catalog-runtime.test.ts,src/mcp/plugin-tools-serve.test.ts,src/mcp/plugin-tools-registration.stdio.test.ts, andsrc/mcp/codex-supervision-tools-serve.test.ts; the other 21 rows below belong to the first lease.Focused test cost and source identity
extensions/telegram/src/webhook.test.tsa5c7951e7faesrc/agents/cli-runner/execute.background-work.test.tsa5c7951e7faesrc/agents/embedded-agent-runner/runs.liveness.test.tsa5c7951e7faesrc/cli/runtime-cleanup.test.tsa5c7951e7faesrc/gateway/server-methods/question.recovery.test.tsa5c7951e7faesrc/gateway/server.diagnostics-policy.test.tsa5c7951e7faesrc/gateway/worker-environments/worker-turn-run-owner.test.tsa5c7951e7faesrc/logging/diagnostic-gc.test.tsa5c7951e7faesrc/logging/diagnostic-heartbeat-context.test.tsa5c7951e7faesrc/logging/diagnostic-lifecycle.test.tsa5c7951e7faesrc/logging/diagnostic-stuck-session-exec-deadline.test.tsa5c7951e7faesrc/logging/diagnostic-stuck-session-followup-recovery.integration.test.tsa5c7951e7faesrc/logging/diagnostic-stuck-session-recovery.integration.test.tsa5c7951e7faesrc/logging/diagnostic.test.tsa5c7951e7faesrc/mcp/plugin-tools-registration.test.tsa5c7951e7faesrc/plugin-sdk/logging-core.test.tsa5c7951e7faesrc/cli/run-main.cleanup.test.tsa5c7951e7faesrc/cli/plugin-invocation-resources.owner.test.tsa5c7951e7faesrc/plugins/memory-runtime.test.tsa5c7951e7faesrc/plugins/registry.runtime-config.test.tsa5c7951e7faesrc/plugins/plugin-source-capture-directory.test.tsa5c7951e7faesrc/plugin-sdk/provider-catalog-runtime.test.tsa5c7951e7faesrc/mcp/plugin-tools-serve.test.tsa5c7951e7faesrc/mcp/plugin-tools-registration.stdio.test.tsa5c7951e7faesrc/mcp/codex-supervision-tools-serve.test.tsa5c7951e7faeCurrent-composition refresh: provider
blacksmith-testbox, leasetbx_01m3fz4ar9ygxxkxh5y2qjc40x, run 36278033418. Changed source remains byte-identical except preservation of main’s proxy-capture finalizer. Refreshed focused results:src/plugins/plugin-source-capture-directory.test.tssrc/plugins/plugin-source-capture-recovery.test.tssrc/plugins/plugin-metadata-lifecycle.test.tssrc/cli/runtime-cleanup.test.tssrc/plugin-sdk/logging-core.test.tssrc/gateway/server.diagnostics-policy.test.tsThe same current composition passed full
pnpm build(326.589 s),pnpm plugin-sdk:api:diff --base 0e27650f8e89afa47a839182e8018e5fb9382ce3 --head e06a34e17bceaaca9f04c5af68f4a52f7f84defe(130.200 s), export/surface/import guards, scoped docs sanity, and the existing MCP UI fixture (2 cases, 64.325 s). The isolated import profiler covered 19 packaged SDK consumers (6.229 s) plus three source-only QA consumers (0.918 s). The initial profiler command incorrectly selected private, non-packagedqa-laband was rejected before import; the corrected routes preserve coverage. All source was verified, and no suite/build ran locally.SDK API acknowledgement: digest
5e457d84reports 125 affected exports (124 reachable, one signature-text change), with no added or removed entrypoints.startDiagnosticHeartbeatkeeps the same optional config/options types throughParameters<...>[1]/[2]; its internal scheduler parameter is not part of the public call. PubliccreateAuthRateLimiterretains its name, parameters and return contract; its declaration now belongs to the wrapper instead of the aliased internal constructor. The remaining reachable diff addsreadonlyto three synthesizedreason?: undefinedfields in recovery unions whose source is byte-identical. This is a nonempty declaration/reachability diff, with no public contract migration required.Deslop and independent Codex review completed with no accepted/actionable findings. Rejected hypothetical findings retain source-backed dispositions. Required GitHub
openclaw/ci-gatevalidates the exact published head; final Gateway/cron/SIGSTOP/SIGCONT/restart/SIGTERM proof follows the final stack slice.Stack
Earlier slices include kernel scheduler #158423, session delivery #159275, update watcher #159291, and update campaign #159306. The independent MCP fixture preparation #159372 is being landed alongside this slice. Remaining sequence: diagnostic/CLI/SDK lifetime → auth pruning → MCP fixture preparation → CLI settlement → MCP scheduler cutover → final timer census and docs. Earlier full stack links appear in predecessor PRs.
Merged scheduler slices
Late caller: main added a foreground-Agent backend liveness case after the initial preparation. Its required constructor dependency now uses the shared manual scheduler clock, with ordinary 30-second heartbeat advances preserving the existing 14-minute + 14-minute + 1-minute scenario and every assertion. A single large advance would instead simulate sleep and correctly discount scheduler lateness. This was corrected from source inspection before any test executed. The complete owner-context delta passed fresh Codex review through P2. Remote proof: provider
blacksmith-testbox, leasetbx_01m3ge5z33tbzfkv8jyx0v6y0a, run 36291231330. After frozen install (9.245 s),pnpm test src/logging/diagnostic-backend-liveness.test.ts --maxWorkers=1passed all 13 cases in 20.843 s, on exact tree232976c209eb2455b3c1a26f579b7f2921a001d1. Source guards passed and the private proof checkout was removed.Previous publication head
5f49a4323f800e1937d91f676e86b06febe3b7d4, basec5b1eee718431609d13ab14633ea60a44c102c5f. The rebase preserves main’s node-runtime destructuring cleanup; scheduler changes and test assertions are unchanged.CI correction: run 36292134084 stopped at the assertion-safety ratchet because the new global singleton identity read lacked its required SAFETY invariant. The value remains
unknownand is compared only by identity. A one-line comment documents that existing invariant; no runtime expression, test assertion or baseline allowance changed. Fresh Codex P2 review of the correction is scoped-clean. Remote proof onblacksmith-testbox, leasetbx_01m3ge5z33tbzfkv8jyx0v6y0a, run36291231330:pnpm check:assertion-safety --base c5b1eee718431609d13ab14633ea60a44c102c5ffailed the original published source with exactlylegacy-sdk-resource-host.ts: 1 > 0(20.394 s), then passed after only the comment (21.311 s). The target file hash and unchanged baseline/runtime expressions were verified.Corrected publication head
a1ad9fa57a6eb983159acfd02b3a6dcf0612a004is rebased onto main4c3181e2386c2317e2525471ec22ab2fc2d70dca. The only new source delta after the focused proof is the verified comment-only assertion annotation. Exact-head CI remains the merge gate.