Repository navigation
Remove NodeStore abstraction, use SurrealDB directly #470
Copy link
Copy link
Closed
Labels
Description
Context
Epic #461 successfully implemented SurrealStore but left the migration incomplete. NodeService still has dual dependencies:
store: Arc<dyn NodeStore>- Trait abstraction (partially used)db: Arc<DatabaseService>- Direct Turso/SQLite access (still heavily used)
Discovery: 12+ methods in NodeService still call self.db.connect_with_timeout() directly. Embedding services also depend on DatabaseService.
Goal
Complete the migration Epic #461 started by:
- Removing the NodeStore abstraction layer
- Migrating all remaining DatabaseService usage to SurrealStore
- Making SurrealDB the only backend
Revised Scope
Keep (Reuse from #461)
packages/core/src/db/surreal_store.rs- Full SurrealDB implementation (670 lines)- SurrealDB schema design and documentation
- All SurrealStore unit tests
Delete (Abstraction Overhead)
- ✅
packages/core/src/db/node_store.rs- Trait definition - ✅
packages/core/src/db/turso_store.rs- Wrapper around DatabaseService - ✅
packages/core/src/db/database.rs- Old DatabaseService (Turso/SQLite) - ✅
packages/core/src/db/ab_testing.rs- A/B testing framework - ✅
packages/core/src/db/metrics.rs- Metrics collection - ✅
packages/core/src/db/ab_tests.rs- Integration tests comparing backends
Migrate (Complete Epic #461's Partial Work)
packages/core/src/services/node_service.rs- Remove
db: Arc<DatabaseService>field - Change
store: Arc<dyn NodeStore>tostore: Arc<SurrealStore> - Replace all
self.db.*calls withself.store.*methods - Remove trait-based indirection (direct method calls)
- Remove
packages/core/src/services/embedding_service.rs- Replace
Arc<DatabaseService>withArc<SurrealStore> - Update constructor and internal logic
- Replace
packages/core/src/services/embedding_processor.rs- Replace DatabaseService dependency
packages/core/src/db/mod.rs- ✅ Export SurrealStore directly
- ✅ Remove NodeStore trait exports
packages/core/src/lib.rs- ✅ Export SurrealStore instead of DatabaseService
- All service initialization code (desktop-app)
- Replace DatabaseService creation with SurrealStore
- Update dependency injection
Acceptance Criteria
- DatabaseService completely removed from codebase
- NodeStore trait abstraction removed
- TursoStore wrapper removed
- A/B testing infrastructure removed
- NodeService uses SurrealStore directly (no trait, no dual db field)
- NodeService has zero
self.dbreferences - Embedding services use SurrealStore
- All initialization code uses SurrealDB
- All tests pass (no regressions)
- Code compiles without warnings
- Documentation updated (no references to Turso/abstraction/DatabaseService)
Testing
- Run full test suite:
bun run test:all - Run Rust tests:
cargo test --package nodespace-core - Verify SurrealDB initialization works
- Confirm all NodeService operations work with SurrealStore
- No trait dispatch overhead (direct method calls)
Estimated Effort
3-4 hours (revised from original 2-3 hours estimate)
Breakdown:
- 1 hour: Complete NodeService migration (remove
self.dbfield, migrate all calls) - 1 hour: Update embedding services
- 30 min: Fix initialization code in desktop-app
- 30 min: Clean up test files
- 1 hour: Testing and bug fixes
Dependencies
- Epic SurrealDB Migration - Hybrid Architecture (Desktop-Only) #461 (merged to main) - Provides SurrealStore implementation
- SurrealStore implementation fully functional
Strategic Rationale
Why SurrealDB:
- Built-in version history (planned feature)
- RBAC for collaborative sync (planned feature)
- Better performance characteristics (proven in PoC SurrealDB Feasibility PoC - Quick Evaluation #460)
- Simpler to maintain one backend pre-launch
Why remove abstraction:
- Zero users = no migration needed
- Won't switch back to Turso
- Epic SurrealDB Migration - Hybrid Architecture (Desktop-Only) #461's migration was incomplete - finish what was started
- ~2,000 lines of abstraction code we'll never use
- Direct access to SurrealDB-specific features needed
- Maintaining half-migrated code is worse than completing the migration
Why complete now:
- Tech debt compounds - half-migrated code is hardest to maintain
- Zero users means perfect time for breaking changes
- Need direct SurrealDB access for future features (versioning, RBAC)
Related:
- Epic SurrealDB Migration - Hybrid Architecture (Desktop-Only) #461: SurrealDB Migration (merged, but migration incomplete)
- Issue SurrealDB Feasibility PoC - Quick Evaluation #460: SurrealDB PoC (performance validated)
Status: In Progress - Abstraction layer deleted, NodeService migration underway
Reactions are currently unavailable
Activity
malibio commentedon Nov 12, 2025
Test Baseline Recorded
Frontend tests: 728 passed, 0 failed, 35 skipped
Starting implementation: Removing NodeStore abstraction layer and switching to direct SurrealDB usage.
WIP: Complete SurrealDB migration - Phase 1 (nodespace-core lib compi…
WIP: Fix critical SurrealDB version increment bugs - Phase 3 progress
WIP: Fix 24 SurrealDB migration tests - Phase 3 complete (451/455 pas…
WIP: Fix 4 remaining SurrealDB migration tests - Phase 3 complete (45…
WIP: Complete SurrealDB migration - Phase 1 (nodespace-core lib compi…
WIP: Fix critical SurrealDB version increment bugs - Phase 3 progress
WIP: Fix 24 SurrealDB migration tests - Phase 3 complete (451/455 pas…
WIP: Fix 4 remaining SurrealDB migration tests - Phase 3 complete (45…
Address code review feedback from PR #485
malibio commentedon Nov 13, 2025
✅ Completed and merged in PR #485
Summary
Successfully completed the SurrealDB migration by removing all abstraction layers and migrating NodeSpace to use SurrealDB as the single, direct backend.
What Was Accomplished
Deleted (~8,860 lines):
Migrated:
self.dbreferences remainingAcceptance Criteria: 10/11 Met (91%)
self.dbreferencesImpact
Follow-Up Work
Merged: 2025-11-13
PR: #485 (6 commits, 455 tests passing)
Review: Code review completed, all blockers resolved
12 remaining items
Complete SurrealDB migration - Advanced features (#487)
WIP: Complete SurrealDB migration - Phase 1 (nodespace-core lib compi…
WIP: Fix critical SurrealDB version increment bugs - Phase 3 progress
WIP: Fix 24 SurrealDB migration tests - Phase 3 complete (451/455 pas…
WIP: Fix 4 remaining SurrealDB migration tests - Phase 3 complete (45…
Address code review feedback from PR #485
Update documentation to reflect SurrealDB-only architecture
Merge documentation updates: Reflect SurrealDB-only architecture
Complete SurrealDB migration - Advanced features (#487)
WIP: Complete SurrealDB migration - Phase 1 (nodespace-core lib compi…
WIP: Fix critical SurrealDB version increment bugs - Phase 3 progress
WIP: Fix 24 SurrealDB migration tests - Phase 3 complete (451/455 pas…
WIP: Fix 4 remaining SurrealDB migration tests - Phase 3 complete (45…
Address code review feedback from PR #485
Complete SurrealDB migration - Advanced features (#487)