/**
 * Stub-completeness verifier — detects placeholder/stub bodies in
 * emitted `.ai.ts` files and reports them as VerifyErrors so the
 * existing feedback runner re-emits real bodies.
 *
 * Why this exists:
 *   The tsc verifier catches code that DOESN'T COMPILE. It says nothing
 *   about code that compiles but ships no behavior — the dominant
 *   failure mode for smaller/open LLMs on per-owner emit:
 *     - Engine γ-stubs (LLM declined → fallback placeholder file)
 *     - LLM-emitted throw stubs ("not implemented", "TODO: ...")
 *     - LLM-emitted trivial returns (`return null as any`)
 *
 *   Empirical at 2026-05-13:
 *     - idle-meta Ollama: 58% real-LLM fill, 80 tsc errors → 0 tsc
 *       errors looks clean but 42% of bodies are stubs.
 *     - idle-meta MarrBox: 69% real-LLM fill, 40 → ? tsc errors,
 *       31% bodies still stubs.
 *
 *   Reporting stubs as VerifyErrors lets the feedback runner re-emit
 *   them with a targeted prompt. The existing rollback machinery
 *   prevents regressions if the LLM can't do better.
 *
 * Design:
 *   - Regex-only — no TS compiler API import. The `.ai.ts` files have
 *     a narrow shape: top-level `export async function NAME(...):
 *     Promise<X> { ... }` declarations. Brace-balanced extraction with
 *     a single line scanner is enough.
 *   - Conservative: ONLY flags single-statement bodies that match
 *     stub patterns. A real function body with a stub-shaped throw
 *     inside a conditional is NOT flagged.
 *   - Severity `warning` not `error` — these don't break the build,
 *     but the feedback runner counts them as errors-to-fix.
 *
 * Initial release: `enabledByDefault: false` — opt in via
 * `SPECVERSE_REALIZE_POST_VERIFY_ENABLE=stub-completeness`. Once the
 * empirical hit-rate is measured we flip default-on.
 */
import type { PostEmitVerifier } from '../types.js';
/** Stub error codes — surfaced to the feedback prompt as the verifier
 *  code; the LLM doesn't see them directly but they appear in the
 *  audit sidecar + logs. */
export declare const STUB_CODES: {
    readonly GAMMA_FALLBACK: "STUB001";
    readonly LLM_THROW: "STUB002";
    readonly TRIVIAL_RETURN: "STUB003";
    readonly EMPTY_BODY: "STUB004";
    readonly MISPLACED_BRACE: "STUB005";
};
/**
 * Find every top-level `export async function NAME(...): Promise<X> {`
 * declaration in a file and return its name + body + start-line.
 *
 * Brace counting handles nested blocks and template-literal expression
 * holes. We don't try to parse strings/regexes/comments precisely; the
 * narrow shape of `.ai.ts` files makes this safe in practice (each
 * function is independent and bodies don't contain `}` in odd places
 * at the start of a line at depth 0).
 */
interface ExtractedFunction {
    name: string;
    body: string;
    /** 1-based line number of the `export async function` declaration. */
    declLine: number;
    /** 1-based line number of the first body line (after the opening `{`). */
    bodyStartLine: number;
    /** 1-based line number of the closing `}` that ends the body. */
    endLine: number;
}
export declare function extractAsyncFunctions(source: string): ExtractedFunction[];
/**
 * Strip line + block comments and blank lines, then trim.
 * Used to normalize bodies before stub-pattern matching.
 */
export declare function stripCommentsAndBlanks(body: string): string;
export interface StubMatch {
    kind: 'gamma-fallback' | 'llm-throw' | 'trivial-return' | 'empty' | 'misplaced-brace';
    code: string;
    /** For 'misplaced-brace': a sample of the orphan code that follows
     *  the misplaced `}`. Surfaced to the LLM in the reemit prompt so it
     *  knows exactly which lines were displaced. */
    orphanPreview?: string;
}
/**
 * Detect the "misplaced `}`" emission pattern surfaced by marrbox on
 * `GameConditionController.loadGameData` (2026-05-14). When the LLM
 * emits a stray `}` right after the [PRE-BAKED] comment block, the
 * brace-walker (correctly) treats it as the function's end. The
 * function body classifies as `empty`, but the steps that were meant
 * to be inside the body are now orphan top-level code:
 *
 *   export async function loadGameData(_input: any): Promise<any> {
 *     // [PRE-BAKED] Step 1: ...
 *     // TODO: ...
 *     }                              ← misplaced
 *     // [WRITE] Step 2: ...         ← orphan
 *     const v3BaseUrl = ...;         ← orphan
 *     return { ... };                ← orphan, tsc TS1108
 *
 * The plain STUB004 message ("empty body") gives the LLM no clue why
 * its previous emission was wrong; the reemit typically repeats the
 * same mistake. STUB005's message names the specific shape so the
 * LLM can correct the brace placement.
 *
 * Heuristic: between `fn.endLine + 1` and `nextDeclLine - 1` (or EOF
 * if no next function), strip comments + blanks; if any non-trivial
 * line remains AND we see at least one of:
 *   - `// [WRITE]` or `// [PRE-BAKED]` marker (these belong INSIDE
 *     function bodies; their presence at top level is diagnostic)
 *   - a top-level `return` statement (illegal TS — TS1108)
 *   - a top-level `const`/`let`/`var` declaration that isn't followed
 *     by `export`/`function` (i.e. not a module-level binding)
 * → it's misplaced-brace orphan code.
 *
 * Returns a preview of the first ~5 orphan lines, or `null` if not
 * misplaced-brace.
 */
export declare function detectMisplacedBrace(source: string, fn: ExtractedFunction, nextDeclLine: number | null): string | null;
/**
 * Classify a function body as a stub (or not). Conservative: requires
 * the body to be a single-statement match to avoid false positives on
 * real bodies that happen to contain a throw deep inside a conditional.
 */
export declare function classifyBody(body: string): StubMatch | null;
export declare const STUB_COMPLETENESS_VERIFIER: PostEmitVerifier;
export {};
//# sourceMappingURL=stub-completeness.d.ts.map