I had been stuck on the same bug for most of a day. Not a hard bug, in the sense that the fix turned out to be three lines. A stuck bug, which is different. The kind where you have read the same forty lines of code so many times that they have stopped being code and become wallpaper, and your eyes slide across the actual mistake without registering it because you have already decided it cannot be there.
By late afternoon I was just adding print statements out of spite. So I gave up, in the good way, and went for a ride.
Two hours, no particular route, just out into the lanes with the sole intention of not thinking about the problem. And of course you cannot order your brain to stop, but you can give it something else to do, and a long climb does that nicely because it leaves you no spare capacity for anything but breathing. Somewhere on the way back, freewheeling down a hill with my mind pleasantly empty, the answer just arrived, fully formed, uninvited. The thing I had assumed was set before the function ran was set after. Obvious. Embarrassingly obvious. The sort of thing I would have spotted in five minutes if I had come to it fresh.
I have stopped treating this as a quirk and started treating it as a tool. When I am stuck, properly stuck, the most productive thing I can do is leave. Not switch to another tab, leave: go outside, move, let the foreground process release the lock it has on the problem so the background one can have a go. The answer was never going to come from staring harder. It came from staring at a hedgerow instead.