Skip to content

fix(whatsapp): normalize provider self-echo identity ownership - #117228

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-whatsapp-provider-self-echo-normalization
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-whatsapp-provider-self-echo-normalization

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

WhatsApp gateway-originated messages can return as apparent new inbound messages when the provider changes their conversation identity. Device-qualified numbers, legacy @c.us identifiers, hosted phone/LID domains, and equivalent direct-message phone/LID aliases previously bypassed the outbound-echo cache and could trigger incorrect pairing, replies, or duplicate work.

Why This Change Was Made

The existing private dedupe owner stored destination JIDs verbatim even though pinned [email protected] normalizes incoming JIDs and exposes direct-chat aliases through remoteJidAlt. The fix applies the provider's actual canonicalization rules at the owning boundary, narrows decoded hosted users correctly for strict TypeScript, and restricts alternate identity matching to direct conversations.

User Impact

Gateway-originated WhatsApp self echoes are suppressed consistently across real provider identity representations. Account and message isolation, ordinary human-authored group commands, group participant aliases, access policy, and the existing cache lifetime remain unchanged.

Evidence

  • Actual pinned Baileys cleanMessage and decodeMessageNode: six frozen-baseline failures become six passing final-production scenarios, including hosted PN/LID domains and direct phone/LID aliases.
  • Provider-boundary controls verify cross-account and message-ID isolation, reject cross-group alias matches, and preserve human group messages.
  • Dedicated immutable Blacksmith Testbox: 99 WhatsApp test files and 1,263 tests passed, including the real inbound-monitor regressions.
  • Full production extension TypeScript, full extension-test TypeScript, strict owner/provider declaration compatibility, normal type-aware lint, and formatting all passed.
  • Four independent hostile reviews and a genuine Sol-high autoreview --max-priority P3 report zero P0/P1/P2/P3 findings.
  • Dedicated Testbox tbx_01kyxvfbrdt85nfmjysfteyyry was stopped and verified completed after the successful immutable run: https://github.com/openclaw/openclaw/actions/runs/30685210696.

@steipete
steipete marked this pull request as ready for review August 1, 2026 05:23
@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: S 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 August 1, 2026, 1:58 AM ET / 05:58 UTC.

ClawSweeper review

What this changes

Normalizes WhatsApp outbound and inbound conversation identities so provider-rewritten self echoes match the existing outbound-message cache without treating group aliases as direct-chat aliases.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for protected maintainer review. The patch repairs an existing WhatsApp self-echo dedupe boundary with focused provider-normalization coverage; no discrete correctness or security defect was found in the proposed diff.

Priority: P1
Reviewed head: fb85fa3cde0941969c5c50deaff056d23726e08a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with strong stated after-fix evidence and no supported correctness finding; final protected-label maintainer review remains appropriate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body supplies after-fix pinned-provider scenarios and a completed immutable Testbox run covering the WhatsApp suite; the supplied check context also records successful real-behavior proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body supplies after-fix pinned-provider scenarios and a completed immutable Testbox run covering the WhatsApp suite; the supplied check context also records successful real-behavior proof.
Evidence reviewed 6 items Owning dedupe boundary: The PR canonicalizes the remote JID in the private outbound cache key, preserving account and message-ID scoping; direct aliases are tried only after the primary key misses.
Inbound call-site coverage: The inbound normalizer supplies Baileys' alternate direct-chat identity before the existing self-echo decision, which remains ahead of access control and new agent work.
Focused regression scenarios: The branch adds cases for device-qualified, legacy, hosted, and direct phone/LID alias echoes, plus account/message isolation and a group-alias control.
Findings None None.
Security None None.

How this fits together

The bundled WhatsApp plugin records gateway-sent message identifiers, then normalizes incoming Baileys message upserts before access control and agent work. This change makes the cache compare provider-equivalent phone and LID identities so a gateway self echo does not become new inbound work.

flowchart LR
  A[Gateway sends WhatsApp message] --> B[Outbound dedupe cache]
  B --> C[Canonical account, identity, and message key]
  D[Baileys inbound message upsert] --> E[Inbound identity normalization]
  E --> F{Matches recent outbound key?}
  C --> F
  F -->|Yes| G[Suppress self echo]
  F -->|No| H[Access control and agent work]
Loading

Before merge

  • Resolve merge risk (P1) - This change sits on the inbound message-suppression boundary: a mismatch in the provider's direct-alias contract could suppress an otherwise eligible self-authored direct message, so the final maintainer review should confirm that the attached Baileys/Testbox proof represents production alias semantics.
Agent review details

Security

None.

PR surface

Source +164. Total +164 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 166 2 +164
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 166 2 +164

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Land with the guarded provider contract (recommended)
    Accept the focused direct-alias match because the branch preserves account/message isolation and includes group and human-message controls alongside the completed Testbox evidence.
  2. Request a provider capture before landing
    Ask for a redacted Baileys payload or fixture demonstrating the exact production remoteJidAlt aliases if maintainers need additional assurance beyond the existing Testbox scenarios.

Technical review

Best possible solution:

Retain one canonical dedupe-key builder at the WhatsApp provider boundary and merge after maintainer confirmation that the guarded direct-alias behavior matches the pinned Baileys contract.

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

Yes, source inspection establishes the current-main failure shape: outbound cache keys retain raw JIDs while inbound Baileys upserts can use normalized or alternate direct-chat identities. The branch's focused scenarios exercise that boundary, but this read-only review did not run them locally.

Is this the best way to solve the issue?

Yes, conditionally: normalizing identity at the cache owner is narrower and more maintainable than adding downstream echo guards, and the alternate lookup is explicitly limited to direct conversations.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 732c57435c98.

Labels

Label changes:

  • add P1: The PR repairs a WhatsApp inbound workflow where gateway-originated self echoes can otherwise become duplicate pairing, reply, or agent work.
  • add merge-risk: 🚨 message-delivery: The diff changes the inbound decision that suppresses a message before access control and agent processing, making provider identity semantics merge-relevant.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix pinned-provider scenarios and a completed immutable Testbox run covering the WhatsApp suite; the supplied check context also records successful real-behavior proof.
  • 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 body supplies after-fix pinned-provider scenarios and a completed immutable Testbox run covering the WhatsApp suite; the supplied check context also records successful real-behavior proof.

Label justifications:

  • P1: The PR repairs a WhatsApp inbound workflow where gateway-originated self echoes can otherwise become duplicate pairing, reply, or agent work.
  • merge-risk: 🚨 message-delivery: The diff changes the inbound decision that suppresses a message before access control and agent processing, making provider identity semantics merge-relevant.
  • 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 body supplies after-fix pinned-provider scenarios and a completed immutable Testbox run covering the WhatsApp suite; the supplied check context also records successful real-behavior proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix pinned-provider scenarios and a completed immutable Testbox run covering the WhatsApp suite; the supplied check context also records successful real-behavior proof.

Evidence

What I checked:

Likely related people:

  • steipete: Current main attributes the complete dedupe owner to Peter Steinberger's recent self-echo repair, and the proposed branch extends that same boundary. (role: recent area contributor and current dedupe-boundary author; confidence: high; commits: 65717fd3be89, fb85fa3cde09; files: extensions/whatsapp/src/inbound/dedupe.ts, extensions/whatsapp/src/inbound/message-normalization.ts, extensions/whatsapp/src/inbound/socket-session.ts)

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 1f130ce into main Aug 1, 2026
168 of 188 checks passed
@steipete
steipete deleted the codex/qa400-whatsapp-provider-self-echo-normalization branch August 1, 2026 07:08
@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: S 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