import type { Result, WorkflowError, WorkflowGateMode, WorkflowPhase, WorkflowPhaseRecord, WorkflowPhaseStatus, WorkflowRunRecord } from '../types/index.js';
export type WorkflowRunOptions = {
    storyId: string;
    gates: WorkflowGateMode;
    maxIterations: number;
    profiles?: string[];
};
export type PhaseOutcome = {
    kind: 'done';
    notes: string;
} | {
    kind: 'qa-fail';
    notes: string;
} | {
    kind: 'reject';
    targetPhase: WorkflowPhase;
    findings: string;
} | {
    kind: 'gate-pause';
    reviewId: string;
} | {
    kind: 'decompose';
    voter: 'ba' | 'ta';
    reason: string;
    suggestedSplits: string[];
};
export declare function workflowRunPath(cwd: string): string;
export declare function createWorkflowRun(cwd: string, opts: WorkflowRunOptions): WorkflowRunRecord;
export declare function readWorkflowRun(cwd: string, id: string): WorkflowRunRecord | undefined;
export declare function advanceWorkflow(cwd: string, run: WorkflowRunRecord, phase: WorkflowPhase, outcome: PhaseOutcome): Result<WorkflowRunRecord, WorkflowError>;
export declare function initPhase(cwd: string, run: WorkflowRunRecord, phase: WorkflowPhase, rejectionContext?: string): WorkflowPhaseRecord;
export declare function listWorkflowRuns(cwd: string): WorkflowRunRecord[];
export declare function pausedPhaseAndNext(run: WorkflowRunRecord, cwd?: string): {
    pausedPhase: WorkflowPhase;
    nextPhase: WorkflowPhase;
    reviewId: string;
} | undefined;
export type CorrectionReturn = {
    reviewId: string;
    returnTarget: WorkflowPhase;
    findings?: string;
    correctionIteration: number;
};
export declare function detectCorrectionReturn(cwd: string, run: WorkflowRunRecord): CorrectionReturn | undefined;
export declare function midPhaseGates(run: WorkflowRunRecord): Array<{
    phase: WorkflowPhase;
    reviewId: string;
}>;
export declare function updatePhaseStatus(cwd: string, run: WorkflowRunRecord, phase: WorkflowPhase, status: WorkflowPhaseStatus, extra?: {
    clarificationIds?: string[];
}): WorkflowRunRecord;
export declare function addMidPhaseGate(cwd: string, run: WorkflowRunRecord, phase: WorkflowPhase, reviewId: string): WorkflowRunRecord;
/**
 * Roll back a run to `targetPhase` (inclusive).
 *
 * All phase records from `targetPhase` onward are removed so the run can
 * be re-executed from that phase via `workflow run --resume`. The run
 * status is reset to `running` and the rollback reason is recorded.
 */
export declare function rollbackWorkflowRun(cwd: string, run: WorkflowRunRecord, targetPhase: WorkflowPhase, reason: string): Result<WorkflowRunRecord, WorkflowError>;
