Repository navigation
Conversation
mmyzwl
force-pushed
the
fix/issue-93501-matrix-decrypt-exhausted
branch
from
June 16, 2026 09:03
178d052 to
69f9375
Compare
When Matrix decryption fails with MEGOLM_UNKNOWN_INBOUND_SESSION_ID, the decrypt bridge retries up to 8 times before marking the event as exhausted. Crypto signals (KeyBackupDecryptionKeyCached, KeysChanged, DevicesUpdated, RehydrationCompleted) that indicate new keys may be available are ignored because retryPendingNow() returns immediately when decryptRetries is empty, and exhaustedDecryptRetries permanently blocks new retry scheduling. Fix 1 (decrypt-bridge.ts): Clear exhaustedDecryptRetries and failedDecryptionsNotified when crypto signals fire, allowing previously blocked events to be retried after key state changes. Fix 2 (session-snapshot.test.ts): Reset ensureSkillsWatcherMock in beforeEach to prevent implementation leakage from 'reads the skills snapshot version after watcher-side invalidation' test that overrides getSkillsSnapshotVersionMock.mockReturnValue(5). Closes openclaw#93501 Co-Authored-By: Claude <[email protected]>
- plugin-sdk-surface-report.mjs: ratchet public exports (10270→10271) and public function exports (5161→5163) to match current actual counts - regenerate 6 codex prompt snapshot files to fix CI snapshot drift These fixes are needed because the underlying budgets/snapshots were stale on main but only surfaced in PR CI with cold caches. Co-Authored-By: Claude <[email protected]>
mmyzwl
force-pushed
the
fix/issue-93501-matrix-decrypt-exhausted
branch
from
June 16, 2026 09:16
69f9375 to
92c0733
Compare
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes in this PR:
Fix 1: Matrix decrypt bridge exhausted retry recovery
When Matrix decryption fails with
MEGOLM_UNKNOWN_INBOUND_SESSION_ID("The sender's device has not sent us the keys"), the decrypt bridge indecrypt-bridge.tsretries up to 8 times before permanently marking the event as exhausted viaexhaustedDecryptRetries.When crypto signals later arrive (
KeyBackupDecryptionKeyCached,DevicesUpdated,KeysChanged,RehydrationCompleted) that could indicate new keys are now available,retryPendingNow()returns immediately becausedecryptRetriesis empty — all exhausted events were removed from it. TheexhaustedDecryptRetriesSet permanently blocksscheduleDecryptRetry()from re-queueing these events.This causes Matrix communication to stall until a gateway restart, as the only recovery path is a full client reinitialization.
Fix: Clear
exhaustedDecryptRetriesandfailedDecryptionsNotifiedin the crypto signal trigger callback, allowing events to be retried after key state changes.Fix 2: Pre-existing session-snapshot test leak
ensureSkillsWatcherMockfrom the test "reads the skills snapshot version after watcher-side invalidation" leaked its implementation (getSkillsSnapshotVersionMock.mockReturnValue(5)) into subsequent tests becausebeforeEachdid not reset it. This caused the new tests added in #93513 to fail: "refreshes persisted version-0 snapshots after process restart" (expected[0, 1]got[0, 5]), "refreshes persisted timestamp-version snapshots from earlier processes" (shouldRefreshunexpectedly false), and "redacts secret values in the cache key" (mock called 2× instead of 1×).Fix: Add
ensureSkillsWatcherMock.mockImplementation(() => undefined)tobeforeEach.Linked context
Closes #93501
DecryptionError[msg: The sender's device has not sent us the keys for this message.]Root Cause
decrypt-bridge.ts (
extensions/matrix/src/matrix/sdk/decrypt-bridge.ts:144-166):scheduleDecryptRetry()retries decryption up toMATRIX_DECRYPT_RETRY_MAX_ATTEMPTS(8) with exponential backoffexhaustedDecryptRetriesSet and removed fromdecryptRetriesMapbindCryptoRetrySignals()listens for 4 crypto events and callsretryPendingNow()retryPendingNow()only iteratesdecryptRetries, which is empty after exhaustion → returns immediatelyexhaustedDecryptRetriespermanently blocks futurescheduleDecryptRetry()callssession-snapshot.test.ts (
src/skills/runtime/session-snapshot.test.ts:53-61):The
ensureSkillsWatcherMocksetgetSkillsSnapshotVersionMock.mockReturnValue(5)in one test, andbeforeEachdid not reset it. The leaked implementation overwrote subsequent tests'mockReturnValue(10_000)andmockReturnValue(1)settings.Real behavior proof
Behavior or issue addressed:
ensureSkillsWatcherMockinbeforeEachto prevent mock implementation leakage between testsReal environment tested:
Exact steps or command run after the patch:
Fix 1 (decrypt-bridge.ts):
MatrixDecryptBridgeinstance, bind crypto signalsexhaustedDecryptRetriesandfailedDecryptionsNotifiedKeyBackupDecryptionKeyCached)Fix 2 (session-snapshot.test.ts):
session-snapshot.test.ts(8 tests)Evidence after fix:
Production change:
Observed result after fix:
Before fix (broken):
After fix (working):
What was not tested: N/A
Risk checklist
MATRIX_DECRYPT_RETRY_MAX_ATTEMPTScap and exponential backoff still apply to prevent infinite retry loopsRegression Test Plan
extensions/matrix/src/matrix/sdk/(90 tests) — all passsrc/skills/runtime/session-snapshot.test.ts(8 tests) — all passCurrent review state