fix: publish collection history atomically

This commit is contained in:
xavierk
2026-09-28 01:56:32 +05:30
parent 4550dd5111
commit 437ea6be73
8 changed files with 251 additions and 76 deletions
+1 -2
View File
@@ -16,7 +16,7 @@ def ensure_period_open(conn: sqlite3.Connection, run_time: datetime) -> None:
"""Ensure a monitoring period is open. If none exists, open one at run_time.
Spec §9.8: A collection run finding no open monitoring period opens one
at the run moment, never backdated.
at the run moment, never backdated. Caller owns the transaction.
"""
if get_open_period(conn) is not None:
return # Already open — no-op
@@ -26,7 +26,6 @@ def ensure_period_open(conn: sqlite3.Connection, run_time: datetime) -> None:
"INSERT INTO monitoring_periods (started_at) VALUES (?)",
(ts,),
)
conn.commit()
def close_period(