EDGE: the mass–metallicity relation as a critical test of galaxy formation physics