package com.correx.core.kernel.orchestration.subagent

import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.core.kernel.orchestration.OrchestrationConfig
import com.correx.core.sessions.Session
import com.correx.core.transitions.execution.StageExecutionResult
import com.correx.core.transitions.graph.WorkflowGraph

/** One sequential one-shot subagent run for a single plan/workflow stage. */
data class SubagentRunRequest(
    val sessionId: SessionId,
    val stageId: StageId,
    val graph: WorkflowGraph,
    val session: Session,
    val config: OrchestrationConfig,
)

data class SubagentRunResult(val outcome: StageExecutionResult)

/**
 * Seam between the execution loop and "run one stage to completion." The default
 * [InSessionSubagentRunner] runs the stage in the parent session. A future
 * child-session runner can implement this interface with no caller changes.
 * Sequential by contract — callers must not invoke concurrently for one session.
 */
fun interface SubagentRunner {
    suspend fun run(request: SubagentRunRequest): SubagentRunResult
}
