The old Auto Ease Factor addon had a function for rewriting the revlog ease factors as if they had been reviewed using the config enabled at that time. This was a dangerous operation that was only kind of undoable in that you could set your config back to what it was before and rewrite the revlog again.
The SM2 revlog rewrite code from Auto Ease Factor is like this:
Now that I’ve switched to using FSRS instead of my heavily customized SM2 scheduling, I’d like to make a similar function that would overwrite the factor values using the current FSRS settings as if those reviews had been done with my current FSRS settings.
Is this even possible? If so, what Anki backend functions will I need to use?
Why do you want to overwrite the D values in the old revlogs? The values don’t affect scheduling. Scheduling depends on the value of memory states in the cards table. These values in the cards table are automatically updated whenever you update the parameters as if you did all the reviews with the latest parameters.
I think this isn’t what I need. The rust backend part where it sets the card.memory_state and then passes that card to log_scheduled_review, is what I’m looking for, I think.
If I understand the gist of the FSRS algorithm correctly, I need to calculate S, R and D for a historical review and then calculate the next S, R, D using the previous ones as input, right? I imagine the code I need is something like this: