Skip to content

fix(cron): classify failure-alert deadlines by handoff and delivery ack - #203362

Closed
yy19971996 wants to merge 13 commits into
openclaw:mainfrom
yy19971996:fix/cron-failure-alert-unknown-203140
Closed

yy19971996 wants to merge 13 commits into
openclaw:mainfrom
yy19971996:fix/cron-failure-alert-unknown-203140

Conversation

@yy19971996

Copy link
Copy Markdown
Contributor

Fixes #203140

What Problem This Solves

The Gateway deadline wrapping a cron failure alert's strict announce classified its timeout only from the recipient-reached flag, which turns true when a receipt becomes visible to the caller. A provider acknowledgment that arrived after the deadline — or whose publication lagged it — therefore recorded not-delivered and queued the in-app fallback even though the provider had accepted the alert. In the mirrored ordering (ack visible, conversation-history write stalled past the deadline) the outcome degraded to unknown instead of the delivered receipt that had already landed.

Why This Change Was Made

The durable batch now reports two facts the deadline classifier was missing: the provider handoff (fired before sendDurableMessageBatchCore, after which the provider may still complete the send) and the complete payload acknowledgment. Deadline classification becomes three states: a deadline before the handoff predicts non-delivery and keeps the fallback; a handoff without the complete acknowledgment leaves the outcome unknown and no longer queues a duplicate in-app fallback; a complete acknowledgment settles as delivered with the history-write failure staying a diagnostic. Partial acknowledgments and fail-fast history errors keep their current outcomes, and conversation-only alerts (where the history write is the delivery) are unchanged.

User Impact

Operators see the alert's real delivery state: a sent failure alert is no longer reported as not delivered, and the duplicate in-app fallback no longer appears on top of a delivered external alert. Pre-handoff deadlines still prove non-delivery.

Evidence

Red/green at the owning boundary, head 63ba9b5cf2 (Node 26.12.1, Linux).

Scenario Unpatched Patched
Handoff + complete ack before deadline, history write stalled unknown delivered
Handoff, no complete ack at deadline not-delivered + in-app fallback unknown, no fallback
Deadline before handoff not-delivered + fallback unchanged (control)

pnpm exec vitest run src/gateway/server-cron-notifications.test.ts: 31/31 pass at head 63ba9b5cf2. The new "settles a handoff whose complete payload was acked before the deadline as delivered" and "does not queue the in-app fallback for a handoff without a complete acknowledgment" cases fail on the unpatched classifier (verified by reverting the classification, showing delivered: false/status: not-delivered where delivered: true/status: delivered is expected), while the pre-existing stalled-admission controls (recipientReached=false/true) still pass with their established outcomes. test-lines ratchet: net +66, allocation credit 66 via config/test-lines-allocations/203140-failure-alert-deadline.txt.

Gap: the live Telegram observation from the issue was not reproduced here (no channel credentials on this host); the deterministic deadline orderings the reporter built exercise the same classification path at the owning boundary.

AI Assistance

This PR is AI-assisted. Used grep and git log to analyze issue #203140, locate the deadline classifier in src/gateway/server-cron-notifications.ts, and thread the handoff/acknowledgment facts from src/cron/delivery.ts into it. The implementer understands the code: the classifier now distinguishes proven non-delivery (before handoff) from unproven non-delivery (after handoff, no complete ack) and confirmed delivery (complete ack), and only the last two suppress the in-app fallback. All evidence above is from real local runtime execution.

The Gateway deadline wrapped the strict announce call and classified its
timeout only from the recipient-reached flag, which turns true when a
receipt is visible to the caller. A provider acknowledgment arriving
after the deadline (or its publication lagging the deadline) therefore
recorded not-delivered and queued the in-app fallback even though the
provider had accepted the alert, and a stalls in the conversation-history
write recorded unknown instead of the delivered receipt that had already
landed.

The durable batch now reports the provider handoff and the complete
payload acknowledgment to the failure-alert caller, which classifies the
deadline in three states: before handoff proves non-delivery (fallback
kept), a handoff without the complete ack is unknown without queueing a
duplicate fallback, and a complete ack settles as delivered with the
history failure staying a diagnostic. Partial acknowledgments and
fail-fast history errors keep their current outcomes.

Fixes openclaw#203140
@clawsweeper

clawsweeper Bot commented Nov 22, 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 gateway Gateway runtime size: S labels Nov 22, 2026
@yy19971996
yy19971996 marked this pull request as ready for review November 22, 2026 00:04
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR distinguishes transport dispatch, complete payload acknowledgment, and history recording when classifying cron failure-alert deadlines.

Example: A Telegram failure alert is acknowledged before the 10-second deadline, but conversation-history recording stalls.

  • Before: The alert settles as unknown despite confirmed delivery.
  • After: The alert settles as delivered, with the history failure retained as a diagnostic.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source change is coherent and the prior finding is resolved, but required real-behavior proof is absent and exact-head validation is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators can see non-delivery or uncertainty for an externally accepted failure alert, and false non-delivery can trigger an unnecessary in-app fallback.
Reason: The change restores the existing three-state delivery contract using the current cron and outbound owners, with no new user configuration or storage model.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR addresses a source-supported delivery-state bug still present on current main; the previous test finding is fixed, and no new blocking code defect was identified.

Priority: P2
Reviewed head: 43bc2789526b621534f45f8ee55171927becb9c3

Before merge

  • Add real behavior proof - The PR body reports mocked Gateway tests at initial head 63ba9b5, and discussion supplies no after-fix runtime trace through strict announce, durable dispatch, retry clearing, and transport acknowledgment/history ordering; the contributor must supply that evidence and redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted runtime evidence through the real failure-alert and outbound transport path showing pre-dispatch timeout, in-flight timeout, acknowledged delivery with stalled history, and proven non-delivery before retry backoff; the supplied red/green claim covers the mocked classifier rather than this production composition.
Agent review details

How this fits together

The Gateway sends scheduler failure alerts through strict cron announce and durable outbound delivery, then returns a delivery outcome to the cron owner for persistence and fallback selection.

flowchart TD
  A[Cron failure alert] --> B[Gateway deadline]
  B --> C[Strict cron announce]
  C --> D[Durable outbound queue]
  D --> E[Channel transport]
  E --> F[Conversation history]
  D --> G[Delivery classification]
  F --> G
  G --> H[Cron outcome and fallback]
Loading

Technical review

Best possible solution:

Use the existing outbound dispatch and completed-payload boundaries to classify failure alerts independently of history recording while preserving bounded admission and fallback for proven non-delivery.

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

Current-main source establishes both deadline orderings, supported by the reporter’s official-release fixture; no tests, fixture, or live sends were executed during this read-only review.

Is this the best way to solve the issue?

Separating dispatch uncertainty and completed-payload acknowledgment from transcript bookkeeping addresses the faulty invariant without changing deadlines, routes, stored formats, or retry ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 31c9a9a90f50.

Provenance checked

  • Failure-alert outcome classification keeps the original intent (3e94877: Persist settled alert outcomes and reserve fallback for current, confirmed non-delivery.)
  • Bounded Gateway admission keeps the original intent (af0a1c0: Prevent a non-responsive failure-alert transport from retaining Gateway admission indefinitely.)
  • Confirmed delivery and destination-history recording keeps the original intent (e63e209: Make the resolved destination own delivered conversation results while keeping history-write failures from undoing confirmed transport delivery.)
  • Durable transport dispatch evidence keeps the original intent (889d93a: Distinguish actual platform dispatch from pre-send preparation so ambiguous sends cannot be replayed as proven non-delivery.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +69, Tests +103, Other +2. Total +174 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 73 4 +69
Tests 1 103 0 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 9 178 4 +174

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: same_root_cause
Canonical: #203140
Summary: This PR implements the dispatch-versus-acknowledgment classification repair described by the linked report.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs bounded failure-alert delivery accounting and unnecessary fallback behavior without evidence of a widespread urgent regression.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-11-22T03:04:59.983Z sha 2d92d83 :: needs real behavior proof before merge. :: [P2] Observe actual transport dispatch after channel preparation
  • reviewed 2026-11-22T03:59:15.569Z sha 807e9ff :: needs real behavior proof before merge. :: [P2] Observe transport dispatch separately from adapter admission | [P2] Clear resolved non-delivery before retry backoff
  • reviewed 2026-11-22T05:05:32.900Z sha 455f73e :: needs real behavior proof before merge. :: [P2] Observe outstanding transport work before its result arrives
  • reviewed 2026-11-22T06:38:44.169Z sha f9cd245 :: needs real behavior proof before merge. :: [P2] Forward the dispatch observer into the durable send
  • reviewed 2026-11-22T07:01:34.999Z sha d607bcd :: needs real behavior proof before merge. :: [P2] Clear resolved no-send dispatch state before retry backoff
  • reviewed 2026-11-22T08:42:05.031Z sha ac99cd3 :: needs real behavior proof before merge. :: [P2] Remove the unread per-attempt dispatch flag
  • reviewed 2026-11-22T09:07:48.977Z sha a71ffa3 :: needs real behavior proof before merge. :: [P2] Exercise dispatch without fabricating recipient evidence
  • reviewed 2026-11-22T09:37:16.789Z sha ca66e1f :: needs real behavior proof before merge. :: [P2] Exercise dispatch without fabricating recipient evidence

Reviewed November 22, 2026, 5:11 AM ET / 10:11 UTC (Revision 12).

…uthoritative

First review round repairs for openclaw#203362:

- Report the handoff from the platform dispatch boundary (after admission,
  hooks and durable queue staging) instead of before the durable batch
  call, so a deadline that expires during pre-send preparation stays
  not-delivered and keeps its in-app fallback.
- Latch the unknown classification to deadlines (and to webhook attempts
  whose outcome was observed as indeterminate) rather than every
  exception: an ordinary permanent rejection after a handoff remains
  authoritative non-delivery with its fallback.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Second review round repair for openclaw#203362: the deadline latch had absorbed
the recipient-reached signal, so a first chunk accepted by the provider
followed by a later chunk failure recorded not-delivered and queued the
in-app fallback although external progress was confirmed. Recipient
evidence now disproves non-delivery independently of the deadline; only
a bare handoff without recipient evidence still needs the deadline to
become unknown, and a complete acknowledgment still settles delivered.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Third review round repair for openclaw#203362: the platform dispatch callback is
also invoked at adapter admission, before channel-side preparation that
can still wait past the deadline (e.g. resolving an unresolved chat id).
The handoff now rides the platform send start: the queue executor has
persisted its pre-send state and flips its own platform-send flag right
after this returns, so a deadline expiring during preparation keeps its
not-delivered classification and fallback.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…dmission

Fourth review round repair for openclaw#203362: onPlatformSendStart still runs
inside dispatchToAdapter before the adapter is entered, so an alert whose
channel-side preparation blocks past the deadline (e.g. resolving an
unresolved chat id) was recorded unknown with its fallback suppressed
although no send request had begun. The handoff now rides the channel
turn's platform send dispatch: delivery custody is established and the
adapter is invoked immediately after, which is the actual transport
boundary.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Fifth review round repair for openclaw#203362: the previously selected callback is
also forwarded by the queue executor's adapter-admission handoff, so it
fired before the adapter ran and a channel-preparation deadline still
recorded unknown with its fallback suppressed. The observer now rides the
delivery result callback, which only fires once the adapter actually
returns transport output; the handoff-only signal is removed.

Fixes openclaw#203140
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Nov 22, 2026
Sixth review round repair for openclaw#203362: the replacement observer shared its
invocation with onDeliveryAttempt, so it added no independent information and
the in-flight-at-deadline case still recorded not-delivered with fallback
queued. The outbound owner now exposes a distinct signal that only fires once
the queue executor has durably marked the send dispatched; Gateway consumes
that one, separately from receipt evidence.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Seventh review round repair for openclaw#203362: the new signal was added to the
schema and the consumer, but sendCronAnnouncePayloadStrict never forwarded it
into sendDurableMessageBatchCore, so only the delivery-result callback set it
and the in-flight-at-deadline case stayed unproven. The observer now travels
with the batch params, leaving the queue executor's post-mark point as its
only source.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Nov 22, 2026
Eighth review round repair for openclaw#203362: the forwarded observer latched on the
first attempt's durable dispatch and nothing cleared it, so two fast
connection failures followed by a deadline inside the retry backoff recorded
unknown and suppressed the fallback although no request was outstanding. The
observer is now scoped per attempt, and a proven non-delivery clears it so the
following attempt's deadline can prove non-delivery again.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Nov 22, 2026
Ninth review round repair for openclaw#203362: attemptDispatched was assigned but
never read, which the core noUnusedLocals setting rejects. The per-attempt
reset already happens through onTransportDispatchCleared, so the flag is
removed.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…essions

Tenth review round repair for openclaw#203362: the regressions invoked a stale
onTransportDispatch callback name while production passes onTransportDispatched,
so the optional invocation was never exercised. The mocks now destructure the
same name the production path supplies.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…ssion

Eleventh review round repair for openclaw#203362: the regression also reported a
delivered attempt, so the pre-existing recipient branch alone produced unknown
and the test could not detect a disconnected dispatch observer. It now reports
only the dispatch, and fails when the dispatch classification is disabled,
while the separate recipientReached control keeps its own coverage.

Fixes openclaw#203140
@yy19971996

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@yy19971996

Copy link
Copy Markdown
Contributor Author

Status note for maintainers: the remaining item is real-behavior proof through a real outbound transport (Telegram). No Telegram credentials are available on this host, so the red/green above (mocked strict announce at the owning boundary) plus the six deadline orderings cannot be extended to a live Telegram send here. If that is acceptable, this is ready for maintainer review; if not, please say so and I will keep the branch parked until a Telegram-capable environment is available.

@yy19971996

Copy link
Copy Markdown
Contributor Author

Closing — the remaining gate needs runtime evidence that is not producible from this environment.

The open item is a runtime trace through the real failure-alert and outbound transport path covering pre-dispatch timeout, in-flight timeout, acknowledged delivery with stalled history, and proven non-delivery before retry backoff. That requires a configured outbound channel credential (Telegram, per the linked issue) plus a genuinely stalled history write in a live run; this host has neither channel credentials nor a way to induce a real stalled-history write without altering the code under test, and a fabricated stall would be the mocked evidence the review excludes. The mocked-classifier red/green on file cannot stand in for this production composition.

Branch fix/cron-failure-alert-unknown-203140 at 43bc278952 is kept; the change restores the existing three-state delivery contract with no identified defect, so it can be reopened as-is where a live channel trace can be captured.

@yy19971996 yy19971996 closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cron failure alert can record not-delivered despite a provider acknowledgment

1 participant