Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5496fe6
Plan version 2.1.3: an optional host for sharing a record.
mwhitham Nov 23, 2026
0068552
Move to version 2.1.3 with migration step 7 and coach authorship.
mwhitham Nov 23, 2026
f334338
Record D268: a remote write runs on a local working copy.
mwhitham Nov 23, 2026
ff0267e
Record a write's row changes and replay them on another copy.
mwhitham Nov 23, 2026
e50a1c0
Keep host receipts, the access epoch, and the change log in the library.
mwhitham Nov 24, 2026
37f8e20
Add ath-host, an optional program that serves many athletes' records.
mwhitham Nov 24, 2026
42ceb50
Move a record between hosts and back up one athlete at a time.
mwhitham Nov 24, 2026
584e244
Test host failures and large jobs, and send large writes in scripts.
mwhitham Nov 24, 2026
7dc8668
Record D269: a write's rows are recorded with temporary triggers.
mwhitham Nov 24, 2026
5d72bc3
Add connectHost, the npm client for the host API.
mwhitham Nov 24, 2026
a5cc759
Add a starter app that runs a coach's steps through a host.
mwhitham Nov 24, 2026
e469204
Add an example MCP server that works through the host API.
mwhitham Nov 24, 2026
5508fd3
Check athlete IDs and access before storage, and answer retries every…
mwhitham Nov 24, 2026
91468b2
Add the hosting guide for operators and app developers.
mwhitham Nov 24, 2026
ba9f6c3
Add a container definition for ath-host and a guide to running it.
mwhitham Nov 24, 2026
ee8020b
Restrict the host's files and clear them only when serving starts.
mwhitham Nov 24, 2026
726925e
Add a Swift example client for ath-host.
mwhitham Nov 24, 2026
46eb817
Compare retries in a standard form, accept any Bearer case, and answe…
mwhitham Nov 24, 2026
5024862
Record the 2.1.3 build evidence and mark the build done.
mwhitham Nov 24, 2026
63a4a45
Update the hosting guide for moves, backups, restores, and retries.
mwhitham Nov 24, 2026
461c469
Test a move from directory mode to remote mode and back, and keep bac…
mwhitham Nov 24, 2026
01d09ff
Fix the release workflow's tag check, and report a refused release.
mwhitham Nov 23, 2026
d927431
Let an athlete disconnect one app from a record, and connect it again.
mwhitham Nov 24, 2026
6c6046e
Name the app_disconnected error code in the Swift client.
mwhitham Nov 24, 2026
1dcb125
Let the JSON Schema writer put several shapes into one document.
mwhitham Nov 24, 2026
c549538
Generate the host API description from one operation table.
mwhitham Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The container build needs the Rust sources, skills, mappings, and SQL files. Leave
# out build output, installed packages, and Git history, which only make the build
# context larger.
.git
target
**/node_modules
packages/npm/native
packages/npm/schema
packages/npm/skills
packages/npm/pack-output
performance/generated
performance/results/local

# Real health data never enters an image. These rules follow .gitignore. No file the
# build reads has one of these endings.
.private-data
private-validation
validation-data
**/*.ath.json
**/*.ath.sqlite
**/*.ath.sqlite-wal
**/*.ath.sqlite-shm
**/*.fit
**/*.gpx
**/*.tcx
**/*.xml
**/*.zip
**/*.csv
50 changes: 47 additions & 3 deletions .github/workflows/release-cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ jobs:
GH_TOKEN: ${{ github.token }}
PUBLISH: ${{ github.event_name == 'push' || inputs.publish }}
run: |
# The commit a tag names, or nothing when there is no such tag.
# `gh api` prints GitHub's "Not Found" body on standard output for a
# missing ref, so `git/ref/tags/<tag>` cannot tell "no tag" from a tag.
# The matching-refs list is empty instead. Any other failure stops the
# step: `|| return 1` passes the failure out of `$(...)`, where
# `bash -e` does not apply, so an outage is never read as "no tag".
tag_commit() {
local found type sha
found="$(gh api "repos/$GITHUB_REPOSITORY/git/matching-refs/tags/$1" \
--jq ".[] | select(.ref == \"refs/tags/$1\") | .object | \"\\(.type) \\(.sha)\"")" || return 1
[ -n "$found" ] || return 0
type="${found%% *}"
sha="${found#* }"
if [ "$type" = tag ]; then
gh api "repos/$GITHUB_REPOSITORY/git/tags/$sha" --jq .object.sha
else
printf '%s\n' "$sha"
fi
}
version="$(node -p "require('./packages/npm/package.json').version")"
tag="v$version"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
Expand All @@ -67,13 +86,17 @@ jobs:
echo "Full check only; nothing will be released."
exit 0
fi
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::packages/npm/package.json has version $version, which is not X.Y.Z."
exit 1
fi
if [ "$GITHUB_REF_TYPE" = tag ]; then
if [ "$GITHUB_REF_NAME" != "$tag" ]; then
echo "::error::The tag $GITHUB_REF_NAME does not name version $version."
exit 1
fi
elif [ "$GITHUB_REF" = refs/heads/main ]; then
existing="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" --jq .object.sha 2>/dev/null || true)"
existing="$(tag_commit "$tag")"
if [ -n "$existing" ] && [ "$existing" != "$GITHUB_SHA" ]; then
echo "::error::$tag already names commit $existing. Raise the version in packages/npm/package.json to release $GITHUB_SHA."
exit 1
Expand Down Expand Up @@ -150,7 +173,26 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
existing="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG" --jq .object.sha 2>/dev/null || true)"
# The commit a tag names, or nothing when there is no such tag.
# `gh api` prints GitHub's "Not Found" body on standard output for a
# missing ref, so `git/ref/tags/<tag>` cannot tell "no tag" from a tag.
# The matching-refs list is empty instead. Any other failure stops the
# step: `|| return 1` passes the failure out of `$(...)`, where
# `bash -e` does not apply, so an outage is never read as "no tag".
tag_commit() {
local found type sha
found="$(gh api "repos/$GITHUB_REPOSITORY/git/matching-refs/tags/$1" \
--jq ".[] | select(.ref == \"refs/tags/$1\") | .object | \"\\(.type) \\(.sha)\"")" || return 1
[ -n "$found" ] || return 0
type="${found%% *}"
sha="${found#* }"
if [ "$type" = tag ]; then
gh api "repos/$GITHUB_REPOSITORY/git/tags/$sha" --jq .object.sha
else
printf '%s\n' "$sha"
fi
}
existing="$(tag_commit "$TAG")"
if [ -z "$existing" ]; then
gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$TAG" -f sha="$GITHUB_SHA" --silent
echo "Tagged $GITHUB_SHA as $TAG."
Expand All @@ -168,7 +210,9 @@ jobs:
report:
name: Report on the pull request
needs: [version, validate, publish]
if: always() && needs.version.outputs.release == 'true'
# Also when deciding failed, before `release` was set, so a refused
# release is reported too. A run with `publish` off never fails there.
if: always() && (needs.version.outputs.release == 'true' || needs.version.result == 'failure')
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
15 changes: 8 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ Read these before making decisions — they are the project's memory and outrank
4. **`build-history/v2.0.0/spec.md`** — version 2.0.0. The program, the record, and the database share that version. Garmin and Strava imports and calculation skill files are described there.
5. **`build-history/v2.1.0/spec.md`** — version 2.1.0. Mapping files (`mappings/`, `ath import --mapping`), migration step 4, and `field_basis` are described there.
6. **`build-history/v2.1.1/spec.md`** — version 2.1.1: the complete native rebuild, SQL migration step 5, and the npm launcher and JavaScript client. Its `appendix/` holds the 2.1.0 reference evidence (D218): the command inventory, deliberate behavior changes, semantic rules, public API inventory, and test disposition.
7. **`build-history/v2.1.2/spec.md`** — version 2.1.2, the current version: repaired calculation methods, SQL migration step 6, session effort and strength-set fields, and the three kinds of skill (tool, calculation, coaching) with the CrossFit and HYROX coaching skills.
8. **`build-history/*/decisions.md`** — every decision with the alternatives that were rejected and why (D1 onward, numbered continuously across version folders). Do not relitigate these without new information; if a decision is superseded, append a new D-number in the current version's file. Don't rewrite earlier entries. Don't create addendum files.
9. **`build-history/*/appendix/`** — the long-form studies that informed decisions. Link each study from its D-number. Do not move the decision into the appendix, and do not trim the study down to the decision line.
10. **`build-history/*/progress.md`** — what's done and what's next.
11. **`docs/connections.md`** — per-provider data research (what WHOOP/Oura/Garmin/Apple Health each provide via which path).
12. **`SPEC.md`** — the public field-level format reference. The normative model for version 2.1.2 is the Rust model in `src/model/` with its semantic checks. JSON Schema and the npm protocol declarations are generated from it. The Zod schemas in `packages/npm/src/schema.ts` are 2.1.x compatibility code for JavaScript callers (D209); they mirror the Rust model, including the 2.1.2 optional fields (D238, D239), are tested against the Rust validator, and are not where records are designed.
7. **`build-history/v2.1.2/spec.md`** — version 2.1.2: repaired calculation methods, SQL migration step 6, session effort and strength-set fields, and the three kinds of skill (tool, calculation, coaching) with the CrossFit and HYROX coaching skills.
8. **`build-history/v2.1.3/spec.md`** — version 2.1.3, the current version: an optional host program (`ath-host`, in `host/`) for sharing a record, human coach authorship, SQL migration step 7, and two storage backends — native SQLite files, and libSQL databases written through a local working copy (D268, D269). Its `appendix/` holds the hosted-storage study, the hosting experiments, and the build evidence. `docs/hosting.md` is the guide for operators and app developers.
9. **`build-history/*/decisions.md`** — every decision with the alternatives that were rejected and why (D1 onward, numbered continuously across version folders). Do not relitigate these without new information; if a decision is superseded, append a new D-number in the current version's file. Don't rewrite earlier entries. Don't create addendum files.
10. **`build-history/*/appendix/`** — the long-form studies that informed decisions. Link each study from its D-number. Do not move the decision into the appendix, and do not trim the study down to the decision line.
11. **`build-history/*/progress.md`** — what's done and what's next.
12. **`docs/connections.md`** — per-provider data research (what WHOOP/Oura/Garmin/Apple Health each provide via which path).
13. **`SPEC.md`** — the public field-level format reference. The normative model for version 2.1.3 is the Rust model in `src/model/` with its semantic checks. JSON Schema and the npm protocol declarations are generated from it. The Zod schemas in `packages/npm/src/schema.ts` are 2.1.x compatibility code for JavaScript callers (D209); they mirror the Rust model, including the 2.1.2 optional fields (D238, D239) and the 2.1.3 coach author (D255), are tested against the Rust validator, and are not where records are designed.

For v1 storage, IDs, revisions, import behavior, and final schema names, D82–D105 supersede the relevant
parts of D4, D25, D36, D40, D43, D48, D62, D64, and D65. The old decisions still
Expand All @@ -36,7 +37,7 @@ D83's native use of Zod and D93's local libSQL adapter.

- **The two-tier wall:** measured records and athlete reports never mix. Measured records require a `source` reference; athlete reports structurally cannot claim one. Never weaken this.
- **`build-history/` is append-only.** New plans get a new version folder, named for the format version it produces (`v0.2.0/`, `v1.0.0/`). D-numbers continue across folders — D25 follows D24. Within a version, append new decisions to `decisions.md`. Supporting research goes in `appendix/` and is linked from the D-number. Don't rewrite earlier D-numbers or earlier version folders. A draft that was not approved goes, unchanged, into the `appendix/` of the version that replaced it, as `draft-<version>/` (D224).
- **The Rust model is the source of truth.** After changing the model (`src/model/`), a command or its help (`src/cli/`), or a protocol operation (`src/protocol/`), run `ATH_WRITE_GENERATED=1 cargo test --test generated` and commit the regenerated files: JSON Schema in `schema/2.1.2/` and `schema/athleticstandard.schema.json`, `packages/npm/src/generated/protocol.ts`, `skills/athletic-standard/references/cli.md` (D80), and the demo database in `examples/demo-athlete/`. `cargo test --test generated` fails when a committed copy is behind. Generators never rewrite a published historical schema, `spec/sql/`, or `tests/fixtures/`.
- **The Rust model is the source of truth.** After changing the model (`src/model/`), a command or its help (`src/cli/`), a protocol operation (`src/protocol/`), or a host API operation or body (`host/src/operations.rs`, `host/src/shapes.rs`), run `ATH_WRITE_GENERATED=1 cargo test --test generated` and commit the regenerated files: JSON Schema in `schema/2.1.3/` and `schema/athleticstandard.schema.json`, `packages/npm/src/generated/protocol.ts`, `skills/athletic-standard/references/cli.md` (D80), the host API description in `schema/host-api/1/` (D266), and the demo database in `examples/demo-athlete/`. `cargo test --test generated` fails when a committed copy is behind. Generators never rewrite a published historical schema, `spec/sql/`, or `tests/fixtures/`.
- **Naming:** "Athletic Standard" in prose; `athleticstandard` for the npm package, file extension, and version field; `ath` is the CLI command; `AthleticStandard` in code identifiers.
- **Keep the repo impersonal:** no personal objectives, audience/positioning framing, or individual names in committed content.
- **Never commit real health data.** Real exports stay outside Git, including private repositories. Public tests use only the synthetic files listed in `tools/public-data-allowlist.json`; `tests/public_data.rs` enforces the list and the `.gitignore` rules.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ npm test

## Generated files

JSON Schema, the npm protocol module, the skill's command reference, and the demo database are generated from the Rust sources. After changing the record model, a command or its help, or a protocol operation, regenerate them and commit the result:
JSON Schema, the npm protocol module, the skill's command reference, the host API description (`schema/host-api/1/openapi.json`), and the demo database are generated from the Rust sources. After changing the record model, a command or its help, a protocol operation, or a host API operation or body, regenerate them and commit the result:

```sh
ATH_WRITE_GENERATED=1 cargo test --test generated
Expand Down
Loading
Loading