Repository navigation
fix(matrix): bind E2EE readiness to client generations - #120168
vincentkoc wants to merge 2 commits into
Conversation
Punchcard-Session: cobalt-valley-meadow-mg
Punchcard-Session: calm-orchard-workshop-fw
|
Codex review: blocked before merge. Reviewed September 27, 2026, 4:04 AM ET / 08:04 UTC (Revision 8). ClawSweeper reviewWhat this changesThe branch makes Matrix encrypted-room QA sends wait for client-generation readiness, forwards cancellation to image uploads, and adds shutdown deadlines for encrypted-state persistence. Merge readiness⛔ Blocked before merge - 9 items remain Keep this protected, MEMBER-authored PR open. Current main has merged part of the shutdown repair, but the branch retains distinct QA readiness and upload cancellation work. Three previously reported correctness blockers remain at the unchanged head, and GitHub reports merge conflicts. Priority: P1 Review scores
Verification
How this fits togetherThe Matrix plugin wraps matrix-js-sdk for account sync, encrypted sends, and crypto-state storage. QA Lab drives that client through send and shutdown scenarios, while shared client generations control when a replacement may start. flowchart LR
A[Matrix account and QA action] --> B[Shared client generation]
B --> C[SDK sync and crypto]
C --> D{Room ready and generation live?}
D -->|Yes| E[Encrypted send or upload]
D -->|No| F[Wait or report failure]
B --> G[Shutdown and snapshot persistence]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +80, Tests +361. Total +441 across 11 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Integrate the remaining QA readiness and upload behavior into current main's Matrix lifecycle owners, keeping a generation keyed through startup retirement and joining periodic persistence before shutdown completes. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives three concrete ordering cases at this PR head: abort while SDK startup remains pending, stop during an active periodic snapshot, and STOPPED while encrypted-room readiness waits. They were not executed in this read-only review. Is this the best way to solve the issue? No. The owner boundaries are appropriate, but this implementation needs to preserve current main's startup-retirement and periodic-persistence fences and reject terminal readiness promptly. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9ae6e1853062. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
|
Closing as superseded by the verified current-main reconstruction in #163012, squash commit 37a8f34. The replacement landed through the native workflow with green exact-head CI and Security Review, a completed clean ClawSweeper review, and remote causal/runtime proof: 55 unique candidate tests, affected readiness follow-ups, encrypted text/notice/image round trips, and all 28 selected checks. All eight landed source hashes match that proof. Current-main snapshot The remaining historical behavior is already owned on main:
Those canonical commits and the existing QA simplification in #160460 were verified ancestors of the landed replacement. This is source-backed supersession plus the replacement's actual proof, not a reuse of the historical 188-pass claim. The separate QA cleanup in #119920 remains open. This closure does not delete the historical branch or revive its unidentified session. |
Related: #119920
What Problem This Solves
Fixes four Matrix E2EE lifecycle races in the split from #119920:
This remains limited to Matrix generation/readiness, upload cancellation, persistence shutdown, and the QA E2EE lifecycle that owns those operations. It does not add scenario configuration, room setup, CLI/gateway, Docker, recording, release, or live evidence changes.
Why This Change Was Made
The canonical owners now enforce the lifecycle:
extensions/matrix/src/matrix/sdk/client-base.ts:381-432races each async readiness probe against sync/error/abort changes and rechecks captured generation ownership before accepting success.extensions/matrix/src/matrix/sdk/client-base.ts:680-718re-stops matrix-js-sdk if delayed Rust crypto initialization settles after the OpenClaw generation stopped.extensions/matrix/src/matrix/sdk/client-core.ts:445-457passes the QA operation'sAbortControllerinto matrix-js-sdk's upload contract;extensions/qa-lab/src/live-transports/matrix/substrate/e2ee-client.ts:491-522keeps readiness, encryption, upload, and dispatch in one tracked operation. Cancellation can abort an active upload; once message dispatch starts, its send promise remains authoritative and timeout reports unknown completion rather than a false aborted-send result.extensions/matrix/src/matrix/sdk/client-base.ts:577-612propagates one absolute shutdown deadline and abort signal to persistence;extensions/matrix/src/matrix/sdk/idb-persistence.ts:305-344checks cancellation again immediately before the snapshot write, preventing a late commit after shutdown returns.The repair also removes duplicate lifecycle policy: failed shared generations are deleted at the startup producer, QA uses the plugin SDK timeout primitive, and one generation-aware readiness loop owns both startup and encrypted-room readiness.
Direct Dependency Evidence
Personally inspected installed matrix-js-sdk 41.9.0 source and declarations:
matrix-js-sdk/src/sync.ts:80-97,821-855,887-929:ERRORmay recover, cachedPREPAREDis markedfromCache, live sync emits readiness after processing, and sync persistence occurs before/after those transitions.matrix-js-sdk/src/client.ts:1470-1542,1564-1576: startup is async;stopClient()stops the current crypto backend and is idempotent once client polling is stopped.matrix-js-sdk/src/client.ts:1993-2048: Rust crypto assignscryptoBackendonly after asynchronous import/initialization, so an earlier stop cannot clean the late backend.matrix-js-sdk/src/http-api/interface.ts:192-215,src/http-api/index.ts:55-165,src/http-api/fetch.ts:257-305: upload cancellation is owned byUploadOpts.abortController, which drives both XHR and fetch cancellation.matrix-js-sdk/lib/client.d.ts:949-958,1160-1176,2763-2769: declarations confirm async start/init, synchronous stop, and the upload options contract.Provenance
95bac4d76966d78e92711336c68ab761593db1b7introduced the readiness wait, generation checks, QA operation cancellation, and shutdown deadline paths where findings 1, 3, and 4 manifested.5402ef192d5, which did not expose matrix-js-sdk's upload controller.5402ef192d5, shared generation retirement from fix(matrix): retire shared E2EE clients safely #119570 (a3419d4a4b4c894b47a9273181735d091f4d502f), and the new generation checks at95bac4d.56915896bc8e5f98ed6d5ac068bd5ff3f926204f) for bounded QA sends and fix(qa): Matrix replies disappear after final replacement #117390 (39cc0a3199f5444a95e2a7756440792c73cd19ed) for Matrix replacement-event observation.User Impact
Matrix E2EE QA sends now wait on the current live generation, active image uploads are actually abortable, terminal stop cleans crypto even when initialization completes late, and shutdown cannot produce a post-deadline snapshot commit.
Evidence
089056737bd173a02afe129b9b27142fbf587c38.oxfmt: clean on all 9 repair files.git diff --check: clean.+272/-192, net+80.+369/-8, net+361.packages/terminal-core/src/ansi.ts:194withTS2554.Remaining proof: independent exact-head re-review, hosted CI, and any parent-assigned live Matrix/Crabbox evidence. This PR remains draft.
Punchcard-Session: calm-orchard-workshop-fw