Spaces:
Running on T4
Running on T4
github-actions[bot] commited on
Commit ·
7bf5a7e
1
Parent(s): a8788e5
Automated Deploy: 9a9b646cc63bf5c0b3e1e8ce109df190b8eca5f7
Browse files- AI-coach-agent/docs/PITCH_REPORT_API.md +34 -48
- AI-coach-agent/src/ai_coach/knowledge/pitch_v1_1_coaching.yaml +10 -0
- AI-coach-agent/src/ai_coach/pitch_report/__init__.py +4 -22
- AI-coach-agent/src/ai_coach/pitch_report/v1_1/service.py +37 -12
- AI-coach-agent/src/ai_coach/swing_report/schemas.py +1 -2
- AI-coach-agent/src/ai_coach/swing_report/service.py +1 -2
- AI-coach-agent/src/ai_coach/swing_report/text.py +0 -4
- AI-coach-agent/tests/test_pitching_coaching.py +4 -1
- AI-coach-agent/tests/test_pitching_report.py +38 -6
- backend/app/main.py +3 -4
- backend/app/modules/swing_reports/controller.py +1 -1
- backend/app/modules/swing_reports/service.py +2 -2
- backend/docs/FRONTEND_INTEGRATION.md +2 -2
- backend/docs/openapi.json +4 -621
- backend/tests/integration/test_pitching_flow.py +3 -3
- backend/tests/integration/test_pitching_openapi.py +6 -10
- docs/PITCHING_APP_INTEGRATION.md +5 -5
- tests/test_pitching_api.py +5 -5
AI-coach-agent/docs/PITCH_REPORT_API.md
CHANGED
|
@@ -1,51 +1,37 @@
|
|
| 1 |
# Pitch report API
|
| 2 |
|
| 3 |
-
`POST /v1/sessions/{session_id}/pitch-report` takes the ML pitch payload (contract `pitch-1.
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|---|---|
|
| 13 |
-
|
|
| 14 |
-
|
|
| 15 |
-
| `
|
| 16 |
-
| `
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
| `stride_length_pct_height` | stride_landing | pct_height | foot_plant | lead ankle to rear ankle along the throwing line, as a percent of height |
|
| 26 |
-
| `stride_direction_deg` | stride_landing | deg | foot_plant | stride angle, positive = across the body (closed) |
|
| 27 |
-
| `hip_shoulder_separation_at_foot_plant` | stride_landing | deg | foot_plant | pelvis rotation minus trunk rotation |
|
| 28 |
-
| `trunk_forward_tilt_at_foot_plant` | stride_landing | deg | foot_plant | trunk flexion, positive = toward the plate |
|
| 29 |
-
| `shoulder_abduction_at_foot_plant` | arm_action | deg | foot_plant | throwing-shoulder abduction |
|
| 30 |
-
| `elbow_flexion_at_foot_plant` | arm_action | deg | foot_plant | throwing-elbow flexion |
|
| 31 |
-
| `trunk_forward_tilt_at_release` | release_finish | deg | ball_release | trunk flexion, positive = toward the plate |
|
| 32 |
-
| `trunk_lateral_tilt_at_release` | release_finish | deg | ball_release | trunk side bend, positive = glove side |
|
| 33 |
-
| `arm_slot_at_release` | release_finish | deg | ball_release | forearm angle above horizontal |
|
| 34 |
-
| `lead_knee_extension_plant_to_release` | release_finish | deg | foot_plant → ball_release | change in lead-knee angle, positive = straightening |
|
| 35 |
-
|
| 36 |
-
Lead-leg metrics (stride length, stride direction, lead knee) must be `unavailable` with `lead_foot_unknown` when
|
| 37 |
-
`lead_foot` is null. `leg_lift_balance` has no metrics yet and always shows "not measured yet".
|
| 38 |
-
|
| 39 |
-
## Coaching rules specific to pitching
|
| 40 |
-
|
| 41 |
-
- Benchmarks: OBP pitching (411 pitches, 100 pitchers), P25–P75 on target and P10–P90 satisfactory of per-athlete
|
| 42 |
-
medians, per throwing hand and level (`knowledge/pitch_benchmarks.yaml`, built by `tools/build_pitch_benchmarks.py`).
|
| 43 |
-
OBP has too few high-school pitchers, so high school and unset levels use college.
|
| 44 |
-
- `arm_slot_at_release` is a style: compared with the reference but never the focus, never given a tip, and not counted
|
| 45 |
-
in group or overall scores.
|
| 46 |
-
- `long_toss`: stride length, stride direction, forward bend at release and arm slot are not compared.
|
| 47 |
-
- `dry_drill`, `towel_drill`: results are described, never corrected (no ball, no reference task).
|
| 48 |
-
- `unknown` practice: stride length and forward bend at release are shown but not coached.
|
| 49 |
-
- Model text may not claim velocity, control, command, strikes, arm stress, injury or arm health; such text falls back
|
| 50 |
-
to the rules text (`meta.text_rejections`).
|
| 51 |
-
- Coaching text and drill choices in `knowledge/pitch_metrics.yaml` need coach review.
|
|
|
|
| 1 |
# Pitch report API
|
| 2 |
|
| 3 |
+
`POST /v1/sessions/{session_id}/pitch-report` takes the ML pitch payload (contract `pitch-1.1`, schema
|
| 4 |
+
`docs/pitching-coach-payload.schema.json`, example `docs/pitching-coach-payload.example.json`) for a pitching session
|
| 5 |
+
(`mode: "p"`), unchanged. Library entry point: `ai_coach.pitch_report.build_pitch_report(payload, athlete)`
|
| 6 |
+
(`pitch_report/v1_1/service.py`). The response follows the swing report layout (overall score, groups, focus area with
|
| 7 |
+
a drill, measurements, data quality) plus the pitching sections `coaching` (AI cards), `drill_evaluation` and
|
| 8 |
+
`delivery_evidence`.
|
| 9 |
+
|
| 10 |
+
## Scoring
|
| 11 |
+
|
| 12 |
+
- Benchmarks: OBP pitching, college pitchers per throwing side (`knowledge/pitching_benchmarks.yaml`). P25–P75 is on
|
| 13 |
+
target and P10–P90 satisfactory. OBP has no usable high-school or pro groups, so every level uses college with a
|
| 14 |
+
`level_assumed` or `level_approximated` note.
|
| 15 |
+
- Throwing side: payload `athlete.throwing_hand`, then the profile, then the opposite of the lead foot. A profile that
|
| 16 |
+
disagrees is reported (`throwing_hand_conflict`) and blocks advice.
|
| 17 |
+
- Values far outside the P10–P90 band (more than two band widths) are tracking errors: `implausible_value`, not rated.
|
| 18 |
+
- A result whose rating changes when an event moves by one frame is shown without a tip and is never the focus
|
| 19 |
+
(`event_sensitive_scores`).
|
| 20 |
+
- `ankle_span_at_foot_strike_cm` has no OBP equivalent and is shown for reference only.
|
| 21 |
+
|
| 22 |
+
## Context
|
| 23 |
+
|
| 24 |
+
| Context | Result |
|
| 25 |
|---|---|
|
| 26 |
+
| fastball, baseball, `standard` drill, any known practice | everything compared |
|
| 27 |
+
| any of practice, drill, pitch or ball `unknown` | compared as a regular fastball; leg-lift and stride results are rated but not coached (`practice_context_unknown`) |
|
| 28 |
+
| `step_back`, `rocker` | compared, except leg-lift and stride results (`not_comparable_for_drill`) |
|
| 29 |
+
| `other` drill, `dry_delivery`, non-fastball, training ball or no ball | described without scores (`practice_context_unverified`) |
|
| 30 |
+
|
| 31 |
+
## Text
|
| 32 |
+
|
| 33 |
+
Headline, group summaries, result text, tips and the focus message come from `knowledge/pitch_v1_1_coaching.yaml`
|
| 34 |
+
(plain words, no numbers, guarded by the same checks as the swing report). The focus is the lowest-scoring coachable
|
| 35 |
+
result with its drill; `maintain` when everything is on target; `general` (rhythm drill) when nothing is coachable.
|
| 36 |
+
The AI cards in `coaching` are generated separately and never replace the headline or focus. Coaching text and drill
|
| 37 |
+
choices need coach review.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AI-coach-agent/src/ai_coach/knowledge/pitch_v1_1_coaching.yaml
CHANGED
|
@@ -3,6 +3,8 @@
|
|
| 3 |
# `above` / `below` mean the value is above or below the on-target interval in pitching_benchmarks.yaml.
|
| 4 |
# mirror_for_right: the reference sign flips with the throwing side (right-handers are negative), so the coaching side
|
| 5 |
# is flipped for right-handed pitchers and `above` always means "more of it".
|
|
|
|
|
|
|
| 6 |
# Text rules: plain words, no numbers, no good/bad judgements, no claims about speed, control or arm health.
|
| 7 |
version: "pitch-1.1-rules-1"
|
| 8 |
|
|
@@ -11,6 +13,8 @@ headline_all_on_target: Everything we could rate in this pitch is in the typical
|
|
| 11 |
headline_nothing_rated: We could not rate this pitch yet, but you can see what we measured below.
|
| 12 |
headline_not_comparable: This kind of drill is not compared with regular pitches, so your results are shown without a rating.
|
| 13 |
headline_tentative: These results are close estimates from your video.
|
|
|
|
|
|
|
| 14 |
hand_conflict_message: The video and your profile list different throwing arms. Check the side before using these results.
|
| 15 |
not_comparable_message: This drill or pitch changes how you throw on purpose. So we show your results, but we do not change your pitch.
|
| 16 |
|
|
@@ -23,6 +27,8 @@ general_focus:
|
|
| 23 |
|
| 24 |
metrics:
|
| 25 |
torso_inclination_at_leg_lift:
|
|
|
|
|
|
|
| 26 |
in_range_text: Your upper body was set about like most pitchers at the top of your leg lift.
|
| 27 |
above:
|
| 28 |
result_text: Your upper body leaned more than most pitchers at the top of your leg lift.
|
|
@@ -47,6 +53,8 @@ metrics:
|
|
| 47 |
drill_id: pit_13
|
| 48 |
|
| 49 |
leg_lift_to_foot_strike_ms:
|
|
|
|
|
|
|
| 50 |
in_range_text: Your move from leg lift to landing took about as long as most pitchers.
|
| 51 |
above:
|
| 52 |
result_text: Your move from leg lift to landing took longer than most pitchers.
|
|
@@ -70,6 +78,8 @@ metrics:
|
|
| 70 |
drill_id: pit_12
|
| 71 |
|
| 72 |
ankle_span_at_foot_strike_cm:
|
|
|
|
|
|
|
| 73 |
in_range_text: Your stride is shown for reference.
|
| 74 |
above:
|
| 75 |
result_text: Your feet were spread wider than most pitchers when your front foot landed.
|
|
|
|
| 3 |
# `above` / `below` mean the value is above or below the on-target interval in pitching_benchmarks.yaml.
|
| 4 |
# mirror_for_right: the reference sign flips with the throwing side (right-handers are negative), so the coaching side
|
| 5 |
# is flipped for right-handed pitchers and `above` always means "more of it".
|
| 6 |
+
# drill_dependent: rated but never coached when the practice or drill is unknown. not_comparable_drills: not rated for
|
| 7 |
+
# those drill types.
|
| 8 |
# Text rules: plain words, no numbers, no good/bad judgements, no claims about speed, control or arm health.
|
| 9 |
version: "pitch-1.1-rules-1"
|
| 10 |
|
|
|
|
| 13 |
headline_nothing_rated: We could not rate this pitch yet, but you can see what we measured below.
|
| 14 |
headline_not_comparable: This kind of drill is not compared with regular pitches, so your results are shown without a rating.
|
| 15 |
headline_tentative: These results are close estimates from your video.
|
| 16 |
+
headline_reference_only: Your results are compared with other pitchers below. None of them is clear enough yet to change your pitch.
|
| 17 |
+
reference_only_message: These results are close estimates, so they are not used to change your pitch yet. Keep a smooth, steady delivery with this drill.
|
| 18 |
hand_conflict_message: The video and your profile list different throwing arms. Check the side before using these results.
|
| 19 |
not_comparable_message: This drill or pitch changes how you throw on purpose. So we show your results, but we do not change your pitch.
|
| 20 |
|
|
|
|
| 27 |
|
| 28 |
metrics:
|
| 29 |
torso_inclination_at_leg_lift:
|
| 30 |
+
drill_dependent: true # shown but not coached when the drill is unknown
|
| 31 |
+
not_comparable_drills: [step_back, rocker] # these drills change the leg lift and stride on purpose
|
| 32 |
in_range_text: Your upper body was set about like most pitchers at the top of your leg lift.
|
| 33 |
above:
|
| 34 |
result_text: Your upper body leaned more than most pitchers at the top of your leg lift.
|
|
|
|
| 53 |
drill_id: pit_13
|
| 54 |
|
| 55 |
leg_lift_to_foot_strike_ms:
|
| 56 |
+
drill_dependent: true # shown but not coached when the drill is unknown
|
| 57 |
+
not_comparable_drills: [step_back, rocker] # these drills change the leg lift and stride on purpose
|
| 58 |
in_range_text: Your move from leg lift to landing took about as long as most pitchers.
|
| 59 |
above:
|
| 60 |
result_text: Your move from leg lift to landing took longer than most pitchers.
|
|
|
|
| 78 |
drill_id: pit_12
|
| 79 |
|
| 80 |
ankle_span_at_foot_strike_cm:
|
| 81 |
+
drill_dependent: true # shown but not coached when the drill is unknown
|
| 82 |
+
not_comparable_drills: [step_back, rocker] # these drills change the leg lift and stride on purpose
|
| 83 |
in_range_text: Your stride is shown for reference.
|
| 84 |
above:
|
| 85 |
result_text: Your feet were spread wider than most pitchers when your front foot landed.
|
AI-coach-agent/src/ai_coach/pitch_report/__init__.py
CHANGED
|
@@ -1,25 +1,7 @@
|
|
| 1 |
-
"""Pitch report
|
| 2 |
|
| 3 |
from ..swing_report.service import AthleteContext, InvalidPayload
|
| 4 |
-
from .
|
| 5 |
-
from .service import
|
| 6 |
-
from .service import build_pitch_report as _build_v1
|
| 7 |
-
from .validation import validate_pitch_payload as _validate_v1
|
| 8 |
|
| 9 |
-
|
| 10 |
-
def validate_pitch_payload(payload):
|
| 11 |
-
"""Versioned contracts keep distinct measurement definitions intact."""
|
| 12 |
-
if isinstance(payload, dict) and payload.get("schema_version") == "pitch-1.1":
|
| 13 |
-
from .v1_1.service import validate_payload
|
| 14 |
-
return validate_payload(payload)
|
| 15 |
-
return _validate_v1(payload)
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def build_pitch_report(payload, athlete=None, *, request_id=None, **kwargs):
|
| 19 |
-
if isinstance(payload, dict) and payload.get("schema_version") == "pitch-1.1":
|
| 20 |
-
from .v1_1.service import build_report
|
| 21 |
-
return build_report(payload, athlete, request_id=request_id, **kwargs)
|
| 22 |
-
return _build_v1(payload, athlete, request_id=request_id, **kwargs)
|
| 23 |
-
|
| 24 |
-
__all__ = ["PITCH", "AthleteContext", "InvalidPayload", "PitchAnalysisPayload", "build_pitch_report",
|
| 25 |
-
"validate_pitch_payload"]
|
|
|
|
| 1 |
+
"""Pitch report: contract pitch-1.1 payload in, scored and worded report out. See docs/PITCH_REPORT_API.md."""
|
| 2 |
|
| 3 |
from ..swing_report.service import AthleteContext, InvalidPayload
|
| 4 |
+
from .v1_1.service import build_report as build_pitch_report
|
| 5 |
+
from .v1_1.service import validate_payload as validate_pitch_payload
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
__all__ = ["AthleteContext", "InvalidPayload", "build_pitch_report", "validate_pitch_payload"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AI-coach-agent/src/ai_coach/pitch_report/v1_1/service.py
CHANGED
|
@@ -59,7 +59,11 @@ MEANINGS = {
|
|
| 59 |
}
|
| 60 |
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
MIN_ATHLETES = 10
|
| 64 |
PLAUSIBLE_SPANS = 2.0 # values beyond the P10-P90 band widened by this many band widths are tracking errors
|
| 65 |
|
|
@@ -147,19 +151,22 @@ def build_report(payload, athlete=None, *, request_id=None, settings=None, gener
|
|
| 147 |
hand_inferred = False
|
| 148 |
if hand is None and p.athlete.lead_foot:
|
| 149 |
hand, hand_inferred = ("left" if p.athlete.lead_foot == "right" else "right"), True
|
| 150 |
-
# Reference trials are normal fastballs
|
| 151 |
-
#
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
)
|
| 158 |
notes = []
|
| 159 |
if not comparable:
|
| 160 |
notes.append(_note("practice_context_unverified", "warning",
|
| 161 |
"This drill or pitch changes the delivery on purpose, so it is not compared with regular "
|
| 162 |
"fastballs. Your results are shown without a rating."))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
if conflict:
|
| 164 |
notes.append(_note("throwing_hand_conflict", "warning",
|
| 165 |
"The video and your profile list different throwing arms. Scores use the side from the "
|
|
@@ -191,6 +198,8 @@ def build_report(payload, athlete=None, *, request_id=None, settings=None, gener
|
|
| 191 |
why = "measurement_unavailable"
|
| 192 |
elif not comparable:
|
| 193 |
why = "context_not_comparable"
|
|
|
|
|
|
|
| 194 |
elif hand is None:
|
| 195 |
why = "throwing_hand_unknown"
|
| 196 |
elif cell is None:
|
|
@@ -237,7 +246,7 @@ def build_report(payload, athlete=None, *, request_id=None, settings=None, gener
|
|
| 237 |
else:
|
| 238 |
text = advice[side]["result_text"]
|
| 239 |
tip = advice[side]["coach_tip"]
|
| 240 |
-
if result_score is not None and m.metric_id in sensitive:
|
| 241 |
tip = None
|
| 242 |
text = f"Your estimated {spec[1].lower()} was {_position(m.value, benchmark)} the reference range."
|
| 243 |
elif tentative:
|
|
@@ -272,6 +281,14 @@ def build_report(payload, athlete=None, *, request_id=None, settings=None, gener
|
|
| 272 |
)
|
| 273 |
if level_note and any(m["score"] is not None for m in rows):
|
| 274 |
notes.append(level_note)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
if implausible:
|
| 276 |
notes.append(_note("implausible_value", "warning",
|
| 277 |
"Some results were far outside what we see in real pitches, so they look like tracking "
|
|
@@ -321,9 +338,13 @@ def build_report(payload, athlete=None, *, request_id=None, settings=None, gener
|
|
| 321 |
"Some ratings change when a marked moment moves by one frame, so those results are shown "
|
| 322 |
"without practice advice."))
|
| 323 |
|
| 324 |
-
|
|
|
|
| 325 |
needs_work = sorted((m for m in eligible if m["rating"] != ON_TARGET), key=lambda m: m["score"])
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
| 327 |
group_names = GROUPS
|
| 328 |
if needs_work:
|
| 329 |
m = needs_work[0]
|
|
@@ -344,6 +365,10 @@ def build_report(payload, athlete=None, *, request_id=None, settings=None, gener
|
|
| 344 |
if not comparable and any(m["value"] is not None for m in rows):
|
| 345 |
headline = rules["headline_not_comparable"]
|
| 346 |
focus["coach_message"] = rules["not_comparable_message"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
if conflict:
|
| 348 |
focus["coach_message"] = rules["hand_conflict_message"]
|
| 349 |
if focus["is_tentative"]:
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
|
| 62 |
+
# Context values that change the whole delivery on purpose: never compared with regular fastballs.
|
| 63 |
+
NOT_COMPARABLE_CONTEXT = {"practice_type": ("dry_delivery",), "drill_type": ("other",),
|
| 64 |
+
"pitch_type": ("breaking_ball", "changeup", "other"), "ball_type": ("training_ball", "none")}
|
| 65 |
+
# Partial drills (step_back, rocker) are compared except for the metrics listed in their not_comparable_drills.
|
| 66 |
+
PARTIAL_DRILLS = ("step_back", "rocker")
|
| 67 |
MIN_ATHLETES = 10
|
| 68 |
PLAUSIBLE_SPANS = 2.0 # values beyond the P10-P90 band widened by this many band widths are tracking errors
|
| 69 |
|
|
|
|
| 151 |
hand_inferred = False
|
| 152 |
if hand is None and p.athlete.lead_foot:
|
| 153 |
hand, hand_inferred = ("left" if p.athlete.lead_foot == "right" else "right"), True
|
| 154 |
+
# Reference trials are normal fastballs with a baseball. Other pitches, training balls, dry deliveries and
|
| 155 |
+
# "other" drills change the whole delivery on purpose, so they are described but never rated. Unknown context is
|
| 156 |
+
# rated as a regular fastball (the app rarely sends it), but drill-dependent results are then not coached.
|
| 157 |
+
comparable = not any(getattr(context, field) in values for field, values in NOT_COMPARABLE_CONTEXT.items())
|
| 158 |
+
context_unknown = comparable and "unknown" in (context.practice_type, context.drill_type, context.pitch_type,
|
| 159 |
+
context.ball_type)
|
| 160 |
+
partial_drill = context.drill_type if context.drill_type in PARTIAL_DRILLS else None
|
|
|
|
| 161 |
notes = []
|
| 162 |
if not comparable:
|
| 163 |
notes.append(_note("practice_context_unverified", "warning",
|
| 164 |
"This drill or pitch changes the delivery on purpose, so it is not compared with regular "
|
| 165 |
"fastballs. Your results are shown without a rating."))
|
| 166 |
+
drill_dependent = set()
|
| 167 |
+
for metric_id, advice in rules["metrics"].items():
|
| 168 |
+
if context_unknown and advice.get("drill_dependent"):
|
| 169 |
+
drill_dependent.add(metric_id)
|
| 170 |
if conflict:
|
| 171 |
notes.append(_note("throwing_hand_conflict", "warning",
|
| 172 |
"The video and your profile list different throwing arms. Scores use the side from the "
|
|
|
|
| 198 |
why = "measurement_unavailable"
|
| 199 |
elif not comparable:
|
| 200 |
why = "context_not_comparable"
|
| 201 |
+
elif partial_drill in advice.get("not_comparable_drills", ()):
|
| 202 |
+
why = "not_comparable_for_drill"
|
| 203 |
elif hand is None:
|
| 204 |
why = "throwing_hand_unknown"
|
| 205 |
elif cell is None:
|
|
|
|
| 246 |
else:
|
| 247 |
text = advice[side]["result_text"]
|
| 248 |
tip = advice[side]["coach_tip"]
|
| 249 |
+
if result_score is not None and (m.metric_id in sensitive or m.metric_id in drill_dependent):
|
| 250 |
tip = None
|
| 251 |
text = f"Your estimated {spec[1].lower()} was {_position(m.value, benchmark)} the reference range."
|
| 252 |
elif tentative:
|
|
|
|
| 281 |
)
|
| 282 |
if level_note and any(m["score"] is not None for m in rows):
|
| 283 |
notes.append(level_note)
|
| 284 |
+
if context_unknown and any(m["score"] is not None for m in rows):
|
| 285 |
+
notes.append(_note("practice_context_unknown", "info",
|
| 286 |
+
"We do not know the full drill or pitch type, so we compared this with regular fastballs. "
|
| 287 |
+
"Leg lift and stride results are not used for practice advice."))
|
| 288 |
+
if any(m["not_rated_reason"] == "not_comparable_for_drill" for m in rows):
|
| 289 |
+
notes.append(_note("not_comparable_for_drill", "info",
|
| 290 |
+
"This drill changes the leg lift and stride on purpose, so those parts are not compared "
|
| 291 |
+
"with a regular pitch."))
|
| 292 |
if implausible:
|
| 293 |
notes.append(_note("implausible_value", "warning",
|
| 294 |
"Some results were far outside what we see in real pitches, so they look like tracking "
|
|
|
|
| 338 |
"Some ratings change when a marked moment moves by one frame, so those results are shown "
|
| 339 |
"without practice advice."))
|
| 340 |
|
| 341 |
+
uncoachable = sensitive | drill_dependent
|
| 342 |
+
eligible = [] if conflict else [m for m in rows if m["score"] is not None and m["metric_id"] not in uncoachable]
|
| 343 |
needs_work = sorted((m for m in eligible if m["rating"] != ON_TARGET), key=lambda m: m["score"])
|
| 344 |
+
# "Everything is typical" would be untrue when an uncoachable result is outside the range.
|
| 345 |
+
hidden_issue = any(m["metric_id"] in uncoachable and m["score"] is not None and m["rating"] != ON_TARGET
|
| 346 |
+
for m in rows)
|
| 347 |
+
on_target = [] if hidden_issue else [m for m in eligible if m["rating"] == ON_TARGET]
|
| 348 |
group_names = GROUPS
|
| 349 |
if needs_work:
|
| 350 |
m = needs_work[0]
|
|
|
|
| 365 |
if not comparable and any(m["value"] is not None for m in rows):
|
| 366 |
headline = rules["headline_not_comparable"]
|
| 367 |
focus["coach_message"] = rules["not_comparable_message"]
|
| 368 |
+
elif any(m["score"] is not None for m in rows):
|
| 369 |
+
# Rated, but every result outside the range is too uncertain or drill-dependent to coach.
|
| 370 |
+
headline = rules["headline_reference_only"]
|
| 371 |
+
focus["coach_message"] = rules["reference_only_message"]
|
| 372 |
if conflict:
|
| 373 |
focus["coach_message"] = rules["hand_conflict_message"]
|
| 374 |
if focus["is_tentative"]:
|
AI-coach-agent/src/ai_coach/swing_report/schemas.py
CHANGED
|
@@ -133,8 +133,7 @@ class SwingAnalysisPayload(_Input):
|
|
| 133 |
|
| 134 |
Rating = Literal["on_target", "satisfactory", "off_target", "not_rated"]
|
| 135 |
# The report shape is shared by the swing and pitch reports (pitch_report/), so its groups are both sets.
|
| 136 |
-
ReportGroup = Literal["balance_load", "stride", "power_move", "contact_follow_through"
|
| 137 |
-
"leg_lift_balance", "stride_landing", "arm_action", "release_finish"]
|
| 138 |
NotRatedReason = Literal["measurement_unavailable", "no_benchmark", "no_measurements_available",
|
| 139 |
"measurements_unavailable", "no_rated_measurements", "implausible_value",
|
| 140 |
"not_comparable_for_drill"]
|
|
|
|
| 133 |
|
| 134 |
Rating = Literal["on_target", "satisfactory", "off_target", "not_rated"]
|
| 135 |
# The report shape is shared by the swing and pitch reports (pitch_report/), so its groups are both sets.
|
| 136 |
+
ReportGroup = Literal["balance_load", "stride", "power_move", "contact_follow_through"]
|
|
|
|
| 137 |
NotRatedReason = Literal["measurement_unavailable", "no_benchmark", "no_measurements_available",
|
| 138 |
"measurements_unavailable", "no_rated_measurements", "implausible_value",
|
| 139 |
"not_comparable_for_drill"]
|
AI-coach-agent/src/ai_coach/swing_report/service.py
CHANGED
|
@@ -156,8 +156,7 @@ def build_discipline_report(spec: Discipline, payload: dict, athlete: AthleteCon
|
|
| 156 |
repo = spec.registry
|
| 157 |
parsed, problems = spec.validate(payload)
|
| 158 |
if parsed is None:
|
| 159 |
-
raise InvalidPayload(problems
|
| 160 |
-
else "swing analysis contract 1.0")
|
| 161 |
athlete = athlete or AthleteContext()
|
| 162 |
settings = settings or get_settings()
|
| 163 |
hand, hand_inferred = resolve_hand(parsed, athlete, spec.hand_field)
|
|
|
|
| 156 |
repo = spec.registry
|
| 157 |
parsed, problems = spec.validate(payload)
|
| 158 |
if parsed is None:
|
| 159 |
+
raise InvalidPayload(problems)
|
|
|
|
| 160 |
athlete = athlete or AthleteContext()
|
| 161 |
settings = settings or get_settings()
|
| 162 |
hand, hand_inferred = resolve_hand(parsed, athlete, spec.hand_field)
|
AI-coach-agent/src/ai_coach/swing_report/text.py
CHANGED
|
@@ -229,10 +229,6 @@ def semantic_problems(text: str, key: str, facts: dict) -> list[str]:
|
|
| 229 |
problems.append("follow_through_scope_exceeded")
|
| 230 |
if re.search(r"\b(?:power|energy|force|exit velocity|bat speed|ball flight|bat path)\b", t):
|
| 231 |
problems.append("unsupported_physical_claim")
|
| 232 |
-
if facts.get("discipline") == "pitching" and re.search(
|
| 233 |
-
r"\b(?:velocity|faster|harder|speed|mph|command|accuracy|control|strikes?|stress|torque|injur\w*|arm health"
|
| 234 |
-
r"|healthy|safe|safer|risk)\b", t):
|
| 235 |
-
problems.append("unsupported_pitching_claim")
|
| 236 |
if re.search(r"shoulder.*(?:early|late|before.*(?:foot|land))", t):
|
| 237 |
problems.append("unsupported_shoulder_timing")
|
| 238 |
approximate = any(m.get("approximate") for m in selected)
|
|
|
|
| 229 |
problems.append("follow_through_scope_exceeded")
|
| 230 |
if re.search(r"\b(?:power|energy|force|exit velocity|bat speed|ball flight|bat path)\b", t):
|
| 231 |
problems.append("unsupported_physical_claim")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
if re.search(r"shoulder.*(?:early|late|before.*(?:foot|land))", t):
|
| 233 |
problems.append("unsupported_shoulder_timing")
|
| 234 |
approximate = any(m.get("approximate") for m in selected)
|
AI-coach-agent/tests/test_pitching_coaching.py
CHANGED
|
@@ -96,7 +96,10 @@ def test_drill_context_never_becomes_validated_score(tmp_path):
|
|
| 96 |
p = payload()
|
| 97 |
p["context"]["drill_type"] = "rocker"
|
| 98 |
r = build_pitch_report(p, settings=settings(tmp_path))
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
| 100 |
assert r["drill_evaluation"]["validation_status"] == "provisional_qualitative"
|
| 101 |
|
| 102 |
|
|
|
|
| 96 |
p = payload()
|
| 97 |
p["context"]["drill_type"] = "rocker"
|
| 98 |
r = build_pitch_report(p, settings=settings(tmp_path))
|
| 99 |
+
# The drill checklist is never scored; the delivery is compared except for the rocker's leg lift and stride.
|
| 100 |
+
assert r["drill_evaluation"]["score"] is None
|
| 101 |
+
lift = next(m for m in r["measurements"] if m["metric_id"] == "torso_inclination_at_leg_lift")
|
| 102 |
+
assert lift["score"] is None and lift["not_rated_reason"] in ("not_comparable_for_drill", "measurement_unavailable")
|
| 103 |
assert r["drill_evaluation"]["validation_status"] == "provisional_qualitative"
|
| 104 |
|
| 105 |
|
AI-coach-agent/tests/test_pitching_report.py
CHANGED
|
@@ -63,14 +63,10 @@ def payload():
|
|
| 63 |
@pytest.mark.parametrize(
|
| 64 |
"context",
|
| 65 |
[
|
| 66 |
-
{"
|
| 67 |
-
{"drill_type": "step_back"},
|
| 68 |
-
{"drill_type": "rocker"},
|
| 69 |
-
{"drill_type": "unknown"},
|
| 70 |
{"pitch_type": "breaking_ball"},
|
| 71 |
-
{"pitch_type": "
|
| 72 |
{"ball_type": "training_ball"},
|
| 73 |
-
{"ball_type": "unknown"},
|
| 74 |
],
|
| 75 |
)
|
| 76 |
def test_nonmatching_context_keeps_measurements_without_normal_delivery_grades(context):
|
|
@@ -159,6 +155,42 @@ def test_wrong_profile_throwing_hand_cannot_select_another_side_or_enable_advice
|
|
| 159 |
assert all(m["benchmark"]["benchmark_id"].endswith(".right.college") for m in r["measurements"] if m["benchmark"])
|
| 160 |
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
def test_rules_text_passes_guardrails():
|
| 163 |
from ai_coach.pitch_report.v1_1.service import coaching_rules
|
| 164 |
from ai_coach.swing_report.text import check_text
|
|
|
|
| 63 |
@pytest.mark.parametrize(
|
| 64 |
"context",
|
| 65 |
[
|
| 66 |
+
{"drill_type": "other"},
|
|
|
|
|
|
|
|
|
|
| 67 |
{"pitch_type": "breaking_ball"},
|
| 68 |
+
{"pitch_type": "changeup"},
|
| 69 |
{"ball_type": "training_ball"},
|
|
|
|
| 70 |
],
|
| 71 |
)
|
| 72 |
def test_nonmatching_context_keeps_measurements_without_normal_delivery_grades(context):
|
|
|
|
| 155 |
assert all(m["benchmark"]["benchmark_id"].endswith(".right.college") for m in r["measurements"] if m["benchmark"])
|
| 156 |
|
| 157 |
|
| 158 |
+
LEG_LIFT_AND_STRIDE = {"torso_inclination_at_leg_lift", "leg_lift_to_foot_strike_ms", "ankle_span_at_foot_strike_cm"}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
@pytest.mark.parametrize("context", [{"practice_type": "unknown"}, {"drill_type": "unknown"},
|
| 162 |
+
{"pitch_type": "unknown"}, {"ball_type": "unknown"},
|
| 163 |
+
{"practice_type": "unknown", "drill_type": "unknown", "pitch_type": "unknown",
|
| 164 |
+
"ball_type": "unknown"}])
|
| 165 |
+
def test_unknown_context_is_rated_but_leg_lift_and_stride_are_not_coached(context):
|
| 166 |
+
p = rated_payload()
|
| 167 |
+
lift = next(m for m in p["measurements"] if m["metric_id"] == "torso_inclination_at_leg_lift")
|
| 168 |
+
lift.update(value=30.0, value_interval={"lower": 29.9, "upper": 30.1, "source": "adjacent_event_frames"})
|
| 169 |
+
p["context"].update(context)
|
| 170 |
+
r = build_report(p, AthleteContext(level="college"))
|
| 171 |
+
rows = {m["metric_id"]: m for m in r["measurements"]}
|
| 172 |
+
assert r["overall_score"] is not None
|
| 173 |
+
assert rows["torso_inclination_at_leg_lift"]["rating"] == "off_target"
|
| 174 |
+
assert all(rows[k]["coach_tip"] is None for k in LEG_LIFT_AND_STRIDE)
|
| 175 |
+
assert r["focus_area"]["metric_id"] not in LEG_LIFT_AND_STRIDE and r["focus_area"]["drill"] is not None
|
| 176 |
+
assert "everything" not in r["overview"]["headline"].lower()
|
| 177 |
+
assert "practice_context_unknown" in {n["code"] for n in r["data_quality"]}
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
@pytest.mark.parametrize("drill_type", ["step_back", "rocker"])
|
| 181 |
+
def test_step_back_and_rocker_compare_everything_but_leg_lift_and_stride(drill_type):
|
| 182 |
+
p = rated_payload()
|
| 183 |
+
p["context"]["drill_type"] = drill_type
|
| 184 |
+
r = build_report(p, AthleteContext(level="college"))
|
| 185 |
+
for m in r["measurements"]:
|
| 186 |
+
if m["metric_id"] in LEG_LIFT_AND_STRIDE:
|
| 187 |
+
assert m["score"] is None and m["not_rated_reason"] == "not_comparable_for_drill"
|
| 188 |
+
elif m["benchmark"] is not None:
|
| 189 |
+
assert m["score"] == 100
|
| 190 |
+
assert r["overall_score"] == 100 and r["focus_area"]["kind"] == "maintain"
|
| 191 |
+
assert "not_comparable_for_drill" in {n["code"] for n in r["data_quality"]}
|
| 192 |
+
|
| 193 |
+
|
| 194 |
def test_rules_text_passes_guardrails():
|
| 195 |
from ai_coach.pitch_report.v1_1.service import coaching_rules
|
| 196 |
from ai_coach.swing_report.text import check_text
|
backend/app/main.py
CHANGED
|
@@ -4,7 +4,6 @@ import re
|
|
| 4 |
import uuid
|
| 5 |
|
| 6 |
from ai_coach.config import get_settings as get_coach_settings
|
| 7 |
-
from ai_coach.pitch_report.schemas import PitchAnalysisPayload
|
| 8 |
from ai_coach.pitch_report.v1_1.contract import PitchPayload
|
| 9 |
from ai_coach.swing_report.schemas import SwingAnalysisPayload, SwingReport
|
| 10 |
from fastapi import FastAPI, Request
|
|
@@ -98,7 +97,7 @@ ERROR_SCHEMA = {
|
|
| 98 |
|
| 99 |
|
| 100 |
REQUEST_MODELS = {"/v1/sessions/{session_id}/swing-report": ("SwingAnalysisPayload",),
|
| 101 |
-
"/v1/sessions/{session_id}/pitch-report": ("
|
| 102 |
|
| 103 |
|
| 104 |
def _openapi(app: FastAPI) -> dict:
|
|
@@ -110,8 +109,8 @@ def _openapi(app: FastAPI) -> dict:
|
|
| 110 |
schemas.pop("HTTPValidationError", None)
|
| 111 |
schemas.pop("ValidationError", None)
|
| 112 |
schemas["ErrorResponse"] = ERROR_SCHEMA
|
| 113 |
-
_, contract = models_json_schema([(SwingAnalysisPayload, "validation"), (
|
| 114 |
-
|
| 115 |
schemas.update(contract.get("$defs", {}))
|
| 116 |
# Isolate pitch-1.1 validation definitions from existing input names and response serialization schemas.
|
| 117 |
pitch_input = PitchPayload.model_json_schema(
|
|
|
|
| 4 |
import uuid
|
| 5 |
|
| 6 |
from ai_coach.config import get_settings as get_coach_settings
|
|
|
|
| 7 |
from ai_coach.pitch_report.v1_1.contract import PitchPayload
|
| 8 |
from ai_coach.swing_report.schemas import SwingAnalysisPayload, SwingReport
|
| 9 |
from fastapi import FastAPI, Request
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
REQUEST_MODELS = {"/v1/sessions/{session_id}/swing-report": ("SwingAnalysisPayload",),
|
| 100 |
+
"/v1/sessions/{session_id}/pitch-report": ("PitchPayload",)}
|
| 101 |
|
| 102 |
|
| 103 |
def _openapi(app: FastAPI) -> dict:
|
|
|
|
| 109 |
schemas.pop("HTTPValidationError", None)
|
| 110 |
schemas.pop("ValidationError", None)
|
| 111 |
schemas["ErrorResponse"] = ERROR_SCHEMA
|
| 112 |
+
_, contract = models_json_schema([(SwingAnalysisPayload, "validation"), (SwingReport, "serialization")],
|
| 113 |
+
ref_template="#/components/schemas/{model}")
|
| 114 |
schemas.update(contract.get("$defs", {}))
|
| 115 |
# Isolate pitch-1.1 validation definitions from existing input names and response serialization schemas.
|
| 116 |
pitch_input = PitchPayload.model_json_schema(
|
backend/app/modules/swing_reports/controller.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""H1: POST /v1/sessions/{session_id}/swing-report (contract 1.0/1.1) and /pitch-report (pitch-1.
|
| 2 |
|
| 3 |
The body is the ML API's payload, unchanged. Pitch-1.1 returns the pitching report extension.
|
| 4 |
"""
|
|
|
|
| 1 |
+
"""H1: POST /v1/sessions/{session_id}/swing-report (contract 1.0/1.1) and /pitch-report (pitch-1.1).
|
| 2 |
|
| 3 |
The body is the ML API's payload, unchanged. Pitch-1.1 returns the pitching report extension.
|
| 4 |
"""
|
backend/app/modules/swing_reports/service.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"""H1: validate the ML payload, build the swing or pitch report with the ai_coach library and save both on the session.
|
| 2 |
|
| 3 |
-
Hitting sessions (mode "h") take swing contract 1.0/1.1; pitching sessions (mode "p") take pitch-1.
|
| 4 |
Pitch-1.1 coaching uses only structured ML evidence.
|
| 5 |
|
| 6 |
Revision rules: the same analysis_id and revision returns the stored report (no rebuild, no model call); a lower
|
|
@@ -98,7 +98,7 @@ class ReportKind:
|
|
| 98 |
|
| 99 |
SWING = ReportKind(mode="h", validate=validate_payload, contract="swing analysis contract 1.0 or 1.1",
|
| 100 |
mode_message="Swing reports are for hitting sessions.", marks=swing_marks)
|
| 101 |
-
PITCH = ReportKind(mode="p", validate=validate_pitch_payload, contract="pitch analysis contract pitch-1.
|
| 102 |
mode_message="Pitch reports are for pitching sessions.", marks=pitch_marks)
|
| 103 |
|
| 104 |
|
|
|
|
| 1 |
"""H1: validate the ML payload, build the swing or pitch report with the ai_coach library and save both on the session.
|
| 2 |
|
| 3 |
+
Hitting sessions (mode "h") take swing contract 1.0/1.1; pitching sessions (mode "p") take pitch-1.1.
|
| 4 |
Pitch-1.1 coaching uses only structured ML evidence.
|
| 5 |
|
| 6 |
Revision rules: the same analysis_id and revision returns the stored report (no rebuild, no model call); a lower
|
|
|
|
| 98 |
|
| 99 |
SWING = ReportKind(mode="h", validate=validate_payload, contract="swing analysis contract 1.0 or 1.1",
|
| 100 |
mode_message="Swing reports are for hitting sessions.", marks=swing_marks)
|
| 101 |
+
PITCH = ReportKind(mode="p", validate=validate_pitch_payload, contract="pitch analysis contract pitch-1.1",
|
| 102 |
mode_message="Pitch reports are for pitching sessions.", marks=pitch_marks)
|
| 103 |
|
| 104 |
|
backend/docs/FRONTEND_INTEGRATION.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
| 19 |
|
| 20 |
When this guide and `openapi.json` disagree, `openapi.json` wins. Please report the mismatch.
|
| 21 |
|
| 22 |
-
Regenerate older client models before adding pitching: `POST /v1/sessions/{id}/pitch-report` accepts
|
| 23 |
|
| 24 |
When generating with `openapi-typescript`, use `--default-non-nullable false` so optional fields with defaults remain optional. Version 7.13.0 with that setting passed strict TypeScript compilation using current pitching, legacy pitching and hitting fixtures; the pitching guide includes the complete command.
|
| 25 |
|
|
@@ -164,7 +164,7 @@ The app calls the ML API itself. Our backend never calls the ML API: the app for
|
|
| 164 |
- For someone else's swing, send `{name, age, height_cm, weight_kg, bats, throws, level}`; all are required.
|
| 165 |
- **Plan:** the free plan allows 3 analysed swings in a rolling 7 days, counting swings filmed for someone else. Step 3 returns 402 `PLAN_LIMIT` before anything is stored. Pending sessions that never get a report don't count, and are deleted with their media after 24 h.
|
| 166 |
- **No polling:** the Analyzing screen waits on steps 4 and 5. There is no `queued` or `processing` status: a session is `pending` until its report exists, then `done`.
|
| 167 |
-
- **Pitching:** for a `mode:"p"` session, step 5 is `POST /v1/sessions/{id}/pitch-report` with the ML pitch payload (contract `pitch-1.
|
| 168 |
- **Re-analysis:** post a payload with a higher `analysis_revision` and the same `analysis_id`.
|
| 169 |
- Re-posting the same id and revision is safe: it returns the stored report.
|
| 170 |
- A lower revision returns 409 `STALE_REVISION`.
|
|
|
|
| 19 |
|
| 20 |
When this guide and `openapi.json` disagree, `openapi.json` wins. Please report the mismatch.
|
| 21 |
|
| 22 |
+
Regenerate older client models before adding pitching: `POST /v1/sessions/{id}/pitch-report` accepts `pitch-1.1`. `SessionOut.report` is a nullable union of the existing swing/legacy report and the current pitching report. Report `schema_version` remains `1.0` for both; use `discipline` when present and session `mode` for legacy reports. Regular fastballs and unknown contexts are scored; see `AI-coach-agent/docs/PITCH_REPORT_API.md`.
|
| 23 |
|
| 24 |
When generating with `openapi-typescript`, use `--default-non-nullable false` so optional fields with defaults remain optional. Version 7.13.0 with that setting passed strict TypeScript compilation using current pitching, legacy pitching and hitting fixtures; the pitching guide includes the complete command.
|
| 25 |
|
|
|
|
| 164 |
- For someone else's swing, send `{name, age, height_cm, weight_kg, bats, throws, level}`; all are required.
|
| 165 |
- **Plan:** the free plan allows 3 analysed swings in a rolling 7 days, counting swings filmed for someone else. Step 3 returns 402 `PLAN_LIMIT` before anything is stored. Pending sessions that never get a report don't count, and are deleted with their media after 24 h.
|
| 166 |
- **No polling:** the Analyzing screen waits on steps 4 and 5. There is no `queued` or `processing` status: a session is `pending` until its report exists, then `done`.
|
| 167 |
+
- **Pitching:** for a `mode:"p"` session, step 5 is `POST /v1/sessions/{id}/pitch-report` with the ML pitch payload (contract `pitch-1.1`, see `AI-coach-agent/docs/PITCH_REPORT_API.md`). It returns the pitching report, with the groups `gather`, `stride_plant`, `rotation_release` and `release_finish`, and the same revision, plan and consent rules. Posting to the wrong endpoint for the session mode returns 422 `MODE_NOT_SUPPORTED`. The throwing side comes from the payload's `athlete.throwing_hand`, then the session athlete's `throws`.
|
| 168 |
- **Re-analysis:** post a payload with a higher `analysis_revision` and the same `analysis_id`.
|
| 169 |
- Re-posting the same id and revision is safe: it returns the stored report.
|
| 170 |
- A lower revision returns 409 `STALE_REVISION`.
|
backend/docs/openapi.json
CHANGED
|
@@ -1436,14 +1436,7 @@
|
|
| 1436 |
"content": {
|
| 1437 |
"application/json": {
|
| 1438 |
"schema": {
|
| 1439 |
-
"
|
| 1440 |
-
{
|
| 1441 |
-
"$ref": "#/components/schemas/PitchAnalysisPayload"
|
| 1442 |
-
},
|
| 1443 |
-
{
|
| 1444 |
-
"$ref": "#/components/schemas/PitchPayload"
|
| 1445 |
-
}
|
| 1446 |
-
]
|
| 1447 |
}
|
| 1448 |
}
|
| 1449 |
}
|
|
@@ -9767,11 +9760,7 @@
|
|
| 9767 |
"balance_load",
|
| 9768 |
"stride",
|
| 9769 |
"power_move",
|
| 9770 |
-
"contact_follow_through"
|
| 9771 |
-
"leg_lift_balance",
|
| 9772 |
-
"stride_landing",
|
| 9773 |
-
"arm_action",
|
| 9774 |
-
"release_finish"
|
| 9775 |
],
|
| 9776 |
"type": "string"
|
| 9777 |
},
|
|
@@ -10246,11 +10235,7 @@
|
|
| 10246 |
"balance_load",
|
| 10247 |
"stride",
|
| 10248 |
"power_move",
|
| 10249 |
-
"contact_follow_through"
|
| 10250 |
-
"leg_lift_balance",
|
| 10251 |
-
"stride_landing",
|
| 10252 |
-
"arm_action",
|
| 10253 |
-
"release_finish"
|
| 10254 |
],
|
| 10255 |
"title": "Group",
|
| 10256 |
"type": "string"
|
|
@@ -10841,11 +10826,7 @@
|
|
| 10841 |
"balance_load",
|
| 10842 |
"stride",
|
| 10843 |
"power_move",
|
| 10844 |
-
"contact_follow_through"
|
| 10845 |
-
"leg_lift_balance",
|
| 10846 |
-
"stride_landing",
|
| 10847 |
-
"arm_action",
|
| 10848 |
-
"release_finish"
|
| 10849 |
],
|
| 10850 |
"title": "Group",
|
| 10851 |
"type": "string"
|
|
@@ -16312,604 +16293,6 @@
|
|
| 16312 |
"title": "Measurement",
|
| 16313 |
"type": "object"
|
| 16314 |
},
|
| 16315 |
-
"PitchAnalysisPayload": {
|
| 16316 |
-
"additionalProperties": false,
|
| 16317 |
-
"properties": {
|
| 16318 |
-
"schema_version": {
|
| 16319 |
-
"const": "pitch-1.0",
|
| 16320 |
-
"title": "Schema Version",
|
| 16321 |
-
"type": "string"
|
| 16322 |
-
},
|
| 16323 |
-
"analysis_id": {
|
| 16324 |
-
"minLength": 1,
|
| 16325 |
-
"pattern": "\\S",
|
| 16326 |
-
"title": "Analysis Id",
|
| 16327 |
-
"type": "string"
|
| 16328 |
-
},
|
| 16329 |
-
"analysis_revision": {
|
| 16330 |
-
"minimum": 1,
|
| 16331 |
-
"title": "Analysis Revision",
|
| 16332 |
-
"type": "integer"
|
| 16333 |
-
},
|
| 16334 |
-
"pitch_id": {
|
| 16335 |
-
"minLength": 1,
|
| 16336 |
-
"pattern": "\\S",
|
| 16337 |
-
"title": "Pitch Id",
|
| 16338 |
-
"type": "string"
|
| 16339 |
-
},
|
| 16340 |
-
"status": {
|
| 16341 |
-
"const": "completed",
|
| 16342 |
-
"title": "Status",
|
| 16343 |
-
"type": "string"
|
| 16344 |
-
},
|
| 16345 |
-
"athlete": {
|
| 16346 |
-
"$ref": "#/components/schemas/PitchAthlete"
|
| 16347 |
-
},
|
| 16348 |
-
"context": {
|
| 16349 |
-
"$ref": "#/components/schemas/PitchContext"
|
| 16350 |
-
},
|
| 16351 |
-
"measurement_definitions_version": {
|
| 16352 |
-
"const": "pitch-1.0",
|
| 16353 |
-
"title": "Measurement Definitions Version",
|
| 16354 |
-
"type": "string"
|
| 16355 |
-
},
|
| 16356 |
-
"events": {
|
| 16357 |
-
"$ref": "#/components/schemas/PitchEvents"
|
| 16358 |
-
},
|
| 16359 |
-
"measurements": {
|
| 16360 |
-
"items": {
|
| 16361 |
-
"$ref": "#/components/schemas/PitchMeasurement"
|
| 16362 |
-
},
|
| 16363 |
-
"minItems": 1,
|
| 16364 |
-
"title": "Measurements",
|
| 16365 |
-
"type": "array"
|
| 16366 |
-
}
|
| 16367 |
-
},
|
| 16368 |
-
"required": [
|
| 16369 |
-
"schema_version",
|
| 16370 |
-
"analysis_id",
|
| 16371 |
-
"analysis_revision",
|
| 16372 |
-
"pitch_id",
|
| 16373 |
-
"status",
|
| 16374 |
-
"athlete",
|
| 16375 |
-
"context",
|
| 16376 |
-
"measurement_definitions_version",
|
| 16377 |
-
"events",
|
| 16378 |
-
"measurements"
|
| 16379 |
-
],
|
| 16380 |
-
"title": "PitchAnalysisPayload",
|
| 16381 |
-
"type": "object"
|
| 16382 |
-
},
|
| 16383 |
-
"PitchAthlete": {
|
| 16384 |
-
"additionalProperties": false,
|
| 16385 |
-
"properties": {
|
| 16386 |
-
"athlete_id": {
|
| 16387 |
-
"minLength": 1,
|
| 16388 |
-
"pattern": "\\S",
|
| 16389 |
-
"title": "Athlete Id",
|
| 16390 |
-
"type": "string"
|
| 16391 |
-
},
|
| 16392 |
-
"throwing_hand": {
|
| 16393 |
-
"anyOf": [
|
| 16394 |
-
{
|
| 16395 |
-
"enum": [
|
| 16396 |
-
"left",
|
| 16397 |
-
"right"
|
| 16398 |
-
],
|
| 16399 |
-
"type": "string"
|
| 16400 |
-
},
|
| 16401 |
-
{
|
| 16402 |
-
"type": "null"
|
| 16403 |
-
}
|
| 16404 |
-
],
|
| 16405 |
-
"title": "Throwing Hand"
|
| 16406 |
-
},
|
| 16407 |
-
"lead_foot": {
|
| 16408 |
-
"anyOf": [
|
| 16409 |
-
{
|
| 16410 |
-
"enum": [
|
| 16411 |
-
"left",
|
| 16412 |
-
"right"
|
| 16413 |
-
],
|
| 16414 |
-
"type": "string"
|
| 16415 |
-
},
|
| 16416 |
-
{
|
| 16417 |
-
"type": "null"
|
| 16418 |
-
}
|
| 16419 |
-
],
|
| 16420 |
-
"title": "Lead Foot"
|
| 16421 |
-
},
|
| 16422 |
-
"age_years": {
|
| 16423 |
-
"anyOf": [
|
| 16424 |
-
{
|
| 16425 |
-
"minimum": 0,
|
| 16426 |
-
"type": "integer"
|
| 16427 |
-
},
|
| 16428 |
-
{
|
| 16429 |
-
"type": "null"
|
| 16430 |
-
}
|
| 16431 |
-
],
|
| 16432 |
-
"title": "Age Years"
|
| 16433 |
-
},
|
| 16434 |
-
"height_cm": {
|
| 16435 |
-
"anyOf": [
|
| 16436 |
-
{
|
| 16437 |
-
"exclusiveMinimum": 0,
|
| 16438 |
-
"type": "number"
|
| 16439 |
-
},
|
| 16440 |
-
{
|
| 16441 |
-
"type": "null"
|
| 16442 |
-
}
|
| 16443 |
-
],
|
| 16444 |
-
"title": "Height Cm"
|
| 16445 |
-
}
|
| 16446 |
-
},
|
| 16447 |
-
"required": [
|
| 16448 |
-
"athlete_id",
|
| 16449 |
-
"throwing_hand",
|
| 16450 |
-
"lead_foot",
|
| 16451 |
-
"age_years",
|
| 16452 |
-
"height_cm"
|
| 16453 |
-
],
|
| 16454 |
-
"title": "PitchAthlete",
|
| 16455 |
-
"type": "object"
|
| 16456 |
-
},
|
| 16457 |
-
"PitchBenchmark": {
|
| 16458 |
-
"additionalProperties": false,
|
| 16459 |
-
"properties": {
|
| 16460 |
-
"benchmark_id": {
|
| 16461 |
-
"minLength": 1,
|
| 16462 |
-
"pattern": "\\S",
|
| 16463 |
-
"title": "Benchmark Id",
|
| 16464 |
-
"type": "string"
|
| 16465 |
-
},
|
| 16466 |
-
"version": {
|
| 16467 |
-
"minLength": 1,
|
| 16468 |
-
"pattern": "\\S",
|
| 16469 |
-
"title": "Version",
|
| 16470 |
-
"type": "string"
|
| 16471 |
-
},
|
| 16472 |
-
"kind": {
|
| 16473 |
-
"const": "reference_interval",
|
| 16474 |
-
"title": "Kind",
|
| 16475 |
-
"type": "string"
|
| 16476 |
-
},
|
| 16477 |
-
"lower": {
|
| 16478 |
-
"anyOf": [
|
| 16479 |
-
{
|
| 16480 |
-
"type": "number"
|
| 16481 |
-
},
|
| 16482 |
-
{
|
| 16483 |
-
"type": "null"
|
| 16484 |
-
}
|
| 16485 |
-
],
|
| 16486 |
-
"title": "Lower"
|
| 16487 |
-
},
|
| 16488 |
-
"upper": {
|
| 16489 |
-
"anyOf": [
|
| 16490 |
-
{
|
| 16491 |
-
"type": "number"
|
| 16492 |
-
},
|
| 16493 |
-
{
|
| 16494 |
-
"type": "null"
|
| 16495 |
-
}
|
| 16496 |
-
],
|
| 16497 |
-
"title": "Upper"
|
| 16498 |
-
},
|
| 16499 |
-
"unit": {
|
| 16500 |
-
"enum": [
|
| 16501 |
-
"deg",
|
| 16502 |
-
"pct_height"
|
| 16503 |
-
],
|
| 16504 |
-
"title": "Unit",
|
| 16505 |
-
"type": "string"
|
| 16506 |
-
},
|
| 16507 |
-
"source_reference": {
|
| 16508 |
-
"minLength": 1,
|
| 16509 |
-
"pattern": "\\S",
|
| 16510 |
-
"title": "Source Reference",
|
| 16511 |
-
"type": "string"
|
| 16512 |
-
}
|
| 16513 |
-
},
|
| 16514 |
-
"required": [
|
| 16515 |
-
"benchmark_id",
|
| 16516 |
-
"version",
|
| 16517 |
-
"kind",
|
| 16518 |
-
"lower",
|
| 16519 |
-
"upper",
|
| 16520 |
-
"unit",
|
| 16521 |
-
"source_reference"
|
| 16522 |
-
],
|
| 16523 |
-
"title": "PitchBenchmark",
|
| 16524 |
-
"type": "object"
|
| 16525 |
-
},
|
| 16526 |
-
"PitchContext": {
|
| 16527 |
-
"additionalProperties": false,
|
| 16528 |
-
"properties": {
|
| 16529 |
-
"sport": {
|
| 16530 |
-
"const": "baseball",
|
| 16531 |
-
"title": "Sport",
|
| 16532 |
-
"type": "string"
|
| 16533 |
-
},
|
| 16534 |
-
"practice_type": {
|
| 16535 |
-
"enum": [
|
| 16536 |
-
"bullpen",
|
| 16537 |
-
"flat_ground",
|
| 16538 |
-
"game",
|
| 16539 |
-
"live_bp",
|
| 16540 |
-
"long_toss",
|
| 16541 |
-
"dry_drill",
|
| 16542 |
-
"towel_drill",
|
| 16543 |
-
"unknown"
|
| 16544 |
-
],
|
| 16545 |
-
"title": "Practice Type",
|
| 16546 |
-
"type": "string"
|
| 16547 |
-
},
|
| 16548 |
-
"delivery": {
|
| 16549 |
-
"enum": [
|
| 16550 |
-
"windup",
|
| 16551 |
-
"stretch",
|
| 16552 |
-
"unknown"
|
| 16553 |
-
],
|
| 16554 |
-
"title": "Delivery",
|
| 16555 |
-
"type": "string"
|
| 16556 |
-
},
|
| 16557 |
-
"pitch_type": {
|
| 16558 |
-
"enum": [
|
| 16559 |
-
"fastball",
|
| 16560 |
-
"changeup",
|
| 16561 |
-
"breaking",
|
| 16562 |
-
"unknown"
|
| 16563 |
-
],
|
| 16564 |
-
"title": "Pitch Type",
|
| 16565 |
-
"type": "string"
|
| 16566 |
-
},
|
| 16567 |
-
"camera_view": {
|
| 16568 |
-
"enum": [
|
| 16569 |
-
"open_side",
|
| 16570 |
-
"behind",
|
| 16571 |
-
"front",
|
| 16572 |
-
"unknown"
|
| 16573 |
-
],
|
| 16574 |
-
"title": "Camera View",
|
| 16575 |
-
"type": "string"
|
| 16576 |
-
}
|
| 16577 |
-
},
|
| 16578 |
-
"required": [
|
| 16579 |
-
"sport",
|
| 16580 |
-
"practice_type",
|
| 16581 |
-
"delivery",
|
| 16582 |
-
"pitch_type",
|
| 16583 |
-
"camera_view"
|
| 16584 |
-
],
|
| 16585 |
-
"title": "PitchContext",
|
| 16586 |
-
"type": "object"
|
| 16587 |
-
},
|
| 16588 |
-
"PitchEvent": {
|
| 16589 |
-
"additionalProperties": false,
|
| 16590 |
-
"properties": {
|
| 16591 |
-
"status": {
|
| 16592 |
-
"enum": [
|
| 16593 |
-
"available",
|
| 16594 |
-
"limited",
|
| 16595 |
-
"unavailable"
|
| 16596 |
-
],
|
| 16597 |
-
"title": "Status",
|
| 16598 |
-
"type": "string"
|
| 16599 |
-
},
|
| 16600 |
-
"video_time_s": {
|
| 16601 |
-
"anyOf": [
|
| 16602 |
-
{
|
| 16603 |
-
"type": "number"
|
| 16604 |
-
},
|
| 16605 |
-
{
|
| 16606 |
-
"type": "null"
|
| 16607 |
-
}
|
| 16608 |
-
],
|
| 16609 |
-
"title": "Video Time S"
|
| 16610 |
-
},
|
| 16611 |
-
"capture_time_s": {
|
| 16612 |
-
"anyOf": [
|
| 16613 |
-
{
|
| 16614 |
-
"type": "number"
|
| 16615 |
-
},
|
| 16616 |
-
{
|
| 16617 |
-
"type": "null"
|
| 16618 |
-
}
|
| 16619 |
-
],
|
| 16620 |
-
"title": "Capture Time S"
|
| 16621 |
-
},
|
| 16622 |
-
"source": {
|
| 16623 |
-
"anyOf": [
|
| 16624 |
-
{
|
| 16625 |
-
"enum": [
|
| 16626 |
-
"manual_review",
|
| 16627 |
-
"pose_estimated"
|
| 16628 |
-
],
|
| 16629 |
-
"type": "string"
|
| 16630 |
-
},
|
| 16631 |
-
{
|
| 16632 |
-
"type": "null"
|
| 16633 |
-
}
|
| 16634 |
-
],
|
| 16635 |
-
"title": "Source"
|
| 16636 |
-
},
|
| 16637 |
-
"reasons": {
|
| 16638 |
-
"items": {
|
| 16639 |
-
"enum": [
|
| 16640 |
-
"event_not_detected",
|
| 16641 |
-
"event_timing_uncertain",
|
| 16642 |
-
"required_event_unavailable",
|
| 16643 |
-
"required_event_limited",
|
| 16644 |
-
"lead_foot_unknown",
|
| 16645 |
-
"required_landmarks_unusable",
|
| 16646 |
-
"ground_plane_unknown",
|
| 16647 |
-
"excessive_interpolation",
|
| 16648 |
-
"occlusion_unresolved",
|
| 16649 |
-
"temporal_inconsistency",
|
| 16650 |
-
"capture_time_unknown",
|
| 16651 |
-
"model_accuracy_unvalidated",
|
| 16652 |
-
"release_not_verified",
|
| 16653 |
-
"pitching_direction_unknown",
|
| 16654 |
-
"camera_view_unsuitable"
|
| 16655 |
-
],
|
| 16656 |
-
"type": "string"
|
| 16657 |
-
},
|
| 16658 |
-
"title": "Reasons",
|
| 16659 |
-
"type": "array"
|
| 16660 |
-
},
|
| 16661 |
-
"source_frame_index": {
|
| 16662 |
-
"anyOf": [
|
| 16663 |
-
{
|
| 16664 |
-
"minimum": 0,
|
| 16665 |
-
"type": "integer"
|
| 16666 |
-
},
|
| 16667 |
-
{
|
| 16668 |
-
"type": "null"
|
| 16669 |
-
}
|
| 16670 |
-
],
|
| 16671 |
-
"default": null,
|
| 16672 |
-
"title": "Source Frame Index"
|
| 16673 |
-
}
|
| 16674 |
-
},
|
| 16675 |
-
"required": [
|
| 16676 |
-
"status",
|
| 16677 |
-
"video_time_s",
|
| 16678 |
-
"capture_time_s",
|
| 16679 |
-
"source"
|
| 16680 |
-
],
|
| 16681 |
-
"title": "PitchEvent",
|
| 16682 |
-
"type": "object"
|
| 16683 |
-
},
|
| 16684 |
-
"PitchEvents": {
|
| 16685 |
-
"additionalProperties": false,
|
| 16686 |
-
"properties": {
|
| 16687 |
-
"peak_knee_height": {
|
| 16688 |
-
"anyOf": [
|
| 16689 |
-
{
|
| 16690 |
-
"$ref": "#/components/schemas/PitchEvent"
|
| 16691 |
-
},
|
| 16692 |
-
{
|
| 16693 |
-
"type": "null"
|
| 16694 |
-
}
|
| 16695 |
-
],
|
| 16696 |
-
"default": null
|
| 16697 |
-
},
|
| 16698 |
-
"foot_plant": {
|
| 16699 |
-
"$ref": "#/components/schemas/PitchEvent"
|
| 16700 |
-
},
|
| 16701 |
-
"ball_release": {
|
| 16702 |
-
"$ref": "#/components/schemas/PitchEvent"
|
| 16703 |
-
}
|
| 16704 |
-
},
|
| 16705 |
-
"required": [
|
| 16706 |
-
"foot_plant",
|
| 16707 |
-
"ball_release"
|
| 16708 |
-
],
|
| 16709 |
-
"title": "PitchEvents",
|
| 16710 |
-
"type": "object"
|
| 16711 |
-
},
|
| 16712 |
-
"PitchMeasurement": {
|
| 16713 |
-
"additionalProperties": false,
|
| 16714 |
-
"properties": {
|
| 16715 |
-
"metric_id": {
|
| 16716 |
-
"enum": [
|
| 16717 |
-
"stride_length_pct_height",
|
| 16718 |
-
"stride_direction_deg",
|
| 16719 |
-
"hip_shoulder_separation_at_foot_plant",
|
| 16720 |
-
"trunk_forward_tilt_at_foot_plant",
|
| 16721 |
-
"shoulder_abduction_at_foot_plant",
|
| 16722 |
-
"elbow_flexion_at_foot_plant",
|
| 16723 |
-
"trunk_forward_tilt_at_release",
|
| 16724 |
-
"trunk_lateral_tilt_at_release",
|
| 16725 |
-
"arm_slot_at_release",
|
| 16726 |
-
"lead_knee_extension_plant_to_release"
|
| 16727 |
-
],
|
| 16728 |
-
"title": "Metric Id",
|
| 16729 |
-
"type": "string"
|
| 16730 |
-
},
|
| 16731 |
-
"group": {
|
| 16732 |
-
"enum": [
|
| 16733 |
-
"leg_lift_balance",
|
| 16734 |
-
"stride_landing",
|
| 16735 |
-
"arm_action",
|
| 16736 |
-
"release_finish"
|
| 16737 |
-
],
|
| 16738 |
-
"title": "Group",
|
| 16739 |
-
"type": "string"
|
| 16740 |
-
},
|
| 16741 |
-
"value": {
|
| 16742 |
-
"anyOf": [
|
| 16743 |
-
{
|
| 16744 |
-
"type": "number"
|
| 16745 |
-
},
|
| 16746 |
-
{
|
| 16747 |
-
"type": "null"
|
| 16748 |
-
}
|
| 16749 |
-
],
|
| 16750 |
-
"title": "Value"
|
| 16751 |
-
},
|
| 16752 |
-
"unit": {
|
| 16753 |
-
"enum": [
|
| 16754 |
-
"deg",
|
| 16755 |
-
"pct_height"
|
| 16756 |
-
],
|
| 16757 |
-
"title": "Unit",
|
| 16758 |
-
"type": "string"
|
| 16759 |
-
},
|
| 16760 |
-
"event_id": {
|
| 16761 |
-
"anyOf": [
|
| 16762 |
-
{
|
| 16763 |
-
"enum": [
|
| 16764 |
-
"peak_knee_height",
|
| 16765 |
-
"foot_plant",
|
| 16766 |
-
"ball_release"
|
| 16767 |
-
],
|
| 16768 |
-
"type": "string"
|
| 16769 |
-
},
|
| 16770 |
-
{
|
| 16771 |
-
"type": "null"
|
| 16772 |
-
}
|
| 16773 |
-
],
|
| 16774 |
-
"default": null,
|
| 16775 |
-
"title": "Event Id"
|
| 16776 |
-
},
|
| 16777 |
-
"start_event_id": {
|
| 16778 |
-
"anyOf": [
|
| 16779 |
-
{
|
| 16780 |
-
"enum": [
|
| 16781 |
-
"peak_knee_height",
|
| 16782 |
-
"foot_plant",
|
| 16783 |
-
"ball_release"
|
| 16784 |
-
],
|
| 16785 |
-
"type": "string"
|
| 16786 |
-
},
|
| 16787 |
-
{
|
| 16788 |
-
"type": "null"
|
| 16789 |
-
}
|
| 16790 |
-
],
|
| 16791 |
-
"default": null,
|
| 16792 |
-
"title": "Start Event Id"
|
| 16793 |
-
},
|
| 16794 |
-
"end_event_id": {
|
| 16795 |
-
"anyOf": [
|
| 16796 |
-
{
|
| 16797 |
-
"enum": [
|
| 16798 |
-
"peak_knee_height",
|
| 16799 |
-
"foot_plant",
|
| 16800 |
-
"ball_release"
|
| 16801 |
-
],
|
| 16802 |
-
"type": "string"
|
| 16803 |
-
},
|
| 16804 |
-
{
|
| 16805 |
-
"type": "null"
|
| 16806 |
-
}
|
| 16807 |
-
],
|
| 16808 |
-
"default": null,
|
| 16809 |
-
"title": "End Event Id"
|
| 16810 |
-
},
|
| 16811 |
-
"reference": {
|
| 16812 |
-
"enum": [
|
| 16813 |
-
"horizontal_lead_ankle_minus_rear_ankle_over_body_height",
|
| 16814 |
-
"stride_angle_cross_body_positive",
|
| 16815 |
-
"pelvis_minus_trunk_rotation_throwing_side",
|
| 16816 |
-
"trunk_flexion_forward_positive",
|
| 16817 |
-
"throwing_shoulder_abduction",
|
| 16818 |
-
"throwing_elbow_flexion",
|
| 16819 |
-
"trunk_lateral_flexion_glove_side_positive",
|
| 16820 |
-
"forearm_angle_above_horizontal",
|
| 16821 |
-
"change_in_3d_lead_knee_angle"
|
| 16822 |
-
],
|
| 16823 |
-
"title": "Reference",
|
| 16824 |
-
"type": "string"
|
| 16825 |
-
},
|
| 16826 |
-
"status": {
|
| 16827 |
-
"enum": [
|
| 16828 |
-
"available",
|
| 16829 |
-
"limited",
|
| 16830 |
-
"unavailable"
|
| 16831 |
-
],
|
| 16832 |
-
"title": "Status",
|
| 16833 |
-
"type": "string"
|
| 16834 |
-
},
|
| 16835 |
-
"confidence": {
|
| 16836 |
-
"anyOf": [
|
| 16837 |
-
{
|
| 16838 |
-
"maximum": 1,
|
| 16839 |
-
"minimum": 0,
|
| 16840 |
-
"type": "number"
|
| 16841 |
-
},
|
| 16842 |
-
{
|
| 16843 |
-
"type": "null"
|
| 16844 |
-
}
|
| 16845 |
-
],
|
| 16846 |
-
"title": "Confidence"
|
| 16847 |
-
},
|
| 16848 |
-
"uses_interpolated_input": {
|
| 16849 |
-
"title": "Uses Interpolated Input",
|
| 16850 |
-
"type": "boolean"
|
| 16851 |
-
},
|
| 16852 |
-
"reasons": {
|
| 16853 |
-
"items": {
|
| 16854 |
-
"enum": [
|
| 16855 |
-
"event_not_detected",
|
| 16856 |
-
"event_timing_uncertain",
|
| 16857 |
-
"required_event_unavailable",
|
| 16858 |
-
"required_event_limited",
|
| 16859 |
-
"lead_foot_unknown",
|
| 16860 |
-
"required_landmarks_unusable",
|
| 16861 |
-
"ground_plane_unknown",
|
| 16862 |
-
"excessive_interpolation",
|
| 16863 |
-
"occlusion_unresolved",
|
| 16864 |
-
"temporal_inconsistency",
|
| 16865 |
-
"capture_time_unknown",
|
| 16866 |
-
"model_accuracy_unvalidated",
|
| 16867 |
-
"release_not_verified",
|
| 16868 |
-
"pitching_direction_unknown",
|
| 16869 |
-
"camera_view_unsuitable"
|
| 16870 |
-
],
|
| 16871 |
-
"type": "string"
|
| 16872 |
-
},
|
| 16873 |
-
"title": "Reasons",
|
| 16874 |
-
"type": "array"
|
| 16875 |
-
},
|
| 16876 |
-
"benchmark": {
|
| 16877 |
-
"anyOf": [
|
| 16878 |
-
{
|
| 16879 |
-
"$ref": "#/components/schemas/PitchBenchmark"
|
| 16880 |
-
},
|
| 16881 |
-
{
|
| 16882 |
-
"type": "null"
|
| 16883 |
-
}
|
| 16884 |
-
]
|
| 16885 |
-
},
|
| 16886 |
-
"value_interval": {
|
| 16887 |
-
"anyOf": [
|
| 16888 |
-
{
|
| 16889 |
-
"$ref": "#/components/schemas/ValueInterval"
|
| 16890 |
-
},
|
| 16891 |
-
{
|
| 16892 |
-
"type": "null"
|
| 16893 |
-
}
|
| 16894 |
-
],
|
| 16895 |
-
"default": null
|
| 16896 |
-
}
|
| 16897 |
-
},
|
| 16898 |
-
"required": [
|
| 16899 |
-
"metric_id",
|
| 16900 |
-
"group",
|
| 16901 |
-
"value",
|
| 16902 |
-
"unit",
|
| 16903 |
-
"reference",
|
| 16904 |
-
"status",
|
| 16905 |
-
"confidence",
|
| 16906 |
-
"uses_interpolated_input",
|
| 16907 |
-
"reasons",
|
| 16908 |
-
"benchmark"
|
| 16909 |
-
],
|
| 16910 |
-
"title": "PitchMeasurement",
|
| 16911 |
-
"type": "object"
|
| 16912 |
-
},
|
| 16913 |
"SwingAnalysisPayload": {
|
| 16914 |
"additionalProperties": false,
|
| 16915 |
"properties": {
|
|
|
|
| 1436 |
"content": {
|
| 1437 |
"application/json": {
|
| 1438 |
"schema": {
|
| 1439 |
+
"$ref": "#/components/schemas/PitchPayload"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1440 |
}
|
| 1441 |
}
|
| 1442 |
}
|
|
|
|
| 9760 |
"balance_load",
|
| 9761 |
"stride",
|
| 9762 |
"power_move",
|
| 9763 |
+
"contact_follow_through"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9764 |
],
|
| 9765 |
"type": "string"
|
| 9766 |
},
|
|
|
|
| 10235 |
"balance_load",
|
| 10236 |
"stride",
|
| 10237 |
"power_move",
|
| 10238 |
+
"contact_follow_through"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10239 |
],
|
| 10240 |
"title": "Group",
|
| 10241 |
"type": "string"
|
|
|
|
| 10826 |
"balance_load",
|
| 10827 |
"stride",
|
| 10828 |
"power_move",
|
| 10829 |
+
"contact_follow_through"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10830 |
],
|
| 10831 |
"title": "Group",
|
| 10832 |
"type": "string"
|
|
|
|
| 16293 |
"title": "Measurement",
|
| 16294 |
"type": "object"
|
| 16295 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16296 |
"SwingAnalysisPayload": {
|
| 16297 |
"additionalProperties": false,
|
| 16298 |
"properties": {
|
backend/tests/integration/test_pitching_flow.py
CHANGED
|
@@ -110,9 +110,9 @@ async def test_pitch_report_store_read_retry_and_revision_clear_missing_marks(cl
|
|
| 110 |
assert response.status_code == 200, response.text
|
| 111 |
report = response.json()
|
| 112 |
assert report["discipline"] == "pitching" and len(report["measurements"]) == 10
|
| 113 |
-
# A rocker drill is
|
| 114 |
-
assert report["
|
| 115 |
-
assert report["focus_area"]["
|
| 116 |
saved = await load_session(sid)
|
| 117 |
assert saved.measurement_payload == p and saved.report == report and saved.status == "done"
|
| 118 |
assert saved.marks["release_frame"] == p["events"]["release"]["source_frame_index"]
|
|
|
|
| 110 |
assert response.status_code == 200, response.text
|
| 111 |
report = response.json()
|
| 112 |
assert report["discipline"] == "pitching" and len(report["measurements"]) == 10
|
| 113 |
+
# A rocker drill is compared except for its leg lift and stride; the focus always carries a drill.
|
| 114 |
+
assert next(g for g in report["groups"] if g["group"] == "gather")["score"] is None
|
| 115 |
+
assert report["focus_area"]["drill"] is not None
|
| 116 |
saved = await load_session(sid)
|
| 117 |
assert saved.measurement_payload == p and saved.report == report and saved.status == "done"
|
| 118 |
assert saved.marks["release_frame"] == p["events"]["release"]["source_frame_index"]
|
backend/tests/integration/test_pitching_openapi.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
-
"""Generated clients must accept
|
| 2 |
|
| 3 |
import copy
|
| 4 |
import json
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
import pytest
|
| 8 |
-
from ai_coach.pitch_report.schemas import PitchAnalysisPayload
|
| 9 |
from ai_coach.pitch_report.v1_1.schemas import PitchReport
|
| 10 |
from ai_coach.swing_report.schemas import SwingAnalysisPayload, SwingReport
|
| 11 |
from fastapi.openapi.utils import get_openapi
|
|
@@ -15,7 +14,6 @@ from pydantic.json_schema import models_json_schema
|
|
| 15 |
from app.integrations.pitching_reports import report_for_read
|
| 16 |
from app.main import create_app
|
| 17 |
from tests.factories import make_account
|
| 18 |
-
from tests.integration.test_pitch_reports import PITCH
|
| 19 |
from tests.integration.test_pitching_flow import payload as current_pitch_payload
|
| 20 |
from tests.integration.test_swing_reports import PAYLOAD, make_session
|
| 21 |
|
|
@@ -47,8 +45,8 @@ async def test_openapi_pitching_unions_and_all_references_resolve(client):
|
|
| 47 |
paths, schemas = spec["paths"], spec["components"]["schemas"]
|
| 48 |
pitch = paths["/v1/sessions/{session_id}/pitch-report"]["post"]
|
| 49 |
request = pitch["requestBody"]["content"]["application/json"]["schema"]
|
| 50 |
-
assert request == {"
|
| 51 |
-
|
| 52 |
assert schemas["SessionOut"]["properties"]["report"]["anyOf"] == [
|
| 53 |
{"$ref": "#/components/schemas/SwingReport"}, {"$ref": "#/components/schemas/PitchReport"}, {"type": "null"}]
|
| 54 |
assert paths["/v1/sessions"]["post"]["responses"]["201"]["content"]["application/json"]["schema"] == {
|
|
@@ -60,7 +58,6 @@ async def test_openapi_pitching_unions_and_all_references_resolve(client):
|
|
| 60 |
assert retry["responses"]["200"]["content"]["application/json"]["schema"] == {
|
| 61 |
"$ref": "#/components/schemas/PitchReport"}
|
| 62 |
assert schemas["PitchPayload"]["properties"]["schema_version"]["const"] == "pitch-1.1"
|
| 63 |
-
assert schemas["PitchAnalysisPayload"]["properties"]["schema_version"]["const"] == "pitch-1.0"
|
| 64 |
assert schemas["PitchPayload"]["properties"]["visual_evidence"]["type"] == "null"
|
| 65 |
assert schemas["PitchReport"]["properties"]["visual_evidence"]["type"] == "null"
|
| 66 |
|
|
@@ -69,7 +66,7 @@ def test_existing_schema_components_and_hitting_contract_remain_unchanged():
|
|
| 69 |
app = create_app()
|
| 70 |
before = get_openapi(title=app.title, version=app.version, routes=app.routes)
|
| 71 |
_, contracts = models_json_schema([
|
| 72 |
-
(SwingAnalysisPayload, "validation"), (
|
| 73 |
], ref_template="#/components/schemas/{model}")
|
| 74 |
before["components"]["schemas"].update(contracts["$defs"])
|
| 75 |
after = app.openapi()
|
|
@@ -83,13 +80,12 @@ def test_existing_schema_components_and_hitting_contract_remain_unchanged():
|
|
| 83 |
"$ref": "#/components/schemas/SwingReport"}
|
| 84 |
|
| 85 |
|
| 86 |
-
@pytest.mark.parametrize("kind", ["current_pitch", "
|
| 87 |
async def test_real_requests_reports_and_session_envelopes_validate_against_openapi(client, kind):
|
| 88 |
spec = (await client.get("/openapi.json")).json()
|
| 89 |
owner = await make_account()
|
| 90 |
sid = await make_session(owner["id"], mode="h" if kind == "hitting" else "p")
|
| 91 |
-
payload = copy.deepcopy(PAYLOAD if kind == "hitting" else
|
| 92 |
-
else current_pitch_payload(sid))
|
| 93 |
path = "/v1/sessions/{session_id}/" + ("swing-report" if kind == "hitting" else "pitch-report")
|
| 94 |
operation = spec["paths"][path]["post"]
|
| 95 |
assert_valid(spec, operation["requestBody"]["content"]["application/json"]["schema"], payload)
|
|
|
|
| 1 |
+
"""Generated clients must accept the pitch-1.1 contract without changing hitting schemas."""
|
| 2 |
|
| 3 |
import copy
|
| 4 |
import json
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
import pytest
|
|
|
|
| 8 |
from ai_coach.pitch_report.v1_1.schemas import PitchReport
|
| 9 |
from ai_coach.swing_report.schemas import SwingAnalysisPayload, SwingReport
|
| 10 |
from fastapi.openapi.utils import get_openapi
|
|
|
|
| 14 |
from app.integrations.pitching_reports import report_for_read
|
| 15 |
from app.main import create_app
|
| 16 |
from tests.factories import make_account
|
|
|
|
| 17 |
from tests.integration.test_pitching_flow import payload as current_pitch_payload
|
| 18 |
from tests.integration.test_swing_reports import PAYLOAD, make_session
|
| 19 |
|
|
|
|
| 45 |
paths, schemas = spec["paths"], spec["components"]["schemas"]
|
| 46 |
pitch = paths["/v1/sessions/{session_id}/pitch-report"]["post"]
|
| 47 |
request = pitch["requestBody"]["content"]["application/json"]["schema"]
|
| 48 |
+
assert request == {"$ref": "#/components/schemas/PitchPayload"}
|
| 49 |
+
assert "PitchAnalysisPayload" not in schemas
|
| 50 |
assert schemas["SessionOut"]["properties"]["report"]["anyOf"] == [
|
| 51 |
{"$ref": "#/components/schemas/SwingReport"}, {"$ref": "#/components/schemas/PitchReport"}, {"type": "null"}]
|
| 52 |
assert paths["/v1/sessions"]["post"]["responses"]["201"]["content"]["application/json"]["schema"] == {
|
|
|
|
| 58 |
assert retry["responses"]["200"]["content"]["application/json"]["schema"] == {
|
| 59 |
"$ref": "#/components/schemas/PitchReport"}
|
| 60 |
assert schemas["PitchPayload"]["properties"]["schema_version"]["const"] == "pitch-1.1"
|
|
|
|
| 61 |
assert schemas["PitchPayload"]["properties"]["visual_evidence"]["type"] == "null"
|
| 62 |
assert schemas["PitchReport"]["properties"]["visual_evidence"]["type"] == "null"
|
| 63 |
|
|
|
|
| 66 |
app = create_app()
|
| 67 |
before = get_openapi(title=app.title, version=app.version, routes=app.routes)
|
| 68 |
_, contracts = models_json_schema([
|
| 69 |
+
(SwingAnalysisPayload, "validation"), (SwingReport, "serialization"),
|
| 70 |
], ref_template="#/components/schemas/{model}")
|
| 71 |
before["components"]["schemas"].update(contracts["$defs"])
|
| 72 |
after = app.openapi()
|
|
|
|
| 80 |
"$ref": "#/components/schemas/SwingReport"}
|
| 81 |
|
| 82 |
|
| 83 |
+
@pytest.mark.parametrize("kind", ["current_pitch", "hitting"])
|
| 84 |
async def test_real_requests_reports_and_session_envelopes_validate_against_openapi(client, kind):
|
| 85 |
spec = (await client.get("/openapi.json")).json()
|
| 86 |
owner = await make_account()
|
| 87 |
sid = await make_session(owner["id"], mode="h" if kind == "hitting" else "p")
|
| 88 |
+
payload = copy.deepcopy(PAYLOAD if kind == "hitting" else current_pitch_payload(sid))
|
|
|
|
| 89 |
path = "/v1/sessions/{session_id}/" + ("swing-report" if kind == "hitting" else "pitch-report")
|
| 90 |
operation = spec["paths"][path]["post"]
|
| 91 |
assert_valid(spec, operation["requestBody"]["content"]["application/json"]["schema"], payload)
|
docs/PITCHING_APP_INTEGRATION.md
CHANGED
|
@@ -4,7 +4,7 @@ The mobile app keeps its upload, polling and group-driven report screens. Hittin
|
|
| 4 |
|
| 5 |
The pipeline is **video → ML pose/measurements → structured JSON → AI coach**. No pitching video, sampled image, media URL, or visual-model observation is supplied to the coach. This guide matches the deployed engine 1.21.7 and backend pitching contract verified on 2026-11-02; validation evidence is recorded in `PITCHING_VALIDATION.md`.
|
| 6 |
|
| 7 |
-
The engine emits `pitch-1.1`
|
| 8 |
|
| 9 |
## Changes to an already integrated mobile app
|
| 10 |
|
|
@@ -31,7 +31,7 @@ There is no mobile Gemini call and no new AI-provider key for the app. The backe
|
|
| 31 |
|
| 32 |
The account token and engine credential are different. Keep engine secrets in the existing server/proxy credential handling, rather than embedding a shared engine key in the mobile binary. All engine status, result, schema and coach-payload requests require engine authentication. Resolve the engine's relative URLs against the **engine** base URL, not the app backend.
|
| 33 |
|
| 34 |
-
**SDK generation:** regenerate mobile API models from `https://baseball-engine.scalethemod.online/openapi.json` or the checked-in [backend OpenAPI snapshot](../backend/docs/openapi.json). The pitch-report request
|
| 35 |
|
| 36 |
The report envelope still has `schema_version: "1.0"`, with `discipline: "pitching"` and `meta.input_schema_version: "pitch-1.1"` for current pitching. Only the incoming ML payload has `schema_version: "pitch-1.1"`. Do not dispatch report parsing on `report.schema_version` alone: use the current report's `discipline` when present and the session's `mode` for legacy reports. Standalone contracts remain available in [pitching-coach-payload.schema.json](pitching-coach-payload.schema.json) and [pitch-report.schema.json](pitch-report.schema.json).
|
| 37 |
|
|
@@ -61,7 +61,7 @@ Choose the output path used by your app. The `--default-non-nullable false` opti
|
|
| 61 |
| `pitch_type` | `fastball`, `breaking_ball`, `changeup`, `other`, `unknown` |
|
| 62 |
| `ball_type` | `baseball`, `training_ball`, `none`, `unknown` |
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
## Backend: create the session
|
| 67 |
|
|
@@ -209,9 +209,9 @@ If generation is unavailable or rejected, `coaching.status: unavailable` include
|
|
| 209 |
|
| 210 |
Offer **Retry AI coaching** using `POST /v1/sessions/{session_id}/pitch-report/retry-coaching` with the account bearer token and no body. By default it retries unavailable coaching and rebuilds reports with obsolete visual evidence or a superseded coaching prompt; it returns a current generated report unchanged. Reposting the identical analysis also rebuilds an obsolete report without another analysis charge. Use `?refresh=true` to explicitly reinterpret an existing report with the current coaching implementation. Ownership and consent still apply. Neither operation reruns pose estimation or consumes another analysis. The saved engine payload stays unchanged; current quality checks can withhold unreliable older estimates or visual claims from the displayed report. Refresh uses only the saved ML evidence and discards all legacy visual observations.
|
| 211 |
|
| 212 |
-
Retry returns HTTP 200 with a **bare report**, which should replace the local displayed report. `refresh=true` can reuse accepted cached coaching (`meta.cache_hit: true`); it does not guarantee a new provider call. Retry requires a saved pitch-1.1 report: a missing report returns `409 REPORT_NOT_READY`,
|
| 213 |
|
| 214 |
-
Reading an obsolete pitch-1.1 report returns `coaching.status: "unavailable"` and `coaching.reason: "coaching_refresh_required"`. Superseded advice, visual observations and grades are hidden in session details and summaries, including coach views. Display a refresh action while retaining access to the saved measurements as provisional estimates. Reads do not call the coach, rewrite the stored analysis or consume quota; only the explicit retry/report routes regenerate feedback. Current pitching
|
| 215 |
|
| 216 |
`drill_evaluation` provides source-backed objectives and observed/indeterminate findings for step-back, rocker and standard deliveries. Its `validation_status` is `provisional_qualitative`; its score is null. These are not validated drill scores. Other or unknown drills do not acquire made-up criteria. Do not convert missing scores to zero or assign a percentage based on checklist coverage.
|
| 217 |
|
|
|
|
| 4 |
|
| 5 |
The pipeline is **video → ML pose/measurements → structured JSON → AI coach**. No pitching video, sampled image, media URL, or visual-model observation is supplied to the coach. This guide matches the deployed engine 1.21.7 and backend pitching contract verified on 2026-11-02; validation evidence is recorded in `PITCHING_VALIDATION.md`.
|
| 6 |
|
| 7 |
+
The engine emits `pitch-1.1`, the only pitching contract the backend accepts. Forward each payload unchanged and render its returned groups.
|
| 8 |
|
| 9 |
## Changes to an already integrated mobile app
|
| 10 |
|
|
|
|
| 31 |
|
| 32 |
The account token and engine credential are different. Keep engine secrets in the existing server/proxy credential handling, rather than embedding a shared engine key in the mobile binary. All engine status, result, schema and coach-payload requests require engine authentication. Resolve the engine's relative URLs against the **engine** base URL, not the app backend.
|
| 33 |
|
| 34 |
+
**SDK generation:** regenerate mobile API models from `https://baseball-engine.scalethemod.online/openapi.json` or the checked-in [backend OpenAPI snapshot](../backend/docs/openapi.json). The pitch-report request takes `pitch-1.1`; saved session reports support the existing hitting/legacy report, the current pitching report, or null. The pitching report and retry responses include the current pitching groups and nullable fields. Do not send the ML payload through an older hitting-only serializer that drops pitching fields.
|
| 35 |
|
| 36 |
The report envelope still has `schema_version: "1.0"`, with `discipline: "pitching"` and `meta.input_schema_version: "pitch-1.1"` for current pitching. Only the incoming ML payload has `schema_version: "pitch-1.1"`. Do not dispatch report parsing on `report.schema_version` alone: use the current report's `discipline` when present and the session's `mode` for legacy reports. Standalone contracts remain available in [pitching-coach-payload.schema.json](pitching-coach-payload.schema.json) and [pitch-report.schema.json](pitch-report.schema.json).
|
| 37 |
|
|
|
|
| 61 |
| `pitch_type` | `fastball`, `breaking_ball`, `changeup`, `other`, `unknown` |
|
| 62 |
| `ball_type` | `baseball`, `training_ball`, `none`, `unknown` |
|
| 63 |
|
| 64 |
+
Unknown values are allowed, but send the real values when the player picks them. Scoring: regular fastballs with a baseball (any practice type, `standard` drill) are compared with OBP college pitchers of the same throwing side. Unknown practice, drill, pitch or ball is compared as a regular fastball, but leg lift and stride results are not used for advice. `step_back` and `rocker` are compared except for the leg lift and stride results. `other` drills, `dry_delivery`, non-fastball pitches and training or no ball are described without scores. Every level is compared with college pitchers, with a note. Population percentiles are not ideal-technique targets.
|
| 65 |
|
| 66 |
## Backend: create the session
|
| 67 |
|
|
|
|
| 209 |
|
| 210 |
Offer **Retry AI coaching** using `POST /v1/sessions/{session_id}/pitch-report/retry-coaching` with the account bearer token and no body. By default it retries unavailable coaching and rebuilds reports with obsolete visual evidence or a superseded coaching prompt; it returns a current generated report unchanged. Reposting the identical analysis also rebuilds an obsolete report without another analysis charge. Use `?refresh=true` to explicitly reinterpret an existing report with the current coaching implementation. Ownership and consent still apply. Neither operation reruns pose estimation or consumes another analysis. The saved engine payload stays unchanged; current quality checks can withhold unreliable older estimates or visual claims from the displayed report. Refresh uses only the saved ML evidence and discards all legacy visual observations.
|
| 211 |
|
| 212 |
+
Retry returns HTTP 200 with a **bare report**, which should replace the local displayed report. `refresh=true` can reuse accepted cached coaching (`meta.cache_hit: true`); it does not guarantee a new provider call. Retry requires a saved pitch-1.1 report: a missing report returns `409 REPORT_NOT_READY`,.
|
| 213 |
|
| 214 |
+
Reading an obsolete pitch-1.1 report returns `coaching.status: "unavailable"` and `coaching.reason: "coaching_refresh_required"`. Superseded advice, visual observations and grades are hidden in session details and summaries, including coach views. Display a refresh action while retaining access to the saved measurements as provisional estimates. Reads do not call the coach, rewrite the stored analysis or consume quota; only the explicit retry/report routes regenerate feedback. Current pitching and hitting reports retain their existing read behavior.
|
| 215 |
|
| 216 |
`drill_evaluation` provides source-backed objectives and observed/indeterminate findings for step-back, rocker and standard deliveries. Its `validation_status` is `provisional_qualitative`; its score is null. These are not validated drill scores. Other or unknown drills do not acquire made-up criteria. Do not convert missing scores to zero or assign a percentage based on checklist coverage.
|
| 217 |
|
tests/test_pitching_api.py
CHANGED
|
@@ -122,13 +122,13 @@ def test_rocker_without_leg_lift_does_not_invent_a_phase_or_grade():
|
|
| 122 |
assert p["events"]["leg_lift"]["reasons"] == ["event_not_applicable"]
|
| 123 |
report = build_report(p, AthleteContext(level="college"))
|
| 124 |
PitchReport.model_validate(report)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
assert len(report["measurements"]) == 10
|
| 129 |
assert any(m["value"] is not None for m in report["measurements"])
|
| 130 |
-
assert all(m["coach_tip"] is None for m in report["measurements"])
|
| 131 |
-
assert report["focus_area"]["
|
| 132 |
|
| 133 |
|
| 134 |
def test_unknown_camera_keeps_intrinsic_angles_unknown_clock_blocks_times():
|
|
|
|
| 122 |
assert p["events"]["leg_lift"]["reasons"] == ["event_not_applicable"]
|
| 123 |
report = build_report(p, AthleteContext(level="college"))
|
| 124 |
PitchReport.model_validate(report)
|
| 125 |
+
# No leg lift: the gather phase is never graded; the rest of the rocker delivery is compared.
|
| 126 |
+
gather = next(g for g in report["groups"] if g["group"] == "gather")
|
| 127 |
+
assert gather["score"] is None
|
| 128 |
assert len(report["measurements"]) == 10
|
| 129 |
assert any(m["value"] is not None for m in report["measurements"])
|
| 130 |
+
assert all(m["coach_tip"] is None for m in report["measurements"] if m["group"] == "gather")
|
| 131 |
+
assert report["focus_area"]["drill"] is not None
|
| 132 |
|
| 133 |
|
| 134 |
def test_unknown_camera_keeps_intrinsic_angles_unknown_clock_blocks_times():
|