Skip to content

test(sketchdb): comprehensive persist-format-versioning coverage - #53

Merged
zzylol merged 1 commit into
mainfrom
feat/sketchdb-format-versioning-tests
Apr 20, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/sketchdb-format-versioning-tests

Conversation

@zzylol

@zzylol zzylol commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

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:

  • SchemaRegistry (5): realistic multi-schema round-trip, tampered version-field fallback, truncated/empty/wrong-shape fallback
  • BackfillRegistry (5): all 5 BackfillStatus variants round-trip, `next_job_id` wire-format check, same corruption paths
  • SimpleMapStore part meta.bin (4): bad-magic, unsupported-version, truncated-header, missing-file — previously untested binary-header paths

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

  • `cargo test -p query_engine_rust --lib` — 752 pass (was 738; +14)
  • `cargo clippy --all-targets -- -D warnings` — clean
  • `cargo fmt --all -- --check` — clean

🤖 Generated with Claude Code

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>
@zzylol
zzylol merged commit fbb2428 into main Apr 20, 2026
@zzylol
zzylol deleted the feat/sketchdb-format-versioning-tests branch April 20, 2026 22:14
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