Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Coach: the create schema requires a routine id and a week
Konstantinos Thermosdafc80f1d641
diff --git a/api/coach/core/schemas.js b/api/coach/core/schemas.jsindex 9779e732c..072c58fda 100644--- a/api/coach/core/schemas.js+++ b/api/coach/core/schemas.js@@ -59,6 +59,11 @@ const EX_SCHEMA = {required: ['id', 'sets']};+// `week` and `routines[].id` are required, not optional: the week is the only thing that says+// which day trains which routine, and it points at a routine by id. A schema that leaves either+// out lets a small local model answer with routines that have no id and a week naming "r1" —+// grammar-valid, and something validate.js can only ever reject ("the week schedules 0 days but+// 3 were asked for"), through the repair round and out as a failed job.export const CREATE_SCHEMA = {type: 'object',properties: {@@ -75,7 +80,7 @@ export const CREATE_SCHEMA = {id: STR, name: STR, emoji: STR, prog: STR, why: STR,ex: { type: 'array', items: EX_SCHEMA }},- required: ['name', 'ex']+ required: ['id', 'name', 'ex']}},customEx: {@@ -83,7 +88,7 @@ export const CREATE_SCHEMA = {items: { type: 'object', properties: { id: STR, n: STR, bp: STR, desc: STR }, required: ['id', 'n'] }}},- required: ['coach_contract', 'routines']+ required: ['coach_contract', 'week', 'routines']};export const DEBRIEF_SCHEMA = {diff --git a/api/test/prompt-split.test.js b/api/test/prompt-split.test.jsindex 1b0072bd0..aea87c9e3 100644--- a/api/test/prompt-split.test.js+++ b/api/test/prompt-split.test.js@@ -4,6 +4,7 @@ import { buildPrompt, buildPromptParts, taskOf } from '../coach/core/prompt.js';import { SCHEMAS } from '../coach/core/schemas.js';import { build, FULL_DETAIL_SESSIONS } from '../coach/core/payload.js';import { chatCompletionsSpec } from '../coach/core/adapters/openai.js';+import { validatePlan } from '../coach/core/validate.js';const S = (workouts = []) => ({lang: 'en', unit: 'kg', routines: [{ id: 'r1', name: 'A', ex: [{ id: '0001', sets: 3, reps: 8 }] }],@@ -48,6 +49,25 @@ test('every task has a flat schema — no $ref, no anyOf/oneOf (llama.cpp grammaassert.equal(taskOf('create', { refine: 'x' }), 'refine');});+test('the create schema requires what the week resolves through: a routine id, and a week', () => {+ // A schema handed to a grammar-constrained decoder is the only thing standing between a small+ // local model and an answer the validator can only reject. These two fields are where that+ // showed: llama3.2:3b and qwen2.5:3b both answer with routines that carry no `id` and a week+ // naming what they put in `name`, which costs a job and a repair round to find out.+ assert.ok(SCHEMAS.create.properties.routines.items.required.includes('id'));+ assert.ok(SCHEMAS.create.required.includes('week'));+ assert.equal(SCHEMAS.refine, SCHEMAS.create); // refine reuses it, same guarantee++ const noId = {+ coach_contract: 1,+ routines: [{ name: 'r1', ex: [{ id: '0001', sets: 3, reps: 8 }] }],+ week: { 1: 'r1' }+ };+ const checked = validatePlan(noId, { daysPerWeek: 1 });+ assert.ok(!checked.ok);+ assert.ok(checked.errors.some(e => e.includes('week[1] points at "r1"')));+});+test('older sessions in a review window are compacted, the recent ones keep full sets', () => {const many = Array.from({ length: FULL_DETAIL_SESSIONS + 4 }, (_, i) => workout('2026-08-' + String(i + 1).padStart(2, '0')));const p = build(S(many), { handle: 'h1', kind: 'review' });