package com.correx.core.kernel.orchestration

import com.correx.core.approvals.domain.ApprovalEngine
import com.correx.core.context.builder.ContextPackBuilder
import com.correx.core.inference.InferenceRouter
import com.correx.core.risk.RiskAssessor
import com.correx.core.toolintent.FileSystemWorldProbe
import com.correx.core.toolintent.ToolCallAssessor
import com.correx.core.toolintent.WorkspacePolicy
import com.correx.core.toolintent.WorldProbe
import com.correx.core.tools.contract.ToolExecutor
import com.correx.core.tools.registry.ToolRegistry
import com.correx.core.transitions.evaluation.PromptResolver
import com.correx.core.transitions.resolution.TransitionResolver
import com.correx.core.validation.pipeline.ValidationPipeline

data class OrchestratorEngines(
    val transitionResolver: TransitionResolver,
    val contextPackBuilder: ContextPackBuilder,
    val inferenceRouter: InferenceRouter,
    val validationPipeline: ValidationPipeline,
    val approvalEngine: ApprovalEngine,
    val riskAssessor: RiskAssessor,
    val promptResolver: PromptResolver = PromptResolver { "" },
    val toolExecutor: ToolExecutor? = null,
    val toolRegistry: ToolRegistry? = null,
    val toolCallAssessor: ToolCallAssessor? = null,
    val workspacePolicy: WorkspacePolicy? = null,
    val worldProbe: WorldProbe = FileSystemWorldProbe(),
    val workspaceToolRegistryProvider: WorkspaceToolRegistryProvider? = null,
    // Runs operator-configured static-analysis commands as a harness step (role-reliability §5).
    // Null = no static-first step; a stage declaring `static_analysis` then no-ops with a warning.
    val staticAnalysisRunner: StaticAnalysisRunner? = null,
    val lspDiagnosticsRunner: LspDiagnosticsRunner? = null,
    // Evaluates Gate 2 contract assertions against a stage's produced files (design §1). Null = no
    // contract gate; the deterministic funnel then rests on produces-presence + static analysis only.
    val contractAssertionEvaluator: ContractAssertionEvaluator? = null,
    // Compiles a stage's produced execution_plan as a post-stage gate (plan-compile gate). Null = no
    // gate; a compile-invalid plan then falls through to the post-planning compiler, which historically
    // parked the session in ACTIVE. Wired, it fails the architect stage retryably so the existing
    // retry-feedback loop hands the compiler error back for self-correction.
    val planCompilationCheck: PlanCompilationCheck? = null,
    // Gate 3 semantic (LLM) reviewer, run last over a stage's static-clean produced files (design §
    // Gate 3). Null = no semantic review; the funnel then rests on the deterministic gates only. A
    // stage opts in via StageConfig.semanticReview.
    val semanticReviewer: SemanticReviewer? = null,
    // Hybrid-exhaustion salvage judge (design 2026-07-06-per-gate-retry-budgets.md §3/T7), consulted
    // only when the "review" gate exhausts its retry budget. Null = no LLM judge wired; the
    // orchestrator then falls back to a deterministic allow-one-reset-then-fail policy.
    val salvageJudge: SalvageJudge? = null,
    // One-shot post-failure diagnostic (design task #294), consulted once per terminal-failure
    // fingerprint just before a run becomes terminal. Null = no diagnostic; the run fails terminally
    // as before (deterministic degrade).
    val postFailureDiagnoser: PostFailureDiagnoser? = null,
)
