/**
 * `LanceStore` — thin wrapper around `@lancedb/lancedb` that owns dataset
 * lifecycle, the content-table Arrow schema, lazy index creation, compaction,
 * and the `search_meta` singleton row.
 *
 * This module is the only part of the search subsystem that touches the
 * LanceDB native binary. Higher-level modules (indexer, hybrid-query,
 * search-service) should talk to `LanceStore` and never import LanceDB
 * directly.
 *
 * See docs/design/semantic-search.md §3 (schema), §9 (meta row),
 * §10 (migration) and §13 (index parameters).
 */
import { Schema } from "apache-arrow";
import type { Table } from "@lancedb/lancedb";
import { type MetaRow } from "./meta.js";
export declare const EMBED_DIM = 768;
/**
 * Authoritative Arrow schema for the `content` table.
 *
 * This is the literal schema from design §3 — nullability and field order
 * are significant. All file-specific fields (file_path / start_line /
 * end_line) are nullable so the v2 files source drops in without a schema
 * migration.
 */
export declare function buildContentSchema(embedDim?: number): Schema;
export declare const contentSchema: Schema<any>;
/**
 * TypeScript mirror of the Arrow `content` schema. Field order and
 * nullability match §3 literally. Consumers build rows of this shape and
 * pass them to `upsert`.
 */
export interface ContentRow {
    id: string;
    source_id: string;
    project_id: string;
    entity_type: string;
    parent_id: string | null;
    archived: boolean;
    timestamp: number;
    content_hash: string;
    weight: number;
    role: string | null;
    title: string | null;
    text: string;
    goal_id: string | null;
    session_id: string | null;
    session_title: string | null;
    file_path: string | null;
    start_line: number | null;
    end_line: number | null;
    /** Must have length `embedDim`. Accepts plain array or Float32Array. */
    embedding: number[] | Float32Array;
}
export interface LanceStoreOpenOptions {
    /** Directory holding the LanceDB dataset (e.g. `.bobbit/state/search.lance`). */
    dataDir: string;
    /** Embedding dimension. Must match the active embedder. */
    embedDim: number;
}
/**
 * Lance-backed content + meta store.
 *
 * Design invariants:
 * - One dataset per project.
 * - `content` table has a fixed schema (§3). A corrupt dataset is renamed
 *   aside (§10) and recreated empty.
 * - `search_meta` is a single-row table. Writing replaces the row
 *   atomically.
 * - Indexes (IVF_PQ vector + FTS) are created lazily — only called when the
 *   caller asserts rowCount > 10_000.
 */
export declare class LanceStore {
    readonly dataDir: string;
    readonly embedDim: number;
    private readonly _schema;
    private readonly _metaSchema;
    private _conn;
    private _content;
    private _closed;
    private constructor();
    /**
     * Open or create the dataset at `opts.dataDir`.
     *
     * - If the directory does not exist, it is created and a fresh `content`
     *   + `search_meta` pair is initialised.
     * - If the dataset exists and opens cleanly, both tables are reused
     *   (missing tables are created empty).
     * - If the dataset fails to open (corruption), the directory is renamed
     *   to `<dataDir>.corrupt-<ts>` and a fresh dataset is created in its
     *   place. Per design §10.
     */
    static open(opts: LanceStoreOpenOptions): Promise<LanceStore>;
    private _ensureTables;
    /** Release references; no-op if already closed. LanceDB manages its own handles. */
    close(): Promise<void>;
    private _checkOpen;
    /**
     * Idempotent upsert keyed by primary key `id`. Rows with matching
     * `id` are replaced; new rows are inserted.
     */
    upsert(rows: ContentRow[]): Promise<void>;
    private _rowToRecord;
    deleteByIds(ids: string[]): Promise<void>;
    deleteByFilter(sql: string): Promise<void>;
    count(filter?: string): Promise<number>;
    /**
     * Thin pass-through to the native Lance query builder. Callers chain
     * `.fullTextSearch(...)`, `.nearestTo(...)`, `.where(...)`, `.rerank(...)`,
     * `.limit(...)`, `.toArray()` as documented in the LanceDB API.
     */
    query(): ReturnType<Table["query"]>;
    /**
     * Create the vector + FTS indexes. IVF_PQ parameters follow §13:
     *   numPartitions = min(256, ceil(sqrt(rowCount)))
     *   numSubVectors = 96
     * FTS is built on `title` + `text` with positions enabled so phrase
     * queries work.
     *
     * Caller is responsible for gating this on `rowCount > 10_000`; we emit
     * a console warning (but still run) if called below that threshold, to
     * make accidental misuse visible in logs without breaking tests that
     * exercise the path on small fixtures.
     */
    createIndexes(): Promise<void>;
    /** Compact and prune old versions. Safe to run periodically in the background. */
    compact(): Promise<void>;
    readMeta(): Promise<MetaRow | null>;
    writeMeta(meta: MetaRow): Promise<void>;
}
//# sourceMappingURL=lance-store.d.ts.map