As the title suggests I just had a major failure in situational awareness.
You, like everybody else, has a multitude of situational awareness failures on a daily basis. Some are going to be major, some minor. The significant difference is that nothing bad or unexpected usually happened during those times. As a result, you fail to realize how often it occurs. It is amazing to me the number of self defense instructors I have had that have claimed to be very situationally aware, "From the moment I walk out my front door, I am constantly in Condition Yellow" only to see them surprised by a student that walks up behind them.
So you do the best that you can, but realize that virtually any time that you are doing anything else other than trying to maintain situational awareness, you have compromised your situational awareness to some extent. The worst part is that how often it is compromised and how much it is compromised is often undiscerned. That is reality. You don't know what you don't know.
There are some fun and interesting videos on
inattention blindness that are microcosm examples for loss of situational awareness. Note that sometimes the same phenomenon is called attention blindness, perception/ual blindness, and selective attention. It happens all the time in day to day life. It is also part of tradecraft for folks like magicians and some criminals.
https://www.youtube.com/results?search_query=attention+blindness
Most people try to maintain situational awareness via a method of limited sampling of the environment around them, assuming that the sampling is sufficient to account for the gaps in time and space that have not been sampled - in other words, hoping or believing nothing will develop in those areas or during those periods that are not sampled, or that if something does develop, that their sampling will discern the problem quick enough for an appropriate response.
My point? Lots of good suggestions above, but also realize you aren't going to be perfect. Nobody is. You can work to be less imperfect, however.