-- ADR-090-D: automation_operation_log.operation_type adds Ansible executor audit states
-- Created: 2026-05-12 Taipei
--
-- Purpose:
--   T3 Ansible declarative executor visibility. These operation types allow
--   the AI automation truth chain to record that Ansible was matched,
--   check-mode executed, applied, rolled back, or explicitly skipped.
--
-- Safety:
--   This migration only expands the CHECK allowlist. It does not execute
--   Ansible, change approval behavior, or create auto-remediation rows.

ALTER TABLE automation_operation_log
    DROP CONSTRAINT IF EXISTS automation_operation_log_type_valid;

ALTER TABLE automation_operation_log
    ADD CONSTRAINT automation_operation_log_type_valid CHECK (operation_type IN (
        'monitor_configured','monitor_removed',
        'alert_fired','alert_suppressed','alert_routed',
        'rule_created','rule_updated','rule_matched','rule_rejected','rule_deprecated',
        'playbook_generated','playbook_updated','playbook_executed',
        'remediation_executed','remediation_verified','remediation_rolled_back',
        'self_correction_attempted',
        'km_created','km_updated','km_linked',
        'asset_discovered','coverage_recalculated',
        'capacity_recommendation','quota_enforced',
        'notification_formatted',
        'ansible_candidate_matched',
        'ansible_check_mode_executed',
        'ansible_apply_executed',
        'ansible_rollback_executed',
        'ansible_execution_skipped'
    ));

COMMENT ON CONSTRAINT automation_operation_log_type_valid ON automation_operation_log IS
    'ADR-090-D: allow first-class Ansible executor audit states for AwoooP truth-chain visibility.';
