In a household app syncing two partners' phones, why should conflict rules run on the server, and when must a phone still resolve one with the user?
answer
- where do all writes meet
- two app versions, two merge results
- rules change without an app release
- the phone owns the human choice
- the choice sent as a new write
basics
~20 sThe server sees every write in one order, so both phones get one verdict and rules change without a release. A phone settles only what needs a person, keeping the user's text, showing both and sending the choice as a new write.
solid answer
~50 sIf each phone merges on its own, both phones must run identical, deterministic rules, and they rarely do once one partner is three releases behind: the same pair of edits merges differently on each phone and the copies drift. A server-authoritative design puts the rules where all writes meet: the server applies each edit against the current record, merges or keeps per the data type's policy, and returns the result with a new revision that every phone then pulls. Rules change with a server deploy, not an app release. The phone keeps one job: the conflict a person must settle. When the server reports that two rewrites of a note clash, it returns its current version; the phone keeps the user's text as a local draft, marks the note as needing a decision and shows both. The choice goes up as a fresh write based on the server's current revision.
go deeper
Remember that the server, which sees every write, decides conflicts, and the phone asks the user only when a person must choose.
Explain the server's loop, compare revisions, apply the policy, return a new revision, and the conflict answer that carries the current version.
Design the human path end to end: the preserved draft, the non-blocking marker, the comparison, and a resolution write based on the current revision.
Argue where rules must live when old app builds stay in the field for months, and which data, if any, may still merge on the device.
## Two places a conflict can be resolved In a **shared household app**, two partners keep shopping lists, chore checklists and notes on their own phones, often offline. When their edits clash, something has to apply the conflict policy, and there are two candidates. | | Server-authoritative | Merge on each phone | |---|---|---| | Who sees every write | The server, in one order | Each phone sees its own plus what it pulled | | Same verdict on both phones | Yes, by construction | Only if rules and inputs are identical | | Changing a rule | A server deploy | An app release and every user updating | | Old app versions | Get the new rule at once | Keep merging the old way | | Needs the user | Only for clashes a person must settle | Same | **Server-authoritative** means the server holds the copy of record and decides how a stale edit is merged. Phones show the server's outcome once they pull it, with their own pending edits layered on top until those are accepted. ## Why phones that merge on their own drift - **Different builds, different rules.** One partner updates weekly, the other every few months. If the merge logic changed in between, the same two edits merge differently on each phone. - **Different inputs.** Each phone merges with what it has pulled so far. A phone that missed a third change produces a result the other phone never computes. - **No one to referee.** Once two phones disagree and each believes it merged correctly, there is no copy that says which one is right. - **Hidden fixes.** A bug in merge code on the phone stays in the field for as long as people run that build. Rules that live on the server avoid all four. Common offline-first guidance makes the same split: the app keeps the bookkeeping, versions and timestamps, and the network data source is responsible for being the source of truth. ## What server-authoritative looks like 1. The phone sends its edit with the changed fields and its base revision. 2. The server loads the current record and compares revisions. 3. If the base is current, it applies the edit; if not, it applies that data type's policy: merge by field, keep the latest, add an increment. 4. It returns the result and a new revision. 5. The other phone pulls the change and replaces its copy. 6. Only when the policy says a person must decide does the server return a conflict instead of a result. ## The conflict a person must settle For data such as a note body, where either version may hold work that cannot be recreated, the server stops and hands the decision back: 1. The server answers the edit with a conflict that carries its current version and current revision. 2. The phone keeps the user's own text as a local draft. It is never discarded at this point. 3. The phone marks the note as needing a decision and lets the rest of the household's data keep syncing. 4. When the user opens the note, the phone shows both versions side by side, with **keep mine**, **keep theirs** and **edit a combined version**. 5. The user's choice goes up as a new write whose base is the server's current revision from step 1. 6. If the partner has edited again since, the server answers with a fresh conflict and the comparison is refreshed rather than overwritten. ## What the user sees - A badge or marker on the note, not a dialog that interrupts whatever the user is doing when sync finishes. - Names and times on both versions ("Sam, 12:40"), so the choice is informed. - The user's own text preserved until they decide, even across app restarts. - One prompt per clash, never one per sync attempt. ## When the phone merges more Some designs sync phones directly, or keep the server unable to read the content, so the phones must merge it themselves. Then the rules must be deterministic, versioned and identical across builds, and the app needs a plan for the moment two versions disagree.
- Should the conflict prompt appear as a dialog the moment sync finishes?No. Sync often finishes in the background while the user is doing something else, and a dialog then interrupts unrelated work and invites 'keep mine' without reading. Mark the note, count unresolved clashes in a badge, show both versions when the user opens it, and keep the rest of the data syncing meanwhile.
- What if the partner edits the note again before the user resolves the clash?The resolution write carries the server revision the phone showed. If the server has moved on, it answers with a new conflict and the newer version, and the phone refreshes the comparison instead of overwriting. The user's own text stays in the local draft the whole time, so nothing typed is lost.
- Phones merging on their own will always agree because they run the same app.
- Server-authoritative means the phone never has to handle a conflict.
- The losing note text can be discarded once the server picks a winner.
- A conflict should pause all syncing until the user resolves it.
- The resolved version can be sent with the edit's original base revision.