package com.correx.core.journal.model

import kotlinx.serialization.Serializable

enum class Salience { HIGH, LOW }

enum class DecisionKind {
    INTENT, STEERING, PREEMPT, APPROVAL, TRANSITION, RETRY, FAILURE, ARTIFACT;

    fun salience(): Salience = when (this) {
        INTENT, STEERING, PREEMPT, APPROVAL, FAILURE -> Salience.HIGH
        TRANSITION, RETRY, ARTIFACT -> Salience.LOW
    }
}

/**
 * One distilled decision. [sequence] is the source event's sessionSequence, used for
 * stable ordering. [summary] is a single human/agent-readable line. Bounded by the
 * count of *distinct decisions*, not raw events — only the six decision-bearing event
 * types produce a record.
 */
@Serializable
data class DecisionRecord(
    val sequence: Long,
    val kind: DecisionKind,
    val summary: String,
    val stageId: String? = null,
    // TRANSITION only: the stage the workflow advanced FROM. Lets the renderer tell that a
    // stage's earlier RETRY records are resolved (the stage was eventually left successfully)
    // and fold them to a single summary line.
    val fromStageId: String? = null,
)
