Unfortunately, I have to retract my suggestion, as I've just had a game which invalidates it.
Peter and Mao were in a very close race: Mao was missing the engines, Peter the casings. Mao was building both engines outside his capital, and both were due to be completed on the same turn. Peter's last casing would finish one turn later.
Mao launched as soon as the first engine was completed.

So the check for launch is performed after each build queue, and is not restricted to the capital's.
Peter then... revolted to State Property instead of launching, and came out of revolt with 3 turns needed now to complete the last casing, because he had turned all his citizens into specialists.
He launched anyway, without completing the last casing: his ship would arrive on the same turn, and he had the turn order advantage. So that's one thing the AI does evaluate correctly.
Peter won the race.
Out of curiosity, I reloaded the last turn, and this time Mao won: Peter's ship had failed because of the missing casing.
So no idea about what happened in your game.
Regarding ship sabotaging: in most games, it doesn't happen (for instance in the game I've just mentionned, you'd have thought it would happen, but nope). But I've had a few games where on the contrary, the AIs went crazy with it, and an AI which was 2-3 techs being would end up winning the race because of it.
The craziest instance had a ship launch delayed by 30+ turns! (and in that case, to no avail, as the AI which finished the tech tree still ended up launching first).