Repository navigation
feat(cron): system-owned heartbeat monitor jobs replace the dedicated interval scheduler - #112585
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
July 22, 2026 07:20
…scheduler
- new internal cron payload kind {kind:"heartbeat"}: execution pokes
requestHeartbeat({source:"interval"}); reported in the protocol job
schema, not accepted from client create/patch
- gateway converges one declaration-keyed monitor job per heartbeat-enabled
agent (schedule every+deterministic phase anchor) at startup and on
config reload; removes monitors for unconfigured agents
- heartbeat runner loses its interval setTimeout machinery; nextDueMs
stays as the cooldown gate, event wakes unchanged
- converge/prune/failure-containment tests for heartbeat monitor jobs - heartbeat payload run fires an interval wake, no system event - scheduler tests converted from timer self-fire to wake-queue pokes; timer-mechanics-only tests deleted with the timer - persisted-shape accepts the heartbeat payload kind - docs: heartbeat cadence ownership + system payload kind
- targeted cron-monitor interval ticks use the full per-agent path so due-commitment sessions still deliver - cron-disabled gateways keep a local fallback interval timer (shipped cron.enabled=false contract; removed when heartbeat config folds into cron in #110950) - heartbeat job reconciliations serialize with latest-wins epochs and a bounded 30s retry after a failed convergence pass
- targeted monitor redirect skips wakes carrying heartbeat overrides and surfaces the per-agent terminal skip reason instead of not-due - cron-disabled fallback timer re-arms with a 1s floor after each firing so a dropped wake cannot end the chain - heartbeat payloads are system-owned at the service boundary: add requires the gateway opt-in, patches to the kind are rejected
- prune only jobs proven to be monitors (prefix AND heartbeat payload) - existing monitors reject every update patch; declarative upserts on the monitor key require the gateway opt-in even with a different payload
- converge scopes declarative matching to real monitors so a colliding user job with the same key is never adopted or overwritten - monitor removal requires the gateway systemOwned opt-in; ad-hoc API/CLI deletion is rejected, reconciliation cleanup still prunes
steipete
force-pushed
the
claude/heartbeat-cron-monitor
branch
from
July 22, 2026 07:23
f58669d to
6045a74
Compare
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(cron): system-owned heartbeat monitor jobs replace the dedicated interval scheduler This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 23, 2026
… interval scheduler (openclaw#112585) * feat(cron): system-owned heartbeat monitor jobs replace the interval scheduler - new internal cron payload kind {kind:"heartbeat"}: execution pokes requestHeartbeat({source:"interval"}); reported in the protocol job schema, not accepted from client create/patch - gateway converges one declaration-keyed monitor job per heartbeat-enabled agent (schedule every+deterministic phase anchor) at startup and on config reload; removes monitors for unconfigured agents - heartbeat runner loses its interval setTimeout machinery; nextDueMs stays as the cooldown gate, event wakes unchanged * test(cron): heartbeat monitor regressions; docs for cron-owned cadence - converge/prune/failure-containment tests for heartbeat monitor jobs - heartbeat payload run fires an interval wake, no system event - scheduler tests converted from timer self-fire to wake-queue pokes; timer-mechanics-only tests deleted with the timer - persisted-shape accepts the heartbeat payload kind - docs: heartbeat cadence ownership + system payload kind * fix(cron): heartbeat monitor review round 1 - targeted cron-monitor interval ticks use the full per-agent path so due-commitment sessions still deliver - cron-disabled gateways keep a local fallback interval timer (shipped cron.enabled=false contract; removed when heartbeat config folds into cron in openclaw#110950) - heartbeat job reconciliations serialize with latest-wins epochs and a bounded 30s retry after a failed convergence pass * fix(cron): chain clamped fallback heartbeat timers past the setTimeout cap * fix(cron): heartbeat monitor review round 3 - targeted monitor redirect skips wakes carrying heartbeat overrides and surfaces the per-agent terminal skip reason instead of not-due - cron-disabled fallback timer re-arms with a 1s floor after each firing so a dropped wake cannot end the chain - heartbeat payloads are system-owned at the service boundary: add requires the gateway opt-in, patches to the kind are rejected * fix(cron): heartbeat monitor review round 4 — full ownership enforcement - prune only jobs proven to be monitors (prefix AND heartbeat payload) - existing monitors reject every update patch; declarative upserts on the monitor key require the gateway opt-in even with a different payload * fix(cron): complete heartbeat monitor ownership boundary - converge scopes declarative matching to real monitors so a colliding user job with the same key is never adopted or overwritten - monitor removal requires the gateway systemOwned opt-in; ad-hoc API/CLI deletion is rejected, reconciliation cleanup still prunes * docs(cron): record intentional enrollment-snapshot semantics for monitor ticks * fix(cron): repair heartbeat monitor CI gates
This was referenced Jul 23, 2026
17 tasks done
JFWaskin
pushed a commit
to JFWaskin/openclaw
that referenced
this pull request
Aug 5, 2026
…nclaw#79192) The original PR openclaw#79192 targeted the pre-openclaw#112585 monolithic heartbeat-runner architecture. That architecture has been fully retired on main; this is a v2 rewrite that re-anchors the feature on the new heartbeat-cooldown.ts + cron monitor rows + split cron service seams. What is preserved: * cron.maintenance config (window + maintenanceAgents + allowManualRun) * daily maintenance window with timezone awareness * role isolation: non-roster agents are deferred during the window * deferred replay in FIFO order on phase exit * manual run gate (force pierces; allowManualRun opt-in) * Heartbeat wake deferral with reason 'maintenance-window' * cron.status / CronJobState additive diagnostics What is intentionally different from the original: * No src/infra/maintenance-phase.ts (the module is gone in main); the decision logic lives in src/cron/maintenance-policy.ts * shouldDeferWake gains a maintenanceWindow input; manual intent is the sole pierce path (D1: allowManualRun is the opt-in knob) * Manual run admission goes through inspectManualRunPreflight, which returns 'maintenance-blocked' (added to CronRunResult reason union) * Hot reload of cron.maintenance.* requires a cron service restart in v2; a v3 follow-up will thread live config into the running service Validation: * pnpm tsgo:core (passes) * pnpm tsgo:core:test (passes) * 66 new unit tests pass * Protocol conformance preserved (CronJobState gains 3 additive fields) * Evidence: artifacts/pr79192-v2-maintenance-proof.mjs
This was referenced Oct 9, 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
Phase 2 (first stage) of the automation-unification program (#110950): OpenClaw ran two independent schedulers — the cron service and a dedicated per-agent heartbeat interval timer buried in
heartbeat-runner.ts(scheduleNext+state.timer+ phase-seek machinery). Two cadence owners meant duplicated scheduling logic, invisible heartbeat cadence (no cron listing, no run records), and no path to the RFC's "everything is a cron" end state.Why This Change Was Made
Heartbeat cadence moves into the cron scheduler as system-owned monitor jobs, while everything the heartbeat runner is actually good at stays put:
{kind:"heartbeat"}: executing the job only pokesrequestHeartbeat({source:"interval", intent:"scheduled"}). The wake queue keeps coalescing/busy-retry; the runner keeps its cooldown gate (nextDueMs), quiet-hours guard, flood guard, and per-agent dispatch. A tick outside active hours is skipped by the exact guards that governed the old timer — behavior-preserving by construction.server-cron-heartbeat-jobs.ts): one declaration-keyed job per heartbeat-enabled agent (heartbeat:<agentId>,schedule: every+ deterministic per-agent phase anchor so multi-agent beats stay spread), converged at cron start and on config reload; monitors for unconfigured agents are pruned. Config remains the single source of truth — the job is not client-writable (reported in the protocol job schema, rejected by create/patch schemas, read-only in the Control UI).scheduleNext,state.timer, the setTimeout-cap clamp, and the self-poke are gone fromheartbeat-runner.ts. Event-driven wakes (exec events, hooks, tasks, session-state) are untouched.Timing safety: cron fires at/after the anchor-aligned boundary (setTimeout never fires early), both sides derive the boundary from the same phase function and seed, and the wake queue's coalesce delay only lands the handler past the due time — so the runner's
not-duecooldown cannot eat a legitimate tick.Not in this PR (follow-ups tracked on #110950): migrating
agents.*.heartbeatconfig keys into cron job records via doctor, database-backed per-job scratch space, and the HEARTBEAT.md → database migration.User Impact
Heartbeat behavior is unchanged (same cadence, same guards, same delivery). Operators gain visibility:
openclaw cron list --allnow shows each agent's heartbeat monitor ("Heartbeat ()") with its schedule and run state. Docs updated (docs/gateway/heartbeat.md,docs/automation/cron-jobs.md).Evidence
src/gateway/server-cron-heartbeat-jobs.test.ts), heartbeat payload fires an interval wake with no system event (src/cron/service.heartbeat-payload.test.ts).heartbeat-runner.scheduler.test.ts, 25 green;heartbeat-runner.active-hours-schedule.e2e.test.tsrewritten, 7 green); timer-mechanics-only tests deleted with the timer.src/cron+ gateway cron suites (145 files / 1,599 tests), all 30src/infra/heartbeat*files +server-runtime-services(267 tests).tsgocore + core-test lanes clean;oxlintclean, no new suppressions;oxfmtapplied. Net diff +629/−504.