How does this sort of thing evolve? Especially the variant where the gall secretes a sweet nectar to enlist ants to defend the wasp embryo from another wasp species.
[1] https://australianmuseum.net.au/lycaenid-butterflies-and-ant...
[2] https://en.m.wikipedia.org/wiki/Ant%E2%80%93fungus_mutualism
A random mutation happened, and that mutation ends up dominating the gene pool because it's more successful.