a-ludi / a-ludi/tasks-harmony

Auto-sync: pull-merge-push conflict resolution

Aberta
#50 0 comentários 0 reações 0 responsáveis Ver no GitHub
enhancement
Linguagem predominante
TypeScript
Estrelas
1
Forks
0
Merge médio
9min
PRs com merge (30d)
1

Descrição

## 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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

A issue descreve a substituição de um mecanismo de sincronização last-write-wins por uma estratégia pull-merge-push. Procure a implementação existente de auto-sync e seu tratamento de ETag. A lógica de merge para completions (união) e chore definitions (o `updatedAt` mais recente) precisa ser implementada. Testes Unit e E2E são necessários. Comece encontrando o serviço de sync e o código atual de resolução de conflitos.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Domínio
backend, data
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Pouca atividade
Clareza
Claramente especificada
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.