Great article, loved your style of writing!
I'm not sure how they usually do things in the ECS space, but I think the natural thing to do for the spell megafunction is to split it up into smaller systems. The original system just slaps a spell component onto the entity that affects it and after that there are the spell systems that check for the tagged entities. Now the queries in the megafunction are greatly simplified. Also the spell queries are now more tightly defined