Spaces:
Running on T4
Running on T4
|
Download backend/docs/reference/coaching_workflow_decisions.md from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 4.99 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/docs/reference/coaching_workflow_decisions.md
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/docs/reference/coaching_workflow_decisions.md
-
curl -L -o coaching_workflow_decisions.md https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/docs/reference/coaching_workflow_decisions.md
4.99 kB
Coaching workflow: implementation decisions (lead, 2026-10-30)
The contract source is coaching_workflow_spec.md (sections 4, 5 and 6). Where it leaves a question open (Q01-Q15),
we use the decisions below. Reread them before writing code.
Already built (lead-owned, do not edit; report needed changes instead)
- Tables: every new model is in
app/modules/{settings,notifications,threads,goals,assignments,arm_care,academy}/models.py, and one migrationmigrations/versions/20261030_9c1e5a7b3d20_coaching_workflow_and_academy.pycreates them all. Existing tables changed:uploads.kindalso allowsaudioanddrill_video,drill_logs.drill_idis now 40 chars with a newassignment_id, andreviewshas newvoice_upload_idandvoice_secondscolumns. app/common/academy_access.py:CurrentStaffandCurrentAdmindependencies,Staff(team_id, role, sees_all, permissions,require(perm)),visible_players_query/visible_player_ids/can_see_player/require_player,sessions_shared(player_id),coaches_of_player(player),normalize_permissions(role, requested).app/common/notify.py:notify(db, push, recipient_id, kind=, title=, body=, target=, event_key=). It inserts the notification once per (recipient, event_key) and sends the push only if the recipient's preference allows it.app/common/schemas.py:MediaRef(upload_id, url, expires_at, seconds?).ReviewOut.voice_note: MediaRef | None.app/core/config.py:require_analysis_consent(default False) andconsent_versions(default ["1.0"]).- Routers are already registered in
app/main.py. Each new module has a placeholdercontroller.pythat exposesrouter. Replace that file but keep theroutername.
Tenancy and identity (Q01/Q02)
- An academy is an existing team. The owner (
teams.coach_id) is the implicit admin with every permission and has no membership row. Other staff have anacademy_membershipsrow with roleadmin,coachorassistant. - Players belong to the team through
accounts.team_id, as before. - The coach id used in routes such as
/academy/coaches/{id}is the account (user) id. The owner appears in coach lists withrole:"admin". - An applicant can be a player or a coach account (dual role). Approval creates or reactivates the membership.
CurrentStaffaccepts any account with an active membership, and also any role=coach account (whose team_id may be None). The existingCurrentCoach(role=coach) is unchanged. Endpoints that need academy scope useCurrentStaff. - Only one academy context applies: the team the account owns, or else its newest active membership.
- Visibility: an admin or sees_all member sees every player on the team. Anyone else sees
coach_playersrows plus players in the groups they coach. A player who setscoach_can_see_sessions=falsehides their sessions, media and review access from coaches. Goals, assignments, notes and threads stay visible. - An inaccessible player, thread or other resource returns 404 (no existence leak). A missing capability returns 403.
Conventions
- Request-shape validation errors are 400
VALIDATIONwithfields, as in the rest of the repo. Where the spec names a domain code, raiseUnprocessable(code=...)(422) orConflict(code=...)(409). - Pagination uses
PagingplusPage[T]. The cursor encodes(created_at or updated_at, id)throughencode_cursor, ordered newest first with id as the tie-breaker. Idempotency-Keyusesrun_idempotenton the POSTs listed in spec 4.1.expected_version: when it is sent and does not match, return 409STALE_VERSION. Bumpversionon every change.- Dates: date-only fields are
YYYY-MM-DDand are the client's local day. Timezones (Q06) are not modelled yet. Labels such asdueare computed from the date. - Media always reaches the client as a presigned GET through
MediaRef, never as an object key. To attach an upload, check that it is owned by the caller, has the right kind, and thatstorage.head(key)finds the bytes (otherwise 409UPLOAD_NOT_READY). Then setuploads.attached_at. - Notifications use these kinds: review (review, coach message), drill (assignment, goal set), armcare, result, report. Use the targets from N06: {thread_id} | {session_id} | {month}.
- Never fabricate data. When a metric has no source, return null plus
unavailable_reason, or an empty list.
Domain gates (Q07/Q08/Q10)
- Goal outcomes: a replaced goal gets outcome
superseded. Nothing is evaluated automatically yet, sometstays null unless the outcome is met or not_met. Milestones are derived from met goals only, so the list is empty today. - Arm care:
rest_statusis alwaysunknownwithrule_version: nulland anunavailable_reason. No thresholds. - Earnings: there is no revenue ledger, so every money field is null with
unavailable_reason. Activity counts that come from real tables (players, sessions, reviews) are computed.