/**
 * `execution_runs` cold-store adapter (Orchestrator side).
 *
 *
 * Contract:
 *   - tenant column: `routing_key`
 *   - partition column: `created_at`
 *   - warm TTL: 30 days (design §5 matrix row 7)
 *   - eligibility: terminal run status AND no live jobs reference this run
 *
 * Order: registered LAST in the orchestrator cold-store. Within one
 * cycle the framework iterates adapters steps → jobs → runs; this
 * adapter goes last so the FK `execution_jobs.run_id →
 * execution_runs(run_id)` doesn't fire on DELETE. The "no live jobs"
 * predicate enforces the same invariant across cycle interruptions.
 */
import { type Kysely, type Selectable } from 'kysely';
import { type ChunkCommitMetadata, type ColdStoreTableConfig, type EligiblePartition, type TableAdapter } from '@kici-dev/shared';
import type { Database, ExecutionRunTable } from '../../db/types.js';
export type ExecutionRunRow = Selectable<ExecutionRunTable>;
export interface ExecutionRunsAdapterOptions {
    overrides?: Partial<ColdStoreTableConfig>;
}
export declare class ExecutionRunsAdapter implements TableAdapter<ExecutionRunRow> {
    private readonly kdb;
    private readonly instanceId;
    readonly db: "orchestrator";
    readonly table = "execution_runs";
    readonly tenantColumn = "routing_key";
    readonly partitionColumn = "created_at";
    readonly config: ColdStoreTableConfig;
    constructor(kdb: Kysely<Database>, instanceId: string, opts?: ExecutionRunsAdapterOptions);
    listEligiblePartitions(args: {
        warmCutoff: Date;
    }): AsyncIterable<EligiblePartition>;
    countTenantWarmBytes(args: {
        tenantId: string;
        warmCutoff: Date;
    }): Promise<number>;
    withPartitionLock<T>(args: {
        tenantId: string;
        partitionDate: string;
    }, fn: () => Promise<T>): Promise<T | null>;
    selectEligible(args: {
        tenantId: string;
        partitionDate: string;
        limit: number;
    }): AsyncIterable<ExecutionRunRow>;
    encodeRow(row: ExecutionRunRow): string;
    decodeRow(line: string): ExecutionRunRow;
    rowId(row: ExecutionRunRow): string | number;
    rowTimestamp(row: ExecutionRunRow): Date | string;
    /**
     * Phase F — natural-key extractor used by `replayRow` so callers
     * (the rerun pipeline) can locate the chunk holding a given UUID
     * `run_id` without knowing the internal SERIAL `id` returned by
     * `rowId()`.
     */
    replayLookupKey(row: ExecutionRunRow): string;
    /**
     * Phase F — replay a chunk's `execution_runs` rows back into
     * Orchestrator PG. Mirrors the Platform-side replayInsert; the
     * audit row goes to `access_log` (not `audit_log`) because the
     * orchestrator's audit surface is access_log per design §8.
     *
     * Idempotent on duplicate replays via `ON CONFLICT (run_id) DO
     * NOTHING`. Decrements `cold_store_chunk_counts` (floored at 0).
     */
    replayInsert(args: {
        rows: ReadonlyArray<ExecutionRunRow>;
        chunkMeta: ChunkCommitMetadata;
    }): Promise<{
        inserted: number;
        skipped: number;
    }>;
    markArchivedAndDelete(args: {
        rowIds: ReadonlyArray<string | number>;
        chunkMeta: ChunkCommitMetadata;
    }): Promise<void>;
}
//# sourceMappingURL=execution-runs.d.ts.map