feat: accept the ndt7 server timestamp on measurements - #355
Open
Victor1Ja wants to merge 1 commit into
Open
Conversation
The app stamps every measurement with Date.now(), so `timestamp` is only as trustworthy as the clock of the machine running the test, which on these devices is frequently wrong. From v2.0.4 the ndt7 client also reports M-Lab's own clock, read from the Date header of the locate service response, and sends it as server_timestamp. This stores it as a second, independent reference point next to `timestamp` rather than replacing it. Additive and optional throughout: a new migration that only adds the column, nullable with no default, and clients that do not send the field keep working unchanged - which is every release before v2.0.4. App counterpart: unicef/project-connect-daily-check-app#85 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
rashan-smith
approved these changes
Aug 31, 2026
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.
Stores M-Lab's own clock alongside the device clock on each measurement.
Client side: unicef/project-connect-daily-check-app#85.
Why
Date.now()in the app, someasurements.timestampis only as trustworthy as the clock of the machine running the test — and on these devices it is frequently off by hours or days.Dateheader of the locate service response.timestamp, not a replacement. Nothing that readstimestamptoday changes behaviour.What changed
server_timestamp DateTime? @db.Timestamptz(6)onmeasurements. Not onmeasurements_failed, matching howscheduled_at/scheduled_slotwere handled.20260824130000_add_server_timestamp_to_measurements— one nullableADD COLUMN, no default. Additive only; no existing migration touched.server_timestamp?: Datewith an@ApiPropertydescription.toModel()and in the DTO mapping (?? null), same pattern asscheduled_at.Compatibility
Caveat worth knowing
The value is M-Lab's clock at server discovery, a few seconds before the test starts, at 1-second resolution. Good enough to detect a device clock that is badly off; not a precise start-of-test timestamp. The ndt7 protocol carries no wall clock of its own — see the client PR for why this is the only reachable source.
Testing
npx jest— 446 passed, 63 suites (444 onstagingbefore this), no regressions.nullwhen omitted.npx tsc --noEmitandnpx prisma generateclean.