M8-R08: add atomic meter close and binding transfer

This commit is contained in:
2026-08-24 18:37:46 +02:00
parent 2be4f78f8a
commit 8dc3f71aaf
15 changed files with 1667 additions and 35 deletions
+8 -1
View File
@@ -666,7 +666,7 @@ def compute_closed_periods(session: Session) -> int:
def recompute_range(
session: Session, start: datetime, end: datetime, *, commit: bool = True
session: Session, start: datetime, end: datetime, *, commit: bool = True, strict: bool = False
) -> int:
"""Recompute (overwrite) all 15-minute periods in ``[start, end)``.
@@ -693,6 +693,11 @@ def recompute_range(
When true (the default), commit after all periods have been processed.
Callers composing this recompute with other writes may pass false and
own the surrounding transaction themselves.
strict:
When true, propagate a failed period computation to the caller. This
is for lifecycle transactions which must roll back their meter/binding
mutation together with the cost recompute. The default remains
best-effort for existing background and standalone callers.
start:
Inclusive start datetime (floored to the nearest quarter-hour internally).
end:
@@ -723,6 +728,8 @@ def recompute_range(
if did_write:
written += 1
except Exception:
if strict:
raise
logger.exception(
"recompute_range: unexpected error for t0=%s — continuing.",
t0.isoformat(),