diff --git a/apps/api/src/services/platform_runtime.py b/apps/api/src/services/platform_runtime.py index 9b5df8096..b999db320 100644 --- a/apps/api/src/services/platform_runtime.py +++ b/apps/api/src/services/platform_runtime.py @@ -19,7 +19,7 @@ from __future__ import annotations import hashlib import json -from datetime import datetime, timedelta, timezone +from datetime import UTC, datetime, timedelta from typing import Any from uuid import UUID @@ -32,7 +32,7 @@ from src.db.awooop_models import ( AwoooPRunStepJournal, ) from src.db.base import get_db_context -from src.services.run_state_machine import LEASE_TTL_SECONDS, transition +from src.services.run_state_machine import transition from src.services.runtime_correlation import ( canonical_traceparent, correlation_readback_for_run, @@ -205,7 +205,7 @@ async def create_run( trace_id = correlation.trace_id # AwoooPRunState timestamps use PostgreSQL TIMESTAMP WITHOUT TIME ZONE. # Normalize UTC before binding so asyncpg does not reject an aware value. - timeout_at = datetime.now(timezone.utc).replace(tzinfo=None) + timedelta( + timeout_at = datetime.now(UTC).replace(tzinfo=None) + timedelta( seconds=timeout_seconds ) diff --git a/apps/api/src/services/runtime_correlation.py b/apps/api/src/services/runtime_correlation.py index d0775dfb0..68c162271 100644 --- a/apps/api/src/services/runtime_correlation.py +++ b/apps/api/src/services/runtime_correlation.py @@ -75,10 +75,10 @@ def canonical_traceparent(run_id: UUID) -> str: """Derive a stable W3C traceparent from one durable run identifier.""" trace_hex = hashlib.sha256( - f"awooop-runtime-trace:{run_id}".encode("utf-8") + f"awooop-runtime-trace:{run_id}".encode() ).hexdigest()[:32] span_hex = hashlib.sha256( - f"awooop-runtime-root-span:{run_id}".encode("utf-8") + f"awooop-runtime-root-span:{run_id}".encode() ).hexdigest()[:16] return f"00-{trace_hex}-{span_hex}-01"