Merge remote-tracking branch 'gitea-ssh/main' into codex/p0-b-incident-closure-20260722

This commit is contained in:
Your Name
2026-07-22 18:07:05 +08:00
6 changed files with 131 additions and 6 deletions

View File

@@ -70,6 +70,7 @@ _WAZUH_INCOMPLETE_RUNTIME_RETRY_REASONS = frozenset(
"controlled_apply_failed",
"post_apply_learning_incomplete",
"recipient_visible_transition_missing",
"scheduled_candidate_recurrence_expired_before_claim",
}
)
_WAZUH_INGRESS_CATALOG_ID = "ansible:wazuh-alertmanager-integration"
@@ -1219,6 +1220,8 @@ async def enqueue_iwooos_wazuh_manager_posture_candidate_once(
telegram.send_status AS latest_telegram_send_status,
telegram.provider_message_id
AS latest_telegram_provider_message_id,
execution_skip.input ->> 'not_used_reason'
AS latest_execution_skip_reason,
EXISTS (
SELECT 1
FROM incident_evidence evidence
@@ -1290,6 +1293,14 @@ async def enqueue_iwooos_wazuh_manager_posture_candidate_once(
ORDER BY packet.created_at DESC
LIMIT 1
) capability_packet ON TRUE
LEFT JOIN LATERAL (
SELECT skipped.input
FROM automation_operation_log skipped
WHERE skipped.parent_op_id = candidate.op_id
AND skipped.operation_type = 'ansible_execution_skipped'
ORDER BY skipped.created_at DESC, skipped.op_id DESC
LIMIT 1
) execution_skip ON TRUE
LEFT JOIN LATERAL (
SELECT outbound.send_status,
outbound.provider_message_id
@@ -1681,6 +1692,10 @@ async def enqueue_iwooos_wazuh_manager_posture_candidate_once(
retry_attempt_ref = f"{deploy_ref}-learning"
elif retry_reason == "recipient_visible_transition_missing":
retry_attempt_ref = f"{deploy_ref}-receipt"
elif retry_reason == (
"scheduled_candidate_recurrence_expired_before_claim"
):
retry_attempt_ref = f"{deploy_ref}-recurrence"
elif latest_check_status == "success":
retry_attempt_ref = f"{deploy_ref}-context"
retry_reason = "predecision_context"
@@ -2001,6 +2016,11 @@ def _wazuh_posture_retry_reason(
check_status = str(existing_row.get("latest_check_status") or "")
apply_status = str(existing_row.get("latest_apply_status") or "")
learning_status = str(existing_row.get("latest_learning_status") or "")
execution_skip_reason = str(
existing_row.get("latest_execution_skip_reason") or ""
)
if execution_skip_reason == "scheduled_candidate_identity_chain_not_verified":
return "scheduled_candidate_recurrence_expired_before_claim"
if check_status == "failed":
return "check_mode_failed"
if apply_status == "failed":