Skip to content

fix(whatsapp): preserve accepted delivery and partial receipt ownership - #117198

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-whatsapp-accepted-delivery-lifecycle
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-whatsapp-accepted-delivery-lifecycle

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

WhatsApp could already accept and deliver a message, then report a later caption-send, group-mention-resolution, or activity-bookkeeping failure without preserving the accepted provider receipt. The existing retry owner also interpreted accepted partial-delivery disconnects as ordinary retryable failures and resent the same user-visible reply up to three times.

Why This Change Was Made

Fix both failures at their existing architectural owners. One private WhatsApp accepted-send lifecycle captures the real Baileys message key immediately after the awaited provider relay, preserves every accepted voice/caption/text/poll receipt through subsequent failures, and surfaces the original cause in the canonical partial-delivery envelope. Ordinary and structured sends share that lifecycle. The existing retry owner checks the canonical accepted-delivery state before matching disconnect text, without changing legitimate pre-accept retries or unknown-timeout policy.

This is a bounded owner refactor, not a second send path, a wider retry policy, or a public SDK/configuration change. The production delta is 51 additions and 21 deletions, net 30 lines, and removes repeated quoted-send dispatch decisions.

User Impact

Accepted WhatsApp messages and voice notes remain visible and retain their actual provider message IDs even if a caption, group mention lookup, poll activity update, or later bookkeeping step fails. Accepted replies are never resent merely because that later error contains a disconnect phrase, preventing duplicate user-visible WhatsApp messages while retaining normal retries for genuine pre-delivery socket failures.

Evidence

  • Frozen baseline: fdcb321; immutable candidate: 34356ba; exact candidate tree: 77501ebf9bb54c37033cd608030e10f2f6acac8e.
  • Current-main compatibility: 7e78de7 leaves the complete WhatsApp plugin, shared partial-delivery contract, Plugin SDK, package manifest, and lockfile byte-identical; clean synthetic merge tree 0f82de6b0bfd6136fcda8fae3b29c4744559ef04.
  • Seven genuine frozen-baseline RED scenarios prove accepted voice-caption disconnect, accepted voice mention failure, accepted canonical retry replay, actual auto-reply transport replay, ordinary text bookkeeping failure, structured poll bookkeeping failure, and combined voice+caption bookkeeping failure.
  • Focused real owner/retry/auto-reply boundary suite: 85/85 passed; corrected activity regression subset: 3/3 passed.
  • Isolated exact-head Linux Blacksmith Testbox: 101 WhatsApp test files and 1,262/1,262 tests passed, plus full extension production tsgo, full extension test tsgo, normal type-aware oxlint, and oxfmt. Exact-head proof run: https://github.com/openclaw/openclaw/actions/runs/30681035863. Wrapper exited 0, owned lease was stopped, and direct status was verified completed.
  • The real pinned Baileys 7.0.0-rc13 generated a real provider WAMessage without credentials; its installed sendMessage source awaits relayMessage before returning the accepted fullMsg, directly proving the lifecycle boundary used by this refactor.
  • Fresh full-branch genuine Codex Sol-high autoreview through P3: zero accepted findings, confidence 0.94. Three freshly refreshed, independent blind reviewers each returned P0=0/P1=0/P2=0/P3=0.

No authentication, security, public SDK, configuration, protocol, persistent-state, database, or migration changes.

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 11:55 PM ET / August 1, 2026, 03:55 UTC.

ClawSweeper review

What this changes

The PR captures accepted Baileys WhatsApp receipts before later caption, mention, or activity failures, then prevents the retry layer from replaying that known partial delivery.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This is a focused, owner-boundary WhatsApp bug fix with no discrete correctness finding from the reviewed diff. Keep it open for the existing maintainer-labelled review path and current-head CI completion; the patch should preserve ordinary pre-accept retries while preventing duplicate replies after confirmed provider acceptance.

Priority: P1
Reviewed head: 34356babbe0da3df078126229e47bfa4e61e4c2c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrowly scoped, follows the existing delivery contract, and is backed by focused and reported exact-head validation; only the normal maintainer-labelled merge refresh remains.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR supplies exact-head Testbox evidence, focused owner/retry coverage, and a direct pinned-provider acceptance check; redact any future runtime artifacts if they include account or endpoint details.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR supplies exact-head Testbox evidence, focused owner/retry coverage, and a direct pinned-provider acceptance check; redact any future runtime artifacts if they include account or endpoint details.
Evidence reviewed 6 items Accepted-send owner: The branch adds one local accepted-send lifecycle that records normalized provider results immediately after each awaited send, wraps later failures with the canonical partial-delivery envelope, and preserves the original failure as its cause.
Canonical delivery contract: The shared contract explicitly preserves provider-visible delivery facts when a later native operation fails, and its type guard requires the canonical code plus visibleReplySent state.
Retry boundary: The branch excludes canonical partial-delivery errors before applying the existing disconnect-text retry matcher, leaving direct pre-accept disconnect handling intact.
Findings None None.
Security None None.

How this fits together

The WhatsApp plugin turns agent replies into Baileys sends and performs follow-up caption, mention, and activity work. Its outbound retry adapter decides whether a rejected send is safe to replay, so accepted-delivery facts must reach that decision without losing the original failure.

flowchart LR
  A[Agent reply] --> B[WhatsApp send owner]
  B --> C[Baileys relay acceptance]
  C --> D[Caption, mention, activity work]
  D --> E[Partial-delivery receipt]
  E --> F[Outbound retry decision]
  F --> G[Visible WhatsApp reply]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main, so merge should use the actual three-way result and finish the in-progress current-head checks before landing; GitHub currently reports it cleanly mergeable.
  • Complete next step (P2) - No repair worker is needed because no actionable patch defect was found; retain the maintainer-labelled PR for normal merge review once its current-head checks finish.
Agent review details

Security

None.

PR surface

Source +30, Tests +141. Total +171 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 51 21 +30
Tests 3 141 0 +141
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 192 21 +171

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/whatsapp/src/inbound/send-api.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Merge after refreshed delivery proof (recommended)
    Use the clean three-way merge result and current-head CI to confirm that accepted partial deliveries remain non-retryable while genuine pre-accept disconnects still retry.
  2. Pause for an explicit delivery-policy review
    If maintainers want different semantics for a confirmed provider receipt, pause rather than merging a second retry policy.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Confirm the clean merge result and focused WhatsApp receipt/retry coverage on the current head before merge.

Technical review

Best possible solution:

Land the single accepted-send lifecycle and canonical retry exclusion after the current-head merge/CI refresh confirms the focused receipt and pre-accept retry cases still pass.

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

Yes, source-reproducible: an accepted first send followed by a caption, mention, or activity failure reaches the old generic disconnect retry path without a partial-delivery receipt. The branch adds focused regression coverage for those cases, although this read-only review did not execute the tests.

Is this the best way to solve the issue?

Yes: the patch records acceptance at the WhatsApp send owner and passes the canonical result to the existing retry owner, rather than adding a second send path or broadening retry heuristics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3374f78ad8e9.

Labels

Label changes:

  • add P1: The affected path can resend an already accepted user-visible WhatsApp reply, producing duplicate channel messages.
  • add merge-risk: 🚨 message-delivery: The patch changes the decision that suppresses or permits replay after a WhatsApp send fails.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies exact-head Testbox evidence, focused owner/retry coverage, and a direct pinned-provider acceptance check; redact any future runtime artifacts if they include account or endpoint details.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR supplies exact-head Testbox evidence, focused owner/retry coverage, and a direct pinned-provider acceptance check; redact any future runtime artifacts if they include account or endpoint details.

Label justifications:

  • P1: The affected path can resend an already accepted user-visible WhatsApp reply, producing duplicate channel messages.
  • merge-risk: 🚨 message-delivery: The patch changes the decision that suppresses or permits replay after a WhatsApp send fails.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR supplies exact-head Testbox evidence, focused owner/retry coverage, and a direct pinned-provider acceptance check; redact any future runtime artifacts if they include account or endpoint details.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies exact-head Testbox evidence, focused owner/retry coverage, and a direct pinned-provider acceptance check; redact any future runtime artifacts if they include account or endpoint details.

Evidence

What I checked:

  • Accepted-send owner: The branch adds one local accepted-send lifecycle that records normalized provider results immediately after each awaited send, wraps later failures with the canonical partial-delivery envelope, and preserves the original failure as its cause. (extensions/whatsapp/src/inbound/send-api.ts:84, 34356babbe0d)
  • Canonical delivery contract: The shared contract explicitly preserves provider-visible delivery facts when a later native operation fails, and its type guard requires the canonical code plus visibleReplySent state. (src/channels/turn/delivery-result.ts:20, 3374f78ad8e9)
  • Retry boundary: The branch excludes canonical partial-delivery errors before applying the existing disconnect-text retry matcher, leaving direct pre-accept disconnect handling intact. (extensions/whatsapp/src/outbound-retry.ts:18, 34356babbe0d)
  • Regression coverage: The branch adds focused cases for accepted voice-caption failure, mention failure, activity bookkeeping failure, combined receipts, retry suppression, and auto-reply non-replay. (extensions/whatsapp/src/inbound/send-api.test.ts:476, 34356babbe0d)
  • Feature provenance: The current send and retry behavior being repaired was introduced together by the prior channel refactor, which anchors the same owner boundary on current main. (extensions/whatsapp/src/outbound-retry.ts:17, a1b41d5ddb05)
  • Submitted real-behavior evidence: The PR body reports an exact-head Linux Testbox run with all WhatsApp tests passing and a direct pinned-Baileys acceptance-boundary check; the provided GitHub context also records a successful Real behavior proof check. (34356babbe0d)

Likely related people:

  • Peter Steinberger: Git blame attributes the current send/retry behavior to the recent channel refactor, and the same person authored the proposed owner-boundary repair. (role: feature introducer and recent area contributor; confidence: high; commits: a1b41d5ddb05, 34356babbe0d; files: extensions/whatsapp/src/inbound/send-api.ts, extensions/whatsapp/src/outbound-retry.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the clean three-way merge and allow the current-head CI set to complete before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 121a862 into main Aug 1, 2026
124 of 135 checks passed
@steipete
steipete deleted the codex/qa400-whatsapp-accepted-delivery-lifecycle branch August 1, 2026 04:31
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant