the candidate document (typically JSON.parse output)
the canonical, frozen recording
FourError SERIALIZATION_VERSION_MISMATCH if formatVersion is not
one of SUPPORTED_REPLAY_FORMAT_VERSIONS, or if the document declares
a version too low for the fields it carries — §34's "refuses to run" applied
to the envelope itself
Validates an arbitrary value as a §34 replay document and returns it in canonical form.
The result is a fresh, deep-frozen object holding only the fields this format defines, built in a fixed key order — so re-encoding it is byte-stable, and no unknown field from an untrusted document survives into the player.
The declared
formatVersionis re-derived rather than copied: the result carries the lowest version that can express it (see LATEST_REPLAY_FORMAT_VERSION), so validation is idempotent and a configuration-free document is spelled exactly as MINIMUM_REPLAY_FORMAT_VERSION always spelled it.