async def create_and_run_sync(
        self,
        db: AsyncSession,
        sync_in: schemas.SyncCreate,
        current_user: schemas.User,
        uow: Optional[UnitOfWork] = None,
    ) -> tuple[schemas.Sync, Optional[schemas.SyncJob]]:
        """Create a new sync and optionally run it immediately.

        TODO: Make it run immediately if sync_in.run_immediately is True
            Currently, it expects the FastAPI endpoint to trigger the run
            in background. This should be replaced by decentralized orchestration.

        Args:
        ----
            db (AsyncSession): The database session.
            sync_in (schemas.SyncCreate): The sync to create.
            current_user (schemas.User): The current user.
            uow (Optional[UnitOfWork]): Existing unit of work if provided, otherwise create new one.

        Returns:
        -------
            tuple[schemas.Sync, Optional[schemas.SyncJob]]: The created sync and job if run.
        """
        if uow is not None:
            # Use the provided UnitOfWork without managing its lifecycle
            return await self._create_and_run_sync_internal(sync_in, current_user, uow)
        else:
            # Create and manage our own UnitOfWork
            async with UnitOfWork(db) as local_uow:
                result = await self._create_and_run_sync_internal(sync_in, current_user, local_uow)
                await local_uow.commit()
                return result
Create a new sync and optionally run it immediately.

        TODO: Make it run immediately if sync_in.run_immediately is True
            Currently, it expects the FastAPI endpoint to trigger the run
            in background. This should be replaced by decentralized orchestration.

        Args:
        ----
            db (AsyncSession): The database session.
            sync_in (schemas.SyncCreate): The sync to create.
            current_user (schemas.User): The current user.
            uow (Optional[UnitOfWork]): Existing unit of work if provided, otherwise create new one.

        Returns:
        -------
            tuple[schemas.Sync, Optional[schemas.SyncJob]]: The created sync and job if run.
        
backend/airweave/core/sync_service.py