diigo-cache: diigo counts pages from 0; migrate stored pages (schema v2)

Comparing a cache with diigo's RSS export: the size-100 walk had missed
exactly the 100 newest bookmarks (everything updated since 2026-09-16).
diigo's page_num is 0-based, and we sent our 1-based page number
unchanged, so "page 1" was really page 2 and the newest page was never
fetched. diigo's total (16744) was right; the "total-overstated"
reading was a misdiagnosis.

- page() asks for page_num = n - 1
- BREAKING for stored state, agreed beforehand, migrated in place:
  schema v2 renumbers every stored page +1 (pages and page_members, via
  negation so no number collides), once, recorded as kv "schema" = 2;
  nothing is refetched, page 1 just becomes a miss
- fill jobs record their numbering; a job saved without it fails ("page
  numbering changed …; start the fill again") instead of resuming
- the fake pages from 0 like diigo (7 tests failed until the fix);
  tests feed v1-shaped storage and a v1-numbered job to the new code
- the next-page peek guard stays; its comments no longer claim diigo
  overstates its total
- the fixed test clock moves to 2099: pinned to "today" its alarms came
  due in real time and fired on their own

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-10-07 08:26:13 -05:00
1 parent e6deb9fda0
commit cffb1fa9b2
5 files changed
+116 -17

No files matched your search

+3 -2
View File
@@ -9,8 +9,9 @@ import type { CacheEnv } from "../src/cache.js";
export * from "../src/index.js";
export { default } from "../src/index.js";
/** 2026-10-07T12:00:00Z */
export const FIXED_NOW = Date.UTC(2026, 9, 7, 12, 0, 0);
/** 2099-01-01T00:00:00Z: in the future, so an alarm set by this clock is
* never due in real time — tests run it with runDurableObjectAlarm */
export const FIXED_NOW = Date.UTC(2099, 0, 1, 0, 0, 0);
/** a fixed clock that records each sleep it is asked for */
export class FixedClockCache extends DiigoCacheLogic {