diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-08 21:18:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-08 21:18:55 +0900 |
| commit | 5e7c3ad7ed8c287b538de97d4de3a4df87e9a100 (patch) | |
| tree | a3b400fb00ba9544d51640cb5d6eb494c2b095f3 /docs/dev/architecture.md | |
| parent | e17c87441d9beff9c1241cbe3ba71c402a7c0c3f (diff) | |
| download | kioku-5e7c3ad7ed8c287b538de97d4de3a4df87e9a100.tar.gz kioku-5e7c3ad7ed8c287b538de97d4de3a4df87e9a100.tar.zst kioku-5e7c3ad7ed8c287b538de97d4de3a4df87e9a100.zip | |
feat(study): use seeded PRNG for deterministic card shuffle order
Shuffle order is now fixed within a study day by seeding mulberry32
with the study day boundary timestamp (3:00 AM rollover).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'docs/dev/architecture.md')
| -rw-r--r-- | docs/dev/architecture.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index cb6e634..7d3bdd4 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -378,6 +378,23 @@ GET /api/sync/pull - Pull server changes 4. Client pulls server changes 5. Mark synced items with `_synced = true` +## Study + +### Date Boundary + +The "study day" rolls over at **3:00 AM local time**, not midnight. A study day spans from 3:00 AM to the next day's 3:00 AM. This boundary is used for: + +- Determining which cards are due (`card.due < endOfStudyDay`) +- Counting today's new card reviews (budget calculation) +- Seeding the card shuffle order (see below) + +### Card Shuffle Order + +Cards fetched for a study session are shuffled client-side using the Fisher-Yates algorithm with a **seeded PRNG** (mulberry32). The seed is derived from `getStartOfStudyDayBoundary().getTime()`, which means: + +- The shuffle order is **deterministic within the same study day** — reopening the study screen produces the same card order. +- The order **changes when the study day rolls over** (at 3:00 AM). + ## Authentication - **Hash**: Argon2 for password hashing |
