fix(coordinator): auto-transition participant to Ready before Completed
ReportCompletion was failing with "cannot transition to completed status" because participants were in Joined state trying to transition directly to Completed, which violates the state machine flow: Joined -> Ready -> Completed. Changes: - Check participant status before marking as Completed - Auto-transition Joined -> Ready if needed - Then transition Ready -> Completed - Add debug logging for auto-transition This fixes the error seen during keygen completion. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8e683064ed
commit
4e14212147
|
|
@ -53,7 +53,25 @@ func (uc *ReportCompletionUseCase) Execute(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// 3. Update participant status to completed
|
||||
// 3. Get participant and check current status
|
||||
participant, err := session.GetParticipant(partyID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 3.1 Ensure participant is in Ready state before marking as Completed
|
||||
// The status flow is: Joined -> Ready -> Completed
|
||||
if participant.Status == value_objects.ParticipantStatusJoined {
|
||||
// Auto-transition to Ready if currently Joined
|
||||
if err := session.UpdateParticipantStatus(partyID, value_objects.ParticipantStatusReady); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logger.Debug("auto-transitioned participant to ready",
|
||||
zap.String("session_id", session.ID.String()),
|
||||
zap.String("party_id", inputData.PartyID))
|
||||
}
|
||||
|
||||
// 3.2 Update participant status to completed
|
||||
if err := session.UpdateParticipantStatus(partyID, value_objects.ParticipantStatusCompleted); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -67,10 +85,6 @@ func (uc *ReportCompletionUseCase) Execute(
|
|||
}
|
||||
|
||||
// 4. Update participant's public key if provided
|
||||
participant, err := session.GetParticipant(partyID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(inputData.PublicKey) > 0 {
|
||||
participant.SetPublicKey(inputData.PublicKey)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue