Skip to content

fix(sync): keep local edits ahead of every clock this device has seen - #1542

Merged
A-EDev merged 1 commit into
mainfrom
fix/sync-clock
Oct 29, 2026
Merged

A-EDev merged 1 commit into
mainfrom
fix/sync-clock

Conversation

@A-EDev

@A-EDev A-EDev commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

An edit made right after a sync could lose to the very change it followed: last-writer-wins compares stamps, and this device stamped its edit with its own wall clock, which may be behind the other device's. Flow-Tube/flow-sync#38 now says what "hybrid logical clocks are persisted" means, and this implements it:

  • DeviceIdentity keeps the highest physical time of any stamp this device has applied (clock_ms in the existing sync_identity store).
  • editTime() returns max(now, that + 1).
  • SyncChangeTracker stamps every local edit and tombstone with editTime(), and raises the mark whenever a merge settles.

The wire format doesn't change. This covers FLOW-SYNC/1 sessions and the coming linked-devices sync alike.

Related issue

Part of #1075 (linked devices).

Change type

  • Bug fix
  • Feature
  • Refactor or maintenance
  • Build, packaging, or CI
  • Documentation

Validation

  • ./gradlew :app:assembleGithubDebug: ok (on top of fix(sync): let sync remove a channel from a group #1543, which includes this commit)
  • ./gradlew :app:testGithubDebugUnitTest: 4570 passed, 46 skipped, 0 failed (same); new SyncChangeTrackerTest.an_edit_after_a_newer_peer_stamp_is_stamped_after_it
  • ./gradlew ktlintCheck: ok
  • I manually tested the affected behavior on an Android device or emulator. (Not run on a device; covered by unit tests.)

Test device and Android version: none (JVM tests)

Risk and compatibility

One new key in the existing device-only sync_identity DataStore. Flow Desktop ships the same rule in its own PR.

  • The change does not introduce secrets, private data, or unexpected telemetry.
  • New user-facing text uses Android string resources. (None.)
  • Dependency and lockfile changes are intentional and limited to this PR. (None.)
  • Room schema changes include the required version bump and migration, or this PR does not change the Room schema.
  • Breaking changes and upgrade steps are clearly documented. (None.)

@github-actions github-actions Bot added documentation Improvements or additions to documentation sync Device-to-device sync labels Oct 29, 2026
@A-EDev
A-EDev merged commit c53dae4 into main Oct 29, 2026
9 checks passed
@A-EDev
A-EDev deleted the fix/sync-clock branch October 29, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation sync Device-to-device sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant