/** * LLM-Judge Reranker (Phase 7a, plan item 7a). * * Re-scores the top-K (`search.rerank.rerankWindow`, default 50) results of a * fused/centrality-boosted list via a single `llmObject` call with a strict zod * schema. The returned `rankedIds` is a permutation guide: * - ids present in both verdict + window → placed in LLM order. * - ids missing from the verdict → appended in their original order. * - duplicate ids in the verdict → first occurrence wins, rest dropped. * * Contract (cross-cutting §1 + spec R7A-02): * - Default-off via `config.search.rerank.enabled`. * - Silent degradation: on `!isLlmEnabled()`, `{ok:false}`, or any throw, * returns the input list VERBATIM (no re-order, no drop). Never throws to * the caller (SearchController). Logged at warn. * - Only the top-K window is re-ordered; the tail (rank > window) is * concatenated unchanged. Final list length == input length (rerank never * drops results). * * Pure over inputs + the injected LLM surface, so tests inject fakes without * touching config or network (design.md §7). */ import { z } from "zod"; import type { SearchResult } from "@massa-th0th/shared"; import type { QueryLlmSurface } from "./query-understanding.js"; /** The LLM returns an ordered id list. Non-empty array of strings. */ export declare const RerankVerdictSchema: z.ZodObject<{ rankedIds: z.ZodArray; }, z.core.$strip>; export type RerankVerdict = z.infer; /** * LLM-judge reranker. Stateless; the `llm` surface is injectable for tests. */ export declare class LLMJudgeReranker { private readonly llm; constructor(llm?: QueryLlmSurface); /** * Re-order the top-K (`window`) of `results` per the LLM verdict. * * - When `!isLlmEnabled()` OR the feature is off OR `window <= 0`, returns * `results` verbatim. * - On `{ok:false}` or throw, returns `results` verbatim (logged at warn). * - Empty input → empty output (no-op). * * `window` defaults to `config.search.rerank.rerankWindow` (50). Callers may * pass an explicit value for tests / tighter budgets. */ rerank(query: string, results: SearchResult[], window?: number): Promise; } /** * Apply the verdict permutation to the head: * - ids in the verdict AND in head → placed in verdict order. * - ids in the verdict but NOT in head → ignored. * - duplicate ids in the verdict → first occurrence wins. * - head ids missing from the verdict → appended in original order. * Result length == head.length (no drops, no additions). */ export declare function applyVerdict(head: SearchResult[], rankedIds: string[]): SearchResult[]; //# sourceMappingURL=reranker.d.ts.map