An instance can now be pointed at a model entirely from its environment — so a
container is redeployed with the Coach already working, and nobody has to open
an admin screen:
COACH_PROVIDER=compatible
COACH_BASE_URL=https://ai.example.com # WITHOUT /v1 — the adapter adds it
COACH_MODEL=vendor/model-name
COACH_API_KEY=sk-... # or the provider's own variable
Naming a provider is the whole configuration, so it also turns the Coach on: an
instance started this way that then reported itself "off" would be a puzzle with
no clue in it.
Three decisions worth stating:
- The environment is the *base*, the way DEFAULTS is, and the saved file is
layered on top: an admin who picked a provider in the app meant it, and this
only fills what is absent.
- The key is deliberately NOT a field of the config. That object is cached,
written to data/coach.json by any admin action, and included in the backup the
docs tell people to make. envCredentialFor reads it from the process
environment instead, so it is written nowhere and never surfaced by any route
that reports configuration. A pasted credential still outranks it, and a filed
one that fails to decrypt stays a failure rather than quietly falling back to
a key nobody knows is being spent.
- What the environment supplies is stripped before the file is written. A saved
config used to be written back whole, which would have frozen this start-up's
values on disk — and since the file outranks the environment, a later change
to COACH_MODEL would have been silently ignored.
Verified through the server's own path (config → credentialFor → jobEnv →
adapter) against the OpenAI-compatible router this fork runs on: a chest+triceps
request came back as a six-exercise routine with the cardio row first and
correctly marked `mode: cardio`.
The screen that will drive this needs three things underneath it, and all three
are here, tested, with no UI yet.
1. `librarySlice` can be narrowed to the muscles someone picked. A selector is
`{ bp }` or `{ tg }` — the target muscle matters because "biceps" and "triceps"
are both `upper arms`, and asking for one must not hand back the other — and an
exercise is kept when it matches any of them, so "back and biceps" is one list.
`catalogueOnly` drops the person's own exercises, which are the only rows in
the app with no animation; the builder promises every pick can be watched.
Both answers ride in the existing `intake` object rather than a second channel:
the intake is already how "which muscles" reaches the payload, and it travels
the whole way (route → job → build, and local → build) untouched. `cleanGroups`
sanitises it, since it is the one intake field that reaches a filter rather than
the model's reading.
2. `lib/ai-routine.js` — the three questions and what to do with the answer: the
intake the model is asked with, and the routine it hands back, normalised for
this app. Cardio lands in the library and not only in the sentence (a model told
to start with cardio but handed no cardio exercise can only improvise, which is
what it did the first time this was tried), a cardio row becomes one bout
whatever set count came back, and a missing mode is read from the exercise the
same way `modeOf` reads it everywhere else.
3. A validator fix found on the way: the cardio branch set `min` and `speed` but
never `clean.mode = 'cardio'`, unlike the time and reps branches. The app
recovered it from the catalogue, so nothing was visibly broken — but the bundle
did not describe its own prescription, and a model that omitted `mode` (which is
what a model prescribing "8 minutes of cardio" usually does) got "3 × 10 reps"
with a stray `min` nothing reads. Now the mode is stated, and inferred from the
catalogue when it is missing. `time` is deliberately not inferred: nothing in the
catalogue says an exercise is held for seconds.
Verified against the real router behind gym.dploy.lol with the real pipeline: a
back+biceps request produced a 6-exercise routine from an 80/80/22 library slice.
A gateway may answer a request that did not ask for streaming with SSE framing
anyway: the whole chat.completion object followed by "\ndata: [DONE]". That body
is not JSON, so readJson's strict parse rejected it, `data` came back null, and
the job failed with "unexpected response shape: Cannot read properties of null
(reading 'choices')" — while the answer it wanted sat in the first few kilobytes.
Not hypothetical: the OpenAI-compatible router behind this fork's own instance
answers exactly that way, which made every coach job fail against it with a
message that says nothing about the real problem.
The lenient read takes the first complete JSON value and ignores what follows,
counting braces outside of strings so a "}" inside a rationale cannot end the
scan early. It cannot paper over a truncated answer — an object that never closes
still returns null, which is what the token-limit path depends on — and there are
three tests for that: the terminator case, trailing junk after a complete object,
and an object that never closes.
The app is now KuentaGYM everywhere a user can see it, and a fresh profile no
longer starts on upstream's English/kg defaults. Both are this fork's decisions,
so both are pinned by tests rather than left to a find-and-replace.
Rename (1,270 references, 149 files)
- Visible surfaces: the Login/Home/mobile-onboarding wordmark, the Settings
version line, the printed plan, the PWA title + manifest, and the 17 branded
strings across all 14 locale packs.
- Infrastructure: repo links, the container images and the release endpoints now
name git.dploy.lol/dsantillan/kuentagym; .gitea/workflows/docker-publish.yml
publishes to this forge's registry instead of gitea.com.
- The Android/iOS application id stays ch.duartesantos.opengym on purpose:
changing it would make the mobile app a different app that could never update
an installed copy.
Three things the mechanical pass would have broken, fixed here
- The update check asked gitlab.com for upstream's releases and would have
installed upstream's APK, putting the old name back on the phone. It now reads
this fork's Gitea releases API (the assets shape differs), with the tests
rewritten to the payload Gitea actually returns.
- Renaming the mobile state/pairing files (opengym-state.json,
opengym-remote.json) would lose the on-device copy of a history whose WebView
storage may have been evicted, and silently unpair the device. Both are read
under their old names and written forward under the new ones.
- Renaming the exported plan-file marker (openGym_plan) rejected every plan
shared before the rename as "not a plan file". Both markers are accepted.
Defaults: pounds and Spanish
- DEF.unit = 'lb', DEF.lang = 'es', plus every fallback that independently
assumed en/kg (the <html lang> attribute, the Settings pickers, the Store, the
MCP, the Coach payload).
- Server-generated push copy existed only in English and pt-BR, so a Spanish
profile would have been notified in English; Spanish added.
- The demo seed states unit: 'kg' — its seeded numbers are kilograms, and
inheriting the new default would have introduced an 82.4 lb lifter benching 60.
- The module-level language in i18n-core stays English: it is the only language
whose strings need no pack, so `t()`, dates, numbers and lists agree before a
pack loads. Starting there on 'es' formats a Spanish-shaped UI with English
strings.
Also
- api/package.json's test glob missed push-messages.test.js and
verify-error.test.js, which sat beside the modules they cover and never ran.
- README, docs/, website/ and the issue templates no longer describe upstream's
GitLab/GitHub pipeline, Discord, sponsorship or public demo as if they were
this fork's; upstream history and attribution are preserved (NOTICE.md).
versionCode 22. The milestone was due on the 27th; it ships a week early because the QA round
that followed the bug fixes found — and closed — enough to be worth releasing on its own.
Disabling locks someone out but deliberately leaves their state file and credential on disk, so
'no data remains' was not reachable from the dashboard — which is what the request asked for.
POST /api/admin/user/delete removes the user, their passkeys, their push subscriptions, their
presence entry, their training history and any Coach credential of theirs. Two refusals, because
nothing in the UI could undo either: an admin cannot delete their own account, and the last
remaining admin cannot be removed. The invite code they joined with stays burned — it was used,
and freeing it would quietly widen an invite-only instance.
In the dashboard it asks twice, naming the account both times, and offers their data as a
download first: the training history is theirs. Five tests drive the real server.
GET /api/admin/user mapped S.routines straight off disk — `r.id` on every entry — so a single
null routine threw, the route answered 500 {"error":"server error"} with a stack trace in the
log, and the sheet never left "Loading…". The Disable button lives inside that sheet, so the
one account an operator opened the dashboard to stop was the one they could not: exactly the
end state C16 described, reached through routines instead of workouts. C16 hardened the sheet
and taught PUT /api/data to drop such entries, but a document v1.3.7 accepted still sits on
disk and answers to nobody.
A `records(list)` helper next to readState now hands every reader the entries of a stored list
and nothing else, and both admin routes go through it: the routine map, the body-weight log,
the workout history (whose `.slice()` threw in its own right when `workouts` was an object
rather than an array) and the user list's workout count, which counted entries the drill-down
then dropped and read `null` for a non-array list. A routine's exercise count counts entries
too, rather than the length of whatever `ex` happens to be. PUT /api/data reuses the helper
for the filter it already had, unchanged in behaviour.
The reminder tick walks the same two lists outside any route: a null entry threw there, was
logged and skipped, and cost that profile every reminder from then on, day after day. It
skips the entry now, not the profile.
Measured on QA slot 32 with each shape planted directly in the slot's data dir
(scripts/opengym-qa/run/r3-admin-null-routine/plant.mjs, shots alongside it):
routines [null, r] before GET /api/admin/user 500, sheet "Loading…", 0 Disable
buttons, 16 stack frames in api.log
after 200, sheet shows Workouts 1 · Weigh-ins 1 · Routines 1,
disable and re-enable both land in the audit log,
0 stack frames, no console or HTTP errors
workouts/routines as before 500, same dead sheet, 12 stack frames
objects, not arrays after 200 with empty lists
bodyweight [null, b] before 200 but "Weigh-ins 2" for one weigh-in (4 for one plus
three junk entries)
after 1, the number of weigh-ins there are
null and shapeless workout entries, a null customEx, absent lists and an ordinary
profile all open, disable and enable, before and after.
api/test/server-admin-state.test.js covers both admin routes against ten stored shapes, and
server-reminder.test.js gains the null-entry case: 188 api tests (was 185). Frontend
untouched — the sheet's own guard from C16 still does the work the server cannot: 1533 vitest
green, 14 locales in sync, 33 demo-only source strings.
readBody rejects with a typed HttpError for unparseable text and for a JSON null, string,
number or array; the catch-all answers it with its status and does not log it — three of
these routes are reachable without a session, and a stack trace per malformed body let
anyone fill the container log. String() on a caller-supplied field went through the same
door ({"code":{"toString":1}} is valid JSON) and is replaced by a text() helper.
PUT /api/data refuses an array state (typeof 'object', but _rev on it is dropped by
JSON.stringify, so the file read back as rev 0 while the response claimed rev N+1) and
drops null and non-object entries from workouts/routines instead of refusing them: such an
entry carries nothing worth keeping, while a 400 would strand a client whose own copy is
already malformed in a re-send loop. Every server-side reader of the document (reminder
tick, admin drill-down) dereferences the entries.
POST /api/push/rest-timer validates seconds before clamping — the clamp ran first, turned
any missing or unusable value into a 1-second push and made the documented 400 unreachable.
A body over 5 MiB is a 413 the client actually gets to read: the remainder of the upload is
drained instead of the socket destroyed under it (which sent a reset that a node client hit
before parsing the answer — the QA proxy reported 502 on 3 of 4 attempts, 5 of 5 read the
413 afterwards); past twice the cap the upload is cut off. openapi.yaml documents the
400/413 bodies and the rest-timer 400.
- reminder tick: a due reminder is sent for up to 15 minutes after its time (once per local
date) instead of only on the exact minute — a restart across that minute used to lose the day;
state files are stat'ed and re-read only when they changed
- sendPush prunes 403 (stale VAPID key) like 404/410; optional device targeting
- POST /api/push/subscribe is an upsert that keeps created and stores a deviceId;
GET /api/push/status says whether the server holds an endpoint
- rest timers keyed per user+device; cancel without a device id keeps the old account-wide
behaviour
- sw.js: payload parsed inside waitUntil (never a silent push), pushsubscriptionchange
re-subscribes and registers the new endpoint
- lib/push.js: syncPushSubscription() (called once per signed-in boot from App.jsx and when
Settings opens) re-registers a lost row, replaces a subscription made against another key,
pushSupported() is false off https; deviceId() per browser
- Settings: the notifications switch shows what the server holds
- tests: server-reminder (window, dedupe, trained day), server-push-status (upsert, status,
per-device timers), lib/push.test.js
Same capability, other direction. The child writes as `coach`, so its own
directories come out coach-owned -- and this process cannot unlink inside them
without CAP_DAC_OVERRIDE. fs.rmSync then throws EACCES from a `finally`,
which turns a run that actually succeeded into a failed one:
EACCES: permission denied, rmdir '/tmp/coach-test-XXXX/.claude/backups'
The child's user now clears its own files (argv array, no shell, paths from
this module's own mkdtemp) and the server removes the directory it still owns.
Best effort on both halves: a leaked temp directory beats a failed job.
Every Coach run failed instantly on Kubernetes -- "Claude Code native binary
... exists but failed to launch. This usually means the binary does not match
this system's libc" -- with a musl binary on a musl host, which the SDK's own
--version printed happily one shell command earlier.
The message is the Agent SDK's guess at any spawn failure. The real errno was
EACCES, and the cause is the job directory rather than the binary: libuv
chdir()s into cwd BEFORE dropping to the child's uid, so handing the directory
to `coach` locks out the very process that has to enter it first. mkdtemp
creates 0700, and `drop: [ALL]` leaves root without CAP_DAC_OVERRIDE to
ignore that with -- so the child never starts.
cf7e4cc fixed the same class of bug for the fixture provider by skipping the
chown when the child stays root. It does not help here: claude and codex do
drop, and the chdir still happens before they do.
The directory now stays owned by the server and `coach\' reaches it through
the group (0770, coach gid). The child writes, the parent still chdirs and
still cleans up, nothing else on the container can read it. chmod before
chown, while the server is still the owner: CAP_FOWNER is not in the set
either, so the other order fails with EPERM.
Verified in the running container: chown -> EACCES, group handover -> exit 0,
child writes, parent removes.
- Phone with own key: the provider's or validator's reason reaches the chat line and toast
(BYOK_ERRORS + jobErrorText); no more "instance owner" wording where there is none (#58)
- CoachChat: a message with no routines refines/creates instead of reviewing an empty window;
menu entry "Start a new plan" (Discord "Coach reset" thread)
- payload: refine without a previous plan becomes a create with userNote; the last six chat
lines travel as `conversation` (documented in common.md, prompts.js regenerated)
- OpenAI model list cut to Chat-Completions models (isChatModel); Gemini placeholder names AQ. keys
- 3 new strings in 14 packs, pt-BR guard 626/616/3db560d7; tests for all of it
startFlow / beginWorkout now take string | string[] | null and route
through buildCombinedEntries; callers pass [r.id], effectiveRoutineIds(...)
or [] as appropriate. Every effectiveRoutine(S,iso) render site that
showed one routine now iterates effectiveRoutines / checks
effectiveRoutineIds.
- sheets.jsx: beginWorkout / beginBackfill write s.active.routineIds +
derived name, no routineId / excludeFromProgression; swapTo resolves the
slot's routine from its entry rid and carries rid onto the replacement;
DayOverride / Calendar use the plural resolver (dayPlan stays scalar —
overriding a combined date collapses it, per spec §8); DayAssign writes a
one-element list.
- active-exercise-swap.js: split-insert carries current.rid like it carries sg.
- Workout.jsx: StartChooser id-set exclusion + startFlow(list); add-exercise
and progression-settings resolve the routine from the current entry's rid
and stamp rid on a freehand add.
- TabBar / Home: onStart(effectiveRoutineIds(...)); Home plannedPerWeek
counts scheduled days not routines; today card name joins the day's
routines.
- mobile.js buildReminderNotifications: names all of a combined day's
routines, or a count past two.
- RoutineEdit delete-cleanup pulls the id from each week list, drops an
emptied key. api/server.js effectiveRoutineId reads the first of the list.
Tests: sheets.combine.test.jsx (beginWorkout with a routine-id list);
mobile.test.js combined-day reminder. Existing suites stay green on the
tolerant-reader path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JVbWJtoyQU4WgwFR4eAKgy
The plan fingerprint is computed in two runtimes that share no build step
(frontend/src/lib/coach.js and api/coach/core/) and must stay byte-for-byte
matched. Both now normalise every weekday to a routine-id list:
- canonicalPlan / cleanPlan: day value -> [].concat(S.week[d]); filter
S.week?.[d]?.length. A legacy bare string and a one-element list are
indistinguishable downstream.
- hashPlan (both): week join -> k + '=' + list.join('+'). A single-routine
plan's fingerprint is byte-identical to pre-upgrade — no false-stale storm.
- aggregates.plannedDays counts scheduled days, not routines.
- coach.js currentValue/markStale compare `week` by canonical join;
CHANGE_APPLY.week writes [c.after] (single-routine op, collapses a
combined day — same limitation as DayOverride); changeValues.fmt renders
a week array as " + "-joined routine names before the generic branch.
- prompts/common.md + review.md: plan.week is a list; a `week` change names
exactly one routine and replaces the day. core/prompts.js regenerated.
Tests: shared combined-day fixture (client hashPlan === server hashPlan),
legacy scalar vs one-element array identical, canonicalPlan order,
CHANGE_APPLY.week, markStale canonical compare, changeValues rendering.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JVbWJtoyQU4WgwFR4eAKgy
Every key-store call on Android stalled before it started: the Capacitor plugin proxy answers
`then` with a native method, so a promise resolving to the plugin itself never settled. Save
greyed out, key "not saved", Coach "thinking" forever (#42, #58). The plugin now travels inside
a plain object; a test drives the store through a Capacitor-style proxy. Verified on an emulator.
create.md asks for "1-7 routines, each 3-12 exercises" and validate.js slices at MAX_ROUTINES /
MAX_EX_PER_ROUTINE, but the schema the endpoint decodes against had no bound at all. A model that
starts repeating itself never reaches the validator: qwen2.5:3b walks the library id by id, three
sets of eight apiece, until it exhausts the 16k output limit — twelve minutes for an answer that
arrives truncated, which the adapter turns into "the answer was cut off at the output limit" and a
job that would already have hit COACH_JOB_TIMEOUT_MS.
maxItems on the two arrays states the caps that already exist, where the decoder can enforce them.
CREATE_SCHEMA is handed to OpenAI-compatible endpoints as a grammar to decode against, and it
left both `routines[].id` and `week` optional. Small local models take that offer: llama3.2:3b
and qwen2.5:3b both answer with routines that carry no id, and a week naming what they wrote
into `name` instead. Nothing in the week then resolves, validate.js reports "the week schedules
0 days but 3 were asked for", the repair round produces the same answer again, and the job ends
as `unusable` — "The Coach answered with something the app couldn't use."
Requiring the two fields the week resolves through is enough. With them in the schema,
llama3.2:3b produces a plan that passes validatePlan on the first attempt, against the payload
that failed twice before. The validator is untouched; this only stops the grammar from offering
an answer it can never accept.
Der Trivy-Scan meldete 13 Funde, alle im api-Image und keiner in einer Abhaengigkeit der App:
2x openssl aus alpine (node:22-alpine hinkt alpines Fixes hinterher) und 11x in npms eigenem
gebuendelten Baum (tar, brace-expansion, pacote, ...). Beide Images ziehen jetzt `apk upgrade`
beim Bauen; das publizierte api-Image (Target default) verliert npm komplett - der Server
startet mit `node server.js`, nichts spawnt npm. build:api-check prueft das. Das coach-Target
behaelt npm fuer die Codex-CLI.
build:apk schreibt die .sha256 jetzt bei jedem Build (die Artefakt-Warnung auf Branches ist weg),
hochgeladen wird sie weiterhin nur vom Release-Tag.
web/Dockerfile kopierte nur frontend/, aber frontend/src importiert den Coach-Kern aus
api/coach/core (../../../api/coach/core/*). Der Build-Stage liegt jetzt unter /app/frontend
und bekommt api/coach/core an derselben relativen Stelle wie im Repo. Neuer Job
build:web-check baut das Web-Image in jeder MR-Pipeline, die frontend/, web/ oder den Kern
anfasst (der API-Check gab es schon, den Web-Check nicht — deshalb ist v1.2.15 durchgerutscht).
Auf der VM gebaut und geprueft: App-Shell 200, Coach im Bundle.
- Instanz-Modus: nur eine persoenliche Anmeldung (Setup-Token/OAuth) bindet sich an das
erste Profil, ein API-Key ist gemessen und wird von allen Profilen unter den Tageslimits
geteilt. Die Bindung passiert jetzt wirklich beim Einreihen eines Jobs (jobs.enqueue),
vorher gab es sie nur in den Tests.
- HTTP-Adapter: 429/500/502/503/504/529 werden zweimal mit kurzer Pause wiederholt, ein
4xx nie. retryDelayMs fuer Tests.
- Payload: Warm-up-Saetze wie in progression.js aus readSession/stalls, done/planned,
Top-Satz, setsByBodyPart und workingWeights herausgefiltert; in vollen Sessions als
warmup:true markiert, common.md sagt dem Modell, was das ist.
- Admin-Karte: .field im Card hat jetzt eine sichtbare Flaeche, die Limit-Zahlenfelder
sind echte Felder statt weisser Browser-Boxen; Text zu 'Whose account pays' unterscheidet
API-Key und persoenliche Anmeldung.
- Neuer Test e2e-apikey: Key ueber die Admin-Routen einlegen, Modelle listen, Review durch
die echte Queue gegen einen lokalen Anthropic/OpenAI/Gemini-Stand-in, inkl. Header,
Cache-Block, Schema, Retry und Auth-Fehler. api 150, frontend 1029, mcp 45 gruen.
Konflikte: zwoelf Locale-Packs (beide Seiten haengen Strings an, sechs doppelte
Schluessel bereinigt), Admin.jsx/admin.css (Coach-Karte bleibt, main-Umbau uebernommen),
Workout/Home/Plan/sheets (main gewinnt), docs.html (Coach-Kapitel war doppelt).
Ungarisch und Thai sind auf main dazugekommen und bekommen die 334 Coach-Strings.
pt-BR-Fingerprint nachgezogen.
api.html was Swagger UI with the site's colors painted over it — a foreign layout in
a black-and-green frame. It is now generated: scripts/build-api-docs.mjs reads
api/openapi.yaml and emits the whole reference as static HTML, so the page needs no
runtime rendering and no CDN bundle. One card per endpoint (method badge, path, one
line of summary) that unfolds into the description, what authentication it wants, the
parameter and body tables and the response codes; the named schemas live once in their
own section and every type links to them. The chapter rail is the site's own .side
markup — the hamburger sheet on a phone, a Contents drawer from 980px up.
The generator is deterministic and re-runnable: node scripts/build-api-docs.mjs
rewrites website/api.html, and the file says so in its first comment. js-yaml is a
build-time devDependency in the repo root; nothing new ships to the browser.
Also drops gym.duarte-santos.ch as an example server from the spec. That instance is
semi-private, and the docs have no business pointing anyone at it: the servers are now
the relative / and a neutral https://opengym.example.com ("your self-hosted instance").
Auf einer CPU mit ~12 Token/s Prompt-Eval ist jedes Payload-Token Wartezeit. Drei volle
Sessions decken genau das Fenster, unter dem der Review-Prompt ohnehin keine strukturellen
Aenderungen erlaubt; aeltere Sessions bleiben als Einzeiler, aggregates zaehlt Stalls
uebers ganze Fenster.
Mit OLLAMA_NUM_PARALLEL=1 gibt es einen Live-Slot, und er gehoert dem letzten Prompt; die
Wiederherstellung grosser Prompts aus dem Cache ist nicht verlaesslich. Der Warmup endete
mit dem Debrief-Prefix und klaute der Review den Slot: Review nach Debrief-Ping 402 s,
nach Review-Ping 26 s. Also: debrief zuerst, review zuletzt.
Der KV-Prefix-Cache eines lokalen Endpunkts stirbt mit dem Ollama-Prozess; der erste Job
danach zahlte still den Kaltstart (~8 min statt ~1). Jetzt pingt der api-Prozess bei Boot
und alle 30 Minuten die Review- und Debrief-Prefixe an den kompatiblen Endpunkt — warm
kostet der Ping ein Token, kalt macht er die teure Lesung genau einmal, auf niemandes Uhr.
Cloud-Provider werden nie gepingt. Und estimateMs nimmt min(Median, letzter Lauf): nach
einer Beschleunigung schleppte der Median drei alte 8-Minuten-Laeufe mit.
Der Prompt ist gesplittet: die Regeln (byteidentisch pro Task) fahren als System-Message,
nur die Payload wechselt — ein llama.cpp/Ollama-Endpunkt trifft damit seinen KV-Prefix-Cache,
Anthropic cached den Block explizit (cache_control ephemeral). Die Payload selbst: kompaktes
JSON statt Einrueckung, volle Saetze nur fuer die letzten fuenf Sessions (aeltere als eine
Zeile pro Uebung; aggregates zaehlt Stalls ohnehin uebers ganze Fenster), Bibliothek als
{id,n,bp} und fuer Reviews auf 100 gedeckelt. ~14.600 Tokens pro Review vorher, ~5.900 jetzt
plus gecachter Prefix. Dazu: response_format json_schema (Fallback json_object, dann ohne,
wie gehabt), temperature 0 nur auf dem kompatiblen Endpunkt, Gemini/Anthropic bekommen die
Regeln ebenfalls als System-Teil. api 142, frontend 799, mcp 36 gruen.
Was der Coach vorgeschlagen hat, verschwindet nach Ja/Nein nicht mehr: die Chat-Zeile traegt
eine Referenz ins Log, das jetzt jede Aenderung samt before/after (auch abgelehnte), Notizen,
Evidenz und bei Plaenen die Routinen behaelt; eine Recap-Karte im Thread und ein Verlauf-
Sheet oeffnen alles wieder. Unter jeder Review liegen die Zahlen aus dem zitierten Fenster —
Sessions, Dauer, Volumen, Koerpergewicht als Kurve mit Ziel, geschaetztes 1RM erste→letzte
Session, Saetze pro Koerperregion — auf dem Geraet gerechnet (lib/coach-insights.js).
Neu: Job-Art `debrief` (eine Session, kein Planeingriff: Score 1–10, lief gut / beobachten /
naechstes Mal; validateDebrief im Core, eigener Prompt), Vergleich mit anderen auf der
Instanz (Admin-Schalter `community`, pro Person Opt-in serverseitig, Mediane ab drei
Teilnehmern, Epley-1RM, lb→kg; auch als `cohort` im Prompt), und "Routine verbessern"
als fokussierte Review. Schnell-Chips ueber dem Composer, deutsche Strings, Doku, Changelog.
Tests: api 136, frontend 799, mcp 36.
Die Review-Regel verbietet strukturelle Aenderungen unter drei Sessions oder einer Woche
Daten — qwen2.5:3b hatte auf Staging nach EINER Session eine Bein-Uebung entfernt, 'weil
keine Beinarbeit'. Dazu die Changelog-Eintraege fuer den Chat, das Admin-Dashboard, den
Job-Timeout und den 160er-Deckel, COACH_JOB_TIMEOUT_MS in .env.example und in AI_COACH.md,
und Schritt 3 der Doku beschreibt den Chat statt des alten Intake-Buttons.
Nodes eingebauter fetch bricht nach fuenf Minuten mit 'fetch failed' ab — egal, welches
Job-Timeout gesetzt ist. Ollama hatte den 8k-Prompt tatsaechlich fertig, die API hatte nur
schon aufgelegt. Jetzt ein undici-Dispatcher, dessen Timeouts aus dem Job-Timeout
abgeleitet sind; AbortController gewinnt weiterhin.
Bisher gingen alle 1.324 Uebungen mit — 10k+ Tokens pro Job, teuer gegen eine Cloud-API
und in den Kontext eines kleinen lokalen Modells passte es gar nicht. Jetzt: Round-Robin
ueber die Koerperteile in Katalogreihenfolge (deterministisch), Plan- und History-Uebungen
werden immer eingepinnt, damit eine Review benennen kann, worueber sie spricht. Dazu
COACH_JOB_TIMEOUT_MS fuer Boxen, auf denen ein lokales Modell laenger als fuenf Minuten
braucht.