Skip to content

refactor(channels): mattermost event-plan builder and whatsapp durable admission - #114763

Merged
steipete merged 5 commits into
mainfrom
codex/w2-channel-a
Jul 27, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/w2-channel-a

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Mattermost event handling repeated the same routing and reply-planning work across handlers, while WhatsApp durable admission reconstructed facts after persistence instead of carrying the receive-time decision through the queue.

Why This Change Was Made

This adds one shared Mattermost event-plan builder and routes WhatsApp through the shared durable-admission integration. Prepared routing, context, lifecycle, and admission facts are carried forward rather than rediscovered, while existing retry, dedupe, thread, typing, and delivery contracts remain intact.

AI-assisted; reviewed with the repository autoreview workflow.

User Impact

No intended visible behavior change. Mattermost events follow the same routing and reply semantics through less duplicated code, and WhatsApp durable delivery preserves receive-time admission decisions consistently across persistence and replay.

Evidence

  • 144 focused Mattermost tests passed.
  • 22 durable ingress/admission tests passed.
  • Six WhatsApp dedupe/append regression tests passed.
  • Blacksmith Testbox branch-wide changed gate passed during preparation.
  • Fresh branch autoreview against current origin/main: clean, no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost channel: whatsapp-web Channel integration: whatsapp-web size: L maintainer Maintainer-authored PR labels Jul 27, 2026
@steipete steipete self-assigned this Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 21:54
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 6:21 PM ET / 22:21 UTC.

ClawSweeper review

What this changes

The branch centralizes Mattermost monitor-event planning and carries WhatsApp receive-time admission decisions through its durable queue instead of reconstructing them during replay.

Merge readiness

⛔ Blocked until real behavior proof is added - 4 items remain

Keep open for protected-label maintainer review. The refactor changes Mattermost routing/reply planning and WhatsApp durable-admission handoff, but the PR body still has only test and changed-gate claims rather than after-fix runtime evidence for delivery and replay behavior.

Priority: P3
Reviewed head: ffedd5ab1a2fd7165e76d78eac90e57e895721cc

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The refactor has focused automated-validation claims, but it is not merge-ready without real channel delivery and durable-replay proof.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The body reports tests and a changed gate, but no after-fix real Mattermost event/reply or WhatsApp durable-replay transcript, recording, terminal output, or redacted runtime log; add redacted evidence to the PR body, then a fresh review should trigger automatically or a maintainer can request one. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The body reports tests and a changed gate, but no after-fix real Mattermost event/reply or WhatsApp durable-replay transcript, recording, terminal output, or redacted runtime log; add redacted evidence to the PR body, then a fresh review should trigger automatically or a maintainer can request one. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Changed delivery boundary: The proposed branch introduces a shared Mattermost event-plan builder consumed by post, reaction, interaction, model-picker, and turn paths, consolidating route, thread, context, typing, and delivery facts.
Durable-admission change: The WhatsApp refactor changes durable ingress from enqueue-time reconstruction to a typed receive-time admission object that is passed into dispatch and used to locate prepared inbound state.
Existing review continuity: The prior completed ClawSweeper review found no line-level defect but required real behavior proof. The supplied PR body has not added a runtime transcript, recording, redacted log, or durable-replay artifact after the later WhatsApp identity commits.
Findings None None.
Security None None.

How this fits together

Mattermost inbound posts, reactions, and interactive callbacks are normalized into a shared event plan before the plugin routes an agent turn and delivers a reply. WhatsApp receives messages, records admission facts in durable ingress, then drains and replays the accepted work into the channel monitor.

flowchart LR
  A[Mattermost events] --> B[Shared event plan]
  B --> C[Route and thread context]
  C --> D[Agent turn and reply delivery]
  E[WhatsApp inbound message] --> F[Durable admission]
  F --> G[Persisted queue replay]
  G --> H[Channel monitor delivery]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The body reports tests and a changed gate, but no after-fix real Mattermost event/reply or WhatsApp durable-replay transcript, recording, terminal output, or redacted runtime log; add redacted evidence to the PR body, then a fresh review should trigger automatically or a maintainer can request one. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - A receive-time decision now crosses persistence and replay; without a redacted live durable-replay trace, a mismatch could silently change dedupe, admission, or reply targeting after restart.
  • Resolve merge risk (P1) - Mattermost now shares routing and reply facts across several event consumers; focused tests do not demonstrate an after-fix event-to-reply path through a real Mattermost setup.
  • Complete next step (P2) - A protected maintainer label and missing contributor runtime proof require human review; there is no narrow code defect that an automated repair lane can safely prove or fix.
Agent review details

Security

None.

PR surface

Source -170, Tests +27. Total -143 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 11 339 509 -170
Tests 1 48 21 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 387 530 -143

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Add end-to-end channel evidence (recommended)
    Provide redacted after-fix Mattermost event-to-reply output and WhatsApp durable enqueue/replay output that shows the preserved route, target, and admission result.
  2. Pause pending manual channel verification
    Do not merge until an owner accepts the remaining delivery and persisted-admission risk without runtime proof.

Technical review

Best possible solution:

Keep one canonical Mattermost planning path and one WhatsApp receive-time admission path, then attach redacted after-fix evidence showing a Mattermost event reply and a WhatsApp durable replay preserve the intended target, dedupe, and delivery outcome.

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

Not applicable: this PR reports a behavior-preserving refactor rather than a currently reproducible user bug; the supplied evidence names focused tests but no failing baseline scenario.

Is this the best way to solve the issue?

Unclear: centralizing facts is consistent with the repository's prepared-facts guidance, but the available review evidence does not establish that the shared path preserves every real Mattermost and WhatsApp delivery contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0d32f85155ff.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P3: This is presented as a behavior-preserving channel refactor, with no confirmed user-facing regression in the supplied evidence.
  • merge-risk: 🚨 message-delivery: Shared Mattermost planning now determines reply delivery facts across posts, reactions, callbacks, and model-picker interactions.
  • merge-risk: 🚨 session-state: WhatsApp admission and prepared inbound identity now traverse durable persistence and replay before monitor processing.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body reports tests and a changed gate, but no after-fix real Mattermost event/reply or WhatsApp durable-replay transcript, recording, terminal output, or redacted runtime log; add redacted evidence to the PR body, then a fresh review should trigger automatically or a maintainer can request one. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Changed delivery boundary: The proposed branch introduces a shared Mattermost event-plan builder consumed by post, reaction, interaction, model-picker, and turn paths, consolidating route, thread, context, typing, and delivery facts. (extensions/mattermost/src/mattermost/monitor-event-plan.ts:1, ffedd5ab1a2f)
  • Durable-admission change: The WhatsApp refactor changes durable ingress from enqueue-time reconstruction to a typed receive-time admission object that is passed into dispatch and used to locate prepared inbound state. (extensions/whatsapp/src/inbound/durable-receive.ts:37, ffedd5ab1a2f)
  • Existing review continuity: The prior completed ClawSweeper review found no line-level defect but required real behavior proof. The supplied PR body has not added a runtime transcript, recording, redacted log, or durable-replay artifact after the later WhatsApp identity commits. (4243f12d1f59)
  • Repository policy applied: The supplied root policy treats channel delivery and persisted admission/session paths as merge-sensitive and requires real behavior evidence beyond tests for external PRs. (AGENTS.md:1, 0d32f85155ff)

Likely related people:

  • steipete: The supplied history shows this person authored the Mattermost consolidation, the shared WhatsApp durable-admission change, and the follow-up receive-time identity repair; no accessible current-main feature-history trail was available to route more broadly. (role: current change author; confidence: low; commits: 1d70a278622c, 694c1a4c918b, 069251935070; files: extensions/mattermost/src/mattermost/monitor-event-plan.ts, extensions/whatsapp/src/inbound/durable-receive.ts, extensions/whatsapp/src/inbound/monitor.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted Mattermost event-to-reply runtime transcript or recording.
  • Add redacted WhatsApp durable enqueue/replay output demonstrating preserved admission and delivery targeting.

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 (1 earlier review cycle)
  • reviewed 2026-07-27T22:05:15.557Z sha 4243f12 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Live replay evidence for exact PR head ffedd5ab1a2fd7165e76d78eac90e57e895721cc.

Environment: Blacksmith Testbox tbx_01kyjw6xbq7na4t9ev4dpqt5qh (Actions run 30311991372). I started a session-owned dev Gateway with a fresh OPENCLAW_STATE_DIR under /tmp, a dynamically reserved loopback port (34303 in the final run), and --allow-unconfigured. /readyz returned 200 before the replay and again after both scenarios. No live Mattermost or WhatsApp credentials were used.

Command:

pnpm test extensions/mattermost/src/mattermost/channel-a-live-evidence.test.ts extensions/whatsapp/src/inbound/channel-a-live-evidence.test.ts -- --reporter=verbose

Mattermost replayed through the raw ingress monitor and real interaction callback pipeline:

  • a posted WebSocket envelope for post post-live in chan-live, body recorded normal post
  • a signed button callback for approve on post-button
  • a signed model-picker callback selecting openai/gpt-5.6-luna on post-picker
  • a reaction_added envelope for :eyes: on post-live

The post, button, and model-picker paths produced the same prepared routing/context facts:

[mattermost-trace] normal-post  route=agent:main:mattermost:default:channel:chan-live from=mattermost:channel:chan-live to=channel:chan-live session=agent:main:mattermost:default:channel:chan-live chatType=channel sid=post-live
[mattermost-trace] button-click route=agent:main:mattermost:default:channel:chan-live from=mattermost:channel:chan-live to=channel:chan-live session=agent:main:mattermost:default:channel:chan-live chatType=channel sid=interaction:post-button:approve
[mattermost-trace] model-picker route=agent:main:mattermost:default:channel:chan-live from=mattermost:channel:chan-live to=channel:chan-live session=agent:main:mattermost:default:channel:chan-live chatType=channel sid=interaction:post-picker:select:openai/gpt-5.6-luna
[mattermost-trace] reaction system-event route=agent:main:mattermost:default:channel:chan-live text="Mattermost reaction added: :eyes: by @alice on post post-live in channel chan-live"

WhatsApp replayed real serialized Baileys envelopes through createWhatsAppIngressMonitor().admit() and the SQLite-backed shared ingress queue. The envelope identities were wamid.channel-a.atomic and wamid.channel-a.restart for [email protected]; payload text was recorded atomic replay / recorded restart replay. Both carried upsertType=append, skipStaleAppend=true, skipRecentOutboundEcho=true, and explicit receive order.

[whatsapp-trace] atomic-admit accepted=accepted duplicate=pending sameEventId=true
[whatsapp-trace] replay-dispatch id=wamid.channel-a.atomic upsertType=append skipStaleAppend=true skipRecentOutboundEcho=true receiveOrder=1
[whatsapp-trace] completed-dedupe result=completed dispatchCount=1
[whatsapp-trace] before-monitor-restart admission=accepted pending=[{id:wamid.channel-a.restart,attempts:1,upsertType:append,skipStaleAppend:true,skipRecentOutboundEcho:true,receiveOrder:2}]
[whatsapp-trace] after-monitor-restart replayed={id:wamid.channel-a.restart,upsertType:append,skipStaleAppend:true,skipRecentOutboundEcho:true,receiveOrder:2,text:"recorded restart replay"} duplicate=completed dispatchCount=1

Result: 2 scenario tests passed in 2 Vitest shards; Testbox wrapper exit code 0. The harness files were temporary/uncommitted evidence fixtures (SHA-256: Mattermost 55a10f01a448eaf10673bd803ea2ebea7e4d87175c5c1261afd36087294385e4, WhatsApp 47c6f9e250d1f0dea35d37defd91465d7618e8ad78250ee68479e64cc52649d7).

@steipete
steipete merged commit 4301ca9 into main Jul 27, 2026
112 of 114 checks passed
@steipete
steipete deleted the codex/w2-channel-a branch July 27, 2026 23:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
…e admission (openclaw#114763)

* refactor(mattermost): consolidate event planning

* refactor(whatsapp): use shared durable admission

* refactor(channels): keep ingress helpers private

* fix(whatsapp): preserve receive-time ingress identity

* style(whatsapp): format durable receive helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost channel: whatsapp-web Channel integration: whatsapp-web maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L 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