/**
 * Post-emit feedback runner.
 *
 * After all per-owner emits complete, this orchestrator:
 *   1. Runs all applicable verifiers against the realized output
 *   2. Groups errors by source file → owning entity
 *   3. For each owner with errors, asks the caller to re-emit the
 *      file via the provided `reemit` callback (with errors + previous
 *      content as context — the caller builds the LLM prompt)
 *   4. Re-runs verifiers + records per-pass deltas
 *   5. Bounded retries (default 1 pass)
 *
 * The runner is intentionally framework-agnostic: it does NOT call any
 * specific LLM provider or import the per-owner-emit module. The
 * caller wires `reemit` to whatever re-emission path makes sense for
 * the project. This keeps the runner testable in isolation and
 * forward-compatible with future re-emit strategies.
 *
 * Rollback policy: if a re-emit INCREASES error count for that file,
 * the runner rolls back to the previous content. The LLM doesn't get
 * to make things worse.
 */
import type { SpecGapEntry, TreatmentSelector, TreatmentStrategy, VerifyContext, VerifyError } from './types.js';
export interface ReemitRequest {
    /** Resolved owner name (e.g. `AuthController`). */
    ownerName: string;
    /** Source file path RELATIVE to outputDir (e.g.
     *  `backend/src/behaviors/AuthController.ai.ts`). */
    file: string;
    /** Errors specific to this file. */
    errors: VerifyError[];
    /** Current file content (as written by per-owner-emit). */
    previousContent: string;
}
export type Reemit = (req: ReemitRequest) => Promise<string | null>;
export interface FeedbackRunOptions {
    /** Max number of feedback passes. Each pass = run verifiers, attempt
     *  re-emits for all errored files, re-run verifiers. Default 1. */
    maxPasses?: number;
    /** Map file path → owner name. Defaults to extracting from
     *  `behaviors/<OwnerName>.ai.ts` (the SpecVerse TypeScript layout). */
    mapFileToOwner?: (file: string) => string | null;
    /**
     * Maximum number of distinct files to re-emit PER PASS. Bounds LLM
     * spend on pathological codebases. When more files have errors than
     * the cap allows, the runner picks the first N (deterministic by
     * file order) and skips the rest. Skipped files are recorded as
     * `ownersOverBudget` in the pass result. Default 20.
     *
     * Set via env: `SPECVERSE_REALIZE_POST_VERIFY_MAX_FILES=N`.
     */
    maxFilesPerPass?: number;
    /**
     * Set of verifier ids to enable in addition to the
     * `enabledByDefault: true` set. Used to opt in to experimental
     * verifiers like `stub-completeness` (default-off until empirically
     * validated). Passed straight through to `runAllVerifiers`.
     *
     * Set via env: `SPECVERSE_REALIZE_POST_VERIFY_ENABLE=id1,id2`.
     */
    enabledOverrides?: Set<string>;
    /**
     * Treatment selector — decides per-error whether to auto-reemit,
     * surface as spec gap, or skip. Defaults to
     * `defaultTreatmentSelector` (Phase 2 of
     * 2026-05-13-VERIFIER-DIAGNOSTIC-TREATMENT-SPLIT).
     *
     * Override at the call site for advanced cases (custom verifiers,
     * stricter / more permissive LLM tolerance profiles).
     */
    treatmentSelector?: TreatmentSelector;
}
export interface PassResult {
    passNumber: number;
    errorsBefore: number;
    errorsAfter: number;
    ownersAttempted: number;
    ownersImproved: number;
    ownersUnchanged: number;
    ownersRolledBack: number;
    ownersUnmappable: number;
    ownersReemitFailed: number;
    /** Files that had errors but exceeded the maxFilesPerPass budget. */
    ownersOverBudget: number;
}
export interface FeedbackRunResult {
    initialErrors: VerifyError[];
    finalErrors: VerifyError[];
    passes: PassResult[];
    verifierNotes: Array<{
        verifierId: string;
        notes: string[];
    }>;
    /** Errors classified `surface-spec-gap` by the treatment selector —
     *  these are NOT auto-fixed; the caller writes them to the
     *  realize-quality.json sidecar's `specGaps` field for user review. */
    specGaps: SpecGapEntry[];
}
/**
 * Default file→owner mapping for the SpecVerse TypeScript layout:
 *   `backend/src/behaviors/<Owner>.ai.ts` → `<Owner>`
 *   `<anything>/<Owner>.ai.ts` → `<Owner>` (relaxed fallback)
 * Returns null for files that don't match.
 */
export declare function defaultMapFileToOwner(file: string): string | null;
/**
 * Default treatment policy (Phase 2 of
 * 2026-05-13-VERIFIER-DIAGNOSTIC-TREATMENT-SPLIT):
 *
 *   - `STUB002` (LLM-throw stubs) → `surface-spec-gap`. The LLM already
 *     signaled "I lack context for this action" via the throw message;
 *     re-prompting either no-ops or hallucinates cross-file regressions.
 *     Better to tell the user about the gap so they can adjust the
 *     spec / manifest / provider choice.
 *
 *   - Everything else (tsc errors, STUB001 γ-fallback, STUB003 trivial-
 *     return, STUB004 empty-body, STUB005 misplaced-brace, future
 *     codes) → `auto-reemit`.
 *
 * Override at the call site for testing or for advanced policies.
 */
export declare function defaultTreatmentSelector(error: VerifyError): TreatmentStrategy;
export declare function runPostEmitFeedback(ctx: VerifyContext, reemit: Reemit, options?: FeedbackRunOptions): Promise<FeedbackRunResult>;
//# sourceMappingURL=feedback-runner.d.ts.map