INNER CODE UNIT · Python
_purge_operation_spool_on_startup
Soju06/codex-lb · app/main.py:418
async def _purge_operation_spool_on_startup(*, retention_seconds: float) -> int:
"""Run one bounded transcript purge and record a sanitized aggregate result."""
started_at = time.monotonic()
try:
operation_purge_result = await DurableBridgeSessionCoordinator(SessionLocal).purge_operation_spool_batch(
cutoff=utcnow() - timedelta(seconds=retention_seconds),
)
except Exception as exc:
result = OperationRetentionCleanupResult(
deleted_operations=0,
batches=0,
backlog_likely=True,
outcome="failed",
duration_seconds=max(time.monotonic() - started_at, 0.0),
)
_record_operation_retention_cleanup(result)
logger.warning(