/** * ollama_corpus_rerank — post-retrieval re-sort utility. * * Takes the hits array from a prior ollama_corpus_search (or equivalent * shape) and re-ranks by one of three cheap, LLM-free strategies: * * - "recency" : newer file mtime ranks higher (stats the file on disk) * - "path_specificity" : more path segments ranks higher * - "lexical_boost" : substring match of lexical_terms in preview / * heading_path / title, case-insensitive with * word-boundary matching, pushes hits up * * The original score is preserved on each hit so callers can diff/inspect; * a `rerank_score` + `rank` are appended. No embed calls, no file reads * except in the `recency` mode. */ import { z } from "zod"; import type { Envelope } from "../envelope.js"; import type { RunContext } from "../runContext.js"; export declare const RERANK_MODES: readonly ["recency", "path_specificity", "lexical_boost"]; export type RerankMode = (typeof RERANK_MODES)[number]; /** * Input hit shape — mirrors the shape ollama_corpus_search emits. We * don't reuse its type because callers may pass hits from other sources * (synthetic, filtered, deduped) and a too-strict schema would reject * legitimate inputs. */ declare const inputHitSchema: z.ZodObject<{ id: z.ZodString; path: z.ZodString; score: z.ZodNumber; chunk_index: z.ZodNumber; preview: z.ZodOptional; heading_path: z.ZodOptional>; title: z.ZodOptional>; }, z.core.$strip>; export declare const corpusRerankSchema: z.ZodObject<{ hits: z.ZodArray; heading_path: z.ZodOptional>; title: z.ZodOptional>; }, z.core.$strip>>; rerank_by: z.ZodEnum<{ recency: "recency"; path_specificity: "path_specificity"; lexical_boost: "lexical_boost"; }>; lexical_terms: z.ZodOptional>; }, z.core.$strip>; export type CorpusRerankInput = z.infer; export type CorpusRerankHit = z.infer; export interface RerankedHit extends CorpusRerankHit { /** The new score produced by the rerank strategy. */ rerank_score: number; /** The hit's original input-order position (1-based) for diff/inspection. */ original_rank: number; /** The hit's new rank after sorting by rerank_score (1-based). */ rank: number; } export interface CorpusRerankResult { hits: RerankedHit[]; rerank_by: RerankMode; } export declare function handleCorpusRerank(input: CorpusRerankInput, ctx: RunContext): Promise>; export {}; //# sourceMappingURL=corpusRerank.d.ts.map