Why don’t aircraft have interlocks to prevent high-lift devices from being retracted when doing so would stall the airplane?
Most modern airliners have some form or other of mechanism that does exactly that, mostly for the slats (which are more important in stall prevention, anyway).

E.g. on modern Airbusses, there is a Slat Alpha Lock function which prevents slat retraction at high angles of attack, on the Boeings there is a Slat Auto-Gap function extending slats from mid to gapped position at high angles of attack.

Military aircraft often have automatic slat deployment to aid with high angle of attack manoeuvres, and even some vintage aircraft did have aerodynamically activated slat-like devices for stall prevention.

Any sensible reference suggestions welcome for any of these... cannot post mine.