Hold it… false alarm… I think.
Just by chance I caught a line of code where I was loading a double value into an int variable.
Fixing that has made the inverted rotation result come out correctly.
I wish I knew enough about matrix math to know why the wrong version was good enough for all the tests except that inverted rotation.