Skip to content

WPB-20806 Require history client when history sharing is enabled#5217

Open
battermann wants to merge 33 commits into
developfrom
WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled
Open

WPB-20806 Require history client when history sharing is enabled#5217
battermann wants to merge 33 commits into
developfrom
WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled

Conversation

@battermann
Copy link
Copy Markdown
Contributor

@battermann battermann commented May 7, 2026

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label May 7, 2026
@battermann battermann force-pushed the WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled branch from bf9edb9 to 030a0a5 Compare May 7, 2026 16:28
@pcapriotti pcapriotti force-pushed the WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled branch from 030a0a5 to ac6f8e3 Compare May 8, 2026 09:24
@battermann battermann force-pushed the WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled branch from d7ffc22 to df9b0b6 Compare May 8, 2026 12:54
@battermann battermann changed the title wip WPB-20806 Require history client when history sharing is enabled May 12, 2026
@battermann battermann force-pushed the WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled branch from 185a808 to d3363a2 Compare May 13, 2026 08:35
@battermann battermann force-pushed the WPB-20806-support-and-require-a-history-client-in-an-mls-group-of-a-conversation-with-history-sharing-enabled branch from 12d8e74 to 0e80c06 Compare May 13, 2026 10:42
Copy link
Copy Markdown
Contributor

@pcapriotti pcapriotti left a comment

Choose a reason for hiding this comment

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

TODO:

  • test history client in federation
  • remove key_package_ref
  • clean up history client on conversation deletion

@battermann battermann marked this pull request as ready for review May 18, 2026 08:24
@battermann battermann requested review from a team as code owners May 18, 2026 08:24
@battermann battermann requested a review from Copilot May 18, 2026 08:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enforces invariants for MLS conversation history clients: when history sharing is enabled a group must contain exactly one history client, and when disabled it must contain none. The PR introduces a new GroupMember sum type (RegularClient / HistoryClient) used throughout MLS credential parsing, validation, index maps, and proposal processing; persists history clients in a new mls_history_client table (Cassandra V103 migration and Postgres migration); adds new errors MLSHistoryClientConflict / MLSHistoryClientDuplication; and adds integration test coverage for the new invariants and the conversation migration flow.

Changes:

  • Introduce GroupMember (regular vs history client) and propagate it through key-package validation, index map, proposal actions, and group-info checks.
  • Add mls_history_client storage (Cassandra + Postgres) with new ConversationStore effects (AddHistoryClient, RemoveHistoryClient, RemoveAllHistoryClients, LookupHistoryClients) and migration support.
  • Enforce history-client invariants on MLS commits and messages, returning new MLSHistoryClientConflict / MLSHistoryClientDuplication errors, with corresponding integration tests.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
services/galley/src/Galley/Schema/V103_HistoryClient.hs New Cassandra V103 migration creating the mls_history_client table.
services/galley/src/Galley/Schema/Run.hs Register V103 migration.
services/galley/galley.cabal Expose new schema module.
services/brig/src/Brig/API/MLS/KeyPackages/Validation.hs Wrap identity in RegularClient for key-package validation.
postgres-schema.sql Schema dump for mls_history_client (plus unrelated conversation_parent_conv_idx).
libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Proposal.hs Extend ProposalAction with history-client add/remove; relax checkExternalProposalUser for history clients.
libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Message.hs Enforce history-client invariants on commits and messages.
libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/GroupInfoCheck.hs Use GroupMember in group-info mismatch diagnostics.
libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Commit/InternalCommit.hs Apply history client add/remove during commit processing.
libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Commit/ExternalCommit.hs Wrap sender in RegularClient when adding to index map.
libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Commit/Core.hs Adapt creator action and leaf-node validation to GroupMember.
libs/wire-subsystems/src/Wire/ConversationSubsystem/Errors.hs Add new conversation subsystem errors and mappers.
libs/wire-subsystems/src/Wire/ConversationSubsystem/Action.hs Also remove history clients on conversation deletion.
libs/wire-subsystems/src/Wire/ConversationStore.hs New effect constructors for history-client storage.
libs/wire-subsystems/src/Wire/ConversationStore/Postgres.hs Postgres implementations of history-client ops; combined index map from regular+history.
libs/wire-subsystems/src/Wire/ConversationStore/MLS/Types.hs IndexMap now holds GroupMember; helper mkGroupMember / mkIndexMapFromParts.
libs/wire-subsystems/src/Wire/ConversationStore/Migration/Types.hs Carry history clients in migration data.
libs/wire-subsystems/src/Wire/ConversationStore/Migration/Cleanup.hs Fetch history clients when collecting migration data.
libs/wire-subsystems/src/Wire/ConversationStore/Migration.hs Persist history clients to Postgres during migration; add history_depth to conversation insert.
libs/wire-subsystems/src/Wire/ConversationStore/Cassandra/Queries.hs Cassandra CQL for history client table.
libs/wire-subsystems/src/Wire/ConversationStore/Cassandra.hs Cassandra implementations and hybrid interpreter for new ops.
libs/wire-subsystems/postgres-migrations/20260507162106-history_client.sql Postgres migration for mls_history_client.
libs/wire-api/src/Wire/API/MLS/Credential.hs Define GroupMember, parse history-client: prefix, prisms, schema.
libs/wire-api/src/Wire/API/MLS/Validation.hs Switch validation signatures to GroupMember.
libs/wire-api/src/Wire/API/MLS/KeyPackage.hs credentialIdentityAndKey/keyPackageIdentity return GroupMember.
libs/wire-api/src/Wire/API/Error/Galley.hs New MLSHistoryClient* errors and updated group-info diagnostics.
libs/wire-api/test/unit/Test/Wire/API/MLS.hs Adjust test expectation to RegularClient.
libs/types-common/src/Data/Id.hs Add HistoryClientId id tag.
integration/test/Testlib/Types.hs Test GroupMember ADT and history-client state map.
integration/test/Testlib/Env.hs Initialize historyClientState.
integration/test/MLS/Util.hs Support history clients in mlscli, add commit/remove helpers, parse history-client leaves.
integration/test/Test/MLS/History.hs New tests for history-client invariants.
integration/test/Test/MLS.hs Pass Nothing for the new history-client kp parameter.
integration/test/Test/Migration/Conversation.hs Cover migration with a shared-history channel.
cassandra-schema.cql Cassandra schema dump for new table.
changelog.d/2-features/WPB-20806 Changelog entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Proposal.hs Outdated
Comment thread libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Proposal.hs Outdated
Comment thread postgres-schema.sql
Comment thread libs/wire-subsystems/src/Wire/ConversationStore/Cassandra.hs Outdated
Comment thread libs/wire-subsystems/src/Wire/ConversationSubsystem/MLS/Message.hs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants