This bug can easily be reproduced by recreating the situation in the screenshots and summoning a skeleton or just a mob with a distance attack.
The mob won't attack you if you're one block above and they have a block on top. That's probably caused by the fact that mob won't attack if they only see your legs.
This indeed doesn't happen if you shift.
affects 20w29a