from __future__ import annotations

from datetime import datetime, timezone
from typing import Any, Literal

from pydantic import BaseModel, Field


SkillStatus = Literal["candidate", "shadow", "active", "deprecated", "retired"]
SkillInjectionMode = Literal["metadata_only", "summary", "full"]


class SkillShortlistEntry(BaseModel):
    skill_name: str
    source: str = "runtime"
    source_id: str | None = None
    status: SkillStatus = "active"
    scope: list[str] = Field(default_factory=list)
    effectiveness: float | None = None
    score: float = 0.0
    rationale: str | None = None
    summary: str | None = None
    matched_terms: list[str] = Field(default_factory=list)
    injection_mode: SkillInjectionMode = "metadata_only"
    metadata: dict[str, Any] = Field(default_factory=dict)


class SkillActivationRecord(BaseModel):
    skill_name: str
    source: str = "runtime"
    source_id: str | None = None
    status: SkillStatus = "active"
    injection_mode: SkillInjectionMode = "metadata_only"
    matched_terms: list[str] = Field(default_factory=list)
    rationale: str | None = None
    activated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
    outcome: str | None = None
    metadata: dict[str, Any] = Field(default_factory=dict)
