Skip to content

Membership workflows

Generated by ./gradlew workflowCatalog from :feature:conversationorchestration:membership. Do not edit by hand.

Creating and administrating groups, joining a group and group verification.

Diagram legend: boxes are Steps, arrow labels are the Outcome a step reported, [*] is the start or a successful completion, Rejected ends the workflow with a ConversationFailure.

Workflow Started by Command Lock
AddGroupMembersWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.AddMembers groupAdministrationLockKey(command.groupId)
CreateGroupWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.CreateGroup —
DeleteGroupWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.DeleteGroup groupAdministrationLockKey(command.groupId)
LeaveGroupWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.LeaveGroup groupAdministrationLockKey(command.groupId)
PromoteGroupMemberWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.PromoteMember groupAdministrationLockKey(command.groupId)
RemoveGroupMemberWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.RemoveMember groupAdministrationLockKey(command.groupId)
TransferGroupAdminAndLeaveWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.TransferAdminAndLeave groupAdministrationLockKey(command.groupId)
HandleGroupInvitationResultWorkflow orchestration (engine.run) MembershipCommand.HandleGroupInvitationResult —
HandleMembershipResultWorkflow orchestration (engine.run) MembershipCommand.HandleMembershipResult —
RecoverAcceptedGroupInvitationWorkflow orchestration (engine.run) MembershipCommand.RecoverAcceptedGroupInvitation —
ResumeApprovedGroupJoinWorkflow orchestration (engine.run) MembershipCommand.ResumeApprovedGroupJoin —
RefreshOwnedGroupVerificationWorkflow orchestration (engine.run) MembershipCommand.RefreshOwnedGroupVerification groupVerificationLockKey(command.groupId)
SynchronizeGroupVerificationWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.SynchronizeVerification groupVerificationLockKey(command.groupId)
VerifyGroupMemberWorkflow Chats (ConversationOrchestrator) GroupAdministrationCommand.VerifyMember groupVerificationLockKey(command.groupId)

administration

AddGroupMembersWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.AddMembers
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/AddGroupMembersWorkflow.kt
  • Lock: groupAdministrationLockKey(command.groupId)
  • Uses: WorkflowEngine, GroupConversationRepository, StartGroupMembershipUseCase, RecordGroupInvitationUseCase
LoadTitle -> (StartMembership -> RecordInvitation -> RefreshVerification) for every contact.

The verification projection shows each invited member as pending right after its invitation.
stateDiagram-v2
    [*] --> LoadTitle
    LoadTitle --> StartMembership : TitleLoaded
    LoadTitle --> [*] : TitleLoaded
    StartMembership --> RecordInvitation : MembershipStarted
    RecordInvitation --> RefreshVerification : InvitationRecorded
    RefreshVerification --> StartMembership : VerificationRefreshed
    RefreshVerification --> [*] : VerificationRefreshed

CreateGroupWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.CreateGroup
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/CreateGroupWorkflow.kt
  • Lock: none
  • Uses: WorkflowEngine, GroupConversationRepository, GroupSecurityRepository, LocalSigningKeyPairSource, RefreshOwnedGroupVerificationUseCase
CreateConversation -> InitializeSecurity -> InitializeVerification -> InviteMember for every contact.

No invitation may be created before the owner's epoch and group key exist. Once they do, the group exists: a
contact whose invitation fails is logged and returned in [ConversationResult.GroupCreated.failedContactIds]
instead of failing the creation, so a retry does not create a second group; the admin can add that contact again.
stateDiagram-v2
    [*] --> CreateConversation
    CreateConversation --> InitializeSecurity : ConversationCreated
    InitializeSecurity --> InitializeVerification : SecurityInitialized
    InitializeVerification --> InviteMember : VerificationInitialized
    InitializeVerification --> [*] : VerificationInitialized
    InviteMember --> InviteMember : InvitationAttempted
    InviteMember --> [*] : InvitationAttempted

DeleteGroupWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.DeleteGroup
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/DeleteGroupWorkflow.kt
  • Lock: groupAdministrationLockKey(command.groupId)
  • Uses: GroupConversationRepository, MessageAttachmentRepository, DeleteGroupMembershipUseCase, ClearGroupStateUseCase
LoadContext -> DeleteMembership -> DeleteAttachments -> DeleteLocalConversation -> ClearGroupState.

Membership goes first because it can refuse, e.g. a sole admin of a group with members; the attachments are
only deleted once the group is really gone.
stateDiagram-v2
    [*] --> LoadContext
    LoadContext --> DeleteMembership : ContextLoaded
    DeleteMembership --> DeleteAttachments : MembershipDeleted
    DeleteAttachments --> DeleteLocalConversation : AttachmentsDeleted
    DeleteLocalConversation --> ClearGroupState : LocalConversationDeleted
    ClearGroupState --> [*] : GroupStateCleared

LeaveGroupWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.LeaveGroup
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/LeaveGroupWorkflow.kt
  • Lock: groupAdministrationLockKey(command.groupId)
  • Uses: GroupConversationRepository, LeaveGroupUseCase, DeleteLocalExpenseReceiptsUseCase
LoadContext -> LeaveGroup -> EndLocalMembership -> DeleteExpenseReceipts.
stateDiagram-v2
    [*] --> LoadContext
    LoadContext --> LeaveGroup : ContextLoaded
    LeaveGroup --> EndLocalMembership : MembershipEnded
    EndLocalMembership --> DeleteExpenseReceipts : LocalMembershipEnded
    DeleteExpenseReceipts --> [*] : ExpenseReceiptsDeleted

PromoteGroupMemberWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.PromoteMember
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/PromoteGroupMemberWorkflow.kt
  • Lock: groupAdministrationLockKey(command.groupId)
  • Uses: WorkflowEngine, GroupConversationRepository, PromoteGroupMemberUseCase
LoadContext -> PromoteMember -> ProjectPromotion -> RefreshVerification.

A retry after a crash or a failed later step is safe: Membership returns the promotion of a member who is an
admin already without rotating again, so the projection and the verification refresh still run.
stateDiagram-v2
    [*] --> LoadContext
    LoadContext --> PromoteMember : ContextLoaded
    PromoteMember --> ProjectPromotion : MemberPromoted
    ProjectPromotion --> RefreshVerification : PromotionProjected
    RefreshVerification --> [*] : VerificationRefreshed

RemoveGroupMemberWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.RemoveMember
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/RemoveGroupMemberWorkflow.kt
  • Lock: groupAdministrationLockKey(command.groupId)
  • Uses: WorkflowEngine, GroupConversationRepository, FindGroupMemberRemovalProgressUseCase, RemoveGroupMemberUseCase, FindMemberDisplayNameUseCase
LoadContext -> FindRemovalProgress -> [RemoveMember] -> ResolveMemberName -> ProjectRemoval -> RefreshVerification.

Membership commits the removal in one step; projection and verification follow. A retry after a crash or a
failed later step finds the committed removal and continues with the missing steps.
stateDiagram-v2
    [*] --> LoadContext
    LoadContext --> FindRemovalProgress : ContextLoaded
    FindRemovalProgress --> RefreshVerification : RemovalProgressFound
    FindRemovalProgress --> RemoveMember : RemovalProgressFound
    FindRemovalProgress --> ResolveMemberName : RemovalProgressFound
    RemoveMember --> ResolveMemberName : MemberRemoved
    ResolveMemberName --> ProjectRemoval : MemberNameResolved
    ProjectRemoval --> RefreshVerification : RemovalProjected
    RefreshVerification --> [*] : VerificationRefreshed

TransferGroupAdminAndLeaveWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.TransferAdminAndLeave
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/administration/TransferGroupAdminAndLeaveWorkflow.kt
  • Lock: groupAdministrationLockKey(command.groupId)
  • Uses: GroupConversationRepository, TransferGroupAdminAndLeaveUseCase, DeleteLocalExpenseReceiptsUseCase
LoadContext -> TransferAdminAndLeave -> EndLocalMembership -> DeleteExpenseReceipts.
stateDiagram-v2
    [*] --> LoadContext
    LoadContext --> TransferAdminAndLeave : ContextLoaded
    TransferAdminAndLeave --> EndLocalMembership : MembershipEnded
    EndLocalMembership --> DeleteExpenseReceipts : LocalMembershipEnded
    DeleteExpenseReceipts --> [*] : ExpenseReceiptsDeleted

join

HandleGroupInvitationResultWorkflow

  • Kind: internal — started by an observer, dispatcher or another workflow MembershipCommand.HandleGroupInvitationResult
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/join/HandleGroupInvitationResultWorkflow.kt
  • Lock: none
  • Uses: GetMembershipHandshakeUseCase, StageRemoteIdentityUseCase, AcceptRemoteIdentityHandshakeUseCase, AcceptGroupMembershipUseCase, DeclineGroupMembershipUseCase, GroupConversationRepository, DiscardDeclinedGroupConversationUseCase
accepted, staged:  FindHandshake -> StageOwnerIdentity -> AcceptOwnerIdentity -> AcceptMembership -> ShowConversation
accepted, joining: FindHandshake -> ShowConversation   (an accepted invitation is replayable after restart)
declined:          FindHandshake -> DeclineMembership -> DiscardConversation

The owner keys were verified when this exact offer was staged. A half-joined group is never shown:
the conversation appears only after identity and join preflight succeeded.
stateDiagram-v2
    [*] --> FindHandshake
    FindHandshake --> ShowConversation : AcceptedHandshakeFound
    FindHandshake --> StageOwnerIdentity : AcceptedHandshakeFound
    FindHandshake --> [*] : AcceptedHandshakeFound
    FindHandshake --> DeclineMembership : DeclinedHandshakeFound
    FindHandshake --> [*] : NotForThisDevice
    StageOwnerIdentity --> AcceptOwnerIdentity : OwnerIdentityStaged
    AcceptOwnerIdentity --> AcceptMembership : OwnerIdentityAccepted
    AcceptMembership --> ShowConversation : MembershipAccepted
    ShowConversation --> [*] : Done
    DeclineMembership --> DiscardConversation : MembershipDeclined
    DiscardConversation --> [*] : Done

HandleMembershipResultWorkflow

  • Kind: internal — started by an observer, dispatcher or another workflow MembershipCommand.HandleMembershipResult
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/join/HandleMembershipResultWorkflow.kt
  • Lock: none
  • Uses: WorkflowEngine, HandleInvitationResponseUseCase, LoadMutualMemberIdentityUseCase, ConfirmGroupMemberIdentityUseCase, FindMemberDisplayNameUseCase, GetGroupCurrentEpochUseCase, GroupConversationRepository
IDENTITY_READY: MarkInvitationAccepted -> LoadMemberIdentity -> ConfirmMemberIdentity
WELCOME_SENT:   MarkInvitationAccepted
ACTIVE:         ResolveMemberName -> LoadEpoch -> AddParticipant -> FlushQueuedMessages

IDENTITY_READY recovers memberships left behind when the process stopped after the signed join request
but before the welcome.
stateDiagram-v2
    [*] --> IgnoreResult
    [*] --> MarkInvitationAccepted
    [*] --> ResolveMemberName
    MarkInvitationAccepted --> LoadMemberIdentity : InvitationAccepted
    MarkInvitationAccepted --> [*] : InvitationAccepted
    LoadMemberIdentity --> ConfirmMemberIdentity : MemberIdentityLoaded
    ConfirmMemberIdentity --> [*] : Done
    ResolveMemberName --> LoadEpoch : MemberNameResolved
    LoadEpoch --> AddParticipant : EpochLoaded
    AddParticipant --> FlushQueuedMessages : ParticipantAdded
    FlushQueuedMessages --> [*] : Done
    IgnoreResult --> [*] : Done

RecoverAcceptedGroupInvitationWorkflow

  • Kind: internal — started by an observer, dispatcher or another workflow MembershipCommand.RecoverAcceptedGroupInvitation
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/join/RecoverAcceptedGroupInvitationWorkflow.kt
  • Lock: none
  • Uses: WorkflowEngine, GetMembershipHandshakeUseCase
CheckHandshakeExists -> HandleResult.
stateDiagram-v2
    [*] --> CheckHandshakeExists
    CheckHandshakeExists --> HandleResult : HandshakeExists
    CheckHandshakeExists --> [*] : NothingToRecover
    HandleResult --> [*] : ResultHandled

ResumeApprovedGroupJoinWorkflow

  • Kind: internal — started by an observer, dispatcher or another workflow MembershipCommand.ResumeApprovedGroupJoin
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/join/ResumeApprovedGroupJoinWorkflow.kt
  • Lock: none
  • Uses: GetMembershipHandshakeUseCase, GetRemoteIdentityUseCase, StageRemoteIdentityUseCase, EstablishMutualIdentityUseCase, ConfirmGroupMemberIdentityUseCase
FindHandshake -> LoadApprovedIdentity -> StageIdentity -> EstablishMutualIdentity -> ConfirmMemberIdentity

Approval changed the pinned keys in place but reset mutual authorization: the original signed JOIN's key
receipt is marked again and no earlier verification is inherited. A join that already got its welcome
needs nothing.
stateDiagram-v2
    [*] --> FindHandshake
    FindHandshake --> LoadApprovedIdentity : HandshakeFound
    FindHandshake --> Rejected : HandshakeFound
    FindHandshake --> [*] : HandshakeFound
    LoadApprovedIdentity --> StageIdentity : IdentityLoaded
    StageIdentity --> EstablishMutualIdentity : IdentityStaged
    EstablishMutualIdentity --> ConfirmMemberIdentity : MutualIdentityEstablished
    ConfirmMemberIdentity --> [*] : MemberIdentityConfirmed
    Rejected --> [*]
    classDef reject fill:#f8d7da,stroke:#b02a37,color:#58151c
    class Rejected reject

verification

RefreshOwnedGroupVerificationWorkflow

  • Kind: internal — started by an observer, dispatcher or another workflow MembershipCommand.RefreshOwnedGroupVerification
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/verification/RefreshOwnedGroupVerificationWorkflow.kt
  • Lock: groupVerificationLockKey(command.groupId)
  • Uses: ResolveGroupVerificationRoleUseCase, CheckGroupOwnershipUseCase, RefreshOwnedGroupVerificationUseCase, BroadcastGroupVerificationSnapshotUseCase
LoadSecurity -> RefreshRows -> BroadcastSnapshot   (local admin)
LoadSecurity -> CheckOwnership -> RefreshRows      (owner without security state, e.g. before the first member joined)
stateDiagram-v2
    [*] --> LoadSecurity
    LoadSecurity --> RefreshRows : LocalAdmin
    LoadSecurity --> CheckOwnership : NoSecurityState
    CheckOwnership --> RefreshRows : OwnershipConfirmed
    RefreshRows --> BroadcastSnapshot : RowsRefreshed
    RefreshRows --> [*] : RowsRefreshed
    BroadcastSnapshot --> [*] : SnapshotBroadcast

SynchronizeGroupVerificationWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.SynchronizeVerification
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/verification/SynchronizeGroupVerificationWorkflow.kt
  • Lock: groupVerificationLockKey(command.groupId)
  • Uses: ResolveGroupVerificationRoleUseCase, CheckGroupOwnershipUseCase, RefreshOwnedGroupVerificationUseCase, BroadcastGroupVerificationSnapshotUseCase, RequestGroupVerificationSnapshotUseCase
LoadSecurity -> RefreshRows -> BroadcastSnapshot   (local admin)
LoadSecurity -> RequestSnapshot                     (member)
LoadSecurity -> CheckOwnership -> RefreshRows       (no security state left)
stateDiagram-v2
    [*] --> LoadSecurity
    LoadSecurity --> RefreshRows : LocalAdmin
    LoadSecurity --> RequestSnapshot : Member
    LoadSecurity --> [*] : Member
    LoadSecurity --> CheckOwnership : NoSecurityState
    CheckOwnership --> RefreshRows : OwnershipChecked
    CheckOwnership --> [*] : OwnershipChecked
    RefreshRows --> BroadcastSnapshot : RowsRefreshed
    RefreshRows --> [*] : RowsRefreshed
    BroadcastSnapshot --> [*] : SnapshotBroadcast
    RequestSnapshot --> [*] : SnapshotRequested

VerifyGroupMemberWorkflow

  • Kind: public — Chats submits GroupAdministrationCommand.VerifyMember
  • Source: feature/conversationorchestration/membership/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/membership/domain/workflow/verification/VerifyGroupMemberWorkflow.kt
  • Lock: groupVerificationLockKey(command.groupId)
  • Uses: ResolveGroupVerificationRoleUseCase, ConfirmParticipantVerificationUseCase, BroadcastGroupVerificationSnapshotUseCase, SendAdminVerificationReceiptUseCase
LoadSecurity -> ConfirmParticipant -> BroadcastSnapshot   (the admin verified a member)
LoadSecurity -> SendReceipt                               (a member verified an admin)

A member may verify any admin of the current epoch, also one promoted after its welcome.
stateDiagram-v2
    [*] --> LoadSecurity
    LoadSecurity --> ConfirmParticipant : LocalAdmin
    LoadSecurity --> SendReceipt : TargetIsAdmin
    LoadSecurity --> Rejected : TargetIsNotAdmin
    ConfirmParticipant --> BroadcastSnapshot : ParticipantConfirmed
    BroadcastSnapshot --> [*] : SnapshotBroadcast
    SendReceipt --> [*] : ReceiptSent
    Rejected --> [*]
    classDef reject fill:#f8d7da,stroke:#b02a37,color:#58151c
    class Rejected reject