Skip to content

test(fsrs): add unit tests for FSRS-lite module - #21

Open
yizhibibao125 wants to merge 1 commit into
Goldentrii:mainfrom
yizhibibao125:test/fsrs-unit-tests
Open

test(fsrs): add unit tests for FSRS-lite module#21
yizhibibao125 wants to merge 1 commit into
Goldentrii:mainfrom
yizhibibao125:test/fsrs-unit-tests

Conversation

@yizhibibao125

Copy link
Copy Markdown

Summary

Add a dedicated test file for the fsrs module (packages/core/src/palace/fsrs.ts), which had no test coverage despite being a core mathematical primitive used by insights, room facts, and pipeline syntheses.

What's covered

  • initFsrs — default stability, confirmations seed, last_confirmed validity, explicit now parameter
  • score — retrievability range [0,1], decay over time, age_days accuracy, all four status bucket boundaries (hot / warm / cool / archive_candidate), stability passthrough
  • reinforce — exact 30% stability growth, confirmations increment, last_confirmed update, pure-function guarantee, compounding over multiple calls
  • penalize — stability halving, floor at 1 (including repeated penalizations), immutability of last_confirmed and confirmations, pure-function guarantee
  • Combined workflows — reinforce after penalize, dormancy + refresh cycle
  • Exported constantsARCHIVE_THRESHOLD, HOT_THRESHOLD, DEFAULT_INITIAL_STABILITY

Tests

npm run build -w packages/core
node --test packages/core/test/fsrs.test.mjs

## Notes

- Pure test addition — no runtime code changed.
- Style follows the existing suite (`node:test` + `node:assert/strict`, dynamic `import` from `dist/`).

Cover all four exported functions and the three constants:
- initFsrs: default state, explicit now, confirmations seed
- score: retrievability range, decay over time, age_days accuracy,
  status bucket boundaries (hot/warm/cool/archive_candidate)
- reinforce: 30% stability growth, confirmations increment,
  last_confirmed update, pure-function guarantee, compounding
- penalize: halving, floor at 1, immutability of other fields
- combined workflows: reinforce after penalize, dormancy + refresh
- constants: ARCHIVE_THRESHOLD, HOT_THRESHOLD, DEFAULT_INITIAL_STABILITY

No runtime code changed. Tests use node:test + node:assert/strict,
consistent with the existing test suite style.

Co-authored-by: yizhibibao125 <143419304+yizhibibao125@users.noreply.github.com>
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.

2 participants