I’ve found the bug. It’s in the gyro calibration code; it’s been in the code for weeks if not months; it affects the calibration of all 3 axes of the gyro. Yet it only reared its ugly head at the point the thermostat code is done, and even then only in the y-axis calibration.
I have no idea why only now has it expressed itself, and why only in the Y-axis. I simply have to assume god* has a sense of irony.
* Insert your favoured deity or bad luck demon here.