Skip to content

fix(cron): failed one-shot jobs are disabled without any failure alert - #167908

Closed
erlightbourn-source wants to merge 2 commits into
openclaw:mainfrom
erlightbourn-source:dev/cron-oneshot-failure-notice
Closed

erlightbourn-source wants to merge 2 commits into
openclaw:mainfrom
erlightbourn-source:dev/cron-oneshot-failure-notice

Conversation

@erlightbourn-source

@erlightbourn-source erlightbourn-source commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #131590

What Problem This Solves

Fixes: a one-shot cron job (schedule.kind: "at") that fails permanently, or uses up its transient retries, is disabled with no failure alert when failureAlert.after is at its default of 2.

User Impact

User impact: operators now get the configured failure alert the first time a one-shot job fails terminally, so a missed reminder or scheduled send no longer disappears silently. Recurring jobs and retryable first failures behave exactly as before.

Why This Change Was Made

A one-shot is disabled after its terminal failure, so its consecutive-error streak can never reach after=2, and the alert threshold is never met. This change marks that outcome as terminal and lets maybeEmitFailureAlert skip the after threshold for it only. Alert routing, cooldown, bestEffort and failureAlert: false are unchanged.

This overlaps with #131590, which takes a broader approach (it also changes the disable reason and docs). This PR is the minimal version: 4 files, +146/−4, most of it a regression test. Maintainers can pick whichever they prefer, and I'm happy to close this one if #131590 lands.

Evidence

Real Gateway run (base vs head, same state dir)

Isolated Gateway built from this checkout (OPENCLAW_HOME=/tmp/..., loopback, token auth, OPENCLAW_SKIP_CHANNELS=1). Timed one-shot command jobs (--at), each with failureAlert: { mode: "webhook", to: <local receiver> }. The local receiver needed cron.webhookSsrfPolicy.dangerouslyAllowPrivateNetwork: true in the test config.

  1. Base 3e90389813 (no fix in the built dist, checked by grep): ran proof-base-permanent (exit 2, default after), proof-base-exhausted (exit 1, after: 5) and proof-base-exhausted-timeout (timeoutSeconds: 1, after: 5, 4 timed-out attempts). All three were disabled, no alert was emitted (lastFailureAlertAtMs unset), and 0 webhook requests arrived.
  2. Upgrade: proof-upgrade-permanent (default after) and proof-upgrade-exhausted (after: 5) were created and configured on the base build. The Gateway was then stopped and restarted on the head build (1f428ad278) against the same state, with the jobs' existing failure-alert settings unchanged.
  3. Head: each terminal failure emitted its alert.
job built on after errors alert emitted delivery
proof-base-permanent base, ran on base default (2) 1 no none
proof-base-exhausted-timeout base, ran on base 5 4 (timeouts) no none
proof-upgrade-permanent base, ran on head default (2) 1 yes blocked by the SSRF guard (the private-network allowance wasn't on yet)
proof-head-permanent head default (2) 1 yes delivered
proof-upgrade-exhausted base, ran on head 5 4 (timeouts) yes delivered

Webhook bodies received on head (redacted to the receiver's view):

15:14:15 {"jobName":"proof-head-permanent","message":"Automation \"proof-head-permanent\" failed 1 times\nLast error: command exited with code 2","runAtMs":1791573255724}
15:17:17 {"jobName":"proof-upgrade-exhausted","message":"Automation \"proof-upgrade-exhausted\" failed 4 times\nCause: timeout\nLast error: command timed out","runAtMs":1791573436377}

Tests

  • timer-outcomes.regression.test.ts:
    • A one-shot's first permanent failure alerts under the default policy and stays silent with failureAlert: false.
    • A one-shot's retryable first failure still respects after.
    • A one-shot that exhausts its transient retries alerts exactly once, even with an explicit after: 5.
  • The existing one-shot lifecycle test now expects the terminal-failure alert.
  • Base-fail/head-pass: with the two source files at base 3e90389813, 3 of these tests fail. On head, 33/33 pass across the two files.
  • vitest run src/cron on the original head, rebased on main 3e90389: 2303 passed, 7 skipped, 0 failed. One file (run.session-workspace-authority.test.ts) errored in setup on my machine because a local Xcode license prompt blocked git init. That's an environment issue, not this change.

Contract note

docs/cli/cron.md now documents the terminal exception: a disabled one-shot can never reach after, so its terminal failure alerts immediately. Cooldown, routing, bestEffort and failureAlert: false still apply. See the reasoning in the thread.

…g it silently

A one-shot (schedule.kind=at) that fails permanently, or exhausts its transient
retries, is disabled and never runs again, so the failure-alert streak (default
after=2) can never be reached and the disable was silent. Mark that outcome as
terminal and let maybeEmitFailureAlert bypass the after threshold for it. Routes,
cooldown, bestEffort and failureAlert:false are unchanged; retryable first
failures keep the threshold.
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The automation scheduler sends a configured failure alert when a timed one-shot job permanently fails or exhausts its retries, even below its failure-count threshold.

Example: A timed one-shot command exits with code 2 under the default alert policy.

  • Before: The job is disabled after one failure without sending its configured webhook alert.
  • After: The webhook receives an alert containing “command exited with code 2.”

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation and convincing Gateway proof support the repair, while the explicit-threshold contract remains an unresolved product choice.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The contributor’s isolated real Gateway runs exercise the changed outcome and alert owners and record received webhook JSON after permanent failure and exhausted timeout retries. An existing base-created job with after: 5 also delivers after restarting head against the same state, resolving the prior proof request. No stored format or schema changes are introduced; existing settings retain their stored values.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision
User problem: A scheduled one-time reminder or command can fail, stop permanently, and never send its configured failure notification.
Reason: Preventing silent terminal failures is valuable, but the patch also overrides explicitly configured alert thresholds that the existing owner-approved policy honors.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR addresses a source-confirmed silent failure that remains on current main. The implementation is focused and the previous proof gap is resolved; overriding explicitly configured alert thresholds still needs an area-owner decision.

Priority: P2
Reviewed head: 1f428ad2787849eb6790558991a0e521b97d692e
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should terminal timed one-shot failures bypass explicitly configured failureAlert.after values as well as the inherited default?
  • Recommendation: Accept the terminal exception: Alert on terminal timed one-shot failures regardless of after, while preserving cooldown, routing, best-effort suppression, and opt-outs.
  • Why: Existing owner-approved behavior honors configured thresholds uniformly; the contributor explains the exception, but no recorded area-owner decision accepts this expanded contract.

Before merge

  • Complete next step - Have the alert-policy owner select the terminal threshold contract described in the decision options.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

OpenClaw’s automation scheduler runs scheduled jobs and records their outcomes. Its failure-alert owner applies notification policy and passes committed alerts to the Gateway for delivery.

flowchart TD
  A[Timed one-shot job] --> B[Run outcome]
  B --> C{Retry remains?}
  C -->|Yes| D[Schedule retry]
  C -->|No| E[Disable job]
  E --> F[Apply alert policy]
  F --> G[Persist outcome and alert intent]
  G --> H[Gateway delivers notification]
Loading

Technical review

Best possible solution:

Keep the repair in the existing outcome and alert owners, with an explicit owner-approved terminal threshold contract.

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

Yes: current main disables terminal timed one-shots before their error streak can reach the default threshold of 2. Contributor base/head Gateway output independently demonstrates the silent base result and delivered head alerts.

Is this the best way to solve the issue?

Yes structurally: carrying the terminal disposition into the existing alert owner is a narrow repair that preserves persistence and transport ownership. Bypassing explicit thresholds remains a product-contract choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8eb960d42a70.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still has the threshold gap: Current main retains the unconditional consecutiveCount < after check. Comparing the merge base with fetched main shows no changes to either production owner touched by this PR. (src/cron/service/failure-alerts.ts:356, 8eb960d42a70)
  • Narrow terminal-outcome repair: The introduced delta marks only the timed one-shot permanent-error or exhausted-retry disable as terminal. Existing route resolution, opt-outs, cooldown, incident deduplication, replay suppression, and deferred delivery remain in their existing owners. (src/cron/service/timer-outcomes.ts:345, 1f428ad27878)
  • Real Gateway and existing-state proof: The complete supplied PR body, captured with source revision 220e299f3d73e2c70cf62e13fbaf97f19dd6d65c92eb56fffe6281072888f8f6, records base failures producing zero webhooks and head Gateway runs delivering permanent-failure and exhausted-timeout alerts. The exhausted job was created on base with after: 5 and ran after restarting head against the same state. Received JSON contains jobName, failure text, and runAtMs. The contributor also reports three base failures and 33 passing focused head tests; these runs were not repeated during this read-only review. (1f428ad27878)
  • Existing owner-approved threshold contract: fix(cron): honor failure alert thresholds #126483 (comment) explicitly accepts uniform scheduler thresholds, cooldown, and opt-out semantics for existing route-backed jobs. That decision does not explicitly accept bypassing an operator’s after value for terminal one-shots. The current documented contract is at https://docs.openclaw.ai/cli/cron. (docs/cli/cron.md:178, 177828aa75bf)
  • Persistence intent is preserved: The historical persistence repair keeps alert policy and cooldown state with the committed run outcome and delays transport until persistence succeeds. This PR continues to enqueue the existing notification intent rather than sending from the mutation. (src/cron/service/failure-alerts.ts:419, 0fb28afac74f)
  • Related broader PR is not a safe replacement: fix(cron): make one-shot terminal disables visible instead of silently parking jobs #131590 also handles durable auto-disable facts, notification fallbacks, cancellation, and on-exit jobs. Its latest discussion describes a ground-up re-expression, and GitHub currently reports that branch as conflicting; it does not justify closing this narrower contribution. (2090a5e1058b)

PR surface

Source +9, Tests +135, Docs 0. Total +144 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 11 2 +9
Tests 2 137 2 +135
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 149 5 +144

Review metrics

Metric Value Why it matters
Existing setting semantics 1 threshold gains a terminal exception failureAlert.after changes meaning for terminal timed one-shots, including existing explicitly configured values.
Production versus tests Production +11/−2; tests +137/−2 The small production increase carries a terminal outcome fact through existing owners, with most growth covering the regression.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: A terminal timed automation can stop without its configured failure alert, with limited scope to one-shot jobs.
  • merge-risk: 🚨 compatibility: Existing explicitly configured after values are bypassed on terminal timed one-shot failures, requiring an owner decision about their meaning.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-09T18:25:35.650Z sha 425cfaa :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-09T18:54:29.644Z sha 1f428ad :: needs real behavior proof before merge. :: none

Reviewed October 9, 2026, 3:26 PM ET / 19:26 UTC (Revision 3).

… document the terminal exception

Drop the recurring streak-reset replay (unchanged by this fix, covered at service level).
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 9, 2026
@erlightbourn-source

Copy link
Copy Markdown
Contributor Author

On the decision question (bypassing an explicit after for terminal one-shot failures):

I'd keep the terminal exception for explicit values too, not just the inherited default. A terminal timed one-shot is disabled and never runs again, so its streak stops at whatever count it had. For a permanent error that's 1. For exhausted transient retries it's 4, since DEFAULT_MAX_TRANSIENT_RETRIES = 3. Any after above that count can't be reached. If an explicit after: 3 were honored, the permanent-failure case this PR fixes would stay silent forever for that operator. In practice after is a flap filter for recurring jobs, and a job that will never run again can't flap.

Everything else is unchanged: routing, cooldownMs, delivery.bestEffort suppression of inherited alerts, failureAlert: false, and replay suppression. Retryable failures still respect after, because the job is still enabled and can reach it.

Pushed in 1f428ad:

  • docs/cli/cron.md now states the exception next to the "after 2 consecutive failures" default.
  • Removed the recurring streak-reset test you flagged as low-value.
  • Added the missing exhausted-retries case: a one-shot with an explicit failureAlert: { after: 5 } that hits four transient errors gets disabled and emits exactly one alert.

Base-fail/head-pass for the changed tests: on base 3e90389813, 3 fail (the two terminal cases plus the updated one-shot lifecycle assertion). On head, all 33 pass across the two files. A real Gateway trace with webhook delivery is coming shortly. It covers a first permanent failure, exhausted retries, and jobs created on the base build and run after upgrading to head, and I'll fold it into the PR body.

If maintainers would rather narrow it to the inherited default only, it's a one-line change and I'm happy to make it.

@erlightbourn-source

Copy link
Copy Markdown
Contributor Author

Real Gateway proof is now in the PR body under "Real Gateway run (base vs head, same state dir)". On base, a first permanent failure and exhausted retries (after: 5) disabled the job with no alert, and 0 webhooks arrived. After upgrading the same state to head, both alerted, and the webhooks arrived for the first-permanent case and for a job created on base that exhausted its retries after the upgrade.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks @erlightbourn-source, good catch and nice proof. The threshold half of this landed in #169102 (terminal one-shot failures now notify on that failure, with owned jobs getting a repair turn and an alert fallback), and your docs/cli/cron.md sentence is folded into #169314, with you as co-author.

I'll close this PR once #169314 lands.

@erlightbourn-source

Copy link
Copy Markdown
Contributor Author

Thanks @steipete, makes sense. Glad the terminal one-shot case is covered in #169102, and thanks for the co-author credit on #169314. Closing this once that lands works for me.

steipete added a commit that referenced this pull request Oct 11, 2026
Classify operator cancellation and Gateway retirement at their producers so
terminal one-shots do not request a repair, alert, safety notice, or retry.
This fixes the cancellation regression introduced by #169102 while retaining
watchdog timeout retries and recurring-job policy.

Record terminal timed and watcher-fired on-exit failures through the existing
auto-disable owner, making them visible in doctor. Preserve watcher occurrence
provenance across worker finalization and keep ordinary paused/armed force-runs
out of that terminal disposition. Use the existing owner repair with alert
fallback, a resolved failure alert, or the generic safety notice; retain shared
cooldown and incident suppression without sending an extra notice.

The auto-disable owner's safety notice remains active for failureAlert:false
and inherited bestEffort suppression; terminal test expectations follow that
existing policy. Document the terminal behavior and doctor visibility.

Release-note context: terminal one-shot failures no longer disappear silently,
while operator cancels and restart retirements remain quiet. This maintainer
re-expression supersedes #131590 and #167908 on current main.

Co-authored-by: lonexreb <[email protected]>
Co-authored-by: erlightbourn-source <[email protected]>
steipete added a commit that referenced this pull request Oct 12, 2026
Classify operator cancellation and Gateway retirement at their producers so
terminal one-shots do not request a repair, alert, safety notice, or retry.
This fixes the cancellation regression introduced by #169102 while retaining
watchdog timeout retries and recurring-job policy. Preserve completed payload
and delivery facts when cancellation interrupts webhook response cleanup.

Record terminal timed and watcher-fired on-exit failures through the existing
auto-disable owner, making them visible in doctor. Carry watcher occurrence
provenance from the durable queue's launcher through worker finalization;
keep ordinary paused/armed force-runs out of that terminal disposition and
preserve later schedule edits. No schema, configuration, or compatibility path.

Use the existing owner repair with alert fallback, a resolved failure alert,
or the safety notice. Retain shared cooldown and incident suppression without
an extra notice. The safety notice remains active for failureAlert:false and
inherited bestEffort suppression. Document terminal behavior and doctor visibility.

Release-note context: terminal one-shot failures no longer disappear silently,
while operator cancels and restart retirements remain quiet. This maintainer
re-expression supersedes #131590 and #167908 on current main after #169364.

Co-authored-by: lonexreb <[email protected]>
Co-authored-by: erlightbourn-source <[email protected]>
steipete added a commit that referenced this pull request Oct 12, 2026
…et (#169314)

Classify operator cancellation and Gateway retirement at their producers so
terminal one-shots do not request a repair, alert, safety notice, or retry.
This fixes the cancellation regression introduced by #169102 while retaining
watchdog timeout retries and recurring-job policy. Preserve completed payload
and delivery facts when cancellation interrupts webhook response cleanup.

Record terminal timed and watcher-fired on-exit failures through the existing
auto-disable owner, making them visible in doctor. Carry watcher occurrence
provenance from the durable queue's launcher through worker finalization;
keep ordinary paused/armed force-runs out of that terminal disposition and
preserve later schedule edits. No schema, configuration, or compatibility path.

Use the existing owner repair with alert fallback, a resolved failure alert,
or the safety notice. Retain shared cooldown and incident suppression without
an extra notice. The safety notice remains active for failureAlert:false and
inherited bestEffort suppression. Document terminal behavior and doctor visibility.

Release-note context: terminal one-shot failures no longer disappear silently,
while operator cancels and restart retirements remain quiet. This maintainer
re-expression supersedes #131590 and #167908 on current main after #169364.

Co-authored-by: lonexreb <[email protected]>
Co-authored-by: erlightbourn-source <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Landed: the terminal threshold fix is on main via #169102, and your docs/cli/cron.md change is in #169314 (squash 7ee1c26), with you as co-author. Closing this one as superseded. Thanks for the clear report and the real Gateway proof.

@steipete steipete closed this Oct 12, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…et (openclaw#169314)

Classify operator cancellation and Gateway retirement at their producers so
terminal one-shots do not request a repair, alert, safety notice, or retry.
This fixes the cancellation regression introduced by openclaw#169102 while retaining
watchdog timeout retries and recurring-job policy. Preserve completed payload
and delivery facts when cancellation interrupts webhook response cleanup.

Record terminal timed and watcher-fired on-exit failures through the existing
auto-disable owner, making them visible in doctor. Carry watcher occurrence
provenance from the durable queue's launcher through worker finalization;
keep ordinary paused/armed force-runs out of that terminal disposition and
preserve later schedule edits. No schema, configuration, or compatibility path.

Use the existing owner repair with alert fallback, a resolved failure alert,
or the safety notice. Retain shared cooldown and incident suppression without
an extra notice. The safety notice remains active for failureAlert:false and
inherited bestEffort suppression. Document terminal behavior and doctor visibility.

Release-note context: terminal one-shot failures no longer disappear silently,
while operator cancels and restart retirements remain quiet. This maintainer
re-expression supersedes openclaw#131590 and openclaw#167908 on current main after openclaw#169364.

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

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants