package com.correx.core.approvals.domain

import com.correx.core.approvals.ApprovalOutcome
import com.correx.core.approvals.ApprovalStatus
import com.correx.core.approvals.Tier
import com.correx.core.approvals.model.ApprovalContext
import com.correx.core.approvals.model.ApprovalDecision
import com.correx.core.approvals.model.ApprovalGrant
import com.correx.core.approvals.model.DomainApprovalRequest
import kotlinx.datetime.Instant

/**
 * No-op implementation of [ApprovalEngine] used during deterministic replay.
 * Replay reconstructs approval decisions from the event log — live approval
 * evaluation must never run on the replay path.
 */
class NoOpApprovalEngine : ApprovalEngine {
    override fun evaluate(
        request: DomainApprovalRequest,
        context: ApprovalContext,
        grants: List<ApprovalGrant>,
        now: Instant,
    ): ApprovalDecision = ApprovalDecision(
        id = null,
        requestId = request.id,
        outcome = ApprovalOutcome.AUTO_APPROVED,
        state = ApprovalStatus.COMPLETED,
        tier = Tier.T0,
        contextSnapshot = context,
        resolutionTimestamp = now,
        reason = "replay — reconstructed from event log",
    )
}
