super-productivity/packages/sync-core/tests
Johannes Millan 9132ab6722
fix(sync-core): break whole-entity LWW timestamp ties by clientId (#9035)
* fix(sync-core): break whole-entity LWW timestamp ties by clientId

An exact-millisecond timestamp tie on the same field of one entity fell
to remote-wins with no tiebreak. Because local/remote are swapped between
devices, each kept the other's value and diverged permanently.

Fall back to a deterministic larger-clientId compare on the tie (mirrors
noiseTiebreakSide), routing a local tie-win through the existing
localWinOperationKind: 'update' path so the compensating op preserves the
local value and dominates the loser's clock.

* refactor(sync-core): tidy LWW tiebreak helper + strengthen tie tests

Multi-review follow-up (no behavior change):
- drop unreachable `?? ops[0]` fallback and the unused generic in
  winningClientId; correct the doc comment's "mirrors" overstatement.
- rewrite the mislabeled service-level tie test that never exercised the
  tiebreak and add the local-clientId-larger direction (compensating op).

* test(sync): cover LWW client-ID tie-win over a concurrent remote DELETE

The tiebreak reaches _createLocalWinUpdateOp's delete-recreation branch via
a tie (not just a newer timestamp); assert the entity is still recreated.
2026-07-15 13:03:09 +02:00
..
compression.spec.ts refactor(sync): post-extraction review cleanup of @sp/sync-core and @sp/sync-providers (#7595) 2026-05-14 13:06:08 +02:00
conflict-resolution.spec.ts fix(sync-core): break whole-entity LWW timestamp ties by clientId (#9035) 2026-07-15 13:03:09 +02:00
download-planning.spec.ts refactor(sync): extract snapshot hydration planning 2026-05-12 00:52:50 +02:00
encryption.spec.ts refactor(sync): post-extraction review cleanup of @sp/sync-core and @sp/sync-providers (#7595) 2026-05-14 13:06:08 +02:00
error.util.spec.ts refactor(sync): extract sync file prefix helpers 2026-05-11 21:21:25 +02:00
full-state-op-types.spec.ts refactor: remove dead SyncStateCorruptedError, compat exports, and 0 byte sync-providers barrel #8328 (#8396) 2026-06-15 14:16:14 +02:00
remote-apply.spec.ts fix(sync): harden op-log replay and recovery (#8978) 2026-07-13 20:03:42 +02:00
replay-coordinator.spec.ts fix(sync): harden op-log replay and recovery (#8978) 2026-07-13 20:03:42 +02:00
sync-file-prefix.spec.ts refactor(sync): post-extraction review cleanup of @sp/sync-core and @sp/sync-providers (#7595) 2026-05-14 13:06:08 +02:00
sync-import-filter.spec.ts refactor(sync): post-extraction review cleanup of @sp/sync-core and @sp/sync-providers (#7595) 2026-05-14 13:06:08 +02:00
upload-planning.spec.ts fix(sync): remediate sync-correctness review findings 2026-07-10 13:25:30 +02:00
vector-clock.spec.ts refactor(sync): post-extraction review cleanup of @sp/sync-core and @sp/sync-providers (#7595) 2026-05-14 13:06:08 +02:00