Repository navigation
fix(app): correct Limitless flash timestamps for clock drift (#5734) - #11145
aryanorastar wants to merge 2 commits into
Conversation
…rdware#5734) Measure pendant−phone drift from Type-8 BLE clock notifications before SetCurrentTime, then subtract that offset during flash-page WAL sync so batch uploads overlap real-time conversations instead of duplicating. Co-authored-by: Cursor <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- Only subtract drift when a real flash page timestamp exists (avoid double-correcting DateTime.now fallback). - Freeze _timeSynced before SetCurrentTime write so mid-write Type-8s cannot clobber the offline offset. - Reject unterminated/overlong varints in Type-8 parse. - Replace tautological math test with correctedFlashPageTimestampMs cases; clears prefer_const_declarations analyzer ratchet. Co-authored-by: Cursor <[email protected]>
|
Follow-up
|
|
Thanks for this clean fix for #5734 — the drift-capture-then-freeze design is sound and the fail-open behavior (null offset => unchanged timestamps) avoids regressions when no Type-8 clock notification arrives before A few observations from static review:
The one gap you already flagged: drift capture depends on the pendant spontaneously emitting a Type-8 clock notification during the connect listen window, which couldn't be validated against real hardware here. The parser + freeze + correction logic is well unit-tested, so the main remaining validation is a live pendant reconnect + duplicate-conversation repro. CI is green (Dart Analyze & Tests, Android Compile Smoke, Backend Hermetic Merge Gate). Requesting human maintainer sign-off before merge given the hardware-validation gap. Nice work. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
@Git-on-my-level Thanks for the positive signal. Agreed on the hardware gap — drift capture depends on a live Type-8 during the connect window, which we couldn't exercise here. Parser + freeze-before-write + No further author code changes pending. Leaving live pendant reconnect + duplicate-conversation smoke and APPROVE/merge to @mdmohsin7 / maintainers. |
|
@mdmohsin7 Friendly code-owner bump on #5734. Head If the approach looks good (or you’re comfortable merging on the unit-tested parser/freeze/correction with fail-open null offset), an APPROVE from you clears the merge gate. Thanks! |
mdmohsin7
left a comment
There was a problem hiding this comment.
Please provide tests with the limitless device. There shouldn't be any skew/drift in time because each flashpage of limitless has a timestamp and we read that timestamp while parsing the flashpage
|
@mdmohsin7 Thanks for the review — pausing code changes until we align on the diagnosis. On device tests: I don't have a Limitless pendant in this environment, so I can't run a live reconnect + flash-download + duplicate-conversation repro. What's on the PR today is hermetic only ( On "no skew because flash pages already have timestamps": Agreed we already parse Field 1
If your read is that Field 1 is already phone-aligned absolute epoch (so subtracting connect-time Type-8 drift would be wrong / unnecessary), then this PR's Part 2 is the wrong fix and I should close it rather than push more correction logic. Could you confirm which is correct?
Either way I won't ship more drift math without your call + device confirmation. Thanks. |
This is an assumption
That is not how the limitless device works. It does not have any drift. And besides the issue was already fixed by the person who opened the issue |
What changed and why
Limitless duplicates conversations when real-time streaming and batch flash download cover the same audio: the backend merge (
get_closest_conversation_to_timestamps) 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.Part 1: Parse Type-8 BLE notifications (
f4 → f8 → f6 EPOCH_MS) during the connect listen window, storeclockDriftOffsetMs = pendant − phonebeforeSetCurrentTime, and freeze that reading (post-sync Type-8s would show ~0 drift)._timeSyncedis set before the write so a mid-write Type-8 cannot clobber the offline offset.Part 2: In
flash_page_wal_sync.dart, subtract the offset from page timestamps viacorrectedFlashPageTimestampMsbefore session-gap detection and filename embedding. Drift is applied only when a real page timestamp was parsed — theDateTime.now()fallback is already phone time and is not double-corrected.Out of scope: Part 3 sync-mode toggle; #5733 firmware diagnostic pages.
Fixes #5734.
Product invariants affected
none
How it was verified
Could not exercise a live Limitless pendant reconnect + duplicate-conversation repro in this environment. Parser + connect-time capture + post-sync freeze + flash correction helper (including missing-timestamp path) are unit-tested.
Tests
app/test/unit/limitless_clock_drift_test.dart— Type-8 f8→f6 / nested f8→f6→f1 parse; unterminated varint; connect captures drift before msg6; post-sync Type-8 does not clobber;correctedFlashPageTimestampMssubtracts drift / skips double-correct / null drift.Failure class (fixes)
Failure-Class: none
Scoped cleanups (optional)
n/a