d8130443a94b898ea58f9e23b5f8196f7e169cfb
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5d8332d11d |
Coach: the store field the whole UI reads, which was never ported
The entry point in the previous commit was necessary but not sufficient: every Coach surface gates on coachAvailable(config, user), config comes from useStore(s => s.config), and that field does not exist. 4/6 brought the views across and left behind the one line of store they all depend on. So `config` was undefined at all five call sites, the gate was false on every instance, and the feature was invisible everywhere — no row on Plan, and /#/coach redirecting straight back to /home. Enabled, credentialed, a real round trip through the provider passing, and no way in. Indistinguishable from "this instance has no Coach", which is exactly why it survived review: the failure mode is silence. Adds `config: null` and the boot-time fetch, ahead of /api/me because instance capabilities are public and needed whether or not anyone is signed in. Two tests pin it. One asserts the gate opens for the exact shape GET /api/config returns, and stays shut for `undefined` — the bug itself. The other asserts the store source still declares the field and still fetches it; that one reads the file rather than the live store, because useStore touches `document` at import time and cannot be instantiated in this environment. Crude, but it fails on precisely the two edits that broke this. frontend 406/406, build clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
4ee9a2abbf |
Coach: a way in, and instructions for getting there
Two gaps found by deploying the thing and then trying to use it. The Coach had no entry point. Its three routes have existed since the UI landed and nothing in the app linked to them — not the nav, not Home, not Plan, not Settings. The hub's back button already pointed at /plan, so that is where the link was always meant to be. On a configured instance the feature was enabled, credentialed, running, and reachable only by typing the URL. It sits behind the same coachAvailable() predicate every other Coach surface uses, so an instance without the feature sees exactly the Plan screen it saw before. And there were no setup instructions anywhere. This document said the Coach is "off until an admin turns it on" and then never said how to turn it on: ten sections on what it does and why it is safe, nothing on the four steps that get you from a running instance to a working Coach. .env.example has no Coach knobs and SELF_HOSTING mentions it only in the backup caveat, so there was nowhere else to look either. The new section covers building the target that has a runtime in it, minting a token with `claude setup-token`, connecting and testing it on the admin card, and where a user starts. It also warns up front about the thing a multi-profile instance discovers the hard way: in instance mode the credential binds to the first profile that spends it and every other profile is refused by design, so one person gets the Coach and the rest get a refusal. api 72/72, frontend 404/404, build clean, 11 locales in sync. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
ef61df50f2 |
Coach: the Codex provider, and a credential that stays out of your backups
The Codex CLI adapter, its runtime and sandbox in the coach image only, and the one placement decision this PR exists to get right. Codex keeps a refreshable sign-in cache of its own rather than taking a token on the environment, so it needs somewhere durable to write. That is ./coach-auth — a sibling of ./data, never a folder inside it, mounted separately, owned by `coach`, mode 0700. The placement is the point. docs/SELF_HOSTING §5 tells owners to back up with `tar czf … data/`, so anything under ./data lands in every archive people are instructed to produce. Workout history belongs there; a live refresh token does not — it keeps working after that archive is copied to a laptop or a cloud drive. Keeping the cache outside ./data is what lets the backup instructions stay true about what they capture, and §5 now says so explicitly rather than leaving the reader to find out. I got to define this rather than fix it: no Codex path was ever committed here, so the nested layout the fork had never reached this repo. A test asserts the sibling relationship directly, because "outside ./data" is the kind of invariant a later refactor breaks by tidying. bubblewrap and the Codex CLI are added in the coach target only — bubblewrap is a Codex requirement, so an owner who never opted in carries neither. The image job now asserts both directions: present and runnable in the coach image (codex-cli 0.147.0, bubblewrap 0.11.2, /coach-auth as coach:0700), and absent from the default one. Codex is usable through the existing connect route with an API key, which needs no new surface. Its ChatGPT device-code sign-in is not in this PR — see the PR description for what that still needs. api 73/73, frontend 404/404, both image targets built and inspected, 11 locales in sync at 767, library in sync at 1324. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
64fd67cfa8 |
Coach: the eleven locales
139 Coach keys added to each of the eleven locale files — 767 keys each, in sync.
English is the source language and has no file, so a key present in only some
locales falls back mid-sentence with nothing failing anywhere; check-locales
compares the union, which is what makes "in sync" mean something.
`{0}: rep-range ceiling` is the one string with no prior translation to draw on:
it is the counterpart of the rep-range floor label that 2/6's repsMax change
type needed. Each locale's wording is derived from its own existing floor
string rather than translated independently, so the pair reads as a pair.
Deliberately left in English: the twenty-one canned strings in coach-demo.js.
They are the demo build's fake proposal — long-form coaching prose invented to
make the public demo look alive — and they never reach a self-hosted instance;
the module is dynamically imported behind the DEMO flag precisely so none of it
lands in that bundle. Machine-grade translations of six-line paragraphs would
read worse than the English does, and the locale gate is satisfied either way
because the key set stays identical across all eleven.
frontend 404/404, build clean, 11 locales in sync at 767.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
ab1adcdd4f |
Coach: the screens, and the four things they were supposed to say
The Coach hub, the six-screen intake, the proposal review with per-change accept/reject, and the admin card — wired into App.jsx and Admin.jsx. Nothing renders unless the instance offers the Coach, so an admin page on a box that never enabled it is the page it was before. Four gaps I named earlier and owed this PR: CoachProposal had no health disclaimer. The hub and the intake screen both carry one; the screen where changes are actually accepted did not, which is the one place it matters — that tap changes what somebody does with their body next week. It sits immediately above the accept button on both proposal kinds rather than at the top of a scrolling page, so it is on screen at the decision. The admin card never showed whether the privilege drop can be performed. It fails closed, so when it cannot, nothing runs at all, and the admin was left to learn that from a user reporting silence. It now states the verdict, and the server's own reason when the answer is no. Whose account is being spent was not stated anywhere in the UI. Both the admin card and the user's Coach screen have to name it, and that is only true if neither infers it from settings — so coach-api gained the /api/coach/account call that PR 1 built the route for and nothing had used since. The credential UI was wired to a server shape that does not exist: it read d.auth.state, which GET /api/admin/coach never sent, and posted to /auth/setup-token, /auth/key and /auth/disconnect, none of which are routes. Every credential button was dead. The card now uses the connect/disconnect routes from 3/6, and the admin payload carries an auth summary — state, type and account label, never the credential — with `unreadable` as its own state, because ./data restored without its `secret` has a specific cause and a specific fix rather than being "not connected". Left out on purpose: the ChatGPT device-login sheet. It is Codex's, it calls routes that do not exist, and Codex is 6/6 — so it comes back with the provider it belongs to rather than shipping as unreachable UI here. api 72/72, frontend 404/404, build clean, 11 locales in sync. The new strings fall back to English until 5/6 adds them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
49be4e0626 |
Coach: the Claude provider, and an AI runtime you only carry if you ask
The Agent SDK adapter, its dependency, and the packaging that keeps both out of the image an owner gets when they never wanted the Coach. api/Dockerfile builds two targets. The default one runs `npm ci --omit=optional` and ships no AI runtime at all (~158 MB); `--target coach` drops that flag and adds @anthropic-ai/claude-agent-sdk (~455 MB). The SDK's runtime ships as a per-platform package, so on this Alpine base the lockfile resolves the musl build — the kind of thing that only fails on somebody else's machine, which is why the new api-image CI job builds *and runs* both targets rather than merely building them. Both targets now create the unprivileged `coach` user. That is not a Claude detail: canDropPrivileges() fails closed, so without it every job is refused — including the fixture provider that exists so the loop can be walked before an account is connected. The shipped image could not run one. The adapter imports the SDK lazily, so an absent runtime stays an ordinary reportable state rather than a boot crash: check() says so, isConnected() goes false, and /api/config carries no coach key. Four SDK options are what make this safe next to ./data — tools: [] (no Read, no Bash, no Grep), settingSources: [], skills: [], strictMcpConfig. They are one frozen exported object, asserted by value, so re-enabling one is a red build rather than a quiet capability grant. Verified against the SDK's own type definitions rather than from memory. Two things the fork's draft had wrong: SDKResultError carries no `errors` field, so `message.errors?.join()` was dead code and the failure reason now comes from `subtype` and `stop_reason`; and the client-app version string was hardcoded at 1.2.3 two releases after it stopped being true, so it is read from package.json. The credential connect/disconnect routes land here as promised in 2/6 — they serve a credential, and until this PR there was no provider that had one. authMode and the per-profile pair still wait for the side that consumes them. api 72/72 on macOS and on Linux as uid 65534 with the SDK absent; both image targets built and run; library in sync at 1324. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
2c76da270b |
Coach: put coach/ in the api image, which never had it
server.js has imported ./coach/config.js since 1/6, and the Dockerfile copies
only server.js. The published api image therefore cannot start:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/coach/config.js'
imported from /app/server.js
Reproduced by building `api/` at
|
||
|
|
34d41b8e64 |
Coach: the validator, and the apply path it exists to protect
PR 1 stopped at transport and held every answer as `unvalidated`. This closes that seam. validate.js is the gate: a closed list of eighteen change types with no default case, every exercise id resolved against the real catalogue, every target resolved against the plan it claims to be about, and a rationale required on every change. A hostile note in someone's free text can talk a model into saying anything at all; it cannot invent a change type. Its errors join the parse failures on the same single repair round, so a model that named an exercise nobody has is told which one — and a model that cannot be told is a failed job rather than a retry loop. frontend/src/lib/coach.js is the other half: snapshot, apply, revert, and the staleness rules. Applying happens on the client because it is ordinary local editing — offline, synced like everything else, reversible without the server knowing. A change-set is all-or-nothing, and a change aimed at something the user has since edited by hand is disabled with its reason rather than silently overwriting them. Two things the seam was hiding, both from PR 1: hashPlan hashed the pre-1.2.4 field list while canonicalPlan had already learned repsMax, bodyweight and side — so it computed all three and threw them away. A rep ceiling raised by hand fingerprinted as an untouched plan, on exactly the exercises where that ceiling is how progression works. Both runtimes now hash what canonicalPlan reports, with a test per field. `refine` reads pending.bundle, and pending only ever carried `unvalidated`, so `previous` resolved to null every time: the model was asked to refine a plan it had never been shown. It works now, and the fixture echoes whether the previous bundle arrived so a test can tell the difference. The validator also enforces the two rules prompts/common.md states and could not guarantee: unilateral reps are a total across both sides and must be even, and a rep ceiling may not sit below its own floor. "Nothing to change" keeps the reading it came with, on the profile's own record — deliberately not in the instance log, which stays counts and outcomes only. api 65/65, frontend 403/403, build clean, locales in sync, library in sync at 1324 exercises. No new dependency. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
7be3978476 |
Coach: server plumbing, consent, payload boundary, credential model
First of six. Everything here is transport and boundary: a job can run, its answer can be parsed, and nothing yet judges whether that answer is safe to act on. The validator and the apply path are the next PR, and the seam is explicit — jobs.js carries an answer no further than `unvalidated`, and a test pins that so the next PR has something to replace. Whose account pays, settled first because it decides what the rest may be: instance one account in coach.json, for the single-profile instance profile one account per profile, in its own coach-auth-<uid>.json In instance mode the credential binds to the first profile that spends it and every other profile is refused — no job, not a dismissible warning. A warning moves the decision onto whoever clicks past it and the decision is about somebody's personal subscription. A profile credential is deliberately not a field on state-<uid>.json: that blob syncs and travels in the user's export, and a credential in a backup is the mistake we are avoiding, not repeating. openGym does not interpret any provider's terms; it offers the shape that does not need the interpretation and refuses the shape that does. The privilege drop now fails closed. It only ever engaged when the server ran as root, so adding a USER line to the Dockerfile for unrelated hardening would have silently left the provider runtime on the server's uid. On Linux, no drop means no job, and the admin card says so. ./data is no longer sealed with a blanket 0700. It is a host bind mount and this container is root, so sealing it landed on the host as root-owned and took the owner's own directory hostage — backup scripts, jq, the MCP server in issue #19. The files that hold secrets carry 0600 themselves instead, which is what the directory mode was standing in for; db.json gained an explicit mode rather than inheriting umask once the blanket came off. Bodyweight and per-side, folded in rather than deferred: v1.2.4 made `weight` mean *added* load on a bodyweight exercise, so it is 0 on a good session and every load-shaped signal reads flat. Uncorrected, the Coach would have looked at a working push-up progression and proposed adding weight to a push-up. The payload carries bodyweight/side/repsMax, the session reader carries set count, and the prompts say reps then sets are the progression and per-side targets step in twos. coach-parity.test.js pins the server's three copied reading rules against the frontend's originals over a table of configs — modeOf was never actually pinned, and it is the one that was predicted to drift. No AI dependency lands here: api/ still installs @simplewebauthn/server and web-push and nothing else. Jobs run against the in-repo fixture provider, so CI needs no account, no network and no image build. 33 api tests, 361 frontend tests (169 of them parity), locales in sync. |