beads/internal/types
Ben Younes e8839c4f0a
fix(import): normalize optional timestamps to UTC on insert (#5771)
* fix(import): normalize optional timestamps to UTC on insert

On JSONL import, an optional timestamp carrying a non-UTC offset (e.g. a
closed_at of `...-04:00` from an older SQLite-era export) kept its local
wall-clock digits: created_at/updated_at were normalized to UTC on insert
but closed_at and the other optional pointer timestamps were not, so the
stored instant shifted by the host's UTC offset while every other field
round-tripped cleanly.

Add Issue.NormalizeOptionalTimestampsToUTC and call it from both insert
paths (embedded PrepareIssueForInsert and proxied-server
normalizeIssueTimestamps) so started_at, closed_at, compacted_at, due_at,
defer_until, lease_expires_at and heartbeat_at are converted to true UTC,
exactly as created_at/updated_at already are.

Fixes #5765

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore(bazel): enumerate the two new UTC-normalization test files in go_test srcs

gazelle-generated, one line per package, both packages owned by this PR.
Each file is untagged so its go_test target owes the enumeration; the
in-package census showed the gap was exactly these two with zero
pre-existing untagged gaps (59 vs 58, 61 vs 60).

* review: correct the domain/db mechanism claim and pin the full timestamp set

Applies the two optional in-PR minors from the bd-s0msb iteration-1 review
synthesis (both Gate impact: none; the synthesis and scorecard both decided
approve with zero blockers and zero majors).

- normalize_timestamps_utc_test.go header claimed this route covers "the
  proxied-server insert path share of #5765". It does not: domain/db runs on
  go-sql-driver, whose DSN Loc defaults to time.UTC and which converts bound
  time.Time values into that location on both the interpolate and prepared
  paths, and no production DSN sets loc=. The embedded route is the one that
  discards offsets, formatting in the value own zone via vitess
  BuildBindVariable. Reworded to state the call is defense-in-depth for parity
  with the embedded path. The test body is unchanged and still passes.

- NormalizeOptionalTimestampsToUTC hand-enumerates its 7 *time.Time fields to
  keep the insert path free of reflection, but the two new tests assert only 5
  of them, leaving LeaseExpiresAt and HeartbeatAt normalized yet unasserted, so
  an 8th field added later would be skipped silently. Adds a reflection-driven
  drift tripwire that walks Issue, sets every *time.Time to a fixed non-UTC
  zone, and fails on any field left off UTC. Dropping &i.HeartbeatAt from the
  helper reds it naming HeartbeatAt while both pre-existing tests stay green.

No production code changes. The tripwire went into the existing types_test.go,
so no new go_test src is owed in internal/types/BUILD.bazel.

---------

Co-authored-by: Ben Younes <2910651+ousamabenyounes@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
2026-09-30 16:00:03 -07:00
..
BUILD.bazel test(bazel): runfiles helpers + declared inputs for scan-guard tests (#6828) 2026-09-27 08:24:08 -07:00
explain_test.go tests: add coverage for explain logic, cycle detection, and engine warnings 2026-03-30 09:15:52 -07:00
id_generator.go refactor: consolidate ExtractPrefix into types package 2026-03-02 23:17:14 -08:00
id_generator_test.go style: run gofmt across entire codebase (bd-nmk12) 2026-02-07 19:35:20 -08:00
orphans.go chore: clean up stale SQLite references in comments (bd-nlw2m) 2026-02-18 11:50:52 -08:00
storage_class_test.go feat(storage): one guarded issue-lifecycle surface for the CLI and linked consumers (#5191) 2026-07-31 11:26:38 -07:00
storage_ext.go fix(compact): archive content before destructive compaction; make restore work (#4464) 2026-06-20 14:12:07 -07:00
types.go fix(import): normalize optional timestamps to UTC on insert (#5771) 2026-09-30 16:00:03 -07:00
types_test.go fix(import): normalize optional timestamps to UTC on insert (#5771) 2026-09-30 16:00:03 -07:00