Quality Score Persistence Fix for Hybrid Backend
This release fixes a critical bug where ONNX quality scores were not persisting to Cloudflare in hybrid storage backend, causing scores to remain at default 0.5 instead of evaluated ~1.0 values.
Fixed
-
Quality Score Persistence - ONNX quality scores now persist correctly to Cloudflare in hybrid backend
- Scores remained at default 0.5 instead of evaluated ~1.0 values
- Root cause:
/api/quality/evaluateendpoint was passing entirememory.metadatadict - Fix: Extract only quality-related fields before persisting
-
Metadata Normalization - Added
_normalize_metadata_for_cloudflare()helper function- Separates Cloudflare-recognized top-level keys from custom metadata fields
- Wraps custom fields in 'metadata' key as expected by Cloudflare D1
- Idempotent operation (only wraps if not already wrapped)
-
Enhanced Sync Operations - Added
preserve_timestampsflag toSyncOperation- Ensures timestamp preservation through background sync queue
- Maintains temporal consistency across hybrid backends
Verification
- ONNX evaluation returns quality_score ~1.0
- Scores persist to SQLite-vec correctly
- Scores sync to Cloudflare D1 successfully
- Search results show quality 1.000 instead of 0.500
Impact
- Affects only hybrid backend with Cloudflare secondary storage
- SQLite-vec primary storage was working correctly
- Issue manifested during background sync to Cloudflare D1
- No breaking changes to API or configuration
Files Changed
src/mcp_memory_service/web/api/quality.py- Extract quality fields onlysrc/mcp_memory_service/storage/hybrid.py- Add metadata normalization + preserve_timestamps
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com