import type { ScopedSql } from './scope-host.js'; /** * The spine table the ownership lives in — a scope table, so it travels with the scope's data. * The name is spelled out rather than interpolated: `lint:spine-ddl` reads this text as written. */ export declare const TABLE_OWNERS_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_table_owners (\n table_name TEXT PRIMARY KEY,\n module_id TEXT NOT NULL,\n source TEXT NOT NULL,\n recorded_at TEXT NOT NULL\n );\n"; /** * Refuse an authored migration that names the ownership ledger — in any statement, read or * write, quoted or qualified. Each adapter runs it beside `assertNoSpineReference`, before the * migration executes, so a refused migration changes nothing and the scope fails closed. */ export declare function assertMigrationLeavesLedgerAlone(sql: string, what: string): void; /** One statement's effect on the table set, as its text states it. */ export type TableStatement = { readonly kind: 'create'; readonly table: string; readonly ifNotExists: boolean; } | { readonly kind: 'rename'; readonly from: string; readonly to: string; } | { readonly kind: 'drop'; readonly table: string; }; /** The table DDL in one migration's text, in statement order. TEMP tables are nobody's and are left out. */ export declare function tableStatements(sqlText: string): TableStatement[]; /** * Where ownership is kept while a transition is applied: the scope's ledger, or the replay's * in-memory model. `null` is a table that exists and whose owner is not known; `undefined`, one * that does not exist as far as the store knows. */ export interface OwnerStore { get(table: string): string | null | undefined; set(table: string, owner: string | null): void; delete(table: string): void; } /** One table change, in the terms both the live diff and the journal replay produce. */ export type TableChange = { readonly kind: 'create'; readonly table: string; readonly owner: string | null; } | { readonly kind: 'rename'; readonly from: string; readonly to: string; } | { readonly kind: 'drop'; readonly table: string; }; /** The table set either side of one statement that changed it. */ export interface TableStep { readonly before: ReadonlySet; readonly after: ReadonlySet; } /** * Run an authored migration ONE statement at a time, through the adapter's `exec`, and return * the table set either side of every statement that changed it. Both adapters run their * authored migrations through this, inside the migration's transaction; recording happens * afterwards (`recordOwnershipSteps`), so the journal's `rows_changed` counts the migration's * own writes and none of the kernel's bookkeeping. */ export declare function runMigrationStatements(sql: ScopedSql, migrationSql: string, exec: (statement: string) => void): TableStep[]; /** Apply each recorded step to the ledger, in statement order, through `applyTableChange`. */ export declare function recordOwnershipSteps(sql: ScopedSql, moduleId: string, steps: readonly TableStep[], at: string): void; /** * Refuse, before anything is written, an erasure that would touch a table the scope does not * record as the erasing module's. Missing rows are backfilled from the journal first. */ export declare function assertTablesOwned(sql: ScopedSql, moduleId: string, tables: Iterable, migrationSqlOf: (moduleId: string, version: string) => string | undefined, at: string): void; //# sourceMappingURL=table-ownership.d.ts.map