Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions spec/conformance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Conformance vectors

Language-neutral behavior fixtures for Athletic Standard v1. Each case has a JSON
manifest with independently specified expectations. Rust, Node, and Swift runners
should load the same files (CR5 / Rust prerequisite R2).

## Layout

- `cases/<id>/manifest.json` — scenario metadata and expected outcomes
- `cases/<id>/inputs/` — optional seed data (synthetic only)

## Running (Node)

```sh
pnpm test tests/conformance-vectors.test.ts
```

## Case IDs

| ID | Covers |
|---|---|
| `two-tier-wall-reject` | Measured record without `source` must fail validation |
| `rmssd-toy-intervals` | RMSSD from three RR intervals matches reference answer |

Grokbot and the Swift verification app should reuse these IDs when adding UI or
browser scenarios.
13 changes: 13 additions & 0 deletions spec/conformance/cases/rmssd-toy-intervals/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"conformance": "athleticstandard-behavior",
"case_id": "rmssd-toy-intervals",
"description": "RMSSD over twenty equal 1000 ms intervals is zero (independent closed-form reference).",
"expect": {
"rmssd_ms": 0,
"n_beats": 20
},
"intervals_ms": [
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
]
}
25 changes: 25 additions & 0 deletions spec/conformance/cases/two-tier-wall-reject/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"conformance": "athleticstandard-behavior",
"case_id": "two-tier-wall-reject",
"description": "Measured point_measurement data without source_id must fail schema validation.",
"expect": {
"validation": "reject",
"error_includes": "source_id"
},
"record": {
"record_type": "point_measurement",
"record_id": "01890f3e-e7d3-7cc0-88c8-000000000101",
"created_at": "2026-08-09T08:00:00.000Z",
"current_revision": 1,
"is_deleted": false,
"data": {
"quantity": "resting_heart_rate",
"received_at": "2026-08-09T08:00:00.000Z",
"received_at_basis": "import_time",
"value": {
"standard_value": 52,
"standard_unit": "bpm"
}
}
}
}
36 changes: 36 additions & 0 deletions tests/conformance-vectors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { rmssdFromIntervals } from "../src/hrv.js";
import { PointMeasurementRecord } from "../src/v1/schema.js";

const casesRoot = join(import.meta.dirname, "..", "spec", "conformance", "cases");

function loadManifest(caseId: string): Record<string, unknown> {
const path = join(casesRoot, caseId, "manifest.json");
return JSON.parse(readFileSync(path, "utf8")) as Record<string, unknown>;
}

describe("spec/conformance vectors", () => {
it("two-tier-wall-reject", () => {
const manifest = loadManifest("two-tier-wall-reject");
const record = manifest.record as Record<string, unknown>;
const result = PointMeasurementRecord.safeParse(record);
expect(result.success).toBe(false);
const expectBlock = manifest.expect as { error_includes?: string };
if (expectBlock.error_includes !== undefined) {
const message = JSON.stringify(result.success ? {} : result.error.format());
expect(message.toLowerCase()).toContain(expectBlock.error_includes.toLowerCase());
}
});

it("rmssd-toy-intervals", () => {
const manifest = loadManifest("rmssd-toy-intervals");
const intervals = manifest.intervals_ms as number[];
const expectBlock = manifest.expect as { rmssd_ms: number; n_beats: number };
const computed = rmssdFromIntervals(intervals);
expect(computed).not.toBeNull();
expect(computed!.rmssd_ms).toBe(expectBlock.rmssd_ms);
expect(computed!.n_beats).toBe(expectBlock.n_beats);
});
});
Loading