Skip to content

refactor(channels): share approval reaction settlement - #140645

Merged
steipete merged 4 commits into
mainfrom
steipete/dedup-channels-approvals-0906
Sep 7, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/dedup-channels-approvals-0906

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #131004. Related: #130969.

What Problem This Solves

WhatsApp approval reactions were silently consumed when Gateway resolution failed transiently, so the operator's click never reached durable ingress. The iMessage, Signal, and WhatsApp plugins also duplicated explicit-approver admission, persisted target validation, and terminal settlement.

Why This Change Was Made

A stateless settleApprovalReaction operation and base-record decoder now live behind the existing openclaw/plugin-sdk/approval-reaction-runtime seam. Plugins retain transport identity, Signal route/target-author checks, iMessage GUID/poll cleanup, diagnostics, and replay ownership. Authorizer calls retain their receivers. Terminal results—including concurrent losing clicks—retire bindings; nonterminal failures retain them and propagate to the existing replay owner. The Gateway remains the first-answer authority.

This incorporates the WhatsApp durable-admission repair from #130969 by @wangmiao0668000666: a failed fast path preserves batch siblings, and the drain resolves reactions before ordinary message normalization. No sibling PR was modified.

The existing reaction seam is private-local and consumes no public SDK slots. No public export was removed or renamed. Store namespaces, versions, expiry, and persistence semantics are unchanged. Production delta: -45 lines; tests: +167. The assertion baseline shrinks exactly as required after deleting duplicate decoders: iMessage 3→2, WhatsApp 1→0. No baseline or budget increases.

User Impact

WhatsApp approval reactions survive transient Gateway loss and replay after recovery. Existing iMessage and Signal authorization, canonical-winner reporting, and polling behavior remain intact. There are no new settings or UI appearance changes.

Evidence

Fresh validation is for cd1f7612c7dd16f00671f85911736a610752ea2d, rebased patch-identically onto main containing #140974, #140997, and #141148.

  • Focused approval and WhatsApp ingress suites: 44 files, 512 tests passed. Concrete approval test files were passed to node scripts/run-vitest.mjs, including extensions/whatsapp/src/monitor-inbox.delivery-and-dedupe.test.ts.
  • Boundary proof uses real SQLite ingress queues and settlement paths with a mocked Gateway. It covers transient fast-path failure, batch sibling preservation, claim release/replay, completion tombstones, concurrent resolution, and terminal-card-update failures. The original WhatsApp regression previously failed for the intended swallowed-Gateway-503 defect.
  • node scripts/check-changed.mjs passed ratchets, formatting, SDK checks, core/plugin production and test types, declaration/deprecation checks, all three dead-export scans (zero entries), and core lint. Local plugin lint reaches the documented nested-worktree Declaration input escapes checkout exception for ancestor punycode/package.json; exact-head hosted lint, typechecks, and extension package-boundary checks passed.
  • The SDK surface check passes against current main: 4,447 public exports and 2,631 callables; this PR changes no budget.
  • Fresh isolated Codex branch review: zero actionable P0–P2 findings.

pnpm build passed in 6m28s, and pnpm plugin-sdk:surface:check passed. Isolated iMessage, Signal, and WhatsApp startup profiles passed with zero failures/timeouts (peak RSS 99.16, 98.83, and 98.28 MiB). Exact-head hosted CI passed: https://github.com/openclaw/openclaw/actions/runs/34119401075. The required openclaw/ci-gate is green, and native prepare completed on the unchanged reviewed head. The earlier CI hold was caused by unrelated tests whose fixes are now in the base.

Live transport proof is unavailable. The SQLite/mock-Gateway harness is the available boundary proof; it is not a live channel test.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: imessage Channel integration: imessage channel: signal Channel integration: signal channel: whatsapp-web Channel integration: whatsapp-web size: L maintainer Maintainer-authored PR labels Sep 7, 2026
@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. 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 Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 8:06 AM ET / 12:06 UTC.

ClawSweeper review

What this changes

Shares approval-reaction authorization and cleanup across iMessage, Signal, and WhatsApp, and routes transient WhatsApp resolution failures through durable replay.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and v2026.9.2 still consume failed WhatsApp approval reactions before durable admission. No actionable introduced defect was found. The earlier assertion-baseline finding is resolved, and the previous draft/CI hold has been lifted.

Priority: P1
Reviewed head: cd1f7612c7dd16f00671f85911736a610752ea2d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with useful regression coverage and no actionable introduced findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored PR. Its reported SQLite ingress/mock-Gateway coverage exercises the changed admission and settlement paths; startup checks are supplemental, and live transport behavior is not claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored PR. Its reported SQLite ingress/mock-Gateway coverage exercises the changed admission and settlement paths; startup checks are supplemental, and live transport behavior is not claimed.
Evidence reviewed 9 items Introduced changes verified: Read the complete merge-base-to-head diff across all ten introduced paths. The supplied verified test-merge comparison identifies the same paths; unrelated base changes were excluded.
Current main still has the reported failure: The reaction resolver catches nonterminal Gateway errors and returns true; the inbound consumer then continues before durable admission. The PR therefore addresses remaining behavior.
Latest release comparison: The supplied latest release also returns true after non-NotFound resolution failures; this is not an already-shipped fix.
Findings None None.
Security None None.

How this fits together

Channel plugins translate operator reactions into approval decisions sent to the Gateway. Shared settlement handles authorization and terminal cleanup, while WhatsApp’s durable ingress retains failed reactions for another attempt.

flowchart TD
  A[Operator reaction] --> B[Plugin identity and target checks]
  B --> C[Explicit approver authorization]
  C --> D[Gateway approval resolution]
  D -->|Terminal result| E[Clear reaction binding]
  D -->|Transient WhatsApp failure| F[Durable ingress queue]
  F -->|Replay with current config| B
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -45, Tests +167, Docs +10, Other -1. Total +131 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 186 231 -45
Tests 3 168 1 +167
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 2 -1
Total 10 365 234 +131

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #131004
Summary: This PR is a candidate fix for the canonical WhatsApp reaction-loss issue, with additional shared settlement work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Use shared stateless settlement while keeping transport identity checks local and failed WhatsApp reactions under the existing durable replay owner.

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

Yes, from source: a nonterminal Gateway error makes the current WhatsApp handler return handled, causing intake to skip durable admission. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. The patch repairs both admission and replay at their existing owners, preserves transport-specific checks, and removes duplicated settlement without adding a competing public API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0f8932785cca.

Labels

Label justifications:

  • P1: The repair addresses silently lost operator approval reactions during Gateway failures, leaving pending work without the intended decision.
  • 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: The external-contributor proof gate does not apply to this maintainer-authored PR. Its reported SQLite ingress/mock-Gateway coverage exercises the changed admission and settlement paths; startup checks are supplemental, and live transport behavior is not claimed.

Evidence

What I checked:

  • Introduced changes verified: Read the complete merge-base-to-head diff across all ten introduced paths. The supplied verified test-merge comparison identifies the same paths; unrelated base changes were excluded. (cd1f7612c7dd)
  • Current main still has the reported failure: The reaction resolver catches nonterminal Gateway errors and returns true; the inbound consumer then continues before durable admission. The PR therefore addresses remaining behavior. (extensions/whatsapp/src/approval-reactions.ts, 0f8932785cca)
  • Latest release comparison: The supplied latest release also returns true after non-NotFound resolution failures; this is not an already-shipped fix. (extensions/whatsapp/src/approval-reactions.ts, 3928bad9badf)
  • Settlement preserves admission and terminal behavior: The helper rejects empty approver sets and unauthorized actors before loading the resolver, clears bindings for terminal results and not-found errors, and propagates other failures. Transport wrappers retain their authorizer receivers. (src/plugin-sdk/approval-reaction-runtime.ts:113, cd1f7612c7dd)
  • Replay uses the existing owner: The fast path catches failures without abandoning batch siblings. Durable dispatch resolves reactions before normalization and reloads configuration on each attempt; actor and target checks run again rather than persisting an authorization verdict. (extensions/whatsapp/src/inbound/message-delivery.ts:430, cd1f7612c7dd)
  • Private SDK seam and preserved storage format: The reaction runtime is listed as private-local and excluded from the typed public API. Existing exports, store namespaces, payload versions, and retention settings are unchanged; the decoder extraction preserves the stored record fields. (scripts/lib/plugin-sdk-private-local-only-subpaths.json:15, cd1f7612c7dd)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • wangmiao0668000666: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-07T03:44:53.225Z sha 95e78fc :: blocked before merge. :: none
  • reviewed 2026-09-07T04:07:11.278Z sha 7d8b784 :: blocked before merge. :: none
  • reviewed 2026-09-07T04:34:03.168Z sha 4aa0134 :: blocked before merge. :: none
  • reviewed 2026-09-07T04:46:31.323Z sha 3e548fa :: blocked before merge. :: none
  • reviewed 2026-09-07T04:59:44.950Z sha 3e548fa :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T05:18:09.852Z sha 39ce430 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T05:28:57.434Z sha 39ce430 :: needs changes before merge. :: none
  • reviewed 2026-09-07T06:07:21.666Z sha 39ce430 :: needs changes before merge. :: none

@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906 branch from e20e321 to 95e78fc Compare September 7, 2026 03:38
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 7, 2026
@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906 branch from 4aa0134 to 3e548fa Compare September 7, 2026 04:40
steipete and others added 4 commits September 7, 2026 04:40
Keep transport identity and replay ownership local while sharing explicit
approver admission, persisted record validation, and terminal cleanup.
WhatsApp now admits transient resolver failures into durable ingress.

Shrink the assertion baseline exactly (iMessage 3 to 2, WhatsApp 1 to 0)
as required ratchet maintenance after deleting duplicate decoders.

Proof: node scripts/run-vitest.mjs across 47 approval/ingress files
(530 tests); 88 decoder tests passed after removing the copied assertion.

Co-authored-by: wangmiao0668000666 <[email protected]>
Preserve concurrent-click ordering with the existing deferred helper supported
by the core test TypeScript library. Do not widen compiler libraries.

Proof: node scripts/run-vitest.mjs src/plugin-sdk/approval-reaction-runtime.test.ts
(21 passed); fresh isolated review has no actionable findings.
Preserve the ingress replay sequence with the existing SDK deferred helper
supported by the extension test TypeScript library.

Proof: monitor-inbox.delivery-and-dedupe.test.ts (18 passed), full extension
test typecheck passed, and fresh isolated review found no actionable issues.
Call each transport authorizer through its owner when sharing reaction
settlement, and keep the iMessage settlement result distinct from log text.

Proof: four direct reaction suites (88 tests); diff check and fresh isolated
review passed. Hosted lint exposed the three unbound references and shadow.
@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906 branch from 39ce430 to cd1f761 Compare September 7, 2026 11:51
@steipete
steipete marked this pull request as ready for review September 7, 2026 11:58
@steipete
steipete merged commit 32c8015 into main Sep 7, 2026
455 of 457 checks passed
@steipete
steipete deleted the steipete/dedup-channels-approvals-0906 branch September 7, 2026 12:15
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 7, 2026
* commit 'b07b7d8bd1293c4e70ece7281b9cb8422318ae5a': (30 commits)
  fix(ui): keep reopened select menus visible (#141047)
  test(ui): fix dashboard gallery client fixtures (#141203)
  refactor(links): remove unused understanding results (#141200)
  refactor(plugins): share manifest contribution projection (#141193)
  refactor(logging): share portable redaction pattern mechanics (#140742)
  chore(ui): refresh control ui locales (#141208)
  refactor(minimax): reuse generated video asset downloader (#141094)
  fix(test): await Telegram loopback prompt reception (#141204)
  refactor(acp): remove unused in-memory event ledger (#141145)
  improve(models): reduce overhead in catalog discovery (#141154)
  refactor(channels): share approval reaction settlement (#140645)
  chore(i18n): refresh native locales (#141089)
  refactor: share one-shot tickets and WebSocket helpers across desktop, node, and browser streams (#141185)
  refactor(google-meet): share browser open and recovery setup (#140972)
  refactor(plugins): share npm version queries (#141166)
  refactor(http): share bounded response byte consumption (#140654)
  refactor(whatsapp): share prompt selection (#141195)
  fix: bound temporary storage for terminal upload batches (#141116)
  perf(markdown): reuse image parser configuration (#141126)
  fix(policy): align tool requirements with core vocabulary (#140628)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
* refactor(channels): share approval reaction settlement

Keep transport identity and replay ownership local while sharing explicit
approver admission, persisted record validation, and terminal cleanup.
WhatsApp now admits transient resolver failures into durable ingress.

Shrink the assertion baseline exactly (iMessage 3 to 2, WhatsApp 1 to 0)
as required ratchet maintenance after deleting duplicate decoders.

Proof: node scripts/run-vitest.mjs across 47 approval/ingress files
(530 tests); 88 decoder tests passed after removing the copied assertion.

Co-authored-by: wangmiao0668000666 <[email protected]>

* test(channels): use shared deferred in approval settlement coverage

Preserve concurrent-click ordering with the existing deferred helper supported
by the core test TypeScript library. Do not widen compiler libraries.

Proof: node scripts/run-vitest.mjs src/plugin-sdk/approval-reaction-runtime.test.ts
(21 passed); fresh isolated review has no actionable findings.

* test(whatsapp): use shared deferred for approval replay latches

Preserve the ingress replay sequence with the existing SDK deferred helper
supported by the extension test TypeScript library.

Proof: monitor-inbox.delivery-and-dedupe.test.ts (18 passed), full extension
test typecheck passed, and fresh isolated review found no actionable issues.

* fix(channels): preserve approval authorizer receivers

Call each transport authorizer through its owner when sharing reaction
settlement, and keep the iMessage settlement result distinct from log text.

Proof: four direct reaction suites (88 tests); diff check and fresh isolated
review passed. Hosted lint exposed the three unbound references and shadow.

---------

Co-authored-by: wangmiao0668000666 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage channel: signal Channel integration: signal channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

[Bug]: WhatsApp approval reactions are silently dropped on transient Gateway failures

1 participant