Repository navigation
refactor(whatsapp): split inbound monitor orchestration - #115806
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 9:04 AM ET / 13:04 UTC. ClawSweeper reviewWhat this changesThe branch splits the WhatsApp inbound monitor into dedicated socket-session, group-metadata-cache, message-normalization, enrichment, debounce, and delivery modules while retaining Merge readinessKeep this PR open for normal maintainer review. It is a maintainer-authored, maintainer-labeled WhatsApp refactor with a clean merge result and substantial targeted/CI validation, but it rewires the live inbound delivery and socket-shutdown path too broadly for automated cleanup or an evidence-free close. Priority: P3 Review scores
Verification
How this fits togetherWhatsApp Web socket events enter the inbound monitor, which admits and normalizes messages, manages group metadata and short-lived caches, then delivers messages to the OpenClaw channel runtime. The refactor changes how those owners are composed while preserving message delivery, reconnect, retry, dedupe, and shutdown behavior. flowchart LR
A[WhatsApp Web socket events] --> B[Inbound monitor composition root]
B --> C[Attached socket session]
B --> D[Group metadata cache]
B --> E[Delivery coordinator]
E --> F[Admission and normalization]
F --> G[Debounce and durable delivery]
G --> H[OpenClaw channel runtime]
C --> E
D --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource +297, Other -1. Total +296 across 14 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land only after a WhatsApp-area maintainer confirms that reconnect, close/drain, dedupe, and read-receipt ownership remain equivalent at the current merge result; keep the monitor as the single composition root and the new modules WhatsApp-local. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a behavior-preserving internal refactor rather than correcting a reported user-facing failure. Its relevant proof is lifecycle-equivalence coverage of the existing monitor behavior. Is this the best way to solve the issue? Unclear: the proposed WhatsApp-local ownership split matches the repository’s bounded-refactor architecture, but the size and lifecycle sensitivity require maintainer confirmation that the new composition preserves current delivery and shutdown invariants. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 79e0b559fe46. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…nitor-orchestration refactor(whatsapp): split inbound monitor orchestration
What Problem This Solves
The WhatsApp inbound monitor concentrated socket lifecycle, metadata caching,
message admission and delivery, retry, dedupe, and shutdown behavior in one
high-context module. This made behavior-neutral maintenance risky even though
the monitor inbox already has substantial coverage.
Why This Change Was Made
This maintainer-requested refactor separates the attached socket session,
bounded group metadata cache, and message delivery coordinator, with
inbound/monitor.tsreduced to a composition root. Delivery-specific helpersown debounce batching, identity/access normalization, and media enrichment so
each module stays below the repository line limit.
Retry, dedupe, reconnect handoff, cache invalidation, and shutdown drain
ordering remain explicit and WhatsApp-local. No transport policy moved into
core, and there is no compatibility or user-visible behavior change.
This PR is AI-assisted. I reviewed the complete branch and understand the
resulting ownership and shutdown flow.
User Impact
No user-visible behavior change. Maintainers can diagnose monitor failures from
smaller owner-specific modules and test names.
Evidence
node scripts/run-vitest.mjs extensions/whatsapp/src/monitor-inbox.behavior.test.ts extensions/whatsapp/src/inbound/durable-receive.test.ts extensions/whatsapp/src/inbound.media.test.tsoxfmt,oxlint, andgit diff --checkpassed.check-max-lines-ratchetpasses after removing the obsoleteinbound/monitor.tsbaseline exception.node scripts/check-deadcode-exports.mjsorigin/main: no accepted/actionable findings.One callback-variance claim was rejected because the composition root already
narrows through
normalizeAdmittedWebInboundMessage; the same code passedcheck-prod-types.9e246deb6ef: 70 checks passed, 39intentionally skipped, zero failed.