Skip to content

Return targets in a deterministic order - #3385

Merged
adamtheturtle merged 1 commit into
mainfrom
adamtheturtle/issue-3369
Aug 9, 2026
Merged

Return targets in a deterministic order#3385
adamtheturtle merged 1 commit into
mainfrom
adamtheturtle/issue-3369

Conversation

@adamtheturtle

Copy link
Copy Markdown
Member

Targets are held in a set, so every endpoint which returns a list of them iterated in hash order, which varies between runs because target IDs are random hex and str hashing is salted per process. For the Query API this was not merely cosmetic: max_num_results truncates the result list after it is built, so a query matching three targets with max_num_results=1 returned an arbitrary one of the three, and include_target_data=top attached target data to whichever result happened to come first.

The Query API, GET /targets and GET /duplicates/{target_id} now order targets by upload date and then by target ID, on both the in-process and Flask backends. The mock has no match score, so it cannot reproduce real Vuforia's best-match-first order; differences-to-vws.rst now says so, so that callers do not read the mock's order as a ranking.

New tests cover the order for each of the three endpoints; they skip on the real backend, whose order the mock does not claim to match.

Closes #3369.

🤖 Generated with Claude Code

Targets are held in a `set`, so every endpoint which returns a list of them
iterated in hash order. Target IDs are random hex and `str` hashing is salted
per process, so that order varied between runs.

For the Query API this was not merely cosmetic: `max_num_results` truncates the
result list after it is built, so a query matching three targets with
`max_num_results=1` returned an arbitrary one of the three, and a different one
on the next run. `include_target_data=top` attached target data to whichever
result happened to come first.

Order the targets returned by the Query API, `GET /targets` and
`GET /duplicates/{target_id}` by upload date and then by target ID. The mock has
no match score, so it cannot reproduce real Vuforia's best-match-first order;
the differences document now says so, so that callers do not read the mock's
order as a ranking.

Closes #3369.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

Query and target list results are returned in an order which varies between runs

1 participant