fix(agent99): reconcile durable callbacks as verified repairs
This commit is contained in:
@@ -782,6 +782,174 @@ def test_build_dossier_recurrence_opens_work_item_for_completed_run_without_repa
|
||||
}
|
||||
|
||||
|
||||
def test_agent99_durable_callback_closes_recurrence_automation_gap() -> None:
|
||||
incident_id = "INC-20260712-72CBC5"
|
||||
recurrence = build_dossier_recurrence(
|
||||
[
|
||||
{
|
||||
"event_id": "11111111-1111-4111-8111-111111111111",
|
||||
"project_id": "awoooi",
|
||||
"channel_type": "internal",
|
||||
"provider_event_id": "agent99:resolved:callback-1",
|
||||
"content_hash": "a" * 64,
|
||||
"content_preview": f"Agent99 Recover resolved {incident_id}",
|
||||
"content_redacted": f"Agent99 Recover resolved {incident_id}",
|
||||
"redaction_version": "audit_sink_v1",
|
||||
"source_envelope": {
|
||||
"provider": "agent99",
|
||||
"stage": "resolved",
|
||||
"source_refs": {"incident_ids": [incident_id]},
|
||||
"log_correlation": {
|
||||
"target_resource": "cold-start-gate",
|
||||
"fingerprint": "agent99-cold-start",
|
||||
},
|
||||
},
|
||||
"is_duplicate": False,
|
||||
"provider_ts": None,
|
||||
"received_at": "2026-07-14T09:30:28",
|
||||
"run_id": UUID("22222222-2222-4222-8222-222222222222"),
|
||||
"run_state": "completed",
|
||||
"run_agent_id": "agent99",
|
||||
}
|
||||
],
|
||||
project_id="awoooi",
|
||||
limit=20,
|
||||
repair_summaries_by_incident={
|
||||
incident_id: {
|
||||
"schema_version": "awooop_recurrence_repair_summary_v1",
|
||||
"incident_id": incident_id,
|
||||
"repair_evidence_kind": "agent99_completion_callback",
|
||||
"latest_auto_repair_id": None,
|
||||
"latest_agent99_callback_id": "agent99:callback-1:resolved",
|
||||
"latest_success": True,
|
||||
"latest_verification_result": "success",
|
||||
"operation_receipt_count": 2,
|
||||
"verified_callback_total": 1,
|
||||
"auto_repair_total": 0,
|
||||
"success_total": 1,
|
||||
"failed_total": 0,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
item = recurrence["items"][0]
|
||||
assert recurrence["summary"]["verified_repair_group_total"] == 1
|
||||
assert recurrence["summary"]["agent99_callback_verified_group_total"] == 1
|
||||
assert recurrence["summary"]["automation_gap_group_total"] == 0
|
||||
assert recurrence["summary"]["open_work_item_group_total"] == 0
|
||||
assert item["repair_summary"]["status"] == "agent99_callback_verified"
|
||||
assert item["work_item"] == {
|
||||
"schema_version": "awooop_recurrence_work_item_link_v1",
|
||||
"work_item_id": f"incident:{incident_id}",
|
||||
"incident_id": incident_id,
|
||||
"matched_incident_id": None,
|
||||
"auto_repair_id": None,
|
||||
"status": "closed",
|
||||
"kind": "verified_repair",
|
||||
"next_step": "monitor_recurrence",
|
||||
"reason": "agent99_callback_durable_verified",
|
||||
"needs_human": False,
|
||||
}
|
||||
|
||||
|
||||
def test_agent99_callback_does_not_close_reopened_recurrence() -> None:
|
||||
incident_id = "INC-20260712-72CBC5"
|
||||
recurrence = build_dossier_recurrence(
|
||||
[
|
||||
{
|
||||
"event_id": "11111111-1111-4111-8111-111111111111",
|
||||
"project_id": "awoooi",
|
||||
"channel_type": "internal",
|
||||
"provider_event_id": "agent99:firing:callback-2",
|
||||
"content_hash": "b" * 64,
|
||||
"content_preview": f"Agent99 firing {incident_id}",
|
||||
"content_redacted": f"Agent99 firing {incident_id}",
|
||||
"redaction_version": "audit_sink_v1",
|
||||
"source_envelope": {
|
||||
"provider": "agent99",
|
||||
"stage": "firing",
|
||||
"source_refs": {"incident_ids": [incident_id]},
|
||||
"log_correlation": {"fingerprint": "agent99-cold-start"},
|
||||
},
|
||||
"is_duplicate": False,
|
||||
"provider_ts": None,
|
||||
"received_at": "2026-07-14T09:35:00",
|
||||
"run_id": UUID("22222222-2222-4222-8222-222222222222"),
|
||||
"run_state": "completed",
|
||||
"run_agent_id": "agent99",
|
||||
}
|
||||
],
|
||||
project_id="awoooi",
|
||||
limit=20,
|
||||
repair_summaries_by_incident={
|
||||
incident_id: {
|
||||
"repair_evidence_kind": "agent99_completion_callback",
|
||||
"latest_success": True,
|
||||
"latest_verification_result": "success",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
item = recurrence["items"][0]
|
||||
assert item["repair_summary"]["status"] == (
|
||||
"agent99_callback_verification_stale"
|
||||
)
|
||||
assert item["work_item"]["status"] == "open"
|
||||
assert item["work_item"]["needs_human"] is False
|
||||
assert item["work_item"]["next_step"] == "rerun_agent99_verifier"
|
||||
assert recurrence["summary"]["verified_repair_group_total"] == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_agent99_callback_summary_requires_execution_and_resolution() -> None:
|
||||
captured: list[dict[str, object]] = []
|
||||
|
||||
class FakeMappings:
|
||||
def all(self) -> list[dict[str, object]]:
|
||||
return [
|
||||
{
|
||||
"incident_id": "INC-20260712-72CBC5",
|
||||
"callback_id": "agent99:callback-1:resolved",
|
||||
"callback_run_id": "sre-alert-1",
|
||||
"operation_receipt_count": 2,
|
||||
"latest_callback_at": "2026-07-14T09:30:29",
|
||||
"verified_callback_total": 1,
|
||||
}
|
||||
]
|
||||
|
||||
class FakeResult:
|
||||
def mappings(self) -> FakeMappings:
|
||||
return FakeMappings()
|
||||
|
||||
class FakeDb:
|
||||
async def execute(self, statement, params): # noqa: ANN001
|
||||
captured.append({"sql": str(statement), "params": params})
|
||||
return FakeResult()
|
||||
|
||||
result = await channel_event_dossier_service._fetch_agent99_callback_summaries_by_incident(
|
||||
FakeDb(),
|
||||
["INC-20260712-72CBC5"],
|
||||
project_id="awoooi",
|
||||
)
|
||||
|
||||
summary = result["INC-20260712-72CBC5"]
|
||||
assert summary["repair_evidence_kind"] == "agent99_completion_callback"
|
||||
assert summary["latest_verification_result"] == "success"
|
||||
assert summary["operation_receipt_count"] == 2
|
||||
assert summary["verified_callback_total"] == 1
|
||||
sql = str(captured[0]["sql"])
|
||||
assert "EXECUTION_COMPLETED" in sql
|
||||
assert "RESOLVED" in sql
|
||||
assert "verifier_passed" in sql
|
||||
assert "source_event_resolved" in sql
|
||||
assert captured[0]["params"] == {
|
||||
"actor": "agent99_completion_callback",
|
||||
"schema_version": "agent99_completion_callback_v1",
|
||||
"project_id": "awoooi",
|
||||
"agent99_incident_id_0": "INC-20260712-72CBC5",
|
||||
}
|
||||
|
||||
|
||||
def test_build_recurrence_work_item_preview_selects_ticket_mode() -> None:
|
||||
recurrence = build_dossier_recurrence(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user