Skip to content

fix(mattermost): wake agents from edited mentions - #97316

Closed
yungchentang wants to merge 7 commits into
openclaw:mainfrom
yungchentang:codex/71930-mattermost-post-edited-wake
Closed

yungchentang wants to merge 7 commits into
openclaw:mainfrom
yungchentang:codex/71930-mattermost-post-edited-wake

Conversation

@yungchentang

@yungchentang yungchentang commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #71930

AI-assisted: yes. I understand the change and reviewed the source, dependency contracts, and validation below.

What Problem This Solves

Fixes an issue where Mattermost users who edited an existing message to add an @openclaw mention would not wake the agent because post_edited WebSocket events were ignored.

Why This Change Was Made

Mattermost edit events now enter the existing inbound post path. Transport-facing message identity stays the canonical Mattermost post id, while replay protection derives edit-specific keys from Mattermost edit metadata so the original post cannot suppress a later edited wake.

Edited events bypass text batching, but the zero-delay path remains FIFO-serialized with ordinary posts from the same sender, channel, and thread. Pending ordinary posts flush first, then each edit is evaluated independently. Mention snapshots require an observed false-to-true transition and fail closed when the prior state is unknown or the sender changes. Bot and system posts are filtered before enqueueing.

User Impact

Users can add an @openclaw mention by editing an existing Mattermost message. Immediate posted and post_edited frames retain their order and wake exactly once. Formatting-only, attachment-only, replayed, other-bot, and unknown-prior-state edits do not wake the agent.

Evidence

  • An isolated Linux Node 24 container checked out the exact PR head and passed all 5 focused Mattermost files: 43 tests total (14 WebSocket, 10 existing routing/session, 5 existing streaming, 8 edited-mention, and 6 edited-debounce/ordering cases).
  • Public CI on the current head passes production and test types, dependency checks, lint/format, max-lines ratchet, and build.
  • The two remaining public CI failures are unrelated current-main drift: the package-acceptance workflow expectation for allow_frozen_target_scenario_omissions, and Android Japanese localization drift. This PR touches neither surface.
  • The 15 pre-existing inbound cases were preserved byte-for-byte when the test file was split to satisfy the max-lines gate.
  • oxfmt --check passed for all touched TypeScript files.
  • git diff --check passed.
  • Official Mattermost source lists both posted and post_edited, exposes edit_at/update_at on posts, and emits the edited-post WebSocket event.

Known gap: I do not have a live Mattermost tenant credential in this environment, so I cannot provide a real-provider transcript. Validation therefore uses the official Mattermost event contract plus isolated source-level WebSocket, replay, debounce, ordering, and inbound-context regression coverage.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: M labels Jun 27, 2026
@clawsweeper

clawsweeper Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask.

Close as stalled and unproven: the branch predates Mattermost’s durable-ingress rewrite, remains dirty, and still lacks both the required ingress adaptation and real-provider evidence.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #71930
Summary: This PR was a candidate fix for the canonical edited-mention report, but its branch is no longer a viable implementation against current main.

Members:

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

So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again.

Review details

Best possible solution:

If the linked issue still needs a fix, start a fresh current-main PR that extends the durable ingress event classifier and edit-specific identity, then prove one edited mention produces one durable agent wake without regressing normal posts.

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

Yes, from source: inject a Mattermost post_edited frame containing a bot mention; current WebSocket and durable-ingress guards reject it before the dispatcher. This read-only review did not run the scenario.

Is this the best way to solve the issue?

No. The branch changes the pre-rewrite WebSocket and replay path, while current main makes durable ingress the authoritative admission and replay owner.

Security review:

Security review cleared: The diff changes Mattermost event handling and tests only; no dependency, workflow, secret, or privilege boundary concern was found.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • steipete: History identifies the Mattermost durable-ingress introduction and subsequent ingress refactors under this area. (role: durable-ingress feature owner; confidence: high; commits: d4d23fe95454, c163daa4ed02, bde6b166c0e5; files: extensions/mattermost/src/mattermost/monitor-ingress.ts, extensions/mattermost/src/mattermost/monitor.ts)
  • Josh Avant: Current-main blame attributes the active websocket and ingress boundary to this recent area change. (role: recent adjacent contributor; confidence: medium; commits: 49275b8f4b46; files: extensions/mattermost/src/mattermost/monitor-websocket.ts, extensions/mattermost/src/mattermost/monitor-ingress.ts)

Codex review notes: model internal, reasoning high; reviewed against 8a3964f87cd2.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 Jun 27, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 12, 2026
@yungchentang
yungchentang force-pushed the codex/71930-mattermost-post-edited-wake branch from 56dccb2 to 62cddba Compare July 15, 2026 13:39
@yungchentang
yungchentang force-pushed the codex/71930-mattermost-post-edited-wake branch 2 times, most recently from 185e3bc to 85398f1 Compare July 15, 2026 16:07
@openclaw-barnacle openclaw-barnacle Bot added size: XL and removed stale Marked as stale due to inactivity size: L labels Jul 16, 2026
@yungchentang

Copy link
Copy Markdown
Contributor Author

Addressed the max-lines finding on head 135355676af by splitting the edited-mention and debounce cases into focused test modules while preserving all 28 inbound tests. Public CI passes changed tests, test types, dependency/unused-file checks, lint/format, max-lines, and the aggregate gate on the current head. Live Mattermost tenant proof remains unavailable in this environment, so that separate proof request is unchanged. @clawsweeper re-review

@yungchentang
yungchentang force-pushed the codex/71930-mattermost-post-edited-wake branch from 1353556 to 1734e1e Compare July 17, 2026 19:13
@yungchentang

Copy link
Copy Markdown
Contributor Author

Refreshed this PR on current main and resolved the dirty merge state.

Additional fixes on 424f8a614d69635c177eb244d18d36a3e1d14fc4:

  • Preserved current-main replay, mention-policy, reply-runtime, and WebSocket boundaries during the rebase.
  • Serialized zero-delay posted / post_edited handling and added a deterministic concurrency regression test.
  • Split the streaming tests to clear the max-lines gate; all 15 pre-existing inbound cases were preserved byte-for-byte.
  • Public CI passes lint, production/test types, dependency checks, max-lines, and build.
  • An isolated Linux Node 24 container passed all 5 focused Mattermost files: 43/43 tests.

The only CI failures are unrelated current-main drift in the package-acceptance expectation and Android Japanese localization; this PR touches neither surface.

Live Mattermost tenant proof remains unavailable, so that separate proof gap remains.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost 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. P2 Normal backlog priority with limited blast radius. 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.

Mattermost plugin drops post_edited events — @mentions added via edit do not trigger agent wake

1 participant