Skip to content

feat(fsrs): add srs-kit rescheduler - #426

Open
Eijnewgnaw wants to merge 1 commit into
open-spaced-repetition:previewfrom
Eijnewgnaw:agent/reschedule-with-srs-kit
Open

feat(fsrs): add srs-kit rescheduler#426
Eijnewgnaw wants to merge 1 commit into
open-spaced-repetition:previewfrom
Eijnewgnaw:agent/reschedule-with-srs-kit

Conversation

@Eijnewgnaw

@Eijnewgnaw Eijnewgnaw commented Jul 25, 2026

Copy link
Copy Markdown

Summary

  • add a Rescheduler class in packages/fsrs that accepts an existing srs-kit scheduler core
  • infer review-time and memory-state types from the scheduler's chronology and model
  • accept review history only as { rating, reviewTime }[], derive intervals through the configured chronology, and rebuild memory with one model.forward() call
  • return only the final memoryState
  • cover Date, numeric, and Temporal.Instant chronologies, validation, type inference, and empty-history behavior
  • add a 100-review benchmark and a release changeset

Verification

  • pnpm --filter @open-spaced-repetition/srs-kit check
  • pnpm --filter @open-spaced-repetition/srs-kit test — 25 files, 201 tests passed
  • pnpm --filter ts-fsrs check
  • pnpm --filter ts-fsrs typecheck
  • pnpm --filter ts-fsrs test — 51 files passed, 425 passed, 1 skipped
  • pnpm --filter ts-fsrs build
  • pnpm --filter ts-fsrs bench

Benchmark

100-review replay on the local WSL environment:

  • direct model.forward: ~49,962 ops/s
  • Rescheduler.reschedule: ~33,029 ops/s

The rescheduler remains a single model.forward() replay plus chronology-to-interval conversion.

@Eijnewgnaw
Eijnewgnaw requested a review from ishiko732 as a code owner July 25, 2026 06:30
@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0747871

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
ts-fsrs Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0747871682

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

initialState: input.initialState,
}) as readonly MemoryStateOf<Scheduler>[]
const memoryState =
memoryStates.at(-1) ??

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid Array.at in the ES2017 UMD path

When consumers run the UMD bundle in an ES2017 browser without Array.prototype.at, every call to reschedule() reaches this expression and throws a TypeError instead of returning the rebuilt state. The browser bundle explicitly targets ES2017 in packages/fsrs/tsdown.config.ts, and transpilation does not polyfill built-in prototype methods; use ordinary index access so the new API works across the configured target.

Useful? React with 👍 / 👎.

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.

1 participant