Skip to content

fix(fsrs): achieve state preservation parity between Forget and Rollback#66

Merged
cantalupo555 merged 2 commits into
mainfrom
fix/rollback-forget-parity
May 10, 2026
Merged

fix(fsrs): achieve state preservation parity between Forget and Rollback#66
cantalupo555 merged 2 commits into
mainfrom
fix/rollback-forget-parity

Conversation

@cantalupo555
Copy link
Copy Markdown
Member

Summary

This PR achieves state preservation parity between the Forget and Rollback operations in the FSRS (Free Spaced Repetition Scheduler). The Forget function now captures the card's full pre-forget state in the review log, and the Rollback function now restores RemainingSteps from the log, ensuring both operations consistently preserve and restore all relevant state information.

Bug Description

  • What was happening: The Forget function was not capturing the card's pre-forget state (State, Due, Stability, Difficulty, ScheduledDays, RemainingSteps) in the ReviewLog — instead it recorded only the reset state. The Rollback function restored most fields from the log but omitted RemainingSteps.
  • Expected behavior: Both Forget and Rollback should preserve and restore the complete card state to maintain operational parity.
  • Root cause: Forget recorded minimal information in the ReviewLog rather than the card's pre-operation state. Rollback was missing the RemainingSteps restoration logic.

Changes Made

  • forget.go: Capture pre-forget State, Due, Stability, Difficulty, ScheduledDays, and RemainingSteps in the ReviewLog; preserve card LastReview.
  • rollback.go: Add result.RemainingSteps = log.RemainingSteps to restore RemainingSteps from the ReviewLog during rollback.
  • fsrs_test.go: Update existing tests and add new test cases covering pre-state capture, ScheduledDays computation, LastReview preservation, and learning-state rollback.

Testing

  • Tested locally
  • Unit tests added/updated
  • No regressions

Related Issues

Fixes #65

Breaking Changes

None — These are bug fixes correcting incorrect behavior. The public API signatures remain unchanged.

…state in Forget

- Copy RemainingSteps from ReviewLog when rolling back a card
- Record pre-forget State, Due, Stability, Difficulty, ScheduledDays and RemainingSteps in Forget ReviewLog
- Preserve card LastReview across forget
…state capture

- Add learning-state rollback test asserting RemainingSteps restoration
- Update Forget tests to assert pre-forget state in ReviewLog
- Add tests for scheduled-days computation and pre-forget log fields
@cantalupo555 cantalupo555 requested a review from ishiko732 May 9, 2026 12:56
@cantalupo555 cantalupo555 self-assigned this May 9, 2026
Copy link
Copy Markdown
Member

@ishiko732 ishiko732 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cantalupo555
Copy link
Copy Markdown
Member Author

LGTM

Thank you!!!

@cantalupo555 cantalupo555 merged commit a7dca6e into main May 10, 2026
6 checks passed
@cantalupo555 cantalupo555 deleted the fix/rollback-forget-parity branch May 10, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rollback() does not restore RemainingSteps field

2 participants