From e31ef2a26a1707c666f161533971a4e7585da123 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 13 Oct 2026 16:12:38 +0000 Subject: [PATCH 1/5] docs: plan contribution-ready public foundation Co-authored-by: Michael Whitham --- build-history/contribution-readiness/plan.md | 925 +++++++++++++++++++ 1 file changed, 925 insertions(+) create mode 100644 build-history/contribution-readiness/plan.md diff --git a/build-history/contribution-readiness/plan.md b/build-history/contribution-readiness/plan.md new file mode 100644 index 00000000..057bd6f6 --- /dev/null +++ b/build-history/contribution-readiness/plan.md @@ -0,0 +1,925 @@ +# Contribution readiness plan + +Status: proposal only. This document does not approve a format, package, or +governance change. + +## 1. Goal + +Make the public Athletic Standard repository safe and practical to build on. +A Swift fitness app should be able to read the SQLite record without running +Node. A TypeScript app should have stable package entry points. Contributors +should have clear ways to add skills, provider importers, and calculations. + +Accepted public work may later ship in `athleticstandard`. A private hosted +product can then adopt it by updating its exact package pin. The public +repository must not depend on private code or private checks. + +This plan preserves the current product boundary: + +- SQLite is the live local record. +- JSON is the complete portable package. +- The two-tier wall remains structural. Measured records require a source. + Athlete reports cannot claim one. +- The public package is not an app, a coach, or medical advice. +- Community entries are not fetched or run merely because they appear in a + catalog. + +## 2. Why this plan is outside a version folder + +`build-history/README.md` names version folders after the format version they +produce. This work has open questions that may produce no format change, an +additive format release, or a breaking release. Giving it a version now would +answer those questions before they are reviewed. + +Once the decisions in section 7 are made: + +1. Append the approved decisions after D114 in the decisions file for the + release that will carry them. +2. Put any approved format work in a folder named for that format version. +3. Add its build steps to that version's `progress.md`. +4. Keep this proposal as the record of the work considered before approval. + +## 3. Verified starting point + +This review uses `main` after pull request +[#14](https://github.com/mwhitham/ath/pull/14) merged. + +| Area | What exists now | Readiness gap | +|---|---|---| +| SQLite versions | `database_metadata.sql_schema_version` and `PRAGMA user_version` are both checked in `src/db/migrate.ts` and `src/db/check.ts`. | `src/db/migrations/001-initial.ts` contains the only schema as a TypeScript string. `migrateDatabase` throws for every version other than 1. There is no standalone SQL contract or forward migration runner. | +| Record schemas | `src/v1/schema.ts` is the public record definition. Generated JSON Schemas live in `schema/1.0.0/`. | The SQL schema and JSON Schema can drift without one check that compares all generated public artifacts. | +| Cross-language use | A standard SQLite file and complete JSON package exist. | There are no language-neutral query examples, conformance vectors, or Swift examples. Direct writers outside Node have no tested transaction recipe. | +| Pure logic | `src/v1/schema.ts` and some calculation helpers are independent of file access. | Database calculations live in `src/db/calculate.ts`. Import, series, model, key, file, and package paths use Node file APIs. The published package requires Node 20. | +| Local API | The CLI exposes named operations. | There is no local HTTP API, OpenAPI document, or stdio MCP server. D7 chose CLI plus Skill over MCP, so MCP requires a new decision rather than being assumed work. | +| Package API | `package.json` already has `.`, `./database`, `./schema`, JSON Schema, and Skill entry points. `tests/v1-package-exports.test.ts` checks them. | `src/index.ts` uses `export *`. There is no public API policy, API reference, deprecation rule, or importer entry point. | +| Importers | Apple Health, WHOOP, and Oura parsing feeds the common `ImportPayload` in `src/import/merge.ts`. | `src/import/index.ts` uses `VENDOR_LABELS` and nested format branches. `ImportPayload` and `mergePayload` are not public. There is no importer interface or registry. | +| Skills | `skill/` contains one versioned Skill. `src/skill.ts` installs and updates that one directory. | There is no selected multi-skill loader. D41 expressly deferred a registry and community distribution, so a new decision is required. | +| CLI and services | Tests can replace model completion and model catalog functions. | `src/program.ts` writes to the console and process state throughout. `src/update.ts`, `src/keyring.ts`, and `src/gateway.ts` hold separate package, keyring, URL, and site constants. | +| Extensions | Strict Zod objects and refusal of unknown package fields prevent silent data loss. | Records have no namespaced extension field. Adding one without tier and preservation rules could weaken the two-tier wall. | +| Contribution checks | Release-only cross-platform and performance workflows exist. | There is no pull-request check on `main`. Pull request #5 adds it, public-data checks, and a first `CONTRIBUTING.md`. It should land before this plan is executed. | +| Repository guidance | `AGENTS.md`, `README.md`, `SPEC.md`, and the build history explain the current release. | There is no contributor-facing architecture guide, extension guide, public API guide, or Swift build-on example. There are no issue templates, pull request template, or `CODEOWNERS`. | +| Site metadata | Repository and issue links are present in `package.json`. | The homepage is `https://athleticstandard.ai`; the intended public site is `https://ath.fit`. | + +The earlier review was wrong in two places: + +- A schema-version table is not wholly missing. `database_metadata` already + carries `sql_schema_version`, with `PRAGMA user_version` as a local mirror. + The missing part is a public SQL migration chain. +- Subpath exports are not wholly missing. The missing part is a stated and + documented stability boundary. + +Additional gaps found during review: + +- Provider import still passes through the old model in `src/schema.ts` before + `src/db/provider-import.ts` maps it into v1 records. This leaves two domain + models in active maintenance. +- `src/import/index.ts#importExport` is an unused 0.x JSON write path. It makes + the supported importer contract unclear. +- `src/models.ts#defaultModelPath` only replaces `.json`, even though the live + file now ends in `.ath.sqlite`. +- The public database handle is intentionally opaque under D104. A direct + Swift writer therefore needs a separately approved write contract. Reading + SQLite does not imply that third-party direct writes are safe. +- The release workflows and the proposed pull-request workflow in #5 use + different Node and action versions. They should share one supported version + policy after #5 lands. + +## 4. Recommended end state + +Use a workspace with small packages, but reach it through compatibility +entry points. Do not make the repository move and public package split one +large pull request. + +```text +spec/ + README.md + json-schema/ + sql/ + migrations/ + openapi/ + conformance/ +packages/ + core/ # @ath/core: schemas, values, pure transforms, API version + store/ # @ath/store: SQLite operations and file adapters + importers/ # @ath/importers: interface, registry, built-in importers + server/ # @ath/server: optional loopback HTTP service +src/ # athleticstandard compatibility facade and ath CLI +community/ + schema/ + skill// + importer// + calculation// + community-catalog.json +``` + +The existing `athleticstandard` npm name and `ath` command remain supported. +The root package re-exports the supported APIs from the workspace packages. +The split packages should start as workspace packages. Publishing them under +the `@ath` scope happens only after package ownership and release policy are +confirmed. + +The `spec/` directory is language-neutral. Generated files may also remain at +their current package paths for compatibility. One generator writes both +locations and one drift check verifies them. + +### 4.1 Contract boundaries + +There are four different contracts. Their versions must not be conflated. + +1. `athleticstandard_version` versions athlete-owned record content. +2. `sql_schema_version` versions the SQLite encoding and migrations. +3. `CORE_API_VERSION` versions the public extension interfaces and test-vector + behavior. +4. The npm package version versions shipped TypeScript and CLI behavior. + +An npm release may change without changing the record format. An additive SQL +index may change the SQL version without changing record content. A breaking +importer interface changes `CORE_API_VERSION`. + +### 4.2 Swift and other non-JavaScript clients + +The first supported route is direct SQLite reading: + +- Publish ordered `.sql` migration files. +- Publish the required SQLite version and compile options. +- Publish stable read views or named reference queries. +- Publish JSON decoding fixtures for `record_revisions.record_json`. +- Add a small Swift example using one library chosen in section 7. + +Direct SQLite writing is a separate promise. Until its transaction, revision, +link, erasure, and migration rules pass cross-language tests, the guide must +label it unsupported. Non-JavaScript writers can use the local HTTP API if +that API is approved. + +### 4.3 Community code and hosted promotion + +The catalog describes reviewed source in this repository. It is not a remote +plugin store. Catalog generation never downloads or runs an entry. + +Skills remain passive instructions. Importers and calculations are compiled +as part of a reviewed package release. The default runtime never loads +arbitrary JavaScript from a community directory. Promotion into the hosted +product follows this order: + +1. Merge the public contribution with synthetic tests. +2. Release an exact public package version. +3. Update the hosted product's exact package pin. +4. Run the hosted product's own checks. + +This keeps the public package as the source reviewed by both products. It also +avoids copying an untracked private variant. + +## 5. Pull request sequence + +Every pull request below is independently mergeable. Each one must preserve +the current `athleticstandard` imports and `ath` commands unless its breaking +change is expressly approved. + +### PR 0 — Land the health-data safeguard first + +Dependency, not duplicate work. + +Scope: + +- Merge [#5](https://github.com/mwhitham/ath/pull/5) after it is rebased. +- Treat its `.github/workflows/ci.yml`, `CONTRIBUTING.md`, + `scripts/check-public-data.ts`, `.gitignore`, and package script as the + starting point. +- Rebase each later pull request after #5. +- Close or replace [#13](https://github.com/mwhitham/ath/pull/13) after its + owner confirms it is superseded by merged #14. Do not copy its old plan. + +Files touched: only the files already owned by #5. + +Acceptance: + +- Pull requests run public-data, type, test, and build checks. +- Branch rules require the check after it exists on `main`. +- Synthetic fixtures remain allowlisted. + +Risk: a stale rebase could drop the v1 fixture exceptions added by #14. +Review the combined `.gitignore` and public-data allowlist. + +### PR 1 — Add contribution governance and public guides + +Scope: + +- Expand #5's `CONTRIBUTING.md` rather than replacing it. +- Add `ARCHITECTURE.md`, `docs/build-on-ath.md`, and + `docs/extensions.md`. +- Add `.github/PULL_REQUEST_TEMPLATE.md`, + `.github/ISSUE_TEMPLATE/bug.yml`, + `.github/ISSUE_TEMPLATE/importer.yml`, + `.github/ISSUE_TEMPLATE/calculation.yml`, and + `.github/ISSUE_TEMPLATE/skill.yml`. +- Add `.github/CODEOWNERS` after owners are confirmed. +- Add DCO sign-off instructions and a sign-off check if section 7 approves + DCO. +- Change `package.json#homepage` and the gateway referrer in + `src/gateway.ts` to `https://ath.fit`. + +Files touched: + +- `CONTRIBUTING.md` +- `ARCHITECTURE.md` +- `docs/build-on-ath.md` +- `docs/extensions.md` +- `.github/**` +- `package.json` +- `src/gateway.ts` +- documentation tests + +Acceptance: + +- A new contributor can identify the record, package, and adapter boundaries. +- Each issue form asks for synthetic data only. +- The pull request template requires fixture safety and generated-file checks. +- DCO and owner checks match the decisions in section 7. +- No private repository name or private process is required by a public + contributor. + +Risk: governance files can block all contributions when owner names or DCO +rules are wrong. Land required checks only after a test pull request passes. + +### PR 2 — Publish the SQLite contract as plain SQL + +Scope: + +- Create `spec/sql/migrations/001-initial.sql` from + `src/db/migrations/001-initial.ts`. +- Keep `database_metadata.sql_schema_version` as the version table. Do not add + a second source of truth. +- Define ordered migration names, transaction rules, rollback behavior, + minimum SQLite version, and the relation to `PRAGMA user_version`. +- Change the Node migration runner to read or import generated SQL rather than + owning a separate string. +- Add a migration ledger test that creates every supported schema from zero + and upgrades every retained prior version. +- Add a drift check between migration files, a newly created database, and the + expected table, index, trigger, and view list. + +Files touched: + +- `spec/sql/README.md` +- `spec/sql/migrations/001-initial.sql` +- `src/db/migrations/**` +- `src/db/migrate.ts` +- `src/db/check.ts` +- `scripts/check-schema-drift.ts` +- `tests/v1-db.test.ts` +- `package.json` + +Acceptance: + +- `sqlite3` can create the schema from published SQL without TypeScript. +- A database made by plain SQL has the same schema as one made by + `createDatabase`. +- The Node runner can migrate from each retained schema version. +- A changed table without a migration or drift update fails CI. +- Metadata and `PRAGMA user_version` agree after each migration. + +Risk: the initial migration currently relies on parameterized metadata inserts +after table creation. The SQL contract must state which values a runner +supplies. It must not embed a fixed database ID or creation time. + +### PR 3 — Add language-neutral conformance fixtures + +Scope: + +- Add `spec/conformance/` with small JSON, SQL, and expected-result fixtures. +- Cover timestamps, UUIDv7 IDs, record revisions, deletions, source links, + dense samples, package order, calculations, and migration results. +- Generate fixtures from fixed inputs. Do not hand-edit the generated outputs. +- Add one runner that checks fixture hashes and expected results. +- Add CI on Linux, macOS, and Windows for the language-neutral contract. Reuse + the release platform matrix rather than creating a conflicting matrix. + +Files touched: + +- `spec/conformance/**` +- `scripts/generate-conformance.ts` +- `scripts/check-conformance.ts` +- `tests/conformance.test.ts` +- `.github/workflows/ci.yml` +- `.github/workflows/release-cross-platform.yml` +- `package.json` + +Acceptance: + +- Another language can implement the tests without importing npm code. +- The fixture generator is deterministic. +- SDNN and RMSSD have separate vectors and expected values. +- Measured and athlete-reported fixtures prove the two-tier wall. +- CI fails on changed generated output. + +Risk: fixtures can accidentally describe current implementation bugs as the +contract. Each vector needs a short rule citation from `SPEC.md` or an approved +decision. + +### PR 4 — Define and document the public core API + +Scope: + +- Add `CORE_API_VERSION` as an exact semantic version. +- Replace root `export *` statements with an explicit reviewed export list + while preserving all currently supported names. +- Add stability markers: stable, experimental, and internal. +- Generate an API reference from the actual exported types. +- Add an API report test that requires review for additions and removals. +- Add deprecation rules and a minimum support window. + +Files touched: + +- `src/index.ts` +- `src/v1/schema.ts` +- `src/db/index.ts` +- `src/core-api.ts` +- `package.json` +- `tests/v1-package-exports.test.ts` +- `docs/api/**` +- API report configuration and checked output + +Acceptance: + +- Existing documented imports compile unchanged. +- Each public export has a stability label and reference entry. +- Deep imports outside `package.json#exports` remain unsupported. +- A public removal or type break fails the API report check. +- `CORE_API_VERSION` is available to manifests and runtime checks. + +Risk: an explicit list can accidentally remove a schema export that a user +already imports. Compare the built package before and after and keep aliases +for supported names. + +### PR 5 — Establish the workspace and extract `@ath/core` + +Scope: + +- Add `pnpm-workspace.yaml` and shared TypeScript/build settings. +- Move schemas, plain values, deterministic JSON helpers, and other no-I/O + logic into `packages/core/`. +- Enforce a no-Node-built-ins rule in `@ath/core`. +- Keep root `athleticstandard` and `athleticstandard/schema` exports as + compatibility wrappers. +- Move algorithm vectors from implementation tests into + `spec/conformance/algorithms/`. + +Files touched: + +- `pnpm-workspace.yaml` +- `packages/core/**` +- `src/index.ts` +- `src/v1/schema.ts` +- `tsup.config.ts` +- `tsconfig*.json` +- `package.json` +- `pnpm-lock.yaml` +- affected tests + +Acceptance: + +- `@ath/core` builds for a browser-like environment with no Node built-ins. +- The current root and schema imports return the same names and behavior. +- The CLI and all tests pass without path aliases that consumers cannot use. +- Algorithm fixtures can be consumed from Swift without npm. + +Risk: package splitting can introduce duplicate Zod copies or declaration +paths that only work in the workspace. Test packed tarballs, not only source +imports. + +### PR 6 — Extract SQLite storage and explicit adapters + +Scope: + +- Move database operations to `packages/store/`. +- Define database, file, clock, random-ID, archive, and secret-store adapters. +- Keep local file security checks in the Node adapter. +- Keep the public database handle opaque for JavaScript callers. +- Add stable read views or reference queries for non-JavaScript readers. +- Keep `athleticstandard/database` as a compatibility wrapper. + +Files touched: + +- `packages/store/**` +- `src/db/**` +- `src/file.ts` +- `src/series.ts` +- `src/keyring.ts` +- `src/index.ts` +- `tsup.config.ts` +- package export tests + +Acceptance: + +- Store domain operations can be tested with injected clock and ID sources. +- Node file, zip, and keyring code is absent from `@ath/core`. +- Existing database imports and CLI behavior remain unchanged. +- Swift can execute every documented read query against the demo database. +- File permission and symbolic-link protections still pass on supported + platforms. + +Risk: file security is platform-specific. An abstract adapter must not turn +owner-only permissions or symbolic-link refusal into optional behavior without +an explicit warning. + +### PR 7 — Define the importer interface and registry + +Scope: + +- Define `Importer`, `ImporterDetection`, `ImportContext`, and + `ImportPayload` in `packages/importers/`. +- Export payload validation and merge operations through a supported subpath. +- Replace `VENDOR_LABELS` and nested format branches in + `src/import/index.ts` with a deterministic registry. +- Register Apple Health, WHOOP, and Oura as built-ins. +- Retire or isolate the unused 0.x `importExport` path. +- Make detection report ambiguity instead of picking the first match. +- Version each importer's matching recipe, preserving D108. + +Files touched: + +- `packages/importers/**` +- `src/import/**` +- `src/db/provider-import.ts` +- `src/schema.ts` +- `package.json` +- `tsup.config.ts` +- `tests/import*.test.ts` +- `tests/v1-provider-import.test.ts` +- provider fixtures under `tests/fixtures/exports/` + +Acceptance: + +- A synthetic importer can be registered in a test without editing a switch. +- Duplicate IDs, ambiguous detection, unsupported versions, and invalid + payloads fail with clear errors. +- `ImportPayload` has one v1 model rather than old hard/soft signal types. +- Existing Apple, WHOOP, and Oura fixture results do not change. +- No importer writes directly to SQLite. + +Risk: moving off the 0.x intermediate model can change IDs or matching keys. +Lock current imports with conformance fixtures before changing the model. + +### PR 8 — Define calculation extensions and portable vectors + +Scope: + +- Separate pure calculation functions from queries in + `src/db/calculate.ts`. +- Define a calculation descriptor with ID, version, accepted input groups, + output record type, and deterministic run function. +- Add a registry for built-in calculations. +- Publish source-separated vectors for summaries, baselines, trends, + correlations, and workout drift. +- Preserve exact input evidence references on every stored result. + +Files touched: + +- `packages/core/src/calculations/**` +- `packages/store/src/calculate.ts` +- `src/db/calculate.ts` +- `spec/conformance/calculations/**` +- `tests/v1-calculate.test.ts` +- `tests/v1-schema.test.ts` +- package exports and API docs + +Acceptance: + +- Pure calculations accept values and return values without a database or + filesystem. +- Query selection remains in the store package. +- Every result can identify exact input record revisions. +- Provider sources never combine in a baseline. +- SDNN and RMSSD remain separate operations and fixtures. + +Risk: a generic calculation interface may hide operation-specific safety +limits. Keep per-operation limits and evidence rules in the descriptor and +tests. + +### PR 9 — Separate the CLI application from reusable operations + +Scope: + +- Introduce an application service that returns typed results and errors. +- Inject output, error output, exit status, clock, configuration, and prompts + into the CLI layer. +- Remove direct `console.*` and `process.exit*` use from reusable operations. +- Centralize package name, command name, Skill name, keyring service, public + site, and model gateway settings. +- Fix `src/models.ts#defaultModelPath` for `.ath.sqlite`. +- Keep gateway and update code out of core and store packages. + +Files touched: + +- `src/program.ts` +- `src/cli.ts` +- `src/config.ts` +- `src/update.ts` +- `src/keyring.ts` +- `src/gateway.ts` +- `src/models.ts` +- command tests and generated `skill/references/cli.md` + +Acceptance: + +- Commands can run in tests without changing global process state. +- JSON command output contains no warnings or progress text on standard output. +- Existing command names, options, exit codes, and text remain covered. +- Branding and service constants have one reviewed source. +- Model settings are placed correctly beside `.ath.sqlite`. + +Risk: changing output plumbing can break scripts that parse JSON or rely on +exit codes. Snapshot both standard output streams and status for each command. + +### PR 10 — Decide and add namespaced record extensions + +Do not start this pull request until the extension decision in section 7 is +approved. + +Scope: + +- Add an optional extension envelope keyed by validated community IDs. +- Set JSON value depth, byte, and collection limits. +- Make an extension inherit the tier and source rules of its parent record. +- Preserve unknown extension values byte-for-byte through SQLite and JSON + export and import. +- Require a published extension schema for entries accepted into this + repository. +- Refuse an extension that attempts to replace core measured quantities, + evidence links, source fields, revisions, or deletion state. +- Add migration and old-reader behavior for the chosen format version. + +Files touched: + +- `packages/core/src/schema/**` +- `src/v1/schema.ts` +- `schema//**` +- `spec/json-schema/**` +- `spec/sql/migrations/**` if storage changes +- `src/db/records.ts` +- `src/db/export.ts` +- `src/db/import-package.ts` +- schema, round-trip, and safety tests +- `SPEC.md` + +Acceptance: + +- Strict validation remains in force outside the extension envelope. +- Measured records still require a source. Athlete reports still cannot claim + one. +- Unknown extension values survive a complete round trip or cause an explicit + refusal. They are never silently dropped. +- Limits prevent deeply nested or oversized extension data. +- An older reader's behavior is documented and tested. + +Risk: arbitrary JSON can become a second ungoverned record model. The envelope +must not be approved until its tier, size, naming, and promotion rules are +clear. + +### PR 11 — Add the community layout and manifest schema + +Scope: + +- Add `community///` for `skill`, `importer`, and `calculation`. +- Add a strict `community/schema/ath.manifest.schema.json`. +- Require these fields: + - `id`, in the form `community.` + - `kind` + - `version`, as one exact semantic version + - `coreRange`, as a supported `CORE_API_VERSION` range + - `tools`, limited to stable tool IDs + - `writeMode`, limited to `read` or `propose` + - `dataGroups`, limited to documented groups + - `requiresRawSeries` + - `license`, as a valid SPDX expression + - `deprecated` + - `replacedBy`, required only when there is a replacement +- Also require `name`, `description`, and a kind-specific `entrypoint`. + Without an entry point, a catalog cannot locate the reviewed source. +- Add one minimal synthetic example for each kind. +- Document that a manifest grants no runtime authority. + +Files touched: + +- `community/schema/ath.manifest.schema.json` +- `community/README.md` +- `community/skill/example/**` +- `community/importer/example/**` +- `community/calculation/example/**` +- `docs/extensions.md` +- manifest validation tests + +Acceptance: + +- Directory kind and ID match the manifest. +- IDs and versions are unique. +- `replacedBy` names an existing compatible item and cannot form a cycle. +- Tool and data-group values come from generated allowlists. +- Every entry has an SPDX-compatible license. +- Examples use only synthetic data and cannot write without confirmation. + +Risk: `coreRange` can claim compatibility that tests do not prove. Catalog +generation must include only versions that pass the contract runner. + +### PR 12 — Add community safety checks and catalog generation + +Scope: + +- Add one contract runner with kind-specific suites. +- Skill checks cover passive language, allowed tool names, `read|propose` + behavior, and fixture prompts. +- Importer checks cover detection, malformed input, resource limits, + deterministic payloads, and no direct writes. +- Calculation checks cover deterministic vectors, source separation, + evidence, and resource limits. +- Add a machine-readable public policy file for blocked capabilities. +- Generate `community/community-catalog.json` from validated manifests. +- Check catalog drift on pull requests and regenerate it during release. +- Extend #5's public-data check instead of creating a second health-data + scanner. + +Files touched: + +- `community/policy.json` +- `community/community-catalog.json` +- `scripts/check-community.ts` +- `scripts/generate-community-catalog.ts` +- `tests/community/**` +- `package.json` +- `.github/workflows/ci.yml` +- release workflows + +Acceptance: + +- A manifest alone cannot cause code execution. +- Catalog order and bytes are deterministic. +- Entries with blocked tools, direct-write claims, real data, network use, or + failed fixtures are excluded and fail CI. +- Each catalog row records item version, compatible core range, license, + deprecation, and fixture result. +- A release fails when the checked catalog is stale. + +Risk: text scanning cannot prove a Skill is safe. Treat it as one check, not a +security boundary. Human review and a narrow runtime permission model remain +required. + +### PR 13 — Support selected multiple skills + +Do not start this pull request until D41 is superseded by an approved decision. + +Scope: + +- Generalize `src/skill.ts` from one shipped directory to a list of selected + skill descriptors. +- Keep `ath skill install` installing only the official bundled Skill by + default. +- Add explicit commands to list and install a named local community Skill. +- Show source, version, permissions, and destination before installation. +- Never fetch a Skill from the network or install every catalog entry. +- Preserve stale-version reporting per installed Skill. + +Files touched: + +- `src/skill.ts` +- `src/program.ts` +- `src/help.ts` +- `skill/**` +- `tests/skill.test.ts` +- `tests/cli.test.ts` +- generated `skill/references/cli.md` + +Acceptance: + +- Current single-Skill behavior is unchanged without new options. +- Installing one Skill does not delete another. +- No read command installs or refreshes a Skill. +- A Skill with an incompatible `coreRange` is refused. +- The user must name each community Skill to install. + +Risk: listing community work can look like endorsement. The command and docs +must distinguish compatibility checks from review or recommendation. + +### PR 14 — Add an optional local HTTP API and OpenAPI + +Do not start this pull request until the API decision in section 7 is approved. + +Scope: + +- Add `@ath/server` over the same application services used by the CLI. +- Publish `spec/openapi/ath-local-v1.yaml`. +- Bind to loopback only by default. +- Require a random session token, deny broad cross-origin access, and emit no + telemetry. +- Separate read routes from preview and confirmed write routes. +- Version routes independently from npm package paths. +- Add request limits and shutdown behavior. + +Files touched: + +- `packages/server/**` +- `spec/openapi/ath-local-v1.yaml` +- `src/application/**` +- `package.json` +- `tsup.config.ts` +- server contract and security tests +- `docs/build-on-ath.md` + +Acceptance: + +- OpenAPI validation passes and generated clients call every documented route. +- The server cannot bind publicly without an explicit unsafe-development + option. +- Write routes use preview then confirmation and preserve database + transactions. +- Tests prove no health data enters logs. +- A Swift client can read the demo database through a generated client. + +Risk: a loopback health-data server is still reachable by local processes and +browser attacks. Token, origin, logging, and bind tests are release gates. + +### PR 15 — Consider stdio MCP separately + +This is optional. HTTP and OpenAPI do not require it. + +Scope if approved: + +- Record a decision that supersedes D7 for a narrow local use. +- Implement stdio MCP as a small adapter over the application service. +- Expose only stable tool IDs already used by community manifests. +- Keep writes as preview or proposal unless a person confirms through the + invoking host. +- Add transcript fixtures for tool listing, reads, proposals, refusals, and + malformed input. + +Files touched: + +- `packages/server/src/mcp/**` or a separate `packages/mcp/**` +- MCP contract fixtures +- `docs/build-on-ath.md` +- package exports and tests + +Acceptance: + +- No network listener starts for stdio use. +- Standard output contains protocol frames only. +- Tools do not bypass CLI or HTTP write rules. +- Tool descriptions remain small enough to justify reversing part of D7. + +Risk: MCP adds another public API and can use much more agent context than a +Skill plus CLI. Skip this pull request unless a concrete host integration +needs it. + +### PR 16 — Publish the Swift example and complete release checks + +Scope: + +- Add a minimal Swift package under `examples/swift-reader/`. +- Use the approved SQLite library and decode at least sources, point + measurements, sleep sessions, and workout sessions. +- Run the language-neutral conformance fixtures from Swift. +- Add package-tarball tests for all published JavaScript entry points. +- Add release notes that map any changed imports, format versions, SQL + versions, and community API versions. + +Files touched: + +- `examples/swift-reader/**` +- `docs/build-on-ath.md` +- `spec/conformance/**` +- `.github/workflows/ci.yml` +- release workflows +- package tarball tests + +Acceptance: + +- The example opens a copied demo database read-only and performs no migration. +- It passes on macOS and Linux Swift runners. +- It does not depend on Node or private services. +- Published tarballs contain all promised spec and community files. +- Release notes contain the migration table from section 6. + +Risk: GRDB and SQLite.swift have different licensing, package, and API tradeoffs. +Choose one before writing the example. Keep raw SQL examples available so the +contract does not depend on that library. + +## 6. Compatibility and migration + +| Change | Breaks existing users? | Migration | +|---|---|---| +| CI, templates, guides, `ath.fit` metadata | No runtime break. New contribution checks can block a pull request. | Rebase and satisfy the documented checks. | +| Plain SQL migration files | No, if generated Node behavior remains identical. | Existing databases stay at SQL version 1 until a later migration exists. | +| Explicit export list | It can break users only if a current public name is missed. | Preserve the built export list. Deprecate before removal. | +| Workspace package split | No for supported `athleticstandard` imports and `ath` commands. | Root compatibility entry points re-export the new packages. New apps may adopt `@ath/*` after publishing is approved. | +| Importer v1 payload | It can break undocumented deep imports. No importer API is currently public. | Publish the new subpath and a mapping guide. Keep one temporary adapter if an actual user is found. | +| CLI output separation | It can break scripts if text, JSON, or exit codes change. | Lock current behavior with stream and status tests. Announce any intentional correction. | +| Optional extension envelope | Yes at the format boundary. Current readers use strict schemas and exact version checks. | Release under the approved format version. Old readers refuse safely. Update `ath`, migrate if SQL changes, then import or open. Never make old readers discard extensions. | +| Community manifests and catalog | No. They are additive and passive. | Existing bundled Skill remains the default. | +| Multi-skill install | No when current defaults are preserved. | Community installs are explicit. Existing installed copies continue to report their own versions. | +| HTTP and OpenAPI | No. It is an optional new process and package. | Clients pin the local API version and regenerate on a documented breaking version. | +| stdio MCP | No when optional. | Hosts opt in to the MCP adapter. CLI plus Skill remains supported. | +| Direct third-party SQLite writes | Yes if declared supported without a full write contract. | Keep writes unsupported until another implementation passes revision, link, erasure, migration, concurrency, and round-trip fixtures. | + +No pull request may silently rewrite an athlete database merely because the npm +package was updated. SQL migration remains an explicit database-open or +explicit migration action with rollback tests. + +## 7. Decisions Mike must make + +These choices change public promises. Record each approved choice as a new +D-number before its implementation pull request. + +1. **Package split:** publish `@ath/core`, `@ath/store`, + `@ath/importers`, and `@ath/server`, or keep them private workspace + packages behind `athleticstandard` at first? + - Recommendation: use private workspace packages first. Publish after + packed-package and release checks are stable. + +2. **Core API version:** should `CORE_API_VERSION` use semantic versions and + start at `1.0.0`? + - Recommendation: yes. `coreRange` then uses normal semantic version + ranges and does not depend on unrelated CLI patch releases. + +3. **SQLite support:** is direct third-party access read-only, or are direct + writes part of the public contract? + - Recommendation: promise reads first. Add writes only after a second + implementation passes the full write suite. + +4. **Swift library:** should the maintained example use GRDB or SQLite.swift? + - Recommendation: choose GRDB for the maintained example, while keeping + the SQL contract library-neutral. + +5. **Extensions:** should extensions live on every record, only selected + records, or in separate linked records? + - Recommendation: use one optional namespaced envelope on selected record + bases only if it can inherit the parent's tier. Do not add arbitrary + top-level records. + +6. **Extension release version:** does the approved envelope ship before the + first public v1 release, as an additive later v1 release, or as v2? + - Recommendation: if v1.0.0 has not been published, settle it before that + release. Otherwise use the existing public version rules and test old + readers' refusal. + +7. **Community execution:** are importers and calculations compiled into a + reviewed release, or can the runtime load third-party code? + - Recommendation: compile reviewed source into releases. Do not add + arbitrary runtime code loading. + +8. **Community endorsement:** does catalog inclusion mean compatibility only, + or project approval? + - Recommendation: state that inclusion means the manifest and tests pass. + It is not coaching, medical review, or a recommendation. + +9. **Multi-skill distribution:** should D41 be superseded to permit explicit + local installation from this repository's catalog? + - Recommendation: yes, but never install by default and never fetch remote + entries automatically. + +10. **Local API:** is the non-JavaScript write route direct SQLite, local HTTP, + or both? + - Recommendation: direct SQLite reads plus local HTTP writes. Defer direct + writes until cross-language proof exists. + +11. **MCP:** is there a concrete local host that needs stdio MCP enough to + supersede part of D7? + - Recommendation: defer it. OpenAPI serves non-JavaScript apps, while the + current Skill plus CLI serves agents. + +12. **Contribution attestation:** require DCO sign-off, a contributor license + agreement, or neither? + - Recommendation: DCO sign-off with the existing MIT license. Do not add a + separate contributor license agreement without legal need. + +13. **Ownership:** who belongs in `.github/CODEOWNERS`, and which areas require + review? + - Recommendation: require owner review for `spec/`, migrations, schemas, + release workflows, and community policy. Confirm GitHub handles before + making the check required. + +14. **Hosted promotion:** do accepted community items ship inside + `athleticstandard`, as separate public packages, or both? + - Recommendation: built-ins ship in the exact-pinned package. Larger or + optional items may use separately exact-pinned public packages after + publishing policy exists. + +## 8. Release gates + +The contribution-ready milestone is complete only when: + +- #5 is merged and its required check is enabled. +- Current imports and CLI behavior have compatibility tests. +- SQL migrations and language-neutral conformance fixtures are public. +- A Swift reader passes the shared fixtures without Node. +- Public APIs have explicit exports, stability labels, and generated docs. +- Importers and calculations use registries with deterministic synthetic + contract tests. +- Community manifests are strict and the catalog is generated. +- Community entries never run merely because they are cataloged. +- Extension behavior preserves the two-tier wall and unknown data. +- Every published package is tested from its packed tarball. +- Release notes state package, core API, SQL, format, and local API versions + separately. + +The local HTTP API, direct third-party writes, and stdio MCP are not all needed +to call the foundation contribution-ready. Their decisions and support levels +must be explicit. From d337a612702a09386269281d4e4ab38c7899ed54 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 13 Oct 2026 16:20:25 +0000 Subject: [PATCH 2/5] docs: tighten contribution plan sequencing Co-authored-by: Michael Whitham --- build-history/contribution-readiness/plan.md | 379 +++++++++++++++---- 1 file changed, 303 insertions(+), 76 deletions(-) diff --git a/build-history/contribution-readiness/plan.md b/build-history/contribution-readiness/plan.md index 057bd6f6..21f0e6f0 100644 --- a/build-history/contribution-readiness/plan.md +++ b/build-history/contribution-readiness/plan.md @@ -116,7 +116,9 @@ The existing `athleticstandard` npm name and `ath` command remain supported. The root package re-exports the supported APIs from the workspace packages. The split packages should start as workspace packages. Publishing them under the `@ath` scope happens only after package ownership and release policy are -confirmed. +confirmed. While they are private workspaces, the root build must bundle their +code into `athleticstandard`; a published package cannot refer to an +unpublished workspace dependency. The `spec/` directory is language-neutral. Generated files may also remain at their current package paths for compatibility. One generator writes both @@ -128,13 +130,14 @@ There are four different contracts. Their versions must not be conflated. 1. `athleticstandard_version` versions athlete-owned record content. 2. `sql_schema_version` versions the SQLite encoding and migrations. -3. `CORE_API_VERSION` versions the public extension interfaces and test-vector - behavior. +3. `CORE_API_VERSION` versions the public extension interfaces. 4. The npm package version versions shipped TypeScript and CLI behavior. An npm release may change without changing the record format. An additive SQL index may change the SQL version without changing record content. A breaking -importer interface changes `CORE_API_VERSION`. +importer interface changes `CORE_API_VERSION`. Each conformance vector names +the contract and version it tests. Record, SQL, core API, and local API vectors +do not share one version. ### 4.2 Swift and other non-JavaScript clients @@ -142,7 +145,8 @@ The first supported route is direct SQLite reading: - Publish ordered `.sql` migration files. - Publish the required SQLite version and compile options. -- Publish stable read views or named reference queries. +- Publish stable read views. Views give clients one versioned read contract + inside SQLite. Example queries alone do not. - Publish JSON decoding fixtures for `record_revisions.record_json`. - Add a small Swift example using one library chosen in section 7. @@ -183,11 +187,11 @@ Scope: - Merge [#5](https://github.com/mwhitham/ath/pull/5) after it is rebased. - Treat its `.github/workflows/ci.yml`, `CONTRIBUTING.md`, - `scripts/check-public-data.ts`, `.gitignore`, and package script as the - starting point. + `scripts/check-public-data.ts`, `.gitignore`, `AGENTS.md`, and package script + as the starting point. - Rebase each later pull request after #5. -- Close or replace [#13](https://github.com/mwhitham/ath/pull/13) after its - owner confirms it is superseded by merged #14. Do not copy its old plan. +- Treat [#13](https://github.com/mwhitham/ath/pull/13) as superseded by merged + #14. It has no remaining change to carry into this plan. Files touched: only the files already owned by #5. @@ -200,13 +204,11 @@ Acceptance: Risk: a stale rebase could drop the v1 fixture exceptions added by #14. Review the combined `.gitignore` and public-data allowlist. -### PR 1 — Add contribution governance and public guides +### PR 1 — Add contribution governance Scope: - Expand #5's `CONTRIBUTING.md` rather than replacing it. -- Add `ARCHITECTURE.md`, `docs/build-on-ath.md`, and - `docs/extensions.md`. - Add `.github/PULL_REQUEST_TEMPLATE.md`, `.github/ISSUE_TEMPLATE/bug.yml`, `.github/ISSUE_TEMPLATE/importer.yml`, @@ -215,23 +217,15 @@ Scope: - Add `.github/CODEOWNERS` after owners are confirmed. - Add DCO sign-off instructions and a sign-off check if section 7 approves DCO. -- Change `package.json#homepage` and the gateway referrer in - `src/gateway.ts` to `https://ath.fit`. Files touched: - `CONTRIBUTING.md` -- `ARCHITECTURE.md` -- `docs/build-on-ath.md` -- `docs/extensions.md` - `.github/**` -- `package.json` -- `src/gateway.ts` - documentation tests Acceptance: -- A new contributor can identify the record, package, and adapter boundaries. - Each issue form asks for synthetic data only. - The pull request template requires fixture safety and generated-file checks. - DCO and owner checks match the decisions in section 7. @@ -241,6 +235,38 @@ Acceptance: Risk: governance files can block all contributions when owner names or DCO rules are wrong. Land required checks only after a test pull request passes. +### PR 1A — Add architecture and build-on guides + +Scope: + +- Add `ARCHITECTURE.md`, `docs/build-on-ath.md`, and + `docs/extensions.md`. +- Document the current package, record, store, importer, CLI, and service + boundaries before moving files. +- Change `package.json#homepage` and the gateway referrer in + `src/gateway.ts` to `https://ath.fit`. + +Files touched: + +- `ARCHITECTURE.md` +- `docs/build-on-ath.md` +- `docs/extensions.md` +- `README.md` +- `package.json` +- `src/gateway.ts` +- documentation tests + +Acceptance: + +- A new contributor can identify each current boundary and its planned + package. +- The build-on guide labels direct SQLite writes unsupported. +- Public links use `ath.fit`. +- No private repository is required to follow the guide. + +Risk: an architecture guide can promise the target before it exists. Mark +current behavior and planned behavior separately. + ### PR 2 — Publish the SQLite contract as plain SQL Scope: @@ -324,9 +350,11 @@ Scope: - Replace root `export *` statements with an explicit reviewed export list while preserving all currently supported names. - Add stability markers: stable, experimental, and internal. +- Define stable tool IDs, data-group IDs, and the `community.` grammar for + later manifests. - Generate an API reference from the actual exported types. - Add an API report test that requires review for additions and removals. -- Add deprecation rules and a minimum support window. +- Apply the deprecation and support policy chosen in section 7. Files touched: @@ -346,6 +374,7 @@ Acceptance: - Deep imports outside `package.json#exports` remain unsupported. - A public removal or type break fails the API report check. - `CORE_API_VERSION` is available to manifests and runtime checks. +- Stable tool IDs and data-group IDs have one generated public list. Risk: an explicit list can accidentally remove a schema export that a user already imports. Compare the built package before and after and keep aliases @@ -387,40 +416,89 @@ Risk: package splitting can introduce duplicate Zod copies or declaration paths that only work in the workspace. Test packed tarballs, not only source imports. -### PR 6 — Extract SQLite storage and explicit adapters +### PR 6 — Extract SQLite storage without behavior changes Scope: - Move database operations to `packages/store/`. -- Define database, file, clock, random-ID, archive, and secret-store adapters. -- Keep local file security checks in the Node adapter. - Keep the public database handle opaque for JavaScript callers. -- Add stable read views or reference queries for non-JavaScript readers. - Keep `athleticstandard/database` as a compatibility wrapper. Files touched: - `packages/store/**` - `src/db/**` -- `src/file.ts` -- `src/series.ts` -- `src/keyring.ts` - `src/index.ts` - `tsup.config.ts` - package export tests Acceptance: -- Store domain operations can be tested with injected clock and ID sources. - Node file, zip, and keyring code is absent from `@ath/core`. - Existing database imports and CLI behavior remain unchanged. -- Swift can execute every documented read query against the demo database. -- File permission and symbolic-link protections still pass on supported - platforms. +- Packed `athleticstandard` contains the store code even while `@ath/store` + remains an unpublished workspace. + +Risk: moving modules can change declaration paths or package initialization. +Compare packed exports and database behavior before and after the move. + +### PR 6A — Add value and platform adapters + +Scope: + +- Define clock, random-ID, database-client, file, archive, and secret-store + adapters. +- Move Node file, zip, and keyring work behind Node adapters. +- Keep local file security checks mandatory in the Node file adapter. +- Inject clock and ID sources into store domain operations. -Risk: file security is platform-specific. An abstract adapter must not turn -owner-only permissions or symbolic-link refusal into optional behavior without -an explicit warning. +Files touched: + +- `packages/store/src/adapters/**` +- `packages/store/src/**` +- `src/file.ts` +- `src/series.ts` +- `src/import/zip.ts` +- `src/keyring.ts` +- adapter and platform tests + +Acceptance: + +- Store operations can be tested with fixed clock and ID sources. +- Pure packages contain no Node built-ins. +- File permission and symbolic-link protections pass on supported platforms. +- A missing security capability produces a refusal or explicit warning. + +Risk: an adapter can make a required security check look optional. Keep the +safe Node adapter as the CLI default and test every refusal. + +### PR 6B — Publish stable SQLite read views + +Scope: + +- Add versioned SQL views for supported cross-language reads. +- Document each view's columns, JSON fields, ordering, and version policy. +- Add drift and query-plan tests against the demo database. +- Keep direct third-party writes unsupported. + +Files touched: + +- `spec/sql/migrations/**` +- `spec/sql/README.md` +- `packages/store/src/migrations/**` +- `tests/v1-db.test.ts` +- `spec/conformance/sql/**` +- `docs/build-on-ath.md` + +Acceptance: + +- Plain `sqlite3` can run every documented read against the demo database. +- View changes require a SQL migration and contract-vector update. +- Raw storage tables remain documented as internal encoding details. +- The views expose source IDs for every measured value. + +Risk: a stable view becomes a long-term contract. Keep the first set small and +limited to real app read needs. ### PR 7 — Define the importer interface and registry @@ -432,7 +510,6 @@ Scope: - Replace `VENDOR_LABELS` and nested format branches in `src/import/index.ts` with a deterministic registry. - Register Apple Health, WHOOP, and Oura as built-ins. -- Retire or isolate the unused 0.x `importExport` path. - Make detection report ambiguity instead of picking the first match. - Version each importer's matching recipe, preserving D108. @@ -453,12 +530,39 @@ Acceptance: - A synthetic importer can be registered in a test without editing a switch. - Duplicate IDs, ambiguous detection, unsupported versions, and invalid payloads fail with clear errors. -- `ImportPayload` has one v1 model rather than old hard/soft signal types. - Existing Apple, WHOOP, and Oura fixture results do not change. - No importer writes directly to SQLite. +Risk: changing detection order can change which importer receives an +ambiguous file. Add ambiguity fixtures before replacing the branches. + +### PR 7A — Remove the 0.x importer model + +Scope: + +- Replace `HardSignalT` and `SoftSignalT` in `ImportPayload` with v1 draft + records. +- Move matching-key creation into the versioned importer result. +- Retire or isolate the unused `src/import/index.ts#importExport` path. +- Remove old model dependencies from `src/db/provider-import.ts`. + +Files touched: + +- `packages/importers/**` +- `src/import/**` +- `src/db/provider-import.ts` +- `src/schema.ts` +- importer conformance fixtures and tests + +Acceptance: + +- `ImportPayload` has one v1 model. +- Existing provider record IDs, matching keys, source facts, and receipts do + not change. +- The supported v1 CLI does not call the old JSON merge path. + Risk: moving off the 0.x intermediate model can change IDs or matching keys. -Lock current imports with conformance fixtures before changing the model. +Lock current results with conformance fixtures before changing the model. ### PR 8 — Define calculation extensions and portable vectors @@ -496,14 +600,10 @@ Risk: a generic calculation interface may hide operation-specific safety limits. Keep per-operation limits and evidence rules in the descriptor and tests. -### PR 9 — Separate the CLI application from reusable operations +### PR 9 — Centralize runtime configuration and fix model paths Scope: -- Introduce an application service that returns typed results and errors. -- Inject output, error output, exit status, clock, configuration, and prompts - into the CLI layer. -- Remove direct `console.*` and `process.exit*` use from reusable operations. - Centralize package name, command name, Skill name, keyring service, public site, and model gateway settings. - Fix `src/models.ts#defaultModelPath` for `.ath.sqlite`. @@ -512,7 +612,6 @@ Scope: Files touched: - `src/program.ts` -- `src/cli.ts` - `src/config.ts` - `src/update.ts` - `src/keyring.ts` @@ -522,11 +621,35 @@ Files touched: Acceptance: +- Branding and service constants have one reviewed source. +- Model settings are placed correctly beside `.ath.sqlite`. +- Existing command output and gateway behavior do not change. + +Risk: changing keyring service names would orphan saved keys. Keep the current +service value as the default and treat any rename as a separate migration. + +### PR 9A — Separate the CLI application from output and process state + +Scope: + +- Introduce an application service that returns typed results and errors. +- Inject output, error output, exit status, clock, configuration, and prompts + into the CLI layer. +- Remove direct `console.*` and `process.exit*` use from reusable operations. + +Files touched: + +- `src/program.ts` +- `src/cli.ts` +- `src/application/**` +- command tests +- generated `skill/references/cli.md` + +Acceptance: + - Commands can run in tests without changing global process state. - JSON command output contains no warnings or progress text on standard output. - Existing command names, options, exit codes, and text remain covered. -- Branding and service constants have one reviewed source. -- Model settings are placed correctly beside `.ath.sqlite`. Risk: changing output plumbing can break scripts that parse JSON or rely on exit codes. Snapshot both standard output streams and status for each command. @@ -541,8 +664,8 @@ Scope: - Add an optional extension envelope keyed by validated community IDs. - Set JSON value depth, byte, and collection limits. - Make an extension inherit the tier and source rules of its parent record. -- Preserve unknown extension values byte-for-byte through SQLite and JSON - export and import. +- Preserve unknown extension values through SQLite and JSON export and import. + Deterministic export may normalize JSON bytes while preserving the value. - Require a published extension schema for entries accepted into this repository. - Refuse an extension that attempts to replace core measured quantities, @@ -587,6 +710,8 @@ Scope: - `kind` - `version`, as one exact semantic version - `coreRange`, as a supported `CORE_API_VERSION` range + - `formatRange`, as the supported `athleticstandard_version` range + - `cliRange` for Skills that call `ath` - `tools`, limited to stable tool IDs - `writeMode`, limited to `read` or `propose` - `dataGroups`, limited to documented groups @@ -617,11 +742,12 @@ Acceptance: - Tool and data-group values come from generated allowlists. - Every entry has an SPDX-compatible license. - Examples use only synthetic data and cannot write without confirmation. +- Skills that call the CLI declare both `coreRange` and `cliRange`. Risk: `coreRange` can claim compatibility that tests do not prove. Catalog generation must include only versions that pass the contract runner. -### PR 12 — Add community safety checks and catalog generation +### PR 12 — Add isolated community contract checks Scope: @@ -633,36 +759,62 @@ Scope: - Calculation checks cover deterministic vectors, source separation, evidence, and resource limits. - Add a machine-readable public policy file for blocked capabilities. -- Generate `community/community-catalog.json` from validated manifests. -- Check catalog drift on pull requests and regenerate it during release. - Extend #5's public-data check instead of creating a second health-data scanner. +- Run executable importer and calculation checks in a process with no secrets, + filtered environment variables, network denial, a read-only checkout, one + temporary writable directory, memory limits, and time limits. Files touched: - `community/policy.json` -- `community/community-catalog.json` - `scripts/check-community.ts` -- `scripts/generate-community-catalog.ts` - `tests/community/**` - `package.json` - `.github/workflows/ci.yml` -- release workflows Acceptance: - A manifest alone cannot cause code execution. -- Catalog order and bytes are deterministic. - Entries with blocked tools, direct-write claims, real data, network use, or failed fixtures are excluded and fail CI. -- Each catalog row records item version, compatible core range, license, - deprecation, and fixture result. -- A release fails when the checked catalog is stale. +- Executable checks cannot read repository secrets, write outside their + temporary directory, or reach the network. Risk: text scanning cannot prove a Skill is safe. Treat it as one check, not a security boundary. Human review and a narrow runtime permission model remain required. +### PR 12A — Generate the release community catalog + +Scope: + +- Generate `community/community-catalog.json` from validated manifests and + passing contract results. +- Check catalog drift on pull requests. +- Regenerate and verify the catalog during release. +- Record item version, core, format, and CLI ranges, license, deprecation, and + fixture result. + +Files touched: + +- `community/community-catalog.json` +- `scripts/generate-community-catalog.ts` +- catalog tests +- `package.json` +- `.github/workflows/ci.yml` +- release workflows + +Acceptance: + +- Catalog order and bytes are deterministic. +- A release fails when the checked catalog is stale. +- Failed or blocked entries never appear in the catalog. +- Catalog generation reads results but never runs entry code. + +Risk: a generated catalog can be mistaken for approval. Include the +compatibility-only meaning in the file metadata and public docs. + ### PR 13 — Support selected multiple skills Do not start this pull request until D41 is superseded by an approved decision. @@ -699,7 +851,7 @@ Acceptance: Risk: listing community work can look like endorsement. The command and docs must distinguish compatibility checks from review or recommendation. -### PR 14 — Add an optional local HTTP API and OpenAPI +### PR 14 — Add an optional read-only local HTTP API and OpenAPI Do not start this pull request until the API decision in section 7 is approved. @@ -710,7 +862,7 @@ Scope: - Bind to loopback only by default. - Require a random session token, deny broad cross-origin access, and emit no telemetry. -- Separate read routes from preview and confirmed write routes. +- Expose read routes only. - Version routes independently from npm package paths. - Add request limits and shutdown behavior. @@ -729,14 +881,44 @@ Acceptance: - OpenAPI validation passes and generated clients call every documented route. - The server cannot bind publicly without an explicit unsafe-development option. -- Write routes use preview then confirmation and preserve database - transactions. - Tests prove no health data enters logs. -- A Swift client can read the demo database through a generated client. +- A generated test client can read the demo database. Risk: a loopback health-data server is still reachable by local processes and browser attacks. Token, origin, logging, and bind tests are release gates. +### PR 14A — Add local HTTP writes after user-presence approval + +Do not start this pull request until section 7 chooses a user-presence rule. + +Scope: + +- Add preview and confirmed write routes over the application service. +- Bind a confirmation to the exact preview, database revision, caller + session, expiry time, and approved user-presence mechanism. +- Preserve one database transaction and current conflict behavior. +- Add replay, stale-preview, cross-session, and concurrent-write tests. + +Files touched: + +- `packages/server/**` +- `spec/openapi/ath-local-v1.yaml` +- `src/application/**` +- server write and security tests +- `docs/build-on-ath.md` + +Acceptance: + +- Calling preview and confirm in sequence is not itself proof of a person. +- A stale, changed, replayed, or cross-session confirmation is refused. +- The approved user-presence mechanism is tested at the boundary that supplies + it. +- Writes have the same result as the matching CLI operation. + +Risk: any client with a bearer token can automate both calls unless a separate +user-presence signal exists. Keep the server read-only until that signal is +approved. + ### PR 15 — Consider stdio MCP separately This is optional. HTTP and OpenAPI do not require it. @@ -769,17 +951,14 @@ Risk: MCP adds another public API and can use much more agent context than a Skill plus CLI. Skip this pull request unless a concrete host integration needs it. -### PR 16 — Publish the Swift example and complete release checks +### PR 16 — Publish the Swift reader example Scope: - Add a minimal Swift package under `examples/swift-reader/`. - Use the approved SQLite library and decode at least sources, point measurements, sleep sessions, and workout sessions. -- Run the language-neutral conformance fixtures from Swift. -- Add package-tarball tests for all published JavaScript entry points. -- Add release notes that map any changed imports, format versions, SQL - versions, and community API versions. +- Run the read-contract subset of the language-neutral fixtures from Swift. Files touched: @@ -787,21 +966,47 @@ Files touched: - `docs/build-on-ath.md` - `spec/conformance/**` - `.github/workflows/ci.yml` -- release workflows -- package tarball tests Acceptance: - The example opens a copied demo database read-only and performs no migration. - It passes on macOS and Linux Swift runners. - It does not depend on Node or private services. -- Published tarballs contain all promised spec and community files. -- Release notes contain the migration table from section 6. Risk: GRDB and SQLite.swift have different licensing, package, and API tradeoffs. Choose one before writing the example. Keep raw SQL examples available so the contract does not depend on that library. +### PR 16A — Complete package and release checks + +Scope: + +- Add packed-tarball tests for every published JavaScript entry point. +- Verify each promised spec, migration, conformance, Skill, and community file + is present in the package that claims to ship it. +- Add a release-note template that maps changed npm, core API, SQL, format, and + local API versions. +- Align pull-request and release workflow runtime versions. + +Files touched: + +- package tarball tests +- `package.json` +- `.github/workflows/ci.yml` +- release workflows +- release-note template + +Acceptance: + +- Tests install packed artifacts in an empty project with no workspace links. +- Published tarballs contain every promised public file. +- Release notes contain the compatibility table from section 6. +- Pull-request and release jobs use the approved Node and package-manager + versions. + +Risk: source tests can pass while packed declarations or workspace dependencies +are missing. The release gate must test only tarballs, not the checkout. + ## 6. Compatibility and migration | Change | Breaks existing users? | Migration | @@ -820,8 +1025,9 @@ contract does not depend on that library. | Direct third-party SQLite writes | Yes if declared supported without a full write contract. | Keep writes unsupported until another implementation passes revision, link, erasure, migration, concurrency, and round-trip fixtures. | No pull request may silently rewrite an athlete database merely because the npm -package was updated. SQL migration remains an explicit database-open or -explicit migration action with rollback tests. +package was updated. The approved trigger must be one of: an explicit +`ath migrate` command, or a confirmed migration during database open. Both +need preview, backup guidance, and rollback tests. ## 7. Decisions Mike must make @@ -845,8 +1051,9 @@ D-number before its implementation pull request. implementation passes the full write suite. 4. **Swift library:** should the maintained example use GRDB or SQLite.swift? - - Recommendation: choose GRDB for the maintained example, while keeping - the SQL contract library-neutral. + - Recommendation: use SQLite.swift if Linux CI remains required. GRDB's + Linux support is community-maintained. Keep the SQL contract + library-neutral either way. 5. **Extensions:** should extensions live on every record, only selected records, or in separate linked records? @@ -902,6 +1109,26 @@ D-number before its implementation pull request. optional items may use separately exact-pinned public packages after publishing policy exists. +15. **SQL migration trigger:** should an old database migrate only through + `ath migrate`, or through a confirmed database-open flow too? + - Recommendation: start with explicit `ath migrate --dry-run` followed by + confirmation. A library caller uses the same preview and apply API. + +16. **SQLite read contract:** are versioned SQL views stable, or are example + queries the only promise? + - Recommendation: make a small set of views stable. Raw tables remain the + versioned encoding and may change through migrations. + +17. **API support policy:** how long must a deprecated stable TypeScript name + remain available? + - Recommendation: keep it through the next major npm release and document + the replacement in the release where deprecation starts. + +18. **HTTP user presence:** what proves a person approved a local HTTP write? + - Recommendation: keep HTTP read-only until an app-owned confirmation + channel can bind approval to one exact preview. Two API calls are not + proof of a person. + ## 8. Release gates The contribution-ready milestone is complete only when: From 9422c06dc0392eba4c76db1265a1fd48122899ea Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 13 Oct 2026 16:21:54 +0000 Subject: [PATCH 3/5] docs: make MCP plan scope explicit Co-authored-by: Michael Whitham --- build-history/contribution-readiness/plan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-history/contribution-readiness/plan.md b/build-history/contribution-readiness/plan.md index 21f0e6f0..bc4eedaf 100644 --- a/build-history/contribution-readiness/plan.md +++ b/build-history/contribution-readiness/plan.md @@ -923,7 +923,7 @@ approved. This is optional. HTTP and OpenAPI do not require it. -Scope if approved: +Scope: - Record a decision that supersedes D7 for a narrow local use. - Implement stdio MCP as a small adapter over the application service. From bda05c9214d93c105b1129fee8457803c8b0db01 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 14 Oct 2026 03:19:51 +0000 Subject: [PATCH 4/5] docs: approve thin contribution foundation Co-authored-by: Michael Whitham --- build-history/contribution-readiness/plan.md | 761 +++++++++---------- 1 file changed, 365 insertions(+), 396 deletions(-) diff --git a/build-history/contribution-readiness/plan.md b/build-history/contribution-readiness/plan.md index bc4eedaf..8bc33504 100644 --- a/build-history/contribution-readiness/plan.md +++ b/build-history/contribution-readiness/plan.md @@ -1,14 +1,34 @@ # Contribution readiness plan -Status: proposal only. This document does not approve a format, package, or -governance change. +Status: direction approved. Section 7 records the approved choices. Each +format choice still gets a D-number in `build-history/v1.0.0/decisions.md` +when its implementation pull request starts. + +## Plain-English summary + +Athletic Standard stays small. +The product is one local SQLite file, a public specification, and the existing CLI and Skill. +The file enforces its important rules even when another program writes it. +Builders may read and write it directly with ordinary SQLite tools. +They do not need a Node service or an Athletic Standard language library. +Agents get machine-readable rules, examples, test vectors, and a build-on-ATH Skill. +The first change adds a safe place for namespaced extension data. +The same change moves critical record rules into SQLite constraints and triggers. +That schema work must land before v1.0.0 is published to npm. +Next come plain SQL migrations, stable read views, and documented writable tables. +Conformance tests then show any app or agent whether its implementation is correct. +The existing npm package gains clear internal boundaries without breaking its public name. +Reviewed skills, importers, and calculations may ship in the main package. +Catalog inclusion means tests passed; it is not an endorsement or hosted approval. +HTTP, MCP, Rust, Swift libraries, and other ports wait until a real builder needs them. ## 1. Goal Make the public Athletic Standard repository safe and practical to build on. -A Swift fitness app should be able to read the SQLite record without running -Node. A TypeScript app should have stable package entry points. Contributors -should have clear ways to add skills, provider importers, and calculations. +A builder should be able to read and write the SQLite record without running +Node or waiting for a maintained language library. A TypeScript app should +have stable package entry points. Contributors should have clear ways to add +skills, provider importers, and calculations. Accepted public work may later ship in `athleticstandard`. A private hosted product can then adopt it by updating its exact package pin. The public @@ -23,20 +43,25 @@ This plan preserves the current product boundary: - The public package is not an app, a coach, or medical advice. - Community entries are not fetched or run merely because they appear in a catalog. +- Forks may add other runtimes or loading models. Official Athletic Standard + and the hosted product run only reviewed code compiled into releases. +- The open-source base stays thin: the file, specification, conformance + vectors, CLI, and Skills. ## 2. Why this plan is outside a version folder `build-history/README.md` names version folders after the format version they -produce. This work has open questions that may produce no format change, an -additive format release, or a breaking release. Giving it a version now would -answer those questions before they are reviewed. +produce. This plan covers repository work as well as the remaining v1 format +work. The approved extension envelope and database-enforced rules belong to +v1.0.0 because npm still publishes 0.4.3. -Once the decisions in section 7 are made: +As implementation begins: -1. Append the approved decisions after D114 in the decisions file for the - release that will carry them. -2. Put any approved format work in a folder named for that format version. -3. Add its build steps to that version's `progress.md`. +1. Append the approved format decisions after D114 in + `build-history/v1.0.0/decisions.md`. +2. Update `build-history/v1.0.0/spec.md` and `progress.md` before the matching + schema implementation lands. +3. Put later format changes in the folder named for the version they produce. 4. Keep this proposal as the record of the work considered before approval. ## 3. Verified starting point @@ -48,16 +73,16 @@ This review uses `main` after pull request |---|---|---| | SQLite versions | `database_metadata.sql_schema_version` and `PRAGMA user_version` are both checked in `src/db/migrate.ts` and `src/db/check.ts`. | `src/db/migrations/001-initial.ts` contains the only schema as a TypeScript string. `migrateDatabase` throws for every version other than 1. There is no standalone SQL contract or forward migration runner. | | Record schemas | `src/v1/schema.ts` is the public record definition. Generated JSON Schemas live in `schema/1.0.0/`. | The SQL schema and JSON Schema can drift without one check that compares all generated public artifacts. | -| Cross-language use | A standard SQLite file and complete JSON package exist. | There are no language-neutral query examples, conformance vectors, or Swift examples. Direct writers outside Node have no tested transaction recipe. | +| Cross-language use | A standard SQLite file and complete JSON package exist. | There are no language-neutral query examples, conformance vectors, stable writable-table contract, or tested direct-write transaction recipe. | | Pure logic | `src/v1/schema.ts` and some calculation helpers are independent of file access. | Database calculations live in `src/db/calculate.ts`. Import, series, model, key, file, and package paths use Node file APIs. The published package requires Node 20. | -| Local API | The CLI exposes named operations. | There is no local HTTP API, OpenAPI document, or stdio MCP server. D7 chose CLI plus Skill over MCP, so MCP requires a new decision rather than being assumed work. | +| Local API | The CLI and Skill expose named operations. | No local HTTP or MCP service is planned. Direct SQLite, the CLI, and Skills are the approved thin public interfaces. | | Package API | `package.json` already has `.`, `./database`, `./schema`, JSON Schema, and Skill entry points. `tests/v1-package-exports.test.ts` checks them. | `src/index.ts` uses `export *`. There is no public API policy, API reference, deprecation rule, or importer entry point. | | Importers | Apple Health, WHOOP, and Oura parsing feeds the common `ImportPayload` in `src/import/merge.ts`. | `src/import/index.ts` uses `VENDOR_LABELS` and nested format branches. `ImportPayload` and `mergePayload` are not public. There is no importer interface or registry. | -| Skills | `skill/` contains one versioned Skill. `src/skill.ts` installs and updates that one directory. | There is no selected multi-skill loader. D41 expressly deferred a registry and community distribution, so a new decision is required. | +| Skills | `skill/` contains one versioned Skill. `src/skill.ts` installs and updates that one directory. | There is no selected multi-skill loader or build-on-ATH Skill. D41 is superseded by the approved explicit local-install rule. | | CLI and services | Tests can replace model completion and model catalog functions. | `src/program.ts` writes to the console and process state throughout. `src/update.ts`, `src/keyring.ts`, and `src/gateway.ts` hold separate package, keyring, URL, and site constants. | | Extensions | Strict Zod objects and refusal of unknown package fields prevent silent data loss. | Records have no namespaced extension field. Adding one without tier and preservation rules could weaken the two-tier wall. | | Contribution checks | Release-only cross-platform and performance workflows exist. | There is no pull-request check on `main`. Pull request #5 adds it, public-data checks, and a first `CONTRIBUTING.md`. It should land before this plan is executed. | -| Repository guidance | `AGENTS.md`, `README.md`, `SPEC.md`, and the build history explain the current release. | There is no contributor-facing architecture guide, extension guide, public API guide, or Swift build-on example. There are no issue templates, pull request template, or `CODEOWNERS`. | +| Repository guidance | `AGENTS.md`, `README.md`, `SPEC.md`, and the build history explain the current release. | There is no contributor-facing architecture guide, extension guide, public API guide, build-on-ATH Skill, issue template, pull request template, or `CODEOWNERS`. | | Site metadata | Repository and issue links are present in `package.json`. | The homepage is `https://athleticstandard.ai`; the intended public site is `https://ath.fit`. | The earlier review was wrong in two places: @@ -77,9 +102,9 @@ Additional gaps found during review: the supported importer contract unclear. - `src/models.ts#defaultModelPath` only replaces `.json`, even though the live file now ends in `.ath.sqlite`. -- The public database handle is intentionally opaque under D104. A direct - Swift writer therefore needs a separately approved write contract. Reading - SQLite does not imply that third-party direct writes are safe. +- The public JavaScript database handle is opaque under D104, but direct + SQLite writes are now approved. Critical correctness rules therefore need + to move from Node-only checks into SQL constraints and triggers. - The release workflows and the proposed pull-request workflow in #5 use different Node and action versions. They should share one supported version policy after #5 lands. @@ -96,14 +121,14 @@ spec/ json-schema/ sql/ migrations/ - openapi/ conformance/ packages/ core/ # @ath/core: schemas, values, pure transforms, API version store/ # @ath/store: SQLite operations and file adapters importers/ # @ath/importers: interface, registry, built-in importers - server/ # @ath/server: optional loopback HTTP service src/ # athleticstandard compatibility facade and ath CLI +skills/ + build-on-ath/ # agent-facing guide for direct SQLite and extension work community/ schema/ skill// @@ -136,42 +161,52 @@ There are four different contracts. Their versions must not be conflated. An npm release may change without changing the record format. An additive SQL index may change the SQL version without changing record content. A breaking importer interface changes `CORE_API_VERSION`. Each conformance vector names -the contract and version it tests. Record, SQL, core API, and local API vectors -do not share one version. +the contract and version it tests. Record, SQL, and core API vectors do not +share one version. -### 4.2 Swift and other non-JavaScript clients +### 4.2 Direct SQLite builders -The first supported route is direct SQLite reading: +Direct SQLite reads and writes are public interfaces: - Publish ordered `.sql` migration files. - Publish the required SQLite version and compile options. - Publish stable read views. Views give clients one versioned read contract inside SQLite. Example queries alone do not. +- Publish a small set of stable writable tables. Every other table is + internal. +- Require every client connection to run `PRAGMA foreign_keys = ON`. +- Back critical cross-table rules with triggers because foreign-key + enforcement is set per connection. +- Enforce field shape with `STRICT`, `CHECK`, `NOT NULL`, `UNIQUE`, foreign + keys, and SQLite JSON functions. +- Enforce the two-tier wall, revision order, current-revision pointers, + deletion state, and protected links in the database. - Publish JSON decoding fixtures for `record_revisions.record_json`. -- Add a small Swift example using one library chosen in section 7. +- Publish transaction recipes and conformance tests for direct writers. -Direct SQLite writing is a separate promise. Until its transaction, revision, -link, erasure, and migration rules pass cross-language tests, the guide must -label it unsupported. Non-JavaScript writers can use the local HTTP API if -that API is approved. +No hand-maintained Swift, Rust, or other language library is required for +v1. Agents and builders can generate one from the machine-readable contract +when needed. ### 4.3 Community code and hosted promotion The catalog describes reviewed source in this repository. It is not a remote plugin store. Catalog generation never downloads or runs an entry. -Skills remain passive instructions. Importers and calculations are compiled -as part of a reviewed package release. The default runtime never loads -arbitrary JavaScript from a community directory. Promotion into the hosted -product follows this order: +Skills remain passive instructions. Official Athletic Standard and the hosted +product run only reviewed importers and calculations compiled into the main +`athleticstandard` package. The default runtime never loads arbitrary code +from a community directory. Forks are free to choose another model. Promotion +into the hosted product follows this order: 1. Merge the public contribution with synthetic tests. 2. Release an exact public package version. 3. Update the hosted product's exact package pin. 4. Run the hosted product's own checks. -This keeps the public package as the source reviewed by both products. It also -avoids copying an untracked private variant. +Catalog inclusion records passed public tests only. It is not endorsement and +does not approve hosted promotion. This keeps the public package as the source +reviewed by both products without copying an untracked private variant. ## 5. Pull request sequence @@ -181,7 +216,9 @@ change is expressly approved. ### PR 0 — Land the health-data safeguard first -Dependency, not duplicate work. +Dependency, not product implementation. It lands first because every later +pull request needs its health-data and CI checks. PR 1 remains the first +product and schema change. Scope: @@ -204,7 +241,66 @@ Acceptance: Risk: a stale rebase could drop the v1 fixture exceptions added by #14. Review the combined `.gitignore` and public-data allowlist. -### PR 1 — Add contribution governance +### PR 1 — Finish the v1 schema before npm publish + +This pull request is the first implementation step. It must merge before +v1.0.0 is published to npm. + +Scope: + +- Add an optional, namespaced, size-limited `extensions` envelope to records. +- Make extension values inherit the parent record's measured or + athlete-reported tier. +- Preserve unknown extension values through SQLite and complete JSON package + round trips. +- Add `STRICT`, `CHECK`, `NOT NULL`, `UNIQUE`, and foreign-key constraints + wherever SQLite can enforce the current v1 rules. +- Add triggers for critical cross-table rules, including: + - measured records require a valid source; + - athlete-reported records cannot claim a source; + - record and revision types agree; + - revision numbers and previous-revision links are valid; + - current-revision pointers identify the current retained revision; + - deletion and erasure state cannot contradict current records; + - protected evidence and result links keep valid record types. +- Validate stored JSON shape with SQLite JSON functions. +- Add direct-SQL tests that bypass Node operations and prove invalid writes + fail in SQLite. +- Append the approved v1 decisions after D114 and update the v1 spec and + progress before implementation. + +Files touched: + +- `build-history/v1.0.0/decisions.md` +- `build-history/v1.0.0/spec.md` +- `build-history/v1.0.0/progress.md` +- `src/v1/schema.ts` +- `schema/1.0.0/**` +- `src/db/migrations/**` +- `src/db/records.ts` +- `src/db/import-package.ts` +- `src/db/export.ts` +- `SPEC.md` +- schema, direct-SQL, package round-trip, and safety tests + +Acceptance: + +- npm still reports 0.4.3 when this work starts. +- The v1 schema includes the extension envelope before v1.0.0 is published. +- Unknown extension values survive database and package round trips. +- Extension limits reject oversized or deeply nested values. +- Direct SQL cannot bypass the two-tier wall or critical revision, deletion, + erasure, and link rules. +- Every measured write still identifies its source. +- Every athlete-reported write is structurally unable to claim a source. +- Generated JSON Schemas and fixtures are current. + +Risk: triggers can reject valid bulk, restore, or migration work when their +transaction ordering differs from normal writes. Test creation, correction, +package restore, provider import, deletion, erasure, and migration through +both Node and direct SQL. + +### PR 1A — Add contribution governance Scope: @@ -214,9 +310,20 @@ Scope: `.github/ISSUE_TEMPLATE/importer.yml`, `.github/ISSUE_TEMPLATE/calculation.yml`, and `.github/ISSUE_TEMPLATE/skill.yml`. -- Add `.github/CODEOWNERS` after owners are confirmed. -- Add DCO sign-off instructions and a sign-off check if section 7 approves - DCO. +- Add `.github/CODEOWNERS` with `@mwhitham` for `spec/`, migrations, schemas, + release workflows, and community policy. Other areas may be reviewed by any + maintainer. +- Use these exact owner patterns: + - `/spec/ @mwhitham` + - `/src/db/migrations/ @mwhitham` + - `/src/v1/schema.ts @mwhitham` + - `/schema/ @mwhitham` + - `/.github/workflows/ @mwhitham` + - `/community/policy.json @mwhitham` +- Do not add a catch-all owner. Normal repository permissions let any + maintainer review every other path. +- Add DCO sign-off instructions and a required sign-off check. +- Keep MIT and do not add a contributor license agreement. Files touched: @@ -228,23 +335,29 @@ Acceptance: - Each issue form asks for synthetic data only. - The pull request template requires fixture safety and generated-file checks. -- DCO and owner checks match the decisions in section 7. +- DCO sign-off is required, MIT remains the license, and there is no + contributor license agreement. +- `@mwhitham` owns the approved protected areas. Other paths do not require + that owner specifically. - No private repository name or private process is required by a public contributor. Risk: governance files can block all contributions when owner names or DCO rules are wrong. Land required checks only after a test pull request passes. -### PR 1A — Add architecture and build-on guides +### PR 1B — Add architecture and build-on guides Scope: - Add `ARCHITECTURE.md`, `docs/build-on-ath.md`, and `docs/extensions.md`. -- Document the current package, record, store, importer, CLI, and service +- Document the current package, record, store, importer, and CLI boundaries before moving files. - Change `package.json#homepage` and the gateway referrer in `src/gateway.ts` to `https://ath.fit`. +- Document extension promotion. An extension becomes an official field only + after repeated real use, stable meaning across builders, clear tier rules, + and a separately approved format change. Files touched: @@ -260,8 +373,13 @@ Acceptance: - A new contributor can identify each current boundary and its planned package. -- The build-on guide labels direct SQLite writes unsupported. +- The build-on guide states that direct SQLite reads and writes are supported. +- It tells clients to enable `PRAGMA foreign_keys` and names the constraints + and triggers that remain authoritative. - Public links use `ath.fit`. +- `docs/extensions.md` explains that linked extension records may be added + later and that popular extensions require a new format decision before + promotion to official fields. - No private repository is required to follow the guide. Risk: an architecture guide can promise the target before it exists. Mark @@ -271,7 +389,7 @@ current behavior and planned behavior separately. Scope: -- Create `spec/sql/migrations/001-initial.sql` from +- Create `spec/sql/migrations/001-initial.sql` from the completed v1 schema in `src/db/migrations/001-initial.ts`. - Keep `database_metadata.sql_schema_version` as the version table. Do not add a second source of truth. @@ -283,6 +401,15 @@ Scope: and upgrades every retained prior version. - Add a drift check between migration files, a newly created database, and the expected table, index, trigger, and view list. +- Add stable SQL read views and document their columns and version policy. +- Name the small set of stable writable tables and their required transaction + order. Mark every other table internal. +- Publish the constraint and trigger contract in machine-readable form. +- Add `ath migrate` with preview, backup, and explicit confirmation for + agents and scripts. +- On interactive database open, preview the migration and ask the person to + confirm. Never migrate in a noninteractive open. +- Create and verify a backup before applying any migration. Files touched: @@ -291,8 +418,12 @@ Files touched: - `src/db/migrations/**` - `src/db/migrate.ts` - `src/db/check.ts` +- `src/program.ts` +- `src/help.ts` - `scripts/check-schema-drift.ts` - `tests/v1-db.test.ts` +- direct-write and migration tests +- `skill/references/cli.md` - `package.json` Acceptance: @@ -303,10 +434,20 @@ Acceptance: - The Node runner can migrate from each retained schema version. - A changed table without a migration or drift update fails CI. - Metadata and `PRAGMA user_version` agree after each migration. +- Plain `sqlite3` can use every stable read view and writable table. +- Direct clients are told to enable `PRAGMA foreign_keys`. +- Critical rules still fail through triggers when a test connection omits that + pragma. +- `ath migrate` previews, backs up, and confirms before writing. +- Interactive open prompts after a backup is ready. Noninteractive open + refuses and points to `ath migrate`. +- A failed migration leaves the original database usable and the backup + verified. Risk: the initial migration currently relies on parameterized metadata inserts after table creation. The SQL contract must state which values a runner -supplies. It must not embed a fixed database ID or creation time. +supplies. It must not embed a fixed database ID or creation time. Backup and +prompt code must also work for WAL files and interrupted migrations. ### PR 3 — Add language-neutral conformance fixtures @@ -314,11 +455,20 @@ Scope: - Add `spec/conformance/` with small JSON, SQL, and expected-result fixtures. - Cover timestamps, UUIDv7 IDs, record revisions, deletions, source links, - dense samples, package order, calculations, and migration results. + dense samples, package order, calculations, direct writes, constraints, + triggers, stable views, writable tables, and migration results. - Generate fixtures from fixed inputs. Do not hand-edit the generated outputs. - Add one runner that checks fixture hashes and expected results. - Add CI on Linux, macOS, and Windows for the language-neutral contract. Reuse the release platform matrix rather than creating a conflicting matrix. +- Add machine-readable contract metadata for required pragmas, stable views, + writable tables, internal tables, constraints, triggers, and transaction + recipes. +- Update `AGENTS.md` with the direct-write and generated-artifact rules. +- Add `skills/build-on-ath/SKILL.md`. It teaches agents to inspect the + machine-readable contract, generate only the client code a project needs, + and run conformance before writing athlete data. +- Package the build-on-ATH Skill without changing the existing Skill path. Files touched: @@ -326,6 +476,9 @@ Files touched: - `scripts/generate-conformance.ts` - `scripts/check-conformance.ts` - `tests/conformance.test.ts` +- `AGENTS.md` +- `skills/build-on-ath/**` +- `docs/build-on-ath.md` - `.github/workflows/ci.yml` - `.github/workflows/release-cross-platform.yml` - `package.json` @@ -336,17 +489,60 @@ Acceptance: - The fixture generator is deterministic. - SDNN and RMSSD have separate vectors and expected values. - Measured and athlete-reported fixtures prove the two-tier wall. +- Direct-write vectors pass without importing npm code. +- The build-on-ATH Skill contains no hand-maintained language client. +- An agent can find required pragmas, stable reads, stable writes, and tests + from the machine-readable contract. - CI fails on changed generated output. Risk: fixtures can accidentally describe current implementation bugs as the contract. Each vector needs a short rule citation from `SPEC.md` or an approved decision. -### PR 4 — Define and document the public core API +### PR 4 — Lock the v1.0.0 npm publish gate Scope: -- Add `CORE_API_VERSION` as an exact semantic version. +- Add packed-tarball tests for every published JavaScript and specification + entry point. +- Verify the v1 extension schema, SQL enforcement, migrations, stable views, + writable tables, conformance files, and both official Skills ship in the + tarball. +- Add a release check that refuses v1.0.0 when any v1 schema or conformance + artifact is stale. +- Align pull-request and release workflow runtime versions. +- Add release notes for direct writes, required pragmas, extensions, and + explicit migrations. + +Files touched: + +- package tarball tests +- `package.json` +- `.github/workflows/ci.yml` +- release workflows +- release-note template + +Acceptance: + +- `npm view athleticstandard version` is still 0.4.3 before this gate lands. +- Tests install the packed artifact in an empty project with no workspace + links. +- The packed v1 package contains the extension envelope and database + enforcement from PR 1. +- It contains the SQL contract, migration commands, conformance vectors, and + build-on-ATH Skill from PRs 2 and 3. +- A stale or missing v1 artifact blocks publish. +- All cross-platform and measured v1 release checks pass before npm publish. + +Risk: the repository already declares package version 1.0.0. A release command +could publish it before the schema gate is complete. Keep publishing manual +and blocked by this required check until PRs 1 through 4 land. + +### PR 5 — Define and document the public core API + +Scope: + +- Add `CORE_API_VERSION = "1.0.0"`. - Replace root `export *` statements with an explicit reviewed export list while preserving all currently supported names. - Add stability markers: stable, experimental, and internal. @@ -354,7 +550,8 @@ Scope: later manifests. - Generate an API reference from the actual exported types. - Add an API report test that requires review for additions and removals. -- Apply the deprecation and support policy chosen in section 7. +- Keep deprecated stable APIs working with warnings until the next major npm + release. That major release may remove them. Files touched: @@ -380,7 +577,7 @@ Risk: an explicit list can accidentally remove a schema export that a user already imports. Compare the built package before and after and keep aliases for supported names. -### PR 5 — Establish the workspace and extract `@ath/core` +### PR 6 — Establish the workspace and extract `@ath/core` Scope: @@ -410,13 +607,13 @@ Acceptance: - `@ath/core` builds for a browser-like environment with no Node built-ins. - The current root and schema imports return the same names and behavior. - The CLI and all tests pass without path aliases that consumers cannot use. -- Algorithm fixtures can be consumed from Swift without npm. +- Algorithm fixtures can be consumed without npm. Risk: package splitting can introduce duplicate Zod copies or declaration paths that only work in the workspace. Test packed tarballs, not only source imports. -### PR 6 — Extract SQLite storage without behavior changes +### PR 6A — Extract SQLite storage without behavior changes Scope: @@ -442,7 +639,7 @@ Acceptance: Risk: moving modules can change declaration paths or package initialization. Compare packed exports and database behavior before and after the move. -### PR 6A — Add value and platform adapters +### PR 6B — Add value and platform adapters Scope: @@ -472,34 +669,6 @@ Acceptance: Risk: an adapter can make a required security check look optional. Keep the safe Node adapter as the CLI default and test every refusal. -### PR 6B — Publish stable SQLite read views - -Scope: - -- Add versioned SQL views for supported cross-language reads. -- Document each view's columns, JSON fields, ordering, and version policy. -- Add drift and query-plan tests against the demo database. -- Keep direct third-party writes unsupported. - -Files touched: - -- `spec/sql/migrations/**` -- `spec/sql/README.md` -- `packages/store/src/migrations/**` -- `tests/v1-db.test.ts` -- `spec/conformance/sql/**` -- `docs/build-on-ath.md` - -Acceptance: - -- Plain `sqlite3` can run every documented read against the demo database. -- View changes require a SQL migration and contract-vector update. -- Raw storage tables remain documented as internal encoding details. -- The views expose source IDs for every measured value. - -Risk: a stable view becomes a long-term contract. Keep the first set small and -limited to real app read needs. - ### PR 7 — Define the importer interface and registry Scope: @@ -654,52 +823,7 @@ Acceptance: Risk: changing output plumbing can break scripts that parse JSON or rely on exit codes. Snapshot both standard output streams and status for each command. -### PR 10 — Decide and add namespaced record extensions - -Do not start this pull request until the extension decision in section 7 is -approved. - -Scope: - -- Add an optional extension envelope keyed by validated community IDs. -- Set JSON value depth, byte, and collection limits. -- Make an extension inherit the tier and source rules of its parent record. -- Preserve unknown extension values through SQLite and JSON export and import. - Deterministic export may normalize JSON bytes while preserving the value. -- Require a published extension schema for entries accepted into this - repository. -- Refuse an extension that attempts to replace core measured quantities, - evidence links, source fields, revisions, or deletion state. -- Add migration and old-reader behavior for the chosen format version. - -Files touched: - -- `packages/core/src/schema/**` -- `src/v1/schema.ts` -- `schema//**` -- `spec/json-schema/**` -- `spec/sql/migrations/**` if storage changes -- `src/db/records.ts` -- `src/db/export.ts` -- `src/db/import-package.ts` -- schema, round-trip, and safety tests -- `SPEC.md` - -Acceptance: - -- Strict validation remains in force outside the extension envelope. -- Measured records still require a source. Athlete reports still cannot claim - one. -- Unknown extension values survive a complete round trip or cause an explicit - refusal. They are never silently dropped. -- Limits prevent deeply nested or oversized extension data. -- An older reader's behavior is documented and tested. - -Risk: arbitrary JSON can become a second ungoverned record model. The envelope -must not be approved until its tier, size, naming, and promotion rules are -clear. - -### PR 11 — Add the community layout and manifest schema +### PR 10 — Add the community layout and manifest schema Scope: @@ -723,6 +847,8 @@ Scope: Without an entry point, a catalog cannot locate the reviewed source. - Add one minimal synthetic example for each kind. - Document that a manifest grants no runtime authority. +- Document that reviewed items approved for official use are compiled into the + main `athleticstandard` package. There is no third-party runtime loader. Files touched: @@ -743,11 +869,12 @@ Acceptance: - Every entry has an SPDX-compatible license. - Examples use only synthetic data and cannot write without confirmation. - Skills that call the CLI declare both `coreRange` and `cliRange`. +- A manifest cannot make an entry loadable at runtime. Risk: `coreRange` can claim compatibility that tests do not prove. Catalog generation must include only versions that pass the contract runner. -### PR 12 — Add isolated community contract checks +### PR 11 — Add isolated community contract checks Scope: @@ -776,7 +903,7 @@ Files touched: Acceptance: - A manifest alone cannot cause code execution. -- Entries with blocked tools, direct-write claims, real data, network use, or +- Entries with blocked tools, undeclared writes, real data, network use, or failed fixtures are excluded and fail CI. - Executable checks cannot read repository secrets, write outside their temporary directory, or reach the network. @@ -785,7 +912,7 @@ Risk: text scanning cannot prove a Skill is safe. Treat it as one check, not a security boundary. Human review and a narrow runtime permission model remain required. -### PR 12A — Generate the release community catalog +### PR 11A — Generate the release community catalog Scope: @@ -795,6 +922,8 @@ Scope: - Regenerate and verify the catalog during release. - Record item version, core, format, and CLI ranges, license, deprecation, and fixture result. +- Mark the catalog as test results only. Catalog presence is not endorsement + or approval for hosted promotion. Files touched: @@ -811,13 +940,15 @@ Acceptance: - A release fails when the checked catalog is stale. - Failed or blocked entries never appear in the catalog. - Catalog generation reads results but never runs entry code. +- Hosted promotion remains a separate review outside catalog generation. Risk: a generated catalog can be mistaken for approval. Include the compatibility-only meaning in the file metadata and public docs. -### PR 13 — Support selected multiple skills +### PR 12 — Support selected multiple skills -Do not start this pull request until D41 is superseded by an approved decision. +D41 is superseded for this narrow case. A community Skill may be installed +only when it is explicitly named. Scope: @@ -851,302 +982,140 @@ Acceptance: Risk: listing community work can look like endorsement. The command and docs must distinguish compatibility checks from review or recommendation. -### PR 14 — Add an optional read-only local HTTP API and OpenAPI +## Later, only on demand -Do not start this pull request until the API decision in section 7 is approved. +Do not build these now: -Scope: +- A local HTTP or OpenAPI service. +- A local stdio MCP server. +- A maintained Swift library or example app. +- A Rust core or maintained Rust library. +- Any other hand-maintained language port. -- Add `@ath/server` over the same application services used by the CLI. -- Publish `spec/openapi/ath-local-v1.yaml`. -- Bind to loopback only by default. -- Require a random session token, deny broad cross-origin access, and emit no - telemetry. -- Expose read routes only. -- Version routes independently from npm package paths. -- Add request limits and shutdown behavior. +A real builder request must name the missing capability before one of these +becomes an active plan. The machine-readable specification and test vectors +let an agent generate a narrow client without waiting for this repository. -Files touched: +A future Rust core remains compatible with this direction. It may ship inside +the npm package and sit behind existing public APIs. The same conformance +vectors must keep its results aligned with other implementations. -- `packages/server/**` -- `spec/openapi/ath-local-v1.yaml` -- `src/application/**` -- `package.json` -- `tsup.config.ts` -- server contract and security tests -- `docs/build-on-ath.md` - -Acceptance: - -- OpenAPI validation passes and generated clients call every documented route. -- The server cannot bind publicly without an explicit unsafe-development - option. -- Tests prove no health data enters logs. -- A generated test client can read the demo database. - -Risk: a loopback health-data server is still reachable by local processes and -browser attacks. Token, origin, logging, and bind tests are release gates. - -### PR 14A — Add local HTTP writes after user-presence approval - -Do not start this pull request until section 7 chooses a user-presence rule. - -Scope: - -- Add preview and confirmed write routes over the application service. -- Bind a confirmation to the exact preview, database revision, caller - session, expiry time, and approved user-presence mechanism. -- Preserve one database transaction and current conflict behavior. -- Add replay, stale-preview, cross-session, and concurrent-write tests. - -Files touched: - -- `packages/server/**` -- `spec/openapi/ath-local-v1.yaml` -- `src/application/**` -- server write and security tests -- `docs/build-on-ath.md` - -Acceptance: - -- Calling preview and confirm in sequence is not itself proof of a person. -- A stale, changed, replayed, or cross-session confirmation is refused. -- The approved user-presence mechanism is tested at the boundary that supplies - it. -- Writes have the same result as the matching CLI operation. - -Risk: any client with a bearer token can automate both calls unless a separate -user-presence signal exists. Keep the server read-only until that signal is -approved. - -### PR 15 — Consider stdio MCP separately - -This is optional. HTTP and OpenAPI do not require it. - -Scope: - -- Record a decision that supersedes D7 for a narrow local use. -- Implement stdio MCP as a small adapter over the application service. -- Expose only stable tool IDs already used by community manifests. -- Keep writes as preview or proposal unless a person confirms through the - invoking host. -- Add transcript fixtures for tool listing, reads, proposals, refusals, and - malformed input. - -Files touched: - -- `packages/server/src/mcp/**` or a separate `packages/mcp/**` -- MCP contract fixtures -- `docs/build-on-ath.md` -- package exports and tests - -Acceptance: - -- No network listener starts for stdio use. -- Standard output contains protocol frames only. -- Tools do not bypass CLI or HTTP write rules. -- Tool descriptions remain small enough to justify reversing part of D7. - -Risk: MCP adds another public API and can use much more agent context than a -Skill plus CLI. Skip this pull request unless a concrete host integration -needs it. +## 6. Compatibility and migration -### PR 16 — Publish the Swift reader example +| Change | Breaks existing users? | Migration | +|---|---|---| +| CI, templates, guides, `ath.fit` metadata | No runtime break. New contribution checks can block a pull request. | Rebase and satisfy the documented checks. | +| Plain SQL migration files and database enforcement | No published v1 user exists yet. Invalid direct writes that previously reached internal tables will now fail. | Regenerate repository fixtures. Future v1 databases use `ath migrate` or confirmed interactive open after backup. Published 0.4.3 files remain outside the v1 migration promise under D101. | +| Explicit export list | It can break users only if a current public name is missed. | Preserve the built export list. A deprecated stable API warns and remains available until the next major release. | +| `CORE_API_VERSION` | No. It adds a separate compatibility version for extensions. | Start at `1.0.0`. Increase it by semantic-version rules when the public extension interface changes. | +| Workspace package split | No for supported `athleticstandard` imports and `ath` commands. | Root compatibility entry points re-export the new packages. New apps may adopt `@ath/*` after publishing is approved. | +| Importer v1 payload | It can break undocumented deep imports. No importer API is currently public. | Publish the new subpath and a mapping guide. Keep one temporary adapter if an actual user is found. | +| CLI output separation | It can break scripts if text, JSON, or exit codes change. | Lock current behavior with stream and status tests. Announce any intentional correction. | +| Optional extension envelope | No published v1 user exists yet because npm latest is 0.4.3. It changes the current unreleased v1 schema. | Land it in v1.0.0 before npm publish. Regenerate schemas and fixtures. Every v1 reader preserves unknown extension values. | +| Community manifests and catalog | No. They are additive and passive. | Existing bundled Skill remains the default. | +| Multi-skill install | No when current defaults are preserved. | Community installs are explicit. Existing installed copies continue to report their own versions. | +| Reviewed community code in `athleticstandard` | No for existing exports. New built-ins are additive. | Update the exact package version. Catalog presence alone does not add runtime code. | +| Direct third-party SQLite writes | This is a new supported interface before the first v1 npm publish. | Enable `PRAGMA foreign_keys`, use only stable writable tables, follow documented transactions, and pass conformance tests. SQLite constraints and triggers reject invalid state. | -Scope: +No pull request may silently rewrite an athlete database merely because the npm +package was updated. Agents and scripts use explicit `ath migrate` with preview +and confirmation. Interactive open may preview and ask a person to confirm. +Both routes create and verify a backup first. Noninteractive open never +migrates. -- Add a minimal Swift package under `examples/swift-reader/`. -- Use the approved SQLite library and decode at least sources, point - measurements, sleep sessions, and workout sessions. -- Run the read-contract subset of the language-neutral fixtures from Swift. +## 7. Approved decisions -Files touched: +These choices are approved. Record the format and runtime choices as new +D-numbers before their implementation pull requests. -- `examples/swift-reader/**` -- `docs/build-on-ath.md` -- `spec/conformance/**` -- `.github/workflows/ci.yml` +1. **Keep the open-source base thin.** It contains the SQLite file, public + specification, conformance vectors, existing CLI, and official Skills. + Builders should not need a service or maintained language library. -Acceptance: +2. **Split internal packages first.** Start with private workspace packages + behind `athleticstandard`. Publish `@ath/*` packages only after a real need + and stable packed-package checks. -- The example opens a copied demo database read-only and performs no migration. -- It passes on macOS and Linux Swift runners. -- It does not depend on Node or private services. +3. **Use semantic core API versions.** `CORE_API_VERSION` starts at `1.0.0`. + Community `coreRange` values use normal semantic version ranges. -Risk: GRDB and SQLite.swift have different licensing, package, and API tradeoffs. -Choose one before writing the example. Keep raw SQL examples available so the -contract does not depend on that library. +4. **Support direct SQLite writes.** Correctness belongs in the database. + Use `STRICT`, `CHECK`, `NOT NULL`, `UNIQUE`, foreign keys, JSON checks, and + triggers. Clients must enable `PRAGMA foreign_keys`. Triggers back critical + rules that must survive a connection that fails to enable it. -### PR 16A — Complete package and release checks +5. **Ship the extension envelope in v1.0.0.** Records receive an optional, + namespaced, size-limited `extensions` envelope. It inherits the parent + record's tier and survives every round trip. A minimal pass-through version + is enough for v1. Separate linked extension records may arrive later as an + additive change. Popular extensions should become official fields. -Scope: +6. **Compile reviewed official code into releases.** Official Athletic + Standard and the hosted product do not load third-party code at runtime. + Forks remain free to add other loading models. -- Add packed-tarball tests for every published JavaScript entry point. -- Verify each promised spec, migration, conformance, Skill, and community file - is present in the package that claims to ship it. -- Add a release-note template that maps changed npm, core API, SQL, format, and - local API versions. -- Align pull-request and release workflow runtime versions. +7. **Treat catalog inclusion as test status only.** It is not endorsement and + does not approve hosted promotion. Hosted promotion is a separate review. -Files touched: +8. **Supersede D41 for explicit local Skill installation.** A community Skill + installs only when named. Nothing auto-installs, and the installer never + fetches a remote Skill. -- package tarball tests -- `package.json` -- `.github/workflows/ci.yml` -- release workflows -- release-note template +9. **Use DCO with MIT and no contributor license agreement.** Every + contribution carries DCO sign-off. -Acceptance: +10. **Set protected owners.** `@mwhitham` owns `spec/`, migrations, schemas, + release workflows, and community policy. Any maintainer may review other + areas. -- Tests install packed artifacts in an empty project with no workspace links. -- Published tarballs contain every promised public file. -- Release notes contain the compatibility table from section 6. -- Pull-request and release jobs use the approved Node and package-manager - versions. +11. **Never migrate silently.** Agents and scripts use `ath migrate` with + preview and confirmation. Interactive open may prompt a person. Every + route creates and verifies a backup before writing. -Risk: source tests can pass while packed declarations or workspace dependencies -are missing. The release gate must test only tarballs, not the checkout. +12. **Publish stable SQL reads and writes.** Stable views are the read + contract. A small documented set of tables is writable. All other tables + are internal. -## 6. Compatibility and migration +13. **Keep deprecated stable APIs until the next major release.** Emit + warnings and document replacements. That major release may remove them. -| Change | Breaks existing users? | Migration | -|---|---|---| -| CI, templates, guides, `ath.fit` metadata | No runtime break. New contribution checks can block a pull request. | Rebase and satisfy the documented checks. | -| Plain SQL migration files | No, if generated Node behavior remains identical. | Existing databases stay at SQL version 1 until a later migration exists. | -| Explicit export list | It can break users only if a current public name is missed. | Preserve the built export list. Deprecate before removal. | -| Workspace package split | No for supported `athleticstandard` imports and `ath` commands. | Root compatibility entry points re-export the new packages. New apps may adopt `@ath/*` after publishing is approved. | -| Importer v1 payload | It can break undocumented deep imports. No importer API is currently public. | Publish the new subpath and a mapping guide. Keep one temporary adapter if an actual user is found. | -| CLI output separation | It can break scripts if text, JSON, or exit codes change. | Lock current behavior with stream and status tests. Announce any intentional correction. | -| Optional extension envelope | Yes at the format boundary. Current readers use strict schemas and exact version checks. | Release under the approved format version. Old readers refuse safely. Update `ath`, migrate if SQL changes, then import or open. Never make old readers discard extensions. | -| Community manifests and catalog | No. They are additive and passive. | Existing bundled Skill remains the default. | -| Multi-skill install | No when current defaults are preserved. | Community installs are explicit. Existing installed copies continue to report their own versions. | -| HTTP and OpenAPI | No. It is an optional new process and package. | Clients pin the local API version and regenerate on a documented breaking version. | -| stdio MCP | No when optional. | Hosts opt in to the MCP adapter. CLI plus Skill remains supported. | -| Direct third-party SQLite writes | Yes if declared supported without a full write contract. | Keep writes unsupported until another implementation passes revision, link, erasure, migration, concurrency, and round-trip fixtures. | +14. **Ship approved community items in `athleticstandard`.** Separate public + packages may come later if a concrete need appears. -No pull request may silently rewrite an athlete database merely because the npm -package was updated. The approved trigger must be one of: an explicit -`ath migrate` command, or a confirmed migration during database open. Both -need preview, backup guidance, and rollback tests. - -## 7. Decisions Mike must make - -These choices change public promises. Record each approved choice as a new -D-number before its implementation pull request. - -1. **Package split:** publish `@ath/core`, `@ath/store`, - `@ath/importers`, and `@ath/server`, or keep them private workspace - packages behind `athleticstandard` at first? - - Recommendation: use private workspace packages first. Publish after - packed-package and release checks are stable. - -2. **Core API version:** should `CORE_API_VERSION` use semantic versions and - start at `1.0.0`? - - Recommendation: yes. `coreRange` then uses normal semantic version - ranges and does not depend on unrelated CLI patch releases. - -3. **SQLite support:** is direct third-party access read-only, or are direct - writes part of the public contract? - - Recommendation: promise reads first. Add writes only after a second - implementation passes the full write suite. - -4. **Swift library:** should the maintained example use GRDB or SQLite.swift? - - Recommendation: use SQLite.swift if Linux CI remains required. GRDB's - Linux support is community-maintained. Keep the SQL contract - library-neutral either way. - -5. **Extensions:** should extensions live on every record, only selected - records, or in separate linked records? - - Recommendation: use one optional namespaced envelope on selected record - bases only if it can inherit the parent's tier. Do not add arbitrary - top-level records. - -6. **Extension release version:** does the approved envelope ship before the - first public v1 release, as an additive later v1 release, or as v2? - - Recommendation: if v1.0.0 has not been published, settle it before that - release. Otherwise use the existing public version rules and test old - readers' refusal. - -7. **Community execution:** are importers and calculations compiled into a - reviewed release, or can the runtime load third-party code? - - Recommendation: compile reviewed source into releases. Do not add - arbitrary runtime code loading. - -8. **Community endorsement:** does catalog inclusion mean compatibility only, - or project approval? - - Recommendation: state that inclusion means the manifest and tests pass. - It is not coaching, medical review, or a recommendation. - -9. **Multi-skill distribution:** should D41 be superseded to permit explicit - local installation from this repository's catalog? - - Recommendation: yes, but never install by default and never fetch remote - entries automatically. - -10. **Local API:** is the non-JavaScript write route direct SQLite, local HTTP, - or both? - - Recommendation: direct SQLite reads plus local HTTP writes. Defer direct - writes until cross-language proof exists. - -11. **MCP:** is there a concrete local host that needs stdio MCP enough to - supersede part of D7? - - Recommendation: defer it. OpenAPI serves non-JavaScript apps, while the - current Skill plus CLI serves agents. - -12. **Contribution attestation:** require DCO sign-off, a contributor license - agreement, or neither? - - Recommendation: DCO sign-off with the existing MIT license. Do not add a - separate contributor license agreement without legal need. - -13. **Ownership:** who belongs in `.github/CODEOWNERS`, and which areas require - review? - - Recommendation: require owner review for `spec/`, migrations, schemas, - release workflows, and community policy. Confirm GitHub handles before - making the check required. - -14. **Hosted promotion:** do accepted community items ship inside - `athleticstandard`, as separate public packages, or both? - - Recommendation: built-ins ship in the exact-pinned package. Larger or - optional items may use separately exact-pinned public packages after - publishing policy exists. - -15. **SQL migration trigger:** should an old database migrate only through - `ath migrate`, or through a confirmed database-open flow too? - - Recommendation: start with explicit `ath migrate --dry-run` followed by - confirmation. A library caller uses the same preview and apply API. - -16. **SQLite read contract:** are versioned SQL views stable, or are example - queries the only promise? - - Recommendation: make a small set of views stable. Raw tables remain the - versioned encoding and may change through migrations. - -17. **API support policy:** how long must a deprecated stable TypeScript name - remain available? - - Recommendation: keep it through the next major npm release and document - the replacement in the release where deprecation starts. - -18. **HTTP user presence:** what proves a person approved a local HTTP write? - - Recommendation: keep HTTP read-only until an app-owned confirmation - channel can bind approval to one exact preview. Two API calls are not - proof of a person. +15. **Defer extra runtimes and services.** Do not build local HTTP, local MCP, + Swift libraries or examples, Rust, or other maintained ports now. A future + Rust core may ship through npm behind existing APIs. Shared vectors keep + any future port honest. ## 8. Release gates The contribution-ready milestone is complete only when: - #5 is merged and its required check is enabled. +- The extension envelope and database-enforced critical rules land before + v1.0.0 is published to npm. - Current imports and CLI behavior have compatibility tests. -- SQL migrations and language-neutral conformance fixtures are public. -- A Swift reader passes the shared fixtures without Node. +- Plain SQL migrations, stable read views, stable writable tables, and + language-neutral conformance fixtures are public. +- Direct writes that bypass Node still cannot violate the two-tier wall, + revision, deletion, erasure, or critical link rules. +- `ath migrate` and interactive migration always preview, confirm, and verify + a backup. Noninteractive open never migrates. +- `AGENTS.md` and the build-on-ATH Skill point agents to the machine-readable + contract and conformance runner. +- `CORE_API_VERSION` is `1.0.0`. +- Deprecated stable APIs warn and remain available until the next major + release. - Public APIs have explicit exports, stability labels, and generated docs. - Importers and calculations use registries with deterministic synthetic contract tests. - Community manifests are strict and the catalog is generated. - Community entries never run merely because they are cataloged. - Extension behavior preserves the two-tier wall and unknown data. -- Every published package is tested from its packed tarball. -- Release notes state package, core API, SQL, format, and local API versions - separately. +- The main `athleticstandard` tarball contains every approved official item + and all promised specification files. +- Release notes state package, core API, SQL, and format versions separately. -The local HTTP API, direct third-party writes, and stdio MCP are not all needed -to call the foundation contribution-ready. Their decisions and support levels -must be explicit. +HTTP, MCP, Rust, Swift, and other maintained ports are not release gates. They +remain deferred until a real builder asks for a capability the thin base does +not provide. From 74f858157761420e3fbe4a7969da086d7a8ccb2c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 14 Oct 2026 03:29:38 +0000 Subject: [PATCH 5/5] docs: record contribution readiness decisions Co-authored-by: Michael Whitham --- build-history/README.md | 7 + .../appendix/contribution-readiness.md} | 33 ++- build-history/v1.0.0/decisions.md | 273 ++++++++++++++++++ build-history/v1.0.0/progress.md | 23 ++ build-history/v1.0.0/spec.md | 122 ++++++++ 5 files changed, 444 insertions(+), 14 deletions(-) rename build-history/{contribution-readiness/plan.md => v1.0.0/appendix/contribution-readiness.md} (97%) diff --git a/build-history/README.md b/build-history/README.md index 344b7894..10abbde2 100644 --- a/build-history/README.md +++ b/build-history/README.md @@ -29,3 +29,10 @@ build-history/ ## Why Specs written in chat threads and planning sessions evaporate. Six months from now, "why is there no MCP server?" or "why TypeScript?" should be answerable by reading this folder, not by archaeology. Each version's `decisions.md` records the alternatives that were considered and rejected, because the rejected options are the part everyone forgets. Each version's `appendix/` holds the long-form research those decisions rest on. + +## Current v1.0.0 record + +- [Build specification](v1.0.0/spec.md) +- [Decisions](v1.0.0/decisions.md) +- [Progress](v1.0.0/progress.md) +- [Contribution readiness plan](v1.0.0/appendix/contribution-readiness.md) diff --git a/build-history/contribution-readiness/plan.md b/build-history/v1.0.0/appendix/contribution-readiness.md similarity index 97% rename from build-history/contribution-readiness/plan.md rename to build-history/v1.0.0/appendix/contribution-readiness.md index 8bc33504..cd824ef7 100644 --- a/build-history/contribution-readiness/plan.md +++ b/build-history/v1.0.0/appendix/contribution-readiness.md @@ -1,8 +1,8 @@ # Contribution readiness plan -Status: direction approved. Section 7 records the approved choices. Each -format choice still gets a D-number in `build-history/v1.0.0/decisions.md` -when its implementation pull request starts. +Status: approved. D115–D128 in `../decisions.md` record the choices. The v1 +format changes are appended to `../spec.md`, and their work is tracked in +`../progress.md`. ## Plain-English summary @@ -48,21 +48,21 @@ This plan preserves the current product boundary: - The open-source base stays thin: the file, specification, conformance vectors, CLI, and Skills. -## 2. Why this plan is outside a version folder +## 2. Why this plan is in the v1 appendix `build-history/README.md` names version folders after the format version they produce. This plan covers repository work as well as the remaining v1 format work. The approved extension envelope and database-enforced rules belong to -v1.0.0 because npm still publishes 0.4.3. +v1.0.0 because npm still publishes 0.4.3. The full plan is supporting material +for D115–D128, so the repository process places it in the v1 appendix. -As implementation begins: +The approved work follows the repository process: -1. Append the approved format decisions after D114 in - `build-history/v1.0.0/decisions.md`. -2. Update `build-history/v1.0.0/spec.md` and `progress.md` before the matching - schema implementation lands. -3. Put later format changes in the folder named for the version they produce. -4. Keep this proposal as the record of the work considered before approval. +1. D115–D128 are appended after D114 in `../decisions.md`. +2. The v1 format amendment is appended to `../spec.md`. +3. Pending pre-publish work is appended to `../progress.md`. +4. Put later format changes in the folder named for the version they produce. +5. Keep this appendix as the long-form plan linked from each decision. ## 3. Verified starting point @@ -318,10 +318,14 @@ Scope: - `/src/db/migrations/ @mwhitham` - `/src/v1/schema.ts @mwhitham` - `/schema/ @mwhitham` - - `/.github/workflows/ @mwhitham` + - `/.github/workflows/release-*.yml @mwhitham` - `/community/policy.json @mwhitham` - Do not add a catch-all owner. Normal repository permissions let any maintainer review every other path. +- D123 records a narrow exception to the impersonal-repository rule. GitHub + owner handles are allowed only in `CODEOWNERS` and in text that explains + that file. A real account is required because this repository has no team + handle. - Add DCO sign-off instructions and a required sign-off check. - Keep MIT and do not add a contributor license agreement. @@ -1066,7 +1070,8 @@ D-numbers before their implementation pull requests. 10. **Set protected owners.** `@mwhitham` owns `spec/`, migrations, schemas, release workflows, and community policy. Any maintainer may review other - areas. + areas. D123 records the narrow process exception that permits this GitHub + handle only for `CODEOWNERS` and text that explains it. 11. **Never migrate silently.** Agents and scripts use `ath migrate` with preview and confirmation. Interactive open may prompt a person. Every diff --git a/build-history/v1.0.0/decisions.md b/build-history/v1.0.0/decisions.md index 29728dc9..7fbc356e 100644 --- a/build-history/v1.0.0/decisions.md +++ b/build-history/v1.0.0/decisions.md @@ -997,3 +997,276 @@ Rejected alternatives: - **Test only 100,000 records.** Rejected because the 3-million-record run is large enough to expose unsafe query bounds and remains practical as a separate release job. + +## D115. Split internal workspace packages before publishing them + +The repository first splits pure logic, storage, and importers into private workspace +packages behind the existing `athleticstandard` package. The root package bundles +their code and keeps the current package name, CLI, and supported entry points. +Scoped `@ath/*` packages are published only after a concrete need and packed-package +tests prove they work outside the workspace. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Publish every workspace package immediately.** Rejected because it creates more + versioned public APIs before their boundaries have been exercised. +- **Keep one source package forever.** Rejected because pure logic, storage, and + importers need enforceable internal boundaries. + +## D116. Direct third-party SQLite writes are supported and SQLite enforces critical rules + +Builders may write Athletic Standard databases directly with SQLite. They do not +need the Node library, CLI, a local service, or a maintained language binding. +Every client must enable `PRAGMA foreign_keys = ON`. + +Critical correctness rules also use database constraints and triggers. The schema +uses `STRICT` tables, `CHECK`, `NOT NULL`, `UNIQUE`, foreign keys, and SQLite JSON +functions. Triggers enforce the two-tier wall, record and revision agreement, +revision and deletion rules, current-revision pointers, and protected links even +when application code is bypassed. Conformance tests execute direct SQL rather than +assuming the Node operations are the only writer. + +D104 still keeps the JavaScript database handle opaque and keeps arbitrary SQL out +of the JavaScript API. This decision supersedes any reading of D104 that direct SQL +writes by another implementation are unsupported. It also strengthens D83: SQLite +is a public encoding with enforced write rules, while Zod remains the logical record +definition. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Require every writer to use the Node package.** Rejected because the SQLite file + is the cross-language foundation. +- **Document rules without enforcing them in SQLite.** Rejected because another + writer could then create a file the official reader cannot safely interpret. +- **Rely on foreign keys alone.** Rejected because foreign-key enforcement is a + per-connection setting and does not express every critical cross-table rule. + +## D117. Official runtimes execute only reviewed code compiled into releases + +Official Athletic Standard and the hosted product do not load third-party importer +or calculation code at runtime. Code approved for official use is reviewed, tested, +and compiled into a release. Forks may choose another loading model. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Load code from the community catalog.** Rejected because catalog metadata and + compatibility tests are not a runtime trust boundary. +- **Forbid plugin loading in forks.** Rejected because forks control their own + runtime and risk policy. + +## D118. v1 records have a namespaced extension envelope + +Every v1 record may carry an optional, namespaced, size-limited `extensions` +envelope. Extension values inherit the parent record's measured, +athlete-reported, or authored class. An extension cannot add a source to an athlete +report or remove the source requirement from measured data. + +All v1 readers, SQLite writes, JSON import, and JSON export preserve extension +values. A minimal pass-through implementation is sufficient for v1.0.0. It must land +before v1.0.0 is published to npm; npm still publishes 0.4.3. This partially +supersedes D91 for the defined envelope: unknown namespaced values inside a valid +envelope are preserved rather than discarded. D91's unknown-field refusal remains +in force outside the envelope. + +Separate linked extension record types may be added later without replacing the +envelope. An extension becomes an official field only after repeated use, stable +meaning across builders, clear tier rules, and a separately approved format change. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Wait until after v1.0.0.** Rejected because strict v1 readers would otherwise + need a format change before builders have any safe extension point. +- **Allow arbitrary unknown top-level fields.** Rejected because strict validation + would no longer distinguish an extension from a typo or unsupported format. +- **Start with separate linked extension records only.** Rejected because a + pass-through envelope is the smaller useful v1 foundation. + +## D119. Community catalog inclusion means tests passed, not endorsement + +An entry appears in `community-catalog.json` only after its manifest and synthetic +contract tests pass. Inclusion does not mean the project recommends its training +advice, accepts medical claims, approves its security for every use, or approves it +for the hosted product. Hosted promotion is a separate review. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Treat catalog inclusion as project approval.** Rejected because compatibility + checks cannot establish coaching quality or suitability for every athlete. +- **Promote every catalog entry into the hosted product.** Rejected because hosted + use has a separate risk and product review. + +## D120. Named local community Skills may be installed explicitly + +A community Skill may be installed only when the person or agent names it. The +official bundled Skill remains the default. Read commands never install or refresh +a Skill. The installer never fetches a remote Skill and never installs the whole +catalog. + +This supersedes D41's decision not to build community distribution. D41's concern +about implied endorsement remains and is answered by D119. D79 remains in force for +the official bundled Skill and its current install locations. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Auto-install compatible Skills.** Rejected because a read or setup command + should not silently add agent instructions. +- **Fetch Skills from catalog URLs.** Rejected because remote fetching adds a code + and content supply chain that the local repository does not need. +- **Keep community installation entirely out of the CLI.** Rejected because an + explicit local install removes repeated manual copying without implying approval. + +## D121. The public foundation stays thin until a builder needs more + +The v1 public foundation is the SQLite file, public specification, conformance +vectors, existing CLI, and official Skills. It does not add a local HTTP service, a +local MCP server, a maintained Swift library or example, a Rust core, or another +maintained language port now. + +D7 remains in force: CLI plus Skill is the agent interface, and MCP is not added. +A future Rust core may ship inside the npm package behind existing APIs. Any future +service or port must start from a concrete builder need and pass the same conformance +vectors. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Build every likely client surface before demand.** Rejected because each surface + adds maintenance without removing a demonstrated blocker. +- **Forbid future ports.** Rejected because shared vectors are intended to let + builders add the smallest implementation they need. + +## D122. Contributions use DCO sign-off, MIT, and no CLA + +Every contribution requires Developer Certificate of Origin sign-off. The repository +keeps the MIT license and does not require a contributor license agreement. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Add a contributor license agreement.** Rejected because no identified legal + need justifies a second contribution agreement. +- **Require no contribution attestation.** Rejected because DCO sign-off provides a + lightweight record that contributors may submit their work. + +## D123. Critical public contracts have explicit owners + +`@mwhitham` owns `spec/`, `src/db/migrations/`, `src/v1/schema.ts`, `schema/`, +`.github/workflows/release-*.yml`, and `community/policy.json`. Other areas may be +reviewed by any maintainer and have no catch-all required owner. + +This is a narrow exception to the repository rule against individual names. A +GitHub owner handle is allowed only in `CODEOWNERS` and in decision or plan text +that explains `CODEOWNERS`. The repository is personal and has no team handle, so +the required owner must be a real account. No other exception is created. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Require one owner for every file.** Rejected because it needlessly blocks normal + maintenance outside the public contracts and release controls. +- **Use no protected owners.** Rejected because format, migration, schema, release, + and community policy changes need explicit review. + +## D124. Database migrations always preview, back up, and ask + +Agents and scripts use explicit `ath migrate`: first preview, then confirm. An +interactive database open may show the same preview and ask the person to confirm. +A noninteractive open never migrates. Every route creates and verifies a SQLite-safe +backup before changing the database. A package update alone never rewrites a file. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Migrate silently on open.** Rejected because opening an athlete record should + not make an unannounced irreversible storage change. +- **Require only manual file copying.** Rejected because copying an open WAL database + is unsafe and does not prove the backup is usable. +- **Support only a separate migration command.** Rejected because an interactive + person may reasonably confirm the same safe flow while opening the file. + +## D125. Stable views are public reads and a small table set is public for writes + +Versioned SQL views are the stable direct-read contract. A small documented set of +tables is the stable direct-write contract. The SQL specification names their +columns, required pragmas, transaction order, constraints, triggers, and version +policy. Every other table is an internal encoding detail and may change through an +ordered migration. + +D104 still governs the named JavaScript domain API. This decision adds a separate +public SQL contract for non-JavaScript and direct SQLite builders. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Make every table stable.** Rejected because internal indexes, ledgers, and + normalized encodings need room to change through migrations. +- **Publish example queries only.** Rejected because copied queries do not provide a + versioned read contract. +- **Allow reads but no direct writes.** Rejected by D116; direct builders are a + supported use. + +## D126. Deprecated stable APIs remain until the next major release + +A stable public TypeScript API may be deprecated with a warning and documented +replacement. It remains available for the rest of the current major version. The +next major npm release may remove it. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Remove stable APIs in a minor release.** Rejected because builders need a + predictable migration boundary. +- **Keep every stable API forever.** Rejected because major releases exist to remove + obsolete contracts after warning. + +## D127. Approved community items ship in the main package first + +A community Skill, importer, or calculation approved for official use ships in the +main `athleticstandard` package. The hosted product can adopt it by updating its +exact package pin after a separate hosted review. Separate public packages are +deferred until size, release, or dependency needs justify them. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Publish each approved item as a separate package now.** Rejected because it adds + release and compatibility work before a concrete need. +- **Copy approved code into the hosted repository.** Rejected because the public + exact-pinned package should remain the shared reviewed implementation. +- **Treat catalog inclusion as package approval.** Rejected because D119 separates + passing public tests from official and hosted approval. + +## D128. The core extension API uses semantic version 1.0.0 + +`CORE_API_VERSION` starts at `1.0.0` and follows semantic versioning. Community +manifests use `coreRange` to state compatibility with importer, calculation, Skill, +and extension interfaces. This version is independent of +`athleticstandard_version`, `sql_schema_version`, and unrelated CLI patch releases. + +This follows the [contribution readiness plan](appendix/contribution-readiness.md). + +Rejected alternatives: + +- **Use the npm package version as the core interface version.** Rejected because CLI + and packaging changes do not necessarily change extension compatibility. +- **Use an unversioned interface.** Rejected because community compatibility would + become guesswork after the first interface change. diff --git a/build-history/v1.0.0/progress.md b/build-history/v1.0.0/progress.md index c111bdab..24716418 100644 --- a/build-history/v1.0.0/progress.md +++ b/build-history/v1.0.0/progress.md @@ -44,3 +44,26 @@ D114 replaced the required 30-million-record release run with focused query-boun tests. The required measured runs now use 100,000 and 3 million records. Both pass all nine operations on the reference runner. Their measurements and review limits are recorded in `performance/limits.json`. + +## Pre-publish contribution foundation + +D115–D128 and section 19 of `spec.md` add work before release steps 11 and 12. +The long-form sequence is in +[`appendix/contribution-readiness.md`](appendix/contribution-readiness.md). + +| Step | Deliverable | Status | +|---|---|---| +| CR0 | Record the approved contribution-foundation decisions | ✅ D115–D128 recorded | +| CR1 | Add the v1 extension envelope and its generated schemas and fixture | pending — required before the first v1 npm publish | +| CR2 | Enforce the two-tier wall, revisions, deletion, erasure, JSON shape, and protected links with SQLite constraints and triggers | pending — required before the first v1 npm publish | +| CR3 | Publish plain SQL migrations, stable read views, and the stable writable-table contract | pending | +| CR4 | Add `ath migrate` preview, verified backup, explicit confirmation, and interactive prompt-on-open | pending | +| CR5 | Add direct-SQL and language-neutral conformance vectors | pending | +| CR6 | Publish machine-readable contract metadata, update `AGENTS.md`, and add the build-on-ATH Skill | pending | +| CR7 | Add contribution governance, community manifests, isolated checks, catalog generation, and explicit named Skill installation | pending | +| CR8 | Add internal workspace boundaries, `CORE_API_VERSION` 1.0.0, explicit public exports, and API deprecation checks | pending | +| CR9 | Verify the packed v1 tarball contains every promised schema, SQL, conformance, community, and Skill file | pending | + +CR1 and CR2 change the unreleased v1 schema. They must finish before v1.0.0 is +published to npm. Release steps 11 and 12 remain blocked until CR1–CR9 and the +cross-platform part of step 10 pass. diff --git a/build-history/v1.0.0/spec.md b/build-history/v1.0.0/spec.md index a7e39d5a..4cd32beb 100644 --- a/build-history/v1.0.0/spec.md +++ b/build-history/v1.0.0/spec.md @@ -1030,3 +1030,125 @@ D114 supersedes the 30-million-record requirement in section 13. Required measur runs use 100,000 records in normal release CI and 3 million records in the separate large release job. Larger generated databases are optional investigation tools and are not a release gate. + +## 19. Pre-publish contribution foundation amendment + +D115–D128 and the +[contribution readiness plan](appendix/contribution-readiness.md) amend the work +required before v1.0.0 is published to npm. They do not change the released 0.4.3 +format. + +### 19.1 Record extensions + +Every record schema has an optional `extensions` object. Its keys are namespaced +extension IDs. Its values are bounded JSON values. The generated schema defines the +key grammar, value grammar, maximum depth, maximum collection sizes, and maximum +encoded size before release. + +An extension inherits the class of its parent record: + +- An extension on a measured record still requires the parent record's source. +- An extension on an athlete-reported record cannot add or claim a source. +- An extension on an authored record remains governed by the parent record's author, + evidence, content version, and status. + +SQLite revisions, current records, complete JSON export, package import, merge, +correction, and every public reader preserve unknown valid extension values. The +deterministic JSON writer may normalize their JSON encoding but cannot change their +values. Unknown fields outside the extension envelope still follow section 9.2 and +are refused. + +The extension envelope is part of v1.0.0. It and its limits must land before the +first v1 npm publish. The current unreleased v1 fixture and generated schemas are +regenerated. Separate linked extension record types are later additive work and are +not required for v1.0.0. + +### 19.2 Database-enforced writes + +Direct third-party SQLite writes are supported. The JavaScript handle remains opaque +as specified by D104, but it is not the only supported writer. + +Every direct client must enable and verify: + +```sql +PRAGMA foreign_keys = ON; +PRAGMA busy_timeout = 5000; +``` + +The database enforces critical validity without relying on the Node operations. +Use `STRICT` tables, `NOT NULL`, `CHECK`, `UNIQUE`, foreign keys, SQLite JSON +functions, and triggers. Constraints and triggers cover at least: + +- The measured and athlete-reported sides of the two-tier wall. +- Record type agreement between current rows, retained revisions, and typed rows. +- Complete `record_json` shape needed to identify its record and class. +- Sequential revisions and valid previous-revision links. +- Current-revision pointers. +- Deletion and erasure state. +- Source, evidence, result, grade, attachment, and other protected link types. + +Foreign keys remain required. Critical cross-table rules also have trigger coverage +where a connection with foreign keys disabled could otherwise create a database that +official readers accept. Direct-SQL tests bypass the Node library and prove each +invalid state is refused. + +Before the first v1 publish, the ordinary SQL migration is finalized from these +rules and the deterministic repository fixture is regenerated. There is no +published earlier v1 database that needs a compatibility migration. + +### 19.3 Stable SQL contract + +Versioned SQL views are the stable direct-read contract. A small documented set of +tables is the stable direct-write contract. The machine-readable SQL specification +lists: + +- Stable views and their columns. +- Stable writable tables and their columns. +- Internal tables. +- Required pragmas. +- Transaction order. +- Constraints and triggers. +- SQL schema compatibility. + +Tables not listed as stable writable tables are internal. They may change through an +ordered migration. Example queries do not make an internal table public. + +### 19.4 Migration behavior + +`ath migrate` first previews the source and target SQL schema versions, planned +steps, backup location, and compatibility effect. Agents and scripts then provide +explicit confirmation. An interactive database open may show the same preview and +ask the person to confirm. A noninteractive open refuses migration and points to +`ath migrate`. + +Every migration route creates and verifies a SQLite-safe backup before the first +database write. It accounts for WAL state and does not copy an open WAL database as +if that were a complete backup. A package update alone never migrates a database. + +### 19.5 Machine-readable contract and agent guidance + +The repository publishes language-neutral conformance vectors for direct reads, +direct writes, extension preservation, invalid constraints, migrations, and +deterministic calculations. `AGENTS.md` and the build-on-ATH Skill point builders to +the machine-readable SQL and record contracts. No maintained Swift, Rust, or other +language library is required for v1. + +`CORE_API_VERSION` is `1.0.0`. It versions the community importer, calculation, +Skill, and extension interfaces independently of `athleticstandard_version`, +`sql_schema_version`, and the npm package version. + +### 19.6 Additional pre-publish build order + +Complete these steps after the existing implemented v1 work and before steps 11 and +12 release a prerelease or v1.0.0: + +1. Add the extension envelope and SQLite-enforced critical rules. +2. Finalize plain SQL migrations, stable read views, and stable writable tables. +3. Add direct-SQL and language-neutral conformance vectors. +4. Add machine-readable contract metadata and the build-on-ATH Skill. +5. Pack the npm artifact and prove it contains every v1 schema, SQL, conformance, + and Skill file. +6. Run the functional, cross-platform, and D114 measured release checks. + +Local HTTP, local MCP, maintained language ports, and runtime loading of third-party +code are not v1 release work.