Repository navigation
fix(cron): classify failure-alert deadlines by handoff and delivery ack - #203362
yy19971996 wants to merge 13 commits into
Conversation
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
|
🦞👀 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 real behavior proof before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +69, Tests +103, Other +2. Total +174 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: No label 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 (11 earlier review cycles; latest 8 shown)
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
|
@clawsweeper re-review |
|
🦞👀 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
|
@clawsweeper re-review |
|
🦞👀 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
|
@clawsweeper re-review |
|
🦞👀 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
|
@clawsweeper re-review |
|
🦞👀 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
|
🦞👀 Re-review progress:
|
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
|
@clawsweeper re-review |
|
🦞👀 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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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
|
@clawsweeper re-review |
|
🦞👀 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
|
@clawsweeper re-review |
|
🦞👀 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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
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. |
|
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 |
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-deliveredand 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 tounknowninstead of thedeliveredreceipt 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 outcomeunknownand no longer queues a duplicate in-app fallback; a complete acknowledgment settles asdeliveredwith 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).unknowndeliverednot-delivered+ in-app fallbackunknown, no fallbacknot-delivered+ fallbackpnpm exec vitest run src/gateway/server-cron-notifications.test.ts: 31/31 pass at head63ba9b5cf2. 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, showingdelivered: false/status: not-deliveredwheredelivered: true/status: deliveredis expected), while the pre-existing stalled-admission controls (recipientReached=false/true) still pass with their established outcomes.test-linesratchet: net +66, allocation credit 66 viaconfig/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 fromsrc/cron/delivery.tsinto 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.