Repository navigation
feat(cron): auto-disable repeatedly failing recurring jobs - #118113
Conversation
Refs #118089 Release note: recurring automations now auto-disable after 10 consecutive run failures, record the reason, and notify their owning agent.
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 2:29 PM ET / 18:29 UTC. ClawSweeper reviewWhat this changesThe PR automatically disables repeatedly failing Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain This PR remains necessary: current main can accumulate recurring-job execution errors and only surfaces chronic enabled jobs through Doctor; it does not durably auto-disable a time-based recurring job after a run-failure threshold. The patch follows the scheduler’s existing auto-disable pattern and has no discrete correctness finding, but its new default stop condition and persisted/public state contract need maintainer product confirmation and terminal real-behavior proof before merge. Likely related people: Priority: P1 Review scores
Verification
How this fits togetherCron schedules run agent, command, and system-event jobs, then persist completion state and schedule the next occurrence. This change turns the existing consecutive-error counter into a scheduler-owned terminal state, which is then shown to the operator and delivered to the owning agent as a recovery event. flowchart LR
Schedule[Recurring schedule] --> Run[Job execution]
Run --> Outcome[Persist run outcome]
Outcome --> Streak[Update consecutive errors]
Streak --> Threshold{Failure threshold reached?}
Threshold -->|No| Retry[Backoff and next run]
Threshold -->|Yes| Disable[Disable and record reason]
Disable --> Notify[Post-persist owner notification]
Disable --> Operator[CLI, Doctor, Gateway, UI]
Decision needed
Why: The patch is technically coherent, but choosing a fixed terminal default changes whether existing operator workflows continue retrying or intentionally stop after persistent failures. Before merge
Agent review detailsSecurityNone. PR surfaceSource +293, Tests +558, Docs +2. Total +853 across 23 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep one scheduler-owned, post-persist auto-disable transition; explicitly accept the fixed default threshold for existing recurring jobs and add redacted built CLI/Gateway proof that a threshold breach disables the persisted job, sends the recovery event, and cleanly resets on Do we have a high-confidence way to reproduce the issue? Yes, source reproducible: current main persists a recurring job’s consecutive execution-error streak yet does not use it to terminate the recurring schedule. The PR body also reports a real built CLI/Gateway probe for the first failure, while focused tests cover the threshold transition. Is this the best way to solve the issue? Yes, conditionally: the branch places the transition at the authoritative outcome and startup-repair owners, preserves stale/forced-run boundaries, and shares the existing schedule-error auto-disable mechanism. The remaining choice is whether the fixed default threshold is the desired product policy for existing jobs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d02101d7ceb6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…118113) Refs openclaw#118089 Release note: recurring automations now auto-disable after 10 consecutive run failures, record the reason, and notify their owning agent.
What Problem This Solves
Recurring automations could fail forever on the default configuration without a visible terminal outcome. Failure alerts are opt-in, so a permanently broken job could continue consuming scheduler work while only accumulating
state.consecutiveErrors.This completes the existing cron auto-disable family by stopping time-based recurring jobs after 10 consecutive execution failures, recording the reason durably, and notifying the owning agent with a recovery command.
Fixes #118089
Why This Change Was Made
The scheduler already records the authoritative consecutive-error streak at run completion, so this change uses that O(1) state instead of reading retained run history. A shared auto-disable owner now records
state.autoDisabledwith a closed reason (consecutive-failuresorschedule-errors), timestamp, and count. The field stays instate_json; there is no SQLite DDL, schema-version bump, mirrored column, config option, or protocol-version change.Notifications are queued while state mutates and drained only after the corresponding durable write succeeds. That contract now covers scheduled completion, manual due completion, and startup recovery. The recurring threshold check remains after schedule-ownership and force-preserve gates, so stale, removed, and out-of-band force runs cannot disable the durable schedule. Manual enable clears the auto-disable record plus both execution and schedule-error streaks.
Source verification found three details beyond the initial issue sketch:
consecutiveErrorsinstartup-run-repair.ts, nottimer-outcomes.ts, so startup recovery also uses the canonical policy and post-persist notification queue.deliveryContextor a re-enable hint; both schedule and run-failure reasons now share the same owning-agent notifier.autoDisabledwas added as report-only state and intentionally omitted from writable patch/input schemas.One-shot completion/exhaustion,
trigger.once, and stream-source restart exhaustion remain separate. They represent completion or a different lifecycle owner, not the recurring time-schedule failure streak addressed here.Production/UI/schema delta is +339/-46 lines (net +293), with +558 test lines and +2 docs lines. The production growth is the named capability plus its persistence, protocol, recovery, notification, and operator-visibility ownership boundaries.
User Impact
everyandcronjobs auto-disable after 10 consecutive execution failures; successful runs reset the streak.schedule-errors).openclaw automations enable <id>.automations list --all,automations show, JSON output, andopenclaw doctorexpose why a job was auto-disabled.Evidence
Focused Vitest proof:
node scripts/run-vitest.mjs src/cron/service/timer.regression.test.ts— 62 passednode scripts/run-vitest.mjs src/cron/service/timer.batch-finalization.test.ts— 24 passednode scripts/run-vitest.mjs src/cron/service/ops.test.ts— 51 passednode scripts/run-vitest.mjs src/cron/service/jobs.schedule-error-isolation.test.ts— 8 passednode scripts/run-vitest.mjs src/cron/store.test.ts— 51 passednode scripts/run-vitest.mjs src/commands/doctor/cron/index.test.ts— 62 passednode scripts/run-vitest.mjs src/cli/cron-cli/shared.test.ts— 66 passednode scripts/run-vitest.mjs packages/gateway-protocol/src/cron-validators.test.ts— 26 passednode scripts/run-vitest.mjs src/cron/service/startup-run-repair.auto-disable.test.ts— 1 passednode scripts/run-vitest.mjs src/cron/service.restart-catchup.test.ts— 26 passednode scripts/run-vitest.mjs src/cron/service.runs-one-shot-main-job-disables-it.test.ts— 18 passedBroader proof:
OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/check-changed.mjs --base 1704ea59182 --timed— passed all core/core-test/UI/docs formatting, typecheck, lint, dead-code, architecture, database-first, and import-cycle lanes. The normal Crabbox route was unavailable due to the installed broker/provider state, so trusted-source policy used the local fallback against the immutable branch base.OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree pnpm build— passed; final build completed in 3m11.7s, including package surfaces and Control UI..agents/skills/autoreview/scripts/autoreview --mode local ...— clean, no accepted/actionable findings (Codexgpt-5.6-sol, high reasoning).Source-blind built-CLI/Gateway probing observed a real scheduled command failure, durable
consecutiveErrors: 1, and the 30-second error backoff. The remaining threshold clauses were intentionally marked blocked because public schedule edits and--dueruns could not bypass that backoff; the validator did not use force runs, source inspection, or direct SQLite mutation to manufacture ten scheduled outcomes.Built CLI/Gateway live proof (dist build, ephemeral gateway, isolated state dir, port 19872)
Full threshold → persisted disable → owner notification → re-enable loop, run against the built dist:
exit 7), 10 consecutive manualautomations run --waitfailures →consecutiveErrors: 10, job still enabled. (Manual runs do not own the schedule slot, so they feed the streak but do not trip the disable — the trip is reserved for scheduler-owned outcomes.)nextRunAtMsto +60m (DEFAULT_ERROR_BACKOFF_SCHEDULE_MScap), and acron.updatestate patch cannot backdate it — so the trip was exercised through the other scheduler-owned failure path:sleep 120run,kill -9the gateway mid-run, restarted. Startup repair marked the run failed and tripped the threshold:{ "enabled": false, "ce": 11, "autoDisabled": { "reason": "consecutive-failures", "atMs": 1785696282658, "consecutiveErrors": 11 } }cron: marking interrupted running job failed on startup→cron: auto-disabled interrupted job after consecutive run failures(consecutiveErrors: 11).automations listrenders the new status decoration:disabled (11x).automations enable→{ "enabled": true, "consecutiveErrors": 0, "autoDisabled": null }.Ephemeral gateway + test job deleted after the run; no operator state touched.