Repository navigation
Compare declared result arrays as multisets and convert the $graphLookup cases - #4568
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
…kup cases A scenario's comparison.unorderedArrays names result arrays, by pointer within each result, that the server builds in no defined order. The strict and printed-result comparators in both the audits module and core match them as multisets, held together by new golden vectors. A form-review declaration lists each with its evidence; capture checks it and carries it into the scenario. Both $graphLookup cases declare the array $graphLookup builds, convert, and pass under both mappers; their bodies now look up the documented collections, recorded as reviewed body edits. Closes #4562.
This was referenced Nov 23, 2026
This branch has not been deployed
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.
Closes #4562, the follow-up to #4554's open question, as you asked. Stacked on #4567.
Problem
$graphLookupbuilds itsasarray in no defined order. The page says so: "Documents returned in theasfield are not guaranteed to be in any order." Two cases couldn't leave the legacy path because of it:graphLookup/withinASingleCollection: the runner seeds identical data into two databases and runs the documented pipeline and Morphia's. The server listedreportingHierarchyin a different order in each run, so the strict behavior check failed even though both held the same documents.graphLookup/withAQueryFilter: the same failure, inconnections who play golf, which is projected from the array$graphLookupbuilds.The only leniency available was ordering for the top-level result list. Nested arrays always compared in order.
Change
Comparison. A scenario's
comparison.unorderedArrayslists RFC 6901 pointers within each result. Each named array matches as a multiset: the same items, as often, in any order. Every other array, including arrays inside a named array's items, stays ordered.Audits module (Kotlin):
BsonComparisonPolicy.unorderedArraysandPublishedComparison.compareResults(..., unorderedArrays)do the matching.Matchinghelper. The two existing result-row matchers use it too. Matching matters because printed constraints overlap: a printed4matches both Int32 4 and Double 4.0.UNMATCHED_ITEMdifference.PublishedComparisonnow builds paths relative to each row, asBsonComparisonalready did, so a pointer means the same thing in ordered and unordered results.Core (Java):
StrictBsonandPrintedResultsport the same behavior.Golden vectors: 14 new ones (8 strict, 6 printed) cover:
Both implementations run them and agree.
Declaration. A form-review declaration lists
unorderedArrays: [{path, reason}].capturerejects:It then carries the arrays into the override and the scenario. Only a scenario that declares one carries the key, so the other 349 scenarios are unchanged. The field is omitted from the catalogs when it's empty.
Runner.
OperatorCaseRunnerapplies the declared arrays to the behavior check and the published check (documents or printed). It also refuses unknowncomparisonfields, and any unordered path that doesn't start with/.The two cases.
graphLookup(EXAMPLE_TEST_COLLECTION)to the documented collections,employeesandpeople. The ledger records both as reviewed body edits, as Keep documented collection names in cut-over scenarios #4554 did for$dateAdd.cutover.jsondrops them, and their declarations move tomigrated.Decisions for review
BsonComparison's other policies already worked.Verification
FormMigrationTestgains checks that a valid declaration reaches the override and that the three bad forms are rejected.Self-reviewed only: the independent reviewers are out of quota until 2026-11-26.