Skip to content

Add every component's drift for Drift, as the specification says - #60

Merged
jwrosewell merged 1 commit into
rcfrom
fix/drift-is-the-sum-of-the-components
Nov 9, 2026
Merged

jwrosewell merged 1 commit into
rcfrom
fix/drift-is-the-sum-of-the-components

Conversation

@ben51degrees

@ben51degrees ben51degrees commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

For #16.

The problem

DeviceDataHashDefault.getDriftInternal returned the smallest drift among the native results, one per component, starting from Integer.MAX_VALUE. The specification's match metrics table describes Drift as the total difference in character positions, and 51Degrees/specifications#39 says it in full: the drift of every component's result added together. The C++ results add them (ResultsHash.cpp#L183-L192), as do Go and the Node, PHP and Python wrappers, so the same evidence gave a smaller Drift here whenever more than one component drifted.

What changes

getDriftInternal adds the results' drift, as getDifferenceInternal, getMatchedNodesInternal and getIterationsInternal in the same class already do. A test gives two mocked native results drifts of 3 and 5 and reads 8 from getDrift.

Where it came from

Opened as a draft in device-detection-java as device-detection-java#614 before that repository was archived. The commit is the same, applied under device-detection/.

How it was checked

mvn -pl device-detection/device-detection.hash.engine.on-premise test -Dtest=DeviceDataTests with JDK 17 on Windows x64, against a native library built from this repository on 2 November and the Lite data file and evidence files from the data repository: 7 tests run, 0 failures, 0 errors, 0 skipped, the new DeviceData_Drift_IsTheSumOfTheResults among them. The pull request job builds the native library itself and runs the same tests on every configuration.

Failing first, and the full build

The first line said "Fixes #16", and a pull request into rc closes no issue, so it now says "For #16". The rest of the text above is unchanged.

DeviceData_Drift_IsTheSumOfTheResults was run on a runner (Ubuntu 22.04, JDK 17, the native library built there, the Lite data file from the data repository) with mvn -Pdev -pl device-detection/device-detection.hash.engine.on-premise -am -Dtest=DeviceDataTests test.

  • Red, rc at 63d0bb8 with only the new test file added: run 42635315078. Tests run: 7, Failures: 1, with DeviceData_Drift_IsTheSumOfTheResults:112 expected:<8> but was:<3>, which is the smallest of the two drifts that rc returns.
  • Green, this branch at fd05a04: run 42635384734. Tests run: 7, Failures: 0, Errors: 0, with the new test among them.

The full pull request build, common-ci's nightly-pull-request.yml run as a dry run from a temporary branch, built fd05a04, this branch's head, merged with rc at 63d0bb8 (run 42636362517). "Setting 'PullRequestSha'" in the logs of all 10 completed jobs is fd05a04, which is the head. Every non-macOS job passed, being Ubuntu x64 with Java 8, 11, 17 and 21, Ubuntu arm64 with Java 17, and Windows with Java 8, 11, 17 and 21, with the configure job. I cancelled the run while the six macOS jobs were still queued.

macOS was left out of this draft's full build under the 9 November decision. The rc head is built with macOS before it merges into main.

@jwrosewell
jwrosewell marked this pull request as ready for review November 9, 2026 19:13
@jwrosewell
jwrosewell merged commit 5caede0 into rc Nov 9, 2026
2 checks passed
@jwrosewell
jwrosewell deleted the fix/drift-is-the-sum-of-the-components branch November 9, 2026 19:13
@jwrosewell jwrosewell mentioned this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants