"""Seed default decay policies."""
from datetime import datetime
from sqlalchemy.orm import Session
from app.models.decay_policy import DecayPolicy


def seed_decay_policies(db: Session) -> None:
    existing = db.query(DecayPolicy).filter(DecayPolicy.is_default == True).first()
    if existing:
        return

    now = datetime.utcnow()
    default_policy = DecayPolicy(
        name="Default Decay Policy",
        description="Standard: Fresh 90d, Aging 91-180d, Stale 181-365d.",
        fresh_days=90, aging_days=180, stale_days=365,
        default_validity_days=180, silent_threshold_days=30,
        noisy_threshold_daily=100,
        recency_weight=0.30, coverage_weight=0.30,
        health_weight=0.25, diversity_weight=0.15,
        is_default=True, is_active=True,
        created_at=now, updated_at=now,
    )
    db.add(default_policy)

    critical_policy = DecayPolicy(
        name="Critical Techniques Policy",
        description="Stricter: Fresh 60d, Aging 90d, Stale 180d.",
        applies_to_tactic="initial-access",
        fresh_days=60, aging_days=90, stale_days=180,
        default_validity_days=90, silent_threshold_days=14,
        noisy_threshold_daily=50,
        recency_weight=0.35, coverage_weight=0.30,
        health_weight=0.25, diversity_weight=0.10,
        is_default=False, is_active=True,
        created_at=now, updated_at=now,
    )
    db.add(critical_policy)
    db.commit()
