Skip to Content
FFitDatadraft
Specification

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": []
}
FieldRequiredDescription
formatYesLiteral "fitdata".
versionYesWire format version ("0.0.0-local" in this draft).
profilesNoUp to 50 namespaced profile codes declaring domain contracts and policy rules.
subjectNoOptional default subject ID for revisioned records that omit subject.
producerNoOptional { name, version } identifying the software that serialized the document.
referencesYes"closed" or "external".
externalReferencesConditionalExplicit list of { id, revision } or { id, version } references allowed to resolve outside an "external" document.
recordsYesArray 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 effective subject (either on the record or inherited from document subject) on every personal revisioned record.
  • fitdata:profile.audit — requires producer on 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.

  • In a closed document, every internal { id, revision } or { id, version } reference must resolve to a record inside records.
  • In an external document, unresolved references must be declared explicitly in externalReferences.
  • Resolved references cannot target a core.tombstone or cross subjects.
  • Records can declare typed links with relation part_of, derived_from, or same_activity_as. Document validation rejects containment (part_of) and derivation (derived_from) cycles.

Revisions and tombstones

  • id identifies 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 kind across 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:

  1. JSON (parseDocument / serializeDocument) — a single UTF-8 JSON object matching documentSchema.
  2. JSONL (parseJsonLines / serializeJsonLines) — line 1 is the document header object (the envelope without records), 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).

LimitValue
JSON / JSONL payload size16 MiB
Records per document10,000
Samples per core.series100,000
Channels per core.series16
JSON nesting depth32
Visited JSON nodes1,000,000
Source items per mapper call1,000
Retained semantic issues500 (with truncation notice)

On this page