The best solution so far for this problem is to deflect the decision to the current terminal emulator.
For instance, Kitty has the text_fg_override_threshold that automatically detects if there is not enough contrast between background and foreground and changes it automatically
That's what it looks like with the setting set to 1