Anchor coaching Sessions to the Individual stableId (replace name/abbr matching)
Owner idea (2026-06-16)¶
Now that student info is merged into unified Individual profiles, stop linking coaching sessions by student abbreviation / name-match and instead point each session at the Individual by stable id.
Current state (mapped)¶
tebs-mel/Sessionsis ALREADY a single ROOT collection (not grouped under students) β so that half of the idea already holds. β- Sessions link to students by a NAME/STRING match:
Sessions.sessionName == Students.account(the frozenaccountfield), seen in lib/sessionStats.ts:20 (account = sessionDoc.sessionName) + SessionsTab/useBillingInfo. Some cache-invalidation paths also carrystudentAbbr(the Students doc-id), e.g. notifyCoachingChange / useCoachingSync. - The Students doc carries the Individual link already? NO β the Individual carries the student's frozen abbr as an ALIAS + (from P3) the student's personal info; the Session does not yet carry an individualId.
Assessment (my take β it's a GOOD direction, but a real project)¶
- PRO: a stable
individualIdanchor is far more robust than matching on a free-text name (account/sessionName), which is fragile to renames/typos and is exactly the kind of name-keying T-048 set out to fix (R4). - COST / RISK (why it's its own task, not a quick change):
- Calendar sync is the session creator and matches Google Calendar events to students BY NAME
(account == sessionName). Re-anchoring means the sync must resolve
individualIdat creation time (name -> student abbr -> individualId via the abbreviations lookup) and stamp it on the session. - Backfill every existing Session with its
individualId(resolve via account/abbr -> abbreviations lookup -> individualId), dual-key during cutover (keep sessionName/account working until all readers move). - All session readers (sessionStats, useBillingInfo, SessionsTab, invoice generation) move to
individualId. - Sessions DRIVE coaching invoices (financial) β migrate dry-run-first, detect-don't-correct, keep the frozen
accountmatch as a fallback until proven.
Recommendation¶
Do it as a deliberate, dry-run-first migration AFTER T-048 has settled, mirroring the T-048 playbook (snapshot -> propose-link artifact -> additive stamp -> dual-read -> flip -> retire name-match). Not urgent; the current name-match works. Logged so it isn't lost.
Log¶
- 2026-06-16 created from owner idea during T-048 archival. Confirmed Sessions are already a root collection; the change is the ANCHOR (name/abbr -> stable individualId) + the Calendar-sync resolution. See T-048.