/**
 * Re-review narrowing filter + stale-SHA guard (see design.md → Component
 * Design + Error Handling → Stale prior-review SHA).
 *
 * Given the PR's prior provide-remote reviews and a `(rail, project, scope)`
 * tuple, pick the most recent matching review and decide whether the current
 * pass can narrow to `<prior_sha>..<HEAD>`. The guard runs existence + ancestry
 * checks (via an injected {@link GitInvoker}) before declaring a narrowing
 * range, so a rebased/force-pushed/shallow prior SHA never produces a
 * misleading partial range.
 */
import type { ReviewInvocation } from './marker-parser.js';
export type ReviewRail = 'ad-hoc' | 'project';
/** A prior provide-remote review, distilled from its parsed marker block. */
export interface PriorReview {
    /** Full 40-char SHA recorded by the prior review. */
    headSha: string;
    /** Scope token or the `ad-hoc` sentinel. */
    scope: string;
    /** Project path — present only for project-rail reviews. */
    project?: string;
    invocation: ReviewInvocation;
    /** ISO-8601 review submission timestamp, used for descending sort. */
    submittedAt: string;
}
/**
 * Narrow git surface needed by the guard. Callers pass a worktree-bound
 * implementation (rich-context mode) or a fetch-capable one (diff-only mode);
 * tests pass stubs.
 */
export interface GitInvoker {
    /** `git cat-file -e <sha>` — does the object exist locally? */
    objectExists(sha: string): Promise<boolean>;
    /** `git merge-base --is-ancestor <sha> <head>` — reachable from HEAD? */
    isAncestor(sha: string, head: string): Promise<boolean>;
    /** `git fetch origin <sha>:<ref>` — fetch a single ref (diff-only mode). */
    fetchRef(sha: string): Promise<boolean>;
}
export interface NarrowingInput {
    reviews: PriorReview[];
    rail: ReviewRail;
    /** Resolved project path on the project rail; `null` on the ad-hoc rail. */
    project: string | null;
    /** Current scope token, or `ad-hoc`. */
    scope: string;
    /** Current PR HEAD SHA. */
    headSha: string;
    git: GitInvoker;
    /** `--narrow` was passed explicitly: guard failure becomes a hard error. */
    forceNarrow?: boolean;
    /** `workflow.autoNarrowReReviewScope === true`: never prompt. */
    autoNarrow?: boolean;
    /** Diff-only mode (no ephemeral worktree): fetch the single ref first. */
    diffOnly?: boolean;
}
export type FullScopeReason = 'no-prior-review' | 'stale-sha';
export interface NarrowRangeResult {
    kind: 'narrow-range';
    priorSha: string;
    headSha: string;
    /** Whether the caller still owes the user a confirm prompt. */
    prompted: boolean;
}
export interface FullScopeFallbackResult {
    kind: 'full-scope-fallback';
    reason: FullScopeReason;
    /** The stale SHA that triggered the fallback, when applicable. */
    priorSha?: string;
    prompted: boolean;
}
export interface HardErrorResult {
    kind: 'hard-error';
    reason: 'stale-sha';
    priorSha: string;
}
export type NarrowingResult = NarrowRangeResult | FullScopeFallbackResult | HardErrorResult;
/**
 * Pick the narrowing target for the current re-review pass.
 */
export declare function pickNarrowingTarget(input: NarrowingInput): Promise<NarrowingResult>;
//# sourceMappingURL=narrowing.d.ts.map