from abc import ABC, abstractmethod from typing import Optional from pydantic import BaseModel class ScannerContext(BaseModel): adult_id: str # The Gmail SSO ID of the parent/teacher child_name: str # For multi-child identification child_class: str # Critical for school-based reporting level: str # beginner/intermediate/advanced locale: str # AU_VIC / IN_NEP video_path: str hw_path: Optional[str] = None target_text: str # Reading Prompt writing_target: str # Writing Prompt (For Levenshtein comparison) parent_email: str report_password: Optional[str] = None """Shared metadata for all clinical engines [cite: 2026-02-21, 2026-02-27]""" session_id: str locale: str has_paper: bool = False class BaseScanner(ABC): """The universal blueprint for every diagnostic scanner.""" @abstractmethod async def analyze(self, video, paper_scan, context: ScannerContext): """Perform biometric extraction and return raw metrics.""" pass @abstractmethod def synthesize_risk(self, metrics: dict) -> float: """Apply clinical weights (e.g., Logarithmic Dampening) to generate a score.""" pass