Skip Google rawSignals when the export also has semanticSegments - #3279
Open
Freika wants to merge 2 commits into
Open
Skip Google rawSignals when the export also has semanticSegments#3279Freika wants to merge 2 commits into
Freika wants to merge 2 commits into
Conversation
Exports taken after mid-June 2026 ship the raw signal stream alongside the aggregated timeline for the same period. The two are sampled independently, so their gaps do not coincide; merging them erased the pauses track segmentation splits on and welded whole weeks into one track, which then drew journeys onto every day that track overlapped. Skip rawSignals when semanticSegments is present, decided by a chunked byte scan so key order in the document does not matter. The section is discarded at array_start, so its entries are never materialized. Presence of the key does not guarantee usable data, so replay the skipped signals when the aggregated pass yields no points — otherwise an export with an empty semanticSegments array would import nothing at all and still report success. Report the skipped count to the user, since dropping most of a file silently is indistinguishable from data loss.
The storage-download example stubbed download_with_verification while the importer calls download_to_temp_file, so the spec failed on any run.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported by a user whose 204 MB Google phone Timeline export produced "ghost tracks": opening 4 July showed bike commutes from 2 and 3 July, days he was home all day.
Cause
Google switched on the
rawSignalsstream around mid-June 2026 and now emits both formats in the same export. In the reported file:semanticSegmentsrawSignalsThese are not duplicate rows — only 739 of 64,556 raw positions share an exact
(timestamp, lat, lon)with atimelinePathpoint, so the unique index legitimately cannot dedupe them (timelinePathis minute-snapped to:00seconds;rawSignalsland on arbitrary seconds).The damage is temporal density, not row count. Track segmentation splits only on time gaps (
minutes_between_routes, default 30). The two sources are sampled independently, so their gaps do not coincide and merging them cancels nearly all of them. Measured on the reporter's real 28 Jun – 7 Jul data:semanticSegmentsonlyTracks::IndexQueryreturns any track overlapping the requested range and the serializer emits its full unclipped geometry, so one 10-day mega-track paints its entire path onto every day it touches.Fix
Skip
rawSignalswhensemanticSegmentsis present. The decision comes from a chunked byte scan, because Oj's SAJ streaming cannot know a later key exists and JSON key order is not guaranteed. The section is discarded atarray_start, so its entries are never materialised into hashes.Presence of the key does not guarantee usable data — Google's server-side aggregation can lag behind fresher on-device signals. Skipping on key presence alone would make an export with an empty
semanticSegmentsarray import nothing at all while still reporting success, so the skipped signals are replayed when the aggregated pass yields no points.The user is told how many signals were skipped. Dropping most of a file silently is indistinguishable from data loss, and the count is free — the handler counts entries of the discarded section without building them.
Verification
Real-data behaviour, reporter's export:
Before this change the same slice imported 31,276 points as 2 tracks; it now imports 9,928 as 23.
Also covered: a
"semanticSegments"literal appearing inside a value does not false-positive, and a key straddling the 1 MB scan boundary is still found.1202 examples, 0 failures (three consecutive runs). RuboCop clean on changed files.
Notes
rawSignalsare unaffected and still import.Tracks::Reprocessorfor affected users is not part of this PR.google_phone_takeout_invalid_utf8_spec.rb:40, which stubbeddownload_with_verificationwhile the importer callsdownload_to_temp_file— it fails ondevtoday.