Repository navigation
fix(matrix): recover encryption in previously joined rooms - #115688
fuller-stack-dev merged 10 commits into
Conversation
After initRustCrypto() completes, already-joined encrypted rooms never get their encryptors configured because incremental sync doesn't re-send m.room.encryption state events. This causes outbound messages to fail with 'Cannot encrypt event in unconfigured room' or fall back to plaintext. Fix: scan joined rooms after initial sync and retroactively configure encryptors for any room with encryption state on the server. Closes openclaw#115637
|
Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 2:40 AM ET / 06:40 UTC (Revision 13). ClawSweeper reviewWhat this changesThe Matrix plugin restores missing encryption state for previously joined rooms during startup, with bounded requests, cancellation, and coordinated shutdown. Merge readiness✅ Ready for maintainer review This remains a useful fix absent from current main and the latest release. The earlier actionable findings are resolved, the supplied real-server evidence supports recovery, and no blocking patch defect was found. Priority: P1 Review scores
Verification
How this fits togetherThe Matrix plugin connects OpenClaw conversations to a Matrix homeserver. Its startup owner initializes encryption and synchronizes room state before outbound replies pass through encrypted-send checks. flowchart TD
A[Saved room state] --> B[Initialize crypto and sync]
C[Homeserver joined rooms] --> D[Bounded encryption recovery]
B --> D
D --> E[Encrypted-send checks]
E --> F[Encrypted Matrix reply]
E --> G[Reject unready room]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +181, Tests +470. Total +651 across 11 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep room-encryption recovery in the Matrix startup owner, preserving fail-closed sending and shutdown ownership of admitted crypto work. Do we have a high-confidence way to reproduce the issue? Yes, for the missing-cache-state scenario: source and supplied Synapse observations establish failure with an intact cursor and crypto store but absent encryption events. This review did not execute it, and the healthy-cache encryption-toggle trigger was not reproduced on current Synapse. Is this the best way to solve the issue? Yes. Startup reconciliation uses the SDK's existing encryption-event owner and avoids adding repair work to every send; the obsolete preparation no-op and its callers are removed together. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0763bc712dc8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
Reconcile joined-room encryption after sync readiness with the real SDK contract, bounded requests, cancellation, and lifecycle-owned teardown. Preserve encrypted-send fail-closed behavior and remove no-op preparation. Retain the original contributor history while integrating current main. Co-authored-by: Alex Fraser <[email protected]>
Preserve healthy encrypted startup on transient discovery failure while retaining cancellation, fatal authentication errors, and fail-closed sends.
|
Merged via squash.
|
…115688) * fix(matrix): configure encryptors for rooms joined before crypto init After initRustCrypto() completes, already-joined encrypted rooms never get their encryptors configured because incremental sync doesn't re-send m.room.encryption state events. This causes outbound messages to fail with 'Cannot encrypt event in unconfigured room' or fall back to plaintext. Fix: scan joined rooms after initial sync and retroactively configure encryptors for any room with encryption state on the server. Closes openclaw#115637 * fix: add explicit any cast for fake event object * fix: cast crypto to any for onCryptoEvent type * fix: avoid explicit any, use typed interface cast instead * fix(matrix): tolerate temporary joined-room discovery failure Preserve healthy encrypted startup on transient discovery failure while retaining cancellation, fatal authentication errors, and fail-closed sends. * test(matrix): inspect fetch request URLs explicitly --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Alex Fraser <[email protected]>
Closes #115637
What Problem This Solves
Fixes outbound replies failing in previously joined encrypted Matrix rooms when a resumed sync has no local encryption state.
User Impact
Affected rooms recover encrypted sending during startup. Encryption remains opt-in, and unknown or failed encryption state never permits a plaintext fallback. No configuration or storage migration is required.
Why This Change Was Made
Reconcile the homeserver's joined-room set after crypto initialization and sync readiness, using the installed SDK's real encryption-event handling. Recovery has a bounded request pool and startup deadline; cancellation stops new work, and shutdown waits for admitted crypto replay before closing the backend. Temporary joined-room discovery failures log skipped recovery without taking healthy cached encrypted rooms offline; cancellation, authentication failures, and invalid room lists still fail. Remove the obsolete no-op preparation path.
Original report and candidate: Alex Fraser (@AlexSCFraser). This updates the existing contributor PR and preserves its history.
Evidence
Cannot encrypt event in unconfigured room; both sentm.room.encryptedafterward and an independent SDK recipient decrypted both messages.All 209 affected Matrix tests passed, including actual-SDK startup regressions for temporary discovery failure, fatal authentication errors, cancellation, and fail-closed sending from unrecovered rooms. The 503/429/connection regressions fail before the follow-up repair. The upstream Slack typing prerequisite is incorporated and full test typechecking passed. The final full build and independent P0–P2 review passed. Real Synapse acceptance was repeated with the final production source: both rooms again sent encrypted wire events and the independent recipient decrypted both messages. Final changed-file lint passed with zero warnings/errors; prior production typechecking, dead-code and architecture checks also passed. Exact-head CI remains required before landing.
The original contributor disclosed AI assistance and live Continuwuity validation; the current-source evidence above was independently rerun for this revision.