Everything in post 2 as a safety net but mainly:
Know and set your boundaries in your own mind, and be prepared to re-examine them every five years or so to see how you still feel.
What I mean is 'cheating' means different things to different people - and the lines you draw around this definition can mean different things to you at different points in your life.
Ignore how anyone else - especially on here - defines it - just go with what works for you.
For some people flirting, looking at porn, emotional reliance on another women aka 'the work wife' are okay, but for other people that's where they draw the line. Some people can forgive a drunken snog at the office party and others cannot.
Some people believe in second chances, others it's once and done.
Once you know exactly where your boundary lines are, you can't be pushed into a direction you don't want to go by the opinion of others, and you can't be gaslit or persuaded into staying with someone against your better judgement.