Skip to content

feat(cron): include run time in failure alerts - #80246

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
haishmg:codex/cron-alert-event-time
Jul 30, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
haishmg:codex/cron-alert-event-time

Conversation

@haishmg

@haishmg haishmg commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #77497.

What Problem This Solves

Cron failure alerts can arrive after a delay, making an old failure look current when the notification only shows its delivery time.

Why This Change Was Made

Failure alert delivery now carries the run's start time as a separate fact from alert cooldown bookkeeping. Chat notifications append that instant in the agent's configured user timezone; webhook message text remains unchanged and exposes the instant as structured runAtMs.

The rewrite deliberately does not use the cron schedule timezone, rewrite webhook message strings, or reuse the run start time as the alert occurrence time.

Maintainer contract decision: accept runAtMs as an additive optional failure-webhook field. Existing message bytes remain stable, no existing field changes meaning, and webhook consumers should ignore unknown JSON properties.

User Impact

Operators can tell when a failed or skipped cron run actually started, even when its chat alert is delivered later. Existing webhook consumers keep the same message text and can opt into the additive runAtMs field.

Evidence

{
  "surface": "cron failure notifications",
  "result": "pass",
  "chat": "run start appended in agents.defaults.userTimezone",
  "webhook": "message text unchanged; runAtMs added as structured data",
  "cooldown": "still anchored to alert occurrence time",
  "missingRunAtMs": "legacy notification text preserved"
}

Real Behavior Proof

  • Exact PR head: 9d415c85f2f93f74d08a3053ddb120b2c5c58dd9, rebased onto cc48aef143551af2ce13096264335ce9954e61e6.
  • Runtime provenance: exact-head CI built synthetic merge 885da07020e96cb6b6c78e2a20ea722e964399b8; its parents are base cc48aef143551af2ce13096264335ce9954e61e6 and exact PR head 9d415c85f2f93f74d08a3053ddb120b2c5c58dd9.
  • Scenario: the CI-built packaged runtime started a disposable Gateway, added a command cron with failureAlert.after=1, zero cooldown, webhook mode, and normal delivery disabled, then ran it with cron run --wait.
  • Observed failure: the command exited with code 7 and the completed run recorded runAtMs=1785383461252.
  • Real delivery: external request fe51ab55-3e45-4260-b361-a4b6988aee20 received the failure-alert POST. The delivered runAtMs exactly matched the completed run's value.
  • Compatibility proof: the existing human-readable message retained its legacy bytes while the optional numeric field was added:
{
  "jobId": "<redacted>",
  "jobName": "9d415c85 exact-head external failure alert proof",
  "message": "Cron job \"9d415c85 exact-head external failure alert proof\" failed 1 times\nLast error: command exited with code 7",
  "runAtMs": 1785383461252
}
  • Chat proof: focused assertions render 2026-01-15 10:30 EST for a 2026-01-15T15:30:00Z run with agents.defaults.userTimezone=America/New_York; the historical Telegram before/after recording remains in the PR discussion.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S proof: supplied External PR includes structured after-fix real behavior proof. labels May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 12:18 AM ET / 04:18 UTC.

ClawSweeper review

What this changes

The branch carries each failed or skipped cron run’s start time into chat failure alerts and adds it as an optional runAtMs value to failure-webhook JSON payloads.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for normal maintainer landing review. The current head has focused implementation and test coverage, the recorded maintainer contract accepts optional additive runAtMs, and the PR body supplies exact-head packaged-runtime proof that the external failure webhook preserves legacy message bytes while delivering the completed run’s timestamp.

Priority: P2
Reviewed head: 9d415c85f2f93f74d08a3053ddb120b2c5c58dd9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, covered across cron and Gateway boundaries, and backed by current-head real delivery proof; the remaining item is ordinary compatibility-conscious maintainer review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides exact-head, CI-built packaged-runtime evidence of an externally delivered failure webhook whose runAtMs equals the completed run value while the legacy message stays unchanged; earlier Telegram media directly demonstrates the visible chat change.
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 provides exact-head, CI-built packaged-runtime evidence of an externally delivered failure webhook whose runAtMs equals the completed run value while the legacy message stays unchanged; earlier Telegram media directly demonstrates the visible chat change.
Evidence reviewed 4 items Current-head implementation: The proposed branch forwards result.startedAt as runAtMs through failure-alert emission, then appends a localized run-start line only to chat messages while retaining webhook message text and adding structured timestamp data.
Focused regression coverage: The PR adds coverage for cooldown anchoring, localized chat rendering, stable webhook message text, structured webhook runAtMs, and existing gateway cron failure paths.
Exact-head real behavior proof: The PR body documents a CI-built packaged runtime from the current head whose failure webhook received the same runAtMs stored by the completed command cron run, with the legacy human-readable message unchanged.
Findings None None.
Security None None.

How this fits together

Cron service records each job result and decides whether its failure policy should emit an alert. The Gateway then formats chat delivery in the agent’s user timezone or sends a webhook payload to an external integration.

flowchart LR
  A[Cron job run] --> B[Completed run result]
  B --> C[Failure alert policy]
  C --> D[Gateway failure delivery]
  D --> E[Chat alert in user timezone]
  D --> F[Webhook JSON payload]
  B --> G[Cooldown bookkeeping]
Loading

Before merge

  • Resolve merge risk (P1) - Adding runAtMs changes the public failure-webhook payload shape; the recorded additive-field contract and unchanged message bytes reduce compatibility risk, but maintainers should retain that contract in review.
Agent review details

Security

None.

PR surface

Source +26, Tests +181, Docs +4. Total +211 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 30 4 +26
Tests 3 182 1 +181
Docs 2 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 216 5 +211

Review metrics

Metric Value Why it matters
Webhook contract 1 optional field added; 0 existing fields redefined The externally delivered failure-alert payload changes, so preserving existing consumer behavior is the key merge condition.

Stored data model

Persistent data-model change detected: serialized state: src/cron/service/state.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A fresh Telegram Desktop capture would supplement the exact-head webhook proof by showing the localized run-start line in the user-visible chat alert. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify and capture a delayed cron failure alert from the current PR head showing the localized run start time in the delivered message.

Merge-risk options

Maintainer options:

  1. Preserve the additive webhook contract (recommended)
    Merge with message remaining byte-stable and runAtMs remaining optional so existing consumers continue to function while integrations opt in.
  2. Accept a broader webhook change
    Maintainers could intentionally revise existing webhook text or field semantics, but that would require explicit compatibility documentation and upgrade proof.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve byte-stable failure-webhook message text and optional additive runAtMs behavior; require the existing focused cron and Gateway coverage to remain green.

Technical review

Best possible solution:

Land the focused timestamp propagation with the additive webhook contract intact: chat uses the agent user timezone, webhook consumers receive optional runAtMs, and cooldown timing remains based on alert occurrence rather than run start.

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

Not applicable as a feature request; the exact-head packaged-runtime scenario did demonstrate the changed cron failure delivery path through an external webhook.

Is this the best way to solve the issue?

Yes. Carrying the recorded run start as a separate fact preserves cooldown semantics, localizes only the chat presentation, and avoids breaking existing webhook message consumers.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head, CI-built packaged-runtime evidence of an externally delivered failure webhook whose runAtMs equals the completed run value while the legacy message stays unchanged; earlier Telegram media directly demonstrates the visible chat change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides exact-head, CI-built packaged-runtime evidence of an externally delivered failure webhook whose runAtMs equals the completed run value while the legacy message stays unchanged; earlier Telegram media directly demonstrates the visible chat change.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a useful cron-alert clarity improvement with bounded impact rather than an urgent regression.
  • merge-risk: 🚨 compatibility: Failure-webhook consumers receive a new JSON property, although the documented contract preserves existing message bytes and makes the field optional.
  • 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 provides exact-head, CI-built packaged-runtime evidence of an externally delivered failure webhook whose runAtMs equals the completed run value while the legacy message stays unchanged; earlier Telegram media directly demonstrates the visible chat change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head, CI-built packaged-runtime evidence of an externally delivered failure webhook whose runAtMs equals the completed run value while the legacy message stays unchanged; earlier Telegram media directly demonstrates the visible chat change.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The changed chat failure-alert text is directly visible in Telegram and can be demonstrated in a short delayed-alert recording.

Evidence

What I checked:

  • Current-head implementation: The proposed branch forwards result.startedAt as runAtMs through failure-alert emission, then appends a localized run-start line only to chat messages while retaining webhook message text and adding structured timestamp data. (src/cron/service/timer-outcomes.ts:132, 9d415c85f2f9)
  • Focused regression coverage: The PR adds coverage for cooldown anchoring, localized chat rendering, stable webhook message text, structured webhook runAtMs, and existing gateway cron failure paths. (src/gateway/server-cron-notifications.test.ts:261, 9d415c85f2f9)
  • Exact-head real behavior proof: The PR body documents a CI-built packaged runtime from the current head whose failure webhook received the same runAtMs stored by the completed command cron run, with the legacy human-readable message unchanged. (9d415c85f2f9)
  • Maintainer direction: A repository member assigned and refreshed the branch on July 30, 2026, and the PR body records acceptance of runAtMs as an additive optional webhook field; this removes the prior unresolved API-direction question. (9d415c85f2f9)

Likely related people:

  • vincentkoc: Authored the current consolidated commit, refreshed the branch, recorded the webhook contract decision, and requested the current-head review. (role: recent area contributor and branch integrator; confidence: high; commits: 9d415c85f2f9; files: src/gateway/server-cron-notifications.ts, src/cron/service/timer-outcomes.ts)
  • haishmg: The current commit credits this contributor as co-author for the cron alert timestamp feature. (role: feature co-author; confidence: medium; commits: 9d415c85f2f9; files: src/cron/service/failure-alerts.ts, docs/automation/cron-jobs.md)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Keep the optional additive runAtMs contract and byte-stable webhook message behavior intact when merging.

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 (6 earlier review cycles)
  • reviewed 2026-07-30T02:14:52.140Z sha d6d11fd60f554772a40aecbb866eee517a99e8a0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T02:24:58.214Z sha d5c993775373343d61c78fef18dbf630a2f71ad0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T02:38:22.853Z sha d5c993775373343d61c78fef18dbf630a2f71ad0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T02:48:02.169Z sha b37f59db1a592f78f759e6692e507fae558fb219 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T02:57:39.692Z sha b37f59db1a592f78f759e6692e507fae558fb219 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T03:34:54.207Z sha f9aa28c02cc1795c1f3560ffc334edf9efab9caf :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels May 10, 2026
@obviyus

obviyus commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Real Telegram Crabbox proof for the cron failure alert timestamp change.

Main This PR
Main before: failure alert without event time This PR: failure alert includes Last event time

@haishmg
haishmg force-pushed the codex/cron-alert-event-time branch from c762489 to 24b8ee8 Compare May 11, 2026 07:24
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 26, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels May 26, 2026
@clawsweeper

clawsweeper Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Clockwork Patch Peep

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: sniffs out flaky tests.
Image traits: location status garden; accessory rollback rope; palette moonlit blue and soft silver; mood watchful; pose guarding a tiny green check; shell frosted glass shell; lighting moonlit rim light; background smooth stones and checkmarks.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Clockwork Patch Peep in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 27, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Current-head real delivery proof is now in the PR body. The exact CI-built runtime delivered a redacted failure webhook whose runAtMs matched the completed cron run, while the existing message remained unchanged. The maintainer contract decision accepting optional additive runAtMs is also recorded in the body.

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 30, 2026
@vincentkoc
vincentkoc force-pushed the codex/cron-alert-event-time branch 2 times, most recently from b37f59d to f9aa28c Compare July 30, 2026 03:30
@clawsweeper clawsweeper Bot added 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. and removed 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. labels Jul 30, 2026
@vincentkoc
vincentkoc force-pushed the codex/cron-alert-event-time branch from f9aa28c to 9d415c8 Compare July 30, 2026 03:43
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Current-head proof and CI provenance are now in the PR body for 9d415c85f2f93f74d08a3053ddb120b2c5c58dd9.

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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. and removed 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 Jul 30, 2026
@vincentkoc
vincentkoc merged commit 5496cff into openclaw:main Jul 30, 2026
133 of 141 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

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 gateway Gateway runtime mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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. proof: supplied External PR includes structured after-fix real behavior proof. 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.

[Feature]: [cron] Include event timestamp in failure alert body

3 participants