Session 52: Athlete context #227
Labels
No labels
accessibility
area:accounts
area:ai-evals
area:look
area:maps
area:platform
area:rides-progress
area:riding
area:today-plan-coach
area:ui-shell
bot:blocked
bot:failed
bot:pr
bot:waiting
bot:working
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
later
now
owner-check
parked
question
ready
session
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/trainer#227
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
52 · Dated athlete context
Phase: Adaptive coaching 3/5 (owner request 2026-11-08) · Branch:
session/52-athlete-context· Depends on: 51What the athlete tells the coach is lost by the next re-plan, and the plan only knows the profile's weekly hours and days. A week working from home with more time can't add volume: the availability rule caps every week at the profile's hours plus 10%, and coach chat sends hours changes to Settings. This session stores the athlete's circumstances as dated entries the rules and the coach read, confirmed by the athlete, and lets good readiness loosen the plan as low readiness tightens it.
Read first
docs/requirements.md→ "Coaching dialogue and adaptability" (FR-21), FR-11, and "Individual response" in the foundations tabledocs/decisions.md: the 2026-11-08 adaptive coaching entrysrc/domain/rules/availability.ts,src/domain/rules/types.ts(RuleContext),src/domain/rules/config.ts(readiness),src/domain/rules/individual-response.tssrc/server/replan/input.ts,src/server/generation-input.ts,src/ai/prompts/replan.ts,src/ai/prompts/generate.ts,src/ai/prompts/chat.ts(line on profile fields),src/server/coach-store.tssrc/server/replan/triggers.ts(readinessTriggers),src/domain/replan/triggers.ts(LOW_READINESS_DAYS,isLowReadiness)RideChat,endRideChat, the held-trigger releasesrc/server/rescore-store.tsand the TSS override path on the ride pageclaude-apiskill before touchingsrc/ai/Goal
AthleteContext(schema + domain).id, userId, kind (hours | days | feeling | note), from, to (dates, inclusive), value (JSON by kind), text (the athlete's words), source (ride_chat | coach_chat | manual) and sourceId?, createdAt, deletedAt?. Value by kind, one Zod schema each: hours{ weeklyHours }(0.5–30, for whole plan weeks the range covers); days{ available: Weekday[] }or{ away: true }; feeling{ feeling: 'good' | 'run_down' }; note{}. Entries are facts: delete marksdeletedAt, edit writes a new row and deletes the old.RuleContextgains each plan week's hours and available days, resolved in one pure function (entry for that week, else profile).availabilityuses them in place of the profile's. The feeling entries and recent check-ins go to the coach, not to a rule (session 53 lets them justify a graded limit).RULES_CONFIG.readiness:highMean4,highItemMin3,highDays2.readinessTriggersraiseshigh_readiness(new enum value) the day the run turns high, mirroring low. The re-plan prompt: low readiness trims; high readiness and a "feeling good" entry may restore volume or intensity a recent trim removed, or bring forward the block's next quality session, always inside the rules.ride_chattask, promptride-chat-summary-v1) returning up to 4AthleteContextdrafts (kind, range, value, the athlete's words quoted) and at most one TSS override{ tss, reason }, each grounded in something the athlete said in the thread (cite it). The ride page shows them as a "Here's what I'm taking from this" list: each with Keep (default), Edit (range and value) or Drop. Confirm saves the kept entries, sets the override through the existing path (rescores DailyLoad), then releases the held triggers withride_chatas before. An empty list skips straight to the release. Never save an unconfirmed suggestion.chat.tsno longer sends dated changes to Settings: "I'm working from home next week" or "away Thursday to Saturday" returns a context draft beside the reply, shown with Keep or Drop under the message; keeping saves it and re-plans (athlete_contexttrigger, new enum value). Standing changes (the usual weekly hours, the goal) still go to Settings.athlete_contextfor that range. Past entries are not shown, and stay in the export.Rules
authed, Zod anduserIdfilters on every new server function; an entry, its source message and the ride it overrides belong to the athlete.AI_REPLAY=1.Tests
availabilityallows 8 h in an hours week and the profile's elsewhere; away days block sessions; high readiness turns on 2 good days, not on one or with an item below 3.athlete_context; Delete marksdeletedAtand re-plans; another user's entries never enter any input; the export includes entries.Out of scope
Graded limits and reasons (session 53), progression (54), editing the profile from chat, recurring entries. Note anything else under Follow-ups.
Done when
On a production build (replay) an hours entry from a ride chat raises that week's volume within the rules, a high-readiness run re-plans, and entries are listed and deletable on Plan;
bun run eval:replanstays 100% compliant; unit, typecheck, lint, format, audit and e2e pass. Add an eval scenario: an athlete with an 8 h entry for next week against a 5 h profile. Update FR-21's "not yet built", the "Individual response" row, and the data model table (AthleteContext, the trigger kinds). Finish with the end-of-session ritual inCLAUDE.md.Moved from
prompts/52-athlete-context.mdon 2026-11-08.