Skip to content

fix(matrix): retain every message ID and actual reply in multipart sends - #118128

Merged
steipete merged 1 commit into
mainfrom
codex/qa0802-matrix-delivery-receipts
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0802-matrix-delivery-receipts

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Matrix messages containing multiple chunks, attachments, captions, or voice transcripts lost their real message IDs and recorded incorrect message types or reply relationships.

Why This Change Was Made

The Matrix sender now records each emitted event's actual type and native reply relationship. Matrix outbound adapters retain the sender's complete authoritative receipt, and multi-attachment delivery combines those receipts in real event order while preserving the existing final message ID.

User Impact

Matrix conversations correctly account for every delivered text/image/audio event. Replies apply only to messages that actually replied, the first delivered event remains the primary message, later attachments remain discoverable, and ordinary single-message behavior is unchanged.

Evidence

  • Before: an actual PNG followed by overflow text produced wire events [image reply, text nonreply], while public results reported only the last ID and incorrectly projected both events as replying media.
  • After: actual sender, typed channel adapter, and multi-attachment fanout preserve every event ID, [media,text] kinds, [reply,null] reply facts, first primary ID, contiguous indices, and the final returned message ID.
  • Focused hosted Testbox proof: pnpm test extensions/matrix/src/matrix/send.test.ts extensions/matrix/src/outbound.test.ts extensions/matrix/src/channel.message-adapter.test.ts — 96/96 tests across three suites passed.
  • Hosted runner: https://github.com/openclaw/openclaw/actions/runs/30760713254
  • Additional actual runtime proof exercised a real PNG/shared file loader, Matrix message formatting, typed adapter, text chunking, voice, and first-only reply fanout.
  • Fresh independent gpt-5.6-sol/high autoreview: no actionable P0/P1 findings; confidence 0.86. TruffleHog clean.
  • Production delta: +20 lines for authoritative per-event and multi-attachment accounting. No SDK surface, configuration, permission, or persistent-state changes. AI-assisted and independently reviewed.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: M maintainer Maintainer-authored PR labels Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 18:43
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 2:48 PM ET / 18:48 UTC.

ClawSweeper review

What this changes

The PR preserves every Matrix multipart-send event ID and its actual message kind and reply relationship in final outbound delivery receipts.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for normal maintainer review. Current main still collapses multipart Matrix receipt facts to the first event’s kind/reply metadata and strips receipts at outbound return boundaries; this focused patch records those facts at the Matrix sender and preserves them through the adapter without adding a new public API or configuration surface. No discrete correctness finding was identified.

Priority: P1
Reviewed head: 7c8f9370cb702fa35384e15a6612e0c79dd1d703

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrowly scoped, follows the canonical nested-receipt contract, and is backed by focused behavioral coverage plus hosted runtime proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body documents after-fix hosted Testbox execution for the three changed Matrix suites and reports actual runtime coverage of file loading, formatting, chunking, voice, and first-only reply fanout; the supplied check snapshot also records a successful Real behavior proof run.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body documents after-fix hosted Testbox execution for the three changed Matrix suites and reports actual runtime coverage of file loading, formatting, chunking, voice, and first-only reply fanout; the supplied check snapshot also records a successful Real behavior proof run.
Evidence reviewed 6 items Current-main defect: Current main creates every multipart receipt part from one shared kind and reply ID, so an image reply followed by non-reply overflow text is projected as though both parts shared the first event’s metadata.
Current adapter drops receipt data: The current Matrix payload, text, and media adapter paths return only channel, message ID, and room ID, discarding the sender’s receipt before generic outbound delivery can consume it.
Patch records facts at the owner boundary: The proposed sender derives each accepted event’s reply relationship from the actual Matrix event content and emits a per-event receipt, while the final receipt retains all accepted events in order.
Findings None None.
Security None None.

How this fits together

The Matrix plugin turns an outbound payload into one or more Matrix events, then returns a delivery receipt to OpenClaw’s generic outbound pipeline. That receipt is used to retain the primary message ID, all emitted IDs, and per-event delivery metadata for later delivery accounting.

flowchart LR
  A[Outbound payload] --> B[Matrix outbound adapter]
  B --> C[Matrix sender]
  C --> D[One or more Matrix events]
  D --> E[Authoritative event receipt]
  E --> F[Aggregated outbound result]
  F --> G[Generic delivery accounting]
Loading

Before merge

  • Complete next step (P2) - This maintainer-labeled implementation has no actionable patch defect for an automated repair lane; let normal current-head CI and maintainer merge review complete.
Agent review details

Security

None.

PR surface

Source +20, Tests +197. Total +217 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 62 42 +20
Tests 3 198 1 +197
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 260 43 +217

Review metrics

None.

Technical review

Best possible solution:

Merge the focused owner-boundary repair once the current-head required checks finish green, keeping Matrix event facts authoritative at send time and preserving the complete receipt through every outbound adapter return path.

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

Yes—source-reproducible with high confidence. Current main applies the first planned event’s kind and requested reply ID to all receipt parts, and the outbound adapter then removes the complete receipt from its final result; the added focused tests model a media reply followed by non-reply overflow text.

Is this the best way to solve the issue?

Yes. Recording event-specific facts in the Matrix sender and passing the sender’s authoritative receipt through the Matrix adapter is the narrowest maintainable fix; reconstructing kinds or replies later would reintroduce inference from incomplete state.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Current main can mis-associate multipart Matrix delivery IDs, message kinds, and native reply relationships in a real channel workflow.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents after-fix hosted Testbox execution for the three changed Matrix suites and reports actual runtime coverage of file loading, formatting, chunking, voice, and first-only reply fanout; the supplied check snapshot also records a successful Real behavior proof run.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body documents after-fix hosted Testbox execution for the three changed Matrix suites and reports actual runtime coverage of file loading, formatting, chunking, voice, and first-only reply fanout; the supplied check snapshot also records a successful Real behavior proof run.

Label justifications:

  • P1: Current main can mis-associate multipart Matrix delivery IDs, message kinds, and native reply relationships in a real channel workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body documents after-fix hosted Testbox execution for the three changed Matrix suites and reports actual runtime coverage of file loading, formatting, chunking, voice, and first-only reply fanout; the supplied check snapshot also records a successful Real behavior proof run.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents after-fix hosted Testbox execution for the three changed Matrix suites and reports actual runtime coverage of file loading, formatting, chunking, voice, and first-only reply fanout; the supplied check snapshot also records a successful Real behavior proof run.

Evidence

What I checked:

  • Current-main defect: Current main creates every multipart receipt part from one shared kind and reply ID, so an image reply followed by non-reply overflow text is projected as though both parts shared the first event’s metadata. (extensions/matrix/src/matrix/send.ts:67, e92a98c77d6a)
  • Current adapter drops receipt data: The current Matrix payload, text, and media adapter paths return only channel, message ID, and room ID, discarding the sender’s receipt before generic outbound delivery can consume it. (extensions/matrix/src/outbound.ts:159, e92a98c77d6a)
  • Patch records facts at the owner boundary: The proposed sender derives each accepted event’s reply relationship from the actual Matrix event content and emits a per-event receipt, while the final receipt retains all accepted events in order. (extensions/matrix/src/matrix/send.ts:67, 7c8f9370cb70)
  • Shared receipt contract supports the aggregation: The canonical receipt helper flattens nested adapter receipts and treats adapter-provided per-part reply metadata as authoritative, specifically avoiding inherited replies for parts without a native reply. (src/channels/message/receipt.ts:45, e92a98c77d6a)
  • Feature provenance: Blame ties the current Matrix receipt construction and outbound wrapper behavior to the recent receipt feature introduction on current main, so this PR repairs the same owner path rather than adding a parallel mechanism. (extensions/matrix/src/matrix/send.ts:67, a3198023ea86)
  • Current-main status: No Matrix receipt-path commit appears between the PR base snapshot and current main; the current checkout remains at e92a98c and does not contain the PR head, so the fix is still necessary. (extensions/matrix/src/outbound.ts:159, e92a98c77d6a)

Likely related people:

  • steipete: Current-main blame attributes the Matrix receipt construction and outbound return wrappers to Peter Steinberger, and the proposed repair follows that same receipt-owner boundary. (role: recent area contributor and feature owner; confidence: high; commits: a3198023ea86, 7c8f9370cb70; files: extensions/matrix/src/matrix/send.ts, extensions/matrix/src/outbound.ts)

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.

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer exact-head review completed at 7c8f937. Root cause: Matrix multipart receipts copied first-event kind/reply metadata onto later events and outbound wrappers dropped the complete nested receipt. The Matrix sender now records each accepted event ID, actual message kind, and native reply relation; payload/text/media adapters preserve the authoritative ordered receipt. Production +20 lines is justified by real per-event delivery facts. Hosted Blacksmith focused owner proof: 96/96 tests across three suites, including actual PNG/file loading, media overflow, chunking, voice, multiple attachments, and first-only reply fanout. Exact-head CI https://github.com/openclaw/openclaw/actions/runs/30761749660 , Workflow Sanity https://github.com/openclaw/openclaw/actions/runs/30761741029 , and Real behavior proof https://github.com/openclaw/openclaw/actions/runs/30761748723 all succeeded. Fresh independent Sol/high review found no P0/P1 issue. I personally read the full latest ClawSweeper review; its sole requested remaining step was green current-head CI plus native maintainer review, both now satisfied.

@steipete
steipete merged commit 1e10c44 into main Aug 2, 2026
157 of 167 checks passed
@steipete
steipete deleted the codex/qa0802-matrix-delivery-receipts branch August 2, 2026 19:04
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant