fix(sre): render backup checks as no-write receipts
This commit is contained in:
@@ -147,6 +147,84 @@ async def test_agent99_mcp_ack_is_same_run_durable_and_idempotent(
|
||||
assert second == expected
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_backup_telegram_ack_is_no_write_lifecycle_not_apply(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
identity = build_agent99_dispatch_identity(
|
||||
project_id="awoooi",
|
||||
incident_id="INC-20260719-BACKUP",
|
||||
source_fingerprint="backup-fingerprint-1",
|
||||
route_id="agent99:backup_health:BackupCheck",
|
||||
)
|
||||
delivered = []
|
||||
|
||||
async def deliver(payload): # type: ignore[no-untyped-def]
|
||||
delivered.append(payload)
|
||||
return {
|
||||
"ok": True,
|
||||
"provider_message_id": "9919",
|
||||
"durable_outbound_acknowledged": True,
|
||||
"destination_binding_verified": True,
|
||||
}
|
||||
|
||||
class ForbiddenGateway:
|
||||
async def send_controlled_apply_result_receipt(self, **_kwargs):
|
||||
raise AssertionError("BackupCheck must not use controlled-apply receipt")
|
||||
|
||||
monkeypatch.setattr(job, "deliver_agent99_telegram_lifecycle", deliver)
|
||||
monkeypatch.setattr(job, "get_telegram_gateway", lambda: ForbiddenGateway())
|
||||
|
||||
receipt = await job._ensure_telegram_receipt(
|
||||
identity,
|
||||
mode="BackupCheck",
|
||||
)
|
||||
|
||||
assert receipt == "telegram_outbound:9919:durable_ack"
|
||||
assert len(delivered) == 1
|
||||
payload = delivered[0]
|
||||
assert payload.run_id == str(identity.run_id)
|
||||
assert payload.trace_id == identity.trace_id
|
||||
assert payload.work_item_id == identity.work_item_id
|
||||
assert payload.lifecycle == "verifying"
|
||||
assert payload.executor_name == "Agent99 BackupCheck (read-only)"
|
||||
assert payload.verifier_name == "backup_restore_readback_verifier"
|
||||
assert payload.apply_status == "not_applicable"
|
||||
assert payload.verifier_status == "passed"
|
||||
assert payload.closure_status == "pending"
|
||||
assert "沒有執行備份" in payload.impact
|
||||
assert "LLM 未取得 runtime authority" in payload.action
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_backup_telegram_ack_requires_durable_destination_proof(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
identity = build_agent99_dispatch_identity(
|
||||
project_id="awoooi",
|
||||
incident_id="INC-20260719-BACKUP-FAIL",
|
||||
source_fingerprint="backup-fingerprint-2",
|
||||
route_id="agent99:backup_health:BackupCheck",
|
||||
)
|
||||
|
||||
async def deliver(_payload): # type: ignore[no-untyped-def]
|
||||
return {
|
||||
"ok": False,
|
||||
"provider_message_id": "9920",
|
||||
"durable_outbound_acknowledged": True,
|
||||
"destination_binding_verified": False,
|
||||
}
|
||||
|
||||
monkeypatch.setattr(job, "deliver_agent99_telegram_lifecycle", deliver)
|
||||
|
||||
receipt = await job._ensure_telegram_receipt(
|
||||
identity,
|
||||
mode="BackupCheck",
|
||||
)
|
||||
|
||||
assert receipt is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_reconciler_consumes_authenticated_outcome_and_closes_same_run(
|
||||
monkeypatch,
|
||||
|
||||
Reference in New Issue
Block a user