MCP: fixes from review (cardio mode, dead code, Stryker drop, docs)

· entryView was passing `e.target || { id: e.id }` to modeOf, which
   doesn't put id on the target when target exists — so a cardio config
   saved as {sets, min, speed} (no mode, no id) fell through to 'reps'
   and the label came back as "0×0". Now uses the same pattern every
   app call site uses (Workout.jsx, Stats.jsx, progression.js):
   modeOf({ ...(e.target || {}), id: e.id }). Same fix applied to the
   setLabel call right below. Added a regression test using a real
   cardio exercise id with a target that has no mode key — would have
   caught the original bug.

 · requireIso/ISO/fmt/friendlyDate/MUSCLES were unused (zod regexes
   cover ISO validation at the SDK layer). Removed, along with the
   misplaced comment that described requireIso but sat above entryView.

 · estimate_1rm's exercise_id schema description referenced
   search_exercises (v1.5) which doesn't exist yet — an LLM reading
   the schema would try to call it. Dropped the reference; the
   Roadmap section in mcp/README.md drops the same mention.

 · resolveUid threw "set OPENGYM_UID to one of: " (empty list) when
   there were zero state files but multiple users in db.json — the
   files array was empty so files.join(', ') rendered nothing. Now
   falls back to the db.json user ids in that branch.

 · Dropped Stryker entirely. The MCP SDK's 93 transitive runtime
   packages are tolerable since mcp/ is opt-in and never enters
   Docker, but a second test toolchain for a 39% mutation score
   wasn't carrying its weight next to the plain vitest suite.
   Removed .stryker.conf.json, the two Stryker devDeps, the
   mutation:test script, the .gitignore entries, and the README
   section. mcp/ now has a single devDep (vitest); 0 vulnerabilities
   (was 2 moderate).

 · CONTRIBUTING.md layout block + a one-line cross-reference in
   README.md's Tech section pointing at mcp/README.md, so people can
   actually find it.

92 frontend + 33 MCP tests pass.
This commit is contained in:
Pengboi committed 2026-08-02 19:42:36 +01:00
1 parent 6aaf2a3eea
commit 09949686c2
10 files changed
+173 -2029

No files matched your search

+2 -19
View File
@@ -119,28 +119,11 @@ missing routine, zero-workout history, no synced state, superset links, three 1R
tools see consistent values regardless of when the suite runs. The pure lib functions have
their own 92 tests in `frontend/src/lib/*.test.js`.
## Mutation testing
```bash
cd mcp && npm run mutation:test
```
[Stryker](https://stryker-mutator.io) 9.6.1 against the three MCP-only modules in `src/`
(`frontend/src/lib/` is excluded — it has its own 92-test suite). Config at
`.stryker.conf.json`. Run uses `inPlace: true` so the test file's relative imports
`../../frontend/src/lib/*.js` keep resolving; Stryker keeps a backup in `.stryker-tmp/`
during the run and restores on exit.
Baseline: 39% mutation score (333 killed / 330 survived / 184 no-coverage). Most of the
survivors are zod schema string literals; the bulk of the no-coverage debt lives in
`state.js` (file watching, multi-user resolution, mtime fallback). HTML report at
`mcp/reports/mutation/mutation.html` (gitignored, regenerated per run).
## Roadmap
- **Done (Phase 1):** read-only stdio, 8 tools, direct `./data` access.
- **Phase 1.5:** `progression_next` (what does the policy prescribe next?) + `search_exercises`
(search the catalog). No new deps; small surface area.
- **Phase 1.5:** a `progression_next` tool (what does the policy prescribe next?). No new
deps; small surface area.
- **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`,