Repository navigation
feat(cron): database-backed heartbeat monitor scratch replaces HEARTBEAT.md - #112967
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
July 23, 2026 07:44
…scratch - new additive cron_job_scratch SQLite table (revision tombstones keep compare-and-swap monotonic across unset/recreate; 256KiB cap) - heartbeat runner reads monitor scratch instead of workspace HEARTBEAT.md; heartbeat_respond gains a private scratch replacement parameter - openclaw doctor --fix migrates HEARTBEAT.md into scratch (hash-verified, archived under state backups, idempotent, symlink-contained) - gateway cron.scratch.get/set admin RPCs + openclaw cron scratch CLI - workspace bootstrap no longer seeds HEARTBEAT.md; Codex heartbeat file guidance removed; docs and prompt snapshots updated
…non-default agent monitors - doctor migration groups agents by heartbeat source file and imports into every monitor before archiving/removing the shared file once - exempt heartbeat payloads from the main-session default-agent restriction: monitors only poke the wake bus, so non-default agents converge again - document why disabled monitors retain their last cadence (config default already resolves before the fallback)
…d safer doctor claim
…ithout clobbering
…m on release, archive first, report scratch as pending
…k, latest-response scratch pairing
…estore no-row state
…ion on claim release
…ck on proven scratch state
…since-train, inventory path, prompt snapshot, regenerated docs map, SDK baseline, protocol bindings
steipete
force-pushed
the
claude/heartbeat-scratch-migration
branch
from
July 23, 2026 16:59
60d1fc5 to
35014d5
Compare
Contributor
Author
|
Merged via squash.
|
This was referenced Jul 23, 2026
Closed
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 24, 2026
…EAT.md (openclaw#112967) * feat(cron): move heartbeat context into database-backed per-job cron scratch - new additive cron_job_scratch SQLite table (revision tombstones keep compare-and-swap monotonic across unset/recreate; 256KiB cap) - heartbeat runner reads monitor scratch instead of workspace HEARTBEAT.md; heartbeat_respond gains a private scratch replacement parameter - openclaw doctor --fix migrates HEARTBEAT.md into scratch (hash-verified, archived under state backups, idempotent, symlink-contained) - gateway cron.scratch.get/set admin RPCs + openclaw cron scratch CLI - workspace bootstrap no longer seeds HEARTBEAT.md; Codex heartbeat file guidance removed; docs and prompt snapshots updated * fix(cron): review round 2 — shared-workspace heartbeat migration and non-default agent monitors - doctor migration groups agents by heartbeat source file and imports into every monitor before archiving/removing the shared file once - exempt heartbeat payloads from the main-session default-agent restriction: monitors only poke the wake bus, so non-default agents converge again - document why disabled monitors retain their last cadence (config default already resolves before the fallback) * fix(cron): honor configured cron store, legacy heartbeat fallback, and safer doctor claim * fix(cron): claim HEARTBEAT.md before committing scratch and restore without clobbering * fix(cron): pin migration CAS to precondition revision, re-verify claim on release, archive first, report scratch as pending * docs(heartbeat): remove retired config options * fix(cron): crash-recoverable migration claims, partial-import rollback, latest-response scratch pairing * test(heartbeat): keep latest scratch proposal paired * fix(cron): roll back committed scratch on changed-claim release and restore no-row state * fix(cron): revision-guarded rollback delete and recreated-file detection on claim release * fix(cron): treat every failed claim re-verification as a migration conflict * test(heartbeat): rename ack test after ackMaxChars retirement * fix(heartbeat): keep monitor scratch out of bypass-scope runs * fix(cron): resolve claimed symlinks on release and gate legacy fallback on proven scratch state * fix(cron): strict claim-name recovery and per-entry migration grouping * fix(ci): heartbeat scratch gate repairs — lint causes, dead exports, since-train, inventory path, prompt snapshot, regenerated docs map, SDK baseline, protocol bindings * fix(cron): live-owner claim guard and canonical entry-key migration grouping * fix(cron): archive claimed inode on release and flag orphan claims beside recreated files * docs(cron): document process-global state-db invariant for scratch service ops * chore(i18n): refresh native inventory line numbers after protocol binding regen
This was referenced Jul 25, 2026
obviyus
added a commit
that referenced
this pull request
Sep 2, 2026
…5508) Closes #135457 ## What Problem This Solves The Control UI showed an empty **Heartbeat monitor** field for every heartbeat automation, even when the Gateway already held private per-job scratch. The command-line interface showed the stored scratch correctly. `jobToForm` projects text from public cron payloads. A heartbeat payload has no text because its monitor instructions live in private scratch. The page never called the existing `cron.scratch.get` method, so the read-only field always received the empty fallback. ## Fix - Fetch scratch once when an administrator selects a heartbeat automation. - Keep the result in ephemeral page display state, outside `CronFormState` and all add or update payloads. - Revalidate the Gateway connection, selected job, request generation, heartbeat payload kind, and current administrator access after the request resolves. - Clear display state when the connection, access, selection, or panel changes. - Show scratch-read failures instead of presenting a false empty success state. - Keep `cron.scratch.get` at `operator.admin` and keep scratch out of `cron.list`, `cron.get`, and `CronJob`. Command, script, and skill-review automation payloads still use their existing read-only projection. ## Evidence Baseline main: `2837afb07dc9faa27f631760b5f4de9dbb8de940` Sanitized real-Gateway screenshot and observation: #135508 (comment) - Red, real Gateway: existing heartbeat scratch was returned by the Gateway, but the Control UI field stayed empty and sent no `cron.scratch.get` request. - Green, real Gateway: the field displayed the exact stored scratch and remained read-only. - The green observation recorded one `cron.scratch.get`, an empty mutable `payloadText`, and no scratch in `cron.list` or `cron.get`. - Mock browser end-to-end tests cover the visible authorized result, the read-only operator path, and a visible read failure: 3 passed. - The cron page unit suite covers an in-flight administrator-to-read-only downgrade: 35 passed. - Real-Gateway browser end-to-end proof: 1 passed. - Oxfmt, Oxlint, and `git diff --check` passed. Production: `+56/-3`. Tests and test support: `+172/-10`. ## Regression provenance PR #112967 introduced private heartbeat scratch without changing the existing UI projection. PR #130030 later made the empty projection explicit with the **Heartbeat monitor** label. ## AI assistance AI-assisted repair and validation. A maintainer independently inspected the storage owner, Gateway authorization, protocol schemas, UI projection and save boundaries, sibling payload kinds, tests, docs, history, and real browser behavior. Co-authored-by: gaoanze <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Sep 3, 2026
…nclaw#135508) Closes openclaw#135457 ## What Problem This Solves The Control UI showed an empty **Heartbeat monitor** field for every heartbeat automation, even when the Gateway already held private per-job scratch. The command-line interface showed the stored scratch correctly. `jobToForm` projects text from public cron payloads. A heartbeat payload has no text because its monitor instructions live in private scratch. The page never called the existing `cron.scratch.get` method, so the read-only field always received the empty fallback. ## Fix - Fetch scratch once when an administrator selects a heartbeat automation. - Keep the result in ephemeral page display state, outside `CronFormState` and all add or update payloads. - Revalidate the Gateway connection, selected job, request generation, heartbeat payload kind, and current administrator access after the request resolves. - Clear display state when the connection, access, selection, or panel changes. - Show scratch-read failures instead of presenting a false empty success state. - Keep `cron.scratch.get` at `operator.admin` and keep scratch out of `cron.list`, `cron.get`, and `CronJob`. Command, script, and skill-review automation payloads still use their existing read-only projection. ## Evidence Baseline main: `1e7394c79ab1f55e912791169dee1bd31052159d` Sanitized real-Gateway screenshot and observation: openclaw#135508 (comment) - Red, real Gateway: existing heartbeat scratch was returned by the Gateway, but the Control UI field stayed empty and sent no `cron.scratch.get` request. - Green, real Gateway: the field displayed the exact stored scratch and remained read-only. - The green observation recorded one `cron.scratch.get`, an empty mutable `payloadText`, and no scratch in `cron.list` or `cron.get`. - Mock browser end-to-end tests cover the visible authorized result, the read-only operator path, and a visible read failure: 3 passed. - The cron page unit suite covers an in-flight administrator-to-read-only downgrade: 35 passed. - Real-Gateway browser end-to-end proof: 1 passed. - Oxfmt, Oxlint, and `git diff --check` passed. Production: `+56/-3`. Tests and test support: `+172/-10`. ## Regression provenance PR openclaw#112967 introduced private heartbeat scratch without changing the existing UI projection. PR openclaw#130030 later made the empty projection explicit with the **Heartbeat monitor** label. ## AI assistance AI-assisted repair and validation. A maintainer independently inspected the storage owner, Gateway authorization, protocol schemas, UI projection and save boundaries, sibling payload kinds, tests, docs, history, and real browser behavior. Co-authored-by: gaoanze <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
This was referenced Oct 16, 2026
This was referenced Nov 16, 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
Part of the automation-unification program (#110950). Heartbeat cadence already moved to system-owned cron monitor jobs (#112585), but heartbeat context still lived in a workspace
HEARTBEAT.mdfile the runtime re-read on every tick — a legacy file store the storage policy says belongs in SQLite, with no revision safety and no way for the monitor to own its own context.Why This Change Was Made
cron_job_scratchtable in the shared state DB (no schema-version bump; declared in the canonical schema + idempotent ensure). 256 KiB cap, compare-and-swap revisions, and a content-NULL tombstone so the revision lineage stays monotonic across unset/recreate — a stale writer can never resurrect old content (ABA-safe).empty-heartbeat-fileskip,tasks:parsing, prose appended to the prompt). All steady-stateHEARTBEAT.mdreads, the workspace path hint, and the bootstrap-file injection/filter paths are deleted.heartbeat_respondgains an optionalscratchparameter that atomically replaces the monitor scratch for future heartbeats. The value never echoes back into model-visible tool output (onlyscratchUpdated/scratchBytes), and reply payloads carry it via a non-enumerable symbol so it cannot leak through channel data.openclaw doctor --fiximports each enrolled agent'sHEARTBEAT.mdinto its monitor's scratch: SHA-256 provenance, verify-after-write, archive under<state>/backups/heartbeat-migration/, then remove the file. Symlinks escaping the workspace, hard links, non-UTF-8, and >256 KiB files are refused with warnings; reruns are idempotent; operator-edited scratch is never overwritten.cron.scratch.get/cron.scratch.setgateway RPCs (closed schemas expose only content/revision/updatedAt +currentRevision; migration provenance stays internal) andopenclaw cron scratch <jobId> [--set|--file|--unset|--expected-revision].HEARTBEAT.md; disabled heartbeats keep a stable disabled monitor row (scratch survives re-enable); job removal prunes scratch; the dead CodexHEARTBEAT.mdcollaboration-guidance plumbing is deleted and prompt snapshots regenerated.Converting individual
tasks:entries into standalone cron jobs is intentionally deferred to a follow-up (semantic change).User Impact
Heartbeat checklists live in the cron monitor's private scratch instead of a workspace file. Existing setups migrate with
openclaw doctor --fix(original file archived). Default heartbeat prompt copy changed accordingly.agents.defaults.skipOptionalBootstrapFiles: ["HEARTBEAT.md"]remains accepted as a no-op.Evidence
tsgocore + core-test + extensions + extensions-test green; oxlint/oxfmt clean;pnpm buildgreen;pnpm prompt:snapshots:gen/checkcurrent; max-lines ratchet OK.extensions/codex/src/app-server/run-attempt.test.tsstalls on this heavily loaded host (load >100, swap exhausted; stalls identically without the diff-relevant shards); relying on hosted CI for that lane.