From 309dd3d7ab573ccba220499526ebd3cabe0d7e94 Mon Sep 17 00:00:00 2001 From: ogt Date: Wed, 15 Jul 2026 02:46:18 +0800 Subject: [PATCH] test(ci): expire runtime receipt cache by configured ttl --- .../test_ai_agent_autonomous_runtime_control.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/api/tests/test_ai_agent_autonomous_runtime_control.py b/apps/api/tests/test_ai_agent_autonomous_runtime_control.py index e2baa3fc1..6d3b970d1 100644 --- a/apps/api/tests/test_ai_agent_autonomous_runtime_control.py +++ b/apps/api/tests/test_ai_agent_autonomous_runtime_control.py @@ -1073,11 +1073,14 @@ async def test_live_runtime_receipt_readback_uses_last_verified_cache_when_db_de try: first = await runtime_control_module.load_ai_agent_autonomous_runtime_receipt_readback() cache_key = ("awoooi", 24, 20) + cache_expiry_age_seconds = ( + runtime_control_module._RUNTIME_RECEIPT_READBACK_CACHE_TTL_SECONDS + 1.0 + ) stored_at, cached_readback = ( runtime_control_module._runtime_receipt_readback_cache[cache_key] ) runtime_control_module._runtime_receipt_readback_cache[cache_key] = ( - stored_at - 21.0, + stored_at - cache_expiry_age_seconds, cached_readback, ) second = await runtime_control_module.load_ai_agent_autonomous_runtime_receipt_readback() @@ -1094,7 +1097,7 @@ async def test_live_runtime_receipt_readback_uses_last_verified_cache_when_db_de assert fallback["reason"] == "live_runtime_receipt_readback_degraded" assert fallback["live_db_read_status"] == "unavailable" assert fallback["live_error_type"] == "RuntimeReceiptDbContextTimeout" - assert fallback["cache_age_seconds"] >= 21.0 + assert fallback["cache_age_seconds"] >= cache_expiry_age_seconds assert fallback["max_stale_seconds"] == 300.0 assert fallback["source"] == "in_process_last_verified_db_receipt_readback" assert fallback["durable_receipts_reused"] is True @@ -1154,11 +1157,14 @@ async def test_live_runtime_receipt_preserves_identity_partial_when_db_unavailab try: first = await runtime_control_module.load_ai_agent_autonomous_runtime_receipt_readback() cache_key = ("awoooi", 24, 20) + cache_expiry_age_seconds = ( + runtime_control_module._RUNTIME_RECEIPT_READBACK_CACHE_TTL_SECONDS + 1.0 + ) stored_at, cached_readback = ( runtime_control_module._runtime_receipt_readback_cache[cache_key] ) runtime_control_module._runtime_receipt_readback_cache[cache_key] = ( - stored_at - 21.0, + stored_at - cache_expiry_age_seconds, cached_readback, ) second = await runtime_control_module.load_ai_agent_autonomous_runtime_receipt_readback()