"""Decay Policy model — configurable detection validity rules."""

import uuid
from datetime import datetime
from sqlalchemy import Column, String, Integer, Float, Boolean, DateTime, Text
from sqlalchemy.dialects.postgresql import UUID
from app.database import Base


class DecayPolicy(Base):
    __tablename__ = "decay_policies"

    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    name = Column(String(200), nullable=False)
    description = Column(Text)
    applies_to_platform = Column(String(100))
    applies_to_asset_type = Column(String(50))
    applies_to_tactic = Column(String(100))
    fresh_days = Column(Integer, default=90, server_default='90')
    aging_days = Column(Integer, default=180, server_default='180')
    stale_days = Column(Integer, default=365, server_default='365')
    default_validity_days = Column(Integer, default=180, server_default='180')
    silent_threshold_days = Column(Integer, default=30, server_default='30')
    noisy_threshold_daily = Column(Integer, default=100, server_default='100')
    recency_weight = Column(Float, default=0.3, server_default='0.3')
    coverage_weight = Column(Float, default=0.3, server_default='0.3')
    health_weight = Column(Float, default=0.25, server_default='0.25')
    diversity_weight = Column(Float, default=0.15, server_default='0.15')
    is_default = Column(Boolean, default=False, server_default='false')
    is_active = Column(Boolean, default=True, server_default='true')
    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow)
