Document, Profiles & Wire Format
Document envelope, profiles, reference resolution, revision history, JSONL streaming format, and safety limits.
A FitData document wraps any combination of the 18 canonical record kinds into a single self-describing JSON or JSONL payload.
Document envelope
{
"format": "fitdata",
"version": "0.0.0-local",
"profiles": ["fitdata:core", "fitdata:training"],
"subject": "example:athlete",
"producer": {
"name": "example-app",
"version": "0.0.0-local"
},
"references": "closed",
"records": []
}| Field | Required | Description |
|---|---|---|
format | Yes | Literal "fitdata". |
version | Yes | Wire format version ("0.0.0-local" in this draft). |
profiles | No | Up to 50 namespaced profile codes declaring domain contracts and policy rules. |
subject | No | Optional default subject ID for revisioned records that omit subject. |
producer | No | Optional { name, version } identifying the software that serialized the document. |
references | Yes | "closed" or "external". |
externalReferences | Conditional | Explicit list of { id, revision } or { id, version } references allowed to resolve outside an "external" document. |
records | Yes | Array of up to 10,000 canonical FitData records. |
Document profiles
Standalone entity validation does not require ownership metadata. When a consumer needs stricter guarantees, it declares document profiles:
fitdata:profile.multi_subject— requires an effectivesubject(either on the record or inherited from documentsubject) on every personal revisioned record.fitdata:profile.audit— requiresproduceron the document header as well as record provenance metadata for traceability.
Domain profiles (such as fitdata:core, fitdata:training, fitdata:nutrition, fitdata:lab) declare which domain schemas the document exercises.
References and links
- In a
closeddocument, every internal{ id, revision }or{ id, version }reference must resolve to a record insiderecords. - In an
externaldocument, unresolved references must be declared explicitly inexternalReferences. - Resolved references cannot target a
core.tombstoneor cross subjects. - Records can declare typed
linkswith relationpart_of,derived_from, orsame_activity_as. Document validation rejects containment (part_of) and derivation (derived_from) cycles.
Revisions and tombstones
ididentifies a logical entity;{ id, revision }identifies an exact revision (and{ id, version }identifies an exact versioned definition).- A document cannot repeat the same
{ id, revision }or{ id, version }pair. - A logical record cannot change its subject or live
kindacross revisions. currentRecords(document)computes the active view by selecting the highest revision per ID.- If the highest revision for an ID is a
core.tombstone, that record is excluded from the active view. Replaying an older live revision does not restore it; only a higher live revision can restore it. Input order never affects the result.
JSON and JSONL wire formats
FitData supports two lossless text representations:
- JSON (
parseDocument/serializeDocument) — a single UTF-8 JSON object matchingdocumentSchema. - JSONL (
parseJsonLines/serializeJsonLines) — line 1 is the document header object (the envelope withoutrecords), followed by one serialized record per line.
Serialization preserves decimal strings, namespaced extensions, null samples, and historical revisions.
Preflight and runtime limits
Preflight checks run before structural parsing and reject object cycles, non-finite numbers, non-JSON values, and prototype-pollution keys (__proto__, constructor, prototype).
| Limit | Value |
|---|---|
| JSON / JSONL payload size | 16 MiB |
| Records per document | 10,000 |
Samples per core.series | 100,000 |
Channels per core.series | 16 |
| JSON nesting depth | 32 |
| Visited JSON nodes | 1,000,000 |
| Source items per mapper call | 1,000 |
| Retained semantic issues | 500 (with truncation notice) |