"""Rule-only baseline.""" from __future__ import annotations from app.common.enums import ActionType, DecisionMode, DoseBucket from app.common.types import CandidateAction, PolyGuardAction def choose_rules_only(candidates: list[CandidateAction]) -> PolyGuardAction: ranked = sorted(candidates, key=lambda c: (c.legality_precheck, c.estimated_safety_delta), reverse=True) top = ranked[0] return PolyGuardAction( mode=top.mode, action_type=top.action_type, target_drug=top.target_drug, replacement_drug=top.replacement_drug, dose_bucket=top.dose_bucket, taper_days=top.taper_days, monitoring_plan=top.monitoring_plan, candidate_id=top.candidate_id, confidence=0.75, rationale_brief="Rules-only selected top legal candidate.", )