$state['db_runner_active']       = false;
$state['db_runner_completed_at'] = time();
// IMPORTANT: The runner does not delete restore artifacts (state/lock/temp/progress).
// Mark cleanup as pending so the plugin's post-restore GC (or UI-triggered cleanup) can remove them.
$state['cleanup_pending']        = true;
$state['cleanup_completed']      = false;
$state['cleanup_scheduled_at']   = time();
$state['status']                 = 'completed';
$state['finalized']              = true;
$state['current_step']           = 'completed';
$state['progress']               = 100;
$state['message']                = 'Restore completed successfully!';

// Stable completion summary for DB step.
$state['collation_remap_count']  = (int) $collation_remap_count;
$state['collation_remap_target'] = (string) $collation_remap_target;
$state['sub_progress'] = array(
	'label'           => 'done',
	'tables_restored' => $total_tables > 0 ? $total_tables : $tables_completed,
	'rows_restored'   => $total_rows > 0 ? $total_rows : $rows_imported,
);
if ( $collation_remap_count > 0 ) {
	$state['sub_progress']['collation_remap_count']  = (int) $collation_remap_count;
	$state['sub_progress']['collation_remap_target'] = (string) $collation_remap_target;
}
