Repository navigation
Conversation
Measure pendant-phone drift from Type-8 clock notifications before SetCurrentTime, then subtract that offset from flash-page timestamps used for session-gap detection and WAL filenames so backend merge dedupes real-time and batch conversations. Failure-Class: FC-offline-merge-clock-offset-dup Co-authored-by: Apoorv Darshan <[email protected]>
Reformat the two files Formatting CI flagged with the Flutter 3.44.5 / Dart 3.12.2 formatter at language version 3.0 and --line-length 120. No behavior changes. Co-authored-by: Apoorv Darshan <[email protected]>
|
Pushed a format-only commit to this branch ( |
|
Thanks @apoorvdarshan — this is a well-constructed fix for #5734. Reviewed all four files; the Dart-side implementation looks solid, with one cross-platform question before this ships. What I verified:
One material question — native-path parity. limitless_golden_test.dart's own regeneration note says an intentional change to pinned Dart protocol behavior requires updating LimitlessProtocol.kt to match. The native Android flash-drain path (LimitlessFlashDrainEngine.kt, wired in OmiBleForegroundService.kt, with the Swift twin in app/ios/Runner/Limitless/) still appends pages with raw page.timestampMs and LimitlessBatchAudioWriter.kt still names and session-splits batch files from that uncorrected pendant RTC. If those native Transcribe-Later drains are live production flash-download routes feeding the same backend merge, the duplicate-conversation bug this PR fixes on the Flutter path will persist there. Was leaving the native ports untouched a deliberate scope decision (i.e. the native drain is not yet reachable in production), and if not, should the drift correction be ported before this merges? A one-line note on the intended rollout would unblock this. Minor, non-blocking: a single connect-time offset is applied uniformly to pages written across the whole offline window, but RTC drift is a rate — pages from early in a long offline window can stay misaligned beyond the backend's ±2 min merge tolerance. The PR description says backend #11165 catches residual dups, so this may be acceptable; worth confirming that's the safety net. Cross-platform parity decision needed (Dart-only fix vs the Kotlin/Swift drain engines) — leaving for human maintainer review. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
What changed and why
Limitless duplicates conversations when real-time streaming and batch flash download cover the same audio: backend merge (
get_closest_conversation_to_timestamps, ±2 min) works when timestamps overlap, but pendant RTC drift leaves stored flash pages misaligned with phone-time real-time segments._initialize()only forwardsSetCurrentTimeand never measures drift; flash WAL sync used raw page timestamps.This is a fresh client-only implementation of #5734 (not a revive of closed #11145). Differences from that PR:
LimitlessClockDrifthelper so they can be unit-tested without a BLE stack or the 1.9k-line connection class._timeSyncedbefore theSetCurrentTimewrite so a mid-write Type-8 cannot clobber the offline offset.f4→f8→f6, nestedf8→f6→f1, andf1=8+ siblingf6; rejects mode-only Type-8, unterminated varints, and epochs below the 2020 floor.|drift| > 7 days) fail open (no correction).correctedFlashPageTimestampMssubtracts drift only for a real page RTC. Missing/zero/pre-2020 timestamps return phone-now unchanged —extractFramesWithSessionInfono longer bakesDateTime.now()intotimestamp_msso the helper can tell those apart (the fix(app): correct Limitless flash timestamps for clock drift (#5734) #11145 null-only check still double-corrected that fallback).Out of scope: Part 3 sync-mode toggle; #5733 firmware diagnostic pages. Complementary to backend
FC-offline-merge-clock-offset-dup(#11165), which still catches residual clock-offset dups after merge.Fixes #5734.
Product invariants affected
none
How it was verified
CI should run
cd app && flutter test test/unit/limitless_clock_drift_test.dart(same cases viaflutter_test).Could not exercise a live Limitless pendant reconnect + duplicate-conversation repro in this environment. Could not run the full
app/test.shsuite (no Flutter SDK).Tests
app/test/unit/limitless_clock_drift_test.dart— Type-8 parse (f8→f6, nested f8→f6→f1, BLE wrap, f1=8 sibling f6, missing field, mode-only, unterminated varint, below-floor);measureClockDriftOffsetMs(offset / implausible / invalid);correctedFlashPageTimestampMs(subtract / skip missing / skip zero / null drift).Failure class (fixes)
Failure-Class: FC-offline-merge-clock-offset-dup
Scoped cleanups (optional)
n/a