"""Auto-generated from LOOM_CONTRACT.md by contract_compiler.py vv1.1.0"""

from pydantic import BaseModel, Field
from datetime import datetime
from typing import List, Dict, Optional, Any

class ProphecyReceipt(BaseModel):
    """Prediction with calibration metadata."""

    # Standard receipt fields
    receipt_id: str
    receipt_type: str = "prophecy.v1"
    loomdip: str = "pending"
    signature: str = "unsigned"
    valid_time: datetime = Field(default_factory=datetime.utcnow)
    tier: str = "SIGNED"

    # Prediction-specific fields
    prediction: float  # Point estimate (0.0 - 1.0)
    confidence_interval: Optional[List[float]] = None    # [lower, upper] = None
    features_hash: Optional[str] = None    # SHA256 of feature vector
    model_version: Optional[str] = None    # e.g., "triage_v0.1.2"

    # Calibration metadata
    worst_slice_ece: float  # Expected Calibration Error (≤ 0.03)
    coverage: float  # Proportion of predictions (0.90 ± 0.02)
    dignity: Optional[float] = None    # Dignity score (≥ 0.15)

    # Context
    domain: Optional[str] = None    # "clinical", "sports", "finance", etc.
    scope: Optional[str] = None    # Finer-grained scope
    guardian_ref: Optional[str] = None    # GuardianReceipt ID (must pass before emission)

    # Genesis bridge fields (optional, for council decisions)
    decision_id: Optional[str] = None    # Links to CouncilDecisionReceipt
    horizon_s: Optional[int] = None    # Forecast horizon in seconds
    blocked: Optional[bool] = None    # Blocked if calibration breach
    metadata: Optional[Dict[str, Any]] = None    # Additional context
