Direct chat lifecycle workflows¶
Generated by ./gradlew workflowCatalog from :feature:conversationorchestration:lifecycle. Do not edit by hand.
How a direct chat is opened, gets authorized, loses its authorization and recovers 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 |
|---|---|---|---|
DeleteDirectConversationWorkflow |
Chats (ConversationOrchestrator) |
DirectConversationCommand.DeleteConversation |
— |
OpenDirectConversationWorkflow |
Chats (ConversationOrchestrator) |
DirectConversationCommand.OpenConversation |
— |
ReconnectDirectConversationWorkflow |
Chats (ConversationOrchestrator) |
DirectConversationCommand.ReconnectConversation |
— |
RequestReauthorizationWorkflow |
orchestration (engine.run) |
LifecycleCommand.RequestReauthorization |
— |
RevokePeerExchangeWorkflow |
orchestration (engine.run) |
LifecycleCommand.RevokePeerExchange |
— |
StartDirectInvitationWorkflow |
orchestration (engine.run) |
LifecycleCommand.StartDirectInvitation |
— |
AcceptApprovedIdentityChangeWorkflow |
orchestration (engine.run) |
LifecycleCommand.AcceptApprovedIdentityChange |
— |
RecoverAcceptedDirectInvitationWorkflow |
orchestration (engine.run) |
LifecycleCommand.RecoverAcceptedDirectInvitation |
— |
RecoverAuthorizedConversationWorkflow |
orchestration (engine.run) |
LifecycleCommand.RecoverAuthorizedConversation |
— |
StartRecoveryInvitationWorkflow |
orchestration (engine.run) |
LifecycleCommand.StartRecoveryInvitation |
— |
HandleContactBlockedWorkflow |
orchestration (engine.run) |
LifecycleCommand.HandleContactBlocked |
— |
HandleDirectInvitationResultWorkflow |
orchestration (engine.run) |
LifecycleCommand.HandleDirectInvitationResult |
— |
HandleIdentityResultWorkflow |
orchestration (engine.run) |
LifecycleCommand.HandleIdentityResult |
— |
RecordIncomingDirectInvitationWorkflow |
orchestration (engine.run) |
LifecycleCommand.RecordIncomingDirectInvitation |
— |
direct¶
DeleteDirectConversationWorkflow¶
- Kind: public — Chats submits
DirectConversationCommand.DeleteConversation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/direct/DeleteDirectConversationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,DirectConversationRepository,MailboxCapabilityLifecycle
stateDiagram-v2
[*] --> FindContact
FindContact --> RevokeExchange : ContactFound
FindContact --> [*] : ConversationAlreadyGone
RevokeExchange --> RevokeMailbox : ExchangeRevoked
RevokeMailbox --> DeleteConversation : MailboxRevoked
DeleteConversation --> [*] : ConversationDeleted
OpenDirectConversationWorkflow¶
- Kind: public — Chats submits
DirectConversationCommand.OpenConversation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/direct/OpenDirectConversationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,DirectConversationRepository,RequireDirectChatAuthorizationUseCase
FindConversation -> CheckAuthorization (opens the authorized chat)
FindConversation -> [CheckAuthorization] -> StartInvitation
Authorization alone is no evidence that a locally deleted chat still exists: reopening a missing chat
goes through an invitation, otherwise the other device may still wait for authorization.
stateDiagram-v2
[*] --> FindConversation
FindConversation --> CheckAuthorization : ConversationFound
FindConversation --> StartInvitation : ConversationMissing
CheckAuthorization --> [*] : Authorized
CheckAuthorization --> StartInvitation : NotAuthorized
StartInvitation --> [*] : InvitationStarted
ReconnectDirectConversationWorkflow¶
- Kind: public — Chats submits
DirectConversationCommand.ReconnectConversation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/direct/ReconnectDirectConversationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,RequireDirectReconnectAllowedUseCase,ResolveContactInvitationRoutingIdUseCase,GetIdentityPeerStateUseCase
CheckReconnectable -> PreflightRouting -> LoadAuthorization -> [RevokeExchange] -> StartInvitation
The user explicitly reconnects an EXISTING chat: a prior authorization is closed before a fresh
invitation starts. The contact, keys and conversation history are never deleted. A contact without
a phone number can still reconnect when the other installation restored the original signing identity;
routing is checked before anything is revoked.
stateDiagram-v2
[*] --> CheckReconnectable
CheckReconnectable --> PreflightRouting : Reconnectable
PreflightRouting --> LoadAuthorization : RoutingAvailable
LoadAuthorization --> RevokeExchange : Authorized
LoadAuthorization --> StartInvitation : NotAuthorized
RevokeExchange --> StartInvitation : ExchangeRevoked
StartInvitation --> [*] : InvitationStarted
RequestReauthorizationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.RequestReauthorization - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/direct/RequestReauthorizationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,DirectConversationRepository,GetIdentityPeerStateUseCase
FindConversation -> LoadAuthorization -> Reconnect (a retained chat with stale authorization)
FindConversation -> [LoadAuthorization] -> StartInvitation (no chat, or nothing to revoke)
Runs only after an actual authorization failure; a merely offline contact never reaches it.
Reconnecting is required because the plain invitation skips contacts with an authorized chat.
stateDiagram-v2
[*] --> FindConversation
FindConversation --> LoadAuthorization : ConversationExists
FindConversation --> StartInvitation : ConversationMissing
LoadAuthorization --> Reconnect : Authorized
LoadAuthorization --> StartInvitation : NotAuthorized
Reconnect --> [*] : InvitationStarted
StartInvitation --> [*] : InvitationStarted
RevokePeerExchangeWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.RevokePeerExchange - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/direct/RevokePeerExchangeWorkflow.kt - Lock: none
- Uses:
GetIdentityExchangeClosureUseCase,DeclineIdentityExchangeUseCase,DirectChatAuthorizationRevocationSender,CloseIdentityExchangeUseCase
FindExchange -> DeclineExchange -> CloseExchange (an incoming invitation is still pending)
FindExchange -> SendRevocation -> CloseExchange (the exchange is active)
FindExchange -> CloseExchange (the exchange is terminal)
Only orchestration decides whether to decline, revoke or just close the Identity-owned exchange.
stateDiagram-v2
[*] --> FindExchange
FindExchange --> CloseExchange : ExchangeFound
FindExchange --> DeclineExchange : ExchangeFound
FindExchange --> SendRevocation : ExchangeFound
FindExchange --> [*] : ExchangeFound
FindExchange --> [*] : NoExchange
DeclineExchange --> CloseExchange : ExchangeEnded
SendRevocation --> CloseExchange : ExchangeEnded
CloseExchange --> [*] : ExchangeClosed
StartDirectInvitationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.StartDirectInvitation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/direct/StartDirectInvitationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,RequireContactInvitableUseCase,GetIdentityPeerStateUseCase,DirectConversationRepository,ResolveContactInvitationRoutingIdUseCase,GetIdentityPeerDisplayNameUseCase,LocalPhoneNumberSource,StartIdentityExchangeUseCase,RecordOutgoingDirectInvitationUseCase
CheckNotBlocked -> LoadAuthorization -> LoadLabels -> StartExchange -> RecordInvitation
An authorized contact without a chat (it was deleted locally while the peer kept its keys) first goes
through FindConversation -> PreflightRouting -> RevokeExchange. Only that old conversation authorization
is revoked; remote identity, trust records and the user's own keys are never reset. An authorized
contact with a chat needs no invitation.
stateDiagram-v2
[*] --> CheckNotBlocked
CheckNotBlocked --> LoadAuthorization : NotBlocked
LoadAuthorization --> FindConversation : Authorized
LoadAuthorization --> LoadLabels : NotAuthorized
FindConversation --> [*] : ConversationExists
FindConversation --> PreflightRouting : ConversationMissing
PreflightRouting --> RevokeExchange : RoutingAvailable
RevokeExchange --> LoadLabels : ExchangeRevoked
LoadLabels --> StartExchange : LabelsLoaded
StartExchange --> RecordInvitation : ExchangeStarted
RecordInvitation --> [*] : InvitationRecorded
recovery¶
AcceptApprovedIdentityChangeWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.AcceptApprovedIdentityChange - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/recovery/AcceptApprovedIdentityChangeWorkflow.kt - Lock: none
- Uses:
RequireApprovedIdentityPinnedUseCase,ReceiveIdentityExchangeUseCase,InvalidatePendingInvitationUseCase
ValidateApproval -> CheckPinnedIdentity -> AcceptOriginalInvitation -> InvalidateStaleInvitation
The approved path never publishes INCOMING_CHALLENGE_RECEIVED, so the Identity result observer cannot
turn it into a normal invitation again. READY still activates the existing conversation later.
stateDiagram-v2
[*] --> ValidateApproval
ValidateApproval --> CheckPinnedIdentity : ApprovalValid
CheckPinnedIdentity --> AcceptOriginalInvitation : PinnedIdentityMatches
AcceptOriginalInvitation --> InvalidateStaleInvitation : OriginalInvitationAccepted
InvalidateStaleInvitation --> [*] : StaleInvitationInvalidated
RecoverAcceptedDirectInvitationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.RecoverAcceptedDirectInvitation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/recovery/RecoverAcceptedDirectInvitationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GetIdentityExchangeClosureUseCase
stateDiagram-v2
[*] --> CheckExchangeStillOpen
CheckExchangeStillOpen --> HandleResult : ExchangeStillOpen
CheckExchangeStillOpen --> [*] : NothingToRecover
HandleResult --> [*] : ResultHandled
RecoverAuthorizedConversationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.RecoverAuthorizedConversation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/recovery/RecoverAuthorizedConversationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GetIdentityPeerStateUseCase,DirectConversationRepository,GetIdentityExchangeClosureUseCase
LoadAuthorization -> FindConversation -> ActivateConversation
LoadAuthorization -> FindConversation -> CheckExchangeStillActive -> ActivateConversation
An established exchange can be persisted right before a process death, without its chat. Only the
exact, still active exchange may create the missing chat; a deliberately deleted conversation is never
resurrected from history. An existing conversation keeps its ID and messages.
stateDiagram-v2
[*] --> LoadAuthorization
LoadAuthorization --> FindConversation : Authorized
LoadAuthorization --> [*] : NothingToRecover
FindConversation --> ActivateConversation : ConversationExists
FindConversation --> CheckExchangeStillActive : ConversationMissing
CheckExchangeStillActive --> ActivateConversation : ExchangeStillActive
CheckExchangeStillActive --> [*] : NothingToRecover
ActivateConversation --> [*] : ConversationActivated
StartRecoveryInvitationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.StartRecoveryInvitation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/recovery/StartRecoveryInvitationWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GetMembershipHandshakeUseCase,DirectConversationRepository
group, owner side: FindGroupMembership -> ResumeGroupJoin
group, member side: FindGroupMembership (the offer waits in the inbox)
direct: FindGroupMembership -> EnsureConversation -> AcceptOriginalInvitation | RequestReauthorization
A group approval never becomes a direct invitation, even when its membership was withdrawn before this
ran. A direct chat shell does not grant transport authorization or release queued messages.
stateDiagram-v2
[*] --> FindGroupMembership
FindGroupMembership --> EnsureConversation : DirectApproval
FindGroupMembership --> [*] : MemberSideGroupOffer
FindGroupMembership --> ResumeGroupJoin : OwnerSideGroupJoin
FindGroupMembership --> [*] : WithdrawnGroupMembership
ResumeGroupJoin --> [*] : Done
EnsureConversation --> RequestReauthorization : OriginalInvitationUnusable
EnsureConversation --> AcceptOriginalInvitation : OriginalInvitationValid
AcceptOriginalInvitation --> [*] : Done
RequestReauthorization --> [*] : Done
result¶
HandleContactBlockedWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.HandleContactBlocked - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/result/HandleContactBlockedWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,ContactBlocklistRepository
stateDiagram-v2
[*] --> CheckStillBlocked
CheckStillBlocked --> RevokeExchange : StillBlocked
CheckStillBlocked --> [*] : Unblocked
RevokeExchange --> [*] : ExchangeRevoked
HandleDirectInvitationResultWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.HandleDirectInvitationResult - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/result/HandleDirectInvitationResultWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,AcceptIdentityExchangeUseCase,DeclineIdentityExchangeUseCase,BlockContactUseCase,LinkPhoneContactUseCase
incoming, accepted: AcceptExchange -> [LinkPhoneContact] -> ActivateConversation
incoming, declined: DeclineExchange -> [BlockContact]
outgoing, declined: DiscardWaitingMessages
Both identity setup modes create the receiver's chat and release its queued messages on acceptance.
Accepting an invitation that matched a phone book contact by its claimed number links the two.
stateDiagram-v2
[*] --> AcceptExchange
[*] --> DeclineExchange
[*] --> DiscardWaitingMessages
[*] --> IgnoreResult
AcceptExchange --> ActivateConversation : ExchangeAccepted
AcceptExchange --> LinkPhoneContact : ExchangeAccepted
LinkPhoneContact --> ActivateConversation : PhoneContactLinked
ActivateConversation --> [*] : Done
DeclineExchange --> BlockContact : ExchangeDeclined
DeclineExchange --> [*] : ExchangeDeclined
BlockContact --> [*] : Done
DiscardWaitingMessages --> [*] : Done
IgnoreResult --> [*] : Done
HandleIdentityResultWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.HandleIdentityResult - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/result/HandleIdentityResultWorkflow.kt - Lock: none
- Uses:
WorkflowEngine,GetIdentityPeerDisplayNameUseCase,HandleInvitationResponseUseCase,DirectIdentitySetupModeRepository,SendIdentityVerificationReceiptUseCase,MarkInvitationTransportFailedUseCase,InvalidatePendingInvitationUseCase
INCOMING_EXCHANGE: ResolveDisplayName -> RecordIncomingInvitation
ESTABLISHED: [MarkInvitationAccepted] -> ActivateConversation -> LoadSetupMode -> [SendVerificationReceipt]
REMOTE_DECLINED: MarkInvitationDeclined -> DiscardWaitingMessages
FAILED: MarkTransportFailed
EXCHANGE_INVALIDATED: InvalidateInvitation
Invitation acceptance, not the identity setup mode, authorizes the conversation: queued messages are
released in both modes.
stateDiagram-v2
[*] --> ResolveDisplayName
[*] --> MarkInvitationDeclined
[*] --> MarkTransportFailed
[*] --> InvalidateInvitation
ResolveDisplayName --> RecordIncomingInvitation : DisplayNameResolved
RecordIncomingInvitation --> [*] : Done
MarkInvitationAccepted --> ActivateConversation : InvitationAccepted
ActivateConversation --> LoadSetupMode : ConversationActivated
LoadSetupMode --> SendVerificationReceipt : SetupModeLoaded
LoadSetupMode --> [*] : SetupModeLoaded
SendVerificationReceipt --> [*] : Done
MarkInvitationDeclined --> DiscardWaitingMessages : InvitationDeclined
DiscardWaitingMessages --> [*] : Done
MarkTransportFailed --> [*] : Done
InvalidateInvitation --> [*] : Done
RecordIncomingDirectInvitationWorkflow¶
- Kind: internal — started by an observer, dispatcher or another workflow
LifecycleCommand.RecordIncomingDirectInvitation - Source:
feature/conversationorchestration/lifecycle/src/commonMain/kotlin/com/cbgm/sparrow/feature/conversationorchestration/lifecycle/domain/workflow/result/RecordIncomingDirectInvitationWorkflow.kt - Lock: none
- Uses:
CheckIncomingInvitationAllowedUseCase,RecordIncomingDirectInvitationUseCase,DeclineIdentityExchangeUseCase
stateDiagram-v2
[*] --> CheckAllowed
CheckAllowed --> RecordInvitation : Allowed
CheckAllowed --> DeclineExchange : Rejected
CheckAllowed --> [*] : Rejected
RecordInvitation --> [*] : InvitationRecorded
DeclineExchange --> [*] : ExchangeDeclined