# Browser-local attempt coaching method

## Product question

For one athlete-confirmed movement interval and one practical goal, the report answers: **what the clip supports, what most directly limits the selected goal, and what one change to try next**. Goals only change prioritization; they never change the retained pose evidence.

## Attempt model

1. **Sampling and eligibility.** A sample is retained only when complete-pose confidence is at least `0.55`. Every derived measurement separately requires each contributing landmark at the same threshold. Visibility is the required confidence component exposed by the browser Pose Landmarker; when the runtime also emits presence, confidence is tightened to `min(visibility, presence)`. Missing visibility is unqualified (`0`). Missing presence remains `null` in raw provenance and never permits presence-only evidence.
2. **Review navigation, not repetition counting.** Candidate intervals require both confidence-gated wrists above both shoulders, increasing aspect-correct hip height, meaningful rise, and no sampling gap above `0.5 s`. The highest-scoring interval is only a deterministic suggestion. It is not a repetition detector or automatic success classifier. The athlete must review and explicitly confirm the corrected Setup-to-Peak evidence identity—not merely the detector peak—before the next-attempt action becomes active or the summary can be saved.
3. **Observed movement geometry.** In aspect-correct image coordinates, the shoulder midpoint is `S = (P11 + P12) / 2`, hip midpoint is `H = (P23 + P24) / 2`, and attempt torso reference is the median `|S - H|` across eligible samples. The hip midpoint is a pose proxy, not centre of mass.
4. **Moments.** Setup is the first qualified corrected hip-path sample in the selected interval; Peak is the highest corrected hip position; Pull reference is the largest corrected inter-sample rise rate; Exit is the detector interval end. These exact video times are review landmarks, not claims of biomechanical phase boundaries or completion.
5. **Evidence hierarchy.** The primary report uses camera-plane hip rise in torso lengths, setup-to-peak duration, mean rise rate, side-to-side hip path, projected left/right elbow-angle difference, confidence/coverage, and—when separately qualified—bar-relative shoulder clearance and projected knee angle. Derivative peaks, gravity, depth, raw traces and alternative intervals remain evidence-only drill-downs.
6. **One action.** A selected goal chooses exactly one bounded instruction with an explicit retained source-frame time. Missing or limited global evidence, or goal-specific missing bilateral elbow/knee evidence, produces a capture-quality action instead of athlete coaching. No force, power, torque, injury-risk, universal good/bad score, or population threshold is inferred.

## Calibration and stabilization roles

- **Human height** adds approximate physical units using the median visible body-chain length. Clearing or entering a value outside `100–250 cm` removes metric claims immediately.
- **Horizontal bar endpoints** correct static camera roll and optionally provide a bar-relative shoulder reference. The bar evidence is available only when the marked segment spans the shoulder midpoint at the retained peak, the sampled frame dimensions and reference time are finite, both shoulders qualify, and torso scale is available.
- **Background stabilization** estimates accepted global image translation while excluding a padded person region. It separates gross athlete translation from camera translation. It does **not** solve camera rotation, zoom, rolling shutter, perspective, parallax, or person-mask leakage. Raw tracking pixels are cleared and never exported.
- **Two world-parallel lines** expose one vanishing-point diagnostic only. They do not recover focal length, full camera pose, or metric scale.
- **Relative dense depth** is ordinal for one paused frame. It is not metric and does not gate the attempt report.

Changing height, bar geometry, stabilization use, or goal recomputes results from the same retained samples; it does not silently rerun or alter pose inference.

## Primary evidence formulas and limits

- **Rise:** `(peak hip vertical - setup hip vertical) / torso reference`, after accepted translation stabilization and bar-roll correction.
- **Pull duration:** `peak time - setup time`.
- **Mean rise rate:** torso-normalized rise divided by pull duration. This is preferred over a noisy instantaneous derivative as primary evidence.
- **Lateral path:** `(max corrected hip x - min corrected hip x) / torso reference` from Setup through Peak. A single camera cannot distinguish every body-plane trajectory.
- **Projected elbow asymmetry:** median confidence-gated absolute difference between left angle `(11,13,15)` and right angle `(12,14,16)` inside the interval. It is a 2D sequencing cue, not a joint-torque or anatomical-plane measurement.
- **Projected knee strategy:** minimum confidence-gated bilateral mean of left angle `(23,25,27)` and right angle `(24,26,28)` from Setup through Peak, requiring both sides in at least three samples. Qualified evidence from only one side is explicitly labelled and is not used for strictness coaching. The bilateral cue can show visible flexion strategy; it cannot certify a universally “strict” muscle-up from one view.
- **Bar-relative shoulder clearance:** at the retained peak, the roll-corrected shoulder-midpoint height above the marked bar at the same image x, divided by torso reference. It does not classify turnover, support, press, or lockout.

All normalized results are **observed camera-plane geometry**. Foreshortening, depth change, viewpoint, clothing, blur, occlusion, pose error, and bar/reference mismatch can create larger bias than the displayed precision.

## Metric scale, derivatives and gravity

Height scale is an approximate pose-scaled camera-plane estimate near the sampled reference depth, with unit `m/img-h`; it is not metric 3D or guaranteed world-vertical movement. The displayed percentage is a heuristic sensitivity allowance (minimum 12%, increased when visible body-chain length varies), not a confidence interval or calibrated measurement uncertainty.

A three-sample median limits one-frame spikes. Centered local least-squares slopes produce evidence-only velocity and acceleration. Derivatives are suppressed at segment ends, repeated timestamps, and gaps over `0.5 s`. For the attempt report, corrected positions are filtered to the user-confirmed Setup-to-Peak interval before smoothing and derivatives are recomputed inside that interval; samples outside it cannot affect reported metric rise or peak velocity. Clip-wide series remain navigation evidence only.

The optional gravity diagnostic requires user-marked unsupported flight, a finite roll-confirming bar angle, at least six confidence/stabilization-eligible samples, at least `0.25 s` of actual eligible coverage, no eligible gap over `0.12 s`, and the identical eligible subset for gating and regression. It fits acceleration normal to the projected bar under a near-parallel-plane approximation. That axis is not independently calibrated gravity; contact, active tucking, swing, perspective change, or camera tilt invalidate it. Its scale-like value is experimental, reported separately, and never fused into the height-derived metric scale or used as a primary coaching signal.

## Comparison, export and privacy

Comparison requires the athlete’s own confirmed summaries under the same selected goal plus an explicit user assertion that athlete, camera placement, view, and exercise context are unchanged. The compatibility signature also checks image aspect, explicit absent/valid marked-bar status and geometry, torso normalization, and translation-only stabilization. A present but malformed bar calibration fails closed and cannot alias an absent bar. A mismatch withholds deltas; a match still carries the explicit limitation that browser code cannot independently verify athlete or camera identity. Browser-local history is capped at 20 summary-only records and excludes media, frames, landmarks, world landmarks, pose series, and source URLs. Every legacy and new entry is allowlist-compacted on read and again before persistence; entries that place nested objects or arrays in scalar summary fields are discarded rather than re-persisted.

Schema `5` export includes attempt-insight model `4`, the selected goal, suggested/selected interval identity, explicit user-confirmation state, evidence-to-scorecard/source-frame action links, capture repair when coaching evidence is insufficient, raw retained sample summaries, and calibration provenance. Browser camera capture prefers a natively recorded WebM container and falls back to MP4 only when WebM is unavailable; the resulting local blob must decode before it can replace the live camera source. Camera recordings use finite decoded container duration when available; if the container exposes a non-finite duration, analysis falls back to the bounded local monotonic start-to-stop clock and exports `durationMethod: "recording-monotonic-clock"`. Raw media and optical-flow pixel buffers are excluded. All inference and analysis occur in the browser; static runtime and model files are same-origin.
