chore: Cloud compatibility fixes and performance improvements#454
chore: Cloud compatibility fixes and performance improvements#454phernandez merged 7 commits intomainfrom
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
asyncpg uses binary protocol which returns timestamps in UTC but as naive datetimes. The previous ensure_timezone_aware() assumed naive datetimes were in local time, causing a 6-hour offset in CST. Now checks cloud_mode_enabled to determine interpretation: - Cloud mode (PostgreSQL/asyncpg): interprets as UTC - Local mode (SQLite): interprets as local time (original behavior) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
- Rewrite setup_logging() in utils.py with explicit parameters: log_to_file, log_to_stdout, structured_context - Add init_cli_logging(), init_mcp_logging(), init_api_logging() to config.py - Remove old setup_basic_memory_logging() and process name detection - Initialize logging at entry points (CLI, MCP, API) - Add logging section to README with env vars documentation Also fixes: - Remove module-level config in project_service.py (test isolation bug) - Update tests to properly mock cloud_mode config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Batch entity lookups instead of making individual find_by_id calls for each relation's from_id and to_id. This reduces ~30 queries down to 1 query when building graph context with relations. - First pass collects all entity IDs needed from relations - Single batch query via find_by_ids fetches all entities - Lookup dict provides O(1) access during summary building - to_summary becomes sync function (no longer needs await) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 47s —— View job PR #454 Review: Cloud compatibility fixes and performance improvementsI've completed a comprehensive review of this PR against Basic Memory's team standards. Here are my findings: ✅ Code Quality & StandardsExcellent Work:
Areas of Concern:❌ File path comparisons are not Windows-compatible (Critical issue for cross-platform support) In # Replace path separators with forward slashes
normalized = normalized.replace("\\", "/")However, this is incomplete for Windows compatibility. The function only normalizes for comparison, but does NOT preserve Windows paths correctly. Several issues:
Recommendation: Use from pathlib import Path, PurePosix Path
def normalize_file_path_for_comparison(file_path: str) -> str:
# Convert to Path, normalize, then to POSIX for comparison
return Path(file_path).as_posix().lower()This issue affects multiple files:
✅ Testing & DocumentationGood:
Concerns:
Recommendation: Add integration tests for cloud mode datetime handling and file service async operations. ✅ Basic Memory ArchitectureExcellent:
Concerns:In from basic_memory.config import ConfigManager
if dt.tzinfo is None:
config = ConfigManager().config # <-- Loads config from disk
if config.cloud_mode_enabled:This creates hidden I/O during what appears to be a pure utility function. Recommendation: Pass
|
|
Claude finished @phernandez's task in 1m 57s —— View job PR #454 Review: Cloud compatibility fixes and performance improvementsI've completed a comprehensive review of this PR against Basic Memory's team standards. Great work addressing the previous review feedback! Here are my findings: ✅ Code Quality & StandardsExcellent Work:
Key Improvements from Previous Review:✅ Windows path compatibility FIXED: The ✅ Testing & DocumentationExcellent Additions:
Coverage Assessment:✅ Cloud mode datetime handling: Fully tested with explicit test cases ✅ Basic Memory ArchitectureExcellent Changes:
Architecture Compliance:✅ Local-first architecture: Preserved ✅ Security & PerformanceGood:
Minor Note:The ✅ CompatibilityWindows Path Handling:✅ FIXED: Console/Log Output:✅ No emojis in logging: Verified no emoji usage in logger statements or console output
📋 Team Checklist ResultsCode Quality & Standards
Testing & Documentation
Basic Memory Architecture
Security & Performance
Compatibility
🎯 SummaryThis PR successfully addresses all critical issues from the previous review and delivers solid improvements: Key Achievements:
Code Quality:
Recommendation: ✅ Approved - Ready to merge This PR demonstrates excellent collaborative development with thorough responses to review feedback. The code is production-ready and follows all Basic Memory team standards. |
- Use pathlib.PurePath.as_posix() for Windows-compatible path normalization - Add optional cloud_mode parameter to ensure_timezone_aware() to avoid implicit config loading when caller has the value - Add tests for ensure_timezone_aware cloud_mode behavior - Add tests for file_service read_file_bytes and read_file_content 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
eab67e2 to
2bd3609
Compare
|
Claude finished @phernandez's task in 2m 29s —— View job PR #454 Review: Cloud compatibility fixes and performance improvementsI've completed a thorough review of this PR against Basic Memory's team standards. This PR addresses critical cloud deployment issues and includes an excellent performance optimization. ✅ Code Quality & StandardsExcellent Work:
Key Improvements:✅ Windows path compatibility VERIFIED:
✅ Entry-point logging initialization (
✅ Testing & DocumentationComprehensive Test Coverage:✅ New test file:
✅ Enhanced file service tests:
✅ Async client tests updated:
✅ Documentation:
✅ Basic Memory ArchitectureMajor Performance Win:🎯 N+1 Query Fix ( # First pass: collect all entity IDs needed for relations
entity_ids_needed: set[int] = set()
for context_item in context_result.results:
for item in [context_item.primary_result] + context_item.observations + context_item.related_results:
if item.type == SearchItemType.RELATION:
if item.from_id:
entity_ids_needed.add(item.from_id)
if item.to_id:
entity_ids_needed.add(item.to_id)
# Batch fetch all entities at once
entity_lookup: dict[int, str] = {}
if entity_ids_needed:
entities = await entity_repository.find_by_ids(list(entity_ids_needed))
entity_lookup = {e.id: e.title for e in entities}Impact: Reduces ~30 individual entity queries to 1 batch query. This is a significant performance improvement for graph context building. Architecture Compliance:✅ Cloud-friendly file_service refactor (
✅ Module-level config bug FIXED (
✅ Timezone handling (
✅ Repository pattern: Followed correctly in N+1 fix ✅ Security & PerformanceSecurity:
Performance:
Minor Note:The ✅ CompatibilityCross-Platform:✅ Windows path handling FIXED:
Console/Log Output:✅ No emojis in production logs: Verified clean
📋 Team Checklist ResultsCode Quality & Standards
Testing & Documentation
Basic Memory Architecture
Security & Performance
Compatibility
🎯 SummaryThis PR successfully addresses critical cloud deployment compatibility issues while delivering a significant performance optimization. Key Achievements:
Code Quality:
CI Status:
✅ Recommendation: Ready to MergeThis PR demonstrates excellent engineering practices with thorough responses to previous review feedback. The N+1 query fix alone is a substantial improvement that will benefit all graph context operations. All team checklist items are satisfied, and the code is production-ready. Previous review concerns addressed:
Great work! 🎉 |
Summary
Test plan
🤖 Generated with Claude Code