Incoming packet workflows¶
Generated by ./gradlew workflowCatalog from :feature:conversationorchestration:incoming. Do not edit by hand.
Routing every decrypted packet to the one workflow that applies it.
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 |
|---|---|---|---|
ReceiveDirectMessageWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveDirectMessage |
— |
ReceiveGroupMessageWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupMessage |
— |
CompleteManualIdentityWorkflow |
orchestration (engine.run) |
IncomingCommand.CompleteManualIdentity |
— |
ReceiveAuthorizationRevokedWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveAuthorizationRevoked |
— |
ReceiveContactInviteAcceptedWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveContactInviteAccepted |
— |
ReceiveContactInviteDeclinedWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveContactInviteDeclined |
— |
ReceiveContactInviteWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveContactInvite |
— |
ReceiveContactReadyWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveContactReady |
— |
ReceiveIdentityAcknowledgementWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveIdentityAcknowledgement |
— |
ReceiveManualIdentityWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveManualIdentity |
— |
ReceiveGroupActivationAcknowledgementWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupActivationAcknowledgement |
— |
ReceiveGroupDeletionWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupDeletion |
— |
ReceiveGroupInviteDeclineWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupInviteDecline |
— |
ReceiveGroupInviteReceiptWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupInviteReceipt |
— |
ReceiveGroupInviteWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupInvite |
— |
ReceiveGroupJoinRequestWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupJoinRequest |
— |
ReceiveGroupLeaveRequestWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupLeaveRequest |
— |
ReceiveGroupMemberActivationWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupMemberActivation |
— |
ReceiveGroupMemberRemovalWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupMemberRemoval |
— |
ReceiveGroupReadyAcknowledgementWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupReadyAcknowledgement |
— |
ReceiveGroupWelcomeWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupWelcome |
— |
ReceiveGroupAvatarWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupAvatar |
— |
ReceiveGroupDescriptionWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupDescription |
— |
ReceiveGroupPinWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupPin |
— |
ReceiveGroupTitleWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveGroupTitle |
— |
ApplyParkedMessageOperationsWorkflow |
orchestration (engine.run) |
IncomingCommand.ApplyParkedMessageOperations |
— |
ApplyRemoteMessageOperationWorkflow |
orchestration (engine.run) |
IncomingCommand.ApplyRemoteMessageOperation |
— |
RouteIncomingPacketWorkflow |
orchestration (engine.run) |
IncomingCommand.RouteIncomingPacket |
— |
ReceiveVerificationReceiptWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveVerificationReceipt |
groupVerificationLockKey(command.packet.groupId) |
ReceiveVerificationSnapshotRequestWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveVerificationSnapshotRequest |
groupVerificationLockKey(command.packet.groupId) |
ReceiveVerificationSnapshotWorkflow |
orchestration (engine.run) |
IncomingCommand.ReceiveVerificationSnapshot |
groupVerificationLockKey(command.packet.groupId) |
direct¶
ReceiveDirectMessageWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveDirectMessage - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/direct/ReceiveDirectMessageWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,DirectMessagePacketReader,UpdateIncomingSenderProfileUseCase,DirectMessageRepository,MessageAttachmentOperationsRepository,StoreIncomingDirectAttachmentsUseCase,SendDeliveryReceiptUseCase,ClaimAutoReplyForContactUseCase,ReleaseAutoReplyRecipientUseCase
ReadMessage -> FindExisting -> [UpdateSenderProfile -> StoreMessage] -> StoreAttachments -> SendDeliveryReceipt
-> ClaimAutoReply -> [SendAutoReply -> [ReleaseAutoReplyClaim]] -> CacheAttachments -> ApplyParkedOperations
The router created the conversation and checked the authorization before this workflow starts. A redelivered
message keeps its row, so edits, deletions and the read state applied since are not undone; only attachments
and the receipt are repeated. A message ID that belongs to another message is rejected.
stateDiagram-v2
[*] --> ReadMessage
ReadMessage --> FindExisting : MessageRead
FindExisting --> StoreAttachments : MessageStored
FindExisting --> UpdateSenderProfile : NewMessage
UpdateSenderProfile --> StoreMessage : SenderProfileUpdated
StoreMessage --> StoreAttachments : MessageStored
StoreAttachments --> SendDeliveryReceipt : AttachmentsStored
SendDeliveryReceipt --> ClaimAutoReply : DeliveryReceiptSent
ClaimAutoReply --> SendAutoReply : AutoReplyClaimed
ClaimAutoReply --> CacheAttachments : NoAutoReply
SendAutoReply --> ReleaseAutoReplyClaim : AutoReplyFailed
SendAutoReply --> CacheAttachments : AutoReplyHandled
ReleaseAutoReplyClaim --> CacheAttachments : AutoReplyHandled
CacheAttachments --> ApplyParkedOperations : AttachmentsCached
ApplyParkedOperations --> [*] : ParkedOperationsApplied
group¶
ReceiveGroupMessageWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupMessage - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/group/ReceiveGroupMessageWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GroupMessageRepository,RequireGroupConversationUseCase,GroupSecurityRepository,GroupMessagePlaintextCodec,ApplyPeerProfilePictureUseCase,PrefetchLinkPreviewsUseCase,MessageAttachmentOperationsRepository,SendDeliveryReceiptUseCase,AuthorizeIncomingExpensesUseCase,DeleteReplacedExpenseReceiptsUseCase
FindConversation -> DecryptMessage -> ApplyOperation (an operation)
FindConversation -> DecryptMessage -> FindExisting
-> [AuthorizeExpenses -> DeleteReplacedReceipts -> ApplyProfilePicture -> StoreMessage]
-> PrefetchLinkPreviews -> StoreAttachments -> SendDeliveryReceipt -> CacheAttachments
-> ApplyParkedOperations (a message)
A redelivered message keeps its row; only attachments and the receipt are repeated.
stateDiagram-v2
[*] --> FindConversation
FindConversation --> DecryptMessage : ConversationFound
DecryptMessage --> FindExisting : MessageDecrypted
DecryptMessage --> ApplyOperation : OperationDecrypted
ApplyOperation --> [*] : Done
FindExisting --> PrefetchLinkPreviews : MessageStored
FindExisting --> AuthorizeExpenses : NewMessage
AuthorizeExpenses --> DeleteReplacedReceipts : ExpensesAuthorized
DeleteReplacedReceipts --> ApplyProfilePicture : ReplacedReceiptsDeleted
ApplyProfilePicture --> StoreMessage : ProfilePictureApplied
StoreMessage --> PrefetchLinkPreviews : MessageStored
PrefetchLinkPreviews --> StoreAttachments : LinkPreviewsRequested
StoreAttachments --> SendDeliveryReceipt : AttachmentsStored
SendDeliveryReceipt --> CacheAttachments : DeliveryReceiptSent
CacheAttachments --> ApplyParkedOperations : AttachmentsCached
ApplyParkedOperations --> [*] : Done
identity¶
CompleteManualIdentityWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.CompleteManualIdentity - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/CompleteManualIdentityWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,CheckDirectPeerAuthorizedUseCase,SendIdentityVerificationReceiptUseCase
LoadAuthorization -> [ActivateConversation] -> SendVerificationReceipt
Manual setup may precede an invitation: only an accepted invitation creates the chat and releases its
queued messages.
stateDiagram-v2
[*] --> LoadAuthorization
LoadAuthorization --> ActivateConversation : Authorized
LoadAuthorization --> SendVerificationReceipt : NotAuthorized
ActivateConversation --> SendVerificationReceipt : ConversationActivated
SendVerificationReceipt --> [*] : ReceiptSent
ReceiveAuthorizationRevokedWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveAuthorizationRevoked - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveAuthorizationRevokedWorkflow.kt - Lock: none
- Uses:
GetIdentityExchangeBindingUseCase,DirectChatAuthorizationRevocationProtocol,InvalidateIdentityExchangeUseCase
FindExchange -> VerifySignature -> DecideRevocation -> InvalidateExchange
The signature is verified before the signer is compared with the invitation's identity: a self-signed
packet from a new identity never revokes the previous identity's chat. It is acknowledged and ignored.
stateDiagram-v2
[*] --> FindExchange
FindExchange --> [*] : Done
FindExchange --> VerifySignature : ExchangeFound
VerifySignature --> DecideRevocation : SignatureValid
DecideRevocation --> [*] : Done
DecideRevocation --> InvalidateExchange : RevocationApplies
InvalidateExchange --> [*] : Done
ReceiveContactInviteAcceptedWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveContactInviteAccepted - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveContactInviteAcceptedWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,ContactInvitationHandshakeProtocol,GetIdentityExchangeBindingUseCase,ReceiveIdentityExchangeAcceptedUseCase,StageIncomingIdentityReviewUseCase,HandleInvitationResponseUseCase,ApplyPeerProfilePictureUseCase
VerifyAcceptance -> FindExchange -> ReceiveAcceptance -> ActivateConversation -> MarkInvitationAccepted
-> ApplyProfilePicture
An acceptance whose exchange was cancelled or replaced locally cannot establish a chat and is acknowledged
as handled instead of being retried forever. A verified acceptance signed with keys other than the original
contact's is no proof of that contact's identity: it becomes an identity review and never activates the chat.
stateDiagram-v2
[*] --> VerifyAcceptance
VerifyAcceptance --> FindExchange : AcceptanceVerified
FindExchange --> [*] : Done
FindExchange --> ReceiveAcceptance : ExchangeFound
ReceiveAcceptance --> ActivateConversation : AcceptanceReceived
ReceiveAcceptance --> StageIdentityReview : ReviewRequired
StageIdentityReview --> [*] : Done
ActivateConversation --> MarkInvitationAccepted : ConversationActivated
MarkInvitationAccepted --> ApplyProfilePicture : InvitationAccepted
ApplyProfilePicture --> [*] : Done
ReceiveContactInviteDeclinedWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveContactInviteDeclined - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveContactInviteDeclinedWorkflow.kt - Lock: none
- Uses:
ContactInvitationDeclineProtocol,RecordRemoteIdentityDeclineUseCase
stateDiagram-v2
[*] --> VerifyDecline
VerifyDecline --> RecordDecline : DeclineVerified
RecordDecline --> [*] : DeclineRecorded
ReceiveContactInviteWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveContactInvite - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveContactInviteWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,VerifyIncomingContactInvitationUseCase,ResolveIncomingIdentityPeerUseCase,StageIncomingIdentityReviewUseCase,MergeIncomingIdentityPeersUseCase,UpdateIncomingIdentityPeerMetadataUseCase,ReceiveIdentityExchangeUseCase,ApplyPeerProfilePictureUseCase,ResolveContactInvitationDisplayNameUseCase
VerifyInvitation -> ResolvePeer -> MergePeers -> [UpdatePeerPhoneNumber] -> ReceiveExchange -> ApplyProfilePicture
-> ResolveDisplayName -> RecordInvitation
Signature and time bounds are verified BEFORE contacts are looked up or merged. Keys that differ from a
known contact's are proof of the proposed keys only: they become an identity review, never a merge.
The claimed phone number never files the invitation under a contact; a matching phone book contact is
only offered for linking, which happens when the user accepts.
The Identity result observer restores the inbox record after a restart; it alone declines rejected senders.
stateDiagram-v2
[*] --> VerifyInvitation
VerifyInvitation --> ResolvePeer : InvitationVerified
ResolvePeer --> MergePeers : PeerResolved
ResolvePeer --> StageReplacementReview : ReplacementRequired
StageReplacementReview --> [*] : Done
MergePeers --> ReceiveExchange : PeersMerged
MergePeers --> UpdatePeerPhoneNumber : PeersMerged
UpdatePeerPhoneNumber --> ReceiveExchange : PeerUpdated
ReceiveExchange --> ApplyProfilePicture : ExchangeReceived
ApplyProfilePicture --> ResolveDisplayName : ProfilePictureApplied
ResolveDisplayName --> RecordInvitation : DisplayNameResolved
RecordInvitation --> [*] : Done
ReceiveContactReadyWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveContactReady - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveContactReadyWorkflow.kt - Lock: none
- Uses:
GetIdentityExchangeBindingUseCase,ContactInvitationHandshakeProtocol,ReceiveIdentityReadyUseCase,ApplyPeerProfilePictureUseCase
FindExchange -> VerifyReady -> ReceiveReady -> ApplyProfilePicture. READY completes the inviter's side of the
exchange and carries the inviter's picture, which the unencrypted first invite leaves out.
stateDiagram-v2
[*] --> FindExchange
FindExchange --> VerifyReady : ExchangeFound
VerifyReady --> ReceiveReady : ReadyVerified
ReceiveReady --> ApplyProfilePicture : ReadyReceived
ApplyProfilePicture --> [*] : ProfilePictureApplied
ReceiveIdentityAcknowledgementWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveIdentityAcknowledgement - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveIdentityAcknowledgementWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,ReceiveIdentityAcknowledgementUseCase
stateDiagram-v2
[*] --> Receive
Receive --> CompleteIdentity : IdentityMutual
Receive --> [*] : IdentityOneWay
CompleteIdentity --> [*] : IdentityCompleted
ReceiveManualIdentityWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveManualIdentity - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/identity/ReceiveManualIdentityWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,ReceiveManualIdentityUseCase
stateDiagram-v2
[*] --> Receive
Receive --> CompleteIdentity : IdentityMutual
Receive --> [*] : IdentityOneWay
CompleteIdentity --> [*] : IdentityCompleted
membership¶
ReceiveGroupActivationAcknowledgementWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupActivationAcknowledgement - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupActivationAcknowledgementWorkflow.kt - Lock: none
- Uses:
ReceiveGroupActivationAcknowledgementUseCase
stateDiagram-v2
[*] --> ReceiveAcknowledgement
ReceiveAcknowledgement --> [*] : AcknowledgementReceived
ReceiveGroupDeletionWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupDeletion - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupDeletionWorkflow.kt - Lock: none
- Uses:
GetTrustedGroupAuthorityUseCase,AuthorizeIncomingGroupDeletionUseCase,MessageAttachmentRepository,GroupIncomingConversationRepository,CompleteIncomingGroupDeletionUseCase
LoadOwnerKey -> AuthorizeDeletion -> DeleteAttachments -> PrepareDeletion -> CompleteDeletion -> FinishDeletion.
stateDiagram-v2
[*] --> LoadOwnerKey
LoadOwnerKey --> AuthorizeDeletion : OwnerKeyLoaded
AuthorizeDeletion --> DeleteAttachments : DeletionAuthorized
DeleteAttachments --> PrepareDeletion : AttachmentsDeleted
PrepareDeletion --> CompleteDeletion : DeletionPrepared
CompleteDeletion --> FinishDeletion : MembershipDeleted
FinishDeletion --> [*] : Finished
ReceiveGroupInviteDeclineWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupInviteDecline - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupInviteDeclineWorkflow.kt - Lock: none
- Uses:
ReceiveGroupMembershipDeclineUseCase,ClearMembershipHandshakeUseCase,HandleInvitationResponseUseCase,EnsureRemoteSigningIdentityUseCase,MarkMembershipRemovedUseCase
pending invitation: ReceiveDecline -> ClearHandshake -> MarkInvitationDeclined
active member: ReceiveDecline -> RequireSigningIdentity -> MarkMembershipRemoved
A pending decline is authenticated by its signed original challenge and never changes a pinned key;
removing an active member requires the accepted identity.
stateDiagram-v2
[*] --> ReceiveDecline
ReceiveDecline --> ClearHandshake : DeclineReceived
ReceiveDecline --> RequireSigningIdentity : DeclineReceived
ReceiveDecline --> [*] : Done
ClearHandshake --> MarkInvitationDeclined : HandshakeCleared
MarkInvitationDeclined --> [*] : Done
RequireSigningIdentity --> MarkMembershipRemoved : SigningIdentityConfirmed
MarkMembershipRemoved --> [*] : Done
ReceiveGroupInviteReceiptWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupInviteReceipt - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupInviteReceiptWorkflow.kt - Lock: none
- Uses:
ReceiveGroupMembershipReceiptUseCase
ReceiveReceipt: Membership verifies the delivery receipt of a group invitation.
The receipt never accepts the membership or authorizes a welcome, and a restored member may sign it with
new keys; the pinned identity therefore stays unchanged. The join request establishes authorization later.
stateDiagram-v2
[*] --> ReceiveReceipt
ReceiveReceipt --> [*] : ReceiptReceived
ReceiveGroupInviteWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupInvite - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupInviteWorkflow.kt - Lock: none
- Uses:
InspectIncomingGroupOfferUseCase,ShouldRecordPendingInvitationUseCase,ReceiveIncomingGroupMembershipUseCase,CheckGroupInvitationTargetUseCase,EvaluateGroupInvitationIdentityUseCase,GroupConversationRepository,StageRemoteIdentityUseCase,StageIncomingIdentityReviewUseCase,RecordPendingInvitationUseCase,ApplyPeerProfilePictureUseCase
InspectOffer -> CheckRecordable -> CheckTarget -> StageConversation -> EvaluateOwnerIdentity -> [StageOwnerIdentity]
-> StageOffer -> [StageIdentityReview] -> RecordInvitation -> [ApplyProfilePicture]
Expired or blocked offers are dropped so they never enter the inbox or poison the retry queue. A replayed or
no longer stageable offer is still handed to Membership without staging. A signed group offer proves the
PROPOSED keys only: changed owner keys become a separate identity review and never touch trusted keys,
conversations or profile data. An offer whose group ID names an existing conversation other than its own
pending invitation is rejected before anything is staged.
stateDiagram-v2
[*] --> InspectOffer
InspectOffer --> [*] : Dropped
InspectOffer --> CheckRecordable : OfferValid
CheckRecordable --> ReceiveWithoutStaging : AlreadyHandled
CheckRecordable --> CheckTarget : Recordable
ReceiveWithoutStaging --> CheckPinnedOwner : ReceivedWithoutStaging
ReceiveWithoutStaging --> [*] : ReceivedWithoutStaging
CheckPinnedOwner --> [*] : Done
CheckPinnedOwner --> ApplyProfilePicture : OwnerKeysTrusted
CheckTarget --> StageConversation : TargetAllowed
StageConversation --> ReceiveWithoutStaging : ConversationDeletedLocally
StageConversation --> EvaluateOwnerIdentity : ConversationStaged
EvaluateOwnerIdentity --> StageOffer : OwnerIdentityEvaluated
EvaluateOwnerIdentity --> StageOwnerIdentity : OwnerIdentityEvaluated
StageOwnerIdentity --> StageOffer : OwnerIdentityStaged
StageOffer --> RecordInvitation : OfferStaged
StageOffer --> StageIdentityReview : OfferStaged
StageIdentityReview --> RecordInvitation : IdentityReviewStaged
RecordInvitation --> [*] : Done
RecordInvitation --> ApplyProfilePicture : OwnerKeysTrusted
ApplyProfilePicture --> [*] : Done
ReceiveGroupJoinRequestWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupJoinRequest - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupJoinRequestWorkflow.kt - Lock: none
- Uses:
ReceiveGroupMembershipJoinRequestUseCase,EvaluateGroupInvitationIdentityUseCase,StageIncomingIdentityReviewUseCase,StageRemoteIdentityUseCase,EstablishMutualIdentityUseCase,ConfirmGroupMemberIdentityUseCase,ApplyPeerProfilePictureUseCase
ReceiveJoin -> EvaluateMemberIdentity -> StageIdentityReview (changed keys)
ReceiveJoin -> EvaluateMemberIdentity -> StageIdentity -> EstablishMutualIdentity
-> ConfirmMemberIdentity -> ApplyProfilePicture
Unlike the receipt, a JOIN binds both member keys. A different signing OR encryption key always waits
for the user's one-tap approval; the membership stays staged meanwhile. A duplicate JOIN after the
welcome has nothing left to authorize.
stateDiagram-v2
[*] --> ReceiveJoin
ReceiveJoin --> [*] : Done
ReceiveJoin --> EvaluateMemberIdentity : JoinReceived
EvaluateMemberIdentity --> StageIdentity : IdentityAcceptable
EvaluateMemberIdentity --> StageIdentityReview : IdentityChanged
StageIdentityReview --> [*] : Done
StageIdentity --> EstablishMutualIdentity : IdentityStaged
EstablishMutualIdentity --> ConfirmMemberIdentity : MutualIdentityEstablished
ConfirmMemberIdentity --> ApplyProfilePicture : MemberIdentityConfirmed
ApplyProfilePicture --> [*] : Done
ReceiveGroupLeaveRequestWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupLeaveRequest - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupLeaveRequestWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GroupConversationRepository,ReceiveGroupLeaveRequestUseCase,FindMemberDisplayNameUseCase
LoadContext -> ReceiveLeaveRequest -> ResolveMemberName -> RemoveParticipant -> RefreshVerification.
stateDiagram-v2
[*] --> LoadContext
LoadContext --> ReceiveLeaveRequest : ContextLoaded
ReceiveLeaveRequest --> ResolveMemberName : MemberLeft
ResolveMemberName --> RemoveParticipant : MemberNameResolved
RemoveParticipant --> RefreshVerification : ParticipantRemoved
RefreshVerification --> [*] : VerificationRefreshed
ReceiveGroupMemberActivationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupMemberActivation - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupMemberActivationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GetTrustedGroupAuthorityUseCase,AuthorizeIncomingGroupActivationUseCase,ResolveSigningIdentityContactUseCase,ApplyIncomingGroupActivationUseCase,FindMemberDisplayNameUseCase,GroupConversationRepository
LoadOwner -> AuthorizeActivation -> [ResolveMemberContact] -> ApplyActivation, then
local member: SynchronizeVerification
DISCOVERY round: ResolveMemberName -> RecordMemberAdded (history only, no routing yet)
FINAL round: ResolveMemberName -> ActivateParticipant -> FlushQueuedMessages
stateDiagram-v2
[*] --> LoadOwner
LoadOwner --> AuthorizeActivation : OwnerLoaded
AuthorizeActivation --> ApplyActivation : LocalMemberActivated
AuthorizeActivation --> ResolveMemberContact : RemoteMemberActivated
ResolveMemberContact --> ApplyActivation : MemberContactResolved
ApplyActivation --> SynchronizeVerification : AppliedForLocalMember
ApplyActivation --> ResolveMemberName : AppliedForMember
ApplyActivation --> [*] : AppliedForMember
SynchronizeVerification --> [*] : Done
ResolveMemberName --> ActivateParticipant : MemberNameResolved
ResolveMemberName --> RecordMemberAdded : MemberNameResolved
RecordMemberAdded --> [*] : Done
ActivateParticipant --> FlushQueuedMessages : ParticipantActivated
FlushQueuedMessages --> [*] : Done
ReceiveGroupMemberRemovalWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupMemberRemoval - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupMemberRemovalWorkflow.kt - Lock: none
- Uses:
AuthorizeIncomingGroupRemovalUseCase,ApplyIncomingGroupRemovalUseCase,CompleteIncomingGroupRemovalUseCase
stateDiagram-v2
[*] --> AuthorizeRemoval
AuthorizeRemoval --> [*] : NotApplicable
AuthorizeRemoval --> ApplyRemoval : RemovalAuthorized
ApplyRemoval --> CompleteRemoval : RemovalApplied
CompleteRemoval --> [*] : Completed
ReceiveGroupReadyAcknowledgementWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupReadyAcknowledgement - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupReadyAcknowledgementWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,CheckReadyAcknowledgementEpochUseCase,ReceiveGroupReadyAcknowledgementUseCase,FindReadyAcknowledgedMembershipUseCase,FindMemberDisplayNameUseCase,GroupConversationRepository
CheckEpochCurrent -> ReceiveAcknowledgement -> CheckEpochStillCurrent -> FindActivatedMembership
-> [ResolveMemberName -> AddParticipant -> FlushQueuedMessages] -> RefreshVerification -> SendCurrentMetadata
The owner discards old epoch keys on rotation: a delayed acknowledgement of an older welcome is
obsolete and changes nothing. The participant is projected synchronously so group sends never wait
for an observer.
stateDiagram-v2
[*] --> CheckEpochCurrent
CheckEpochCurrent --> ReceiveAcknowledgement : EpochCurrent
CheckEpochCurrent --> [*] : Obsolete
ReceiveAcknowledgement --> CheckEpochStillCurrent : AcknowledgementReceived
CheckEpochStillCurrent --> FindActivatedMembership : EpochStillCurrent
CheckEpochStillCurrent --> [*] : Obsolete
FindActivatedMembership --> ResolveMemberName : MembershipActivated
FindActivatedMembership --> RefreshVerification : NoActivatedMembership
ResolveMemberName --> AddParticipant : MemberNameResolved
AddParticipant --> FlushQueuedMessages : ParticipantAdded
FlushQueuedMessages --> RefreshVerification : QueueFlushed
RefreshVerification --> SendCurrentMetadata : VerificationRefreshed
SendCurrentMetadata --> [*] : MetadataSent
ReceiveGroupWelcomeWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupWelcome - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/membership/ReceiveGroupWelcomeWorkflow.kt - Lock: none
- Uses:
AuthorizeIncomingGroupWelcomeUseCase,GetTrustedGroupAuthorityUseCase,OpenIncomingGroupWelcomeUseCase,GroupIncomingConversationRepository,ResolveIncomingPeerContactsUseCase,PersistIncomingGroupWelcomeUseCase,FindMemberDisplayNameUseCase,EstablishMutualIdentityUseCase,SendGroupReadyAcknowledgementUseCase,CompleteIncomingGroupWelcomeUseCase,RotateGroupKeyAfterAdminLeftUseCase
AuthorizeWelcome -> LoadAuthority -> OpenWelcome -> RecordRestart -> ResolveMemberContacts -> PersistWelcome
-> ResolveMemberNames -> InstallWelcome -> [EstablishMutualIdentity] -> SendReadyAcknowledgement -> CompleteWelcome
-> RotateAfterAdminLeft
The first welcome must come from the accepted, pinned inviter identity; later welcomes are checked against
Membership's prior epoch. Contacts are resolved only after Membership verified and decrypted the welcome.
stateDiagram-v2
[*] --> AuthorizeWelcome
AuthorizeWelcome --> LoadAuthority : Advanced
AuthorizeWelcome --> [*] : NotApplicable
LoadAuthority --> OpenWelcome : Advanced
OpenWelcome --> RecordRestart : Advanced
RecordRestart --> ResolveMemberContacts : Advanced
ResolveMemberContacts --> PersistWelcome : Advanced
PersistWelcome --> ResolveMemberNames : Advanced
ResolveMemberNames --> InstallWelcome : Advanced
InstallWelcome --> EstablishMutualIdentity : Advanced
InstallWelcome --> SendReadyAcknowledgement : Advanced
EstablishMutualIdentity --> SendReadyAcknowledgement : Advanced
SendReadyAcknowledgement --> CompleteWelcome : Advanced
CompleteWelcome --> RotateAfterAdminLeft : Advanced
RotateAfterAdminLeft --> [*] : Completed
metadata¶
ReceiveGroupAvatarWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupAvatar - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/metadata/ReceiveGroupAvatarWorkflow.kt - Lock: none
- Uses:
GroupAvatarPacketCodec,AuthorizeGroupMetadataUseCase,SaveGroupAvatarUseCase
stateDiagram-v2
[*] --> VerifySignature
VerifySignature --> AuthorizeAdmin : SignatureValid
AuthorizeAdmin --> SaveAvatar : AdminAuthorized
AuthorizeAdmin --> [*] : Ignored
SaveAvatar --> [*] : Ignored
SaveAvatar --> [*] : Saved
ReceiveGroupDescriptionWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupDescription - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/metadata/ReceiveGroupDescriptionWorkflow.kt - Lock: none
- Uses:
GroupDescriptionPacketCodec,AuthorizeGroupMetadataUseCase,SaveGroupDescriptionUseCase
stateDiagram-v2
[*] --> VerifySignature
VerifySignature --> AuthorizeAdmin : SignatureValid
AuthorizeAdmin --> SaveDescription : AdminAuthorized
AuthorizeAdmin --> [*] : Ignored
SaveDescription --> [*] : Ignored
SaveDescription --> [*] : Saved
ReceiveGroupPinWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupPin - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/metadata/ReceiveGroupPinWorkflow.kt - Lock: none
- Uses:
GroupPinPacketCodec,AuthorizeGroupMetadataUseCase,CheckIncomingGroupStateVersionUseCase,ResolveIncomingPinSenderUseCase,LocalizePinnedPollVotersUseCase,SaveGroupPinUseCase
VerifySignature -> AuthorizeAdmin -> CheckPinSlot -> [ResolveMessageSender] -> SavePin
ResolveMessageSender also resolves who pinned the message, and maps a pinned poll's voters to this device's
contacts ([LocalizePinnedPollVotersUseCase]).
Older updates are dropped, and an active expense board keeps the pin slot against other messages. SavePin checks
both again atomically with the save, because a local pin may be saved while the sender is resolved.
stateDiagram-v2
[*] --> VerifySignature
VerifySignature --> AuthorizeAdmin : SignatureValid
AuthorizeAdmin --> CheckPinSlot : AdminAuthorized
AuthorizeAdmin --> [*] : Ignored
CheckPinSlot --> [*] : Ignored
CheckPinSlot --> SavePin : SenderResolved
CheckPinSlot --> ResolveMessageSender : SlotAvailable
ResolveMessageSender --> SavePin : SenderResolved
SavePin --> [*] : Ignored
SavePin --> [*] : Saved
ReceiveGroupTitleWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveGroupTitle - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/metadata/ReceiveGroupTitleWorkflow.kt - Lock: none
- Uses:
GroupTitlePacketCodec,AuthorizeGroupMetadataUseCase,SaveGroupTitleUseCase
stateDiagram-v2
[*] --> VerifySignature
VerifySignature --> AuthorizeAdmin : SignatureValid
AuthorizeAdmin --> SaveTitle : AdminAuthorized
AuthorizeAdmin --> [*] : Ignored
SaveTitle --> [*] : Ignored
SaveTitle --> [*] : Saved
operation¶
ApplyParkedMessageOperationsWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ApplyParkedMessageOperations - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/operation/ApplyParkedMessageOperationsWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,ParkedMessageOperationRepository
FindParked -> [Apply -> Apply -> ...]
Runs after a message was stored: the operations that arrived before it (an edit that overtook its message
after a reconnect, for example) are applied in the order they were sent. Each one is removed once it ran;
one that is not allowed, such as an edit by another sender, is dropped as it would have been on arrival.
stateDiagram-v2
[*] --> FindParked
FindParked --> Apply : Waiting
FindParked --> [*] : Waiting
Apply --> Apply : Waiting
Apply --> [*] : Waiting
ApplyRemoteMessageOperationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ApplyRemoteMessageOperation - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/operation/ApplyRemoteMessageOperationWorkflow.kt - Lock: none
- Uses:
AuthorizeRemoteMessageOperationUseCase,DirectMessageRepository,GroupMessageRepository,MessageReactionRepository,DiscardDirectMessagesUseCase,DiscardGroupMessagesUseCase,FindGroupPollUseCase,FindGroupPollHolderUseCase,SaveGroupPollUseCase,ParkedMessageOperationRepository
FindTarget, then by operation:
Edit: CheckEditable -> ReplaceText
Delete: CheckSender -> DeleteMessage
Reaction: SaveReaction | RemoveReaction
PollVote: FindPoll -> SavePoll
PollClose: CheckPollCloser -> FindPoll -> SavePoll
No target: FindPinnedPoll (poll operations), else Park
[AuthorizeRemoteMessageOperationUseCase] decides who may change which message. Edits keep the text with the
latest edit time, not the one that arrived last, because live and mailbox copies can overtake each other.
An operation whose message has not arrived yet, for example an edit that overtook it after a reconnect, is
parked and applied once the message is stored ([ApplyParkedMessageOperationsWorkflow]). A poll vote or close whose
message this device never received, because it joined after the poll was pinned, changes the poll in the pin
instead ([PollHolder.Pin]); the message will never arrive, so parking it would lose it.
stateDiagram-v2
[*] --> FindTarget
FindTarget --> CheckEditable : TargetFound
FindTarget --> CheckPollCloser : TargetFound
FindTarget --> CheckSender : TargetFound
FindTarget --> FindPoll : TargetFound
FindTarget --> RemoveReaction : TargetFound
FindTarget --> SaveReaction : TargetFound
FindTarget --> FindPinnedPoll : TargetMissing
FindTarget --> Park : TargetMissing
CheckEditable --> ReplaceText : Editable
ReplaceText --> [*] : Applied
CheckSender --> DeleteMessage : SenderOwnsTarget
DeleteMessage --> [*] : Applied
SaveReaction --> [*] : Applied
RemoveReaction --> [*] : Applied
CheckPollCloser --> FindPoll : PollCloserAllowed
FindPoll --> SavePoll : PollFound
SavePoll --> [*] : Applied
FindPinnedPoll --> CheckPollCloser : PinnedPollFound
FindPinnedPoll --> FindPoll : PinnedPollFound
FindPinnedPoll --> Park : PinnedPollMissing
Park --> [*] : Parked
routing¶
RouteIncomingPacketWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.RouteIncomingPacket - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/routing/RouteIncomingPacketWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,ResolveDirectPeerAccessUseCase,DirectConversationRepository,ResolveControlConversationIdUseCase,CheckGroupPacketAcceptedUseCase,CheckGroupPacketReadyUseCase,GroupPacketDispatcher,ControlPacketDispatcher
direct message: CheckDirectAuthorization -> EnsureDirectConversation -> ReceiveDirectMessage | ApplyDirectOperation
group packet: CheckGroupAccepted -> CheckGroupReady -> DispatchGroupPacket
receipt: ApplyReceipt
anything else: FindControlConversation -> DispatchControlPacket
Direct and group packets never share handlers. Messages of a contact whose invitation was not accepted
are dropped without a chat being created. Packets that arrived too early — a message of a contact whose
invitation is still in flight, a group packet before the welcome of its epoch — fail with
[IncomingPacketDeferredException]: their envelope is parked and processed again later.
stateDiagram-v2
[*] --> CheckDirectAuthorization
[*] --> CheckGroupAccepted
[*] --> ApplyReceipt
[*] --> FindControlConversation
CheckDirectAuthorization --> Rejected : Deferred
CheckDirectAuthorization --> EnsureDirectConversation : DirectAuthorized
CheckDirectAuthorization --> [*] : Dropped
EnsureDirectConversation --> ApplyDirectOperation : DirectConversationResolved
EnsureDirectConversation --> ReceiveDirectMessage : DirectConversationResolved
EnsureDirectConversation --> Rejected : DirectConversationResolved
ReceiveDirectMessage --> [*] : Handled
ApplyDirectOperation --> [*] : Handled
CheckGroupAccepted --> [*] : Dropped
CheckGroupAccepted --> CheckGroupReady : GroupAccepted
CheckGroupReady --> Rejected : Deferred
CheckGroupReady --> DispatchGroupPacket : GroupReady
DispatchGroupPacket --> [*] : Handled
ApplyReceipt --> [*] : Handled
FindControlConversation --> DispatchControlPacket : ControlConversationResolved
DispatchControlPacket --> [*] : Handled
Rejected --> [*]
classDef reject fill:#f8d7da,stroke:#b02a37,color:#58151c
class Rejected reject
verification¶
ReceiveVerificationReceiptWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveVerificationReceipt - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/verification/ReceiveVerificationReceiptWorkflow.kt - Lock:
groupVerificationLockKey(command.packet.groupId) - Uses:
AcceptParticipantVerificationReceiptUseCase,BroadcastGroupVerificationSnapshotUseCase
AcceptReceipt -> BroadcastSnapshot: the admin records that a member verified it and tells everybody.
stateDiagram-v2
[*] --> AcceptReceipt
AcceptReceipt --> BroadcastSnapshot : ReceiptAccepted
BroadcastSnapshot --> [*] : SnapshotBroadcast
ReceiveVerificationSnapshotRequestWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveVerificationSnapshotRequest - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/verification/ReceiveVerificationSnapshotRequestWorkflow.kt - Lock:
groupVerificationLockKey(command.packet.groupId) - Uses:
AcceptVerificationSnapshotRequestUseCase,RefreshOwnedGroupVerificationUseCase,SendGroupVerificationSnapshotUseCase
AuthenticateRequest -> RefreshRows -> SendSnapshot: the admin answers a member with its current rows.
stateDiagram-v2
[*] --> AuthenticateRequest
AuthenticateRequest --> RefreshRows : RequestAuthenticated
RefreshRows --> SendSnapshot : RowsRefreshed
SendSnapshot --> [*] : SnapshotSent
ReceiveVerificationSnapshotWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
IncomingCommand.ReceiveVerificationSnapshot - Source:
feature/conversationorchestration/incoming/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/incoming/domain/workflow/verification/ReceiveVerificationSnapshotWorkflow.kt - Lock:
groupVerificationLockKey(command.packet.groupId) - Uses:
ApplyVerificationSnapshotUseCase
stateDiagram-v2
[*] --> ApplySnapshot
ApplySnapshot --> [*] : SnapshotApplied