Implement MSC4115: Membership Metadata on Events
Overview
Implement MSC4115 which adds user membership metadata to events returned via the Client-Server API. This allows clients to determine whether they were room members when specific events occurred.
Problem
Clients cannot reliably determine whether they were room members when specific events occurred, particularly in encrypted rooms or when viewing historical messages. This affects encryption key management and user context.
Solution
Add a membership field to the unsigned section of events indicating the requesting user's membership state at the time of the event.
Implementation Status
See detailed PRD: prds/0009-membership-on-events.md
Completed Phases
26a239a9)
- Added membership annotation functions to
syncapi/synctypes/clientevent.go - Added unit tests for membership determination
- Enabled by default (MSC4115 is stable)
a82428ed on sliding-sync branch)
- Integrated into v4_roomdata.go for sliding sync
- Annotates timeline and required_state events
- All tests passing
e3c9fb42 on msc4115-membership-on-events branch)
- Integrated into stream_pdu.go for v2 sync
- Handles all membership states (join, leave, ban, peek)
- All tests passing
Deployment Status
V4 Sync (sliding-sync branch):
-
✅ Built and pushed to registry - Image:
registry.hjallr.com/jackmaninov/dendrite/snapshot:sliding-sync - Commit:
992e9dda3e305448e0dd7aa1c6d4191c779813e1 - Status: Ready for testing with Element X
V2 Sync (msc4115-membership-on-events branch):
-
✅ Implementation complete - Status: Not yet merged to main, pending testing
Remaining Phases
- /messages, /context, /relations, /event endpoints
- Element X testing (next step)
- Complement tests
- Performance validation
Implementation Details
5 Implementation Phases:
-
✅ Core Infrastructure - Add membership annotation capability -
✅ V4 Sync Integration - Enable for sliding sync (priority) -
✅ Legacy Sync Integration - Enable for v2 sync -
⏳ Additional Endpoints - /messages, /context, /relations, /event -
⏳ Testing & Validation - Unit tests, Complement tests, Element X testing
Branches:
-
msc4115-membership-on-events(off main) - v2 sync implementation -
sliding-sync- v4 sync implementation (includes cherry-picked MSC4115 changes)
Testing: V4 implementation merged into sliding-sync branch for Element X testing
References
- MSC4115: https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/4115-membership-on-events.md
- Synapse implementation: PR #17104, #17282
- MSC completed FCP in June 2024 (stable feature)
Success Criteria
-
✅ Events contain correct membership in unsigned -
✅ Works in v4 and v2 sync -
⏳ Complement tests pass -
⏳ No performance regression -
⏳ Element X handles metadata correctly