test: add corrupted BLOB deserialization test (#2033)#2045
Merged
Conversation
Add unit tests for graceful degradation in semantic cache when bytemuck::try_cast_slice fails due to corrupted embedding BLOBs: - test_semantic_get_corrupted_blob_odd_length: 5-byte BLOB (SizeMismatch) - test_semantic_get_corrupted_blob_skips_to_valid: mixed corrupt+valid rows - test_semantic_get_empty_blob: empty BLOB edge case - test_semantic_get_all_blobs_corrupted: all candidates corrupt (REC-1: 6-byte) Use raw SQL INSERT to inject corrupt BLOBs, bypassing put_with_embedding. Verify: no panics, proper error handling, IEEE 754 NaN safety. All 688 zeph-memory tests pass. Code reviewed and approved.
bug-ops
added a commit
that referenced
this pull request
Mar 20, 2026
…2034) Add 3 tests for dimension mismatch handling in semantic cache: - test_semantic_get_dimension_mismatch_returns_none: store dim=3, query dim=2 - test_semantic_get_dimension_mismatch_query_longer: store dim=2, query dim=3 - test_semantic_get_mixed_dimensions_picks_correct_match: mixed dims Complements PR #2045 (corrupted BLOB tests). These tests verify that cosine_similarity() and get_semantic() gracefully handle embedding dimension mismatches using threshold=0.01 to correctly reject 0.0 scores from mismatches. Fixes #2034. All 5533 tests pass, no regressions.
bug-ops
added a commit
that referenced
this pull request
Mar 20, 2026
…2034) Add 3 tests for dimension mismatch handling in semantic cache: - test_semantic_get_dimension_mismatch_returns_none: store dim=3, query dim=2 - test_semantic_get_dimension_mismatch_query_longer: store dim=2, query dim=3 - test_semantic_get_mixed_dimensions_picks_correct_match: mixed dims Complements PR #2045 (corrupted BLOB tests). These tests verify that cosine_similarity() and get_semantic() gracefully handle embedding dimension mismatches using threshold=0.01 to correctly reject 0.0 scores from mismatches. Fixes #2034. All 5533 tests pass, no regressions.
bug-ops
added a commit
that referenced
this pull request
Mar 20, 2026
…2034) Add 3 tests for dimension mismatch handling in semantic cache: - test_semantic_get_dimension_mismatch_returns_none: store dim=3, query dim=2 - test_semantic_get_dimension_mismatch_query_longer: store dim=2, query dim=3 - test_semantic_get_mixed_dimensions_picks_correct_match: mixed dims Complements PR #2045 (corrupted BLOB tests). These tests verify that cosine_similarity() and get_semantic() gracefully handle embedding dimension mismatches using threshold=0.01 to correctly reject 0.0 scores from mismatches. Fixes #2034. All 5533 tests pass, no regressions.
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
Add 4 unit tests for graceful degradation in semantic cache when embedding BLOBs are corrupted and bytemuck deserialization fails.
Tests Added
Implementation Details
crates/zeph-memory/src/response_cache.rs(test module)put_with_embedding:memory:SQLite per test, no state leakageget_semantic()Validation
Test Results
Closes #2033