@chjara accidentally cut off the end of the story btw
In the end I gave up and talked to my boss, who was a great programmer. I told him it looked like a year to make it bug free, with a chance that it was mathematically impossible. We argued until we came up with a stunningly simple solution to the daunting task: five C++ classes that knew how to serialize their history on a common stack. We took about a week to write and test it. It was a big hit with the customers because C++ experience looks much better on a resume than JBMRL (Joe Blow's Magical Reversible Language). Whether something looks good on a resume is the determinant of good or bad programming