Repository navigation
fix(format2): freeze the format-2 specification and escape the stored writer version - #254
Merged
Merged
Conversation
0.9 is the first release that writes index format 2, and its reader binds every later file, so the specification must state what the reader enforces. The layout rule now says what reader and writer do: each section starts at or after the end of the previous table entry, so an empty section shares its offset only with entries after it; the earlier text also allowed an empty section inside or at the start of the previous one, which the reader rejects. Also: drop the draft status and close the open question (the header is not a blob); header growth is per release within version 2; readers check the checksum of known sections exactly when checksummed is set and read known kinds whatever their required bit; reading step 5 lists the checks in the reader's order; the replaced IVF layouts include RBFQRAW1 and the unversioned one; stale proposal wording is removed. A test pins the layout rule for empty sections.
Readers do not validate writer_version, but two FormatError messages embed it. A byte outside printable ASCII reached Python's error conversion, which decodes messages as UTF-8, so loading such a file raised UnicodeDecodeError instead of rabitqlib.FormatError. The messages now show those bytes, and backslashes, as \xNN; Reader::writer_version() still returns the stored bytes. The specification says readers do not validate the field.
This was referenced Nov 19, 2026
Open
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.
Summary
0.9 is the first release that writes index format 2. Once it ships, its reader binds every later format-2 file (the order and overlap checks run before the reader looks up a section's kind, so they also bind optional sections added later), so
docs/formats.mdmust state exactly what the reader enforces. Two commits:1.
docs(format2): freeze the specification.A@192 size 100thenB@192 size 0; the reader rejects that ("overlaps the previous section or is out of order"), and the writer never produces it. The rule now states what reader and writer do: each section starts at or after the end of the previous table entry; an empty section takes no bytes, several may share an offset, and the next section may start at it. Under this rule section ends never decrease, so the existing "the file ends where ... the last section ends" sentence is exact.version2 (the text said "a later version may append fields", but any version other than 2 is rejected).checksummedis set; a known kind is read whatever itsrequiredbit.RBFQRAW1and the unversioned layout; stale proposal wording (hnsw_levels, quant raw-array plan, golden test) is updated.PlacesEmptySectionsByTheLayoutRulepins the rule.2.
fix(format2): escape the stored writer version in error messages.Readers do not validate
writer_version, but twoFormatErrormessages embed it. A byte outside printable ASCII reached Python's error conversion, which decodes messages as UTF-8, so loading such a file raisedUnicodeDecodeErrorinstead ofrabitqlib.FormatError(reproduced with an unknown incompat bit and0xFFinwriter_version). The messages now show those bytes, and backslashes, as\xNN;Reader::writer_version()still returns the stored bytes. No other file-derived string reaches a format-2, IVF, HNSW, SymphonyQG or blob error message.Found during a pre-release check of
dev/0.9.Testing
Local, Linux x86-64, GCC 14.3, Release,
RABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF:ctest --no-tests=error: 612 passed, 1 skipped (ThreadCount.BoundParallelForUsesRuntimePlacementAndPropagatesErrors, also skipped without the change).test_non_ascii_writer_version_still_raises_format_error; the same file raisedUnicodeDecodeErrorwith the previous build.EscapesTheStoredWriterVersionInMessagesfails without the fix.PlacesEmptySectionsByTheLayoutRulefails if the reader exempts empty sections from the order check (the reader then accepts the file)../scripts/check-format.sh, full./scripts/check-tidy.sh(clang-tidy 23),./scripts/check-python.sh,mkdocs build --strict,git diff --check.