An app used on several devices needs to keep working when some are offline. Changes may arrive late or more than once, two devices may edit the same item, and a connection can fail halfway through an upload. Keeping every change forever also makes synchronization increasingly costly.
day-sync is an experimental Rust library for synchronizing a day-persistence store through shared file storage. Each device keeps its own database and exchanges changes through a folder or WebDAV collection. The devices perform the merging; the storage service does not need to understand the app's data.
A local edit and the record needed to synchronize it are saved together. The app can keep working offline and send those records later. When it syncs, day-sync checks incoming data, combines it with local changes, and publishes outstanding work. Repeated delivery is safe, and interrupted work can resume from durable local records.
Changes carry enough history to distinguish an edit that replaces an earlier value from two edits made independently. Concurrent versions are preserved and resolved using a consistent rule, which the application can customize. Devices converge when they receive the same valid data and use the same application rules.
To keep history manageable, a device can publish a snapshot of the replicated state, including concurrent versions and the information needed to preserve deletions. It reads back and verifies the complete snapshot before removing older inputs it has individually processed. This cleanup does not require every device to be online. A returning device can catch up from snapshots and newer changes without replaying the entire history. Large offline backlogs can also be published directly as a snapshot.
Synchronization may take several passes: cleanup and catch-up are bounded, and the library reports remaining work. The application controls when to sync and retry.
| Crate | Purpose |
|---|---|
day-sync |
Replication, conflict handling, snapshots, recovery, and an in-memory test store. |
day-sync-webdav |
Shared storage through WebDAV, using Day's native HTTP support or reqwest. |
day-sync-filesystem |
Shared storage through a filesystem directory. |
Applications supply an adapter for their data and conflict rules. Additional storage backends can implement the same small storage interface.
This is experimental protocol v5, not a production release. Older protocol formats require fresh v5 stores; there is no automatic migration.
- The storage service and its writers are trusted. Data is plaintext at the protocol layer; checksums detect corruption but do not authenticate authors. WebDAV should use HTTPS and the service's authentication.
- Snapshots preserve current replicated state, not a permanent edit history. Sync is not a backup, and restoring an old database requires a fresh device identity.
- Device counts and state sizes have limits. Safe cleanup needs temporary room for a complete replacement; deletion markers and concurrent versions still occupy space.
- Application profiles can use typed records with an independent key per field group. The v5 envelope retains its bounded two-string encoding. Media transfers use separate immutable objects. The native replica syncs the complete catalog and supports selective file downloads. Browser execution is outside this prototype's scope.
assets::upload_file publishes a whole file under a browsable name and reports outgoing
bytes on the polling task. A retry verifies an existing file before sending any bytes.
upload_with_progress reports verified chunks for resumable chunk-pool transfers.
download_with_progress reports received bytes for named files and verified chunks
for chunked files. Await successful completion before using a file or saving its reference.
- How synchronization works, with illustrated scenarios.
- Application records and media libraries.
- Protocol and integration reference, including limits and recovery.
- Physical-device fault lab, with a disposable server, independent history oracle, and recorded Pixel/iPhone qualification results.
- Automerge experiment and decision, recording why the prototype was retired.
The development instructions cover dependencies and checks. Run the disposable example from the repository root:
cargo run -p day-sync --example compactionLicensed under MPL-2.0.
The documents module also runs in a raw-Wasm browser. It exchanges individually
mergeable documents with one or more stores through strong validators and conditional
updates. Each application defines its schema, conflict rules, deletion markers and
durable local merge. The WebDAV adapter exposes verified versions and the strong
ETags available in a collection listing. A response lost after a write is reconciled
by reading the object. Concurrent writers retry against the new version.
Day Plan uses this exchange for its per-item causal registers. Its document collections have their own versioned application directory. The transactional v5 replica and its snapshots still require the native SQLite worker.