/** * Deterministic recall ranking. (change: improve-recall-retrieval-ranking) * * Replaces `recall`'s binary substring token-overlap with a field-weighted, * graded, identifier-aware ranker — still 100% deterministic: no LLM, no * embedding, no learned model. Two transferable ideas from the agent-memory * field survive the determinism constraint (field weighting, identifier-aware * normalization); the exact-anchor boost is OpenLore-native — it knows a memory * is *about* a specific symbol, a signal a lexical-only ranker lacks. * * Pure functions only, so the whole ranker is unit-testable in isolation. The * weights and stopword set below are fixed, documented constants — not learned, * not tuned at runtime, not derived from usage. */ /** * Fixed scoring weights. A match in a stronger field contributes more than a * match in a weaker one (anchor symbol > tags > anchor file path > content). */ export declare const FIELD_WEIGHTS: { readonly anchorSymbol: 4; readonly tag: 3; readonly anchorFile: 2; readonly content: 1; }; /** Strong boost when the query names the exact symbol a memory is anchored to. */ export declare const ANCHOR_EXACT_BOOST = 8; /** Graded, but capped so one token repeated many times can't dominate. */ export declare const OCCURRENCE_CAP = 3; /** * Per-substring contribution of the legacy fallback, applied ONLY when the * token-based score is zero. Kept far below the smallest field weight (1) so a * real token match always outranks a fallback-only (cross-word substring) match, * while guaranteeing the superset property: anything the old substring-overlap * matched still surfaces. */ export declare const SUBSTRING_FALLBACK_WEIGHT = 0.1; /** * Identifier-aware normalization. Splits camelCase / PascalCase / snake_case / * kebab-case into subtokens, lower-cases, drops stopwords and 1-char tokens. * Returns tokens WITH multiplicity (callers that want a set dedup themselves) so * graded frequency scoring is possible. Pure: no external data, no I/O. * * Order of operations matters: identifier boundaries (the case transitions) must * be split BEFORE lower-casing, or `validateDirectory` collapses to one opaque * token and the camelCase boundary is lost. */ export declare function normalizeTokens(raw: string): string[]; /** Deduped, normalized query terms. */ export declare function queryTerms(task: string): string[]; /** The four weighted fields a memory is ranked over. */ export interface RankFields { /** Resolved anchor symbol names (e.g. `validateDirectory`). */ anchorSymbols: string[]; tags: string[]; /** Anchor / affected file paths. */ anchorFiles: string[]; /** Free-text body (note content, or a decision's title + rationale). */ content: string; } export interface RankResult { score: number; /** Which weighted fields contributed (for transparent ranking reasons). */ matched: Array; /** Whether the query named the exact symbol the memory is anchored to. */ anchorBoost: boolean; } /** * Score a memory's fields against deduped query `terms`. Deterministic. * * Primary score is field-weighted and graded (token-equality on normalized * subtokens). The exact-anchor boost fires when every subtoken of an anchor * symbol is present in the query — i.e. the query *names* that symbol. The * legacy substring fallback applies only when the primary score is zero, so the * candidate set is always a superset of the old substring-overlap behavior. */ export declare function scoreMemory(terms: string[], fields: RankFields): RankResult; //# sourceMappingURL=memory-ranking.d.ts.map