diigo-cache: the caches take their clock as a constructor argument

Ocap discipline: no ambient time in logic. PagedCache reads time and
waits only through a Clock { now, sleep }, a default constructor
argument (the live clock; the runtime constructs DOs with ctx and env
only). The fill job's timestamps and alarms, the etch time, and the
diigo-call pacing all go through it.

Tests interpose through the constructor: tests/test-worker.ts (now the
tests' main module) adds FixedClockCache, bound as CLOCKED_DO, and a
test pins startedAt, updatedAt, and the alarm time to the fixed clock
(an ambient new Date() fails it).

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-10-07 04:34:48 -05:00
1 parent 7d2100bf77
commit b6823867ff
4 files changed
+76 -17

No files matched your search

+8 -5
View File
@@ -1,9 +1,10 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
// the real worker, with WEBAPP bound to tests/fake-webapp.js (an aux
// worker declared in vitest.config.ts)
// the real worker (via tests/test-worker.ts, which adds a fixed-clock
// cache), with WEBAPP bound to tests/fake-webapp.js (an aux worker
// declared in vitest.config.ts)
"name": "diigo-cache-tests",
"main": "./src/index.ts",
"main": "./tests/test-worker.ts",
"compatibility_date": "2026-09-29",
"rules": [{ "type": "Text", "globs": ["**/capnweb/dist/index.js"], "fallthrough": true }],
"services": [
@@ -12,11 +13,13 @@
"durable_objects": {
"bindings": [
{ "name": "CACHE_DO", "class_name": "DiigoCache" },
{ "name": "PUBLIC_DO", "class_name": "PublicCache" }
{ "name": "PUBLIC_DO", "class_name": "PublicCache" },
{ "name": "CLOCKED_DO", "class_name": "FixedClockCache" }
]
},
"exports": {
"DiigoCache": { "type": "durable-object", "storage": "sqlite" },
"PublicCache": { "type": "durable-object", "storage": "sqlite" }
"PublicCache": { "type": "durable-object", "storage": "sqlite" },
"FixedClockCache": { "type": "durable-object", "storage": "sqlite" }
}
}