Skip to content

Schema version 5: platform-independent hash that covers custom types - #82

Merged
facontidavide merged 3 commits into
V2from
fix/schema-hash-fnv
Sep 12, 2026
Merged

Schema version 5: platform-independent hash that covers custom types#82
facontidavide merged 3 commits into
V2from
fix/schema-hash-fnv

Conversation

@facontidavide

Copy link
Copy Markdown
Collaborator

Resolves the remaining item of #73 and the "implementation-defined hash" caveat introduced in #78.

What changes

The schema hash becomes FNV-1a 64 of the schema text with its own ### hash: line removed. Consequences:

  • identical on every platform (no more std::hash), so any decoder can recompute and verify it;
  • covers everything in the schema, including custom type bodies, so two schemas that differ only inside a struct no longer collide in a sink's hash-to-channel map;
  • SCHEMA_VERSION bumps to 5.

Compatibility

  • New readers (this header-only parser, the Python decoder) read version 4 files as before, through the declared hash, and can verify version 5 files (check_hash / verify_hash=True).
  • Parsers older than this release recompute the version-4 hash themselves and would decode version 5 files wrongly; the version bump makes them fail explicitly with "Wrong SCHEMA_VERSION". PlotJuggler needs its data_tamer dependency bumped for the 2.0 release.

Code

  • SchemaTextHash() / ComputeSchemaHash() replace AddFieldToHash (library and parser).
  • Hash recomputed at every registration and custom type addition (setup time only).
  • Golden test now compares schema.txt byte for byte including the hash and checks Schema::hash == SchemaTextHash(text); fixture regenerated. The Python test verifies the hash independently, so both implementations of FNV-1a agree on the real fixture.
  • Spec section 5 rewritten as normative, version history added, changelog entry.

Targets V2 together with #75.

🤖 Generated with Claude Code

facontidavide and others added 3 commits September 12, 2026 19:59
The schema hash is now FNV-1a 64 of the schema text without its own hash
line. It is the same on every platform, any decoder can recompute it to
verify a file, and it changes whenever anything in the schema changes,
including custom type bodies; two schemas that differ only inside a struct
no longer collide in a sink's hash-to-channel map.

- library: SchemaTextHash()/ComputeSchemaHash() replace AddFieldToHash;
  the hash is recomputed at every registration and custom type addition.
- header-only parser: accepts version 4 and 5, takes Schema::hash from the
  declared line, check_hash verifies version 5 texts against the FNV value.
- python: schema_hash(text), parse_schema(..., verify_hash=True).
- golden test compares schema.txt byte for byte, including the hash, and
  checks Schema::hash == SchemaTextHash(text); fixture regenerated.
- spec section 5 rewritten as normative; version history added.

Parsers older than this release reject version 5 files explicitly instead
of decoding them wrongly; PlotJuggler needs its data_tamer dependency bumped.

Closes #73.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…files

AddFieldToHash stays in the header-only parser; version 4 texts are matched
by their declared hash and, with check_hash, verified with the version 4
recipe exactly as before. Version 5 texts use SchemaTextHash.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@facontidavide
facontidavide merged commit fc29cba into V2 Sep 12, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant