Deterministic synchronization engine for local-first systems.
The sync module is the brain of Softadastra.
It is responsible for:
Converging multiple devices toward the same state, despite failures, disconnections, and unordered events.
The goal of softadastra/sync is simple:
Take local operations and remote operations, and ensure all peers converge to the same result.
Order does not matter. Convergence does.
The system must produce the same final state:
- Regardless of operation order
- Despite network interruptions
- Across different devices
The sync module provides:
- Sync planning (what to send / what to receive)
- Operation comparison
- Conflict handling (basic in MVP)
- Application of remote operations
- Replay coordination with WAL
- Recovery after disconnection
- No filesystem watching (fs module)
- No durability (wal module)
- No network transport (transport module)
- No raw storage (store module)
👉 It orchestrates everything, but owns no low-level concern.
All peers must reach the same state.
Applying the same operation multiple times must be safe.
State is reconstructed from operations, not assumptions.
The system must work under:
- Disconnections
- Delays
- Partial updates
Represents a logical change.
Examples:
- File created
- File updated
- File deleted
Includes:
- Identifier
- Version / sequence
- Payload
The main orchestrator.
Responsible for:
- Driving synchronization cycles
- Coordinating modules
- Managing sync state
Decides:
- What operations are missing
- What needs to be sent
- What needs to be requested
Applies incoming operations:
- Validates operations
- Applies changes
- Ensures idempotency
Handles inconsistencies:
- Resolves divergence
- Ensures convergence
- Applies conflict rules (basic in MVP)
Tracks:
- Operations waiting to be sent
- Operations waiting to be applied
- File changes detected (fs)
- Operation created
- Operation written to WAL
- Operation enters sync queue
- Planner schedules it for sending
- Transport sends it
- Operation received (transport)
- Sync validates it
- SyncApplier applies it
- Store updates file
- Metadata updated
- Node restarts
- WAL is replayed
- Sync rebuilds state
- Missing operations are requested
- System converges
- softadastra/core
- softadastra/wal
- softadastra/metadata
- softadastra/transport
- softadastra/store
- softadastra/fs
The sync module ensures:
- Eventual consistency
- Deterministic convergence
- No lost operations
- Recovery after interruption
Designed to handle:
- Offline peers
- Network partitions
- Out-of-order messages
- Duplicate operations
- 2 peers
- LAN only
- Basic operations
- Simple conflict strategy (last-write-wins)
- Multi-peer synchronization
- Advanced conflict resolution (CRDT / vector clocks)
- Partial sync (delta transfer)
- Sync over unreliable networks
- Compression and batching
- End-to-end encryption
- Never trust ordering from network
- Never apply without validation
- Always support replay
- Always converge
The sync engine is not about speed.
It is about correctness under failure.
- Orchestrates synchronization
- Ensures convergence
- Handles failures
- Coordinates all modules
vix add @softadastra/sync
vix depsSee root LICENSE file.