test(sketchdb): comprehensive persist-format-versioning coverage - #53
Merged
Merged
Conversation
Addresses the ASAPQuery-backend TODO.md item #4 (serialization format versioning tests) — the paper blocker for "sketchDB restarts without data loss across format bumps." Adds `src/tests/persist_format_versioning_tests.rs` with 14 tests covering the three format-versioned stores: ## SchemaRegistry (5 tests) - realistic_multi_schema_round_trips_through_disk — 4-schema state with Active + Retired, drop + reload preserves timestamps and wire version - tampered_version_field_triggers_safe_fallback — field-level attack (valid v1 snapshot, flip version=999) must not leak tampered schemas; fallback re-writes clean v1 - truncated_snapshot_falls_back_without_panic — half-file scenario - empty_snapshot_file_falls_back_without_panic — zero-byte file - wrong_shape_snapshot_falls_back_without_panic — valid JSON with missing `schemas` array ## BackfillRegistry (5 tests) - realistic_multi_job_round_trips_through_disk — all five BackfillStatus variants (Queued/Running/Complete/Cancelled/ Failed) survive disk round-trip - v1_wire_format_carries_next_job_id_field — golden-file variant asserting next_job_id=43 is honoured so post-restart create() returns 43 not 1 - tampered_version_field_triggers_safe_fallback — same as schema - truncated_snapshot_falls_back_without_panic - wrong_shape_snapshot_falls_back_without_panic ## SimpleMapStore part meta.bin (4 tests) Previously-untested binary-header versioning: - bad_magic_returns_format_error — 0xDEADBEEF where MAGIC_META should be - unsupported_version_returns_format_error — PART_FORMAT_VERSION bumped in file to 9999 - truncated_header_returns_error — 32-byte header (spec says 64) - missing_meta_file_returns_error — part dir exists but meta.bin does not All three format stores are now locked under "bump-forward won't silently re-interpret old data" tests. Future format version bumps in any of the three modules will need to update these tests' expected-error assertions, forcing a conscious migration plan. 752 lib tests pass (+14), clippy clean, fmt clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Addresses TODO.md blocker #4 — serialization format versioning tests. The paper story "sketchDB restarts without data loss across format bumps" needs evidence; this PR locks it in.
What's covered
14 new tests spanning the three format-versioned stores:
Why it matters for the paper
Future format bumps in any of these three modules now require a conscious test update — forcing a migration plan rather than letting behaviour drift silently. The three formats cover the entirety of sketchDB's on-disk state.
Validation
🤖 Generated with Claude Code