/** * Persistence for file-level semantic embeddings (`file_vectors`). * * Vectors from two different models are not comparable — the spaces have * nothing to do with each other — so the provider id is stored alongside every * row and a provider change wipes the table rather than silently mixing them. */ import type { DatabaseSync } from 'node:sqlite'; type Statement = ReturnType; type PrepareStatement = (sql: string) => Statement; /** Metadata key recording which provider produced the stored vectors. */ export declare const FILE_VECTOR_PROVIDER_KEY = "file_vector_provider"; export interface FileVectorRow { file: string; vector: Float32Array; /** Hash of the exact text that was embedded. */ sourceHash: string; provider: string; } /** What is already embedded, so a pass can skip unchanged text. */ export interface FileVectorState { file: string; sourceHash: string; } export declare function getFileVectorStatesWithStatement(stmt: PrepareStatement, provider: string): Map; export declare function upsertFileVectorsWithStatement(stmt: PrepareStatement, maxSqlVars: number, rows: readonly FileVectorRow[]): void; /** * Drop every stored vector when the provider changes. * * Returns true when a wipe happened, so the caller can report that the next * pass is a full re-embed rather than an incremental one. */ export declare function reconcileVectorProviderWithStatement(stmt: PrepareStatement, getMetadata: (key: string) => string | undefined, setMetadata: (key: string, value: string) => void, provider: string): boolean; /** Vectors dropped for files no longer indexed. */ export declare function pruneOrphanFileVectorsWithStatement(stmt: PrepareStatement): number; export declare function countFileVectorsWithStatement(stmt: PrepareStatement): number; export interface VectorHit { file: string; /** Cosine similarity in [-1, 1]. */ score: number; } /** * Rank every stored vector against `query` and return the closest files. * * A brute-force scan, deliberately: at file granularity this repository has * roughly eight thousand vectors of 384 floats, which is about twelve * megabytes and a few milliseconds to sweep. An approximate-nearest-neighbour * index would add a dependency and an accuracy cliff to save time nobody is * waiting on. */ export declare function searchFileVectorsWithStatement(stmt: PrepareStatement, query: Float32Array, limit: number, minScore: number): VectorHit[]; export {}; //# sourceMappingURL=writer-vectors.d.ts.map