test(aiops): preserve verified generation contract
This commit is contained in:
@@ -26,6 +26,7 @@ from src.services.awooop_ansible_audit_service import (
|
||||
build_ansible_decision_audit_payload,
|
||||
preflight_ansible_candidate_generation,
|
||||
record_ansible_decision_audit,
|
||||
verified_ansible_candidate_terminal_sql,
|
||||
)
|
||||
from src.services.awooop_ansible_check_mode_service import (
|
||||
preflight_failed_apply_retry_queue_once,
|
||||
@@ -65,10 +66,12 @@ async def _fetch_missing_candidate_incidents(
|
||||
window_hours: int,
|
||||
scan_limit: int,
|
||||
) -> list[dict[str, Any]]:
|
||||
terminal_candidate_sql = verified_ansible_candidate_terminal_sql(
|
||||
"candidate"
|
||||
)
|
||||
async with get_db_context(project_id) as db:
|
||||
await db.execute(text("SET LOCAL statement_timeout = '5000ms'"))
|
||||
result = await db.execute(
|
||||
text("""
|
||||
query_sql = """
|
||||
SELECT
|
||||
incidents.incident_id,
|
||||
incidents.project_id,
|
||||
@@ -94,6 +97,8 @@ async def _fetch_missing_candidate_incidents(
|
||||
AS latest_candidate_target_route_generation,
|
||||
latest_candidate.source_occurrence_generation
|
||||
AS latest_candidate_source_occurrence_generation,
|
||||
latest_candidate.is_terminal
|
||||
AS latest_candidate_is_terminal,
|
||||
(
|
||||
SELECT approval.id
|
||||
FROM approval_records approval
|
||||
@@ -134,7 +139,8 @@ async def _fetch_missing_candidate_incidents(
|
||||
candidate.input ->> 'target_route_generation'
|
||||
AS target_route_generation,
|
||||
candidate.input ->> 'source_occurrence_generation'
|
||||
AS source_occurrence_generation
|
||||
AS source_occurrence_generation,
|
||||
({terminal_candidate_sql}) AS is_terminal
|
||||
FROM automation_operation_log candidate
|
||||
WHERE candidate.operation_type = 'ansible_candidate_matched'
|
||||
AND candidate.input ->> 'executor' = 'ansible'
|
||||
@@ -163,7 +169,11 @@ async def _fetch_missing_candidate_incidents(
|
||||
) = current_recurrence.source_fingerprint
|
||||
ORDER BY current_recurrence.received_at DESC
|
||||
LIMIT :scan_limit
|
||||
"""),
|
||||
""".replace(
|
||||
"{terminal_candidate_sql}", terminal_candidate_sql
|
||||
)
|
||||
result = await db.execute(
|
||||
text(query_sql),
|
||||
{
|
||||
"project_id": project_id,
|
||||
"window_hours": max(1, window_hours),
|
||||
|
||||
Reference in New Issue
Block a user