Repository navigation
improve(matrix): avoid duplicate outbound body projection - #128392
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 6:26 PM ET / 22:26 UTC. ClawSweeper reviewWhat this changesThe PR carries the Matrix plain-text body rendered during preparation into single-event formatting so it is not projected twice before delivery. Merge readinessNo blocking correctness or security findings. Current main still performs the duplicate body projection, while this maintainer-labeled PR removes it without changing the HTML, mention, routing, or multi-chunk paths; wait for exact-head CI before merge handling. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherMatrix outbound delivery turns agent text into one or more Matrix events, formats each event’s plain and HTML bodies, then sends it through the Matrix client. The change reuses a preparation result only when the exact prepared text becomes one event. flowchart LR
A[Outgoing text] --> B[Matrix text preparation]
B --> C{Single event?}
C -->|Yes| D[Reuse prepared plain body]
C -->|No| E[Render each chunk]
D --> F[Format HTML and mentions]
E --> F
F --> G[Matrix client delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +11, Tests +62. Total +73 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the prepared plain body as a preparation-owned fact, reuse it only for the exact single-event text, and merge after exact-head CI completes. Do we have a high-confidence way to reproduce the issue? Yes—source inspection shows the single-event body is rendered once for size calculation and again during formatting on current main; execution was not performed in this read-only review. Is this the best way to solve the issue? Yes—the preparation owner already computes the required body for its size invariant, and the strict single-event equality guard preserves the existing per-chunk formatter behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6669872a95f8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready disposition for reviewed head
Recommendation remains READY FOR /prepare-pr with no unresolved before-merge item. |
|
Merged via squash.
|
Co-authored-by: Amp <[email protected]>
What Problem This Solves
Fixes an issue where users sending an ordinary single-event Matrix message would pay for the same Markdown-to-Matrix body projection twice before provider delivery. Rich Markdown made this duplicate CPU work measurable on the outbound hot path.
Why This Change Was Made
Matrix text preparation now carries its already-rendered body to formatting when the exact converted text is sent as one event. Multichunk messages retain the existing per-chunk projection path, and provider payload, routing, retry, storage, and public contracts are unchanged.
User Impact
Single-event Matrix text, captions, voice followups, single-message sends, and edits avoid one redundant body render. A controlled rich-Markdown benchmark measured a 33.2% reduction in preparation time for the affected path.
Evidence
sentAt.node scripts/check-changed.mjs --timed -- ...: passed (extensions, extensionTests), including production/test typechecks, formatting, type-aware Oxlint (0 findings), dead-code, boundary, guard, and cycle checks.git diff --check: passed.gpt-5.6-sol/ high clean, patch correct at 0.99 confidence.