Skip to content

Conversation

@richvdh
Copy link
Member

@richvdh richvdh commented Nov 13, 2025

When we receive two copies of the same inbound Megolm session from two sources, merge them together intelligently.

Fixes: #5108, #4698

@richvdh richvdh requested review from a team as code owners November 13, 2025 13:36
@richvdh richvdh requested review from andybalaam and removed request for a team November 13, 2025 13:36
In order to correctly merge sessions, we need more granular comparisons between
two sessions than just "Better" or "Worse", so factor out a method that *just*
looks at the ratchet states.
@richvdh richvdh force-pushed the rav/history_sharing/merge_sessions branch from e3c6044 to 5c442d3 Compare November 13, 2025 13:51
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 13, 2025

CodSpeed Performance Report

Merging #5865 will not alter performance

Comparing rav/history_sharing/merge_sessions (60072b3) with main (17df3f8)

Summary

✅ 50 untouched

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Very excited about this feature.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 91.82390% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.59%. Comparing base (17df3f8) to head (60072b3).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk-crypto/src/store/mod.rs 93.18% 3 Missing and 6 partials ⚠️
...atrix-sdk-crypto/src/olm/group_sessions/inbound.rs 85.18% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5865      +/-   ##
==========================================
+ Coverage   88.58%   88.59%   +0.01%     
==========================================
  Files         363      363              
  Lines      102782   102888     +106     
  Branches   102782   102888     +106     
==========================================
+ Hits        91048    91157     +109     
+ Misses       7495     7489       -6     
- Partials     4239     4242       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Add a method which can be used to merge a received `InboundGroupSession` into
whatever we find in the store.
... with `merge_received_group_session`.

`merge_received_group_session` expands the logic of `compare_group_session` to
handle the fact that there is more than one axis of "better" or "worse" and we
may need to take the best bits of two copies of the session.
Add an integration test that checks that, when we receive a copy of a megolm
session directly after having previously received it via history sharing, we
get the best bits of both.
@richvdh richvdh force-pushed the rav/history_sharing/merge_sessions branch from f72c06b to 60072b3 Compare November 13, 2025 18:37
@richvdh richvdh enabled auto-merge November 13, 2025 18:43
@richvdh richvdh merged commit 9ab886f into main Nov 13, 2025
79 of 82 checks passed
@richvdh richvdh deleted the rav/history_sharing/merge_sessions branch November 13, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

History sharing: merge megolm sessions if we get keys from two sources

3 participants