import { type WorkflowStep } from './workflow.js';
import { type RawPRCommit } from '../github/client.js';
export type StepRecordType = 'review' | 'recheck' | 'fix' | 'conflict-resolve';
export interface StepRecord {
    type: StepRecordType;
    /** APPROVE | NEEDS_WORK | BLOCK — from annotation or parsed from body */
    verdict?: string;
    /** PR head SHA when this step ran (review/recheck only; absent on older comments) */
    sha?: string;
    /** SHA the fix commit pushed to (fix records only; parsed from the commit URL in the body) */
    pushedSha?: string;
    round: number;
    commentId: number;
    commentBody: string;
    /** ISO 8601 timestamp from GitHub */
    createdAt: string;
    reviewer?: string;
    model?: string;
    /** Pre-computed next workflow step from the annotation (review/recheck only) */
    next_step?: string;
    /** Where this record was reconstructed from. */
    source?: 'comment' | 'commit';
}
export interface NextStepResult {
    /** Next workflow step to execute, or null when the workflow is complete. */
    step: WorkflowStep | null;
    /** For fix/recheck steps: the review comment to use as working context. */
    reviewComment?: {
        id: number;
        body: string;
    };
    /** True when at least one review or recheck comment exists on the PR. */
    hasExistingReview: boolean;
    /** Round number the next step should run as. */
    round: number;
    /** Full parsed history in chronological order. */
    history: StepRecord[];
}
export declare function commitToRecord(commit: RawPRCommit): StepRecord | null;
/**
 * Fetch all crosscheck step records from PR comments and crosscheck commit
 * trailers in chronological order.
 * All HTTP calls go through github/client.ts.
 *
 * Fast path (new annotations with next_step):
 *   1. Fetch the last page to find the most recent review/recheck annotation.
 *   2. If it carries next_step, fetch only comments after it (?since=) to check for
 *      trailing fix markers — skipping the entire earlier thread.
 *
 * Full scan fallback (legacy annotations without next_step):
 *   Read all pages from page 1.
 */
export declare function fetchStepHistory(owner: string, repo: string, prNumber: number, token: string): Promise<StepRecord[]>;
/**
 * Given the PR's step history and the current HEAD SHA, determine which workflow
 * step should run next.
 *
 * The algorithm replays the history from the end:
 *  1. No review/recheck on record → start from the first workflow step.
 *  2. Any non-APPROVE review/recheck without a later fix → fix is next.
 *  3. A fix after the last review/recheck → recheck is next.
 *  4. Current SHA has not been analyzed after the initial review → recheck is next.
 *  5. Current SHA already reviewed → walk the workflow steps that follow
 *     and return the first whose `when` condition evaluates to true and
 *     that hasn't already been completed in history.
 */
export declare function identifyNextWorkflowStep(history: StepRecord[], steps: WorkflowStep[], currentSha: string): NextStepResult;
//# sourceMappingURL=pr-workflow-state.d.ts.map