from __future__ import annotations

from typing import Optional

from receipts.compat.pyd import BaseModel, Field
from receipts.base import BaseReceipt


class NormativeShadowReceipt(BaseReceipt):
    """
    Receipt emitted by a stricter shadow evaluation of a live decision.

    Carries the shadow configuration and whether it disagreed with the live verdict.
    """

    receipt_type: str = Field(default="NormativeShadowReceipt", alias="type")
    domain: str = Field(default="shadow")

    target_receipt_id: Optional[str] = Field(
        default=None, description="Live receipt being critiqued"
    )
    episode_id: Optional[str] = Field(
        default=None, description="Episode containing the target receipt"
    )
    intent_contract_id: Optional[str] = Field(
        default=None, description="Intent contract in force for the Episode"
    )
    shadow_profile: Optional[str] = Field(
        default=None, description="Stricter profile used for shadow evaluation"
    )
    shadow_policy_ref: Optional[str] = Field(
        default=None, description="Policy ref/commit used for shadow evaluation"
    )
    shadow_model_ref: Optional[str] = Field(
        default=None, description="Model/config used for shadow evaluation"
    )
    normative_verdict: str = Field(
        default="ok",
        description="Shadow verdict compared to live (ok|would_refuse|would_reshape|higher_risk)",
    )
    rationale: Optional[str] = Field(
        default=None, description="Short explanation of disagreement/concern"
    )

    disagreement: bool = Field(
        default=False, description="True if shadow verdict disagrees with live"
    )

