package com.correx.core.events.events

import com.correx.core.events.execution.RetryPolicy
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("WorkflowStarted")
data class WorkflowStartedEvent(
    val sessionId: SessionId,
    val workflowId: String,
    val startStageId: StageId,
    val retryPolicy: RetryPolicy? = null,
) : EventPayload

@Serializable
@SerialName("WorkflowCompleted")
data class WorkflowCompletedEvent(
    val sessionId: SessionId,
    val terminalStageId: StageId,
    val totalStages: Int,
) : EventPayload

@Serializable
@SerialName("WorkflowFailed")
data class WorkflowFailedEvent(
    val sessionId: SessionId,
    val stageId: StageId,
    val reason: String,
    val retryExhausted: Boolean,
) : EventPayload

@Serializable
@SerialName("OrchestrationPaused")
data class OrchestrationPausedEvent(
    val sessionId: SessionId,
    val stageId: StageId,
    val reason: String,   // e.g. "APPROVAL_PENDING", "USER_REQUESTED"
) : EventPayload

@Serializable
@SerialName("OrchestrationResumed")
data class OrchestrationResumedEvent(
    val sessionId: SessionId,
    val stageId: StageId,
) : EventPayload

@Serializable
@SerialName("RetryAttempted")
data class RetryAttemptedEvent(
    val sessionId: SessionId,
    val stageId: StageId,
    val attemptNumber: Int,
    val maxAttempts: Int,
    val failureReason: String,
) : EventPayload
