Spaces:
Running on T4
Running on T4
github-actions[bot] commited on
Commit ·
af23af0
1
Parent(s): 66d2e51
Automated Deploy: 08eecdabd85d69c2641e9d7d7685e50a72849863
Browse files
AI-coach-agent/src/ai_coach/pitch_report/v1_1/coaching.py
CHANGED
|
@@ -77,6 +77,12 @@ Separation increasing is NOT automatically positive, efficient, or an objective
|
|
| 77 |
Never tell the player to maintain separation or keep shoulders closed based on an unvalidated separation estimate.
|
| 78 |
Explain which movement was observed, whether its direction is robust, and what cannot be concluded.
|
| 79 |
If a result is unavailable, discuss checking the marked frame or filming it clearly; NEVER infer its value/direction.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
A model-estimated distance cannot establish an overlong stride. A single separation angle cannot establish early
|
| 81 |
opening. Knee straightening is not a measurement of force or an effective block. Torso lean is not balance.
|
| 82 |
The rotation headings use an arbitrary coordinate basis: target/catcher direction and 'open/closed' positions were
|
|
@@ -97,6 +103,9 @@ speed differs from recording speed. Say the relationship is unknown; never asser
|
|
| 97 |
documented retiming. Variable frame rates are supported using actual capture timestamps; constant FPS
|
| 98 |
is NOT required. Advise preserving the original recording and documenting capture/export speed, not relying on
|
| 99 |
container FPS or requiring constant timestamps. A speed-ramp export needs its explicit capture-time map.
|
|
|
|
|
|
|
|
|
|
| 100 |
Peak rotation order is not energy transfer or automatically correct/incorrect. Missing leg lift in a rocker is not a fault.
|
| 101 |
No pain, medical or injury-risk judgments, ball speed predictions, joint loading, strength deficits, ball-weight,
|
| 102 |
effort, athlete level or age assumptions. Do not prescribe weighted-ball work, increased intensity, or forced joint positions.
|
|
@@ -115,6 +124,35 @@ PROMPT = GUIDANCE + "Return the JSON schema. Facts:\n"
|
|
| 115 |
VERSION = "pitch-coach-ml-3-" + hashlib.sha256(PROMPT.encode()).hexdigest()[:12]
|
| 116 |
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
def facts_for(p, rubric):
|
| 119 |
facts = {
|
| 120 |
"context:drill": {
|
|
@@ -130,7 +168,7 @@ def facts_for(p, rubric):
|
|
| 130 |
),
|
| 131 |
}
|
| 132 |
for m in p.measurements:
|
| 133 |
-
data = m.model_dump(mode="json")
|
| 134 |
if m.metric_id == "lead_knee_extension_to_release":
|
| 135 |
interval = m.value_interval
|
| 136 |
data["direction_supported"] = (
|
|
@@ -142,17 +180,18 @@ def facts_for(p, rubric):
|
|
| 142 |
)
|
| 143 |
facts["measurement:" + m.metric_id] = data
|
| 144 |
for key, e in p.events:
|
| 145 |
-
facts["event:" + key] = e.model_dump(mode="json")
|
| 146 |
for item in rubric["criteria"]:
|
| 147 |
facts["criterion:" + item["criterion_id"]] = item
|
| 148 |
if p.delivery_evidence:
|
| 149 |
ev = p.delivery_evidence
|
| 150 |
-
facts["clock:capture"] = ev.clock.model_dump(mode="json")
|
| 151 |
-
facts["sequence:rotation"] = ev.sequencing.model_dump(mode="json")
|
| 152 |
for phase in ev.phases:
|
| 153 |
phase_data = phase.model_dump(mode="json")
|
| 154 |
# Do not let phase summaries bypass scalar event reliability gates.
|
| 155 |
for motion in phase_data["motion"]:
|
|
|
|
| 156 |
if motion["change"] is None:
|
| 157 |
motion.update(start_value=None, end_value=None, minimum=None, maximum=None)
|
| 158 |
facts["phase:" + phase.phase] = phase_data
|
|
@@ -180,11 +219,72 @@ def _knee_direction_issues(prose, facts):
|
|
| 180 |
direction = knee["direction_supported"]
|
| 181 |
problems = []
|
| 182 |
for claim, pattern in (
|
| 183 |
-
(
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
):
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
return problems
|
| 189 |
|
| 190 |
|
|
@@ -220,6 +320,7 @@ def _check_content(summary, cards, facts):
|
|
| 220 |
if knee_key in facts and knee_key not in cited_facts:
|
| 221 |
cited_facts[knee_key] = {"direction_supported": "unresolved"}
|
| 222 |
problems.extend(_knee_direction_issues(c.observation, cited_facts))
|
|
|
|
| 223 |
prose = " ".join([summary] + [getattr(c, k) for c in cards for k in ("observation", "why_it_matters", "next_step", "check")])
|
| 224 |
quantities = re.sub(r"\b[23][dD]\b", "", prose)
|
| 225 |
quantities = re.sub(r"\b(?:two|three) (?:frames|marks|moments|images|checks|steps)\b", "", quantities, flags=re.I)
|
|
@@ -231,6 +332,7 @@ def _check_content(summary, cards, facts):
|
|
| 231 |
problems.append("unsupported_physical_or_medical_claim")
|
| 232 |
observations = " ".join([summary] + [c.observation for c in cards])
|
| 233 |
problems.extend(_knee_direction_issues(summary, facts))
|
|
|
|
| 234 |
if re.search(r"\b(?:I (?:see|saw|watched)|the (?:video|frames?|footage) (?:shows?|confirms?))\b", prose, re.I):
|
| 235 |
problems.append("direct_visual_claim_not_supported")
|
| 236 |
if re.search(r"towards? (?:the|your) (?:target|catcher|plate)", observations, re.I):
|
|
|
|
| 77 |
Never tell the player to maintain separation or keep shoulders closed based on an unvalidated separation estimate.
|
| 78 |
Explain which movement was observed, whether its direction is robust, and what cannot be concluded.
|
| 79 |
If a result is unavailable, discuss checking the marked frame or filming it clearly; NEVER infer its value/direction.
|
| 80 |
+
Use the supplied reason_meanings when explaining unavailable results. An event_angle_unstable result was withheld
|
| 81 |
+
because moving an event mark to a neighboring frame changes the estimate too much; it does NOT prove unstable
|
| 82 |
+
joint tracking or a tracking failure. Do not claim that a withheld estimate could not be calculated: a calculation
|
| 83 |
+
may exist but fail the reliability check. Describe it as withheld or unavailable for coaching. Temporal
|
| 84 |
+
inconsistency flags uncertainty from tracking OR smoothing, not a confirmed tracking error. Keep each limitation
|
| 85 |
+
attached to its own measurement; do not combine different missing-data causes into one explanation for all results.
|
| 86 |
A model-estimated distance cannot establish an overlong stride. A single separation angle cannot establish early
|
| 87 |
opening. Knee straightening is not a measurement of force or an effective block. Torso lean is not balance.
|
| 88 |
The rotation headings use an arbitrary coordinate basis: target/catcher direction and 'open/closed' positions were
|
|
|
|
| 103 |
documented retiming. Variable frame rates are supported using actual capture timestamps; constant FPS
|
| 104 |
is NOT required. Advise preserving the original recording and documenting capture/export speed, not relying on
|
| 105 |
container FPS or requiring constant timestamps. A speed-ramp export needs its explicit capture-time map.
|
| 106 |
+
Generic file metadata does not prove original capture speed or absence of retiming. Ask for the documented camera
|
| 107 |
+
recording settings and capture/export history, or an explicit capture-time map; do not say checking metadata can
|
| 108 |
+
confirm them. A clearer recording may improve the evidence but does not guarantee stable or accurate tracking.
|
| 109 |
Peak rotation order is not energy transfer or automatically correct/incorrect. Missing leg lift in a rocker is not a fault.
|
| 110 |
No pain, medical or injury-risk judgments, ball speed predictions, joint loading, strength deficits, ball-weight,
|
| 111 |
effort, athlete level or age assumptions. Do not prescribe weighted-ball work, increased intensity, or forced joint positions.
|
|
|
|
| 124 |
VERSION = "pitch-coach-ml-3-" + hashlib.sha256(PROMPT.encode()).hexdigest()[:12]
|
| 125 |
|
| 126 |
|
| 127 |
+
REASON_MEANINGS = {
|
| 128 |
+
"event_angle_unstable": (
|
| 129 |
+
"Estimate withheld: changing an event mark to a neighboring frame changes the angle too much. "
|
| 130 |
+
"This is sensitivity to the marked moment, not proof of tracking failure or inability to calculate an angle."
|
| 131 |
+
),
|
| 132 |
+
"angle_sensitivity_unresolved": (
|
| 133 |
+
"Neighboring event frames do not support a complete sensitivity check; the angle is withheld."
|
| 134 |
+
),
|
| 135 |
+
"temporal_inconsistency": (
|
| 136 |
+
"Tracking or smoothing near this moment makes the estimate uncertain; the cause is not established."
|
| 137 |
+
),
|
| 138 |
+
"phase_direction_unresolved": "Moving the endpoint marks to neighboring frames can change the movement direction.",
|
| 139 |
+
"capture_time_unknown": (
|
| 140 |
+
"Original recording time is undocumented, so physical durations and rotation-speed peak order are unavailable."
|
| 141 |
+
),
|
| 142 |
+
"required_landmarks_unusable": "The required tracked body points do not support this measurement reliably.",
|
| 143 |
+
"phase_tracking_incomplete": "Some required body-point samples are unavailable within this phase.",
|
| 144 |
+
"container_fps_is_not_capture_fps": (
|
| 145 |
+
"File metadata may describe exported playback speed. Documented recording settings and export history "
|
| 146 |
+
"or an explicit capture-time map are needed; generic metadata cannot prove capture speed or no retiming."
|
| 147 |
+
),
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _with_reason_meanings(data):
|
| 152 |
+
data["reason_meanings"] = {r: REASON_MEANINGS[r] for r in data.get("reasons", []) if r in REASON_MEANINGS}
|
| 153 |
+
return data
|
| 154 |
+
|
| 155 |
+
|
| 156 |
def facts_for(p, rubric):
|
| 157 |
facts = {
|
| 158 |
"context:drill": {
|
|
|
|
| 168 |
),
|
| 169 |
}
|
| 170 |
for m in p.measurements:
|
| 171 |
+
data = _with_reason_meanings(m.model_dump(mode="json"))
|
| 172 |
if m.metric_id == "lead_knee_extension_to_release":
|
| 173 |
interval = m.value_interval
|
| 174 |
data["direction_supported"] = (
|
|
|
|
| 180 |
)
|
| 181 |
facts["measurement:" + m.metric_id] = data
|
| 182 |
for key, e in p.events:
|
| 183 |
+
facts["event:" + key] = _with_reason_meanings(e.model_dump(mode="json"))
|
| 184 |
for item in rubric["criteria"]:
|
| 185 |
facts["criterion:" + item["criterion_id"]] = item
|
| 186 |
if p.delivery_evidence:
|
| 187 |
ev = p.delivery_evidence
|
| 188 |
+
facts["clock:capture"] = _with_reason_meanings(ev.clock.model_dump(mode="json"))
|
| 189 |
+
facts["sequence:rotation"] = _with_reason_meanings(ev.sequencing.model_dump(mode="json"))
|
| 190 |
for phase in ev.phases:
|
| 191 |
phase_data = phase.model_dump(mode="json")
|
| 192 |
# Do not let phase summaries bypass scalar event reliability gates.
|
| 193 |
for motion in phase_data["motion"]:
|
| 194 |
+
_with_reason_meanings(motion)
|
| 195 |
if motion["change"] is None:
|
| 196 |
motion.update(start_value=None, end_value=None, minimum=None, maximum=None)
|
| 197 |
facts["phase:" + phase.phase] = phase_data
|
|
|
|
| 219 |
direction = knee["direction_supported"]
|
| 220 |
problems = []
|
| 221 |
for claim, pattern in (
|
| 222 |
+
(
|
| 223 |
+
"straightening",
|
| 224 |
+
r"\b(?:front|lead) (?:knee|leg) (?:estimate )?(?:is |was |appears? to |keeps? )?(?P<movement>straighten\w*)",
|
| 225 |
+
),
|
| 226 |
+
(
|
| 227 |
+
"bending",
|
| 228 |
+
r"\b(?:front|lead) (?:knee|leg) (?:estimate )?(?:is |was |appears? to |keeps? )?"
|
| 229 |
+
r"(?P<movement>bend\w*|flex(?:es|ed|ing)?)\b",
|
| 230 |
+
),
|
| 231 |
):
|
| 232 |
+
for match in re.finditer(pattern, prose, re.I):
|
| 233 |
+
# "Front knee straightening is unavailable" names the measurement;
|
| 234 |
+
# it does not assert that the knee straightened. Do not exempt finite
|
| 235 |
+
# verbs such as "straightens", or a separate affirmative clause.
|
| 236 |
+
nominal = match.group("movement").lower() in {"straightening", "bending", "flexion"}
|
| 237 |
+
unavailable = re.match(
|
| 238 |
+
r"\s+(?:(?:estimate|measurement|result)\s+)?"
|
| 239 |
+
r"(?:(?:between|from) (?:the )?(?:marked )?(?:landing|plant|foot strike) "
|
| 240 |
+
r"(?:and|to) (?:the )?(?:marked )?release\s+)?"
|
| 241 |
+
r"(?:(?:is|was|remains) (?:currently )?"
|
| 242 |
+
r"(?:unavailable|withheld|unresolved|not (?:available|confirmed|established))"
|
| 243 |
+
r"|(?:cannot|could not) be (?:confirmed|established|determined|assessed|measured))\b",
|
| 244 |
+
prose[match.end() :],
|
| 245 |
+
re.I,
|
| 246 |
+
)
|
| 247 |
+
if nominal and unavailable:
|
| 248 |
+
continue
|
| 249 |
+
if direction != claim:
|
| 250 |
+
problems.append("knee_direction_not_supported")
|
| 251 |
+
return problems
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
def _quality_reason_issues(prose, facts):
|
| 255 |
+
problems = []
|
| 256 |
+
# The quality gates establish an uncertain estimate, not the actual cause
|
| 257 |
+
# (tracking, smoothing, event placement, or real motion) of that uncertainty.
|
| 258 |
+
tracking_failure = (
|
| 259 |
+
r"\b(?:unstable|incorrect|erroneous|faulty|failed) (?:joint |pose |body |landmark )?tracking\b"
|
| 260 |
+
r"|\b(?:joint |pose |body |landmark )?tracking (?:failure|errors?|failed)\b"
|
| 261 |
+
r"|\b(?:joint |pose |body |landmark )?tracking (?:is|was) (?:unstable|incorrect|wrong|faulty)\b"
|
| 262 |
+
)
|
| 263 |
+
for match in re.finditer(tracking_failure, prose, re.I):
|
| 264 |
+
before = prose[max(0, match.start() - 60) : match.start()]
|
| 265 |
+
if not re.search(
|
| 266 |
+
r"(?:does not|doesn't|cannot) (?:prove|establish|mean|show) (?:a |an )?$|not evidence of (?:a |an )?$", before, re.I
|
| 267 |
+
):
|
| 268 |
+
problems.append("uncertain_estimate_does_not_prove_tracking_failure")
|
| 269 |
+
if re.search(
|
| 270 |
+
r"\b(?:enable|ensure|guarantee) (?:stable|reliable|accurate) (?:knee |joint |pose |body |landmark ){0,3}tracking\b",
|
| 271 |
+
prose,
|
| 272 |
+
re.I,
|
| 273 |
+
):
|
| 274 |
+
problems.append("recording_action_does_not_guarantee_tracking_quality")
|
| 275 |
+
if re.search(
|
| 276 |
+
r"\bmetadata\s+(?:to|can|will)\s+(?:confirm|prove|establish|verify|determine)\b.{0,40}\b(?:capture|recording|retiming)\b",
|
| 277 |
+
prose,
|
| 278 |
+
re.I,
|
| 279 |
+
):
|
| 280 |
+
problems.append("file_metadata_does_not_prove_capture_provenance")
|
| 281 |
+
knee = facts.get("measurement:lead_knee_extension_to_release", {})
|
| 282 |
+
if knee.get("value") is None and "event_angle_unstable" in knee.get("reasons", []):
|
| 283 |
+
for clause in re.split(r"[.;!?]", prose):
|
| 284 |
+
if re.search(r"\b(?:front|lead) (?:knee|leg)\b", clause, re.I) and re.search(
|
| 285 |
+
r"\b(?:could not|cannot|can't) (?:be (?:calculated|computed)|calculate|compute)\b(?! reliably)", clause, re.I
|
| 286 |
+
):
|
| 287 |
+
problems.append("withheld_estimate_not_calculation_failure")
|
| 288 |
return problems
|
| 289 |
|
| 290 |
|
|
|
|
| 320 |
if knee_key in facts and knee_key not in cited_facts:
|
| 321 |
cited_facts[knee_key] = {"direction_supported": "unresolved"}
|
| 322 |
problems.extend(_knee_direction_issues(c.observation, cited_facts))
|
| 323 |
+
problems.extend(_quality_reason_issues(" ".join((c.observation, c.why_it_matters, c.next_step, c.check)), cited_facts))
|
| 324 |
prose = " ".join([summary] + [getattr(c, k) for c in cards for k in ("observation", "why_it_matters", "next_step", "check")])
|
| 325 |
quantities = re.sub(r"\b[23][dD]\b", "", prose)
|
| 326 |
quantities = re.sub(r"\b(?:two|three) (?:frames|marks|moments|images|checks|steps)\b", "", quantities, flags=re.I)
|
|
|
|
| 332 |
problems.append("unsupported_physical_or_medical_claim")
|
| 333 |
observations = " ".join([summary] + [c.observation for c in cards])
|
| 334 |
problems.extend(_knee_direction_issues(summary, facts))
|
| 335 |
+
problems.extend(_quality_reason_issues(summary, facts))
|
| 336 |
if re.search(r"\b(?:I (?:see|saw|watched)|the (?:video|frames?|footage) (?:shows?|confirms?))\b", prose, re.I):
|
| 337 |
problems.append("direct_visual_claim_not_supported")
|
| 338 |
if re.search(r"towards? (?:the|your) (?:target|catcher|plate)", observations, re.I):
|
AI-coach-agent/tests/test_pitching_coaching.py
CHANGED
|
@@ -451,3 +451,128 @@ def test_unvalidated_estimates_never_become_praise_or_direct_video_claims(kind,
|
|
| 451 |
|
| 452 |
report = build_pitch_report(payload(), settings=settings(tmp_path, repair_attempts=0), generator=generator)
|
| 453 |
assert report["coaching"]["status"] == "unavailable"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
report = build_pitch_report(payload(), settings=settings(tmp_path, repair_attempts=0), generator=generator)
|
| 453 |
assert report["coaching"]["status"] == "unavailable"
|
| 454 |
+
|
| 455 |
+
|
| 456 |
+
def sensitivity_facts():
|
| 457 |
+
from ai_coach.pitch_report.v1_1.coaching import facts_for
|
| 458 |
+
from ai_coach.pitch_report.v1_1.contract import PitchPayload
|
| 459 |
+
from ai_coach.pitch_report.v1_1.rubric import evaluate_drill
|
| 460 |
+
|
| 461 |
+
p = payload()
|
| 462 |
+
for m in p["measurements"]:
|
| 463 |
+
if m["metric_id"] == "lead_knee_extension_to_release":
|
| 464 |
+
m.update(value=None, value_interval=None, status="unavailable", reasons=["event_angle_unstable"])
|
| 465 |
+
elif m["metric_id"] == "throwing_elbow_flexion_at_release":
|
| 466 |
+
m.update(value=None, value_interval=None, status="unavailable", reasons=["temporal_inconsistency"])
|
| 467 |
+
parsed = PitchPayload.model_validate(p)
|
| 468 |
+
return facts_for(parsed, evaluate_drill(parsed))
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
def test_live_summary_cannot_misattribute_mark_sensitivity_to_tracking_failure():
|
| 472 |
+
from ai_coach.pitch_report.v1_1.coaching import _check_content
|
| 473 |
+
|
| 474 |
+
# The real step-back input also has a separate elbow temporal-inconsistency
|
| 475 |
+
# flag: that cannot establish tracking failure as the cause of knee sensitivity.
|
| 476 |
+
summary = (
|
| 477 |
+
"Front leg change, physical durations, and peak rotation ordering could not be calculated "
|
| 478 |
+
"due to unstable joint tracking and unavailable capture timing."
|
| 479 |
+
)
|
| 480 |
+
problems = _check_content(summary, [], sensitivity_facts())
|
| 481 |
+
assert "uncertain_estimate_does_not_prove_tracking_failure" in problems
|
| 482 |
+
assert "withheld_estimate_not_calculation_failure" in problems
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
@pytest.mark.parametrize(
|
| 486 |
+
"observation",
|
| 487 |
+
[
|
| 488 |
+
"Your front knee straightening is unavailable.",
|
| 489 |
+
"Your front knee straightening estimate is withheld.",
|
| 490 |
+
"Your front knee straightening between landing and release is unavailable.",
|
| 491 |
+
"Your front knee bending could not be established.",
|
| 492 |
+
],
|
| 493 |
+
)
|
| 494 |
+
def test_unavailable_measurement_name_is_not_an_affirmative_direction_claim(observation):
|
| 495 |
+
from ai_coach.pitch_report.v1_1.coaching import Draft, check_draft
|
| 496 |
+
|
| 497 |
+
candidate = draft()
|
| 498 |
+
candidate["cards"][0].update(
|
| 499 |
+
kind="limitation",
|
| 500 |
+
observation=observation,
|
| 501 |
+
why_it_matters="The estimate changes too much when the marked moments move to neighboring frames.",
|
| 502 |
+
next_step="Review the landing and release marks before drawing a movement conclusion.",
|
| 503 |
+
check="Check the front knee estimate after confirming those marked moments.",
|
| 504 |
+
)
|
| 505 |
+
assert not check_draft(Draft.model_validate(candidate), sensitivity_facts())
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
@pytest.mark.parametrize(
|
| 509 |
+
"observation",
|
| 510 |
+
[
|
| 511 |
+
"Your front knee straightens, but capture timing is unavailable.",
|
| 512 |
+
"Your front knee straightening is unavailable. Your front knee straightens between landing and release.",
|
| 513 |
+
"Your front knee is straightening while the elbow estimate is unavailable.",
|
| 514 |
+
],
|
| 515 |
+
)
|
| 516 |
+
def test_unavailable_clause_does_not_hide_an_affirmative_direction_claim(observation):
|
| 517 |
+
from ai_coach.pitch_report.v1_1.coaching import Draft, check_draft
|
| 518 |
+
|
| 519 |
+
candidate = draft()
|
| 520 |
+
candidate["cards"][0].update(kind="limitation", observation=observation)
|
| 521 |
+
assert "knee_direction_not_supported" in check_draft(Draft.model_validate(candidate), sensitivity_facts())
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
def test_reason_meanings_keep_measurement_sensitivity_separate_from_tracking_and_timing():
|
| 525 |
+
facts = sensitivity_facts()
|
| 526 |
+
knee = facts["measurement:lead_knee_extension_to_release"]
|
| 527 |
+
assert "neighboring frame" in knee["reason_meanings"]["event_angle_unstable"]
|
| 528 |
+
assert "not proof of tracking failure" in knee["reason_meanings"]["event_angle_unstable"]
|
| 529 |
+
assert "temporal_inconsistency" not in knee["reason_meanings"]
|
| 530 |
+
|
| 531 |
+
|
| 532 |
+
def test_available_single_frame_flexion_is_not_confused_with_change_in_bend():
|
| 533 |
+
from ai_coach.pitch_report.v1_1.coaching import Draft, check_draft
|
| 534 |
+
|
| 535 |
+
candidate = draft()
|
| 536 |
+
candidate["summary"] = "Your marked landing has an estimated knee angle."
|
| 537 |
+
candidate["cards"][0].update(
|
| 538 |
+
observation="Your front knee flexion at the marked foot strike is available as an estimate.",
|
| 539 |
+
why_it_matters="This describes the knee angle at that moment without establishing its later movement.",
|
| 540 |
+
next_step="Review the marked landing frame alongside the angle estimate.",
|
| 541 |
+
check="Confirm that the mark identifies the intended landing moment.",
|
| 542 |
+
evidence_ids=["measurement:lead_knee_flexion_at_foot_strike"],
|
| 543 |
+
)
|
| 544 |
+
facts = sensitivity_facts()
|
| 545 |
+
assert not check_draft(Draft.model_validate(candidate), facts)
|
| 546 |
+
candidate["cards"][0]["observation"] = "Your front knee flexes between landing and release."
|
| 547 |
+
assert "knee_direction_not_supported" in check_draft(Draft.model_validate(candidate), facts)
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
def test_live_metadata_check_cannot_claim_to_confirm_capture_speed():
|
| 551 |
+
from ai_coach.pitch_report.v1_1.coaching import Draft, check_draft
|
| 552 |
+
|
| 553 |
+
candidate = draft()
|
| 554 |
+
candidate["cards"][0]["check"] = (
|
| 555 |
+
"Check the original file metadata to confirm capture speed and verify that no undocumented "
|
| 556 |
+
"speed alterations occurred during export."
|
| 557 |
+
)
|
| 558 |
+
assert "file_metadata_does_not_prove_capture_provenance" in check_draft(
|
| 559 |
+
Draft.model_validate(candidate), {"measurement:lead_knee_extension_to_release": {"value": 30}}
|
| 560 |
+
)
|
| 561 |
+
candidate["cards"][0]["check"] = (
|
| 562 |
+
"Document the camera recording settings and export history, or supply an explicit capture-time map."
|
| 563 |
+
)
|
| 564 |
+
assert not check_draft(Draft.model_validate(candidate), {"measurement:lead_knee_extension_to_release": {"value": 30}})
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
def test_recording_action_cannot_promise_stable_tracking_from_mark_sensitivity():
|
| 568 |
+
from ai_coach.pitch_report.v1_1.coaching import _check_content
|
| 569 |
+
|
| 570 |
+
assert "recording_action_does_not_guarantee_tracking_quality" in _check_content(
|
| 571 |
+
"Record an unobstructed front knee to enable stable knee joint tracking.", [], sensitivity_facts()
|
| 572 |
+
)
|
| 573 |
+
assert not _check_content(
|
| 574 |
+
"The front knee change is withheld because shifting the marked moments changes the estimate too much. "
|
| 575 |
+
"This does not establish a tracking failure.",
|
| 576 |
+
[],
|
| 577 |
+
sensitivity_facts(),
|
| 578 |
+
)
|
baseball_batting/api.py
CHANGED
|
@@ -78,7 +78,7 @@ def create_app(settings=None, service=None):
|
|
| 78 |
service.start()
|
| 79 |
try: yield
|
| 80 |
finally: service.stop()
|
| 81 |
-
app = FastAPI(title="Baseball Motion Engine and Coach", version="1.21.
|
| 82 |
description="GPU batting/load timing with separate bat keypoint and baseball models. Single-view visual contact; physical miss/shift require synchronized calibrated views. Accuracy validation pending.")
|
| 83 |
app.state.service = service
|
| 84 |
app.add_middleware(UploadGuard, settings=settings, service=service)
|
|
|
|
| 78 |
service.start()
|
| 79 |
try: yield
|
| 80 |
finally: service.stop()
|
| 81 |
+
app = FastAPI(title="Baseball Motion Engine and Coach", version="1.21.6", lifespan=lifespan,
|
| 82 |
description="GPU batting/load timing with separate bat keypoint and baseball models. Single-view visual contact; physical miss/shift require synchronized calibrated views. Accuracy validation pending.")
|
| 83 |
app.state.service = service
|
| 84 |
app.add_middleware(UploadGuard, settings=settings, service=service)
|
docs/PITCHING_VALIDATION.md
CHANGED
|
@@ -16,7 +16,11 @@ The original files match the retained SAM3D results (80 step-back frames; 88 roc
|
|
| 16 |
|
| 17 |
Local checks cover 706 engine tests (two skipped), 735 coach tests (one skipped; twelve live tests excluded), and 64 backend regression tests including hitting/session behavior. Two additional temporary backend checks used each original clip's replayed ML payload with a fake text provider and verified exact persistence. Reusable replay: `tools/validate_pitching_ml_coach.py`; it verifies source/video hashes, recomputes measurements, enforces ML-only evidence and clearly distinguishes offline fallback from optional live text generation.
|
| 18 |
|
| 19 |
-
Release
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## Historical validation record
|
| 22 |
|
|
|
|
| 16 |
|
| 17 |
Local checks cover 706 engine tests (two skipped), 735 coach tests (one skipped; twelve live tests excluded), and 64 backend regression tests including hitting/session behavior. Two additional temporary backend checks used each original clip's replayed ML payload with a fake text provider and verified exact persistence. Reusable replay: `tools/validate_pitching_ml_coach.py`; it verifies source/video hashes, recomputes measurements, enforces ML-only evidence and clearly distinguishes offline fallback from optional live text generation.
|
| 18 |
|
| 19 |
+
Release 1.21.5 source `c6740dc30c6da8c1add9680c0c571ec78bec8366` passed [source tests](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41401984965), [ML deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41401984920) and [backend deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41401984898). The running Hugging Face commit was `66d2e51ce53c0fb1906a3e2c5d9ad5fd770234db`, linked to the source commit in deployment logs. Live readiness and the ML-only capabilities were verified.
|
| 20 |
+
|
| 21 |
+
Both original videos then completed fresh SAM3D analysis and real Gemini coaching through the backend. Step-back job `1d24f619590e4d40a76ce485c30d0b88` and rocker job `ac33677dd38543d2846271c421fcf26b` passed input hashes, implementation/artifact hashes, whole-motion replay, immutable JSON forwarding, idempotence, saved-report and API-audit checks. Both coach payloads and reports have null visual evidence; all numeric performance scores are null. The step-back returned a supported subset after rejecting other cards; the rocker returned four cards after bounded repair.
|
| 22 |
+
|
| 23 |
+
Manual evidence review supported the retained movement descriptions but found two wording problems: the step-back summary attributed event-mark sensitivity to unstable tracking, and the rocker suggested generic file metadata could confirm capture speed. These are not clean content-acceptance results. The 1.21.6 follow-up passed 747 coach tests (one skipped, twelve live tests excluded) and all 32 targeted engine pitching tests. It adds explicit reason meanings and rejects those causal/provenance claims. It also distinguishes a withheld estimate from an impossible calculation and a nominal unavailable knee measurement from an affirmative movement claim. The fresh ML results remain unchanged; final coaching-only refresh results will be recorded after deployment. A green deployment is not a content-accuracy result.
|
| 24 |
|
| 25 |
## Historical validation record
|
| 26 |
|