""" Trunk Stability Push-Up rubric scorer — pure function, no model calls. FMS Trunk Stability Push-Up Criteria: - Score 3: body moves as one unit (rigid) with hands at forehead level (men) or chin level (women). No sag or segment lag. - Score 2: body moves as one unit but with hands at chin (men) or clavicle (women). - Score 1: unable to perform with hands lowered; body sags or segments. - Score 0: PAIN (spinal extension clearing test) — never auto-scored. """ from __future__ import annotations from formscout.types import BiomechFeatures, ScoreResult def score_trunk_stability_pushup(features: BiomechFeatures) -> ScoreResult: """Pure rubric scorer for trunk stability push-up.""" angles = features.angles alignments = features.alignments has_data = "max_sag_px" in angles if not has_data: return ScoreResult( score=1, rationale="Insufficient data: trunk rigidity not measurable", confidence=0.3, notes="missing key measurements", ) body_rigid = alignments.get("body_rigid", False) no_sag = alignments.get("no_sag", False) hands_high = alignments.get("hands_at_forehead", False) rationale_parts = [] if body_rigid and hands_high: score = 3 rationale_parts.append("Body rigid as one unit, hands at forehead position") elif body_rigid or no_sag: score = 2 if not hands_high: rationale_parts.append("rigid body but hands in lower position") else: rationale_parts.append("minor trunk variance detected") rationale_parts.insert(0, "Completed with regression") else: score = 1 sag = angles.get("max_sag_px", 0) variance = angles.get("trunk_variance_px", 0) rationale_parts.append(f"Body sag detected ({sag:.0f}px), variance {variance:.1f}px") confidence = features.confidence * 0.8 return ScoreResult( score=score, rationale="; ".join(rationale_parts), confidence=confidence, notes="", )