Skip to content

feat(sdk, ffi): MSC3814 dehydrated-devices high-level manager#6606

Open
jevolk wants to merge 7 commits into
matrix-org:mainfrom
matrix-construct:dehydrated_devices
Open

feat(sdk, ffi): MSC3814 dehydrated-devices high-level manager#6606
jevolk wants to merge 7 commits into
matrix-org:mainfrom
matrix-construct:dehydrated_devices

Conversation

@jevolk
Copy link
Copy Markdown

@jevolk jevolk commented May 22, 2026

Adds an Encryption::dehydrated_devices() manager that wraps the crypto-crate primitives for MSC3814 (probe support, create, rehydrate, delete, weekly rotation, Secret Storage round trip for the pickle key, lifecycle event stream), modelled on matrix-js-sdk's DehydratedDeviceManager and exposed through the FFI Encryption struct for Element X. Resumable rehydration is left for a follow-up; revisits the surface area of #6273 with MatrixMockServer helpers, doctests on every public method, integration tests, and a live round-trip test that runs against any homeserver advertising MSC3814.

@jevolk jevolk requested a review from a team as a code owner May 22, 2026 10:25
@jevolk jevolk requested review from poljar and removed request for a team May 22, 2026 10:25
@jevolk jevolk force-pushed the dehydrated_devices branch from 09b54e0 to dc448fa Compare May 22, 2026 10:28
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 61.47541% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.88%. Comparing base (b847983) to head (0bbe969).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...es/matrix-sdk/src/encryption/dehydrated_devices.rs 48.57% 86 Missing and 4 partials ⚠️
crates/matrix-sdk/src/test_utils/mocks/mod.rs 93.84% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6606      +/-   ##
==========================================
- Coverage   89.94%   89.88%   -0.06%     
==========================================
  Files         382      383       +1     
  Lines      107958   108202     +244     
  Branches   107958   108202     +244     
==========================================
+ Hits        97106    97261     +155     
- Misses       7184     7263      +79     
- Partials     3668     3678      +10     

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

@jevolk jevolk force-pushed the dehydrated_devices branch from dc448fa to 7632d8d Compare May 22, 2026 10:37
jevolk added 7 commits May 22, 2026 10:48
Adds `Encryption::dehydrated_devices()` returning a manager with
`is_supported`, `create`, `rehydrate`, `delete`, `start`, and `stop`,
plus a Secret Storage round trip for the pickle key, a broadcast
event channel for lifecycle observability, and a weekly rotation
task. The module is gated behind `e2e-encryption` and follows the
matrix-js-sdk `DehydratedDeviceManager` shape so applications can
adopt MSC3814 without writing the wire-glue themselves.

Signed-off-by: Jason Volk <jason@zemos.net>
Each public method on `DehydratedDevices` now carries a runnable `no_run`
example that shows the typical call site, so the docs.rs surface is
discoverable without cross-referencing the integration tests.

Signed-off-by: Jason Volk <jason@zemos.net>
…points.

Adds prebuilt mocks for `GET`, `PUT`, `DELETE /dehydrated_device` and
`POST /dehydrated_device/{device_id}/events`, with helpers for the
common success, `M_NOT_FOUND`, and `M_UNRECOGNIZED` responses and
body matchers (`match_next_batch`, `match_missing_next_batch`) so
integration tests can drive the full lifecycle without hand-rolling
wiremock.

Signed-off-by: Jason Volk <jason@zemos.net>
Drives the full lifecycle through the new `MatrixMockServer` helpers
across 13 cases covering support probing, create with default and
explicit display names, delete on the three server responses, the
rehydrate round trip with single-page and paginated to-device feeds,
wrong-pickle-key handling, and the empty-server short-circuit.

Signed-off-by: Jason Volk <jason@zemos.net>
Adds two integration tests under `matrix-sdk-integration-testing`
exercising the wire endpoints end to end: a direct
`create` → `rehydrate` round trip with a locally generated pickle key,
and a `start` lifecycle that resolves the pickle key out of Secret
Storage and asserts that two consecutive `start` calls upload
distinct device IDs.

Signed-off-by: Jason Volk <jason@zemos.net>
Mirrors the SDK shape on the FFI `Encryption` struct with
`is_dehydrated_device_supported`, `create_dehydrated_device`,
`rehydrate_dehydrated_device`, `delete_dehydrated_device`,
`start_dehydrated_devices`, `stop_dehydrated_devices`, and a
`dehydrated_device_event_listener` callback interface so
Element X (Kotlin and Swift) can drive MSC3814 without bypassing
the SDK's lifecycle events.

Signed-off-by: Jason Volk <jason@zemos.net>
Signed-off-by: Jason Volk <jason@zemos.net>
@jevolk jevolk force-pushed the dehydrated_devices branch from 7632d8d to 0bbe969 Compare May 22, 2026 10:48
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 22, 2026

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing matrix-construct:dehydrated_devices (0bbe969) with main (1205c2b)

Open in CodSpeed

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.

1 participant