Skip to content

fix(rust-sdk): treat an uptime-flagged ring timestamp as no usable time - #22481

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
nabilhaloom:cursor/rust-uptime-timestamp-b0b8
Oct 20, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
nabilhaloom:cursor/rust-uptime-timestamp-b0b8

Conversation

@nabilhaloom

@nabilhaloom nabilhaloom commented Oct 19, 2026 •

Copy link
Copy Markdown

What changed and why

omi-device::record_timestamp read a ring record's 4-byte prefix as epoch seconds even when custody firmware sets bit 31. That flag means the RTC was unset and the low 31 bits are seconds since boot, which is how RingProtocol.readRecordTimestamp in app/lib/services/devices/ring_protocol.dart treats it. The raw word 0x800004D2 (1,234 seconds since boot) is 2,147,484,882, a date in 2038, so a caller would file the recording years in the future. A flagged timestamp now returns 0, the same "no usable time" result as the app. An ordinary epoch word whose high bit is clear is unchanged.

No open issue tracks this helper. Nearby timestamp reports, including #20358, are a different offline-sync clock offset and already have a pull request.

Product invariants affected

none

How it was verified

From sdks/rust/omi-device, with the stable toolchain (the crate's MSRV is 1.85; the image default is 1.83):

  • cargo +stable fmt --check
  • cargo +stable clippy -- -D warnings
  • cargo +stable test --locked — 9 unit tests and 4 codec tests passed, 0 failed

The new tests decode a 444-byte record in memory. No pendant, Bluetooth adapter, or credentials are involved.

make preflight against origin/main (325b7e3f2d) passed, 12 checks.

Tests

epoch_ring_timestamp_keeps_its_seconds and uptime_flagged_ring_timestamp_is_not_epoch_time in sdks/rust/omi-device/src/lib.rs. They cover epoch 1234, the highest non-flag word 0x7FFFFFFF, a flagged uptime of 1,234 seconds, and the flag alone. Before this change the flagged record returned 2_147_484_882, so the new assertion fails on the old helper.

UI evidence

UI-Evidence: none -- Rust protocol helper, no user interface.

Failure class (fixes)

Failure-Class: none

Prepared with AI assistance.

View guided diff

Custody firmware sets bit 31 when the RTC is unset. The low 31 bits are
seconds since boot, and reading the raw word dates the recording in 2038.
Match RingProtocol.readRecordTimestamp and return 0.

Co-authored-by: nabilh <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: this fix is correct, tightly scoped, and matches the maintained client protocol — nothing blocking from my side.

I verified it against app/lib/services/devices/ring_protocol.dart on this head: recordTimestampUptimeFlag = 0x80000000, and readRecordTimestamp returns 0 when the flag is set, raw epoch otherwise. The Rust helper now has identical semantics.

  • sdks/rust/omi-device/src/lib.rs — record_timestamp (+ new RECORD_TIMESTAMP_UPTIME_FLAG): without the flag check, a record written while the RTC was unset decodes as epoch 2,147,484,882 (a 2038 date), so callers would file recordings years in the future. Behavior for unflagged words (including the 0x7FFFFFFF boundary) is unchanged, and no in-crate callers are affected.
  • Tests epoch_ring_timestamp_keeps_its_seconds and uptime_flagged_ring_timestamp_is_not_epoch_time cover epoch 1234, the 0x7FFFFFFF boundary, a flagged uptime value, and flag-only — they fail on the old helper, so they genuinely pin the fix.
  • sdks/rust/omi-device/README.md — the added sentence accurately documents the 0-return and the flag's meaning, consistent with both implementations.

One non-blocking design note: 0 doubles as the "no usable clock" sentinel, so a real epoch of exactly 0 (1970-01-01) is indistinguishable — the same trade-off the Dart side makes, so consistency wins here.

USER IMPACT: recordings captured before the ring's clock was set are no longer dated in 2038; they now carry "no usable time" (0), matching the phone app.

Leaving for human maintainer review before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the positive-signal Automation verified a genuine fix/quality contribution label Oct 19, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treats an uptime-flagged ring timestamp (high bit set) as no usable time instead of misreading it as a 2038 epoch date. Clear root cause, scoped diff, tests added. No CI has run on this PR yet (only cubic ran) so I can't confirm green -- approving only.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked from prior approve-pending-CI: mergeable=MERGEABLE (UNSTABLE is a non-required context, no failing required check). Uptime-flagged ring-timestamp fix matches app-side RingProtocol handling, scoped+tested. Confidence 4/5 holds. Merging.

@kodjima33
kodjima33 merged commit fb319b1 into BasedHardware:main Oct 20, 2026
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants