import type { Config } from '../config/schema.js';
import { type CommitStatusDetail } from '../github/client.js';
export type Freshness = 'stale' | 'not_stale';
export type ReviewState = 'NEEDS_REVIEW' | 'NEEDS_FIX' | 'NEEDS_RECHECK' | 'APPROVED';
export type NextAction = 'review' | 'fix' | 'recheck' | 'merge' | null;
export type ReviewVerdict = 'UNREVIEWED' | 'APPROVE' | 'NEEDS_WORK' | 'BLOCK';
export type CrosscheckVerdict = 'APPROVE' | 'NEEDS_WORK' | 'BLOCK';
export interface CrosscheckAnnotation {
    marker?: string;
    origin?: string;
    reviewer?: string;
    verdict?: CrosscheckVerdict;
    type?: string;
    sha?: string;
}
export interface PRActivityComment {
    body: string;
    createdAt: string;
    updatedAt?: string;
}
export interface PRActivityCommit {
    sha: string;
    committedAt: string;
}
export interface PRActivityTimestamp {
    state?: string;
    name?: string;
    conclusion?: string | null;
    status?: string | null;
    updatedAt: string;
}
export interface PRWorkflowLogEvent {
    ts: string;
    event: string;
    repo?: string;
    pr?: number;
    verdict?: string | null;
    applied_count?: number;
    conflicts_resolved?: number;
    last_verdict?: string | null;
    [key: string]: unknown;
}
export interface PRStatusInput {
    owner: string;
    repo: string;
    number: number;
    title: string;
    author: string;
    url: string;
    headSha: string;
    headRef: string;
    headRepo?: string | null;
    baseRef: string;
    prUpdatedAt: string;
    comments: PRActivityComment[];
    reviewComments: PRActivityComment[];
    commits: PRActivityCommit[];
    commitStatuses: CommitStatusDetail[];
    checkRuns: PRActivityTimestamp[];
    timelineEvents: PRActivityTimestamp[];
    logEvents: PRWorkflowLogEvent[];
    merge?: PRMergeSummary;
}
export interface PRMergeSummary {
    mergeable: boolean | null;
    mergeStateStatus?: string;
    protectedBase: boolean | null;
}
export interface ScanPRStatus {
    owner: string;
    repo: string;
    number: number;
    title: string;
    author: string;
    url: string;
    headSha: string;
    headRef: string;
    headRepo?: string | null;
    baseRef: string;
    freshness: Freshness;
    reviewState: ReviewState;
    nextAction: NextAction;
    lastActiveAt: string;
    staleAfterMs: number;
    ageMs: number;
    verdict: ReviewVerdict;
    latestAnnotation: CrosscheckAnnotation | null;
    merge?: PRMergeSummary;
}
export interface ScanSummary {
    total: number;
    stale: number;
    not_stale: number;
    actionable: number;
}
export interface ScanResult {
    scannedAt: string;
    staleAfterMs: number;
    scopeHash?: string;
    cached: boolean;
    summary: ScanSummary;
    prs: ScanPRStatus[];
}
export interface DeriveStatusOptions {
    nowMs: number;
    staleAfterMs: number;
}
export interface ScanOpenPRStatusesOptions {
    now?: Date;
    staleAfterMs: number;
}
export declare function parseCrosscheckAnnotation(body: string): CrosscheckAnnotation | null;
export declare function derivePRStatus(input: PRStatusInput, options: DeriveStatusOptions): ScanPRStatus;
export declare function summarizeStatuses(prs: ScanPRStatus[]): ScanSummary;
export declare function scanOpenPRStatuses(config: Config, token: string, options: ScanOpenPRStatusesOptions): Promise<ScanResult>;
export declare function loadWorkflowLogEvents(logDir?: string): PRWorkflowLogEvent[];
export declare function filterLogEventsForPR(events: PRWorkflowLogEvent[], owner: string, repo: string, pr: number): PRWorkflowLogEvent[];
export type PRReviewState = 'NEEDS_REVIEW' | 'APPROVED' | 'NEEDS_FIX' | 'FIX_IN_PROGRESS' | 'NEEDS_RECHECK';
export type PRNextAction = 'review' | 'fix' | 'recheck' | 'none';
export type PRVerdict = 'APPROVE' | 'NEEDS_WORK' | 'BLOCK';
export interface PRStatusCommit {
    sha: string;
    committedAt?: string;
    committed_at?: string;
}
export interface PRStatusCommitStatus {
    context: string;
    state: string;
    updatedAt?: string;
    updated_at?: string;
}
export interface PRStatusPullRequest {
    owner: string;
    repo: string;
    number: number;
    title: string;
    author: string;
    headSha: string;
    headRef: string;
    headRepo: string | null;
    baseRef: string;
    body: string | null;
    createdAt: string;
    created_at?: string;
    updatedAt?: string;
    updated_at?: string;
    commits?: PRStatusCommit[];
    commitStatuses?: PRStatusCommitStatus[];
    statuses?: PRStatusCommitStatus[];
}
export interface PRStatusComment {
    id: number;
    body: string;
    createdAt?: string;
    created_at?: string;
    updatedAt?: string;
    updated_at?: string;
}
export interface PRStatusLogEvent {
    ts?: string;
    level?: string;
    event: string;
    repo?: string;
    pr?: number;
    sha?: string;
    headSha?: string;
    head_sha?: string;
    step_type?: string;
    type?: string;
    verdict?: string | null;
    applied_count?: number;
    tokens_used?: number;
    [key: string]: unknown;
}
export interface TokenBucket {
    review: number;
    fix: number;
    recheck: number;
    total: number;
}
export interface TokenTotals {
    byPR: Record<string, TokenBucket>;
    byPRHeadSha: Record<string, TokenBucket>;
}
export interface PRProgressStep {
    kind: 'cr' | 'fix' | 'recheck';
    at: Date;
    verdict?: PRVerdict;
    appliedCount?: number;
    tokens?: number;
}
export interface PRStatus {
    pr: PRStatusPullRequest;
    state: PRReviewState;
    nextAction: PRNextAction;
    verdict: PRVerdict | null;
    lastActive: Date;
    tokenTotals: TokenBucket;
    progress: PRProgressStep[];
    stale?: boolean;
}
export declare function computeTokenTotals(logEvents: PRStatusLogEvent[]): TokenTotals;
export declare function computeLastActive(pr: PRStatusPullRequest, comments: PRStatusComment[], logEvents: PRStatusLogEvent[]): Date;
export declare function foldPRStatus(pr: PRStatusPullRequest, comments: PRStatusComment[], logEvents: PRStatusLogEvent[]): PRStatus;
export declare function isStale(status: PRStatus, staleAfter: number): boolean;
export declare function buildProgressSummary(status: PRStatus): string;
//# sourceMappingURL=pr-status.d.ts.map