Skip to main content

Memory Sync Tutorial

⚠️ Work in Progress - This documentation is being developed Learn how to implement cross-device memory synchronization for Soul Kernel.

Overview

This tutorial will cover:
  • CRDT-based conflict resolution
  • Device identity management
  • Sync protocol implementation
  • Offline-first synchronization
  • Privacy-preserving sync

Prerequisites

Coming Soon

This tutorial is currently being developed as part of Epic-2, Story-6: Sync Service Stub & Conflict Resolution.

Temporary Example

Until the full sync implementation is complete, here’s a basic approach:
use storage::{MemoryStore, MemoryEvent};

async fn basic_sync_example(
    local_store: &impl MemoryStore,
    remote_store: &impl MemoryStore,
    last_sync: i64,
) -> Result<(), Box<dyn std::error::Error>> {
    // Get new local events
    let local_events = local_store.get_events_since(last_sync, 1000).await?;
    
    // Get new remote events
    let remote_events = remote_store.get_events_since(last_sync, 1000).await?;
    
    // Simple merge (in practice, use CRDT logic)
    for event in remote_events {
        // Check if we already have this event
        if local_store.get_event(&event.id).await?.is_none() {
            local_store.insert_event(&event).await?;
        }
    }
    
    Ok(())
}

See Also

Change Log

  • 2025-06-13: Placeholder created, awaiting sync implementation