feat(srs): upgrade from SM-2 to FSRS spaced repetition algorithm#58
Open
nymulinfoinlet wants to merge 2 commits intomainfrom
Open
feat(srs): upgrade from SM-2 to FSRS spaced repetition algorithm#58nymulinfoinlet wants to merge 2 commits intomainfrom
nymulinfoinlet wants to merge 2 commits intomainfrom
Conversation
Closes #53 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Closes #45 Replaces the 1987 SM-2 algorithm with FSRS (Free Spaced Repetition Scheduler), which research shows reduces total reviews by 20-40% while maintaining the same retention rate. FSRS is now the default algorithm in Anki (since v23.10) and RemNote. Changes: - flashcards.service.ts: removed calculateSM2(), added FSRS integration via ts-fsrs library (MIT, open-spaced-repetition project). New methods: mapQualityToFSRSRating() maps legacy SM-2 quality (0-5) to FSRS Rating (1-4: Again/Hard/Good/Easy). toFSRSCard() reconstructs an FSRS Card from the DB row for scheduling. review() now calls fsrs.repeat() instead of SM-2. - Flashcard interface: added stability, fsrsState, lapses fields alongside existing SM-2 fields for backward compat. - Migration 015_fsrs_columns.sql: adds stability, difficulty, fsrs_state, lapses columns to flashcards table. - ReviewFlashcardDto: docstring updated to explain both FSRS (1-4) and legacy SM-2 (0-5) input ranges. - Legacy SM-2 cards (stability=0, fsrsState=0, repetitions>0) are treated as new FSRS cards on first review — FSRS starts fresh rather than inheriting the SM-2 schedule, since the two algorithms model memory differently. - package.json: added ts-fsrs ^5.3.2 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #45
Replaces the 1987 SM-2 algorithm with FSRS (Free Spaced Repetition Scheduler). Research shows FSRS reduces total reviews by 20-40% while maintaining the same retention rate. FSRS is now the default in Anki (since v23.10) and RemNote.
What changed
calculateSM2(), added FSRS viats-fsrslibrary. Legacy SM-2 quality (0-5) is mapped to FSRS Rating (1-4). Legacy cards start as new FSRS cards on first review.stability,difficulty,fsrs_state,lapsescolumns to flashcards tableNote: This branch stacks on PR #57 (Ollama support). Merge #57 first, then this.
Test plan
015_fsrs_columns.sqlstability > 0,fsrs_stateupdatescd backend && npx tsc --noEmit— 0 errors🤖 Generated with Claude Code