Repository navigation
Fix failing Rust embedding service tests - #358
Merged
Merged
Conversation
**Problem:** Four embedding service tests were failing with assertion errors where embedding metadata wasn't being stored correctly in the database. **Root Causes Identified:** 1. **JSON Metadata Storage Bug (3 tests)** - `store_embedding` method was passing metadata as a string to `json_set()` - SQLite's `json_set()` requires JSON type, not string type - This caused `properties["embedding_metadata"]["type"]` to be `Null` instead of expected values like `"complete_container"` or `"container_summary"` 2. **Database Transaction Isolation Issue (1 test)** - `test_re_embed_container` held a database connection across content update and re-embedding - This caused embeddings to appear identical when they should have been different - The second embedding was reading stale data from the open transaction **Fixes Applied:** 1. **packages/core/src/services/embedding_service.rs:678** - Changed `json_set(properties, '$.embedding_metadata', ?)` to use `json(?)` wrapper - Now: `json_set(properties, '$.embedding_metadata', json(?))` - This ensures SQLite parses the JSON string into a proper JSON value 2. **packages/core/src/services/embedding_service_test.rs:247-290** - Refactored connection management to use scoped blocks - Each database operation now gets a fresh connection that is dropped immediately - Ensures transactions commit and data is visible to subsequent operations **Test Results:** - ✅ All 14 embedding service tests now pass (previously 10/14) - ✅ Fixed tests: `test_chunking_strategy_small`, `test_chunking_strategy_medium`, `test_chunking_strategy_large`, `test_re_embed_container` - ✅ No regressions in other tests **Impact:** - Embedding metadata is now correctly stored in the `properties` JSON field - Re-embedding operations correctly detect content changes - Test suite validates embedding functionality comprehensively 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
**Code Review Follow-up:** Added inline documentation to clarify the subtle bug fixes from the previous commit. **Changes:** 1. **embedding_service.rs:675-677** - Added comment explaining json() wrapper - Documents why json() is necessary for SQLite's json_set() - Prevents future regression of this subtle string-vs-JSON bug - Critical for maintainability since the bug causes silent data corruption 2. **embedding_service_test.rs** - Enhanced connection scoping comments - Line 260: "Drop connection to commit transaction and ensure data visibility" - Line 264: "Fresh connection for the update operation" - Line 272: "Drop connection to commit transaction" - Line 279: "Fresh connection ensures we see the committed content update" - Documents intentional pattern to prevent "simplification" refactors **Rationale:** These comments protect against future developers accidentally reverting the fix or "optimizing" the test code by reusing connections, which would reintroduce the transaction isolation bug. **Impact:** - No functional changes - documentation only - Improves long-term maintainability - All 14 embedding service tests still pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
4 tasks done
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
* Fix: Resolve failing Rust embedding service tests (issue #343) **Problem:** Four embedding service tests were failing with assertion errors where embedding metadata wasn't being stored correctly in the database. **Root Causes Identified:** 1. **JSON Metadata Storage Bug (3 tests)** - `store_embedding` method was passing metadata as a string to `json_set()` - SQLite's `json_set()` requires JSON type, not string type - This caused `properties["embedding_metadata"]["type"]` to be `Null` instead of expected values like `"complete_container"` or `"container_summary"` 2. **Database Transaction Isolation Issue (1 test)** - `test_re_embed_container` held a database connection across content update and re-embedding - This caused embeddings to appear identical when they should have been different - The second embedding was reading stale data from the open transaction **Fixes Applied:** 1. **packages/core/src/services/embedding_service.rs:678** - Changed `json_set(properties, '$.embedding_metadata', ?)` to use `json(?)` wrapper - Now: `json_set(properties, '$.embedding_metadata', json(?))` - This ensures SQLite parses the JSON string into a proper JSON value 2. **packages/core/src/services/embedding_service_test.rs:247-290** - Refactored connection management to use scoped blocks - Each database operation now gets a fresh connection that is dropped immediately - Ensures transactions commit and data is visible to subsequent operations **Test Results:** - ✅ All 14 embedding service tests now pass (previously 10/14) - ✅ Fixed tests: `test_chunking_strategy_small`, `test_chunking_strategy_medium`, `test_chunking_strategy_large`, `test_re_embed_container` - ✅ No regressions in other tests **Impact:** - Embedding metadata is now correctly stored in the `properties` JSON field - Re-embedding operations correctly detect content changes - Test suite validates embedding functionality comprehensively 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Docs: Add explanatory comments for embedding service fix (issue #343) **Code Review Follow-up:** Added inline documentation to clarify the subtle bug fixes from the previous commit. **Changes:** 1. **embedding_service.rs:675-677** - Added comment explaining json() wrapper - Documents why json() is necessary for SQLite's json_set() - Prevents future regression of this subtle string-vs-JSON bug - Critical for maintainability since the bug causes silent data corruption 2. **embedding_service_test.rs** - Enhanced connection scoping comments - Line 260: "Drop connection to commit transaction and ensure data visibility" - Line 264: "Fresh connection for the update operation" - Line 272: "Drop connection to commit transaction" - Line 279: "Fresh connection ensures we see the committed content update" - Documents intentional pattern to prevent "simplification" refactors **Rationale:** These comments protect against future developers accidentally reverting the fix or "optimizing" the test code by reusing connections, which would reintroduce the transaction isolation bug. **Impact:** - No functional changes - documentation only - Improves long-term maintainability - All 14 embedding service tests still pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
* Fix: Resolve failing Rust embedding service tests (issue #343) **Problem:** Four embedding service tests were failing with assertion errors where embedding metadata wasn't being stored correctly in the database. **Root Causes Identified:** 1. **JSON Metadata Storage Bug (3 tests)** - `store_embedding` method was passing metadata as a string to `json_set()` - SQLite's `json_set()` requires JSON type, not string type - This caused `properties["embedding_metadata"]["type"]` to be `Null` instead of expected values like `"complete_container"` or `"container_summary"` 2. **Database Transaction Isolation Issue (1 test)** - `test_re_embed_container` held a database connection across content update and re-embedding - This caused embeddings to appear identical when they should have been different - The second embedding was reading stale data from the open transaction **Fixes Applied:** 1. **packages/core/src/services/embedding_service.rs:678** - Changed `json_set(properties, '$.embedding_metadata', ?)` to use `json(?)` wrapper - Now: `json_set(properties, '$.embedding_metadata', json(?))` - This ensures SQLite parses the JSON string into a proper JSON value 2. **packages/core/src/services/embedding_service_test.rs:247-290** - Refactored connection management to use scoped blocks - Each database operation now gets a fresh connection that is dropped immediately - Ensures transactions commit and data is visible to subsequent operations **Test Results:** - ✅ All 14 embedding service tests now pass (previously 10/14) - ✅ Fixed tests: `test_chunking_strategy_small`, `test_chunking_strategy_medium`, `test_chunking_strategy_large`, `test_re_embed_container` - ✅ No regressions in other tests **Impact:** - Embedding metadata is now correctly stored in the `properties` JSON field - Re-embedding operations correctly detect content changes - Test suite validates embedding functionality comprehensively 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Docs: Add explanatory comments for embedding service fix (issue #343) **Code Review Follow-up:** Added inline documentation to clarify the subtle bug fixes from the previous commit. **Changes:** 1. **embedding_service.rs:675-677** - Added comment explaining json() wrapper - Documents why json() is necessary for SQLite's json_set() - Prevents future regression of this subtle string-vs-JSON bug - Critical for maintainability since the bug causes silent data corruption 2. **embedding_service_test.rs** - Enhanced connection scoping comments - Line 260: "Drop connection to commit transaction and ensure data visibility" - Line 264: "Fresh connection for the update operation" - Line 272: "Drop connection to commit transaction" - Line 279: "Fresh connection ensures we see the committed content update" - Documents intentional pattern to prevent "simplification" refactors **Rationale:** These comments protect against future developers accidentally reverting the fix or "optimizing" the test code by reusing connections, which would reintroduce the transaction isolation bug. **Impact:** - No functional changes - documentation only - Improves long-term maintainability - All 14 embedding service tests still pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
* Fix: Resolve failing Rust embedding service tests (issue #343) **Problem:** Four embedding service tests were failing with assertion errors where embedding metadata wasn't being stored correctly in the database. **Root Causes Identified:** 1. **JSON Metadata Storage Bug (3 tests)** - `store_embedding` method was passing metadata as a string to `json_set()` - SQLite's `json_set()` requires JSON type, not string type - This caused `properties["embedding_metadata"]["type"]` to be `Null` instead of expected values like `"complete_container"` or `"container_summary"` 2. **Database Transaction Isolation Issue (1 test)** - `test_re_embed_container` held a database connection across content update and re-embedding - This caused embeddings to appear identical when they should have been different - The second embedding was reading stale data from the open transaction **Fixes Applied:** 1. **packages/core/src/services/embedding_service.rs:678** - Changed `json_set(properties, '$.embedding_metadata', ?)` to use `json(?)` wrapper - Now: `json_set(properties, '$.embedding_metadata', json(?))` - This ensures SQLite parses the JSON string into a proper JSON value 2. **packages/core/src/services/embedding_service_test.rs:247-290** - Refactored connection management to use scoped blocks - Each database operation now gets a fresh connection that is dropped immediately - Ensures transactions commit and data is visible to subsequent operations **Test Results:** - ✅ All 14 embedding service tests now pass (previously 10/14) - ✅ Fixed tests: `test_chunking_strategy_small`, `test_chunking_strategy_medium`, `test_chunking_strategy_large`, `test_re_embed_container` - ✅ No regressions in other tests **Impact:** - Embedding metadata is now correctly stored in the `properties` JSON field - Re-embedding operations correctly detect content changes - Test suite validates embedding functionality comprehensively 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Docs: Add explanatory comments for embedding service fix (issue #343) **Code Review Follow-up:** Added inline documentation to clarify the subtle bug fixes from the previous commit. **Changes:** 1. **embedding_service.rs:675-677** - Added comment explaining json() wrapper - Documents why json() is necessary for SQLite's json_set() - Prevents future regression of this subtle string-vs-JSON bug - Critical for maintainability since the bug causes silent data corruption 2. **embedding_service_test.rs** - Enhanced connection scoping comments - Line 260: "Drop connection to commit transaction and ensure data visibility" - Line 264: "Fresh connection for the update operation" - Line 272: "Drop connection to commit transaction" - Line 279: "Fresh connection ensures we see the committed content update" - Documents intentional pattern to prevent "simplification" refactors **Rationale:** These comments protect against future developers accidentally reverting the fix or "optimizing" the test code by reusing connections, which would reintroduce the transaction isolation bug. **Impact:** - No functional changes - documentation only - Improves long-term maintainability - All 14 embedding service tests still pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This was referenced Jul 22, 2026
6 of 11 tasks
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.
Closes #343