"""ml_settings: CCIP auto-apply switch + threshold (#114)

Confident CCIP character matches auto-tag (source='ccip_auto') on a daily sweep,
so identity tags keep flowing without pressing a button. ON by default (opt-out,
like head auto-apply); the high threshold (0.92, above the 0.85 suggest cut) +
single-character references keep it safe, and every auto-tag is reversible.

Revision ID: 0064
Revises: 0063
Create Date: 2026-06-30
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "0064"
down_revision: Union[str, None] = "0063"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "ml_settings",
        sa.Column(
            "ccip_auto_apply_enabled", sa.Boolean(), nullable=False,
            server_default=sa.true(),
        ),
    )
    op.add_column(
        "ml_settings",
        sa.Column(
            "ccip_auto_apply_threshold", sa.Float(), nullable=False,
            server_default="0.92",
        ),
    )


def downgrade() -> None:
    op.drop_column("ml_settings", "ccip_auto_apply_threshold")
    op.drop_column("ml_settings", "ccip_auto_apply_enabled")
