import type { AppliedStorageMigration } from "./contract.js"; export declare const SHARED_TRANSFER_SOURCE_DSN_ENV = "HASNA_LOOPS_TRANSFER_SOURCE_DATABASE_URL"; export declare const SHARED_TRANSFER_TARGET_DSN_ENV = "HASNA_LOOPS_TRANSFER_TARGET_DATABASE_URL"; export declare const SHARED_TRANSFER_SOURCE_DATABASE = "apps"; export declare const SHARED_TRANSFER_TARGET_DATABASE = "loops"; export declare const SHARED_TRANSFER_TARGET_BASE_THROUGH = "0007_work_item_gate_deaths"; export declare const SHARED_TRANSFER_TARGET_PREPARE_THROUGH = "0008_tenant_prepare"; export declare const SHARED_TRANSFER_FIXED_COMMAND: readonly ["bun", "dist/serve/index.js", "shared-to-dedicated-transfer"]; export declare const SHARED_TRANSFER_TABLES: readonly [{ readonly name: "loops"; readonly orderBy: readonly ["id"]; }, { readonly name: "workflow_specs"; readonly orderBy: readonly ["id"]; }, { readonly name: "runner_machines"; readonly orderBy: readonly ["id"]; }, { readonly name: "goals"; readonly orderBy: readonly ["id"]; }, { readonly name: "loop_runs"; readonly orderBy: readonly ["id"]; }, { readonly name: "workflow_invocations"; readonly orderBy: readonly ["id"]; }, { readonly name: "workflow_runs"; readonly orderBy: readonly ["id"]; }, { readonly name: "workflow_work_items"; readonly orderBy: readonly ["id"]; }, { readonly name: "workflow_step_runs"; readonly orderBy: readonly ["id"]; }, { readonly name: "workflow_events"; readonly orderBy: readonly ["workflow_run_id", "sequence", "id"]; }, { readonly name: "goal_plan_nodes"; readonly orderBy: readonly ["id"]; }, { readonly name: "goal_runs"; readonly orderBy: readonly ["id"]; }, { readonly name: "runner_leases"; readonly orderBy: readonly ["id"]; }, { readonly name: "audit_events"; readonly orderBy: readonly ["id"]; }, { readonly name: "run_receipts"; readonly orderBy: readonly ["run_id"]; }, { readonly name: "daemon_lease"; readonly orderBy: readonly ["id"]; }]; export declare const SHARED_TRANSFER_API_KEY_COLUMNS: readonly ["kid", "app", "agent", "scopes", "token_hash", "issued_at", "expires_at", "revoked_at", "revoked_reason", "last_used_at", "created_by", "created_at"]; export interface CommandResult { exitCode: number; stdout: string; stderr: string; } export interface CommandRunner { (command: readonly string[], opts?: { env?: Record; input?: string; }): Promise; } export interface SharedTransferOptions { env?: NodeJS.ProcessEnv; runner?: CommandRunner; migrateTargetThrough?: (targetDsn: string, through: string) => Promise; now?: () => Date; } export interface TransferCount { table_name: string; row_count: string | number; } export interface TransferHash { table: string; sha256: string; } export interface TransferEvidence { schema: "open-loops.shared-to-dedicated-transfer/v1"; executedAt: string; command: readonly string[]; source: { database: typeof SHARED_TRANSFER_SOURCE_DATABASE; }; target: { database: typeof SHARED_TRANSFER_TARGET_DATABASE; }; archive: { file: "openloops-allowlist.dump"; sha256: string; cleaned: boolean; }; ledgers: { sourceContains0001Through0007: AppliedStorageMigration[]; targetExact0001Through0007: AppliedStorageMigration[]; targetContains0001Through0008: AppliedStorageMigration[]; }; sourceCounts: TransferCount[]; targetCounts: TransferCount[]; sourceHashes: TransferHash[]; targetHashes: TransferHash[]; apiKeys: { copiedRows: number; sha256: string; nonLoopRowsOnTarget: number; }; orphanChecks: Array<{ check_name: string; orphan_count: string | number; }>; unexpectedTargetObjects: Array<{ object_name: string; object_kind: string; }>; nextSequence: readonly string[]; } export interface TenantEnforcementForeignKeyCheck { checkName: string; childTable: string; childColumn: string; parentTable: string; } export declare function tenantEnforcementForeignKeyChecks(): readonly TenantEnforcementForeignKeyCheck[]; export declare function runSharedToDedicatedTransfer(opts?: SharedTransferOptions): Promise; export declare function buildPgServiceFile(sourceDsn: string, targetDsn: string): string; export declare function expectedLedgerRows(through: string): AppliedStorageMigration[]; export declare function assertExactLedger(rows: AppliedStorageMigration[], through: string, label: string): AppliedStorageMigration[]; export declare function assertLedgerContainsExpected(rows: AppliedStorageMigration[], through: string, label: string): AppliedStorageMigration[]; export declare function pgDumpCommand(archivePath: string): readonly string[]; export declare function pgRestoreCommand(archivePath: string): readonly string[];