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

Phase 1: Core Infrastructure (commit 26a239a9)

  • Added membership annotation functions to syncapi/synctypes/clientevent.go
  • Added unit tests for membership determination
  • Enabled by default (MSC4115 is stable)

Phase 2: V4 Sync Integration (commit a82428ed on sliding-sync branch)

  • Integrated into v4_roomdata.go for sliding sync
  • Annotates timeline and required_state events
  • All tests passing

Phase 3: Legacy Sync Integration (commit 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

Phase 4: Additional Endpoints (optional)

  • /messages, /context, /relations, /event endpoints

Phase 5: Testing & Validation

  • Element X testing (next step)
  • Complement tests
  • Performance validation

Implementation Details

5 Implementation Phases:

  1. Core Infrastructure - Add membership annotation capability
  2. V4 Sync Integration - Enable for sliding sync (priority)
  3. Legacy Sync Integration - Enable for v2 sync
  4. Additional Endpoints - /messages, /context, /relations, /event
  5. 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

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
Edited by Jack Maninov