Session 52: Athlete context #227

Closed
opened 2026-11-08 18:22:32 +00:00 by chris-kreidl · 0 comments
chris-kreidl commented 2026-11-08 18:22:32 +00:00 (Migrated from github.com)

52 · Dated athlete context

Phase: Adaptive coaching 3/5 (owner request 2026-11-08) · Branch: session/52-athlete-context · Depends on: 51

What 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 table
  • docs/decisions.md: the 2026-11-08 adaptive coaching entry
  • src/domain/rules/availability.ts, src/domain/rules/types.ts (RuleContext), src/domain/rules/config.ts (readiness), src/domain/rules/individual-response.ts
  • src/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.ts
  • src/server/replan/triggers.ts (readinessTriggers), src/domain/replan/triggers.ts (LOW_READINESS_DAYS, isLowReadiness)
  • Sessions 50–51: RideChat, endRideChat, the held-trigger release
  • src/server/rescore-store.ts and the TSS override path on the ride page
  • Load the claude-api skill before touching src/ai/

Goal

  1. 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 marks deletedAt, edit writes a new row and deletes the old.
  2. Rules read it. RuleContext gains each plan week's hours and available days, resolved in one pure function (entry for that week, else profile). availability uses 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).
  3. High readiness. In RULES_CONFIG.readiness: highMean 4, highItemMin 3, highDays 2. readinessTriggers raises high_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.
  4. End chat suggests, the athlete confirms. End chat (session 50) now first asks the coach for suggestions: one AI call (ride_chat task, prompt ride-chat-summary-v1) returning up to 4 AthleteContext drafts (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 with ride_chat as before. An empty list skips straight to the release. Never save an unconfirmed suggestion.
  5. Coach chat suggests too. chat.ts no 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_context trigger, new enum value). Standing changes (the usual weekly hours, the goal) still go to Settings.
  6. Plan lists them. A short "What the coach knows" section on Plan: current and future entries (kind, dates, value, the athlete's words, source), each with Delete; an Add form for hours (a week picker) and days (a range, free days or away). Add, edit or delete enqueues athlete_context for that range. Past entries are not shown, and stay in the export.
  7. Inputs. Re-plan and generate inputs carry entries overlapping the plan window, inside a delimited block as athlete data; chat and ride-chat inputs carry current ones.

Rules

  • authed, Zod and userId filters on every new server function; an entry, its source message and the ride it overrides belong to the athlete.
  • Athlete text is data in delimited blocks, never instructions.
  • Plans stay append-only; an entry change re-plans, it never edits a version.
  • Replay fixtures for every new AI path; tests and e2e run with AI_REPLAY=1.

Tests

  • Domain: week hours and days resolve from an entry or the profile, for a range that covers part of a week (the rule's choice: say it in the code); availability allows 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.
  • AI: summary output parses its fixtures (entries, an override, empty); a draft not tied to a quote is refused and repaired.
  • DB: Confirm saves only kept entries, sets the override and rescores, then one run consumes the released triggers; Drop saves nothing; coach chat Keep saves and enqueues athlete_context; Delete marks deletedAt and re-plans; another user's entries never enter any input; the export includes entries.
  • E2E (replay): a ride chat where the athlete says they have more time next week, End chat, keep the hours entry, see it on Plan and next week's sessions grow. Keep the axe scans passing.

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:replan stays 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 in CLAUDE.md.

Moved from prompts/52-athlete-context.md on 2026-11-08.

# 52 · Dated athlete context **Phase:** Adaptive coaching 3/5 (owner request 2026-11-08) · **Branch:** `session/52-athlete-context` · **Depends on:** 51 What 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 table - `docs/decisions.md`: the 2026-11-08 adaptive coaching entry - `src/domain/rules/availability.ts`, `src/domain/rules/types.ts` (`RuleContext`), `src/domain/rules/config.ts` (`readiness`), `src/domain/rules/individual-response.ts` - `src/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.ts` - `src/server/replan/triggers.ts` (`readinessTriggers`), `src/domain/replan/triggers.ts` (`LOW_READINESS_DAYS`, `isLowReadiness`) - Sessions 50–51: `RideChat`, `endRideChat`, the held-trigger release - `src/server/rescore-store.ts` and the TSS override path on the ride page - Load the `claude-api` skill before touching `src/ai/` ## Goal 1. **`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 marks `deletedAt`, edit writes a new row and deletes the old. 2. **Rules read it.** `RuleContext` gains each plan week's hours and available days, resolved in one pure function (entry for that week, else profile). `availability` uses 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). 3. **High readiness.** In `RULES_CONFIG.readiness`: `highMean` 4, `highItemMin` 3, `highDays` 2. `readinessTriggers` raises `high_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. 4. **End chat suggests, the athlete confirms.** End chat (session 50) now first asks the coach for suggestions: one AI call (`ride_chat` task, prompt `ride-chat-summary-v1`) returning up to 4 `AthleteContext` drafts (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 with `ride_chat` as before. An empty list skips straight to the release. Never save an unconfirmed suggestion. 5. **Coach chat suggests too.** `chat.ts` no 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_context` trigger, new enum value). Standing changes (the usual weekly hours, the goal) still go to Settings. 6. **Plan lists them.** A short "What the coach knows" section on Plan: current and future entries (kind, dates, value, the athlete's words, source), each with Delete; an Add form for hours (a week picker) and days (a range, free days or away). Add, edit or delete enqueues `athlete_context` for that range. Past entries are not shown, and stay in the export. 7. **Inputs.** Re-plan and generate inputs carry entries overlapping the plan window, inside a delimited block as athlete data; chat and ride-chat inputs carry current ones. ## Rules - `authed`, Zod and `userId` filters on every new server function; an entry, its source message and the ride it overrides belong to the athlete. - Athlete text is data in delimited blocks, never instructions. - Plans stay append-only; an entry change re-plans, it never edits a version. - Replay fixtures for every new AI path; tests and e2e run with `AI_REPLAY=1`. ## Tests - Domain: week hours and days resolve from an entry or the profile, for a range that covers part of a week (the rule's choice: say it in the code); `availability` allows 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. - AI: summary output parses its fixtures (entries, an override, empty); a draft not tied to a quote is refused and repaired. - DB: Confirm saves only kept entries, sets the override and rescores, then one run consumes the released triggers; Drop saves nothing; coach chat Keep saves and enqueues `athlete_context`; Delete marks `deletedAt` and re-plans; another user's entries never enter any input; the export includes entries. - E2E (replay): a ride chat where the athlete says they have more time next week, End chat, keep the hours entry, see it on Plan and next week's sessions grow. Keep the axe scans passing. ## 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:replan` stays 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 in `CLAUDE.md`. _Moved from `prompts/52-athlete-context.md` on 2026-11-08._
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/trainer#227
No description provided.