While it's legally irrelevant as a cause for divorce, adultery is definitely a factor in divorce settlements and custody cases. My guess is that any document to the contrary would be ignored by most middle-aged conservative judges, which makes up most of the justice system. At the end of the day, having the best lawyer matters a lot more than any actual facts anyway. People who have flat-out cheated have walked away with half of their spouse's net worth just by having a better lawyer.
I don't know whether a document would have any weight in court. For one thing, you can't sign contracts that violate legislation, and I'm not sure what the exact legislation is on adultery. I would imagine that such a thing would have to be signed prior to saying your vows to have any real weight.
I've never remotely understood people who get married with an "in case of divorce" plan... what the hell are you getting married for if you think you MIGHT EVER get divorced?? If you're going into it with that attitude, you're setting yourself up for failure because if you're already reneging on your commitment when the going is good and you're all lovey-dovey, where are you going to be when life throws you its curveballs? Religious convictions aside, our society full endorses common-law partnerships with, in most jurisdictions, the same rights and responsibilities as marriages. In Canada, if you live with someone that has a kid and you do one single "parent-like act" (make them dinner one day, take them to the doctor, anything that a parent would do) then instead of waiting a year, you become common-law the moment you move in together (at least as far as Revenue Canada is concerned, i.e. our IRS).
My solution to this conundrum was simple: Don't marry the sort of person who's likely to stab you in the back if things don't work out.
I think this is a lot more of an issue for the people who get married before realizing they're poly, and then the spouse "goes along" with it but is never really emotionally on-board. I could definitely see that coming up in a court battle and being a big issue.
“As I am sure any cat owner will be able to tell you,
someone else putting you in a box is entirely different
from getting into a box yourself.” —bisexualbaker