Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Guestbook: anchor the roll clock on first seed so a fresh seed doesn't roll on the next cron (review M2)

nyblnet96de1d81272f
diff --git a/server/guestbook-daemon/src/worker.js b/server/guestbook-daemon/src/worker.js
index 05038c40..f8f3381f 100644
--- a/server/guestbook-daemon/src/worker.js
+++ b/server/guestbook-daemon/src/worker.js
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento/Suite authors
// bento-guestbook-daemon — the sustainable home of the public guestbook.
// Storage: Workers KV (R2 is not enabled on this account; KV fits — values
// are ~500 KB against a 25 MB limit, archives pruned to the newest 90).
@@ -192,6 +194,12 @@ export default {
m.epoch = doc.guestbookEpoch ?? 0
m.killed = false
m.seededAt = new Date().toISOString()
+ // Anchor the roll clock on first seed so ROLL_HOURS is measured from
+ // now, not from epoch 0 — otherwise a freshly-seeded guestbook (no
+ // lastRoll) rolls on the very next cron tick, wiping the seeded room.
+ // Only set it if absent: re-seeds (every publish) must NOT reset the
+ // cadence, and a real roll() sets its own lastRoll.
+ if (!m.lastRoll) m.lastRoll = new Date().toISOString()
await putMeta(env, m)
return json({ seeded: true, epoch: m.epoch, bytes: body.length })
}