package com.correx.core.approvals.model

import com.correx.core.approvals.ApprovalOutcome
import com.correx.core.approvals.ApprovalStatus
import com.correx.core.approvals.Tier
import com.correx.core.approvals.UserSteering
import com.correx.core.events.types.ApprovalDecisionId
import com.correx.core.events.types.ApprovalRequestId
import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable

@Serializable
data class ApprovalDecision(
    val id: ApprovalDecisionId?,
    val requestId: ApprovalRequestId,
    val outcome: ApprovalOutcome?,
    val state: ApprovalStatus,
    val tier: Tier,
    val contextSnapshot: ApprovalContext,
    val resolutionTimestamp: Instant?,
    val reason: String?,
    val userSteering: UserSteering? = null
) {
    val isFinal: Boolean get() = state != ApprovalStatus.PENDING
    val isApproved: Boolean get() = outcome == ApprovalOutcome.APPROVED || outcome == ApprovalOutcome.AUTO_APPROVED
}
