MCP: preview_session — what a routine will actually open with

get_routine reports what a routine stores. That is not what the athlete
sees. buildSets() consults the confirmed working weight and the previous
session's reps first, and applyPrescription() then overwrites the weight
with whatever the progression policy decided — so the routine's own
sets/reps/weight are the last fallback, not the first.

The gap is not academic. A routine holding "squat 3x8 @ 60 kg" opens at
75 kg when Greyskull deloaded from the last logged session, and an LLM
reading get_routine will confidently name a weight the app never shows.
Editing the routine to fix it changes nothing, which is worse.

preview_session mirrors beginWorkout() exactly — buildSets,
applyPrescription, applyIntensifierPlan — and returns, per exercise:
the planned target, the policy's decision with its stated reason, the
opening set rows including planned drop sets, and which of plan /
confirmed weight / history each number came from. `overridden` lists
just the exercises where the stored plan and the opening session
disagree, so the discrepancy cannot be scrolled past.

Read-only, no new dependency, one new tool registration. This is the
Phase 1.5 `progression_next` item from the README roadmap, named for
what it answers.

9 tests: precedence in both directions (plan wins with no history,
confirmed weight beats plan, policy beats both), reps carrying from
history, drop-set rows, explicit routine_id, rest day, unknown id.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DUgSPgBBqMYdy4vnKjK3bE
This commit is contained in:
Ameer KhanandClaude Opus 5 committed 2026-09-02 08:18:56 +00:00
1 parent 272bf785ee
commit 733dfa9d37
3 files changed
+276 -8

No files matched your search

+12 -4
View File
@@ -67,12 +67,13 @@ the server's stderr.
## Tools
Eight read-only tools in v1:
Nine read-only tools in v1:
| Tool | What it answers |
|---|---|
| `list_routines` | What routines are saved in my profile? (names + exercise counts) |
| `get_routine` | What does the Push Day routine prescribe? (sets/reps/weight per exercise) |
| `preview_session` | What will the app actually put on screen when I start this routine — after the progression policy and my history have overridden the plan? |
| `get_week_plan` | What's on my plan this week, including today with any date-specific override? |
| `list_workouts` | Recent sessions — newest first, with dates, sets done/planned, volume, duration, PRs. |
| `get_workout` | Full set-by-set breakdown of one session, by `workout_id` or by date. On a day with two sessions the date alone returns both ids to pick from rather than guessing at one. |
@@ -80,6 +81,13 @@ Eight read-only tools in v1:
| `estimate_1rm` | All-time best 1RM for an exercise + the trend, or a PR table across all exercises. |
| `muscle_balance` | Which muscles I've trained this week/month/all-time, ranked + which I've neglected. |
`get_routine` and `preview_session` answer two different questions, and confusing them is the
easiest way for a coach to give wrong advice. `get_routine` reports what the routine *stores*.
`preview_session` reports what the athlete will actually *see*: a routine holding "squat 3×8 @
60 kg" opens at 75 kg if the policy deloaded from the last logged session, and the rep counts
come from history, not the plan. The routine's own numbers are the last fallback the session
builder consults, not the first. Ask `preview_session` before naming a weight.
Each tool returns JSON the LLM can format as it likes; structured fields (sets, dates, levels)
are pre-formatted into human-readable labels in `src/labels.js` so the LLM doesn't need to
re-interpret them.
@@ -112,7 +120,7 @@ dependencies landed in `frontend/`, no public exports changed.
cd mcp && npm test
```
32 cases seeding state from `frontend/src/lib/demoSeed.js` (the same deterministic fixture
54 cases seeding state from `frontend/src/lib/demoSeed.js` (the same deterministic fixture
the public demo runs on). Pins JSON shape and the user-facing edge cases: rest-day override,
missing routine, zero-workout history, no synced state, superset links, three 1RM formulas.
"Today" is pinned via `vi.useFakeTimers({ now: ..., toFake: ['Date'] })` so date-dependent
@@ -122,8 +130,8 @@ their own 92 tests in `frontend/src/lib/*.test.js`.
## Roadmap
- **Done (Phase 1):** read-only stdio, 8 tools, direct `./data` access.
- **Phase 1.5:** a `progression_next` tool (what does the policy prescribe next?). No new
deps; small surface area.
- **Done (Phase 1.5):** `preview_session` — the policy's next prescription, the opening set
rows it produces, and which of plan / confirmed weight / history each number came from.
- **Phase 2:** read+write over stdio. Requires a long-lived token auth path minted from the
admin dashboard (new `./data/tokens.json`) and a write-lock against the web UI's read-modify-
write of `state-<uid>.json`. Tools: `log_workout`, `add_bodyweight`, `edit_routine`,