import { type SpecTerminationStrategy } from './spec-service.js'; import { type EvaluatorVerdictEnvelope } from './evaluator-dispatcher.js'; import { type MonotonicScoreRow, type MonotonicReport } from './monotonic-guard.js'; export type RunDriverCode = 'RUN_OK' | 'RUN_OK_REGRESSION' | 'SPEC_NOT_FOUND' | 'SPEC_INVALID' | 'UNKNOWN_TERMINATION_STRATEGY' | 'MONOTONICITY_VIOLATION' | 'EVALUATOR_THREW' | 'LOCKED' | 'EVALUATOR_UNKNOWN' | 'RUN_FAILED'; export interface RunDriverOptions { readonly projectRoot: string; readonly sid: string; readonly rid: string; /** Monotonic threshold (0..1). Default 0.05. */ readonly threshold?: number; /** Override the strategy (otherwise read from spec.yaml). */ readonly strategyOverride?: SpecTerminationStrategy; /** Override max-cycles (otherwise read from spec.yaml). */ readonly maxCyclesOverride?: number; /** When true, persist cycle rows + a summary.json to disk. Default true. */ readonly persist?: boolean; /** Test seam: when set, used as the dispatch path instead of `node bin/peaks.js`. */ readonly peaksBin?: string; /** Test seam: when set, replaces the per-evaluator dispatcher (no shell-out). */ readonly dispatchOverride?: (kind: string, ctx: { projectRoot: string; rid: string; sid: string; }) => EvaluatorVerdictEnvelope; } export interface CycleRecord { readonly cycle: number; readonly rows: readonly MonotonicScoreRow[]; readonly persistedAt: string | null; readonly monotonicReport: MonotonicReport; } export interface RunDriverResult { readonly code: RunDriverCode; readonly ok: boolean; readonly message: string; readonly strategy: SpecTerminationStrategy | 'unknown'; readonly maxCycles: number; readonly cycles: readonly CycleRecord[]; readonly finalReport: MonotonicReport | null; readonly summary: { readonly reachedMaxCycles: boolean; readonly regressionCount: number; readonly totalCycles: number; }; } /** Test seam: clear in-process locks between test cases. */ export declare function _clearRunLocks(): void; /** Compose the cycle dir used for the writer (kept distinct from the * slice dir so we can co-locate the per-cycle summary without * overloading the monotonic-runner writer's `cycle-N.json`). */ export declare function cyclesDir(projectRoot: string, sid: string, rid: string): string; /** Top-level entry point — `peaks loop run `. * * Returns a `RunDriverResult` (the CLI layer maps `code → exit * code` + printResult envelope). The function is intentionally * non-throwing; per-cycle errors are captured as * `code = EVALUATOR_THREW` but the loop continues to the next cycle * so the caller sees a complete picture. */ export declare function runLoop(options: RunDriverOptions): RunDriverResult; /** CLI helper: resolve the project root, sid, and rid from a * `(project, session, rid)` triple. */ export declare function resolveRunContext(opts: { project?: string; session: string; rid: string; }): { projectRoot: string; sid: string; rid: string; };