"""reset activation gate settings for the EV-based redesign

The activation gate was redesigned around expected value (R): the core test is
now ``min_expected_value`` instead of the old, self-contradicting pair of a high
``min_rr`` AND a high ``min_target_probability`` (with the post-recalibration
probability model the two could not be satisfied together, so nothing qualified).
The conviction / conflict toggles are now optional tighteners that default off.

Stored ``activation_*`` rows from the old gate no longer map cleanly onto the new
one, so they are cleared here and the redesigned code defaults take effect. Re-tune
in Admin → Activation (validated against the Track Record's backtest EV sweep).

Revision ID: 009
Revises: 008
Create Date: 2026-06-23 00:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "009"
down_revision: Union[str, None] = "008"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.execute(
        sa.text("DELETE FROM system_settings WHERE key LIKE 'activation\\_%' ESCAPE '\\'")
    )


def downgrade() -> None:
    # One-way data reset — the old per-key values aren't recoverable. Code defaults
    # apply until re-tuned, so there is nothing to restore.
    pass
