package com.correx.core.events.events

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

/**
 * A planner's structured restatement of the brief it was handed: the files it must touch, the
 * symbols it must reach, and the acceptance criteria it must satisfy. The harness diffs this echo
 * against the original brief before any plan is generated, so a divergence halts at the cheapest
 * point in the pipeline. Also reused as the diff input shape for both sides of the comparison.
 */
@Serializable
data class BriefEcho(
    val referencedFiles: Set<String> = emptySet(),
    val symbols: Set<String> = emptySet(),
    val acceptanceCriteria: Set<String> = emptySet(),
)

/**
 * A stage echoed the brief but the echo diverged from the original, so the plan is rejected
 * before generation ("halt before plan generation"). Recorded so replay explains the halt.
 *
 * - [droppedFiles] / [droppedSymbols] / [droppedAcceptanceCriteria]: present in the original brief,
 *   missing from the echo — the planner failed to carry them forward.
 * - [inventedFiles]: file paths in the echo that are not in the original brief — hallucinated paths.
 */
@Serializable
@SerialName("BriefEchoMismatch")
data class BriefEchoMismatchEvent(
    val sessionId: SessionId,
    val stageId: StageId,
    val droppedFiles: Set<String>,
    val droppedSymbols: Set<String>,
    val droppedAcceptanceCriteria: Set<String>,
    val inventedFiles: Set<String>,
) : EventPayload
