I agree that not expanding scope makes things easier but it doesn't solve the problem.
I also agree that knowing the stack goes a long way, but again, doesn't go all the way.
Omniscience is required, by definition. Even if just omniscience about the software you are building. MEANING you know not just all your lines, but all the lines of all the dependencies, the compiler, and the system it is operating on. I have yet to meet anyone that comes anywhere near approaching this knowledge, including many gray beards.
It is utterly foolish to proclaim your code as "bug free". Since you don't seem to be aware of sayings like "software rot" allow me to introduce to you to another one
  There's two types of programs:
  1) Those with bugs
  2) Those that nobody uses
In case it isn't obvious, the joke implies that all programs have bugs, it is just that developers are less likely to be aware of them when few people use them. This is, of course, because there are too many variables for any developer to account for, even in simple programs.