Ripple Project 3 swift-6.4 / ios-26
Tier 1 · SwiftData
Milestone 2 of 4 · Sync engine
Milestone spec

An actor-isolated sync engine

Notes edit offline and reconcile when connectivity returns. The engine must be an actor, expose an AsyncStream of sync events, and never block the main actor.


Model Note with SwiftData @Model
Local persistence + query by folder
SyncEngine actor with backpressure-safe queue
Conflict resolution: last-writer-wins with vector clock
80%+ coverage on the engine (Swift Testing)
// SyncEngine.swift
actor SyncEngine {
    private let store: ModelContext
    private var pending: [Change] = []
    let events: AsyncStream<SyncEvent>
    private let continuation: AsyncStream<SyncEvent>.Continuation

    init(store: ModelContext) {
        self.store = store
        (events, continuation) = AsyncStream.makeStream()
    }

    func enqueue(_ change: Change) {
        pending.append(change)
        continuation.yield(.queued(change.id))
    }
}