[rntuple] Verify envelope checksums - #129
Open
sathabbott wants to merge 3 commits into
Open
sathabbott wants to merge 3 commits into
sathabbott wants to merge 3 commits into
Conversation
root-io-spec moves from 9c3f776 (2026-09-18) to c65c464 (2026-09-24), 68 commits. It still pins ROOT 6.40.04 (1211eda), the latest stable release, so the tracked RNTuple specification (v1.0.2.1) is the same document. It adds three RNTuple fixtures, all of which read: - rntuple/compressed: the only compressed anchor and envelopes in the corpus - rntuple/map: page locators that share byte ranges - rntuple/attributes: linked attribute sets Four new non-RNTuple fixtures fail. Each is listed in EXPECTED_FAILURES with its exact error and the issue that tracks it: - classes/roofit: nsmith-#71 - serialization/pointer-collection: nsmith-#105 - serialization/unframed-records: nsmith-#123, nsmith-#101 - written/two-versions: nsmith-#22 Assisted-by: claude-code:claude-opus-5-5
Every RNTuple envelope ends with an XXH3-64 checksum. rootfilespec read it and compared stored checksums with each other, but never hashed the bytes, so a corrupted header, footer or page list parsed without complaint. REnvelope.read now checks the checksum over [0, length - 8) of the uncompressed envelope: the length includes the checksum, and the checksum covers everything before it (root-io-spec ERRATA 5, checked against ROOT's VerifyXxHash3, RNTupleSerialize.cxx:934). Unknown trailing bytes are covered too, as the spec's compatibility notes require. REnvelopeLocator.read_from also refuses a stored size larger than the uncompressed length. RNTuple decompression branches on equality (root-io-spec NOTES 2, RNTupleZip.hxx:106-113), so that case is an error, where the code used to try to decompress it. Fixes nsmith-#117 Assisted-by: claude-code:claude-opus-5-5
The pre-commit mypy hook installs only pytest, numpy and tomli, so it cannot find xxhash. bootstrap/compression.py already imports it the same way. Assisted-by: claude-code:claude-opus-5-5
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #129 +/- ##
==========================================
+ Coverage 91.82% 92.19% +0.36%
==========================================
Files 37 37
Lines 2962 2971 +9
==========================================
+ Hits 2720 2739 +19
+ Misses 242 232 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #117. Depends on #124 (the tests cover
rntuple/compressed.root, whose envelopes are compressed); until #124 merges, this PR also shows its commit.REnvelope.readverifies the envelope's XXH3-64 over[0, length − 8)of the uncompressed envelope. The length includes the checksum and the checksum covers everything before it (root-io-spec ERRATA 5, checked against ROOT'sVerifyXxHash3,RNTupleSerialize.cxx:934). Unknown trailing bytes are included, as Notes on Backward and Forward Compatibility requires ("must include both known and unknown contents"). A mismatch raisesValueError: <Envelope> checksum mismatch: stored …, computed ….REnvelopeLocator.read_from: a stored size larger than the uncompressed length now raises. RNTuple decompression tests equality (root-io-spec NOTES 2,RNTupleZip.hxx:106-113): equal means raw, smaller means compressed, larger is an error. Before, it tried to decompress that case.The existing cross-checks (the footer's and page lists'
headerChecksumagainst the header's) stay.Tests (
tests/test_rntuple_envelopes.py):rntuple/anchor.root, flipping the case of thenofntpl(offset 288, inside the header envelope at 268–508) still parses but raises the checksum mismatch; so does a flipped byte of the stored checksum;Without the change, 3 of these fail. Full suite:
411 passed, 61 skipped, 50 xfailed(on top of #124).Assisted-by: claude-code:claude-opus-5-5