8d3f667c89832685036a3ac893461bfc22816439
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
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> |
||
|
|
de7f25cbe7 |
Coach: der Test-Lauf laeuft, und CI kann die Jobs ueberhaupt erreichen
Drei Sachen, die nie gelaufen sind, weil die CI fuer die api noch nicht existierte. canDropPrivileges faellt unter Linux zu, solange der Prozess nicht root ist und kein `coach`-User im Image steht. Ein CI-Runner ist Linux, laeuft als normaler User und hat keinen `coach` — also hat dort jedes enqueue() refused, und acht Tests waeren mit dem neuen api-Job rot geworden. Die Suite pinnt das Urteil jetzt selbst, statt es vom Host zu erben; der Test, dem die Verweigerung selbst gehoert, pinnt die Gegenrichtung und laeuft damit erstmals wirklich (vorher sprang er auf jedem Host raus, auf dem der Drop zufaellig klappte — und rief require() in einem ESM-Modul auf). testRun() griff auf ein `job`, das in seinem Scope nicht existiert: ReferenceError bei jedem Klick auf "Test the Coach", und weil der Wurf vor dem try lag, blieb jedes Mal ein Temp-Verzeichnis liegen. Ohne Nutzer gibt es kein Profil, das zahlt — im Instance-Modus ist das der gebundene Credential, im Profile-Modus niemand. Danach antwortete die Fixture auf den Test-Prompt mit einem ganzen Trainingsplan, weil ohne Payload-Fence auf 'create' geraten wird. Genau dieser fehlende Fence unterscheidet den Rundlauf von einem echten Job. Dazu zwei Kleinigkeiten: /api/coach/disclosure verriet den Provider an Nicht-Angemeldete, und der Poll, der ein Proposal verfallen laesst, lieferte als einziger kein cap-Feld zurueck. |
||
|
|
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. |