Add per-session bay calibration as a read-time layer - #6
Merged
Conversation
Direction metrics are measured against the bay target line. When a bay is misaimed, face angle, club path, and launch direction all shift by the same constant while face-to-path stays put. Store that constant per session (calibration_offset_deg) and apply it only at read time: telemetry rows keep the exact TrackMan values. - PATCH /api/v1/sessions/:id sets or clears the offset (telemetry:write, paper_trail audited). It is the only mutable session field. - GET /api/v1/stats/clubs?calibrated=1 corrects face, path, and lateral spread in SQL. face_to_path is never corrected: the offset cancels. - Dashboard gains a Bay cal. toggle and a per-session offset editor. Shot-level correction is client-side math; only club aggregates refetch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A session recorded in a bay whose target line is misaimed reads every direction metric wrong by a constant: face angle, club path, and launch direction shift together while face-to-path stays put (it is a difference of two directions, so the offset cancels). The 2026-08-01 SIM bay session read 2.8 degrees left of the range bay baseline this way.
What
Stored telemetry stays exactly as TrackMan reported it. The correction is a calculation layer applied at read time, scoped per session.
training_sessions.calibration_offset_deg(float, nullable, -15..15). Degrees added to bay-reported direction metrics. Positive when the bay read left of true.PATCH /api/v1/sessions/:idsets or clears the offset. Requirestelemetry:write, audited via paper_trail, and it is the only mutable session field.GET /api/v1/stats/clubs?calibrated=1returns corrected aggregates, computed in SQL: face and path get the offset added, lateral carry spread rotates by it.face_to_pathis never corrected.Tests