storage: keep the stories people saved, and prune more than once a deploy

Maintenance deleted every story older than 30 days and then swept up any
user_story_state row pointing at a story that no longer existed. A bookmark
is one of those rows, so every saved story quietly vanished a month after
Pete first saw it, which is exactly what saving it was meant to prevent. A
bookmarked story is now exempt from the prune; read markers on pruned
stories still go.

Maintenance also only ran at startup, on a service that can go weeks between
deploys, so nothing was pruned for weeks and then everything was at once. It
runs at startup and then daily.

Pruning daily makes one old hole steady-state: the stories row is Pete's only
memory of a GUID, so a slow feed still listing month-old items would meet
them again as new the day after their rows went. The poller now skips items
published before the retention window. Undated items can't be judged and
still pass.
This commit is contained in:
prosolis
2026-09-22 23:13:58 -07:00
parent a15d67e210
commit 517019d4a4
4 changed files with 92 additions and 7 deletions
+4 -3
View File
@@ -305,8 +305,9 @@ func main() {
}
}
// Run maintenance on startup
storage.RunMaintenance()
// Prune now and then daily. Startup-only meant a service that ran for weeks
// between deploys never pruned at all.
storage.StartMaintenance(ctx)
// Wait for shutdown signal
sig := <-sigCh
@@ -423,7 +424,7 @@ func runLocal(cfg *config.Config) {
ws.StartAdventureAlerts(ctx)
slog.Info("local: web UI listening", "addr", cfg.Web.ListenAddr)
storage.RunMaintenance()
storage.StartMaintenance(ctx)
sig := <-sigCh
slog.Info("local: shutdown signal received", "signal", sig)