Session 53: Graded limits #228
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#228
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?
53 · Graded limits
Phase: Adaptive coaching 4/5 (owner request 2026-11-08) · Branch:
session/53-graded-limits· Depends on: 52Every rule is pass or fail at a bound picked as safe for anyone. Four of them now grade: form allows rides deep into fatigue as long as fitness only holds; the ramp has a band that needs a reason; the recovery week gets a floor as well as a ceiling; the easy-share floor scales with phase and hours. Reasons point at records (session 52's entries, check-ins, rides), so the engine still checks them mechanically.
Read first
docs/requirements.md→ "Coaching dialogue and adaptability" (FR-22) and the foundations tabledocs/decisions.md: the 2026-11-08 adaptive coaching entry (the owner's form −6 to −56 and ramp 2 to 9.6 examples)src/domain/rules/:config.ts,types.ts(Violation.severity,Fix),index.ts(validatePlan,validatePatch,newViolations,breakKey),form-floor.ts,fitness-ramp.ts(the forced-bound hold),periodisation.ts,intensity-distribution.ts,projection.ts,clamp.ts,labels.ts, and their testssrc/server/athlete.ts(RulesConfigOverridesvalidator) and the training-rule settings UIsrc/domain/plan/schema.ts(PlanPatch,PlanDraft),src/ai/prompts/generate.ts,src/ai/prompts/replan.ts,src/ai/prompts/chat.tsevals/(bun run eval,bun run eval:replan)Goal
form-floor). ConfigformFloor: { capTsb: -30, recoveryTsb: -60 }(dropdays; migrate stored overrides that set it). For each projected day by its incoming TSB: belowcapTsb, the day's planned ride TSS is at most that day's projected CTL, any zones allowed; belowrecoveryTsb, the day is a recovery day (isRecoveryDay). Fixes: trim the day's rides to the cap (scale steps, keep the structure), orrecovery-day. Stored days are facts, as now. Check the owner's case: from −56 coming into a day, a recovery ride passes.fitnessRamp: { maxCtlGainPerWeek: 5, maxWithReason: 7 }. A gain between them is awarningthat needs a reason; abovemaxWithReason, anerror(trim fix as now). The forced-bound hold for logged rides stays exactly as it is.periodisation). Every non-taper mesocycle's recovery week is its lightest week by ride TSS, atrecoveryWeekMinShare0.5 torecoveryWeekMaxShare0.65 of the block's peak week. A week a trim or the athlete made lighter (a clamp's trim, a pinned edit, a missed or past week) doesn't break the floor: check the floor against planned sessions as the coach wrote them, and say how you decided. The generate and re-plan prompts: a recovery week keeps one short intensity touch (for example 3 × 3 min at threshold in an hour ride), so fatigue drops and sharpness stays.intensity-distribution). Config replacesminLowSharewith a table by phase (base, build, specialty; taper unchecked) and three hour bands (≥ 10, 6 to 10, < 6), defaults in FR-22. A block's hours are the mean of its weeks' resolved hours (session 52's function). Zones 1–2 stay the "easy" zones.PlanPatchandPlanDraftgainexceptions: { ruleId, period, reason: { kind: 'context' | 'readiness' | 'ride', id or dates }, text }[]. The engine accepts a warning-band break only when an exception covers it with a valid reference: theAthleteContextentry exists, isn't deleted, belongs to the athlete and overlaps the period; the check-ins exist on those dates and are at or above the high-readiness bar; the ride exists and is the athlete's, within the last 14 days. An uncovered warning-band break is an error, so repair and clamps handle it as today. The prompts tell the coach when an exception is fair (more hours, good readiness or a "feeling good" entry, a TSS the athlete overrode down) and that it must cite the record.minLowShareanddays.Rules
src/domain/stays pure and unit-tested; every bound lives inRULES_CONFIGwith a test at, just under and just over it.newViolations: an old break isn't a reason to reject a patch.CLAUDE.md(stored overrides with old keys are read and rewritten, not dropped in the same PR).Tests
bun run evalandbun run eval:replanstay 100% compliant after repair or clamps; add a re-plan scenario from the owner's 2026-11-04 to 11-06 rides (78, 124 and 363 TSS on three days) and one with an 8 h hours entry and a ramp of 6.Out of scope
Progression and hard-minute floors (session 54). Note anything else under Follow-ups.
Done when
The four rules grade as above, exceptions show on Plan, and both evals stay 100% compliant; unit, typecheck, lint, format, audit and e2e pass. Update FR-22's "not yet built", the foundations table rows (fitness, form, intensity, periodisation), and the "AI design" re-plan row if the prompt version changes. Finish with the end-of-session ritual in
CLAUDE.md.Moved from
prompts/53-graded-limits.mdon 2026-11-08.Folded in from the board (owner: "covered in #228"). None of these is in the body above yet, so this session takes them on too:
RULES_CONFIG, checked inperiodisation.ts), alongside the recovery-week floor and ceiling in Goal 3. The event ride's TSS doesn't count toward the taper week (below).rideType: 'event'on the goal's event date). Today it is in the projection, and because the event can't be trimmed, the ramp's trim fix cuts the 6 days before it instead, squeezing the taper. Checks that aren't about load still see the event day: it falls in the taper's last week, availability exempts it, and the event week gets no strength. #229's progression rules inherit this exclusion. This replaces the earlier idea of exempting the event day from the ramp check.recovery-dayfix (Goal 1's form recovery, now used more often) should move the removed key session elsewhere in the week, or say why not.Also folded in: #105. The generate and re-plan prompts never describe the forced-ramp hold (decisions 2026-10-23, "ramp fix"): when logged rides already put the 7-day CTL gain over the bound, the plan may only hold fitness (rides at or below that day's CTL in TSS, recovery zones). The coach learns it only from the repair message, which costs an attempt on the re-plans after the hardest days. With this session's prompt bump, describe the hold alongside Goal 2's reason-backed band.