I would like to point out that the proposed hack "withMainSerialExecutor" isn't scoped at all. It affects the entire process by setting the swift_task_enqueueGlobal_hook and I'd be worried about it causing all kinds of threading issues with it flip flopping between enqueueing on main actor and the actual target actor. I'm not even sure concurrency (just plain threading) wise this will be correct tbh.
Could the package name or method at least highlight that this is intended for testing only as well?
It is very concerning that this worryingly unsafe API with global effects is pitched as a general purpose tool (judging by API name and package name).