Repository navigation
fix(cron): owner-targeted automation failure alerts go to the last chat, not the owner - #189953
Conversation
…at, not the owner Without an alert-specific route, the failure-alert route is derived from the job's primary announce target, but the projection carried only channel, recipient, account, and thread. For jobs with delivery.target "owner", such as heartbeats migrated by Doctor, the Gateway alert sender resolved the alert as an ordinary channel delivery: it went to the job session's last conversation or the channel's default recipient, or failed with a missing-target error. Carry target and directPolicy on the alert route when it inherits the primary route and no channel, to, or accountId is set in the job's failureAlert, delivery.failureDestination, or cron.failureAlert, and pass both through the dispatcher and the Gateway alert sender to resolveDeliveryTarget. The incident signature gains the target only when it is inherited, so other jobs' signatures are unchanged. Note the inheritance in the cron delivery route order.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves owner targeting and direct-message policy in inherited automation failure alerts and keeps rejected private alerts’ fallbacks inside their session. Example: Nightly digest has delivery.target="owner", owner Telegram user 2201863137, and a group as its session’s last route.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current routing defect, and the supplied live and upgrade evidence clears the previous proof blocker; no actionable introduced defect remains. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron resolves notification policy from job and Gateway settings, dispatches committed alerts through the Gateway’s existing delivery resolver, and queues confirmed non-delivery through ordinary session events. flowchart TD
A[Failed automation] --> B[Cron alert policy]
B --> C[Notification dispatcher]
C --> D[Gateway delivery resolver]
D --> E[Owner DM or explicit destination]
D --> F[Confirmed non-delivery]
F --> G[Private session fallback]
Technical reviewBest possible solution: Merge the focused repair using the existing delivery resolver and session-event owner. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both dropped-policy boundaries, corroborated by the supplied base and released-Gateway Telegram traces; no target code was executed during this review. Is this the best way to solve the issue? The patch restores the existing delivery contract at its producer and adapters, preserves explicit alert destinations, and prevents private fallback replies from inheriting an external route. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f9553398b8e5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +26, Tests +18, Docs +4. Total +48 across 9 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (6 earlier review cycles)
Reviewed November 19, 2026, 3:59 PM ET / 20:59 UTC (Revision 7). |
When a failure alert on an owner-targeted route, or on a route with directPolicy "block", was rejected and recorded as Not delivered, its in-app fallback was queued as an ordinary session event, so the fallback turn's reply could be delivered to the session's last conversation. Queue that fallback with deliver: false and an internal delivery context. The fallback turn still runs and records the alert in its session, but its reply is not delivered automatically, and the turn has no current external conversation for implicit sends. Other routes keep their fallback delivery. Move the notification test setup into a shared fixture, add fallback and stored-incident tests, and note the fallback behavior in the cron delivery docs.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
Drop the test-lines allocation, the shared notification fixture module and the separate owner-target, fallback and persistence test files. One row in the existing rejected-alert suite now proves the owner target reaches the alert transport and its fallback turn does not inherit the last route; the Gateway routing case asserts the target and directPolicy reach resolveDeliveryTarget.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Telegram Test Server proof for fb1445a (observed lines; base = merge base f96a979): |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Upgrade compatibility of the persisted failure-alert incident (v2026.11.6 -> fb1445a, observed lines): |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @Satoshi-Kusumoto for the report and the fix. This is merged in f59d9a8: failure alerts for automations with |
…at, not the owner (openclaw#189953) Root cause: `src/cron/service/failure-alerts.ts:241` builds the inherited failure-alert route from the job's primary delivery but drops `target` and `directPolicy`, so `src/gateway/server-cron-notifications.ts:488` resolves an owner-targeted job's alert as a plain `channel: "last"` delivery instead of reaching the owner resolver the job's own delivery uses (`src/cron/isolated-agent/delivery-target.ts:232`). Fixes openclaw#189947 ## What Problem This Solves Fixes: failure alerts for automations with `delivery.target: "owner"` (for example heartbeats migrated by Doctor) go to the job session's last conversation (another DM sender or a group) or the channel's `defaultTo`, or fail with `Delivering to Telegram requires target <chatId>`, while the job's own delivery goes to the owner DM or reports the owner unavailable. ## User Impact User impact: for owner-targeted automations without an alert-specific route, failure alerts now go where the automation's own delivery goes, the positively identified owner DM. - No identifiable owner, or `delivery.directPolicy: "block"`: the alert is recorded as Not delivered and the existing in-app fallback is queued, the same outcome as the job's own delivery. That fallback turn stays in the session (`deliver: false`, no external conversation), so it cannot reach the last conversation either. - Explicit alert routes are unchanged: a `channel`, `to` or `accountId` in the job's `failureAlert`, `delivery.failureDestination` or global `cron.failureAlert` keeps its configured routing. - Jobs that are not owner-targeted but set `directPolicy: "block"` now honor it for inherited alerts too. - No config or schema change. A job whose alert newly inherits the owner target counts as a changed destination, so an open incident may alert once more after the cooldown. ## Why This Change Was Made The alert route now carries `target` and `directPolicy` when it inherits the primary route without an alert-specific selector. The dispatcher and the Gateway alert sender pass both to the existing `resolveDeliveryTarget`; owner resolution itself is unchanged and there is no second resolver. Thanks @Satoshi-Kusumoto for the report and the fix. The maintainer pass merged current `main`, dropped the test-lines allocation and the shared test-support module, and folded the new test files into one owner-target row in the existing rejected-alert suite plus target/`directPolicy` assertions in the existing Gateway routing case. Deltas against the merge base: production +29/-3 across `failure-alerts.ts`, `notification-intents.ts`, `notification-dispatch.ts`, `state.ts`, `wake.ts`, `server-cron-notifications.ts`; tests +26/-6; docs +4. ## Evidence - `src/cron/service.failure-alert-notifications.test.ts` and `src/gateway/server-cron-notifications.test.ts` (`ocx test`): red on the merge base `422c0d2d9826` (owner-target row: `expected undefined to be 'owner'`; Gateway routing case: `resolveDeliveryTarget` called without `target`/`directPolicy`), green on this head. - Telegram Test Server proof (base vs candidate, explicit-route and no-owner controls): base: the alert lands in the group; candidate: it lands in the owner DM, and the job's own delivery goes to the same DM; an explicit `failureAlert.to` still reaches the group; with no identifiable owner the alert is Not delivered with `Owner delivery unavailable (no-route)` and the in-app event is queued in the session, the same result as the job's own delivery. Observed lines: openclaw#189953 (comment) - Upgrade from v2026.11.6 with an open incident: the released alert is the only one; both candidate starts inside the cooldown stay suppressed and the persisted incident loads unchanged, matching the cooldown note above. Observed lines: openclaw#189953 (comment) Merge danger: two-way door. A revert restores the old routing; nothing is written or migrated beyond the existing incident signature. Blast radius: failure alerts for cron jobs with `delivery.target: "owner"` or `directPolicy: "block"` and no alert-specific route, on every channel. Co-authored-by: Ayaan Zaidi <[email protected]>
…9953) Preserve target and directPolicy when failure alerts inherit the primary announce route, then keep rejected owner-targeted notifications in-session. Explicit alert route selectors retain their existing routing. Release adaptation: protect the transportless sibling fallback with the same privateFallback option and prove it through the real notification admission flow. The original patch protected only the rejected-transport path. No new configuration, owner, persistence, or notification outcome was introduced. Companion audit through c29f72b: no later same-path changes, PR-number mentions, or source-SHA mentions. Traced route selection, transport settlement, notification admission, and the shared owner resolver; the no-transport gap above is closed in this carrier. Regression-only baseline: 3 Gateway routing failures (26 passed) and 2 fallback failures (4 passed), including unrelated target -10042 in the transportless case. (cherry picked from commit f59d9a8) (cherry picked from commit be174a8e400a8089e6a38c3efc994781d32b74f6) Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a74891e2e1f88a80498b69fdce0f94c44bc541ea) (cherry picked from commit b6b94d3d7093ae949ea01daf6f683c4881421bca)
Root cause:
src/cron/service/failure-alerts.ts:241builds the inherited failure-alert route from the job's primary delivery but dropstargetanddirectPolicy, sosrc/gateway/server-cron-notifications.ts:488resolves an owner-targeted job's alert as a plainchannel: "last"delivery instead of reaching the owner resolver the job's own delivery uses (src/cron/isolated-agent/delivery-target.ts:232).Fixes #189947
What Problem This Solves
Fixes: failure alerts for automations with
delivery.target: "owner"(for example heartbeats migrated by Doctor) go to the job session's last conversation (another DM sender or a group) or the channel'sdefaultTo, or fail withDelivering to Telegram requires target <chatId>, while the job's own delivery goes to the owner DM or reports the owner unavailable.User Impact
User impact: for owner-targeted automations without an alert-specific route, failure alerts now go where the automation's own delivery goes, the positively identified owner DM.
delivery.directPolicy: "block": the alert is recorded as Not delivered and the existing in-app fallback is queued, the same outcome as the job's own delivery. That fallback turn stays in the session (deliver: false, no external conversation), so it cannot reach the last conversation either.channel,tooraccountIdin the job'sfailureAlert,delivery.failureDestinationor globalcron.failureAlertkeeps its configured routing.directPolicy: "block"now honor it for inherited alerts too.Why This Change Was Made
The alert route now carries
targetanddirectPolicywhen it inherits the primary route without an alert-specific selector. The dispatcher and the Gateway alert sender pass both to the existingresolveDeliveryTarget; owner resolution itself is unchanged and there is no second resolver.Thanks @Satoshi-Kusumoto for the report and the fix. The maintainer pass merged current
main, dropped the test-lines allocation and the shared test-support module, and folded the new test files into one owner-target row in the existing rejected-alert suite plus target/directPolicyassertions in the existing Gateway routing case.Deltas against the merge base: production +29/-3 across
failure-alerts.ts,notification-intents.ts,notification-dispatch.ts,state.ts,wake.ts,server-cron-notifications.ts; tests +26/-6; docs +4.Evidence
src/cron/service.failure-alert-notifications.test.tsandsrc/gateway/server-cron-notifications.test.ts(ocx test): red on the merge basef96a979a0f3b(owner-target row:expected undefined to be 'owner'; Gateway routing case:resolveDeliveryTargetcalled withouttarget/directPolicy), green on this head.failureAlert.tostill reaches the group; with no identifiable owner the alert is Not delivered withOwner delivery unavailable (no-route)and the in-app event is queued in the session, the same result as the job's own delivery. Observed lines: fix(cron): owner-targeted automation failure alerts go to the last chat, not the owner #189953 (comment)Merge danger: two-way door. A revert restores the old routing; nothing is written or migrated beyond the existing incident signature. Blast radius: failure alerts for cron jobs with
delivery.target: "owner"ordirectPolicy: "block"and no alert-specific route, on every channel.