Sync: a remote-win field patch re-sends the loser's older fields at the winner's time, beating a third device's newer edit
Follow-up to #10415 (second review, finding 1) and #10393. It depends on #10421. Related: #10260.
Problem
#10415 resolves an update-vs-update conflict as one 'patch' built from both sides.
- The winner is chosen per side:
synthesizeMergedChangesreturns{...loser, ...winner}. - The patch is stamped with the max timestamp over all ops.
So when a device resolves a remote win, it re-sends its own older loser-only fields inside an opaque row that carries the winner's newer time. Those fields then beat a third device's newer edit of the same field.
Reproduction
This is pinned as current behavior in src/app/op-log/testing/integration/sync-fuzz/field-patch-timestamp.integration.spec.ts.
- A writes notes, then renames, offline.
- C writes newer notes, offline.
- B renames last and syncs.
- A syncs, then C syncs.
| title | notes | |
|---|---|---|
| #10415 (all devices) | B title | A notes (older) |
| correct LWW | B title | C notes (newest) |
| master | B title | C notes, but A's notes edit is lost entirely (#10260) |
Not a fix on its own: stamping with the loser's time
I tried stamping the patch with A's own time (the reviewer's suggestion, also restricted to loser-only fields). It breaks convergence:
- C's newer edit beats the opaque patch row.
- C then wins whole-entity with a pre-batch replace snapshot (#10421).
- A and B end with title
'task', both renames lost, and C keeps'B title'.
Do not change the timestamp until #10421 lands.
Proposed direction (not decided)
- After #10421, a remote win re-sends the loser's fields readably, at the loser's own time. Options:
- an existing action such as
TaskSharedActions.updateTask; - a
'patch'with per-field timestamps derived on the reader. No new wire key, action type or schema bump is needed for the op itself.
- an existing action such as
- A readable op alone is not enough. When C resolves, its remote side would be {B title t4, A notes t2}, and the side-level merge would still let A's notes win at t4. So the merge also needs a per-field winner from each op's own timestamp (client-only logic).
Open risks:
- Released clients still merge side-level.
- On file-based providers, two resolvers both emit readable ops.
- A resolver writing a user-action op strains "one user intent = one op".
Needs an E2E reproduction (three devices) first.
Source: super-productivity/super-productivity