chain-rdeveloper portal
build

Timestamps

The convention

WhereForm
Postgres columns (svc-auth)timestamp with time zone. Read back aware.
In-process comparisonsNaive UTC against naive UTC. Code that meets an aware value normalises it first (_aware / as_utc helpers in the scheduler, dashboard refresh and web crawl).
On the wire (every JSON response)ISO 8601 with an explicit offset: 2026-09-24T10:00:00+00:00.
Stored JSON blobsWhatever they were written with. See below.

A naive value on the wire (2026-09-24T10:00:00) is ambiguous: a browser's new Date, moment, and most API clients read a zone-less date-time as their own local time. Every timestamp then shows shifted by the reader's UTC offset, and "5 minutes ago" can render as "in an hour". So the services never send one.

How the services mark UTC on the way out

Both svc-core and svc-ai keep the helpers in app/util/time.py:

Path to the responseMechanism
A route returning ORM rows or plain dicts (no response_model)install_utc_json_encoding(), called in main.py before the app is built, replaces datetime in FastAPI's ENCODERS_BY_TYPE, which jsonable_encoder consults at call time.
A string built by handutc_isoformat(dt), never dt.isoformat() on a value read from the database. (aware_utcnow().isoformat() is already fine; it carries +00:00.)

tests/test_utc_wire_format.py in each service pins all three paths, and walks every route's response_model, nested models included, failing on any field still typed bare datetime. A new schema cannot quietly send a naive value.

svc-auth needs none of this: its columns are timezone-aware, so its values already serialise with an offset. svc-bff proxies bytes and never re-encodes.

What deliberately did not change

This is a wire-format fix only. Columns stay timestamp without time zone, and in-process datetimes stay naive UTC. Converting the columns to timestamptz would also make every value read from the database aware. Python refuses to compare aware with naive values, so every comparison against "now" in both services would then need auditing, and the mocked pytest sessions would not catch the ones missed. Do that when a consumer outside fe-core, such as the Developer API or an audit export, needs aware values end to end. It is not needed for correct display.

Stored JSON keeps its original format. Values already written into JSON columns are not rewritten, and one writer is deliberately left alone:

  • history._serialise_value writes resource-version snapshots with a plain isoformat(). Adding an offset there would make the first diff after the change report every timestamp field as "changed".

  • Older Experiment.config entries (optimiser candidates, promotions) and document_metadata written before this change are naive.

New writes elsewhere use utc_isoformat or aware_utcnow().isoformat().

Reading timestamps in the frontend

fe-core reads every server timestamp through parseServerDate / parseServerDateOrNull / serverTime (modules/fe/core/src/util/time.tsx), never new Date(str) or moment(str). It is still required, because of the stored-JSON exceptions above. It reads a zone-less value as UTC, leaves a zoned one alone, and reads a bare YYYY-MM-DD as that calendar day. fe-core's hygiene test enforces it. See docs/guides/frontend-components.md, Times from the server.