package com.correx.core.events.events

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

/**
 * The architect's validated execution_plan was compiled into a runnable WorkflowGraph and
 * locked as the baseline for phase 2. [planArtifactId] points at the validated plan JSON in
 * CAS (referenced, not inlined); [stageIds]/[startStageId] pin the compiled shape so replay
 * rebuilds the identical graph. Soft lock: later high-priority steering can still preempt.
 */
@Serializable
@SerialName("ExecutionPlanLocked")
data class ExecutionPlanLockedEvent(
    val sessionId: SessionId,
    val planArtifactId: ArtifactId,
    val workflowId: String,
    val stageIds: List<String>,
    val startStageId: String,
) : EventPayload

/**
 * The architect's execution_plan could not become the phase-2 graph: content missing,
 * compile/validation failure, or operator rejection at the plan-review gate. Terminal for
 * the freestyle run unless re-planned; recorded so replay explains why phase 2 never ran.
 */
@Serializable
@SerialName("ExecutionPlanRejected")
data class ExecutionPlanRejectedEvent(
    val sessionId: SessionId,
    val reason: String,
    /** "compile" | "missing_content" | "operator" */
    val source: String,
) : EventPayload
