import type { RunState, NextAction } from "../contracts/orchestration.js";
import type { GoalSpec, GoalEvidence, MissingCriterion, NextActionSuggestion, NextActionContract, PromptNoveltyReport } from "../contracts/goal.js";
import { evaluateEnsembleDecision, type EnsembleDecisionCandidateVote } from "../orchestration/ensemble-decision.js";
export declare function cleanupControlLoopRun(runId: string): void;
export declare function pruneControlLoopRunCaches(now?: number): void;
export declare function getControlLoopCacheStats(): {
    trackedRuns: number;
    deepseekFailureRuns: number;
    adaptiveHistoryRuns: number;
};
export interface GoalProgress {
    status: GoalSpec["status"];
    score: import("../contracts/goal.js").GoalScore;
    nextAction: NextAction;
}
export interface GoalProgressDelta {
    value: number;
    newlyPassedCriteria: string[];
    newlyPassedOptionalCriteria: string[];
    newlyValidArtifacts: string[];
    newlyFailedCriteria: string[];
    failedCriteria: string[];
    missingRequiredCriteria: string[];
    blockedNodes: string[];
    repeatedFailures: string[];
    recommendation: NextAction;
    reason: string;
    targetCriterionId?: string;
    targetNodeId?: string;
    preserveEvidence: boolean;
}
export declare function evaluateGoalProgress(goal: GoalSpec, runState: RunState): Promise<GoalProgress>;
export interface EnsembleGoalProgress extends GoalProgress {
    ensemble: ReturnType<typeof evaluateEnsembleDecision> & {
        preservedEvidence?: Array<{
            nodeId: string;
            evidence: string;
        }>;
        replanDepth?: number;
    };
    noveltyReport?: PromptNoveltyReport;
    progressDelta: GoalProgressDelta;
}
export interface DeepSeekGoalDecisionContext {
    goal: GoalSpec;
    runState: RunState;
    evidence: GoalEvidence[];
    score: import("../contracts/goal.js").GoalScore;
    signal?: AbortSignal;
}
export type DeepSeekGoalDecisionAdvisor = (context: DeepSeekGoalDecisionContext) => Promise<EnsembleDecisionCandidateVote | undefined>;
export interface DeepSeekGoalDecisionOptions {
    enabled?: boolean;
    weight?: number;
    timeoutMs?: number;
    maxTokens?: number;
    env?: NodeJS.ProcessEnv;
    fetchImpl?: typeof fetch;
    advisor?: DeepSeekGoalDecisionAdvisor;
    signal?: AbortSignal;
}
export interface GoalProgressEnsembleOptions {
    deepseek?: false | DeepSeekGoalDecisionOptions;
    signal?: AbortSignal;
}
export declare function evaluateLoopGuard(runState: RunState): {
    shouldStop: boolean;
    reason?: string;
};
export declare function evaluateAdaptiveLoopGuard(runState: RunState, progressDelta: GoalProgressDelta, _ensemble: ReturnType<typeof evaluateEnsembleDecision>): {
    shouldStop: boolean;
    reason?: string;
    forcedNextAction?: NextAction;
};
export declare function evaluateGoalProgressDelta(goal: GoalSpec, currentEvidence: GoalEvidence[], runState?: RunState, previousEvidence?: GoalEvidence[]): GoalProgressDelta;
/**
 * Evaluate goal progress using an ensemble of decision candidates.
 * Returns the consensus next action without requiring human STOP/CONTINUE input.
 */
export declare function evaluateGoalProgressEnsemble(goal: GoalSpec, runState: RunState, iterationContext?: {
    iterationCount: number;
    maxIterations: number;
}, options?: GoalProgressEnsembleOptions): Promise<EnsembleGoalProgress>;
export interface NextPromptResult {
    prompt: string;
    missingCriteria: MissingCriterion[];
    suggestion: NextActionSuggestion;
    nextActionContract: NextActionContract;
    noveltyReport: PromptNoveltyReport;
    progressDelta: GoalProgressDelta;
    memorySummary: string;
    recommendedCommands: string[];
    recommendedSkills: string[];
    verificationGates: string[];
}
export declare function recallMemoryForGoal(goal: GoalSpec, root: string, runState?: RunState, signal?: AbortSignal): Promise<string>;
export declare function generateNextPrompt(goal: GoalSpec, evidence: GoalEvidence[], runState?: RunState, memorySummary?: string, root?: string): Promise<NextPromptResult>;
/**
 * Evaluate which success criteria still lack passing evidence.
 * Returns ordered list with required criteria first, then by weight desc.
 */
/**
 * Incremental evaluation: re-evaluate progress with current evidence.
 * Suitable for calling mid-run without recomputing the full run state.
 */
export declare function evaluateGoalProgressIncremental(goal: GoalSpec, evidence: GoalEvidence[]): {
    score: import("../contracts/goal.js").GoalScore;
    suggestion: NextActionSuggestion;
};
