fix(agents): add direct core receipt fallback
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m13s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m13s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -306,6 +306,11 @@ async def test_live_runtime_receipt_db_context_timeout_returns_degraded_payload(
|
||||
assert project_id == "awoooi"
|
||||
return _log_controlled_writeback_consumer_readback()
|
||||
|
||||
async def _no_direct_core_readback(*, project_id: str, lookback_hours: int):
|
||||
assert project_id == "awoooi"
|
||||
assert lookback_hours == 24
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(
|
||||
runtime_control_module,
|
||||
"_RUNTIME_RECEIPT_DB_CONTEXT_TIMEOUT_SECONDS",
|
||||
@@ -321,6 +326,11 @@ async def test_live_runtime_receipt_db_context_timeout_returns_degraded_payload(
|
||||
"_load_log_controlled_writeback_consumer_readback",
|
||||
_fake_consumer_readback,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
runtime_control_module,
|
||||
"_load_core_runtime_receipt_rows_direct",
|
||||
_no_direct_core_readback,
|
||||
)
|
||||
|
||||
try:
|
||||
loader = getattr(
|
||||
@@ -338,6 +348,81 @@ async def test_live_runtime_receipt_db_context_timeout_returns_degraded_payload(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_live_runtime_receipt_db_context_timeout_uses_direct_core_fallback(
|
||||
monkeypatch,
|
||||
):
|
||||
runtime_control_module._clear_runtime_receipt_readback_cache()
|
||||
|
||||
async def _fake_consumer_readback(*, project_id: str):
|
||||
assert project_id == "awoooi"
|
||||
return _log_controlled_writeback_consumer_readback()
|
||||
|
||||
async def _fake_direct_core_readback(*, project_id: str, lookback_hours: int):
|
||||
assert project_id == "awoooi"
|
||||
assert lookback_hours == 24
|
||||
return {
|
||||
"operation_counts": [
|
||||
{
|
||||
"operation_type": "ansible_apply_executed",
|
||||
"status": "success",
|
||||
"total": 5,
|
||||
"recent": 2,
|
||||
}
|
||||
],
|
||||
"verifier_counts": [
|
||||
{"verification_result": "success", "total": 5, "recent": 2}
|
||||
],
|
||||
"km_counts": [
|
||||
{"status": "linked", "total": 5, "recent": 2},
|
||||
],
|
||||
"telegram_counts": [
|
||||
{"send_status": "sent", "total": 5, "recent": 2},
|
||||
],
|
||||
}
|
||||
|
||||
monkeypatch.setattr(
|
||||
runtime_control_module,
|
||||
"_RUNTIME_RECEIPT_DB_CONTEXT_TIMEOUT_SECONDS",
|
||||
0.01,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
runtime_control_module,
|
||||
"get_db_context",
|
||||
lambda project_id: _SlowEnterRuntimeDbContext(),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
runtime_control_module,
|
||||
"_load_log_controlled_writeback_consumer_readback",
|
||||
_fake_consumer_readback,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
runtime_control_module,
|
||||
"_load_core_runtime_receipt_rows_direct",
|
||||
_fake_direct_core_readback,
|
||||
)
|
||||
|
||||
try:
|
||||
loader = getattr(
|
||||
runtime_control_module,
|
||||
"_load_ai_agent_autonomous_runtime_receipt_readback_uncached",
|
||||
)
|
||||
readback = await loader()
|
||||
finally:
|
||||
runtime_control_module._clear_runtime_receipt_readback_cache()
|
||||
|
||||
assert readback["db_read_status"] == "ok"
|
||||
assert readback["ansible_apply_executed"]["total"] == 5
|
||||
assert readback["runtime_receipt_readback_recovery"]["status"] == (
|
||||
"completed_live_runtime_receipts_observed"
|
||||
)
|
||||
progress_items = {
|
||||
item["work_item_id"]: item
|
||||
for item in readback["work_item_progress"]["ordered_items"]
|
||||
}
|
||||
assert progress_items["P0-A-runtime-truth"]["status"] == "completed"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_live_runtime_receipt_lock_timeout_returns_degraded_payload(
|
||||
monkeypatch,
|
||||
|
||||
Reference in New Issue
Block a user