/** * Relevance-anchored Key-Knowledge selection for the bootstrap briefing. * * "Maximally relevant or none": instead of listing the top-N most recent notes * (which still surfaces stale, off-topic ones), we anchor an embedding on the * RECENT-CONVERSATION tail, cosine-score every active note for the thread, and * keep only those clearing a similarity threshold — rendered fully, never * truncated. A spike on thread 1327 (1789 notes) validated this: sim>=0.40 gave * 23 tightly on-topic notes, 0.45 gave 9. So ~0.40 is a self-limiting, high * quality cut. * * The selector NEVER throws or hangs: a missing API key, an embedding * error/timeout, an empty tail (fresh thread), or zero matches all fall back to * the historical recency selector so the briefing degrades gracefully. */ import type { Database } from "./schema.js"; import { type SemanticNote } from "./semantic-notes.js"; /** * Similarity bump a pinned note gets before the threshold cut and ranking. * Pinning is a relevance WEIGHT, not forced presence: a pinned note outranks an * equally-similar plain note and can clear the threshold on a near-miss, but a * pinned note that is genuinely off-topic (well below threshold) still drops. * Modest by design — 0.05 nudges neighbours without flooding the list. */ export declare const PINNED_RELEVANCE_BOOST = 0.05; export interface KeyKnowledgeParams { threadId: number; /** OpenAI key; empty string forces the recency fallback. */ apiKey: string; /** Minimum cosine similarity a note must clear to be included. */ threshold: number; /** Upper bound on notes returned (also the fallback slice size). */ maxResults: number; /** How many recent conversation episodes form the anchor. */ tailEpisodes: number; /** * Pinned note IDs to boost by PINNED_RELEVANCE_BOOST in the relevance path. * Omitted/empty ⇒ no boost (e.g. the recency fallback, or a thread with no pins). */ pinnedNoteIds?: Set; } /** Drop notes whose content exactly duplicates an earlier one, keeping the first. */ export declare function dedupeByContent(notes: SemanticNote[]): SemanticNote[]; /** * Select the Key-Knowledge notes for a thread's bootstrap briefing. * * Relevance path when possible; otherwise the recency fallback. Guaranteed not * to throw — every failure mode resolves to the fallback selection. */ export declare function selectKeyKnowledge(db: Database, params: KeyKnowledgeParams): Promise; //# sourceMappingURL=key-knowledge.d.ts.map