Skip to content

fix(cron): owner-targeted automation failure alerts go to the last chat, not the owner - #189953

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Satoshi-Kusumoto:fix/cron-failure-alert-owner-target
Nov 19, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Satoshi-Kusumoto:fix/cron-failure-alert-owner-target

Conversation

@Satoshi-Kusumoto

@Satoshi-Kusumoto Satoshi-Kusumoto commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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 #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 f96a979a0f3b (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: fix(cron): owner-targeted automation failure alerts go to the last chat, not the owner #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: 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" or directPolicy: "block" and no alert-specific route, on every channel.

…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.
@clawsweeper

clawsweeper Bot commented Nov 1, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Nov 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The failure alert appears in the group and never reaches the owner DM.
  • After: The failure alert reaches the owner DM; an unavailable owner produces an internal fallback without posting to the group.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused contract repair with real transport evidence, existing-state upgrade validation, reported red/green regressions and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Exact-head Gateway Telegram Test Server output demonstrates corrected owner-DM delivery, unchanged explicit routing and internal no-owner fallback; the subsequent v2026.11.6 upgrade and restart preserve cron_jobs.state_json incident and cooldown behavior, resolving the previous review’s request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Failure alerts from an owner-targeted automation can reach the last external chat instead of the owner.
Reason: Restores documented recipient and privacy behavior without adding configuration or a competing routing owner.

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
Reviewed head: fb1445a5934350257543b3c970dc47fedc70c77a

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron 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]
Loading

Technical review

Best 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

  • Scheduler-owned failure policy and Gateway transport keeps the original intent (177828a: Consolidate thresholds, cooldown, opt-outs and route policy in Cron while leaving the Gateway responsible for transport.)
  • Failure-notification session ownership keeps the original intent (3c0273e: Preserve the execution conversation and prevent untargeted private alerts from borrowing group routes.)
  • Delivery-default and thread inheritance keeps the original intent (87c9eb3: Layer configured destinations while preserving explicit job routes, account ownership and thread semantics.)
  • Persisted failure incidents keeps the original intent (5c81503: Group repeated failures across restarts while allowing changed causes or destinations to alert after cooldown.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 177828a adds src/cron/service/failure-alerts.ts:140 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 177828aa75bf; files: src/cron/service/failure-alerts.ts)
  • Ayaan Zaidi: Raw commit 9a12f4d adds src/cron/service/notification-dispatch.ts:63 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9a12f4dc2838; files: src/cron/service/notification-dispatch.ts)

PR surface

Source +26, Tests +18, Docs +4. Total +48 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 29 3 +26
Tests 2 25 7 +18
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 58 10 +48

Preflight source

Source 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 cluster

Relationship: fixed_by_candidate
Canonical: #189947
Summary: This PR directly repairs the owner-target routing omission documented by the linked open issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, 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:

  • P1: Released owner-targeted automations can send failure alerts to another conversation or fail to notify their owner.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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 execution lanes are retired.

History

Review history (6 earlier review cycles)
  • reviewed 2026-11-01T02:05:39.835Z sha 4697df9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-02T04:01:01.037Z sha c4e527e :: needs maintainer review before merge. :: none
  • reviewed 2026-11-02T04:08:09.815Z sha c4e527e :: needs maintainer review before merge. :: none
  • reviewed 2026-11-05T15:49:24.548Z sha 75fb918 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-19T19:28:20.727Z sha fb1445a :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-19T19:57:01.833Z sha fb1445a :: needs real behavior proof before merge. :: none

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.
@Satoshi-Kusumoto

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 2, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 2, 2026
@Satoshi-Kusumoto

Copy link
Copy Markdown
Contributor Author

@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.
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 19, 2026
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Telegram Test Server proof for fb1445a (observed lines; base = merge base f96a979):

#189947 / PR #189953 head fb1445a59343 (merge base f96a979a0f3b)

Regression (vitest-source, ocx test)
  base f96a979a0f3b: src/cron/service.failure-alert-notifications.test.ts -> 1 failed | 4 passed
    owner-targeted session row: expected undefined to be 'owner'
  base f96a979a0f3b: src/gateway/server-cron-notifications.test.ts -> 3 failed
    resolveDeliveryTarget called without target "owner" / directPolicy "block"
  candidate fb1445a59343: both files pass

Telegram Test Server (telegram-e2e-userbot runner, --source-gateway from each checkout; lease A = SUT bot + QA user 2201863137 as owner, recorder on the credential's group; lease B = second TDLib session of the same QA user reading the owner DM)
Config: commands.ownerAllowFrom ["telegram:2201863137"], channels.telegram.allowFrom ["2201863137"], cron.failureAlert {enabled:true, after:1}
Every job: delivery {mode:"announce", target:"owner"}, sessionKey = the group conversation the QA user just wrote in; fixture model returns HTTP 400 for the failing jobs.

base f96a979a0f3b (proof/base)
  group session agent:main:telegram:group:-5066489359
  "Nightly digest (base)": run error "LLM request rejected: fixture: the model rejected this request"; lastFailureNotificationDeliveryStatus=delivered
  group (recorder): SUT message +67.1s 'Automation "Nightly digest (base)" failed / Cause: format'
  owner DM (lease B): no new message (latest message predates the run)

candidate fb1445a59343 (proof/cand)
  "Nightly digest (candidate)": run error; alert delivered
  owner DM (lease B): SUT 2201754870 'Automation "Nightly digest (candidate)" failed / Cause: format'
  group (recorder): no alert for "Nightly digest (candidate)"
  "Owner digest that succeeds (candidate)": own delivery delivered; owner DM: SUT 'mock reply ok'
  control, failureAlert {channel:"telegram", to:<group id>}: group (recorder) +118.6s 'Automation "Digest with explicit alert route to the group (candidate)" failed'

candidate, no identifiable owner (proof/noowner)
  config file (regular file, not a symlink): commands.ownerAllowFrom=null, allowFrom=["*"], dmPolicy=open
  "Nightly digest (no owner)": run error; lastFailureNotificationDeliveryStatus=not-delivered
    gateway: "cron: failure alert delivery failed" err "Owner delivery unavailable (no-route); configure an authorized owner DM or edit this automation's delivery"
    in-app fallback: the group session history holds the alert as an internal cron event (provenance internal_system/cron); no Telegram message in the group or the owner DM
  "Owner digest that succeeds (no owner)": own delivery not-delivered, "Owner delivery unavailable (no-route); ..." (the same outcome)

Note: both pool credentials map to the same QA user, so a distinct second DM sender was unavailable; the group is the job session's last route (issue case 4).

@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 19, 2026
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Upgrade compatibility of the persisted failure-alert incident (v2026.11.6 -> fb1445a, observed lines):

Upgrade run: released v2026.11.6 (06afb10d3272) Gateway, then candidate fb1445a59343 on the same runner config and state, then a candidate restart. No doctor between starts.
One telegram-e2e-userbot runner run (--source-gateway; scenario restartGateway switches the checkout), recorder on the credential's group, owner DM read through the second lease's TDLib session.
Config: commands.ownerAllowFrom ["telegram:<leased user>"], cron.failureAlert {enabled:true, after:1} (default cooldown 1h).
Job "Nightly digest (upgrade)": delivery {mode:"announce", target:"owner"}, sessionKey = group conversation, fixture model HTTP 400.

1. v2026.11.6: run error at runAtMs 1795120616997
   group (recorder) +66.6s: 'Automation "Nightly digest (upgrade)" failed 1 times / Cause: format'  <- the bug: owner job alert in the group
   owner DM: no new message
2. candidate, same state, ~10 min later (inside the 1h cooldown): run error, consecutiveErrors=2
   lastFailureNotificationDeliveryStatus=not-requested; lastFailureAlertAtMs=1795120618169 (unchanged from step 1)
   group: no new SUT message; owner DM: no new message
3. candidate restart, run error, consecutiveErrors=3
   cron_jobs.state_json: {"lastRunStatus":"error","consecutiveErrors":3,"lastFailureAlertAtMs":1795120618169,
     "failureAlertIncident":{"signature":"f444d81b…78fbfd","scope":"run"},"lastFailureNotificationDeliveryStatus":"not-requested"}
   group: no new SUT message; owner DM: no new message

Result: the alert from v2026.11.6 is the only alert (1 group message in total, 0 in the owner DM). On both candidate starts the alert stays suppressed inside the cooldown. The persisted incident and lastFailureAlertAtMs from v2026.11.6 load unchanged. No duplicate and no loss: the candidate's signature includes the owner target, so after the 1h cooldown (not the 24h same-failure reminder) one alert goes to the owner DM, as the PR body says ("may alert once more after the cooldown"). That post-cooldown alert was not waited for in this run.
Gap: step 1's state_json was not captured (the dump step failed on its database lookup). Steps 2 and 3 show lastFailureAlertAtMs equal to step 1's alert time and the step 1 run record (failureNotificationDelivery present).

@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 19, 2026
@obviyus
obviyus merged commit f59d9a8 into openclaw:main Nov 19, 2026
169 of 174 checks passed
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Satoshi-Kusumoto for the report and the fix. This is merged in f59d9a8: failure alerts for automations with delivery.target: "owner" and no alert-specific route now resolve the owner DM through the same path the job's own delivery uses, instead of the session's last conversation or the channel default. With no identifiable owner, or directPolicy: "block", the alert is recorded as Not delivered and the in-app notification is queued, exactly like the job's own delivery. Explicit failure-alert routes are unchanged.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

[Bug]: Failure alerts for delivery.target "owner" automations resolve the session's last route instead of the owner DM

3 participants