Skip to content

feat(automations): migrate heartbeat jobs through Doctor - #179387

Merged
steipete merged 17 commits into
mainfrom
steipete/automations-s3
Oct 21, 2026
Merged

steipete merged 17 commits into
mainfrom
steipete/automations-s3

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #167796. Replaces #178990; its reviewed migration and contributor history are preserved. The old PR has a native tooling binding deadlock.

This is slice 3 of 4 of the heartbeat-to-Automations migration:

  1. fix(cron): preserve pending reminder outcomes across restarts #178650 — landed: prevent main-session cron events from being recorded successful before adoption.
  2. refactor(automations): run scheduled conversation work through session admission #178764 — landed: session-controller execution and settlement; additive Claw review schema.
  3. This PR — migrate heartbeat data and make ordinary automation jobs authoritative.
  4. After this PR lands — remove the retired heartbeat executor and the approved breaking plugin-SDK surfaces.

What Problem This Solves

Heartbeat monitors cannot become independently editable Automations while their settings, scratch, execution policies, and startup reconciliation remain owned by the old heartbeat path.

User Impact

Existing monitors and supported legacy heartbeat tasks become ordinary editable Automations, preserving job identity, run history, scratch revisions and explicit deletion, disabled state, scheduling anchors, pending occurrences, and existing tool authority. Run openclaw doctor --fix after a manual binary replacement; supported updates run the same migration through Doctor. Edit, disable, or delete the resulting job in Automations or through the CLI. Restart, config reload, and repeated Doctor runs preserve those choices.

This implements Peter's approved October 3/12 migration design and the October 18 additive Claw review decision. Claw Add converts legacy heartbeat declarations into ordinary jobs and shows their positive-integer everyMs schedules and owner delivery truthfully; existing { cron, timezone }, none, and last-channel variants retain their meaning.

Doctor emits this notice once when the migration receipt completes:

Migrated heartbeats now use standard Automations delivery. Heartbeat-specific duplicate suppression and no-route skipping were removed: repeated updates can be delivered, and a missing route no longer skips the run before execution. Delivery failures follow ordinary automation handling. Review the migrated jobs' delivery settings if you relied on either behavior.

The shared state schema advances to 30 so an older scheduler cannot ignore the new job policies. Keep the verified pre-upgrade backup for rollback; do not lower the schema marker. The agent schema remains 31. Physical executor and public SDK removal remain in slice 4.

Why This Change Was Made

The existing Cron service and session controller own migrated execution from admission through settlement. Main-session system events and agent turns use that boundary; queue acceptance alone is not success. Job-level active hours, idle admission, scratch, structured results, and owner/direct-message delivery replace the corresponding heartbeat behavior. Quiet no_change results suppress automatic delivery without hiding execution failures, and optional reasoning accompanies meaningful output. Retained authenticated source, workspace custody, and current permission checks remain in force.

Doctor writes and verifies canonical jobs and context before retiring legacy inputs. Its existing backup and include-aware config owners preserve recovery. Completed provisioning receipts prevent deleted monitors from reappearing, and startup/reload no longer reconcile the old monitor declarations. Explicit setup creates the ambient owner's default proactive check once. Claw Add creates imported jobs disabled until scratch is accepted and activation is verified; an uncertain or conflicting scratch write retains the admitted agent/jobs and reports the required inspection instead of overwriting concurrent edits.

The repair commit fa7eac0a0688 addresses defects exposed by candidate CI: the missing bounded v30 maintenance step; published, native, and plugin migration support; a type-import cycle; health and config producers retaining obsolete heartbeat fields; and fixtures still calling the retired execution contract. The changes keep these responsibilities with their existing owners. Test-module extractions preserve assertions and budgets.

It also fixes a Claw Add review finding: importing a start-only or end-only active-hours window synthesized the missing endpoint and unexpectedly restricted runs. Incomplete windows now retain the prior unrestricted behavior for both imported monitor and task jobs; complete overnight windows remain enforced.

The final adapter repair preserves announce/owner delivery when opening and saving a migrated main-session agent-turn job. CLI add/edit now accept the same delivery policies as the existing Cron service; unflagged main jobs retain their internal-delivery default. Main-session system-event and script chat restrictions remain enforced. The original CLI and browser failures reproduce before the repair.

Limits and recovery behavior:

  • Missing or ambiguous owner identity never falls back to the last group conversation. A missing route does not skip execution; a configured DM block remains intentional non-delivery.
  • A legacy model outside the agent's current allowed policy is dropped with a diagnostic. Doctor preserves allowed overrides and does not expand permission or model allowlists. Changed definitions may require fresh standing approval.
  • Ambiguous migration inputs remain recoverable and their pending jobs cannot run. Archived source bytes and explicit scratch tombstones are preserved; stale pending facts are not promoted into a replacement session.
  • Scratch becomes model context, so it is not a secret store. It remains revision-guarded and omitted from ordinary job/history responses.
  • Script state advances only after the complete run succeeds, preserving the existing retry contract when a requested follow-up is refused. Scripts with external effects must remain idempotent.
  • This does not promise exactly-once arbitrary tool effects across a crash. The existing Cron recovery contract still applies; the main-session system-event regression specifically prevents false success and replay before adoption.
  • Legacy protocol-v4 controls remain as adapters. Transport keepalives are unchanged. This slice adds no new global configuration, retention policy, or Claw lifecycle owner.

Evidence

One-shot active-hours repair

Current candidate: 06efba2caff95. The three-file repair passes all 36 focused tests in the session-payload, restart-event, and session-run suites, the canonical Cron test type graph, targeted lint, format, and diff checks. Its new three-case active-hours regression covers one-shot retention plus both recurring schedule controls. Exact-head CI is complete with the qualified inherited failures below.

The pre-landing review found that an at job due outside its active hours was marked skipped and disabled before any execution. Both active-hours checks now use the existing admission-deferral path for one-shot jobs. The original occurrence stays pending without a terminal history entry, then executes once when its window opens; recurring schedules retain skip-and-advance behavior. The owning-boundary regression failed on the prior head (enabled was false without invoking execution), while both recurring controls passed.

Previous integration: 3705d289f00d0cf611f76aadebb7b7b0e47b8bbe merges main e40cbcf8662a1cc5fcbea5a6154e0aa474dfcd05. Main moved the status presenter in #179372; the resolution preserves that owner and ports S3’s enabled cron-schedule display and Automation delivery remediation. It keeps the deleted old presenter deleted. Both status regression cases fail with the incoming main implementation and pass after the resolution.

The integrated tree passes 98/98 focused tests in six files (Doctor cadence/task migration, Cron restart/settlement, and both status owners), the canonical command, Doctor and Cron type graphs, typed lint, format and index checks. Independent review of the two-file manual resolution is scoped-clean for P0–P2. Exact-head CI is complete as described below; earlier run results retain their original revision scope.

Previous-head run 39589061469, attempt 2 is complete. The sole job-only retry, checks-node-changed-compact-large-16, passed. Its Gateway-close model-acquisition case passed once on both this candidate and clean main 3241b4220e8c under the CI Node/Bun pins; no product fix is claimed. Feishu body-cancellation and iOS keyboard-focus timing cases passed naturally on this head. Types, lint, UI, Docker seed, Android, and PostgreSQL conformance passed.

Six owner jobs remain failed, with eleven qualified main-baseline cases: memory publication admission and retained-worker read repair (extensions-bundle-20/23); Telegram root allowlist/open delivery (changed-9), emoji discovery (changed-14), provider-failure settlement (changed-16); and five non-native Discord progress/custody waits (changed-4). The aggregate gate remains failed. These are attributed inherited failures, not green CI, and use Peter's authorized native exception. Attempt 2 carries these original executions with new job IDs; current-ID logs match the original logs byte for byte.

The inspected checkout is bc34faa5c97c, with ordered parents actual main 184868ac8a4a and candidate 3705d289f00d. Named source objects match between that baseline and the tested merge. Historical macOS main controls retain their original platform/revision limits. Since those controls, the memory SDK tree has only unrelated test refactors; Discord's new deletion retry has no backoff on the fixtures' successful DELETE responses, and the custody case disables streaming. Those changes were inspected explicitly. No fresh Linux replay is claimed for these retained controls. The former restart-warning signature is fixed on main and is absent from this run.

Earlier main 2db57c72bf2448a2ff2004fa96ffd54672cd25b1 was merged without rewriting reviewed history. The only manual resolutions preserve its Cron fixture reuse and consolidated origin-route cases while keeping S3's captured-target, deferred-receiver, cancellation, and settlement contracts. The Security Review publisher workflow is byte-identical to this main revision, including #178708; it was not edited or bypassed.

On the resolved tree committed as c0d0b44bc72be9f8ff3ba2f173d1c506af53222f:

  • 83/83 focused tests in six files pass: 26 Cron/controller cases, including restart settlement and both resolved suites, and 57 Doctor cadence/task migration cases.
  • Canonical Cron, Doctor, and root-tooling test type graphs pass. Typed lint, formatting, diff, and unmerged-index checks pass.
  • Independent Codex review of the two-file resolution delta is scoped-clean for P0–P2.
  • The preceding delivery repair passes 90/90 CLI tests, 81/81 UI owner tests, and 2/2 desktop/narrow browser edit-save cases, plus targeted types/lint/format and independent scoped-clean review. These inputs are unchanged by the merge. Its three new positive CLI cases and the actual editor fail before the fix; main default delivery and system-event/script restrictions remain preserved.
  • The preceding integration passed 135/135 focused tests and the canonical Cron, config, Doctor, and root-tooling type graphs. That is retained revision-scoped evidence, not a second run on this head.

Retained proof, with its original revision scope: serial Doctor 15/15, focused migration/restart 71 tests in 12 files, Claw Add incomplete-hours RED/GREEN 3/3, synthetic Automations UI 8/8, and published-upgrade corruption 11/11. S1's negative control reproduced false success before adoption on main. Required secretless Linux attribution was completed; no task-owned leases remain. Optional AWS/package/PostgreSQL extras were omitted at Peter's direction.

Earlier run 39560577767 ended with the inherited tooling TS2345 failure; incoming main resolved that graph locally. Run 39572941097, on acc023cf50fa6, completed with eight independently reproduced main signatures (memory publication/read repair, planner environment metadata, restart diagnostic, Telegram policy/settlement/emoji, and Discord progress). Its diagnosed Levanto and Codex retries passed; the subpixel UI geometry failure passed local controls. Those results are historical. Exact-head run 39580173234, attempt 2 completed with 170 passing and 15 skipped jobs. Test types, production types, all nine UI E2E shards, and security-fast passed. The one permitted Levanto timing retry passed; that replay is not claimed as a code fix. Seven owner jobs remain red with twelve independently reproduced main signatures, plus the aggregate gate. Peter authorized the native inherited-failure exception; these failures are not represented as green.

Historical #178990 qualification table (not the current failure set):

Failed job Main-baseline qualification
extensions-bundle-20 Memory publication admission expects schemaRebuilt=true; identical retained clean-main failure and unchanged causal source inputs.
extensions-bundle-23 Memory retained-worker read expects repairPending=true; identical retained clean-main failure and unchanged causal source inputs.
compact-large-15 Restart tombstone expects a slow-lifecycle warning that current main suppresses for uncontended work; identical retained clean-main failure.
changed-9 Both Telegram inherited-policy cases return delivered=false on a fresh build of actual CI main 662e2d3.
changed-14 Telegram emoji discovery has no request or scripted call on the same freshly built main.
changed-16 Telegram provider failure emits the Gateway-restarting notice on the same freshly built main.
changed-4 Five non-native Discord progress/custody cases reproduce on clean main; subsequent native-command-only changes do not exercise those fixtures, and the named inputs remain equal.

The fresh Telegram controls used CI-pinned Node 24.19.0 and Bun on macOS. The retained memory, restart and Discord controls used their recorded macOS runtime versions; they are not claimed as fresh Linux runs. The inspected CI checkout is 32bc0b1ee806, with ordered parents main 662e2d3 and candidate c0d0b44. Exact logs, controls and source-object hashes qualify every remaining failed job for native verification.

Line delta against integrated main e40cbcf8662a (tests include test support; generated includes config baselines):

Category Added Removed
Production/tooling 9,508 2,925
Tests/support 11,297 5,546
Docs 762 842
Generated output 5 9

Synthetic desktop, before:

Automations desktop before migration

Synthetic desktop, after:

Editable migrated automation and scratch on desktop

Synthetic narrow layout, before:

Automations narrow layout before migration

Synthetic narrow layout, after:

Migrated automation owner delivery on narrow layout

Main-session delivery repair, synthetic before:

Main-session job loses announce delivery before the repair

Main-session delivery repair, synthetic after:

Main-session job preserves announce and owner delivery after the repair

This replacement preserves the reviewed migration and contributor history from #178990, with the documented current-main integration above. The original PR’s retained native workflow predates #178708 and cannot validate the current Security Review publisher. A new PR number allows the normal native workflow to bind current tooling; no security workflow or guard is changed. Historical results are explicitly identified above; the previous replacement head completed its own exact-head run and the one authorized timing retry. The active-hours follow-up completed its exact-head CI and the two authorized job-only timing retries.

Final exact-head CI

Run 39595872688, attempt 3 completed on 06efba2caff95: 176 passed, 15 skipped, four inherited owner jobs failed, plus the aggregate gate. Test and production types, lint, security-fast, all UI/UI E2E shards, Docker seed, Android, and PostgreSQL passed. The Gateway-close and Levanto timing cases passed their single job-only retries; no source, assertion, or timeout was changed for those replays.

Failed owner job Qualification
extensions-bundle-20 Memory publication admission: schemaRebuilt=false, identical retained clean-main failure.
extensions-bundle-23 Memory retained-worker read: memorySourceProvenanceRepairPending=false, identical retained clean-main failure.
changed-4 Five non-native Discord progress/custody waits, matching retained independently failing main controls.
compact-small-5 models.prepared.test.ts model-list projection assertion: 650 resolver calls instead of at most 10. The exact case fails identically on clean actual CI main 60a97e3012ed and passes on the candidate. This is a work-count assertion, not a timing limit.

The inspected checkout is 3f4f77eb5504, with ordered parents actual main 60a97e3012ed and candidate 06efba2caff95. Every named causal input matches baseline to tested merge. Memory and Discord controls retain their documented historical macOS revision/runtime limits; no fresh Linux replay is claimed. The model-list control used CI-pinned Node 24.19.0 and Bun on macOS. Its spied provider-policy module has one disclosed S3 change adding the proactive-cadence hook key; the resolver implementation and counted callers are unchanged. The exact diff and rationale are retained in the native evidence.

Attempt 3 retains the four original failed executions under new job IDs, proven by matching timestamps and conclusions; their original logs were reused. All 196 jobs are terminal. Temporary queued duplicates from attempt 2 are absent. The final aggregate classifier timed out, so this exception relies on the inspected case-level main attributions, not an automatic matching-signature verdict. CI remains red; Peter authorized the native inherited-failure exception.

Migrate heartbeat state, scratch, execution policy, and monitor ownership into ordinary editable Automations. Preserve Doctor backups and a once-only migration notice, controller settlement, retained source authority, and revision-owned scratch.
Separate legacy enrollment from migration discovery so stored tasks retain implicit ambient cadence without provisioning jobs on empty installations. Preserve explicit monitor and task disables.
Retain current Cron test simplifications with the Automations settlement path. Keep producer-owned scheduled and immediate turns isolated from unrelated passive notices in the persisted-session routing proof.
Merge current main, regenerate the config baseline, and keep fixture scheduling disabled through the current Cron owner. Prepare incognito plugin metadata per case after shared lifecycle cleanup.
Merge current main without rewriting reviewed history. Preserve command admission, timeout, revocation, drain and session-event notification coverage while adopting the shared Cron fixtures. Regenerate config documentation through its owner.
Keep the five native Mac presence identity assertions on the existing S3 options-based fixture. The merged cases still referenced their predecessor helper names, breaking the Gateway-methods test type graph and runtime shard.

Validation: 21 focused cases, Gateway-methods test type graph, typed lint, formatting, and scoped review pass.
Preserve main's Cron test fixtures while retaining Doctor-owned heartbeat migration and controller settlement. Carry the current Security Review publisher unchanged from main.
Keep announce and owner delivery available for main-session agent turns in the CLI and editor. Preserve unflagged main delivery defaults and system-event/script restrictions.
Preserve main fixture reuse and origin-route table cleanup while retaining receipt-owned script follow-ups, captured destinations, cancellation, and restart settlement.
@steipete steipete added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: voice-call Channel integration: voice-call app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: feishu Channel integration: feishu size: XL extensions: anthropic extensions: ollama labels Oct 21, 2026
obviyus added a commit that referenced this pull request Nov 20, 2026
…"did not start" notices (#202390)

Root cause: src/cron/service/timer-execution.ts:220 (and its twin in src/cron/session-run.ts:224) returns `status: "skipped"` when `skipIfScratchEmpty` finds an explicitly empty checklist, and every skipped run is a failure downstream: `resolveCronCompletionStatus` maps skipped to `completionStatus: "failed"`, run storage records it as failed, it counts toward skipped-run alerts, and the Gateway posts "did not start" for any skipped run without an admission-deferral reason.

Fixes #202350. Thanks @herosuncy for the clear report and repro.

## What Problem This Solves

A heartbeat-style automation with "Skip empty scratch" on and the default comments-only checklist skips every interval, as intended. But each skip is recorded as a failed run, and the owner conversation gets `Automation "heartbeat-main" did not start: Automation scratch is explicitly empty. Check automation history, resolve the cause, then run it again.` every 30 minutes. An idle heartbeat looks broken, and the only workaround was disabling it.

## User Impact

An empty checklist now completes quietly: run history shows `status: "ok"`, `completionStatus: "succeeded"` and the same summary `Automation scratch is explicitly empty`, the model is still not called, no "did not start" notice is posted, and it no longer counts toward skipped-run alerts. Real start failures (for example a model that is not configured) still record a failed run and still post the notice.

## Why This Change Was Made

The skip is a deliberate "nothing to do" decision, not a failed start. The cron outcome model has no non-failure skipped state, but it already has one for a run that completes with nothing to deliver: `status: "ok"` with a delivery suppression reason (the same outcome a heartbeat turn with nothing to report records). Both empty-scratch producers now return that outcome with the existing `"empty"` suppression reason, so completion, storage, failure alerts and the conversation notice all treat it as a quiet completion through their existing rules. The primary webhook already ignored skips that never started (#200032); its guard now ignores any non-error run that never started, so the empty-checklist summary is still not POSTed as output. No new status, field, wording or stored shape.

Behavior notes: `lastRunStatus` for these ticks is `ok` instead of `skipped`, and `consecutiveSkipped` no longer grows. A one-shot (`at`) job with `deleteAfterRun` and an empty checklist is now deleted like any other succeeded one-shot instead of being kept disabled; it was already consumed and never replayed.

History: the skipped return came with the Doctor heartbeat migration (ec5d369, #179387). It predates the "did not start" notice, and #194276 only kept the empty-scratch notice as an untouched control while fixing active-hours/busy deferrals, so recording it as a failure was never a product decision.

## Evidence

Real Gateway from source (`ocx src`), isolated state, deterministic local Responses provider that logs every model request, and a process-local Gateway clock stepped past each due time (the system clock is untouched). Job from the issue: every 30 min, `sessionTarget: session:agent:main:main`, `skipIfScratchEmpty: true`, scratch = the issue's comments-only template.

| | main e99e848 | this PR 0519148 |
| --- | --- | --- |
| 2 scheduled ticks of heartbeat-main | `skipped` / `failed` x2 | `ok` / `succeeded` x2, same summary |
| job state | `consecutiveSkipped: 2` | `consecutiveSkipped: 0` |
| "did not start" notices in the session | 0 -> 2 | 0 -> 0 |
| model requests during the ticks | 1 -> 1 | 1 -> 1 |
| control: checklist with a real item | runs the turn (`ok`/`succeeded`, model called) | same |
| control: model override on an unconfigured provider | `error`/`failed` + "did not start" notice | same |

Observed output: #202390 (comment)

- `src/cron/service.runs-one-shot-main-job-disables-it.test.ts`: the existing scratch-empty one-shot case now asserts `ok`/`succeeded` history and no skip counter; it fails on main and passes here.
- `src/cron/service.trigger-eval.test.ts`: the existing webhook case still proves no POST for the empty checklist.
- Production: +7/-4 lines in three files. Tests: +9/-4 (the one regression).

Merge danger: two-way door. Nothing is migrated; a revert restores skipped/failed recording for later ticks, and rows written meanwhile stay `ok`/`succeeded`. Blast radius: automations with `skipIfScratchEmpty` and an empty checklist (run history status, completion, notices, skip alerts, `deleteAfterRun` one-shots).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
…"did not start" notices (openclaw#202390)

Root cause: src/cron/service/timer-execution.ts:220 (and its twin in src/cron/session-run.ts:224) returns `status: "skipped"` when `skipIfScratchEmpty` finds an explicitly empty checklist, and every skipped run is a failure downstream: `resolveCronCompletionStatus` maps skipped to `completionStatus: "failed"`, run storage records it as failed, it counts toward skipped-run alerts, and the Gateway posts "did not start" for any skipped run without an admission-deferral reason.

Fixes openclaw#202350. Thanks @herosuncy for the clear report and repro.

## What Problem This Solves

A heartbeat-style automation with "Skip empty scratch" on and the default comments-only checklist skips every interval, as intended. But each skip is recorded as a failed run, and the owner conversation gets `Automation "heartbeat-main" did not start: Automation scratch is explicitly empty. Check automation history, resolve the cause, then run it again.` every 30 minutes. An idle heartbeat looks broken, and the only workaround was disabling it.

## User Impact

An empty checklist now completes quietly: run history shows `status: "ok"`, `completionStatus: "succeeded"` and the same summary `Automation scratch is explicitly empty`, the model is still not called, no "did not start" notice is posted, and it no longer counts toward skipped-run alerts. Real start failures (for example a model that is not configured) still record a failed run and still post the notice.

## Why This Change Was Made

The skip is a deliberate "nothing to do" decision, not a failed start. The cron outcome model has no non-failure skipped state, but it already has one for a run that completes with nothing to deliver: `status: "ok"` with a delivery suppression reason (the same outcome a heartbeat turn with nothing to report records). Both empty-scratch producers now return that outcome with the existing `"empty"` suppression reason, so completion, storage, failure alerts and the conversation notice all treat it as a quiet completion through their existing rules. The primary webhook already ignored skips that never started (openclaw#200032); its guard now ignores any non-error run that never started, so the empty-checklist summary is still not POSTed as output. No new status, field, wording or stored shape.

Behavior notes: `lastRunStatus` for these ticks is `ok` instead of `skipped`, and `consecutiveSkipped` no longer grows. A one-shot (`at`) job with `deleteAfterRun` and an empty checklist is now deleted like any other succeeded one-shot instead of being kept disabled; it was already consumed and never replayed.

History: the skipped return came with the Doctor heartbeat migration (b2a65a8, openclaw#179387). It predates the "did not start" notice, and openclaw#194276 only kept the empty-scratch notice as an untouched control while fixing active-hours/busy deferrals, so recording it as a failure was never a product decision.

## Evidence

Real Gateway from source (`ocx src`), isolated state, deterministic local Responses provider that logs every model request, and a process-local Gateway clock stepped past each due time (the system clock is untouched). Job from the issue: every 30 min, `sessionTarget: session:agent:main:main`, `skipIfScratchEmpty: true`, scratch = the issue's comments-only template.

| | main 704d0b3 | this PR 0519148 |
| --- | --- | --- |
| 2 scheduled ticks of heartbeat-main | `skipped` / `failed` x2 | `ok` / `succeeded` x2, same summary |
| job state | `consecutiveSkipped: 2` | `consecutiveSkipped: 0` |
| "did not start" notices in the session | 0 -> 2 | 0 -> 0 |
| model requests during the ticks | 1 -> 1 | 1 -> 1 |
| control: checklist with a real item | runs the turn (`ok`/`succeeded`, model called) | same |
| control: model override on an unconfigured provider | `error`/`failed` + "did not start" notice | same |

Observed output: openclaw#202390 (comment)

- `src/cron/service.runs-one-shot-main-job-disables-it.test.ts`: the existing scratch-empty one-shot case now asserts `ok`/`succeeded` history and no skip counter; it fails on main and passes here.
- `src/cron/service.trigger-eval.test.ts`: the existing webhook case still proves no POST for the empty checklist.
- Production: +7/-4 lines in three files. Tests: +9/-4 (the one regression).

Merge danger: two-way door. Nothing is migrated; a revert restores skipped/failed recording for later ticks, and rows written meanwhile stay `ok`/`succeeded`. Blast radius: automations with `skipIfScratchEmpty` and an empty checklist (run history status, completion, notices, skip alerts, `deleteAfterRun` one-shots).

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…"did not start" notices (#202390)

Root cause: src/cron/service/timer-execution.ts:220 (and its twin in src/cron/session-run.ts:224) returns `status: "skipped"` when `skipIfScratchEmpty` finds an explicitly empty checklist, and every skipped run is a failure downstream: `resolveCronCompletionStatus` maps skipped to `completionStatus: "failed"`, run storage records it as failed, it counts toward skipped-run alerts, and the Gateway posts "did not start" for any skipped run without an admission-deferral reason.

Fixes #202350. Thanks @herosuncy for the clear report and repro.

## What Problem This Solves

A heartbeat-style automation with "Skip empty scratch" on and the default comments-only checklist skips every interval, as intended. But each skip is recorded as a failed run, and the owner conversation gets `Automation "heartbeat-main" did not start: Automation scratch is explicitly empty. Check automation history, resolve the cause, then run it again.` every 30 minutes. An idle heartbeat looks broken, and the only workaround was disabling it.

## User Impact

An empty checklist now completes quietly: run history shows `status: "ok"`, `completionStatus: "succeeded"` and the same summary `Automation scratch is explicitly empty`, the model is still not called, no "did not start" notice is posted, and it no longer counts toward skipped-run alerts. Real start failures (for example a model that is not configured) still record a failed run and still post the notice.

## Why This Change Was Made

The skip is a deliberate "nothing to do" decision, not a failed start. The cron outcome model has no non-failure skipped state, but it already has one for a run that completes with nothing to deliver: `status: "ok"` with a delivery suppression reason (the same outcome a heartbeat turn with nothing to report records). Both empty-scratch producers now return that outcome with the existing `"empty"` suppression reason, so completion, storage, failure alerts and the conversation notice all treat it as a quiet completion through their existing rules. The primary webhook already ignored skips that never started (#200032); its guard now ignores any non-error run that never started, so the empty-checklist summary is still not POSTed as output. No new status, field, wording or stored shape.

Behavior notes: `lastRunStatus` for these ticks is `ok` instead of `skipped`, and `consecutiveSkipped` no longer grows. A one-shot (`at`) job with `deleteAfterRun` and an empty checklist is now deleted like any other succeeded one-shot instead of being kept disabled; it was already consumed and never replayed.

History: the skipped return came with the Doctor heartbeat migration (ec5d369, #179387). It predates the "did not start" notice, and #194276 only kept the empty-scratch notice as an untouched control while fixing active-hours/busy deferrals, so recording it as a failure was never a product decision.

## Evidence

Real Gateway from source (`ocx src`), isolated state, deterministic local Responses provider that logs every model request, and a process-local Gateway clock stepped past each due time (the system clock is untouched). Job from the issue: every 30 min, `sessionTarget: session:agent:main:main`, `skipIfScratchEmpty: true`, scratch = the issue's comments-only template.

| | main e99e848 | this PR 0519148 |
| --- | --- | --- |
| 2 scheduled ticks of heartbeat-main | `skipped` / `failed` x2 | `ok` / `succeeded` x2, same summary |
| job state | `consecutiveSkipped: 2` | `consecutiveSkipped: 0` |
| "did not start" notices in the session | 0 -> 2 | 0 -> 0 |
| model requests during the ticks | 1 -> 1 | 1 -> 1 |
| control: checklist with a real item | runs the turn (`ok`/`succeeded`, model called) | same |
| control: model override on an unconfigured provider | `error`/`failed` + "did not start" notice | same |

Observed output: #202390 (comment)

- `src/cron/service.runs-one-shot-main-job-disables-it.test.ts`: the existing scratch-empty one-shot case now asserts `ok`/`succeeded` history and no skip counter; it fails on main and passes here.
- `src/cron/service.trigger-eval.test.ts`: the existing webhook case still proves no POST for the empty checklist.
- Production: +7/-4 lines in three files. Tests: +9/-4 (the one regression).

Merge danger: two-way door. Nothing is migrated; a revert restores skipped/failed recording for later ticks, and rows written meanwhile stay `ok`/`succeeded`. Blast radius: automations with `skipIfScratchEmpty` and an empty checklist (run history status, completion, notices, skip alerts, `deleteAfterRun` one-shots).

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit ccc83c7)

Operator-requested 2026.11.10 stable backport (Dallin, 2026-11-24 04:15). Clean apply. Later main mentions: none.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: buzz channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: voice-call Channel integration: voice-call cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: anthropic extensions: ollama gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant