Anyone interested in coding a Julia ECS?

I had a brief look and IIUC then flecs uses these archetypes as an organizational tool for the data essentially. I does not compile specific versions of functions for every archetype. The linked blog about the archetypes explicitly mentions type erasure to make things more uniform.

I think that your plan of specializing on every archetype is bound for failure. The main reason being the huge overhead of actually compiling methods (because the compiler is slow). So you’d never want to compile new methods on the fly because that for sure would cause a lag spike. Which means you either need to figure out which archetypes can possible exists (likely impossible) or precompile every variant which is also impossible.
Additionally, I am not convinced that there is much optimization to be gained from having specialized variants for different trait combinations considering the additional resources it takes. You mention a couple of easy cases where you can save like a few instructions but a few instructions. But I think in general it will be very hard to figure out these optimizations reliably. It is also not quite necessary because it could be done by hand, if a certain combinations arises very frequently. Then the game programmer could profile their game, see that there is an optimization opportunity and introduce a new combined trait (i.e. “PoisonedAndBurning” which gets applied whenever something burning also gets poisoned or vice versa).
In summary, I think too much specialization does more harm than good. But I totally understand the appeal. From a theoretical perspective it seems so nice and clean just to offload everything to the compiler but in practice it is likely a bad idea.