baseball-engine / docs /PITCHING_VALIDATION.md
github-actions[bot]
Automated Deploy: cd4424ce2a68698c73b0041b0afa5d89d0c6a680
a8788e5
|
Raw History Blame Contribute Delete
27 kB
# Pitching validation and remaining evidence gaps
This work distinguishes implementation tests, inter-method comparisons, visual review, and biomechanical validation. Passing an API or unit test does not validate a neural pose estimate.
“Manual review” below means assistant inspection of the original frames alongside the returned evidence. It is separate from the engine's automated critique, but it is not an independent review by a pitching coach or biomechanics laboratory.
## Current deployed correction: ML-only coaching (2026-11-02)
The requested architecture is video → pose ML → measurements/evidence JSON → AI coach, matching the hitting separation. The pitching visual-model stage is retired: export never calls it, its compatibility function never reads media or calls a provider, and older visual observations are discarded before report generation. Hitting behavior is unchanged. Earlier sections below document historical experiments and failures, including the now-removed image-review approach; they do not describe the corrected architecture.
Four groups organize ten event measurements: gather, stride/plant, rotation/release, and release/finish. Six pose-derived curves and event-bounded phase summaries add motion context. These groups are a product organization of measurable checkpoints, not a claim to cover every biomechanical pitching phase. Shoulder axial rotation, force, ball speed and injury prediction remain outside this measurement contract.
Current measurements have unvalidated model accuracy. Population reference quantiles remain descriptive comparisons, never ideal-technique targets or validated performance scores. Scores are withheld. Coaching cannot promote an unavailable measurement into a movement claim, and phase direction is withheld if neighboring event frames can reverse it. Original capture timing is unknown for both supplied exports, so physical timing and speed claims remain unavailable.
The original files match the retained SAM3D results (80 step-back frames; 88 rocker frames). Integrity-checked replay is possible from `motion.jsonl`; it is not a fresh GPU inference run and does not establish physical accuracy. New audit evidence is retained separately under `artifacts/pitching-validation-2026-11-02/ml-only-audit`.
Local checks cover 706 engine tests (two skipped), 768 coach tests (one skipped; twelve live tests excluded), and 84 backend regression tests including hitting/session behavior, stored-report provenance and coach views. The final coach changes also passed all 32 targeted engine pitching tests and source CI. 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.
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.
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.
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. Coaching-only refresh under source `08eecdabd85d69c2641e9d7d7685e50a72849863` preserved measurements, motion, IDs, analysis timestamps and quota, with matching saved reports and refresh audits. The step-back passed scoped evidence review. The rocker's original timing wording was corrected, but its new summary introduced unsupported “forward” torso tilt from an unsigned inclination metric, and its contact check asked for a completely grounded foot instead of first visible touch. These failures are preserved separately; automated critique alone did not catch them.
The 1.21.7 follow-up supplies explicit metric-reference and event definitions and rejects these mismatches across all returned prose. Source `0a12cc2b74651190f56408d4885da0f57257bac3` passed [source CI](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41405879352), [ML deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41405879450) and [backend deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41405879328). Hugging Face revision `659d1d9657142033d2eac4ecb550153ea04b482e` is linked to that source in deployment logs. Its running revision, API version **1.21.7**, readiness and ML-only capabilities were checked. The ML implementation is byte-identical to the fresh 1.21.5 runs; only coaching and the advertised API version changed afterward.
Both stored reports were refreshed through the deployed backend using real Gemini generation under prompt `pitch-coach-ml-3-b39515cefb5e`. Original payloads, ML measurements, motion evidence, analysis IDs/revisions, analysis timestamps and quota remained unchanged. The saved reports matched the refresh responses and request-specific API audits. A separate assistant review checked the exact retained summary, every card field and cited evidence against each ML payload: no concrete unsupported claim was found in either final report. Step-back remains an explicitly partial result (`some_coaching_cards_withheld`); rocker returned four cards. The earlier failures are retained in `initial/` and `refresh-1.21.6/`, with final report hashes and scoped acceptance in each `manual-review.json` under `artifacts/pitching-validation-2026-11-02/release-1.21.5-ml-only/`.
The final backend review found a separate stored-report gap: ordinary session reads could still expose older visual coaching, and retry without `refresh=true` could keep a superseded ML-only prompt. The backend now projects obsolete pitch-1.1 reports as `coaching_refresh_required`, hiding derived advice, visual observations and scores in detail, list, previous-score and coach views. Raw measurements remain available as estimates. Explicit report/retry writes rebuild stale prompts from the unchanged saved payload. Integration tests verify no provider call, DB mutation or quota use on reads, and identical behavior for current pitching, hitting and legacy pitch-1.0. This requires a narrow pitching-only guard in the shared session-summary projection; no shared schema, model or migration changed. Deployment verification for this backend-only safeguard is recorded separately from the ML/coach release.
These are accepted provisional interpretations of ML estimates, not certified pitching measurements or a general coaching-accuracy guarantee. The two videos do not provide independent 3D ground truth. Unknown capture timing, unsupported movement directions, unreliable angles and numeric performance grades remain withheld. A green deployment is not a content-accuracy result.
## Historical validation record
## Audit findings and changes
The previous pitch-1.1 path used deterministic generic coaching, ten event measurements, no full-motion interpretation, and no paired-video 3D comparison. Low-confidence event geometry could still be displayed as an ordinary estimate. Original capture timing was correctly unknown for the supplied exports, but the report did not explain its clock in detail.
The updated path adds conservative measurement abstention, six full-delivery curves, phase summaries, rotation peak sensitivity, explicit clock provenance, provisional drill criteria, sampled-frame visual observations, and personalized Gemini interpretation with cited evidence and a second automated critique. Missing configuration, failed generation or failed checks are surfaced explicitly. No numerical confidence scores or drill-normal ranges are invented. Legacy hitting and pitch-1.0 behavior is preserved.
## Status against the requested requirements
| Requirement | Implemented and exercised | Remaining validation or scope limit |
|---|---|---|
| Measurement accuracy | Equivalent-angle replay, interpolation/event-sensitivity checks, explicit withholding, and a paired-video comparison tool | No representative independent 3D ground truth; stable estimates may still be wrong |
| Drill scoring | Source-backed step-back/rocker objectives and provisional qualitative findings; unsupported drills remain ungraded | No validated numeric drill scores or outcome-based weights; no arbitrary ranges substituted |
| Video timing | Original PTS, uniform slowdown and explicit per-frame capture maps; contradictory inputs rejected | Original timing cannot be recovered for the two supplied exports; their physical durations/speeds remain unavailable |
| Personalized AI coaching | Actual sampled images plus measured trajectories, generated cards, evidence citations, critique, repair and explicit failure | Provisional interpretation; no independent expert-reviewed coaching accuracy rate |
| Full-motion analysis | Whole-clip trajectories, four event-defined phases, six angle/heading curves, phase coverage and rotation-order sensitivity | No validated shoulder axial rotation, joint moments, energy transfer or repeated-pitch consistency from a single pitch |
| Pipeline validation | Real original-video runs, saved-payload replay, storage/audit/idempotence checks, regression tests and paired-reference comparison | Two drills and one reference trial do not establish general reliability across pitchers and capture conditions |
The implementation therefore supports a substantially richer pitching review, but the overall accuracy requirement remains open. “Not rated” is intentional where scoring has not been validated; it is never a zero or an inferred failure by the athlete.
## What the tests establish
Synthetic tests verify formulas, invariance, missing-data propagation, clock conversion, variable-frame-rate handling, explicit speed-ramp maps, event sensitivity, phase coverage, resolved/unresolved rotation peaks, schema compatibility, coaching citations, unsupported-claim rejection, caching, and provider failure behavior. Backend tests cover storage, ownership, revisions, retry behavior, existing hitting and legacy pitching reports. These are implementation checks.
The real-video evaluation uses SAM3D. GVHMR runtime checks are compatibility checks, not validation of its pitching measurements. Existing normal-delivery reference grades are tentative comparisons to a sampled population, not outcome-validated measures of pitching quality; they have not been validated by these drill tests.
The two supplied left-handed drills are re-evaluated from the saved model artifacts and original video. Event-dependent knee/elbow estimates that fail adjacent-frame or interpolation checks are withheld. Their capture speed remains unknown; no inferred physical timing is supplied. The clips do not provide independent 3D ground truth or repeated-pitch consistency.
## Paired-video comparison protocol
The public OpenBiomechanics CV trial `OBP_movement_BaseballThrow_001`, camera 19, provides 360 Hz video and paired Theia segment transforms. For an economical single-pitch test, source frames 480..1197 are sampled every third frame, with the exact original-index map retained. The resulting 120 Hz capture clock follows the documented rig recording, not an FPS guess. Source hashes, event marks, model artifacts and comparisons are retained under `artifacts/pitching-validation-2026-11-02/reference`.
`tools/validate_pitching_reference.py` compares equivalent joint-centre knee, elbow, torso and separation definitions over the delivered frames; reports bias, MAE, RMSE and upper-tail discrepancies; and measures root-relative joint differences without fitting an alignment to the model predictions. It tests source-to-C3D offsets zero and one. The published trial-specific camera rotation is used only for position comparison; intrinsic joint-angle comparisons require no rotation alignment.
Theia is another markerless estimator, not marker-based ground truth. Its upstream camera provenance and physical synchronization uncertainty are not independently established here. Published calibration is provisional and joint definitions can differ. This experiment can expose disagreement; it cannot certify absolute accuracy, infer an accuracy confidence score, or validate performance across athletes and camera views.
## Drill evaluation basis
The qualitative rubric uses published Driveline drill objectives: step-back loading/transition, rocker movement into the throw, and reviewing the front-leg action. Estimated knee straightening is not a measured block or ground force. Source descriptions guide what to review; they do not supply normal angle distributions or outcome-validated scoring weights. Numeric drill scores remain unavailable until appropriate validation data exists.
Sources: [Driveline throwing program](https://www.drivelinebaseball.com/wp-content/uploads/2024/03/Free_16-Week_In-Season_And_Off-Season_Throwing_Program_2024-03-05.pdf), [Driveline rocker guidance](https://www.drivelinebaseball.com/wp-content/uploads/2018/07/8WeekOn-Ramp.pdf), [OpenBiomechanics](https://github.com/drivelineresearch/openbiomechanics). Normal-fastball reference distributions remain distinct from drill evaluation and retain their existing attribution/license.
## Limits that software changes cannot establish by themselves
- No representative paired marker-based pitching video dataset has been validated for this deployed model, across both hands, age groups, camera views, ball types and drills.
- A single view may leave depth, shoulder rotation and release-arm position ambiguous. A stable prediction can still be wrong; passing abstention checks is not validation.
- No outcome-validated scoring model exists for step-back, rocker or unspecified drills. Provisional observations are not validated scores.
- Exported slow-motion video may permanently lose its original clock. The system must abstain when provenance cannot be recovered.
- A single delivery does not establish repeatability. Joint loading, injury risk, force, ball speed and spin are not measured.
- The whole recording is tracked, but this is not a complete laboratory biomechanics model. Shoulder internal/external rotation, forearm pronation, joint moments and energy transfer are not established by these joint-centre curves. The named phases use reviewed events; they do not establish an independently validated maximum-external-rotation event.
- Automated AI critique is fallible. Coaching usefulness and correctness still require a larger, expert-reviewed evaluation set; no blanket accuracy claim is justified.
The original requirement is not considered scientifically validated merely because these implementation paths exist. Live-test findings and release status are recorded separately in the validation artifacts and appended below after testing.
Additional reference search found [SportsPose](https://christianingwersen.github.io/SportsPose/download.html), which includes pitching and has a published marker-based comparison, but dataset access is by an academic request. It was not obtained or tested here. Published accuracy for another dataset or product is not attributed to this engine. General fitness marker/video datasets also do not establish accuracy for high-speed pitching.
## Initial paired-trial findings
Across 240 sampled frames, the initial SAM3D/Theia comparison showed approximately 2.6° torso, 6.4° front-knee, 7.5° elbow and 7.6° separation mean absolute disagreement (offset +1); ankle spacing differed by 6.5 cm on average. These are discrepancies between estimators, not certified measurement error. Upper-tail disagreement was larger, including about 26° for separation. No model correction was fitted to this trial.
Original-frame review rejected the contributor release label at source frame 950: the ball was still in hand. The revised approximate release is source frame 978 (visible separation bracket 975–980), corresponding to test-clip frame 166. This demonstrates why event annotations must also be checked. The initial run and label are retained separately; revised event comparisons follow.
At the visually revised release, inter-method differences were approximately 4.6° front knee, 6.5° elbow, 2.9° torso and 25.4° hip–shoulder separation. The release separation is a trajectory diagnostic, not one of the ten scalar report scores. The marked foot-strike separation differed by about 3.0°. These findings show that average agreement can conceal larger disagreement at a specific moment.
## Live failures found and corrected during evaluation
Real coaching generation initially produced unsupported direction and rotation advice. Automated critique rejected some claims but accepted another draft that manual review rejected. The rejected output is preserved as `coach-replay-smoke/step-back-1/report-revision-3-manually-rejected.json`. The prompt and deterministic rejection checks were tightened, and the subsequent measurement-only smoke test passed provisional content review. This does not establish a quantified coaching accuracy rate.
The first complete original-video runs (`e9687e5cccdf4b53aca5a585ee3e8b34` and `5c89281e0cc543b6b9f262f950795d77`) reproduced their scalar measurements from their saved trajectories, but their separate visual reviews were rejected. They are preserved under each clip's `initial-visual-review-rejected` directory and were not treated as successful video-coaching tests. Review of the exact subject boxes and frame samples did not show a wrong tracked subject. The old all-or-nothing critique did not retain the rejected topic details, so its specific objection cannot be reconstructed.
Visual critique now checks each topic independently, records specific objections, and gives the model a bounded repair attempt. A claim still rejected is explicitly withheld as unclear. Separately accepted observations can remain. A provider failure never becomes invented visual evidence. The model is still fallible, and these outputs still require comparison with the actual frames.
Saved reports whose coaching failed can now use `POST /v1/sessions/{session_id}/pitch-report/retry-coaching`. An authenticated live check confirmed that an already generated report is unchanged and consumes no additional quota. Integration tests also cover regeneration from saved evidence, ownership, consent and error paths. Older saved payloads with explicit unstable angle estimates are filtered before generating new advice, while the saved input remains unchanged.
Manual review of version 1.21.1 then found a further false visual claim: it called the trailing leg right in the left-handed step-back delivery. The rocker review inferred weight transfer from images, and a coaching card included unsupported smooth/natural/unrushed cues. Automated critique had accepted these claims. These runs are preserved under `manual-review-rejected-v1.21.1` and were rejected for content acceptance. Visual prose now uses body roles, with deterministic checks against ambiguous side labels, unmeasured physical claims and technique judgments. The coaching check rejects those unsupported motion-quality cues. The same visual safeguards apply when older saved evidence is interpreted by the backend. These checks address observed failure classes; they do not prove all future AI claims correct.
Version 1.21.2 completed both original-video pipelines, exact payload forwarding, stored-report checks and audit checks (public source URLs are redacted by the audit logger). Review found residual visual acceleration/deceleration language despite unknown capture timing, and an unclear plant topic whose description still made a categorical assertion. These are now withheld; an unclear topic cannot carry an affirmative movement claim. Coaching also rejects unmeasured load/momentum language. The final guard was replayed on these real saved outputs with unchanged measurement values. Explicit `?refresh=true` on the coaching retry route regenerates interpretation from saved evidence under current checks without changing the original payload or consuming quota; this was also verified live. Final fresh-clip acceptance runs follow below.
## Initial release and regression checks
Implementation commit: `9ad721b942f2bd63a78de04814c4d8cfa7b03b11`; engine API version: `1.21.3`.
- Engine suite: **710 passed, 2 skipped**.
- Coach non-live suite: **686 passed, 1 skipped, 12 live tests deselected**. Real provider behavior was tested separately in the recorded live runs.
- Backend pitching/hitting/session integration regression: **54 passed** against an isolated test database.
- Changed-file Ruff checks and `git diff --check` passed.
- [Source CI](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41362214717), [ML deployment and runtime checks](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41362214696), and [backend deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41362214764) all succeeded for this implementation commit.
The backend regression included `test_pitching_flow.py`, `test_pitch_reports.py`, `test_swing_reports.py` and `test_sessions.py`. No normal-delivery grade or numerical drill score is certified by these passing tests.
## Further content failures in the fresh 1.21.3 runs
The step-back job `b961257158c948a39256c551aa0fa9e1` and rocker job `d56cbdbb786a45d2bcf2d2b97d795143` passed source hashes, scalar replay, immutable forwarding, storage, idempotence and audit checks. Content review still rejected them:
- The first step-back coaching request was explicitly unavailable after evidence rejection. A coaching-only retry generated text, but falsely stated that playback speed differs from recording speed. The actual relationship is unknown. It also prescribed a steady knee lift without supporting evidence.
- The rocker visual reviewer claimed the lead foot stayed on the ground. Inspection of original frames 49 and 53 shows it lifted. The automated visual critique had accepted the false observation.
These results are retained under `final-live`, including `manual-review-before-fix.json` and the first unavailable result. They are not clean first-pass successes. Commit `fcb29d440b3ada848b116394e1125e3309c468e4` adds the recording-clock distinction to generation, critique and deterministic checks; rejects unsupported steady-lift cues; and rejects continuous-contact claims from sparse samples. Visual review now receives the reviewed lift and foot-strike marks and retains up to 1280 pixels of image detail instead of 768. Marks remain approximate checks, not substitutes for visible evidence. The same contact safeguard also protects refreshed older reports.
Replaying the saved real failures through these guards rejects them. This is a regression check, not a new model evaluation. The subsequent live results are recorded below. Final local regressions for this change: engine **711 passed, 2 skipped** (710 passed in the suite, with the sandbox-blocked loopback test then passing separately), coach **692 passed, 1 skipped, 12 deselected**, and backend **54 passed**.
Refreshing both stored reports under that change produced a supported step-back interpretation, but the rocker report was withheld. Its automated critic incorrectly treated advice to preserve future recordings without undocumented speed changes as an assertion that the current clip had been retimed. This is a false rejection, not evidence that the video was retimed.
The follow-up coaching change reviews the summary and each card independently. A rejected card cannot erase a separately accepted card, and an accepted card cannot rescue an unsupported summary. Deterministic checks cannot be overridden by the model; every card must receive exactly one critique. After bounded repair, a supported subset can be returned as `some_coaching_cards_withheld`. No replacement prose is invented. The accepted subset and its limitation survive caching. Tests exercise false model acceptance, rejected summaries, incomplete/duplicate critiques, omitted cards and cache behavior. The critic also distinguishes future recording instructions from claims about the current file. The updated coach suite has **698 passed, 1 skipped, 12 deselected**; the backend regression remains **54 passed**.
## Historical 1.21.4 deployed implementation
Source commit: `42c1af3e1d2677ea1e2bd56a3d4d63838996e2c3`; engine version: **1.21.4**; coaching prompt: `pitch-coach-2-dd16135a6d1d`.
[Source CI](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41364924807), [ML deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41364924882) and [backend deployment](https://github.com/MOD-Ventures-Org/baseball-engine/actions/runs/41364924809) succeeded. The deployed engine version and readiness endpoint were checked before submitting the final original-video runs. Final implementation checks cover **711 engine**, **698 coach** and **54 backend** tests; skipped/deselected tests are detailed above.
Live refresh of both earlier stored reports under this implementation generated personalized Gemini coaching, preserved the saved measurements, matched the stored reports and consumed no additional quota. Manual inspection accepted those refreshes only as provisional coaching. The older rocker's false continuous-contact observation is explicitly withheld. These refresh results are retained separately from the fresh ML runs under `final-live/*/report-42c1af3-refresh.json`.