Repository navigation
improve(whatsapp): reuse inbound message projection - #127958
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready evidence for exact head
All available landing gates are green; no review action remains. |
|
Merged via squash.
|
|
Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 10:43 AM ET / 14:43 UTC. ClawSweeper reviewWhat this changesThis PR builds one normalized WhatsApp inbound-message projection during enrichment and reuses it for text, media, reply, location, contact, and mention extraction. Merge readinessNo blocking correctness finding. The PR centralizes repeated inbound-message normalization inside the WhatsApp owner and preserves the raw-message fallback for standalone media callers; it remains open because it is maintainer-authored and carries the protected Priority: P3 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherThe WhatsApp plugin receives a Baileys message, authorizes it, enriches it into delivery facts, and then queues it for OpenClaw’s channel flow. This change shares one local normalized projection between enrichment and the delivery metadata it produces. flowchart LR
A[Inbound WhatsApp message] --> B[Admission and authorization]
B --> C[Normalized message projection]
C --> D[Enrichment]
D --> E[Media reply and mention facts]
E --> F[Queued channel delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +32, Other 0. Total +32 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the projection private to the WhatsApp plugin, retain the standalone raw-message fallback, and land only after exact-head validation confirms wrapper, media, and mention equivalence. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR optimizes an existing owner-local path rather than reporting a user-facing defect; source comparison confirms the repeated projection work on current main. Is this the best way to solve the issue? Yes. A private projection at the WhatsApp enrichment owner removes duplicate work while preserving the existing raw-message fallback; moving it into core or the public SDK would add unjustified surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 71b5de406111. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
After WhatsApp inbound authorization, ordinary message enrichment repeatedly rebuilt the same immutable Baileys normalized/future-proof wrapper chain for location, contacts, ad context, media kind, text, reply context, direct-media probing, and mentions.
Why This Change Was Made
Build one WhatsApp-owner-local readonly projection after authorization and reuse it across enrichment. Standalone extractor and media callers retain their existing normalization fallbacks. The projection type remains private, and only the narrow derived
mentionedJidsfact leaves enrichment; provider message references do not reach callbacks, persistence, core, protocol, config, or the public SDK.The direct-media handoff uses projection entry zero, which is exactly the Baileys
normalizeMessageContent(msg.message)result that the media owner previously computed itself. Later entries are extraction-only future-proof payloads.User Impact
Accepted WhatsApp inbound messages perform less repeated wrapper normalization and projection, with no user-visible behavior, routing, policy, media, mention, persistence, or configuration change.
Evidence
71b5de40611144b2406c0d28c9cc459b64b693bb; exact PR headfcc5e6ced962e086c4a7fd07d5205a1104f10e75.normalizeMessageContentcalls for an ordinary text message and failed the<= 2invariant; the candidate performs exactly 2 and preserves bodyhello. The implementation-coupled probe was removed after red/green proof per test-audit.e3af3bbd0289ca164a2ac26b2a86fe10ae11bcc980842fcec2808ab2565a8d07.node scripts/check-changed.mjs -- <five changed paths>passed all extension production/test typechecks, format, Oxlint, dead-export, boundary, ratchet, storage/media, and import-cycle gates. The final current-parent assertion ratchet also passed after an unrelated same-file baseline update on main.GIT_BRANCH=main pnpm buildpassed all TS/plugin/postbuild/UI phases; Control UI startup gzip remained within its committed tolerance.