fix(telegram): close Agent99 lifecycle ack
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 1m24s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 1m24s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
This commit is contained in:
@@ -769,6 +769,67 @@ async def test_lifecycle_reconciles_pending_send_without_duplicate_provider_mess
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lifecycle_reconciles_provider_sent_pending_ack_without_resend(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
send_calls: list[dict] = []
|
||||
reconcile_calls: list[dict] = []
|
||||
|
||||
class Gateway:
|
||||
async def send_agent99_lifecycle_receipt(self, **kwargs):
|
||||
send_calls.append(kwargs)
|
||||
return {
|
||||
"ok": True,
|
||||
"result": {"message_id": 9129},
|
||||
"_awooop_outbound_mirror_acknowledged": False,
|
||||
"_awooop_delivery_status": (
|
||||
"provider_sent_durable_receipt_pending"
|
||||
),
|
||||
"_awooop_provider_send_performed": True,
|
||||
"_awooop_delivery_context": {
|
||||
"destination_binding_verified": True,
|
||||
"destination_binding": "a" * 64,
|
||||
},
|
||||
}
|
||||
|
||||
async def reconcile_agent99_lifecycle_receipt(self, **kwargs):
|
||||
reconcile_calls.append(kwargs)
|
||||
return {
|
||||
"ok": True,
|
||||
"result": {"message_id": 9129},
|
||||
"_awooop_outbound_mirror_acknowledged": True,
|
||||
"_awooop_delivery_status": "sent_reused",
|
||||
"_awooop_provider_send_performed": False,
|
||||
"_awooop_delivery_context": {
|
||||
"destination_binding_verified": True,
|
||||
},
|
||||
}
|
||||
|
||||
async def no_sleep(_delay: float) -> None:
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(
|
||||
lifecycle_service,
|
||||
"get_telegram_gateway",
|
||||
lambda: Gateway(),
|
||||
)
|
||||
monkeypatch.setattr(lifecycle_service.asyncio, "sleep", no_sleep)
|
||||
|
||||
receipt = await lifecycle_service.deliver_agent99_telegram_lifecycle(
|
||||
Agent99TelegramLifecycleRequest.model_validate(payload())
|
||||
)
|
||||
|
||||
assert receipt["ok"] is True
|
||||
assert receipt["delivery_status"] == "sent_reused"
|
||||
assert receipt["provider_send_performed"] is True
|
||||
assert receipt["durable_reconciliation_attempts"] == 1
|
||||
assert len(send_calls) == 1
|
||||
assert len(reconcile_calls) == 1
|
||||
assert reconcile_calls[0]["expected_provider_message_id"] == "9129"
|
||||
assert reconcile_calls[0]["expected_destination_binding"] == "a" * 64
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lifecycle_follower_only_reads_inflight_durable_delivery(
|
||||
monkeypatch,
|
||||
|
||||
@@ -738,7 +738,7 @@ async def test_projection_stays_open_until_durable_telegram_readback(
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_controlled_result_pending_reservation_retries_provider_send(
|
||||
async def test_controlled_result_pending_reservation_blocks_duplicate_provider_send(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
class _Response:
|
||||
@@ -779,11 +779,11 @@ async def test_controlled_result_pending_reservation_retries_provider_send(
|
||||
"message_id": "00000000-0000-0000-0000-000000000202",
|
||||
},
|
||||
{
|
||||
"status": "reserved",
|
||||
"status": "pending_unknown",
|
||||
"run_id": "00000000-0000-0000-0000-000000000201",
|
||||
"message_id": "00000000-0000-0000-0000-000000000202",
|
||||
"durable_reservation_committed": True,
|
||||
"reused_pending_reservation": True,
|
||||
"provider_retry_blocked": True,
|
||||
},
|
||||
]
|
||||
)
|
||||
@@ -808,15 +808,13 @@ async def test_controlled_result_pending_reservation_retries_provider_send(
|
||||
_controlled_result_payload(),
|
||||
)
|
||||
|
||||
assert client.post_count == 2
|
||||
assert client.post_count == 1
|
||||
assert first["_awooop_provider_send_performed"] is True
|
||||
assert first["_awooop_outbound_mirror_acknowledged"] is False
|
||||
assert second["ok"] is True
|
||||
assert second["_awooop_provider_send_performed"] is True
|
||||
assert second["_awooop_delivery_status"] == (
|
||||
"provider_sent_durable_receipt_pending"
|
||||
)
|
||||
assert finalize.await_count == 2
|
||||
assert second["ok"] is False
|
||||
assert second["_awooop_provider_send_performed"] is False
|
||||
assert second["_awooop_delivery_status"] == "pending_unknown"
|
||||
assert finalize.await_count == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -925,6 +923,10 @@ async def test_controlled_result_finalize_backfills_missing_destination_binding(
|
||||
assert "{canonical_route_receipt,destination_binding}" in update_sql
|
||||
assert "COALESCE(" in update_sql
|
||||
assert "IN ('', :expected_destination_binding)" in update_sql
|
||||
assert "CAST(" in update_sql
|
||||
assert ":expected_destination_binding\n" in update_sql
|
||||
assert "AS text" in update_sql
|
||||
assert ":expected_destination_binding::text" not in update_sql
|
||||
assert db.parameters[1]["expected_destination_binding"] == "a" * 64
|
||||
|
||||
|
||||
@@ -1300,6 +1302,8 @@ def test_controlled_result_uses_durable_reservation_and_single_reconcile_entry()
|
||||
assert "digest_window_minutes" in reserve_source
|
||||
assert "notification_suppressed_deduplicated" in reserve_source
|
||||
assert "durable_reservation_committed" in reserve_source
|
||||
assert "provider_retry_blocked" in reserve_source
|
||||
assert "reused_pending_reservation" not in reserve_source
|
||||
assert "reservation_readback_failed" not in reserve_source
|
||||
assert "UPDATE awooop_outbound_message" in finalize_source
|
||||
assert "_CONTROLLED_APPLY_OUTBOUND_FINALIZE_ATTEMPTS" in finalize_source
|
||||
|
||||
Reference in New Issue
Block a user