test(ci): expire runtime receipt cache by configured ttl

This commit is contained in:
ogt
2026-07-15 02:46:18 +08:00
parent 19b7445c1a
commit 309dd3d7ab

View File

@@ -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()