/**
 * Port: BigQueryFactStore — provisions fact tables and MERGEs fact rows into
 * BigQuery (D0091).
 *
 * The BigQuery adapter (W-bigquery-fact-store-adapter slice) implements this
 * over `data-platform-302218.ailf_facts`; the `InMemoryBigQueryFactStore`
 * below is the test double. The fact-loader engine talks only to this port.
 *
 * Semantics:
 *   - `ensureTable` is create-if-missing plus additive `ADD COLUMN`
 *     reconciliation against the declared schema. Deploying a descriptor
 *     change auto-provisions the column; it never drops or retypes.
 *   - `mergeRows` stages the batch and `MERGE`s it into the partitioned target
 *     on the natural `mergeKey`, so re-running the loader re-derives rows
 *     idempotently (safe retries, safe backfill).
 *
 * @see docs/decisions/D0091-bigquery-analytics-fact-loader.md
 */
import type { FactRow, FactTableSpec } from "../fact-loader/descriptor.js";
/** Outcome of a single {@link BigQueryFactStore.mergeRows} call. */
export interface MergeResult {
    /** Fully-qualified table the rows were merged into. */
    readonly table: string;
    /** Rows inserted (new key). */
    readonly inserted: number;
    /** Rows updated (existing key). */
    readonly updated: number;
}
export interface BigQueryFactStore {
    /**
     * Create the table from `spec.schema` if it does not exist, or additively
     * add any declared columns the live table is missing. Idempotent.
     */
    ensureTable(spec: FactTableSpec): Promise<void>;
    /**
     * MERGE `rows` into `table` on `mergeKey`. Existing keys are updated,
     * new keys inserted; re-merging the same rows is a no-op on row count.
     * An empty `rows` array is a no-op.
     */
    mergeRows(table: string, rows: readonly FactRow[], mergeKey: readonly string[]): Promise<MergeResult>;
}
/**
 * In-memory {@link BigQueryFactStore} for tests and local dry-runs. Records
 * ensured tables and merged rows with real MERGE-by-key semantics, so the
 * idempotency guarantee is observable: merging the same rows twice yields the
 * same row count. Additive schema reconciliation mirrors the real store —
 * `ensureTable` unions declared columns onto the existing spec.
 */
export declare class InMemoryBigQueryFactStore implements BigQueryFactStore {
    private readonly tables;
    ensureTable(spec: FactTableSpec): Promise<void>;
    mergeRows(table: string, rows: readonly FactRow[], mergeKey: readonly string[]): Promise<MergeResult>;
    /** Names of every ensured table. */
    tableNames(): string[];
    /** The reconciled spec for a table, or undefined if never ensured. */
    specFor(table: string): FactTableSpec | undefined;
    /** Current rows in a table (post-MERGE), or an empty array if never ensured. */
    rowsFor(table: string): FactRow[];
    /** Row count in a table after MERGE. */
    rowCount(table: string): number;
}
