from __future__ import annotations from typing import List, Tuple from .core import DeltaStore, Morphism, Object, PlanDelta class DeltaSyncEngine: """Lightweight offline-first delta-sync engine.""" def __init__(self, store: DeltaStore | None = None) -> None: self.store = store or DeltaStore() self.remote_version = 0 self.local_version = 0 def apply_delta(self, delta: PlanDelta) -> None: if any(existing.delta_id == delta.delta_id for existing in self.store.deltas): return self.store.add_delta(delta) self.local_version += 1 def snapshot(self) -> List[PlanDelta]: return list(self.store.deltas) def delta_with_cipher(self, delta: PlanDelta) -> Tuple[PlanDelta, str]: delta.tags["hash"] = f"hash-{delta.delta_id}-{self.local_version}" return delta, delta.tags["hash"] __all__ = ["DeltaSyncEngine", "DeltaStore", "Object", "Morphism", "PlanDelta"]