fix(engine): bump now_iso() to microsecond precision
CI failure on python 3.11/3.12: test_update_bumps_version_and_updated_at asserts updated_at > created_at, but ms-precision timestamps collide when SQLite create + update fire inside the same millisecond on fast runners. Microsecond precision (6 fractional digits) keeps ISO-8601 valid, TS Date.parse handles it natively, and no consumer regex-binds to the 3-digit form. Fixes the repository ordering invariant.
This commit is contained in:
+7
-2
@@ -5,10 +5,15 @@ import datetime as _dt
|
||||
|
||||
|
||||
def now_iso() -> str:
|
||||
"""UTC ISO timestamp with millisecond precision and ``Z`` suffix.
|
||||
"""UTC ISO timestamp with microsecond precision and ``Z`` suffix.
|
||||
|
||||
Used for `created_at`, `updated_at`, `library_snapshot_at`,
|
||||
migration `applied_at`, and import-export `exported_at`. Single source
|
||||
of truth so the format never drifts between callers.
|
||||
|
||||
Microsecond precision (vs. millisecond) prevents collisions when
|
||||
two ops fire inside the same millisecond on fast CI runners — the
|
||||
`updated_at > created_at` invariant in `ModuleRepository.update`
|
||||
must hold for any sequential create+update pair.
|
||||
"""
|
||||
return _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
|
||||
return _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
|
||||
Reference in New Issue
Block a user