Skip to content

fix(cron): defer auto-disable notifications until persistence - #118384

Merged
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:issue-pr/118345-cron-notify-persist
Aug 3, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
qingminglong:issue-pr/118345-cron-notify-persist

Conversation

@qingminglong

Copy link
Copy Markdown
Contributor

Closes #118345

What Problem This Solves

Fixes an issue where cron jobs could be auto-disabled and notify listeners before the updated schedule-error state was durably persisted. Manual-run preflight could also mutate a job while only checking whether a run should proceed.

Why This Change Was Made

Cron maintenance notifications are now deferred until persistOrRestore succeeds, so failed writes cannot publish speculative auto-disable or schedule changes. Manual-run preflight skips schedule-error side effects because it is an advisory read-shaped check.

User Impact

Cron jobs no longer emit premature auto-disable notifications when persistence fails, and manual-run checks do not unexpectedly disable jobs or advance their schedule-error counters.

Evidence

  • node scripts/run-vitest.mjs src/cron/service/ops.test.ts src/cron/service/jobs.schedule-error-isolation.test.ts — 60 tests passed.
  • Runtime proof through createCronServiceState -> add -> inspectManualRunDisposition with an invalid timezone: { reason: not-due, enabled: true, scheduleErrorCount: 2, enqueueSystemEventCalls: 0, requestHeartbeatCalls: 0 }.
  • Targeted oxfmt --check and git diff --check passed.
  • autoreview --mode uncommitted --engine codex completed cleanly with no accepted/actionable findings.

Proof boundary: the runtime proof covers the production manual-preflight seam and its notification/state invariants; the focused tests cover persistence rollback and schedule-error isolation paths. Broader CI remains GitHub's responsibility.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 5:41 AM ET / 09:41 UTC.

ClawSweeper review

What this changes

The branch defers cron schedule-error auto-disable notifications until cron state persists, and prevents manual-run eligibility checks from advancing schedule-error state or disabling jobs.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR is still necessary: current main retains immediate schedule-error notification paths, while this branch threads deferred notifications through persistence-owning cron flows and makes advisory manual-run preflight skip schedule-error mutations. I found no discrete correctness or security regression in the updated head; keep it open for normal exact-head CI and maintainer merge review.

Priority: P2
Reviewed head: fa0b9bd69b6f97bb46d4e5e88ade1fd4139bdcb3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, evidence-backed cron repair with no source-level blocker found; routine exact-head CI remains the final merge gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body includes after-fix live output from the manual-preflight production seam and a concrete observed result showing unchanged job state with zero notification side effects; focused tests supplement that proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body includes after-fix live output from the manual-preflight production seam and a concrete observed result showing unchanged job state with zero notification side effects; focused tests supplement that proof.
Evidence reviewed 6 items Current-main defect surface: Current main records schedule-computation errors through recomputeJobNextRunAtMs; absent a deferred notification list, autoDisableCronJob immediately invokes its notification callback. The linked issue’s pre-persist-notify premise therefore remains applicable to current code.
Durability owner contract: persistOrRestore restores the state snapshot on failed writes and drains postPersistNotifications only after persist reports success, which is the correct canonical boundary for the branch’s queued notifications.
Manual preflight is read-shaped: Current inspectManualRunDisposition calls the shared preflight before command-lane reservation, while current preflight recomputes maintenance state without persisting it. The proposed skipScheduleErrorHandling path directly prevents an invalid schedule from turning that advisory read into an auto-disable transition.
Findings None None.
Security None None.

How this fits together

Cron scheduling recomputes each job’s next run and may auto-disable invalid schedules after repeated failures. Timer, read, mutation, and manual-run entry points own persistence; they must publish agent-facing notifications only after that durable write succeeds.

flowchart TD
  A[Cron job store] --> B[Schedule recomputation]
  B --> C{Schedule valid?}
  C -->|Repeated error| D[Queue auto-disable notification]
  C -->|Valid| E[Update next run]
  D --> F[Persist or restore cron state]
  E --> F
  F -->|Write succeeds| G[Notify agent and wake timer]
  F -->|Write fails| H[Restore prior state]
  I[Manual-run preflight] --> J[Advisory recomputation without error transition]
Loading

Before merge

  • Complete next step (P2) - No repair lane is warranted because review found no actionable patch defect; await the remaining exact-head checks and normal maintainer merge review.
Agent review details

Security

None.

PR surface

Source +49, Tests +115. Total +164 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 6 80 31 +49
Tests 1 116 1 +115
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 196 32 +164

Review metrics

Metric Value Why it matters
Production versus regression coverage production +80/-31, tests +116/-1 The production growth is justified by threading the existing deferred-notification invariant through six persistence-owning cron paths, with most added lines covering rollback, roster-outcome, and read-preflight regressions.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #118345
Summary: This PR is the concrete candidate fix for the linked cron persistence and manual-preflight invariant report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Merge the branch after the remaining exact-head checks pass, preserving persistOrRestore as the sole success boundary that releases queued cron notifications.

Do we have a high-confidence way to reproduce the issue?

Yes. The PR provides a focused current-head runtime proof through inspectManualRunDisposition using an invalid timezone, showing no auto-disable or notification side effects; the focused cron suite also covers persistence rollback and schedule-error isolation.

Is this the best way to solve the issue?

Yes. Deferring notifications at the existing persistOrRestore durability boundary and suppressing schedule-error transitions only for advisory manual preflight is narrower and more maintainable than adding downstream notification guards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0fbddda540e1.

Labels

Label justifications:

  • P2: This fixes a bounded cron correctness problem that can publish a false automation state to an operator, without evidence of data loss, a crash loop, or a default-path outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live output from the manual-preflight production seam and a concrete observed result showing unchanged job state with zero notification side effects; focused tests supplement that proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live output from the manual-preflight production seam and a concrete observed result showing unchanged job state with zero notification side effects; focused tests supplement that proof.

Evidence

What I checked:

  • Current-main defect surface: Current main records schedule-computation errors through recomputeJobNextRunAtMs; absent a deferred notification list, autoDisableCronJob immediately invokes its notification callback. The linked issue’s pre-persist-notify premise therefore remains applicable to current code. (src/cron/service/jobs-scheduling.ts:533, a0a189360570)
  • Durability owner contract: persistOrRestore restores the state snapshot on failed writes and drains postPersistNotifications only after persist reports success, which is the correct canonical boundary for the branch’s queued notifications. (src/cron/service/store.ts:307, a0a189360570)
  • Manual preflight is read-shaped: Current inspectManualRunDisposition calls the shared preflight before command-lane reservation, while current preflight recomputes maintenance state without persisting it. The proposed skipScheduleErrorHandling path directly prevents an invalid schedule from turning that advisory read into an auto-disable transition. (src/cron/service/ops-run-preparation.ts:210, fa0b9bd69b6f)
  • Deferred notification coverage: The PR routes timer, catch-up, read, and agent-removal maintenance recomputations through deferred lists and passes them to persistOrRestore; its follow-up commit also drains queued notifications after an uncertain roster commit, matching the durable-cron outcome rather than the failed-write path. (src/cron/service/timer-scheduler.ts:208, fa0b9bd69b6f)
  • Focused regression proof: The PR body supplies a production-seam runtime result for inspectManualRunDisposition with an invalid timezone—enabled remains true, the error count remains unchanged, and no event or heartbeat is requested—plus 60 passing focused cron tests. This is real after-fix behavior evidence, not mock-only proof. (src/cron/service/ops.test.ts:1746, fa0b9bd69b6f)
  • Feature-history provenance: Current source blame attributes the central agent-removal transaction area to the shallow-history boundary authored by Peter Steinberger, and Peter Steinberger authored the follow-up PR commit that handles uncertain roster outcomes. The earlier PR-review head is not merged into local main. (src/cron/service/ops-mutations.ts:504, fa0b9bd69b6f)

Likely related people:

  • steipete: Peter Steinberger authored the PR’s follow-up durable-roster handling and is the author shown at the current shallow-history boundary for the central cron mutation path. (role: recent area contributor and follow-up author; confidence: high; commits: fa0b9bd69b6f, 9f5f55bb886; files: src/cron/service/ops-mutations.ts, src/cron/service/store.ts, src/cron/service/timer-scheduler.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-03T02:37:04.699Z sha 15ed0e2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T03:16:56.319Z sha 15ed0e2 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 3f3e59b into openclaw:main Aug 3, 2026
121 of 123 checks passed
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
…aw#118384)

* fix(cron): defer auto-disable notifications until persistence

* fix(cron): emit disable notifications only after durable roster commits

---------

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

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron auto-disable can still notify pre-persist via recompute paths; manual-run preflight mutates without persisting

2 participants