fix: simplify entity upsert to use database-level conflict resolution#328
fix: simplify entity upsert to use database-level conflict resolution#328phernandez merged 1 commit intomainfrom
Conversation
This implementation uses SQLite's UNIQUE constraints to detect conflicts rather than complex application-level pre-checks. When an IntegrityError occurs, we check if it's a file_path conflict (update existing) or permalink conflict (generate unique suffix). Key improvements: - 71 lines vs 300+ in previous approaches - Let database handle race conditions via constraints - Single try/catch pattern - insert first, handle on exception - Preserves ORM relationships for observations/relations - No YAGNI violations - only necessary methods Fixes #205 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task —— View job PR Review - Issue #205 Entity Upsert Simplification ✅I've completed a comprehensive review of this PR against Basic Memory's team checklist. This is an excellent simplification that improves both code quality and maintainability. Code Quality & Standards ✅
Testing & Documentation ✅
Basic Memory Architecture ✅
Security & Performance ✅
Key Improvements 🎯This PR demonstrates excellent engineering judgment: 1. Simplification (71 lines vs 300+)The new approach removes unnecessary complexity:
2. Correctness
3. Performance
4. Maintainability
Detailed Code Analysis
|
…#328) Signed-off-by: phernandez <paul@basicmachines.co> Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Comprehensive changelog for v0.15.0 release covering: - Critical permalink collision data loss fix - 10+ bug fixes including #330, #329, #328, #312 - 9 new features including cloud sync and subscription validation - Platform improvements (Python 3.13, Windows, Docker) - Enhanced testing and documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Summary
Replaces PR #311 with a much simpler implementation that uses SQLite's UNIQUE constraints to detect conflicts rather than complex application-level pre-checks.
Changes
Key Improvements
✅ Simplicity - single try/catch, database does the work
✅ Correctness - properly handles observations via ORM cascade
✅ Race conditions - resolved by checking existing entity after IntegrityError
✅ No YAGNI violations - only necessary methods
✅ Easy to reason about - linear flow, clear error handling
Testing
All existing tests pass, including:
test_entity_repository_upsert.py- 8/8 tests passingtest_knowledge_router.py::test_create_entity_observations_relations- fixedCloses #205
🤖 Generated with Claude Code