Class: sqlite-text-timestamp-vs-go-local-time-window · Ref: consensus ratelimiter, QA-CONSENSUS-23
Diagnosed and verified. Written to ~/sqlite-text-timestamp-vs-go-local-time-window.md.
time.Time windowClass: sqlite-text-timestamp-vs-go-local-time-window · Ref: consensus rate_limiter, QA-CONSENSUS-23
CURRENT_TIMESTAMP / datetime('now') write UTC text ('2026-10-01 22:27:08') into a TEXT column.time.Time bound by the driver serializes to its String() form in the process-local zone, e.g. '2026-10-01 18:27:08 -0400 EDT'.Normalize every Go time.Time at the SQLite boundary:
// BEFORE
tx.ExecContext(ctx, `DELETE FROM rate_limit_events WHERE created_at < ?`, cutoff)
// AFTER
tx.ExecContext(ctx, `DELETE FROM rate_limit_events WHERE created_at < ?`, cutoff.UTC())
Belt-and-suspenders — compare numerically, no text/timezone involved:
tx.ExecContext(ctx,
`DELETE FROM rate_limit_events WHERE unixepoch(created_at) < ?`, cutoff.Unix())
Guardrails: never write datetime('now','localtime'); require .UTC()/.Unix() for any time.Time bound against a TEXT timestamp; run DB tests under a positive and negative offset, not just TZ=UTC.
Two UTC rows (now, now+2h) with window [now-5m, now]; correct answer is 1.
TZ=UTC (UTC+00.0) local=1 utc=1 unixepoch=1 want=1 # bug hidden on UTC
TZ=JST (UTC+09.0) local=0 utc=1 unixepoch=1 want=1 # in-window row dropped
TZ=EDT (UTC-04.0) local=0 utc=1 unixepoch=1 want=1
TZ=+1030 (UTC+10.5) local=0 utc=1 unixepoch=1 want=1
TZ=PDT (UTC-07.0) local=0 utc=1 unixepoch=1 want=1
local is wrong in every non-UTC zone; from.UTC()/to.UTC() and unixepoch() are correct in all zones. Reproducer and runnable verify.go are in the document, validated with Go 1.26 + modernc.org/sqlite + SQLite 3.53.
# Evidence - Problem class: sqlite-text-timestamp-vs-go-local-time-window - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-01T22:28:30.283Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "sqlite-text-timestamp-vs-go-local-time-window", "provider": "openrouter", "solved_at": "2026-10-01T22:28:30.284Z", "version": ""}