Repository navigation
refactor(cron): move due timers into the Gateway scheduler - #159099
Merged
Merged
Conversation
Contributor
|
🦞👀 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. |
steipete
enabled auto-merge (squash)
September 26, 2026 18:49
This was referenced Sep 26, 2026
This was referenced Sep 26, 2026
steipete
added a commit
that referenced
this pull request
Sep 26, 2026
Complete the test dependency migration after #159099 merged alongside both history fixtures and the startup recovery service/lazy proxy. Drive startup recovery with the existing joined scheduler clock instead of polling detached fake-timer callbacks. Inject an actual schedule-call failure and prove that work due during suspension runs exactly once after resume. Production startup recovery and Gateway scheduler behavior remain unchanged. Validation: all 25 pnpm tsgo:core:test shards; all cron tests plus server-cron-lazy and both cron.history suites (263 files, 3400 tests); changed-file checks, formatting, lint, and independent review. The focused start-arm run passed all 3 cases in 18.29s wall time (1.6s test time). Audited all CronService/lazy-cron callers under src, extensions, and test.
This was referenced Sep 26, 2026
This was referenced Sep 26, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Sep 27, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Sep 27, 2026
Complete the test dependency migration after openclaw#159099 merged alongside both history fixtures and the startup recovery service/lazy proxy. Drive startup recovery with the existing joined scheduler clock instead of polling detached fake-timer callbacks. Inject an actual schedule-call failure and prove that work due during suspension runs exactly once after resume. Production startup recovery and Gateway scheduler behavior remain unchanged. Validation: all 25 pnpm tsgo:core:test shards; all cron tests plus server-cron-lazy and both cron.history suites (263 files, 3400 tests); changed-file checks, formatting, lint, and independent review. The focused start-arm run passed all 3 cases in 18.29s wall time (1.6s test time). Audited all CronService/lazy-cron callers under src, extensions, and test.
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Cron owns a private host timer outside the Gateway schedule, so shutdown and next-wake diagnostics must account for another timer owner.
User Impact
Cron continues to own which jobs run, persisted deadlines, catch-up, concurrency, pacing, receipts and run records. Only wake arming moves to the Gateway scheduler. Closing the scheduler also cancels a tick waiting behind suspended admission, while admitted work remains joined.
Why This Change Was Made
Require a scheduler in CronServiceDeps, Gateway cron construction, lazy startup and reload. Move stopTimer to the timer-arming owner and remove direct timeout creation/clearing. The Gateway passes its kernel scheduler throughout; tests use the existing shared injected-clock factory.
One scheduler instance per Gateway process, enforced by types. Standalone Doctor monitor/cadence migration and local agent-job removal explicitly create and stop their short-lived scheduler at the existing operation entry points. No hidden constructor fallback is added.
Existing installs retain their cron store, configuration, spools and ports. Existing startup/store recovery reconstructs due times; no new deadline table, schema, retention, persistence, config, SDK or RPC contract is introduced. Execution watchdogs and operation-local retry timers remain with their existing owners. Foreign-receipt and system-job retry arming are separate followups.
Strict production +121/−72/net +49; tests +1268/−768/net +500; docs +0/−0/net 0. Runtime owners alone are +86/−60/net +26; the requested production glob also counts two existing test-support filenames. The 151-file, 2229-line slice exceeds the preferred size because the required constructor dependency must migrate its entire caller and fixture closure atomically. Its production concern remains one timer owner; optional dependencies or intermediate unused APIs are not introduced.
Evidence
Prepared on main
f61e10a7f49798cd7a041ca3509d3a2c5e0b99bc, treea40024ed3f9144aa401de85071b37539e3378667. Already-merged Gmail scheduler plumbing is deduplicated. Four fixture conflicts retain the exact reviewed shared-clock bindings. Main's admission-helper cleanup, PR-subscription forwarding, scheduler-diagnostics test, backup test pruning and real-heartbeat dispatch/abort prewarm are preserved. Worker-owned task/cron recovery from #158827 remains untouched. The cross-shard constructor census has no new or removed caller paths.Publication head:
b81440e44fce9391ae1325a185d592ea421998de. A later main change added task-notification custody to the cross-tick fixture. The resolution preserves its held-notification/settlement assertions and uses the shared injected scheduler clock, joining both ticks and notification cleanup. Fresh Codex P2 review of the whole composition was clean (one round, three passes). On blacksmith-testbox leasetbx_01m3fe5xws0vqv7gvgg8bg9q61, run 36261201574,pnpm test src/cron/service.cross-tick-admission.test.ts --maxWorkers=1passed all six cases in 26.38s at exact composition treeb379a3f8d4432b14b21f30a788912ca0852a62d2. Frozen install and before/after source checks passed. The subsequent publication rebase preserves the reviewed patch; exact-head CI attaches on publication.The original exact due composition passed independent Codex review through P2 as part of both followup compositions. This mechanical refresh adds no new design or substantive runtime adaptation. Formatting, whitespace and source/index checks pass. The proof below belongs to the earlier exact tree; the earlier broad proof is not relabeled as publication-head proof. GitHub's enforced
openclaw/ci-gatesupplies changed-file validation.On base
d4e7850dd56abcfb66ba8cda511378ff2f98c0da, verified due treeb546a229b2b9dda7e128c89d7cfc4378ba17ecafpassed 135 file runs and 2,059 case executions. Evidence combines 65 unchanged retained file runs with the continuation's remaining 70 due runs; these are recorded executions, not a claim of unique cases or a fresh run on the publication head.Both providers were blacksmith-testbox. Origin A: lease
tbx_01m3ezy8rsvrbyzc6121b5y475, run 36246724140. Origin B: leasetbx_01m3f70jxsg7e3036jppdwwv8j, run 36253776173. Frozen install and exact source/tree checks precede proof; command receipts retain before/after verification. The continuation reused only completed passing receipts with matching source identity. Its private checkout and task processes were cleaned up after completion.The admission negative control restored an uninterruptible wait and ran
pnpm test src/cron/service.armtimer-tight-loop.test.ts --maxWorkers=1 --testNamePattern "joins a scheduled tick waiting for admission without reopening suspension": one intended timeout failure, four skipped, 136.402s command wall. The control was reversed to the exact reviewed tree. The positive file passed all five cases. Final live Gateway/cron/suspend/shutdown proof follows the complete merged stack.Per-file test costs and commands
Every row used
pnpm test <file> --maxWorkers=1. Origin A additionally used--reporter=json --outputFile /tmp/hn-cron-three-slice-results/logs/<receipt-id>.vitest.json; the exact argument arrays and receipt IDs are retained with the proof. Command wall includes wrapper/compiler setup, so these sequential measurements are not a performance comparison. Existing native worker, process, storage and Gateway compositions account for files above 30 seconds; this constructor migration adds no per-test Gateway boots. The timer-owner cases use the shared injected clock.src/cron/service.armtimer-tight-loop.test.tssrc/cron/service.rearm-timer-when-running.test.tssrc/cron/service.cross-tick-admission.test.tssrc/cron/service.prevents-duplicate-timers.test.tssrc/cron/service.every-jobs-fire.test.tssrc/cron/service.one-shot-schedule-ownership.test.tssrc/cron/service.failure-alert.test.tssrc/cron/service.heartbeat-payload.test.tssrc/cron/service.session-reaper-in-finally.test.tssrc/cron/service.list-past-due.test.tssrc/cron/service.timer-maintenance.test.tssrc/cron/service.restart-catchup.test.tssrc/cron/service/state.test.tssrc/cron/service/run-recovery.lifecycle.test.tssrc/cron/service/owner-hardening.test.tssrc/cron/service/shared-store-runtime.test.tssrc/gateway/server-cron.test.tssrc/gateway/server-cron-lazy.test.tssrc/gateway/server-cron.drain.test.tssrc/gateway/server-close.queued-heartbeat.test.tssrc/gateway/server-reload-handlers.test.tssrc/gateway/server-methods/cron.self-removal.test.tssrc/commands/doctor-heartbeat-task-migration.test.tssrc/tasks/task-registry.maintenance-cron.test.tssrc/agents/mcp-connection-resolver.test.tssrc/agents/prepared-model-runtime.hot-reload-dispatch.test.tssrc/agents/tools/cron-tool.output-contract.test.tssrc/cli/cron-cli/cron-suppression.gateway.test.tssrc/commands/backup-schedule.test.tssrc/cron/active-jobs-manual-run.test.tssrc/cron/cron-delivery-outcomes.e2e.test.tssrc/cron/cron-execution-diagnostics.e2e.test.tssrc/cron/cron-state-contracts.e2e.test.tssrc/cron/legacy-default-agent-owner-migration.test.tssrc/cron/service.add-recompute-drops-due-every.test.tssrc/cron/service.backup-timing.test.tssrc/cron/service.channel-requester.test.tssrc/cron/service.declarative-jobs.test.tssrc/cron/service.delivery-plan.test.tssrc/cron/service.failure-alert-notifications.test.tssrc/cron/service.failure-alert-silent-reply.test.tssrc/cron/service.get-job.test.tssrc/cron/service.grant-generation.test.tssrc/cron/service.heartbeat-busy-poll.test.tssrc/cron/service.heartbeat-ok-summary-suppressed.test.tssrc/cron/service.main-job-passes-heartbeat-target-last.test.tssrc/cron/service.manual-delivery.test.tssrc/cron/service.payload-conversion.test.tssrc/cron/service.persists-delivered-status.test.tssrc/cron/service.persists-delivery-suppression.test.tssrc/cron/service.read-ops-nonblocking.test.tssrc/cron/service.recovery-identity.test.tssrc/cron/service.recovery-schedule-ownership.test.tssrc/cron/service.removal-postcommit.test.tssrc/cron/service.remove-recompute-drops-due-every.test.tssrc/cron/service.remove-session-cleanup.test.tssrc/cron/service.restart-catchup-pacing.test.tssrc/cron/service.restart-catchup-schedule-change.test.tssrc/cron/service.restart-catchup-subsecond.test.tssrc/cron/service.runs-one-shot-main-job-disables-it.test.tssrc/cron/service.scheduled-policy-preservation.test.tssrc/cron/service.skips-main-jobs-empty-systemevent-text.test.tssrc/cron/service.stale-family.test.tssrc/cron/service.startup-heartbeat.test.tssrc/cron/service.startup-overflow-clobber.test.tssrc/cron/service.store-load-invalid-main-job.test.tssrc/cron/service.stream-trigger.test.tssrc/cron/service.stream-validation.test.tssrc/cron/service.trigger-cadence.test.tssrc/cron/service.trigger-eval.test.tssrc/cron/service.unresolved-next-run.test.tssrc/cron/service.unresolved-owner.test.tssrc/cron/service.update-recompute-drops-due-every.test.tssrc/cron/service.wake-now-real-heartbeat.test.tssrc/cron/service.webhook-empty-summary.test.tssrc/cron/service/failure-alerts.account-routing.test.tssrc/cron/service/initial-delivery.test.tssrc/cron/service/jobs.schedule-error-isolation.test.tssrc/cron/service/manual-ack-durability.test.tssrc/cron/service/ops.gateway-mutations.test.tssrc/cron/service/ops.native-attempt.test.tssrc/cron/service/ops.pacing.test.tssrc/cron/service/ops.regression.test.tssrc/cron/service/ops.test.tssrc/cron/service/ops.update.disable-and-list.test.tssrc/cron/service/run-receipt-settlement.test.tssrc/cron/service/run-recovery.admission.test.tssrc/cron/service/run-recovery.batch.test.tssrc/cron/service/run-recovery.settlement.test.tssrc/cron/service/run-recovery.test.tssrc/cron/service/runtime-store.test.tssrc/cron/service/startup-run-repair.auto-disable.test.tssrc/cron/service/store.schedule-reload.test.tssrc/cron/service/store.test.tssrc/cron/service/task-runs.test.tssrc/cron/service/timer-execution.script-wake.test.tssrc/cron/service/timer-execution.tool-policy.test.tssrc/cron/service/timer-outcome-finalization.receipts.test.tssrc/cron/service/timer-trigger.test.tssrc/cron/service/timer.batch-finalization.test.tssrc/cron/service/timer.pacing.test.tssrc/cron/service/timer.quiet-finalization.test.tssrc/cron/service/timer.regression.test.tssrc/cron/service/timer.task-ledger.test.tssrc/cron/service/timer.test.tssrc/cron/service/wake-owner.test.tssrc/cron/store.worker.test.tssrc/cron/store/run-receipt-retention.test.tssrc/cron/store/run-receipt-store.test.tssrc/cron/task-run-history.test.tssrc/gateway/server-cron-skill-review-jobs.responsiveness.test.tssrc/gateway/server-cron-skill-review-jobs.test.tssrc/gateway/server-methods/cron.list-scoped.test.tssrc/gateway/server-methods/cron.runs.test.tssrc/gateway/server-methods/cron.scheduled-policy-adoption.integration.test.tssrc/gateway/server-methods/cron.validation.test.tssrc/gateway/server-methods/cron.webchat-delivery.test.tssrc/gateway/server-methods/requester-cron-authority.integration.test.tssrc/gateway/server-plugin-reload.recovery.test.tssrc/gateway/server-reload-handlers.hot-reload-status.test.tssrc/gateway/server-reload-handlers.operator-model-policy.test.tssrc/gateway/server-reload-hot.cron-lazy.test.tssrc/gateway/server-reload-managed-context.test.tssrc/gateway/server-restart-heartbeat.test.tssrc/gateway/server-secrets-reload.model-runtime.test.tssrc/gateway/server.cron.test.tssrc/gateway/tool-resolution.cron-capture.test.tssrc/plugins/services.cron.test.tstest/discord-live-policy.integration.test.tstest/e2e/qa-lab/runtime/gateway-cron-startup-recovery.e2e.test.tstest/gateway.multi.e2e.test.tstest/plugins/dreaming-cron-doctor.integration.test.tstest/plugins/memory-dreaming-cron.test.tstest/plugins/workboard-automation-authority.test.tsui/src/lib/cron/editor-save.node.test.tsScheduler stack
Earlier slices: diagnostic preparation #157517, auth factory naming #158275, kernel scheduler #158423, event-loop health #158531, channel health #158537, mention expiry #158614, upstream monitoring #158617, worker placement #158662, idle/prewarm #158666, Incognito expiry #158690, OAuth maintenance #158717, initial lifetime maintenance #158727, worker reconciliation #158812, PR subscriptions #158821, update checks #158909, Gmail renewal #158913, metadata capture maintenance #158959, and audit maintenance #158982.
This PR moves cron due-timer arming. Foreign-receipt monitoring and system-job retry are the next two prepared cron slices, with links added when published. Combined post-ready #159047 precedes this work.
Task maintenance #159038, generation #159042, approval deadlines #159081, and cold storage #159088 are merged. Outbound recovery #159096 is pending. Remaining reviewed work includes periodic/media maintenance, diagnostic/SDK lifetimes, session delivery, update watchers and cron followups. Final timer exceptions and the merged-main Gateway/cron/suspend/shutdown proof follow the last slice.