fix(agent): replace terminally skipped candidates
This commit is contained in:
@@ -742,12 +742,23 @@ async def record_ansible_decision_audit(
|
||||
)
|
||||
existing = await db.execute(
|
||||
text("""
|
||||
SELECT op_id
|
||||
FROM automation_operation_log
|
||||
WHERE operation_type = 'ansible_candidate_matched'
|
||||
AND coalesce(incident_id::text, input ->> 'incident_id') = :incident_id
|
||||
AND input ->> 'executor' = 'ansible'
|
||||
AND input ->> 'decision_path' = 'repair_candidate_controlled_queue'
|
||||
SELECT candidate.op_id
|
||||
FROM automation_operation_log candidate
|
||||
WHERE candidate.operation_type = 'ansible_candidate_matched'
|
||||
AND coalesce(
|
||||
candidate.incident_id::text,
|
||||
candidate.input ->> 'incident_id'
|
||||
) = :incident_id
|
||||
AND candidate.input ->> 'executor' = 'ansible'
|
||||
AND candidate.input ->> 'decision_path'
|
||||
= 'repair_candidate_controlled_queue'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM automation_operation_log terminal
|
||||
WHERE terminal.parent_op_id = candidate.op_id
|
||||
AND terminal.operation_type
|
||||
= 'ansible_execution_skipped'
|
||||
)
|
||||
LIMIT 1
|
||||
"""),
|
||||
{"incident_id": incident_id},
|
||||
|
||||
@@ -150,7 +150,10 @@ def test_ansible_audit_keeps_external_incident_id_in_json_not_bigint_column() ->
|
||||
claim_source = inspect.getsource(claim_pending_check_modes)
|
||||
|
||||
assert "operation_type, actor, status, incident_id" in decision_source
|
||||
assert "coalesce(incident_id::text, input ->> 'incident_id')" in decision_source
|
||||
assert "candidate.incident_id::text" in decision_source
|
||||
assert "candidate.input ->> 'incident_id'" in decision_source
|
||||
assert "terminal.parent_op_id = candidate.op_id" in decision_source
|
||||
assert "ansible_execution_skipped" in decision_source
|
||||
assert "operation_type, actor, status, incident_id" in claim_source
|
||||
assert "incident_db_id" in decision_source
|
||||
assert "incident_db_id" in claim_source
|
||||
|
||||
Reference in New Issue
Block a user