My general advice would be to avoid situations that require knowing the calculations.
It shouldn’t matter when during a day you retroratchet, except possibly in relation to the data you’ve already entered today, because (I think) it’s calculated based on where you are in relation to the road and its slope.
My mental model (which could be wrong) is that the road is lowered in increments of the slope, until your current datapoint is off the road. So, in the situation outlined, I’m pretty sure that it wouldn’t go to -4, given a slope of 4 and a position of +5. My guess would be -3.
Mostly I use autoratchet (“max safe days”) to ensure that I don’t build up too much safety buffer, without needing to manually change it.
I have come to a similar conclusion: Avoid doing anything drastic where I am not sure what will happen. I’ve tried and failed after opening this thread (or, maybe succeeded because I was suddenly below the road and worked more than I otherwise would have…). Same goes for backdating or downgrading data points… I just need stick to the basics for now.
Yes, I think that was the situation I was in. I’m not sure if it’s incorrect that it does what you experience (since retro to today probably means “emergency day, still need the daily dose”) but it wasn’t clear to me either.
But if “retroratchet to 0 days” means “retroratchet to a state where the user still has to do a full day’s work” , then it’s correct, right?
We both probably think/thought that “retroratchet to 0 days” meant “retroratchet to a state where the user had an emergency day at the start of the day” , but one could certainly argue for the first interpretation.
That’s why I asked this question in the beginning, to find out what retroratcheting to x days means technically. Still haven’t found out 100 % but now I just never go to 0 days any more out of caution.
Maybe @dreev can help and point of it “retroratchet to 0 days” means statement 1 or 2 or something else altogether?
 In that case, if you had already done 1/2 before, you would now still need to do 2 more.  In the second case, if you had already done 1/2 before, you would only have to do 1 more.
Squinting at the code, I think it matches my mental model that retroratchet effectively deletes a chunk of road so that the number of safe days what you asked for. It doesn’t take the data into account, other than using it’s cumulative total value (at the time you press the button!) to calculate the number of safe days.
If your road is on a nice stable unchanging slope, the road change will be in chunks of daily slope – in your example, it’ll be moving 2 units.
Point being, this could leave your datapoints anywhere inside that range, relative to the road. Could be 2, 1, or even 0.1 needed to get back on the road.
If you want to ratchet to zero (and I often do myself), I’d recommend doing it at the beginning of the day, not partway through.
Alternatively, you could add a temporary negative datapoint to simulate the road being where it was first thing today, ratchet to zero, and then delete that datapoint.
That sounds right to me, and your phrasing is better than mine!
It’s hard to intuit because for a particular goal you might be in a habitual pattern where it always seems to reset to the beginning of the day, or always seems to account for what you’ve done already today, etc.