I finally got the validation logic working [1]! And it only took me … um … a bit longer than I expected.
I just took it slow and steady. First assumption—the code was correct, the regression test wasn't. Second, start with the one known condition required to pass the test. Check the failures, and add another condition. Repeat as needed, spending sometimes a bit too much time trying to figure out the common cause of “failure” (as reported by the incorrect regression test). It came down to, depending upon how you count, six or eighteen conditions (there are a base five, plus any one of three other conditions) for when Project: Lumbergh [2] sends a message to Project: Cleese [3]. Some might say the logic is too complicated. I might even agree. But then, I'm not the one defining the business logic here.
Now I can continue with adding the new tests, and it's here that I might have to rethink how the regression test works. Maybe a secondary regression test that tests some of the non-business logic stuff, like making sure we handle the database replies out of order (A returns, then B, or B returns, then A). I don't know, it's something I have to think about.