Repository navigation
fix(cron): honor failure alert thresholds - #126483
Conversation
Per-run Gateway announcements bypassed threshold, cooldown, and opt-out policy. Make the scheduler the sole owner of failure notification decisions.
Keep trusted failure detail proof on the scheduler-authorized transport and remove the obsolete Gateway event-context handoff after the ownership consolidation.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 8:05 PM ET / August 20, 2026, 00:05 UTC. ClawSweeper reviewWhat this changesMoves cron failure-alert decisions into the scheduler so thresholds, cooldowns, opt-out, and configured routes are applied consistently before Gateway transport. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open: current main still sends routed cron failures through Gateway before scheduler threshold, cooldown, and opt-out policy can apply. The PR correctly moves that decision to the scheduler; maintainers need only accept its intentional upgrade-visible alert cadence change. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherCron jobs record outcomes in the scheduler, which decides whether a failure warrants an alert before Gateway delivers it to a channel or webhook. The decision affects notifications while preserving run history. flowchart LR
A[Cron job run] --> B[Scheduler outcome record]
B --> C[Failure-alert policy]
C --> D{Threshold and cooldown met?}
D -->|Yes| E[Gateway delivery]
D -->|No| F[Recorded run history]
E --> G[Channel or webhook alert]
Decision needed
Why: The behavior is intentional and documented, but it changes notification cadence for already configured jobs. Before merge
Agent review detailsSecurityNone. PR surfaceSource -131, Tests -286, Docs +18. Total -399 across 35 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the scheduler-owned policy after explicitly accepting the documented notification-cadence change for existing configured routes. Do we have a high-confidence way to reproduce the issue? Yes: source establishes that current Gateway dispatches routed failures individually, and the PR boundary test demonstrates the scheduler-gated replacement path. Is this the best way to solve the issue? Yes, subject to accepting the upgrade-visible cadence: the scheduler owns persisted outcomes and is the only layer able to apply threshold, cooldown, and opt-out uniformly. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c4c9f6d4644e. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready proof for Behavior proof:
Gates and review:
ClawSweeper handling:
Diff accounting: production +392/−523 (net −131); tests +651/−937; prompt snapshots/test support +15/−15; docs +32/−14. Live Discord proof was intentionally not repeated because the defect is notification flooding. The local guarded HTTP receiver exercises the real scheduler/Gateway transport boundary without sending external channel traffic. |
|
Merged via squash.
|
* fix(cron): honor failure alert thresholds Per-run Gateway announcements bypassed threshold, cooldown, and opt-out policy. Make the scheduler the sole owner of failure notification decisions. * fix(cron): preserve safe failure details Keep trusted failure detail proof on the scheduler-authorized transport and remove the obsolete Gateway event-context handoff after the ownership consolidation. * test(cron): assert alternate failure route isolation
Re-integrate upstream/main (base a3ca846 → tip 784a228, 266 commits) into the cortex fork. Conflict resolution + keystone reconciliation summary in RESYNC_LEDGER.md. Foundation (lead-owned): MCP fence ENHANCE (fence sanitized publicValue + fix a latent _meta-leak), openshell buildRemoteCommand union-trap → adopt upstream extraction, cron completion-announce grafted onto upstream openclaw#126483 failure- threshold rewrite, memory-core prompt-section KEEP-OURS, ui/package.json union. Gateway/protocol second pass (split-brain repair): grafted upstream's GitHub- identity schemas; re-grafted 37 dropped methods (openclaw#118232) + placement scopes + handler wiring; method-scope drift (config.schema/fs.listDir/worktrees.create, sessions.groups.*, skills.forge.*); embedded-agent type extensions; agentHarnessStructuredInput SDK export; resolved-v1 provenance; AgentToolResult<unknown>; cron-trigger-filter; exec-approval; copyImage icon. GitHub-identity (adopt fully): core adopted + working; UI ported to ui/src/ui (compiles + unit-tested); app-shell live-wire + runExternalMutation + visual verification are the documented land-time step. Agent-loop (merge + restore fork features): restored the fork's tool mutation- tracking + recovery cluster (20 files) to fork-main; grafted upstream's clean before-tool-call owner-arg change; deferred upstream intentionalTermination hardening as a follow-up. UI divergence: fork owns ui/src/ui; upstream's ui/src/pages restructure not adopted (184 files kept-deleted). i18n kept-ours (fork en.ts superset). Verification: tsgo core/extensions/test:ui/test:packages = 0 (zero new errors; core:test/extensions:test residuals proven identical to fork-main baseline). Behavior: cron, mcp, memory-core, agent-loop mutation-recovery green (merge regressions fixed). Pending land-time: Linux build + behavior proof + autoreview + GitHub-identity UI wiring/visual. Co-Authored-By: Claude Opus 4.8 <[email protected]>
What Problem This Solves
Fixes an issue where a failing automation could send
⚠️ Automation "name" failedafter every run even whenfailureAlert.after,cooldownMs, orfailureAlert: falseshould have suppressed it. A 60-second monitor produced 21 messages during the reported incident.Why This Change Was Made
Cron finalization is now the single owner of execution-failure, required-delivery-failure, threshold, cooldown, route, recovery, and auto-disable notification decisions. Gateway code only transports scheduler-authorized alerts and completion webhooks. Explicit failure destinations remain route overrides; operator opt-outs and best-effort semantics are honored without duplicate policy.
The ownership split became possible when repeated failure alerts (commit 4637b90 / #24789, 2026-03-01, code author @0xbrak) and per-run failure destinations (#31059, 2026-03-02, author Evgeny Zislis) remained separate owners. The Gateway dispatcher was later split into its own module by 85148f3 on 2026-04-27 by Peter Steinberger. This is provenance, not an assignment of blame.
User Impact
Operators get one comprehensible failure-alert policy instead of per-run floods plus separate threshold alerts. Route-backed jobs default to an alert after two consecutive failures with a one-hour cooldown; per-job/global tuning, disablement, skipped-run opt-in, delivery-only failures, and auto-disable recovery remain visible and deterministic.
Evidence
failureAlert: falseruns).failed 2 timesrequest; the disabled job yields none; all 21 durable history rows remain.node scripts/run-vitest.mjs src/cron/cron-delivery-outcomes.e2e.test.ts --reporter=verbose— 1 file, 6 tests passed.node scripts/run-vitest.mjs src/cron/delivery-plan.test.ts src/cron/delivery.failure-notify.test.ts src/cron/delivery.test.ts src/cron/service.delivery-plan.test.ts src/cron/service.failure-alert.test.ts src/cron/service/failure-alerts.account-routing.test.ts src/cron/service/failure-alerts.persistence.test.ts src/cron/service.persists-delivered-status.test.ts src/cron/service/ops.test.ts src/cron/service/run-recovery.test.ts src/cron/service/startup-run-repair.auto-disable.test.ts src/cron/service/timer.regression.test.ts --reporter=verbose— 12 files, 270 tests passed.node scripts/run-vitest.mjs src/gateway/server-cron-notifications.presentation.test.ts src/gateway/server-cron-notifications.test.ts src/gateway/server-cron.test.ts src/gateway/server.cron.test.ts src/gateway/server-methods/cron.validation.test.ts --reporter=dot— 5 files, 322 tests passed.node scripts/run-vitest.mjs src/cron/service/timer.timeout-watchdog.test.ts -t 're-arms the pre-execution watchdog when before_agent_reply does not claim' --reporter=verbose— 1 focused test passed; the exact alternate-route thread-isolation fact is asserted.pnpm prompt:snapshots:check— current (7 files).pnpm check:docs— passed formatting, Markdown/MDX, glossary, 6,524 internal links, and 1,180 validated config examples.git diff --name-only -z 4970ed235782782ef2373aeebfae266be48a78a1...HEAD | xargs -0 node scripts/check-changed.mjs --base 4970ed235782782ef2373aeebfae266be48a78a1 --head HEAD --— passed all selected core, core-test, docs, and tooling gates.AGENTS_HOME="$HOME/.claude" "$HOME/.claude/skills/autoreview/scripts/autoreview" --mode branch --base origin/main— clean, no accepted/actionable findings.Live Discord proof was intentionally not repeated because the defect is notification flooding. The local SSRF-guarded HTTP receiver exercises the real scheduler/Gateway transport boundary without sending external channel traffic.
AI-assisted: implemented and verified with Codex; no agent transcript is included.