Auto-sync: pull-merge-push conflict resolution
- Ngôn ngữ chính
- TypeScript
- Star
- 1
- Fork
- 0
- Merge trung bình
- 9 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
## Summary
This is a follow-up to the initial auto-sync implementation, which uses last-write-wins conflict resolution. This issue tracks the smarter merge-based approach.
## Current Behavior
The initial auto-sync implementation uses **last-write-wins** semantics backed by ETags:
- Each device compares the server ETag before pushing.
- On an ETag mismatch (another device pushed more recently), the pushing device loses: its changes are discarded and overwritten on the next pull.
- This is safe and simple, but can silently discard legitimate changes made on the losing device (e.g. task completions recorded offline).
## Desired Behavior
On an ETag mismatch, instead of aborting, the sync process should:
1. **Pull** the current server state.
2. **Merge** local and remote state automatically:
- Completions: take the **union** (a task completed on either device counts as completed).
- Chore definitions: **latest definition wins** (most recent `updatedAt` timestamp takes precedence).
3. **Push** the merged result to the server.
4. Surface a conflict to the user **only** when auto-resolution is not possible (e.g. a chore was deleted on one device and modified on the other).
The goal is that for typical usage — completing tasks on one device while another device is offline — no user interaction is required. The merge resolves silently in the background.
## Why This Matters
As users start relying on auto-sync across multiple devices or across offline/online transitions, silent data loss from last-write-wins will become a real pain point. Pull-merge-push makes sync feel reliable and trustworthy without burdening users with manual conflict resolution in the common case.
## Acceptance Criteria
- [ ] On ETag mismatch during push, automatically pull and merge server state.
- [ ] Merged completions are the union of local and remote completions.
- [ ] Merged chore definitions use the latest `updatedAt` to determine the winner.
- [ ] The merged state is pushed to the server with the updated ETag.
- [ ] Only unresolvable conflicts (if any are identified) are surfaced to the user.
- [ ] Existing last-write-wins sync path is replaced or superseded by the new logic.
- [ ] Unit tests cover merge logic for completions and chore definitions.
- [ ] E2E test covers the two-device concurrent-edit scenario.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.