Skip to content

Compare generated results unordered - #4600

Open
evanchooly wants to merge 1 commit into
audits-lookupfrom
audits-unordered-results
Open

evanchooly wants to merge 1 commit into
audits-lookupfrom
audits-unordered-results

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Stacked on #4599. Self-reviewed only.

What this solves

Every generated scenario compared its results in order. But the server fixes result order only when the action sorts, and not even then when sort keys tie. Two cases failed on order alone:

The change

Generated scenarios now compare results as a multiset (ordered = false). The serialization check already proves Morphia sends exactly the documented pipeline, including any $sort. Which order the server then returns tests the server, not Morphia.

Converted legacy cases keep their own order, and so does the migrated case. Of the 511 cases, the 125 generated ones compare unordered.

  • $meta's text-score find now generates (510 → 511).
  • $replaceWith's pivot now passes behavior, but stays excluded for a different reason: its page prints the first $addFields stage's output as if it were the four-stage pipeline's result.

Integration: 523 tests under Critter, then reflection, 0 failures. Audits suite: 447 tests, 0 failures, 4 skipped.

Decision for review

I first tried a narrower rule, and dropped it after review: compare in order after a final $sort that no later $group, $bucket, $bucketAuto or $unionWith regroups. Codex showed four ways it still rejected legal results:

  • tied sort keys;
  • $sortByCount's equal counts;
  • $setWindowFields after a sort, whose output order isn't guaranteed;
  • a $merge/$out write's unsorted paired read, which inherited the pipeline's sort.

The trade-off of always comparing unordered: a generated case no longer checks that the server honored a sort. That's the server's behavior, though, and it isn't deterministic with ties. If you'd rather keep order checks where keys are provably unique, that would take per-case review rather than a generator rule.

Review

Codex, two local rounds: round 1 rejected the narrower rule as above, and round 2 was clean. The design doc and the progress log are updated.

This branch has not been deployed

No deployments
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.

1 participant