/** * Existing-sheet adoption seeding engine (MVP Phase 2/3). * * Turns the Phase-1 dry-run report into a working adopted entity: * * 1. `computeExistingSheetAdoptionLayout` — derives the managed column span, * the row-id system column, the PK column (existing or appended), and the * registered range override from the dry-run report + raw snapshot. * 2. `applyAdoptionSystemColumns` — the ONLY sheet mutation adoption ever * performs: appending the `__hikoutei_row_id` header, an optional * generated PK column, and the deterministic per-row anchors * (`entity:`, `mapping.anchorForEntity`). No existing cell is * rewritten. * 3. `seedAdoptedEntityRows` — one all-or-nothing SQLite transaction that * binds every observed row (row_binding + canonical INSERT via * `commitCanonicalChangesWithSql` + business-key index + User_Input * visible state confirmed to the observed hash), so the CleanupScanner * never sees an unbound row (D5) and the first human edit CAS-matches. * * Ordering is owned by the service bootstrap: planning (read-only) → * runtime/provisioning → system columns → observation → seeding → final * re-verification → supervisors. */ import type { NormalizedCell } from "../../../../contracts/encoding/types.js"; import { type SyncObservedSnapshot } from "../../../../contracts/sheets/syncSheets.js"; import type { TypedSheetsEntityMapping } from "../../../orm/mapping/contracts.js"; import type { TypedSheetsEntityWriterOptions } from "../../../../contracts/sync-orm/writer.js"; import type { InternalSyncProvider } from "../serviceOptions.js"; import type { ExistingSheetAdoptionStartupPlan } from "./existingSheetAdoption.js"; import type { SqlStorageAdapter } from "../../../../contracts/storage/sql.js"; import type { GoogleSheetsApiAdoptionReader } from "./existingSheetAdoption.js"; /** * Writes the adoption's system columns in ONE batchUpdate: the row-id * header, the generated PK header + values (when applicable), and the * deterministic per-row anchors. Nothing outside these appended columns is * touched — adoption never rewrites an existing cell. */ export declare function applyAdoptionSystemColumns(input: { readonly transport: GoogleSheetsApiAdoptionReader; readonly spreadsheetId: string; readonly sheetId: number; /** The layout provides the row-id/PK column indices and the PK header. */ readonly rowIdColumnIndex: number; /** Appended PK column; `undefined` when the PK comes from an existing column. */ readonly pkAppend?: { readonly columnIndex: number; readonly header: string; }; /** * Data rows: 0-based sheet row index and the PK value, sorted by rowIndex. * Sparse rows are grouped into contiguous runs so values never shift across * blank rows. */ readonly rows: readonly { readonly rowIndex: number; readonly pkValue: string; }[]; /** * P8-C: provider-owned batchUpdate reply verification supplied through the * composition ports (the concrete reply gate stays adapter-owned and is * reused verbatim). */ readonly verifyReply: (reply: unknown, requestCount: number) => void; }): Promise; /** * Seeds one adopted entity's observed rows into SQLite: active row bindings * keyed on the OBSERVED anchors, canonical INSERT commits (entity_state + * entity_field_state, revision 1), the business-key index, and the * User_Input visible state confirmed to the observed hash — so the * CleanupScanner sees fully bound rows (D5) and the first human edit * CAS-matches. One transaction: all-or-nothing (D7 safety contract). */ export declare function seedAdoptedEntityRows(input: { readonly storage: SqlStorageAdapter; readonly mapping: TypedSheetsEntityMapping; /** The application-owned ORM entity table (descriptor.tableName). */ readonly entityTableName: string; readonly physicalSheetId: string; /** Observed User_Input snapshot rows (anchors already assigned). */ readonly rows: readonly { readonly visibleEntityId: string; readonly canonicalEntityId: string; readonly anchor: string; readonly fields: Readonly>; }[]; readonly writerRole: string; readonly writerId: string; readonly leaseDurationMs: number; readonly now: number; /** * Startup-wait warn callback from the runtime writer options (see * {@link TypedSheetsEntityWriterOptions.onStartupLeaseWait}); the local * direct-log fallback keeps standalone callers warning-visible too. */ readonly onStartupLeaseWait?: () => void; }): Promise<{ readonly seeded: number; }>; /** * Extracts the seed rows from an observed User_Input snapshot. Rows without * a usable anchor or PK value are skipped (the final re-verification fails * closed when anything remains unbound). */ export declare function extractAdoptedSeedRows(input: { readonly mapping: TypedSheetsEntityMapping; readonly observed: SyncObservedSnapshot; }): { readonly visibleEntityId: string; readonly canonicalEntityId: string; readonly anchor: string; readonly fields: Readonly>; }[]; /** * Re-verifies and completes the adoption AFTER provisioning: observes the * adopted User_Input tab (the anchors written by * {@link applyAdoptionSystemColumns} are already in place, so the anchor * pass assigns nothing), seeds every observed row that is not yet bound, * and repeats until a pass binds nothing new — the final re-verification * that absorbs edits made inside the adoption window (D5/D6). */ export declare function completeExistingSheetAdoption(input: { readonly plan: ExistingSheetAdoptionStartupPlan; readonly provider: InternalSyncProvider; readonly storage: SqlStorageAdapter; readonly mappings: readonly TypedSheetsEntityMapping[]; readonly writer: TypedSheetsEntityWriterOptions; }): Promise; //# sourceMappingURL=adoptionSeeding.d.ts.map