Unions can only prevent automation up to a point. Really the only thing that could have reasonably prevented this would have been for programmers to not produce as much freely accessible training data (formerly known as "open source software").

Exactly. I am always so impressed by the fact that developers never see that open source is essentially them giving away free labor to giant corporations. Developers basically programmed their way out of a job, for free. It's the only profession that is proud to have its best work done on unpaid time and used for free by big corporations.