Skip to content

fix(whatsapp): retain unmatched attachments across captioned replacement - #131672

Merged
steipete merged 2 commits into
mainfrom
steipete/whatsapp-attach-overlap
Aug 28, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/whatsapp-attach-overlap

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Important

review-required: per-attachment delivery/finalization semantics. Prepared under the auto-QA campaign from a channel-delivery audit (finding C1). Changes WhatsApp attachment finalization ownership, so this stays a draft for maintainer review.

What Problem This Solves

A WhatsApp reply that sends multiple images and is then followed by a captioned replacement sharing one image silently dropped the unmatched image. A multi-image tool response mediaUrls:[A,B] enters the deferred-media path; a later text:"Here is A", mediaUrls:[A] replacement — because the dedup tested whether any URL overlapped — resolved the entire pending [A,B] batch as non-visible and removed it. The recipient got A, never B, with no error and a misleading "superseded" message; settlement could not flush the removed remainder.

Why This Change Was Made

The invariant: replacing attachment A must not discard an unsent attachment B just because they share a logical payload — every admitted attachment gets delivery or an accurate recorded non-outcome. The fix subtracts only the attachments actually covered by the replacement and retains the unmatched units with their finalization ownership, recording real per-attachment acceptance instead of inferring "some content became visible." This also let the owner shed accumulated cruft: the whole-batch overlap-discard (introduced by a2efabf4c93, retained through 66a75bb9e52), a redundant post-canonical URL normalization, four duplicated media-send branches, and an ID-compare acceptance inference all removed — net −49 production lines.

User Impact

[A,B] followed by a captioned [A] now delivers B exactly once and does not re-deliver A; a full [A,B]→[A,B] replacement still supersedes cleanly; a non-overlapping [A,B]→[C] is unchanged; a vetoed or errored replacement still suppresses / surfaces its error.

Evidence

  • Production net −49 (+74/−123); tests net +242; docs +1. No schema, persistence-format, public-contract, or dependency change. WhatsApp-owned — no shared code changed (Telegram/Discord/message-plan already account per-attachment; verified unaffected).
  • Failing-first: [A,B]→[A] produced [[A]] pre-fix, [[A],[B]] after (real createWhatsAppReplyPlan + injected accepting transport, original prepare→tool→final→settled order).
  • Deep review kept the production fix unchanged, verified the opposite-failure direction (no double-send of a covered attachment, no resurrection of a suppressed one, hook-veto and visible-then-error handling preserved), confirmed the four removed media-send branches dropped no real path, and moved the four overlap cases into the canonical message_sent suite. Post-rebase whatsapp inbound-dispatch suite green; changed-file gate + two Codex autoreviews clean.
  • Proof caveat for the landing owner: this is core-dispatch integration proof, not a running mock-gateway or live WhatsApp delivery. The repository's channel-visible live/mock-gateway proof requirement should be satisfied (or a concrete exception recorded) before merge.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: M maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 4:30 PM ET / 20:30 UTC.

ClawSweeper review

What this changes

The PR changes WhatsApp deferred-media replacement so only accepted matching attachments are superseded and unmatched attachments remain queued for settlement.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: current main still contains the whole-payload overlap discard, while this PR moves ownership to per-attachment provider acceptance. No introduced blocking correctness defect was found; channel-boundary proof or a recorded exception remains the landing risk.

Priority: P1
Reviewed head: 10eda0e7249e4e79adc7cbf6bc0fc6a0d44124f6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair and regression coverage are solid, with one remaining maintainer-visible channel-proof risk.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; however, the supplied evidence is an injected-transport integration scenario rather than a mock-gateway verdict or live WhatsApp after-fix trace.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; however, the supplied evidence is an injected-transport integration scenario rather than a mock-gateway verdict or live WhatsApp after-fix trace.
Evidence reviewed 7 items Current-main defect remains: Current main resolves an entire deferred payload as non-visible when any URL overlaps a captioned replacement, so a pending batch containing A and B can lose B after a replacement containing A.
Introduced owner-boundary repair: The PR replaces whole-payload dropping with per-URL supersession and mutates the deferred payload to retain its unmatched normalized media URLs.
Receipt-to-attachment mapping: The WhatsApp delivery owner reports a media URL only after an accepted send result is retained, including a partial-delivery receipt, and the caller supersedes queued media from that callback.
Findings None None.
Security None None.

How this fits together

WhatsApp inbound reply handling buffers media-only tool output until a later captioned reply replaces it or turn settlement flushes it. Provider send receipts determine which queued attachments were delivered and which message-sent events are emitted.

flowchart LR
  A[Tool media reply] --> B[Deferred attachment queue]
  C[Captioned reply] --> D[Per-attachment matching]
  D --> E[WhatsApp media transport]
  E --> F[Accepted provider receipt]
  F --> G[Settlement]
  G --> H[Message-sent events]
Loading

Decision needed

Question Recommendation
Should this WhatsApp delivery repair require a mock-gateway or live-channel trace before merge, or should its current injected-transport evidence receive a documented exception? Require channel-boundary proof: Add a redacted mock-gateway verdict or live WhatsApp trace showing A is not repeated and unmatched B is delivered after settlement.

Why: The source repair and focused tests are coherent, but only a maintainer can accept an exception to the repository's normal channel-boundary proof expectation.

Before merge

  • Resolve merge risk (P1) - The PR body documents injected-transport integration coverage, not a mock-gateway verdict or live WhatsApp trace; the receipt/finalization change can still affect real message delivery ordering and failure handling.
  • Complete next step (P2) - This protected maintainer-authored PR needs normal maintainer proof-sufficiency review, not an automated repair lane.
Agent review details

Security

None.

PR surface

Source -49, Tests +242, Docs +1. Total +194 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 74 123 -49
Tests 3 272 30 +242
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 347 153 +194

Review metrics

Metric Value Why it matters
Production versus test delta production -49, tests +242, docs +1 The bug fix reduces production branching while substantially expanding replacement and settlement coverage.

Merge-risk options

Maintainer options:

  1. Capture channel-boundary proof (recommended)
    Before merge, add redacted mock-gateway or live WhatsApp evidence for a deferred multi-attachment reply followed by a partial captioned replacement.
  2. Accept a documented exception
    A maintainer may accept the current integration coverage only by recording why supported channel-boundary proof is infeasible.

Technical review

Best possible solution:

Keep the receipt-level supersession design and capture a redacted mock-gateway or live WhatsApp trace for deferred multi-attachment output followed by a captioned partial replacement before landing.

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

No runtime reproduction was run in this read-only review, but current-main source makes the A,B followed by captioned A scenario reproducible with high confidence.

Is this the best way to solve the issue?

Yes. Moving supersession to the accepted-media receipt boundary avoids treating a visible caption or unrelated attachment as proof that every queued attachment was delivered; channel-boundary evidence remains needed before landing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4c6ed51733d3.

Labels

Label justifications:

  • P1: This repairs silent loss of an attachment in a normal WhatsApp reply-delivery flow.
  • merge-risk: 🚨 message-delivery: The changed callback and coalescer decide whether deferred WhatsApp attachments are delivered, suppressed, or emitted as sent.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; however, the supplied evidence is an injected-transport integration scenario rather than a mock-gateway verdict or live WhatsApp after-fix trace.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Git blame attributes the original whole-payload coalescer around the changed ownership boundary to this commit. (role: recent base-path contributor; confidence: medium; commits: 4bbb3660dfb0; files: extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.ts, extensions/whatsapp/src/auto-reply/deliver-reply.ts)

Rank-up moves

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

  • Add a redacted mock-gateway or live WhatsApp after-fix trace, or record the concrete exception before merge.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-28T08:45:46.355Z sha b0e001f :: needs maintainer review before merge. :: none

Track WhatsApp acceptance per media URL so captioned replacements supersede only delivered attachments. Keep unmatched media under the original deferred finalization, preserve hook vetoes and partial-send errors, and share one ordered media-send branch.
Move overlap regressions to the canonical message_sent boundary and assert retained provider receipts, finalization visibility, and duplicate-free observer outcomes.
@steipete
steipete marked this pull request as ready for review August 28, 2026 20:23
@steipete
steipete force-pushed the steipete/whatsapp-attach-overlap branch from b0e001f to 10eda0e Compare August 28, 2026 20:23
@steipete
steipete merged commit 740f54e into main Aug 28, 2026
161 checks passed
@steipete
steipete deleted the steipete/whatsapp-attach-overlap branch August 28, 2026 21:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…ent (openclaw#131672)

* fix(whatsapp): retain unmatched attachments across captioned replacement

Track WhatsApp acceptance per media URL so captioned replacements supersede only delivered attachments. Keep unmatched media under the original deferred finalization, preserve hook vetoes and partial-send errors, and share one ordered media-send branch.

* test(whatsapp): verify attachment remainders through core settlement

Move overlap regressions to the canonical message_sent boundary and assert retained provider receipts, finalization visibility, and duplicate-free observer outcomes.
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 docs Improvements or additions to documentation 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. 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