fix(delivery): disambiguate hook cancellations from delivery failures#1693
Open
BingqingLyu wants to merge 1 commit into
Open
fix(delivery): disambiguate hook cancellations from delivery failures#1693BingqingLyu wants to merge 1 commit into
BingqingLyu wants to merge 1 commit into
Conversation
…openclaw#57766) Enrich deliverOutboundPayloads return type from OutboundDeliveryResult[] to DeliveryOutcome — carries cancelledCount and allCancelledByHook so callers can distinguish intentional hook suppression from delivery failure. Wrap mid-stream non-bestEffort throws in DeliveryError with sentBeforeError to prevent blind retries that duplicate already-delivered messages. Guard retryTransientDirectCronDelivery against DeliveryError so partial sends are never retried in the cron direct-delivery path. DeliveryError is detected via a local isDeliveryError(err) helper that checks err.name + Array.isArray(err.sentBeforeError), with DeliveryError imported as a type only. This keeps the heavy outbound delivery module off delivery-dispatch.ts's cold-startup import graph (preserving the existing loadDeliveryOutboundRuntime boundary) and stays defensive against a third-party adapter throwing a same-named error. Updates all 5 callers that use the return value; 9 fire-and-forget callers need no changes. Test mocks updated to return DeliveryOutcome shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deliverOutboundPayloadsreturn type fromOutboundDeliveryResult[]toDeliveryOutcome— carriescancelledCountandallCancelledByHookso callers can distinguish intentional hook suppression from delivery failureDeliveryErrorwithsentBeforeErrorto prevent blind retries that duplicate already-delivered messagesMotivation
Closes openclaw#57766. Unblocks correct delivery status tracking in openclaw#53961 and openclaw#57755 — both currently report hook cancellations as
deliveryStatus.succeeded: false.Test plan
deliver.test.tspassdeliver.lifecycle.test.tspass (12 existing + 5 new)delivery-dispatch.double-announce.test.tspasstsgoerrors (pre-existing tui: getKeybindings import no longer exported by @mariozechner/pi-tui, breaking pnpm tsgo openclaw/openclaw#57196 failure on main)New tests added:
allCancelledByHook: true, empty results,cancelledCountmatches payload countcancelledCount,allCancelledByHook: falsecancelledCount: 0,allCancelledByHook: falseDeliveryErrorwithsentBeforeErrorDeliveryError)🤖 Generated with Claude Code