Skip to content

fix(whatsapp): persist inbound delivery in plugin state - #85506

Merged
steipete merged 4 commits into
mainfrom
fix/whatsapp-durable-inbound-plugin-state
May 23, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/whatsapp-durable-inbound-plugin-state

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • add a generic createDurableInboundReceiveJournal helper on the channel-message SDK surface backed by plugin keyed state
  • wire WhatsApp inbound delivery through plugin-state pending/completed journals instead of a plugin-local JSON disk cache
  • delay WhatsApp read receipts until handler completion, release durable state on retryable failures, and fall back to live delivery if persistence rejects an oversized payload
  • cover journal races and WhatsApp read/retry/fallback behavior

Verification

  • node scripts/run-vitest.mjs src/channels/message/durable-receive.test.ts extensions/whatsapp/src/monitor-inbox.behavior.test.ts
  • pnpm build
  • OPENCLAW_TESTBOX=0 pnpm check:changed
  • autoreview --mode local --base origin/main --no-web-search: clean after fixups
  • pnpm check:changed via Testbox attempted first, but remote image failed before repo checks: missing /usr/local/global/v11/f89-19e513f609a/node_modules/pnpm/bin/pnpm.mjs

Behavior addressed: WhatsApp inbound messages are persisted through plugin state before handler dispatch, and read receipts are sent only after successful handler completion.
Real environment tested: Local OpenClaw checkout with Node/pnpm repo tooling; Testbox remote attempted but failed before checks due image pnpm path issue.
Exact steps or command run after this patch: node scripts/run-vitest.mjs src/channels/message/durable-receive.test.ts extensions/whatsapp/src/monitor-inbox.behavior.test.ts; pnpm build; OPENCLAW_TESTBOX=0 pnpm check:changed; local autoreview.
Evidence after fix: Focused tests passed 65/65; build passed plugin SDK export checks; local changed gate passed typecheck/lint/runtime guard lanes; autoreview reported no actionable findings.
Observed result after fix: Retryable WhatsApp handler failures keep inbound messages pending without sending read receipts; completed or duplicate deliveries do not replay; persistence rejection falls back to live delivery instead of dropping the message.
What was not tested: Live WhatsApp device roundtrip; remote Testbox gate was blocked by the pnpm image issue noted above.

Refs #85257.

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XL maintainer Maintainer-authored PR labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Latest ClawSweeper review: 2026-05-23 11:17 UTC / May 23, 2026, 7:17 AM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • 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.

Summary
The branch adds a plugin-state-backed durable inbound receive journal, exposes it through openclaw/plugin-sdk/channel-message, and rewires WhatsApp inbound handling to persist pending/completed deliveries and delay read receipts.

Reproducibility: yes. from source inspection: current main marks WhatsApp messages read before enrichment, dedupe, enqueue, and handler completion in extensions/whatsapp/src/inbound/monitor.ts. I did not run a live WhatsApp crash/restart reproduction.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Summary: The fix direction is useful, but missing real WhatsApp proof plus a public SDK contract blocker keep this from being quality-ready.

Rank-up moves:

  • Add redacted live WhatsApp proof for retryable failure, replay, completion, and delayed read receipt behavior.
  • Update the Plugin SDK API baseline and docs, or keep the durable journal helper private to WhatsApp.
  • Get maintainer acceptance for retaining serialized inbound WhatsApp payloads in plugin state.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

Real behavior proof
Needs real behavior proof before merge: The PR body supplies tests/build/check output only and explicitly says no live WhatsApp device roundtrip was tested; add redacted screenshots, video, terminal output, copied live output, linked artifacts, or logs that show the after-fix WhatsApp path, then update the PR body to trigger re-review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • Merging as-is exposes a new public channel-message SDK helper and types without the required API baseline/docs alignment, creating plugin contract drift and release-check risk.
  • The WhatsApp inbound dedupe, replay, completion, and read-receipt ordering changes can affect message delivery, but the PR body only proves local tests and explicitly lacks a live WhatsApp roundtrip.
  • Serialized inbound WhatsApp payloads would now be retained in plugin state for retry, increasing local sensitive data at rest and needing maintainer acceptance of that boundary.
  • The protected maintainer label means this should stay on a human review path rather than cleanup-close or automated merge handling.

Maintainer options:

  1. Repair SDK contract and proof first (recommended)
    Update the SDK baseline/docs or keep the helper private, then add redacted live WhatsApp proof for durable retry, replay, completion, and delayed read receipts before merge.
  2. Accept the public retention boundary
    Maintainers can explicitly accept the new public SDK helper and plugin-state payload retention, but should still record the contract and proof expectations before landing.
  3. Keep the journal WhatsApp-local
    If this durable helper is not intended as a reusable Plugin SDK contract, move it behind the WhatsApp plugin boundary and avoid expanding the public SDK surface in this PR.

Next step before merge
Missing real WhatsApp proof plus public SDK and data-retention decisions make this a maintainer review path rather than an automated repair candidate.

Security
Needs attention: The diff adds no new dependency or code-execution surface, but it intentionally persists serialized WhatsApp inbound payloads in plugin state and needs data-retention acceptance.

Review findings

  • [P1] Update the SDK contract artifacts for this export — src/plugin-sdk/channel-message.ts:43
Review details

Best possible solution:

Land a maintainer-approved durable WhatsApp receive path that either keeps the journal private or fully updates the public SDK contract, with focused regression tests and redacted live WhatsApp proof for retry, replay, completion, and delayed read receipts.

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

Yes from source inspection: current main marks WhatsApp messages read before enrichment, dedupe, enqueue, and handler completion in extensions/whatsapp/src/inbound/monitor.ts. I did not run a live WhatsApp crash/restart reproduction.

Is this the best way to solve the issue?

Unclear as written: plugin-state durability is a strong fix direction, but the public SDK addition needs contract alignment or should remain WhatsApp-local, and the retention boundary needs maintainer acceptance.

Label justifications:

  • P1: The PR targets WhatsApp inbound message loss and read-receipt ordering, a broken channel workflow with real user impact.
  • merge-risk: 🚨 compatibility: The diff adds a public Plugin SDK helper and types without the required public contract artifacts in the branch.
  • merge-risk: 🚨 message-delivery: The diff changes WhatsApp inbound dedupe, replay, completion, and read-receipt timing, so a mistake could lose, duplicate, or suppress messages.
  • merge-risk: 🚨 security-boundary: The diff persists serialized WhatsApp inbound payloads in plugin state, increasing sensitive local data retained at rest.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦪 silver shellfish, and The fix direction is useful, but missing real WhatsApp proof plus a public SDK contract blocker keep this from being quality-ready.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies tests/build/check output only and explicitly says no live WhatsApp device roundtrip was tested; add redacted screenshots, video, terminal output, copied live output, linked artifacts, or logs that show the after-fix WhatsApp path, then update the PR body to trigger re-review or ask a maintainer for @clawsweeper re-review.

Full review comments:

  • [P1] Update the SDK contract artifacts for this export — src/plugin-sdk/channel-message.ts:43
    This adds createDurableInboundReceiveJournal to the public openclaw/plugin-sdk/channel-message surface, but the tracked SDK API baseline and docs are not updated. The SDK guide requires public subpath changes to keep docs and API/export checks aligned, so either regenerate/document the public contract or keep this helper private to WhatsApp.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.86

Security concerns:

  • [low] Accept inbound payload retention in plugin state — extensions/whatsapp/src/inbound/durable-receive.ts:18
    The new durable receive path stores serialized WhatsApp inbound message payloads for retry, bounded by plugin-state TTL and max-entry settings; this is likely acceptable inside trusted local plugin state, but it is a concrete sensitive-data-at-rest change.
    Confidence: 0.82

What I checked:

  • Current main source-reproduces the ack-before-handler bug: Current main calls maybeMarkInboundAsRead(inbound) before stale-append filtering, enrichment, dedupe claim, activity recording, and enqueueInboundMessage, so a crash after the read receipt can lose the inbound message from WhatsApp's side. (extensions/whatsapp/src/inbound/monitor.ts:841, f7c05dcc9e51)
  • PR changes WhatsApp delivery ordering: The PR moves completion and read receipts into finalizeInboundDelivery, releases durable state on retryable errors, and replays pending durable inbound records during attach. (extensions/whatsapp/src/inbound/monitor.ts:263, 1284217a9846)
  • PR exposes a new public SDK helper: The head exports createDurableInboundReceiveJournal and related DurableInboundReceive* types from the public plugin-sdk/channel-message subpath. (src/plugin-sdk/channel-message.ts:43, 1284217a9846)
  • SDK boundary policy requires contract alignment: The scoped SDK guide says adding or changing a public subpath must keep docs, entrypoint metadata, package exports, API baseline, and export checks aligned. (src/plugin-sdk/AGENTS.md:81, f7c05dcc9e51)
  • API baseline drift is a checked failure mode: The baseline generator exits on hash drift and instructs maintainers to run pnpm plugin-sdk:api:gen for intentional Plugin SDK surface changes; this PR does not include an updated tracked baseline hash. (scripts/generate-plugin-sdk-api-baseline.ts:23, f7c05dcc9e51)
  • Plugin state retention boundary is real: The public runtime docs state keyed stores survive restarts, are isolated by plugin id, and store JSON values under 64KB with namespace limits, which matches the PR's proposed durable WhatsApp payload storage boundary. Public docs: docs/plugins/sdk-runtime.md. (docs/plugins/sdk-runtime.md:527, f7c05dcc9e51)

Likely related people:

  • steipete: Recent main history shows steipete on WhatsApp monitor changes and on the channel-message SDK lifecycle surface that this PR extends. (role: recent area contributor and SDK feature owner; confidence: high; commits: 53d007bc878c, c9a0f03dd734, 8bfabd6bb139; files: extensions/whatsapp/src/inbound/monitor.ts, src/plugin-sdk/channel-message.ts, src/channels/message/index.ts)
  • mcaxtr: Recent merged WhatsApp monitor history includes debounce close-drain and reply quoting work in the same inbound monitor path. (role: recent WhatsApp monitor contributor; confidence: medium; commits: 81a3de1d9d51, f5f0235bb18a; files: extensions/whatsapp/src/inbound/monitor.ts)
  • vincentkoc: History for the WhatsApp inbound dedupe path includes explicit inbound retry work, which is adjacent to this PR's durable retry and release behavior. (role: adjacent inbound retry contributor; confidence: medium; commits: d70e6b13d7e1; files: extensions/whatsapp/src/inbound/dedupe.ts, extensions/whatsapp/src/inbound/monitor.ts)
  • scoootscooob: The current WhatsApp plugin layout was moved into extensions/whatsapp, which is relevant background ownership for plugin-boundary changes. (role: WhatsApp extension migration contributor; confidence: low; commits: 16505718e827; files: extensions/whatsapp/src/inbound/monitor.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against f7c05dcc9e51.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@steipete
steipete force-pushed the fix/whatsapp-durable-inbound-plugin-state branch from bb67ad5 to 1284217 Compare May 23, 2026 11:12
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 23, 2026
@steipete
steipete merged commit b47bace into main May 23, 2026
99 checks passed
@steipete
steipete deleted the fix/whatsapp-durable-inbound-plugin-state branch May 23, 2026 13:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(whatsapp): persist inbound delivery in plugin state

* fix(whatsapp): type durable inbound payload

* fix(channels): close durable receive insert race

* fix(whatsapp): skip owned durable pending duplicates
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
* fix(whatsapp): persist inbound delivery in plugin state

* fix(whatsapp): type durable inbound payload

* fix(channels): close durable receive insert race

* fix(whatsapp): skip owned durable pending duplicates
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(whatsapp): persist inbound delivery in plugin state

* fix(whatsapp): type durable inbound payload

* fix(channels): close durable receive insert race

* fix(whatsapp): skip owned durable pending duplicates
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix(whatsapp): persist inbound delivery in plugin state

* fix(whatsapp): type durable inbound payload

* fix(channels): close durable receive insert race

* fix(whatsapp): skip owned durable pending duplicates
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant