Critical Timestamp Regression Fix
This is a critical hotfix addressing a timestamp corruption bug that affected v8.25.0-v8.27.0.
Problem
The bidirectional sync and drift detection features incorrectly reset created_at timestamps to the current time during metadata updates. This caused all synced memories to appear "just created", destroying historical timestamp data.
Impact: 2,174+ memories in production databases had timestamps corrupted. All hybrid backend users on v8.25.0-v8.27.0 are affected.
Root Cause
The preserve_timestamps=False parameter in update_memory_metadata() reset both created_at and updated_at timestamps, when it should only update updated_at.
Solution
- Modified
update_memory_metadata()to always preservecreated_atfrom source memory during sync - Hybrid storage now passes all 4 timestamp fields during drift detection
- Cloudflare storage updated for consistent timestamp handling across backends
Files Modified:
src/mcp_memory_service/storage/sqlite_vec.py(lines 1389-1406)src/mcp_memory_service/storage/hybrid.py(lines 625-637, 935-947)src/mcp_memory_service/storage/cloudflare.py(lines 833-864)
Tests Added:
tests/test_timestamp_preservation.py- 7 comprehensive regression tests
Recovery Tools
If your database was affected (hybrid backend, v8.25.0-v8.27.0), use these recovery tools:
1. Validate Timestamp Integrity
python scripts/validation/validate_timestamp_integrity.pyThis checks for:
- Impossible timestamps (created_at > updated_at)
- Suspicious timestamp clusters (bulk reset indicators)
- Timestamp distribution anomalies
2. Recover Corrupted Timestamps
# Preview recovery (dry-run)
python scripts/maintenance/recover_timestamps_from_cloudflare.py --dry-run
# Apply recovery
python scripts/maintenance/recover_timestamps_from_cloudflare.py --applyThis restores correct created_at timestamps from Cloudflare backups.
Upgrade Instructions
For all hybrid backend users:
-
Upgrade immediately:
pip install --upgrade mcp-memory-service # or uv pip install --upgrade mcp-memory-service -
Validate your database:
python scripts/validation/validate_timestamp_integrity.py
-
If validation shows issues, run recovery:
# Preview first python scripts/maintenance/recover_timestamps_from_cloudflare.py --dry-run # If preview looks good, apply python scripts/maintenance/recover_timestamps_from_cloudflare.py --apply
-
Re-validate after recovery:
python scripts/validation/validate_timestamp_integrity.py
Changed Semantics
The preserve_timestamps parameter now has clearer behavior:
preserve_timestamps=True(default): Only updatesupdated_atto current time, always preservescreated_atpreserve_timestamps=False: Uses timestamps fromupdatesdict if provided, always preserves existingcreated_atcreated_atis never reset to current time (this was the bug)
What's Fixed
- Timestamp preservation during hybrid sync operations
- Drift detection no longer corrupts
created_attimestamps - Bidirectional sync preserves historical timestamp data
- Cloudflare ↔ SQLite-vec sync maintains timestamp integrity
- Comprehensive regression tests prevent future issues
Affected Versions
- v8.25.0: Introduced drift detection with timestamp bug
- v8.27.0: Enhanced bidirectional sync amplified the issue
For More Information
- See CHANGELOG.md for full technical details
- Test suite:
tests/test_timestamp_preservation.py - Recovery tools in
scripts/maintenance/andscripts/validation/
This is a critical update. All hybrid backend users should upgrade immediately and run validation tools.
Generated with Claude Code (https://claude.com/claude-code)
Co-Authored-By: Claude noreply@anthropic.com