""" RiskTieringResult — output contract for Phase 6's classifier. This is the second structured payload the pipeline produces (after DetectionOutput from Phase 5). It is consumed by: Phase 7 to scope severity analysis (only run analysis for med/high) Phase 8 to shape the response plan (different actions per tier) Phase 10 to decide whether to fan out crowd-verification pushes Like DetectionOutput, this model is frozen + extra="forbid" so the classifier (and any future LLM-backed variant) can't silently grow the schema. Frozen also signals that once tiering is decided for a given crisis, downstream agents do not retro-edit it. """ from __future__ import annotations from typing import Literal from pydantic import BaseModel, ConfigDict, Field RiskLevel = Literal["low", "medium", "high"] class RiskTieringResult(BaseModel): """Classification outcome from `services.risk_tiering.classify_risk`. Attributes: risk_level: The tier the crisis falls into. Drives every downstream routing decision in the pipeline. requires_crowd_verification: Whether radius-based push notifications should be sent to nearby app users before contacting emergency services. True for medium/high and unknown types; False for low. requires_emergency_services: Whether the crisis is one that ultimately needs an emergency dispatch (after verification, if verification is required). Phase 8's planning agent owns the actual dispatch decision; this flag is just the eligibility signal. auto_response_actions: Actions that can fire immediately without human confirmation — populated only for low-risk crises (e.g. ["reroute_traffic", "send_area_alert"]). Always [] for medium/high. reasoning: One short sentence explaining why this tier was chosen. Rendered in the agent-trace UI alongside the LLM agents' reasoning fields. """ model_config = ConfigDict(frozen=True, extra="forbid") risk_level: RiskLevel requires_crowd_verification: bool requires_emergency_services: bool auto_response_actions: list[str] = Field(default_factory=list) reasoning: str