Skip to content

refactor(heartbeat): make cron monitor rows own heartbeat cadence - #113135

Merged
steipete merged 2 commits into
mainfrom
claude/hb-config-cron
Jul 23, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/hb-config-cron

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

After the heartbeat scheduler unification (#112585) and the scratch migration (#112967), heartbeat cadence was still config-derived at reconcile time, which forced a dedicated fallback interval timer for cron-disabled gateways. This PR makes durable cron monitor rows the canonical owner of heartbeat execution timing and deletes that fallback timer per its named removal plan (umbrella #110950).

Why This Change Was Made

agents.*.heartbeat.every remains the documented desired-state input (it also carries the Anthropic OAuth 1h policy default, and system-owned jobs intentionally reject direct CLI/API edits), but gateway reconciliation and openclaw doctor --fix now write it through into system-owned cron monitor rows. A scheduled monitor tick carries its persisted everyMs/anchorMs and is authoritative; the runner adopts that cadence for subsequent event cooldowns. Doctor gains a read-only cadence preview that resolves the scheduler seed without creating device identity, plus an idempotent per-agent fix path.

User Impact

  • Heartbeat cadence is durable cron state; config edits converge into rows via reconcile or doctor.
  • Behavior change: gateways with cron.enabled=false or OPENCLAW_SKIP_CRON=1 no longer receive scheduled heartbeats (startup warning logged; manual and event-driven wakes still work). Previously a local fallback timer kept them alive — deleted here per the removal plan recorded when it shipped.

Evidence

  • Focused proof, all green (7 Vitest shards): node scripts/run-vitest.mjs src/commands/doctor-heartbeat-cadence-migration.test.ts src/commands/doctor-heartbeat-scratch-migration.test.ts src/cron/service.heartbeat-payload.test.ts src/gateway/server-cron.test.ts src/gateway/server-cron-heartbeat-jobs.test.ts src/gateway/server-runtime-services.test.ts src/infra/heartbeat-runner src/flows/doctor-health-contributions.test.ts
  • Two Codex gpt-5.6-sol xhigh autoreview cycles: round 1 found a P1 (migration predicate could select another agent's monitor row) and two env-threading P2s — all fixed with regression tests (multi-agent update/create, distinct state-dir env). Round 2 clean: "patch is correct".
  • Docs updated: docs/gateway/heartbeat.md, docs/gateway/config-agents.md, docs/automation/cron-jobs.md.

agents.*.heartbeat.every stays the documented desired-state input; gateway
reconciliation and openclaw doctor --fix write it through into durable
system-owned cron monitor rows, and a scheduled monitor tick carries its
persisted everyMs/anchorMs as the authoritative cadence, which the runner
adopts for subsequent event cooldowns. Doctor gains a read-only cadence
preview (resolves the scheduler seed without creating device identity) and
an idempotent fix path that converges monitor rows per agent.

The cron-disabled fallback timer is deleted per its named removal plan
(#110950): gateways with cron.enabled=false or OPENCLAW_SKIP_CRON=1 log a
startup warning and get no scheduled heartbeats; manual and event-driven
wakes remain.
@steipete
steipete marked this pull request as ready for review July 23, 2026 19:25
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: XL maintainer Maintainer-authored PR labels Jul 23, 2026
@steipete
steipete merged commit 95b86a3 into main Jul 23, 2026
120 checks passed
@steipete
steipete deleted the claude/hb-config-cron branch July 23, 2026 19:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 24, 2026
…enclaw#113135)

* refactor(heartbeat): make cron monitor rows own heartbeat cadence

agents.*.heartbeat.every stays the documented desired-state input; gateway
reconciliation and openclaw doctor --fix write it through into durable
system-owned cron monitor rows, and a scheduled monitor tick carries its
persisted everyMs/anchorMs as the authoritative cadence, which the runner
adopts for subsequent event cooldowns. Doctor gains a read-only cadence
preview (resolves the scheduler seed without creating device identity) and
an idempotent fix path that converges monitor rows per agent.

The cron-disabled fallback timer is deleted per its named removal plan
(openclaw#110950): gateways with cron.enabled=false or OPENCLAW_SKIP_CRON=1 log a
startup warning and get no scheduled heartbeats; manual and event-driven
wakes remain.

* fix(ci): drop unused requestHeartbeat import and refresh plugin SDK baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant