diff --git a/audits/README.md b/audits/README.md index 9f803c59dcc..5db3e81ed17 100644 --- a/audits/README.md +++ b/audits/README.md @@ -34,6 +34,7 @@ Every command below runs through the exec plugin from the repository root, after | --- | --- | | `audits/catalog/documented-examples.json` | Every example on the current operator pages, with its owner; unowned examples keep their source text. | | `audits/catalog/dsl-bindings.json` | Reviewed MQL-to-Morphia factory bindings the generator uses. | +| `audits/catalog/example-names.json` | Reviewed names for examples with generic titles, and owners for examples several fixtures match. | | `audits/catalog/generation-review.json` | The generated families, the reviewed exclusions with their evidence, and the sample-dataset collections. | | `audits/catalog/fixture-migration.json` | The ledger of legacy cases moved onto the case runner, with their documented sources. | | `audits/catalog/cutover.json` | Legacy cases that stay on the legacy path, with the check that fails and its first difference. | @@ -112,7 +113,9 @@ To cover more examples, read `gaps.json`: - **UNBOUND** names the first node without a binding, such as `stage $match has no binding`. Add the binding to `dsl-bindings.json` with the factory's exact erased parameter types. - **SOURCE_UNSUPPORTED** means the page's mongosh text does not lower; that is parser work. -- **UNNAMED** and **AMBIGUOUS** need a descriptive, unique name for the example. +- **UNNAMED** and **AMBIGUOUS** need a review in `example-names.json`: a descriptive name, or the + owner among the matching fixtures, keyed by the action block's `sha256` from the inventory. Then + rerun `inventory`; `reviews.stale` counts reviews whose example changed. - **EXCLUDED** is a reviewed exclusion; its reason says what would lift it. When a generated case fails integration, read why in `integration.log`. Never loosen the scenario diff --git a/audits/catalog/documented-examples.json b/audits/catalog/documented-examples.json index 18b3bf19b32..3c5885aaa4a 100644 --- a/audits/catalog/documented-examples.json +++ b/audits/catalog/documented-examples.json @@ -182,10 +182,11 @@ "sha256" : "e70a5f27d182fb59b190293dc0c4a82563d5737c2a7cfd99759536232ac92cf3", "text" : "[\n { _id: 'A. Dean Bell', genres: [ 'Crime', 'Drama' ] },\n { _id: 'A. Karunakaran', genres: [ 'Romance' ] },\n { _id: 'A. Vanichkin', genres: [ 'Animation', 'Fantasy' ] },\n { _id: 'A.J. Edwards', genres: [ 'Biography', 'Drama', 'History' ] },\n {\n _id: 'A.R. Murugadoss',\n genres: [ 'Drama', 'Sci-Fi', 'Thriller', 'Action', 'Mystery' ]\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Collect the Genres of Each Director", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "collectTheGenresOfEachDirector", "title" : "main" } ], "includes" : [ { @@ -1199,10 +1200,11 @@ "sha256" : "c4a04a9725ecfb87d106222fb38ea92725ceaeb2dd7c7c3e28577f3d8ebbb614", "text" : "[\n { _id: 'Drama', countNumberOfMoviesForGenre: 12385 },\n { _id: 'Short', countNumberOfMoviesForGenre: 442 }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Count the Movies in Each Genre", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "countTheMoviesInEachGenre", "title" : "main" } ], "includes" : [ { @@ -1874,10 +1876,11 @@ "sha256" : "439165b8d124f4b30952bf22c75e335a74f3841b06ade05c09ba116214dcd02e", "text" : "db.collection('MyCollection').aggregate([\n {\n $match: {\n $expr: {\n $encStrContains: {\n input: '$employeeLastName',\n substring: 'earso'\n }\n }\n }\n }\n])" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Match an Encrypted Substring", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "matchAnEncryptedSubstring", "title" : "main" } ], "includes" : [ { @@ -1899,10 +1902,11 @@ "sha256" : "31a65962f19997c88759b2c7986bb385d7f2673137d91318f083336a7ffa95b9", "text" : "db.collection('MyCollection').aggregate([\n {\n $match: {\n $expr: {\n $encStrEndsWith: {\n input: '$employeeFirstName',\n suffix: 'son'\n }\n }\n }\n }\n])" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Match an Encrypted Suffix", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "matchAnEncryptedSuffix", "title" : "main" } ], "includes" : [ { @@ -1924,10 +1928,11 @@ "sha256" : "9f83861d081923ddacc1dadbf61d4d8e7541203e1fd94e802d3264d23d98210a", "text" : "db.collection('MyCollection').aggregate([\n {\n $match: {\n $expr: {\n $encStrNormalizedEq: {\n input: '$employeeLastName',\n string: 'Béatrice'\n }\n }\n }\n }\n])" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Match a Normalized Encrypted String", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "matchANormalizedEncryptedString", "title" : "main" } ], "includes" : [ { @@ -1949,10 +1954,11 @@ "sha256" : "9d269e8a85656803552e70bf616cda49c8bfef42194941f93df701ffae3bba5b", "text" : "db.collection('MyCollection').aggregate([\n {\n $match: {\n $expr: {\n $encStrStartsWith: {\n input: '$employeeFirstName',\n prefix: 'Sam'\n }\n }\n }\n }\n])" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Match an Encrypted Prefix", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "matchAnEncryptedPrefix", "title" : "main" } ], "includes" : [ { @@ -2173,10 +2179,11 @@ "sha256" : "2b0d30d3cfb3aa1fc4ac587631e62fbfcfafbf18dc048cd10174cd9083163873", "text" : "[\n {\n _id: 'Action',\n firstMovieTitle: 'The Perils of Pauline',\n firstMovieYear: 1914\n },\n {\n _id: 'Adventure',\n firstMovieTitle: 'Robin Hood',\n firstMovieYear: 1922\n },\n {\n _id: 'Animation',\n firstMovieTitle: 'Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics',\n firstMovieYear: 1911\n },\n {\n _id: 'Biography',\n firstMovieTitle: 'Regeneration',\n firstMovieYear: 1915\n },\n {\n _id: 'Comedy',\n firstMovieTitle: 'Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics',\n firstMovieYear: 1911\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Find the First Movie in Each Genre", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "findTheFirstMovieInEachGenre", "title" : "main" } ], "includes" : [ { @@ -2897,10 +2904,11 @@ "sha256" : "f25e5dfef43c90ca37eedfb58c83a3893128024c072c10925a00811216334757", "text" : "[\n {\n _id: 'Action',\n lastMovieTitle: 'The Masked Saint',\n lastMovieYear: 2016\n },\n {\n _id: 'Adventure',\n lastMovieTitle: 'Wolf Totem',\n lastMovieYear: 2015\n },\n {\n _id: 'Animation',\n lastMovieTitle: 'World of Tomorrow',\n lastMovieYear: 2015\n },\n {\n _id: 'Biography',\n lastMovieTitle: 'The Masked Saint',\n lastMovieYear: 2016\n },\n {\n _id: 'Comedy',\n lastMovieTitle: \"You're Ugly Too\",\n lastMovieYear: 2015\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Find the Last Movie in Each Genre", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "findTheLastMovieInEachGenre", "title" : "main" } ], "includes" : [ { @@ -3503,10 +3511,11 @@ "sha256" : "2bcbfebf81e7629d820f5229a29f8035f2fb78163c1f18163a27c286e5e98cd8", "text" : "[\n {\n title: 'Spirited Away',\n cast: [ 'Rumi Hiiragi', 'Miyu Irino', 'Mari Natsuki', 'Takashi Naitè' ],\n topTwoCast: [ 'Takashi Naitè', 'Rumi Hiiragi' ]\n },\n {\n title: 'The Dark Knight',\n cast: [ 'Christian Bale', 'Heath Ledger', 'Aaron Eckhart', 'Michael Caine' ],\n topTwoCast: [ 'Michael Caine', 'Heath Ledger' ]\n },\n {\n title: 'The Godfather',\n cast: [ 'Marlon Brando', 'Al Pacino', 'James Caan', 'Richard S. Castellano' ],\n topTwoCast: [ 'Richard S. Castellano', 'Marlon Brando' ]\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Find the Top Two Cast Members", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "findTheTopTwoCastMembers", "title" : "main" } ], "includes" : [ { @@ -3538,10 +3547,11 @@ "sha256" : "7d615c68cc77d83af4164bdcd020ae6674aac766df91a511b779665667432a0b", "text" : "[\n { _id: 2000, medianRating: 6.4 },\n { _id: 2001, medianRating: 6.4 },\n { _id: 2002, medianRating: 6.2 },\n { _id: 2003, medianRating: 6.4 },\n { _id: 2004, medianRating: 6.5 }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Calculate the Median Rating by Year", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "calculateTheMedianRatingByYear", "title" : "main" } ], "includes" : [ { @@ -3580,10 +3590,11 @@ "sha256" : "b3d3fc5f49f87184aa040ca3d12d9c03e2d5f137f6059e6ebba69a0f3393318c", "text" : "[\n {\n _id: 'Galactic Odyssey',\n allRatings: {\n rating: 8.1,\n votes: 1482903,\n tomatometer: 79,\n audienceScore: 85\n }\n },\n {\n _id: 'Neon Horizon',\n allRatings: {\n rating: 7.4,\n votes: 983201,\n tomatometer: 68,\n audienceScore: 74\n }\n },\n {\n _id: 'The Last Protocol',\n allRatings: {\n rating: 8.7,\n votes: 2104567,\n tomatometer: 91,\n audienceScore: 88\n }\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Merge the Ratings of Each Movie", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "mergeTheRatingsOfEachMovie", "title" : "main" } ], "includes" : [ { @@ -3720,10 +3731,11 @@ "sha256" : "f89e000e4970665b100b4e05c1fdf28d322b67b1a66f95a49e32cecee1eafff8", "text" : "{a: 1, scaled: 0, scaledTo100: 0}\n{a: 5, scaled: 0.2, scaledTo100: 20}\n{a: 13, scaled: 0.6, scaledTo100: 60}\n{a: 21, scaled: 1, scaledTo100: 100}" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Scale Values to a Range", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "scaleValuesToARange", "title" : "main" } ], "includes" : [ ], @@ -4098,10 +4110,11 @@ "sha256" : "6f1b4c1bca04e3c984029110946fb67098be509bb6947978fb268008f4fe6ef9", "text" : "[\n { _id: 'A. Karunakaran', genres: [ 'Romance' ] },\n { _id: 'A.J. Edwards', genres: [ 'Biography' ] },\n { _id: 'A.R. Murugadoss', genres: [ 'Action', 'Action' ] },\n { _id: 'AJ Schnack', genres: [ 'Documentary' ] },\n { _id: 'Aanand Rai', genres: [ 'Comedy' ] }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Collect the First Genre of Each Director's Movies", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "collectTheFirstGenreOfEachDirectorSMovies", "title" : "main" } ], "includes" : [ { @@ -4990,10 +5003,11 @@ "sha256" : "2bfb81d13a219376801a67440936897e63acb1c25fbd8e7cd594d1c5d5a21562", "text" : "{ score: 1, scaled: 0.7310585786 }\n{ score: 5, scaled: 0.9933071491 }\n{ scaled: null }\n{ score: 13, scaled: 0.9999977397 }\n{ score: null, scaled: null }\n{ score: 19, scaled: 0.9999999992 }" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Scale Scores with a Sigmoid", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "scaleScoresWithASigmoid", "title" : "main" } ], "includes" : [ ], @@ -5020,10 +5034,11 @@ "sha256" : "a6fa68c9f58c227d7f0303d685a4d8c074106648671ffe5008a19f2b63ad2575", "text" : "{ _id: 1, raw: 1, normalized: 1 }\n{ _id: 2, raw: 0.7142857142857143,\n normalized: 0.8571428571428571 }\n{ _id: 3, raw: 0.9746318461970762,\n normalized: 0.9873159230985381 }" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Compute Raw and Normalized Cosine Similarity", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "computeRawAndNormalizedCosineSimilarity", "title" : "main" } ], "includes" : [ ], @@ -5050,10 +5065,11 @@ "sha256" : "ef946dd2910528a6f2abe665eeb791046b6b398e19f9971a553d2e465a5a79e8", "text" : "{ _id: 1, raw: 14, normalized: 7.5 }\n{ _id: 2, raw: 10, normalized: 5.5 }\n{ _id: 3, raw: 32, normalized: 16.5 }" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Compute Raw and Normalized Dot Products", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "computeRawAndNormalizedDotProducts", "title" : "main" } ], "includes" : [ ], @@ -5080,10 +5096,11 @@ "sha256" : "7f0e52017d8ade1ee78e95f7c585a5d65d08cad73d33a7ffd6f2eee2e363aede", "text" : "{ _id: 1, raw: 0, normalized: 1 }\n{ _id: 2, raw: 2.8284271247461903,\n normalized: 0.2612038749637415 }\n{ _id: 3, raw: 5.196152422706632,\n normalized: 0.16139702886038895 }" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Compute Raw and Normalized Euclidean Distances", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "computeRawAndNormalizedEuclideanDistances", "title" : "main" } ], "includes" : [ ], @@ -5295,10 +5312,11 @@ "sha256" : "5734a9b9cd62c944a7e2e6e0f769d449ea1cd0413710bab6ec26745d3e3c9cec", "text" : "[\n { _id: 'Bob Clark', movieCount: 12, stdDevRating: 1.6436747447918845 },\n { _id: 'John McTiernan', movieCount: 10, stdDevRating: 1.439305388025766 },\n { _id: 'James Cameron', movieCount: 10, stdDevRating: 1.3683566786477859 },\n { _id: 'Sean McNamara', movieCount: 13, stdDevRating: 1.3499945211372495 },\n {\n _id: 'Robert Rodriguez',\n movieCount: 20,\n stdDevRating: 1.2701476292148088\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Find the Directors with the Most Varied Ratings", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "findTheDirectorsWithTheMostVariedRatings", "title" : "main" } ], "includes" : [ { @@ -5336,10 +5354,11 @@ "sha256" : "d4c95b1f93e5c606dabaa1707ea12dc6b80818a732d1af9e4aeaffc4dab4b163", "text" : "[\n {\n _id: 'Bob Clark',\n movieCount: 12,\n stdDevSampRating: 1.7167622803617066\n },\n {\n _id: 'John McTiernan',\n movieCount: 10,\n stdDevSampRating: 1.517161091571287\n },\n {\n _id: 'James Cameron',\n movieCount: 10,\n stdDevSampRating: 1.4423745853433652\n },\n {\n _id: 'Sean McNamara',\n movieCount: 13,\n stdDevSampRating: 1.4051188470584879\n },\n {\n _id: 'Robert Rodriguez',\n movieCount: 20,\n stdDevSampRating: 1.303143971526675\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Find the Directors with the Most Varied Sampled Ratings", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "findTheDirectorsWithTheMostVariedSampledRatings", "title" : "main" } ], "includes" : [ { @@ -5449,10 +5468,11 @@ "sha256" : "636b077332755da09044bc7f69eb11f2ea37d4934117b90ce982408e225d339d", "text" : "[\n {\n title: 'Centennial',\n titleStart: 'Cen',\n titleRest: 'tennial'\n },\n {\n title: 'Baseball',\n titleStart: 'Bas',\n titleRest: 'eball'\n }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Split Titles into Two Parts", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "splitTitlesIntoTwoParts", "title" : "main" } ], "includes" : [ { @@ -5601,10 +5621,11 @@ "sha256" : "0ed0046e5edc63dddccd63483b5f81106c692aa719f37ccf9088112a8ab0bf4b", "text" : "[\n { _id: 'G', totalVotes: 12773015 },\n { _id: 'PG', totalVotes: 57205811 },\n { _id: 'PG-13', totalVotes: 152323029 },\n { _id: 'R', totalVotes: 209762435 }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Total the Votes by Rating", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "totalTheVotesByRating", "title" : "main" } ], "includes" : [ { @@ -5876,10 +5897,11 @@ "sha256" : "6b54fc3800486eaa98108027ce1c14ab2470c6fb1ae257ce21174cdeee28cea4", "text" : "[ { val: 'string to hash', hashedVal: Long(\"763543691661428748\") } ]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Hash a String Value", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "hashAStringValue", "title" : "main" } ], "includes" : [ ], @@ -6683,9 +6705,9 @@ "title" : "Single Facet Aggregation" }, { "blocks" : [ ], - "detail" : "matches aggregation/stages/bucketAuto/multiFacetedAggregation, aggregation/stages/bucketAuto/multiFacetedAggregationAsPipeline", - "owner" : null, - "status" : "AMBIGUOUS", + "detail" : "reviewed owner: the AsPipeline fixture tests the same example as a pipeline list", + "owner" : "aggregation/stages/bucketAuto/multiFacetedAggregation", + "status" : "OWNED", "stem" : null, "title" : "Multi-Faceted Aggregation" } ], @@ -6724,10 +6746,11 @@ "sha256" : "5ea747115d72208c8ee9c70a804a5b104cdae11e80aea431c7920a23287c0f10", "text" : "{\n \"_id\": {\n _data: \"8262E2EE54000000022B022C0100296E5A100448E5E3DD01364019AE8FE8C6859527E046645F6964006462E2EE54C8756C0D5CF6F0720004\"\n },\n \"operationType\": \"insert\",\n \"clusterTime\": Timestamp({ t: 1659039316, i: 2 }),\n \"wallTime\": ISODate(\"2022-07-28T20:15:16.148Z\"),\n \"fullDocument\": {\n \"_id\": ObjectId(\"62e2ee54c8756c0d5cf6f072\"),\n \"name\": \"Walker Percy\"\n },\n \"ns\": {\n \"db\": \"test\",\n \"coll\": \"names\"\n },\n \"documentKey\": { _id: ObjectId(\"62e2ee54c8756c0d5cf6f072\") }\n}" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Open a Change Stream", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "openAChangeStream", "title" : "main" } ], "includes" : [ { @@ -6765,10 +6788,11 @@ "sha256" : "0c080d4ea36d19ef3d5be80659186b6051f8064bf7a381f85517a0f9145e5871", "text" : "const firstFragment = myChangeStreamCursor.next()\nconst secondFragment = myChangeStreamCursor.next()\nconst thirdFragment = myChangeStreamCursor.next()" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Split a Large Change Event", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "splitALargeChangeEvent", "title" : "main" } ], "includes" : [ ], @@ -6920,9 +6944,9 @@ "context" : "aggregation/stages", "examples" : [ { "blocks" : [ ], - "detail" : "matches aggregation/stages/currentOp/inactiveSessionsReplicaSet, aggregation/stages/currentOp/inactiveSessionsShardedCluster, aggregation/stages/currentOp/inactiveSessionsShardedClusterLocalOpsTrue", - "owner" : null, - "status" : "AMBIGUOUS", + "detail" : "reviewed owner: the sharded-cluster fixtures run the same example on other topologies", + "owner" : "aggregation/stages/currentOp/inactiveSessionsReplicaSet", + "status" : "OWNED", "stem" : null, "title" : "main" } ], @@ -7984,10 +8008,11 @@ "sha256" : "226b294bd763b0a9aa5e5cb2c0c743e34efb3462b6eefaf2bde11a424ff9778f", "text" : "[\n { _id: { year: 1939, rated: 'PASSED' }, count: 1 },\n { _id: { year: 1962, rated: 'PG' }, count: 1 },\n { _id: { year: 1963, rated: 'PG' }, count: 1 },\n { _id: { year: 1970, rated: 'R' }, count: 1 },\n { _id: { year: 1972, rated: 'R' }, count: 1 }\n]" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Summarize Ratings into Another Collection", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "summarizeRatingsIntoAnotherCollection", "title" : "main" } ], "includes" : [ { @@ -8170,10 +8195,11 @@ "sha256" : "b3d6e7b032a3c21453fb20e7eaff7a3eadc87ad5e4527b3ec4fa8c3934ac96e4", "text" : "db.orders.insertMany( [\n { \"_id\" : 1, \"item\" : \"abc\", \"price\" : Decimal128(\"12\"), \"quantity\" : 2, \"type\": \"apparel\" },\n { \"_id\" : 2, \"item\" : \"jkl\", \"price\" : Decimal128(\"20\"), \"quantity\" : 1, \"type\": \"electronics\" },\n { \"_id\" : 3, \"item\" : \"abc\", \"price\" : Decimal128(\"10\"), \"quantity\" : 5, \"type\": \"apparel\" },\n { \"_id\" : 4, \"item\" : \"abc\", \"price\" : Decimal128(\"8\"), \"quantity\" : 10, \"type\": \"apparel\" },\n { \"_id\" : 5, \"item\" : \"jkl\", \"price\" : Decimal128(\"15\"), \"quantity\" : 15, \"type\": \"electronics\" }\n] )" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Populate the Plan Cache", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "populateThePlanCache", "title" : "main" }, { "blocks" : [ ], @@ -8184,9 +8210,9 @@ "title" : "Return Information for All Entries in the Query Cache" }, { "blocks" : [ ], - "detail" : "matches aggregation/stages/planCacheStats/findCacheEntryDetailsForAPlanCacheShapeHash, aggregation/stages/planCacheStats/findCacheEntryDetailsForAQueryHash", - "owner" : null, - "status" : "AMBIGUOUS", + "detail" : "reviewed owner: its name is the example's title; the other fixture holds the same example under the page's later title", + "owner" : "aggregation/stages/planCacheStats/findCacheEntryDetailsForAQueryHash", + "status" : "OWNED", "stem" : null, "title" : "Find Cache Entry Details for a Query Hash" } ], @@ -8289,9 +8315,9 @@ "title" : "Conditionally Exclude Fields" }, { "blocks" : [ ], - "detail" : "matches aggregation/stages/project/includeSpecificFieldsFromEmbeddedDocuments, aggregation/stages/project/includeSpecificFieldsFromEmbeddedDocumentsAsStage", - "owner" : null, - "status" : "AMBIGUOUS", + "detail" : "reviewed owner: the AsStage fixture tests the same example built as a stage", + "owner" : "aggregation/stages/project/includeSpecificFieldsFromEmbeddedDocuments", + "status" : "OWNED", "stem" : null, "title" : "Include Specific Fields from Embedded Documents" }, { @@ -8429,10 +8455,11 @@ "sha256" : "d435a4dccc7b8b18fdafc74f92b095ed1d92f7c92bfef6f6e360b516c7e161fb", "text" : "// Create pizzaOrders collection\ndb.pizzaOrders.insertMany( [\n { _id: 0, type: \"pepperoni\", totalNumber: 5,\n orderDate: new Date( \"2024-01-15T12:00:00Z\" ) },\n { _id: 1, type: \"cheese\", totalNumber: 15,\n orderDate: new Date( \"2024-01-23T11:12:32Z\" ) },\n { _id: 2, type: \"vegan\", totalNumber: 20,\n orderDate: new Date( \"2024-03-20T10:01:12Z\" ) }\n] )\n\n// Create ascending index on orderDate field\ndb.pizzaOrders.createIndex( { orderDate: 1 } )\n\n// Create ascending index on totalNumber field\ndb.pizzaOrders.createIndex( { totalNumber: 1 } )" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Show the Debug Query Shape", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "showTheDebugQueryShape", "title" : "main" } ], "includes" : [ { @@ -8470,10 +8497,11 @@ "sha256" : "27920a8bd7fdb91f3762fd9560792ec18c1ecf5771df88adb52a13ecabc8f626", "text" : "db.products.insertMany(\n [\n { item: \"card\", qty: 15 },\n { item: \"envelope\", qty: 20 },\n { item: \"stamps\" , qty: 30 }\n ]\n)" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Return Query Statistics", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "returnQueryStatistics", "title" : "main" }, { "blocks" : [ { @@ -8550,10 +8578,11 @@ "sha256" : "054c7747654f26dab710536e6dfe273da83876c9f3bc9e57fdba8be10de2f88f", "text" : "db.embedded_movies.createSearchIndex(\n \"vector_index\", \n \"vectorSearch\", \n {\n \"fields\": [\n {\n \"type\": \"vector\",\n \"path\": \"\",\n \"numDimensions\": ,\n \"similarity\": \"dotProduct\"\n }\n ]\n }\n);" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Combine Vector and Text Search Ranks", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "combineVectorAndTextSearchRanks", "title" : "main" } ], "includes" : [ { @@ -8877,10 +8906,11 @@ "sha256" : "19537f318a97d327480703fc1671764fdaa47e5dc2a754698f3a019858a083f8", "text" : "db.embedded_movies.createSearchIndex(\n \"\", \n \"vectorSearch\", \n {\n \"fields\": [\n {\n \"type\": \"vector\",\n \"path\": \"\",\n \"numDimensions\": ,\n \"similarity\": \"dotProduct\"\n }\n ]\n }\n);" } ], - "detail" : "a generic title needs a reviewed name", + "detail" : null, + "name" : "Combine Vector and Text Search Scores", "owner" : null, - "status" : "UNNAMED", - "stem" : null, + "status" : "UNOWNED", + "stem" : "combineVectorAndTextSearchScores", "title" : "main" } ], "includes" : [ { @@ -12687,11 +12717,12 @@ } ], "sourceRepository" : "mongodb/docs", "summary" : { - "examples.ambiguous" : 4, - "examples.owned" : 433, - "examples.unnamed" : 30, - "examples.unowned" : 115, + "examples.ambiguous" : 0, + "examples.owned" : 437, + "examples.unnamed" : 0, + "examples.unowned" : 145, "pages" : 297, - "pages.skipped" : 3 + "pages.skipped" : 3, + "reviews.stale" : 0 } } diff --git a/audits/catalog/example-names.json b/audits/catalog/example-names.json new file mode 100644 index 00000000000..7baccd948e7 --- /dev/null +++ b/audits/catalog/example-names.json @@ -0,0 +1,243 @@ +{ + "schemaVersion": 1, + "examples": [ + { + "page": "aggregation/expressions/addToSet", + "title": "main", + "actionSha256": "2d9e3bbe1326348b788e7dcef099935f6dbb443e699f9709bef7d21152397e66", + "name": "Collect the Genres of Each Director", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/count-accumulator", + "title": "main", + "actionSha256": "547ca4198a6a6587a9e3c721552fe0d3729d947cf48f022949322edc9b50e709", + "name": "Count the Movies in Each Genre", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/encStrContains", + "title": "main", + "actionSha256": "439165b8d124f4b30952bf22c75e335a74f3841b06ade05c09ba116214dcd02e", + "name": "Match an Encrypted Substring", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/encStrEndsWith", + "title": "main", + "actionSha256": "31a65962f19997c88759b2c7986bb385d7f2673137d91318f083336a7ffa95b9", + "name": "Match an Encrypted Suffix", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/encStrNormalizedEq", + "title": "main", + "actionSha256": "9f83861d081923ddacc1dadbf61d4d8e7541203e1fd94e802d3264d23d98210a", + "name": "Match a Normalized Encrypted String", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/encStrStartsWith", + "title": "main", + "actionSha256": "9d269e8a85656803552e70bf616cda49c8bfef42194941f93df701ffae3bba5b", + "name": "Match an Encrypted Prefix", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/first", + "title": "main", + "actionSha256": "99e7a077d4f186a6186965e5188771a3c2c1b06e5cbd848a1f592eb468826943", + "name": "Find the First Movie in Each Genre", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/last", + "title": "main", + "actionSha256": "d405687abd3755d309ea59681b98811681fbf01d8bc954e367b83f4c04dc3ec2", + "name": "Find the Last Movie in Each Genre", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/maxN-array-element", + "title": "main", + "actionSha256": "43f4465048f9e85efd325217402ce4bd451023d3c6b10224558e315a26ae2e16", + "name": "Find the Top Two Cast Members", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/median", + "title": "main", + "actionSha256": "1c5ec50e7061ef69eb7cc7582c7b25b643d55fa416c29202aab8b4a545555737", + "name": "Calculate the Median Rating by Year", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/mergeObjects", + "title": "main", + "actionSha256": "fc0dd9b6a18d455f53bf804fd1baf4f6932813f3e46264c38867a4680d8a1509", + "name": "Merge the Ratings of Each Movie", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/minMaxScaler", + "title": "main", + "actionSha256": "68cadc2ee23a651e9c95b29ee02069dcc6e06179ee07642c59916ac765840f4a", + "name": "Scale Values to a Range", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/push", + "title": "main", + "actionSha256": "40df131bf80452fa7ae8ae5bbeec3d865ce04bea7d77f5ca1bbe484d81c26e11", + "name": "Collect the First Genre of Each Director's Movies", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/sigmoid", + "title": "main", + "actionSha256": "fc237c4d2252310228970e1c493c3dd128a2730f29c7b8901d1534ec0b538f20", + "name": "Scale Scores with a Sigmoid", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/similarityCosine", + "title": "main", + "actionSha256": "761c882c498b557b206107249e2fbcfe23ff60f1f26e646e4210f79134cbd98a", + "name": "Compute Raw and Normalized Cosine Similarity", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/similarityDotProduct", + "title": "main", + "actionSha256": "7d7f0bf63a3871a56df88c55d6d5e81c4404a7447cebae6a713f498db15e635e", + "name": "Compute Raw and Normalized Dot Products", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/similarityEuclidean", + "title": "main", + "actionSha256": "039cd71bf2c4e59b2a61141123e73452d0c6796e82e828d280be950e501f9384", + "name": "Compute Raw and Normalized Euclidean Distances", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/stdDevPop", + "title": "main", + "actionSha256": "afdb393803aae8254cfbcf2ab0a54f7e819668ef5fefe646095b360ba9262b1e", + "name": "Find the Directors with the Most Varied Ratings", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/stdDevSamp", + "title": "main", + "actionSha256": "da5aa827655931d1df76e3118176e51f7d4da003dc04a20eb1d6311fabb3afa0", + "name": "Find the Directors with the Most Varied Sampled Ratings", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/substr", + "title": "main", + "actionSha256": "2b76bac3b7a35957d453ce8f7ec257a9fecb726124b44b6226e312981cdf3aaa", + "name": "Split Titles into Two Parts", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/sum", + "title": "main", + "actionSha256": "71390247d6d31ae4b9cbf51c29648ee2bb46e43474602550df84e0c08b5225ff", + "name": "Total the Votes by Rating", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/expressions/toHashedIndexKey", + "title": "main", + "actionSha256": "799d9684b84aac32629867f268a98d012b4426c697157b36769341364b88e174", + "name": "Hash a String Value", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/bucketAuto", + "title": "Multi-Faceted Aggregation", + "actionSha256": "49c497fa22b49783b1df464f3eb1938f1e8ca2f690771b7bb759cf6042ca1313", + "owner": "aggregation/stages/bucketAuto/multiFacetedAggregation", + "reason": "the AsPipeline fixture tests the same example as a pipeline list" + }, + { + "page": "aggregation/stages/changeStream", + "title": "main", + "actionSha256": "c7b41eadb79149ce317163d6e02efa3551551fd91e9c2e61d40544733f4bfee4", + "name": "Open a Change Stream", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/changeStreamSplitLargeEvent", + "title": "main", + "actionSha256": "93f73aef6deac8d63fb3888a36b4d1013b7a438b16b710b9f2fc61364bb10276", + "name": "Split a Large Change Event", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/currentOp", + "title": "main", + "actionSha256": "030833abe66b5010e1ad768cb461b4434d7d3289c5a83e2ccd388a7ff74a2964", + "owner": "aggregation/stages/currentOp/inactiveSessionsReplicaSet", + "reason": "the sharded-cluster fixtures run the same example on other topologies" + }, + { + "page": "aggregation/stages/merge", + "title": "main", + "actionSha256": "0b8c38bc0cb8bfa1dd7d46446a1a31898fb3e717d9b0525158fe3eabd7657b61", + "name": "Summarize Ratings into Another Collection", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/planCacheStats", + "title": "Find Cache Entry Details for a Query Hash", + "actionSha256": "41f810575e2a2f27f90e5db0ca0f282d533759c52329575ed1c53c37f3582475", + "owner": "aggregation/stages/planCacheStats/findCacheEntryDetailsForAQueryHash", + "reason": "its name is the example's title; the other fixture holds the same example under the page's later title" + }, + { + "page": "aggregation/stages/planCacheStats", + "title": "main", + "actionSha256": "765ee31913796b69459dc41e9283d927ced627ebb30433792b28a79a25507816", + "name": "Populate the Plan Cache", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/project", + "title": "Include Specific Fields from Embedded Documents", + "actionSha256": "f398fb4337ec993a21c9853230ee5bb28aa545539addcee0262f18fc0d54f80d", + "owner": "aggregation/stages/project/includeSpecificFieldsFromEmbeddedDocuments", + "reason": "the AsStage fixture tests the same example built as a stage" + }, + { + "page": "aggregation/stages/querySettings", + "title": "main", + "actionSha256": "415e2de99a5204c0b349852f37c78b452b6017228665df712c7c4f28b639bce9", + "name": "Show the Debug Query Shape", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/queryStats", + "title": "main", + "actionSha256": "288929e2472bc93b5617f57e3401f5ce3a9b8579aba823372f815ba922f01cdc", + "name": "Return Query Statistics", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/rankFusion", + "title": "main", + "actionSha256": "c4871e0499a25d9f92545f72679122a16ef1d2a2cd514d387b5a72018b4a611e", + "name": "Combine Vector and Text Search Ranks", + "reason": "the page gives its only example no title; the name says what the pipeline does" + }, + { + "page": "aggregation/stages/scoreFusion", + "title": "main", + "actionSha256": "2d6d65f7de803401276c55fbb86f847215ae51a080176a56dcaab7302d331433", + "name": "Combine Vector and Text Search Scores", + "reason": "the page gives its only example no title; the name says what the pipeline does" + } + ] +} diff --git a/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt b/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt index e8d865de17d..ee76e9d2586 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt @@ -27,6 +27,7 @@ import dev.morphia.audits.generate.DslBindingCatalog import dev.morphia.audits.generate.ExampleInventory import dev.morphia.audits.generate.GenerationGaps import dev.morphia.audits.generate.GenerationReview +import dev.morphia.audits.generate.ReviewedExamples import dev.morphia.audits.naming.ExampleNameRegistry import dev.morphia.audits.naming.NameProposal import dev.morphia.audits.naming.NamingRequest @@ -200,6 +201,8 @@ object AuditJson { fun exampleInventory(json: String): ExampleInventory = read(json, ExampleInventory::class.java) + fun reviewedExamples(json: String): ReviewedExamples = read(json, ReviewedExamples::class.java) + fun publicationJournal(json: String): PublicationJournal = read(json, PublicationJournal::class.java) diff --git a/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt b/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt index 0f1ec576d0f..177502f5686 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt @@ -3,6 +3,7 @@ package dev.morphia.audits.generate import dev.morphia.audits.repairs.ActionShape import dev.morphia.audits.repairs.BlockRole import dev.morphia.audits.repairs.FixtureMigration +import dev.morphia.audits.repairs.FormEquivalence import dev.morphia.audits.repairs.FormMigration import dev.morphia.audits.repairs.FormOverride import dev.morphia.audits.repairs.FormRule @@ -113,7 +114,12 @@ object CaseGenerator { .filter { it.context in review.families } .forEach { page -> val folder = page.context.substringAfter('/') - val type = "Test" + page.operator.replaceFirstChar { it.uppercase() } + // A page name such as `maxN-array-element` becomes `TestMaxNArrayElement`. + val type = + "Test" + + page.operator.split('-').joinToString("") { part -> + part.replaceFirstChar { it.uppercase() } + } val source = "$SOURCES/${PACKAGE.replace('.', '/')}/$folder/$type.java" page.examples.forEach { example -> fun gap(kind: GapKind, detail: String) { @@ -176,7 +182,8 @@ object CaseGenerator { pageBlob = page.pageBlob, includes = page.includes, unexpandedIncludes = emptyList(), - example = example.title, + // A reviewed name is the case's title, as its display name is. + example = example.name ?: example.title, shape = documented.shape, blocks = example.blocks, rules = emitted.rules.sorted(), @@ -187,7 +194,7 @@ object CaseGenerator { val method = """ | @Test - | @DisplayName(${literal(example.title)}) + | @DisplayName(${literal(example.name ?: example.title)}) | public void $stem() { | runner.aggregate( | OperatorCase.of(${literal(resource)}), @@ -301,8 +308,8 @@ object CaseGenerator { /** Types named in the source, such as an enum argument's. */ val types = mutableSetOf() /** - * The form rules the emitted spelling needs: Morphia writes an implicit equality as `$eq` - * and several operators on one field as one filter each. + * The form rules the emitted spelling needs: Morphia writes an implicit equality as `$eq`, + * several operators on one field as one filter each, and named arguments in its own order. */ val rules = mutableSetOf() @@ -350,6 +357,10 @@ object CaseGenerator { ) } BindingForm.NAMED -> { + // The server reads named arguments in any order, and the generator cannot know + // the order Morphia writes them in. + if (binding.operator in FormEquivalence.namedArgumentOperators) + rules += FormRule.NAMED_ARGUMENTS if (!argument.isDocument) throw Unbound("$path: ${binding.operator} takes a document") val document = argument.asDocument() diff --git a/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt b/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt index 9c8129347c2..f314fec6bdc 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt @@ -1,5 +1,6 @@ package dev.morphia.audits.generate +import com.fasterxml.jackson.annotation.JsonInclude import dev.morphia.audits.coverage.AuditJson import dev.morphia.audits.model.OperatorType import dev.morphia.audits.naming.DescriptiveNames @@ -22,7 +23,10 @@ enum class ExampleStatus { UNOWNED, /** No test owns the example, and its title is generic, so it needs a reviewed name. */ UNNAMED, - /** The example matches more than one owner, or shares its name with another example. */ + /** + * The example matches more than one owner, or shares its name with another example; it keeps + * its source blocks for the review that resolves it. + */ AMBIGUOUS, } @@ -38,8 +42,27 @@ data class DocumentedExample( val owner: String? = null, val detail: String? = null, val blocks: List = emptyList(), + /** The reviewed name of an example whose title is generic; omitted when there is none. */ + @get:JsonInclude(JsonInclude.Include.NON_NULL) val name: String? = null, +) + +/** + * A reviewed decision about one example, identified by its page (`context/operator`), its title and + * the SHA-256 of its action block, so a changed example comes back for review. Exactly one of + * [name] (a descriptive name for a generic title) and [owner] (the fixture that owns an example + * several fixtures match) is set, with the [reason]. + */ +data class ReviewedExample( + val page: String, + val title: String, + val actionSha256: String, + val name: String? = null, + val owner: String? = null, + val reason: String, ) +data class ReviewedExamples(val schemaVersion: Int = 1, val examples: List) + /** * An operator page at the inventory's commit: `context` is the legacy package * (`aggregation/expressions`, ...). @@ -74,6 +97,7 @@ object DocumentedExamples { const val PATH = "audits/catalog/documented-examples.json" private const val RESOURCES = "core/src/test/resources/dev/morphia/test" private const val LEDGER = "audits/catalog/fixture-migration.json" + const val REVIEWED = "audits/catalog/example-names.json" private val DIRECTIVES = mapOf( "expression" to "aggregation/expressions", @@ -96,6 +120,18 @@ object DocumentedExamples { fun capture(repository: Path, pages: Path, sources: CurrentPages): ExampleInventory { val root = repository.toRealPath() val owned = owned(root).groupBy { it.fixture.substringBeforeLast('/') } + val reviewed = + root + .resolve(REVIEWED) + .takeIf { Files.isRegularFile(it) } + ?.let { AuditJson.reviewedExamples(Files.readString(it)).examples } + .orEmpty() + reviewed.forEach { + require((it.name == null) != (it.owner == null) && it.reason.isNotBlank()) { + "${it.page} ${it.title}: a review names an example or its owner, with a reason" + } + } + val used = mutableSetOf() val documented = mutableListOf() val skipped = mutableListOf() sources.pages.forEach { entry -> @@ -136,7 +172,12 @@ object DocumentedExamples { source, read.pageBlob, read.includes, - examples(read.examples.map { it.name to it.blocks }, candidates), + examples( + read.examples.map { it.name to it.blocks }, + candidates, + reviewed.filter { it.page == "$context/$operator" }, + used, + ), ) } val examples = documented.flatMap { it.examples } @@ -148,7 +189,13 @@ object DocumentedExamples { summary = ExampleStatus.entries.associate { status -> "examples.${status.name.lowercase()}" to examples.count { it.status == status } - } + mapOf("pages" to documented.size, "pages.skipped" to skipped.size), + } + + mapOf( + "pages" to documented.size, + "pages.skipped" to skipped.size, + // A review whose example changed or left no longer applies; it is redone. + "reviews.stale" to (reviewed - used).size, + ), ) } @@ -158,32 +205,60 @@ object DocumentedExamples { private fun examples( read: List>>, owners: List, + reviewed: List, + used: MutableSet, ): List { + val reviews = + read.map { (title, blocks) -> + val action = blocks.firstOrNull { it.role == BlockRole.ACTION }?.sha256 + reviewed.singleOrNull { it.title == title && it.actionSha256 == action } + } + used += reviews.filterNotNull() + // A reviewed name stands in for a generic title. + val names = read.mapIndexed { index, (title, _) -> reviews[index]?.name ?: title } val stems = - read.map { (title, _) -> + names.map { title -> if (DescriptiveNames.isGeneric(title)) null else runCatching { DescriptiveNames.stem(title) }.getOrNull() } return read.mapIndexed { index, (title, blocks) -> + val review = reviews[index] + val name = review?.name val action = blocks.firstOrNull { it.role == BlockRole.ACTION }?.text?.let(::squeeze) - val byTitle = owners.filter { it.title == title } + val byTitle = owners.filter { it.title == title || name != null && it.title == name } val byAction = if (byTitle.isNotEmpty() || action == null) emptyList() else owners.filter { it.action != null && it.action in action } val matched = byTitle.ifEmpty { byAction } val stem = stems[index] when { - read.count { it.first == title } > 1 -> + review?.owner != null -> + if (matched.any { it.fixture == review.owner }) + DocumentedExample( + title, + ExampleStatus.OWNED, + owner = review.owner, + detail = "reviewed owner: ${review.reason}", + ) + else + DocumentedExample( + title, + ExampleStatus.AMBIGUOUS, + detail = "the reviewed owner ${review.owner} no longer matches", + ) + names.count { it == names[index] } > 1 -> DocumentedExample( title, ExampleStatus.AMBIGUOUS, detail = "the page has several examples titled \"$title\"", + blocks = blocks, ) matched.size > 1 -> DocumentedExample( title, ExampleStatus.AMBIGUOUS, detail = "matches ${matched.joinToString { it.fixture }}", + blocks = blocks, ) matched.size == 1 -> DocumentedExample( @@ -191,6 +266,7 @@ object DocumentedExamples { ExampleStatus.OWNED, owner = matched.single().fixture, detail = if (byTitle.isEmpty()) "matched by action text" else null, + name = name, ) stem == null -> DocumentedExample( @@ -205,8 +281,16 @@ object DocumentedExamples { ExampleStatus.AMBIGUOUS, stem, detail = "another example on the page has the name $stem", + name = name, + ) + else -> + DocumentedExample( + title, + ExampleStatus.UNOWNED, + stem, + blocks = blocks, + name = name, ) - else -> DocumentedExample(title, ExampleStatus.UNOWNED, stem, blocks = blocks) } } } diff --git a/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt b/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt index 77523325990..d72576a724e 100644 --- a/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt +++ b/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt @@ -17,6 +17,9 @@ import dev.morphia.audits.generate.Exclusion import dev.morphia.audits.generate.GapKind import dev.morphia.audits.generate.GenerationReview import dev.morphia.audits.generate.MethodRef +import dev.morphia.audits.generate.ReviewedExample +import dev.morphia.audits.generate.ReviewedExamples +import dev.morphia.audits.repairs.BlockRole import dev.morphia.audits.repairs.FixtureMigrationLedger import dev.morphia.audits.repairs.FormSource import java.nio.file.Files @@ -177,6 +180,79 @@ class GeneratorTest { assertEquals(inventory, AuditJson.exampleInventory(AuditJson.write(inventory))) } + /** A reviewed name stands in for a generic title; a stale review is counted, not applied. */ + @Test + fun reviewedNamesResolveGenericTitles() { + val first = inventory() + val main = + first.pages.single { it.operator == "bitAnd" }.examples.single { it.title == "main" } + val action = main.blocks.single { it.role == BlockRole.ACTION } + fun review(vararg examples: ReviewedExample) = + write( + directory.resolve("repository/${DocumentedExamples.REVIEWED}"), + AuditJson.write(ReviewedExamples(examples = examples.toList())), + ) + review( + ReviewedExample( + "aggregation/expressions/bitAnd", + "main", + action.sha256, + name = "AND a Field with One", + reason = "untitled", + ), + ReviewedExample( + "aggregation/expressions/bitAnd", + "main", + "0".repeat(64), + name = "Changed Since", + reason = "its example changed", + ), + ) + val named = inventory() + val example = + named.pages.single { it.operator == "bitAnd" }.examples.single { it.title == "main" } + assertEquals( + Triple(ExampleStatus.UNOWNED, "andAFieldWithOne", "AND a Field with One"), + Triple(example.status, example.stem, example.name), + ) + assertEquals(1, named.summary["reviews.stale"]) + val source = + CaseGenerator.generate( + named, + bindings.copy( + bindings = + bindings.bindings + + DslBinding( + "\$bitAnd", + BindingPosition.EXPRESSION, + BindingForm.POSITIONAL, + "$expressions.MathExpressions", + "bitAnd", + listOf("java.lang.Object", "java.lang.Object"), + ) + ), + GenerationReview(families = listOf("aggregation/expressions")), + emptySet(), + ) + .files + .getValue( + "core/src/test/java/dev/morphia/test/generated/expressions/TestBitAnd.java" + ) + assertTrue("@DisplayName(\"AND a Field with One\")" in source, source) + // A review names an example or its owner, never both. + review( + ReviewedExample( + "aggregation/expressions/bitAnd", + "main", + action.sha256, + name = "x", + owner = "y", + reason = "both", + ) + ) + assertThrows(IllegalArgumentException::class.java) { inventory() } + } + private val expressions = "dev.morphia.aggregation.expressions" private val bindings = DslBindingCatalog( @@ -389,7 +465,8 @@ class GeneratorTest { assertEquals("sample_mflix", scenario.getString("dataset").value) assertTrue("sample_mflix" in scenario.getDocument("skipped").getString("results").value) assertEquals( - listOf("EQ_SHORTHAND", "FIELD_OPERATORS_AND"), + // $top's named arguments may come in any order. + listOf("EQ_SHORTHAND", "FIELD_OPERATORS_AND", "NAMED_ARGUMENTS"), scenario.getDocument("comparison").getArray("rules").map { it.asString().value }, ) assertEquals( diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestMaxNArrayElement.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestMaxNArrayElement.java new file mode 100644 index 00000000000..2a6a73f7b8b --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestMaxNArrayElement.java @@ -0,0 +1,36 @@ +// spotless:off +package dev.morphia.test.generated.expressions; + +import java.util.List; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.maxN; +import static dev.morphia.aggregation.stages.AddFields.addFields; +import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Projection.project; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.query.filters.Filters.in; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestMaxNArrayElement extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Find the Top Two Cast Members") + public void findTheTopTwoCastMembers() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/maxN-array-element/findTheTopTwoCastMembers/scenario.json"), + (aggregation) -> aggregation.pipeline( + match(in("title", List.of("The Godfather", "Spirited Away", "The Dark Knight"))), + addFields().field("topTwoCast", maxN(2, "$cast")), + project().suppressId().include("title").include("cast").include("topTwoCast"), + sort().ascending("title"))); + } +} +// spotless:on diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingAcrossMultipleYears/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingAcrossMultipleYears/scenario.json index 4e317164ae7..34b7661d1cf 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingAcrossMultipleYears/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingAcrossMultipleYears/scenario.json @@ -148,7 +148,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "FIELD_OPERATORS_AND" + "FIELD_OPERATORS_AND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingInAGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingInAGenre/scenario.json index c775dca26fe..afc4dfa3220 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingInAGenre/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingInAGenre/scenario.json @@ -75,7 +75,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre/scenario.json index 8e57b2c99dd..f8a6703ece3 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre/scenario.json @@ -112,7 +112,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesForASingleGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesForASingleGenre/scenario.json index 49e4a23ee68..396a63a511c 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesForASingleGenre/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesForASingleGenre/scenario.json @@ -108,7 +108,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN-array-element/findTheTopTwoCastMembers/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN-array-element/findTheTopTwoCastMembers/scenario.json new file mode 100644 index 00000000000..f4b5f933ac7 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN-array-element/findTheTopTwoCastMembers/scenario.json @@ -0,0 +1,214 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/maxN-array-element/findTheTopTwoCastMembers", + "title": "Find the Top Two Cast Members", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/maxN-array-element.txt", + "blob": "4351c1c52f41b27c5d963e1106567f95c3bfd32e" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$match": { + "title": { + "$in": [ + "The Godfather", + "Spirited Away", + "The Dark Knight" + ] + } + } + }, + { + "$addFields": { + "topTwoCast": { + "$maxN": { + "n": { + "$numberInt": "2" + }, + "input": "$cast" + } + } + } + }, + { + "$project": { + "_id": { + "$numberInt": "0" + }, + "title": { + "$numberInt": "1" + }, + "cast": { + "$numberInt": "1" + }, + "topTwoCast": { + "$numberInt": "1" + } + } + }, + { + "$sort": { + "title": { + "$numberInt": "1" + } + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "title", + "value": { + "text": "Spirited Away" + } + }, + { + "name": "cast", + "value": { + "array": [ + { + "text": "Rumi Hiiragi" + }, + { + "text": "Miyu Irino" + }, + { + "text": "Mari Natsuki" + }, + { + "text": "Takashi Naitè" + } + ] + } + }, + { + "name": "topTwoCast", + "value": { + "array": [ + { + "text": "Takashi Naitè" + }, + { + "text": "Rumi Hiiragi" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "title", + "value": { + "text": "The Dark Knight" + } + }, + { + "name": "cast", + "value": { + "array": [ + { + "text": "Christian Bale" + }, + { + "text": "Heath Ledger" + }, + { + "text": "Aaron Eckhart" + }, + { + "text": "Michael Caine" + } + ] + } + }, + { + "name": "topTwoCast", + "value": { + "array": [ + { + "text": "Michael Caine" + }, + { + "text": "Heath Ledger" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "title", + "value": { + "text": "The Godfather" + } + }, + { + "name": "cast", + "value": { + "array": [ + { + "text": "Marlon Brando" + }, + { + "text": "Al Pacino" + }, + { + "text": "James Caan" + }, + { + "text": "Richard S. Castellano" + } + ] + } + }, + { + "name": "topTwoCast", + "value": { + "array": [ + { + "text": "Richard S. Castellano" + }, + { + "text": "Marlon Brando" + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "NAMED_ARGUMENTS" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesAcrossMultipleYears/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesAcrossMultipleYears/scenario.json index 26690df1c5f..9603c45a4f3 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesAcrossMultipleYears/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesAcrossMultipleYears/scenario.json @@ -168,7 +168,9 @@ }, "comparison": { "order": "ORDERED", - "rules": [], + "rules": [ + "NAMED_ARGUMENTS" + ], "ignore": [], "tolerance": null }, diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesForASingleYear/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesForASingleYear/scenario.json index d3830b655c5..bcb2c345566 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesForASingleYear/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesForASingleYear/scenario.json @@ -86,7 +86,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsForASingleGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsForASingleGenre/scenario.json index 363be9620b1..2beb144f899 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsForASingleGenre/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsForASingleGenre/scenario.json @@ -77,7 +77,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingAcrossMultipleRatings/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingAcrossMultipleRatings/scenario.json index b1919680ad3..72c7fc33e1c 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingAcrossMultipleRatings/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingAcrossMultipleRatings/scenario.json @@ -168,7 +168,9 @@ }, "comparison": { "order": "ORDERED", - "rules": [], + "rules": [ + "NAMED_ARGUMENTS" + ], "ignore": [], "tolerance": null }, diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingInAGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingInAGenre/scenario.json index 741804ecbcc..56f78279abc 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingInAGenre/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingInAGenre/scenario.json @@ -80,7 +80,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre/scenario.json index d1e62571db6..321eced331f 100644 --- a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre/scenario.json +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre/scenario.json @@ -114,7 +114,8 @@ "comparison": { "order": "ORDERED", "rules": [ - "EQ_SHORTHAND" + "EQ_SHORTHAND", + "NAMED_ARGUMENTS" ], "ignore": [], "tolerance": null diff --git a/core/src/test/resources/dev/morphia/test/generated/manifest.json b/core/src/test/resources/dev/morphia/test/generated/manifest.json index aab2e5e8942..755fc14bf4f 100644 --- a/core/src/test/resources/dev/morphia/test/generated/manifest.json +++ b/core/src/test/resources/dev/morphia/test/generated/manifest.json @@ -564,6 +564,11 @@ "name" : "aggregation/expressions/max/useInSetWindowFieldsStage", "scenario" : "/dev/morphia/test/aggregation/expressions/max/useInSetWindowFieldsStage/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestMax#testUseInSetWindowFieldsStage" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/maxN-array-element/findTheTopTwoCastMembers", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/maxN-array-element/findTheTopTwoCastMembers/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestMaxNArrayElement#findTheTopTwoCastMembers" }, { "kind" : "CONVERTED", "name" : "aggregation/expressions/maxN/computingNBasedOnTheGroupKeyForGroup", @@ -1890,6 +1895,10 @@ "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestMaxN.java", "sha256" : "4f95b5f229f7fb00e340c3ded0f48ca1444335c71152a6f4a6a39c14c4acca8b" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/expressions/TestMaxNArrayElement.java", + "sha256" : "cb41ee0b3be918fa7cd34e2621fe6edfded90ba044f9aeea5c5e1c3fef06ede4" }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestMinN.java", @@ -3033,31 +3042,35 @@ }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingAcrossMultipleYears/scenario.json", - "sha256" : "386a320bce697eb4944f465f8423cd9b447cdfd1180d6b6b625935e53b1a2e77" + "sha256" : "a0d5201577c5074deb78b21f253ca42d331adb83e59dc28885d11841e7829239" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingInAGenre/scenario.json", - "sha256" : "ca01406e371ac6d641ed62694c18090af9777d6b061a58ddd5850f7e6228f790" + "sha256" : "4128485c63db3adfac11548496f0eb6fa296f1392f2054644be532dc740cd246" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre/scenario.json", - "sha256" : "22053109001193c7bb877b43311df5ac88254c3c38b4b70a95c1299539932466" + "sha256" : "c39d5e9bf578743e5c62e1860855de6de0b16c4f97e4b7e7eb1a36d4aec8e0d0" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesForASingleGenre/scenario.json", - "sha256" : "e6b04741d3a95332d0b6530eaba9197231cc7355c15a718a754a70252581ff02" + "sha256" : "5f7e61c8328a7846714106adb205ad931964ac8fba344b5f6d7e5fbbd6b06cda" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN-array-element/findTheTopTwoCastMembers/scenario.json", + "sha256" : "64842f658bd4a8276dea7f2206c0b6b3c408c2a8422081eedf45a2f70027904d" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesAcrossMultipleYears/scenario.json", - "sha256" : "58b899553d1f69903b4888716263c7e729356dda9fcb1e8937acd58f6346536f" + "sha256" : "300e1f76bf307ecbbdb0c8bffba7bcfd4c211383c9041b655feece4bfadf67d1" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesForASingleYear/scenario.json", - "sha256" : "2f9a52e4361e091ed0af097cb67085665606deb9afa35bbf05c4696c3ef257ca" + "sha256" : "d64d3877583249c2452d3065799e494cc0e990f39f24201bd2e4f3d70b2582f5" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsForASingleGenre/scenario.json", - "sha256" : "39119f69699062f533d5e6facae77297af5757e7e0351fbb0f0e1152119c62f0" + "sha256" : "a256b42390db32b61d78f9017f2d1d62871ae0d1fc83547723ea437e112d2626" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/round/roundExpressionOperator/scenario.json", @@ -3065,15 +3078,15 @@ }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingAcrossMultipleRatings/scenario.json", - "sha256" : "a68bef250e2fcc2f0a3898874873d0aef30d0bfd6a8a4c5b986190fc7ea795b3" + "sha256" : "bb74126de8c6ba5ff3a9a4048ffbaa5d6455be9407e862ad4cb1b43c04ef7077" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingInAGenre/scenario.json", - "sha256" : "4ec04e434e2517e18ed05c11129fae06d55dee0c5f743a354fc40152ccd81e37" + "sha256" : "49525d957d45ca1c4eda22c8c8829da59f9b983aff38b251fc1d34cb208f4bc1" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre/scenario.json", - "sha256" : "60aa1a5031c2b402052f2c1f619abe9d70b98b55a5ca499a6e2df6ee8a53eae5" + "sha256" : "c00273bdf10a7ad0ba29a9e4f603963c802b0be41588284f15a273a45343d6ba" }, { "owner" : "PROTECTED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/runner/crossDatabase/scenario.json", diff --git a/design/operator-audits-design.md b/design/operator-audits-design.md index 54c7a67c6ec..cd50f34f373 100644 --- a/design/operator-audits-design.md +++ b/design/operator-audits-design.md @@ -218,7 +218,13 @@ Each example gets one status: - **UNOWNED**: nothing covers it; the inventory keeps its source blocks so generation never needs the page again. - **UNNAMED**: it has no usable title, so it needs a reviewed name. -- **AMBIGUOUS**: its name collides with another. +- **AMBIGUOUS**: its name collides with another, or several fixtures match it. + +`example-names.json` holds the reviews that resolve the last two: a descriptive name for a generic +title, or the owner among several matching fixtures, each with its reason. A review is keyed by page, +title and the action block's SHA-256, so an example that changes upstream comes back for review; the +inventory counts the reviews that no longer apply (`reviews.stale`). A reviewed name is the +generated case's title and display name. Generated cases never count as owners: generation derives them from the unowned examples on every run. @@ -255,7 +261,8 @@ a test method: 4. **Write the scenario.** `FixtureMigration.scenario` writes it in the same format a converted case uses, ordered. Its form rules are those the emitted spelling needs: `EQ_SHORTHAND` when a plain value became `eq()`, `FIELD_OPERATORS_AND` when one field's operators became one filter - each. + each, and `NAMED_ARGUMENTS` when it calls an operator that takes only named arguments, whose + order the server ignores and Morphia chooses. An example that seeds no data and queries a collection of MongoDB's sample datasets, as most tested snippets do, names that dataset (`generation-review.json`'s `sampleDatasets`). The tests do not load diff --git a/design/operator-audits-progress.md b/design/operator-audits-progress.md index aca0fc23cfd..29b22ba58d1 100644 --- a/design/operator-audits-progress.md +++ b/design/operator-audits-progress.md @@ -18,10 +18,10 @@ how the audits work updates it too; this file records what each PR delivered. Every step of the plan (0–7) has been started. What stands: -- **On the runner:** 363 legacy cases (362 converted, 1 migrated), plus 11 generated cases. +- **On the runner:** 363 legacy cases (362 converted, 1 migrated), plus 12 generated cases. Core gate: 662 tests under each mapper; audits: 452. - **Generation:** inventory of mongodb/docs `e4b0c153` (297 pages read, tested snippets - included; 433 examples owned, 115 unowned, 30 unnamed, 4 ambiguous), reviewed DSL bindings checked against core's API, and the + included; 437 examples owned, 145 unowned, none unnamed or ambiguous after review), reviewed DSL bindings checked against core's API, and the candidate → integrate → promote path. One expressions case is generated, and three are excluded with evidence. - **Monitoring:** a weekly discovery workflow that re-inventories the docs, regenerates, @@ -45,7 +45,6 @@ Step 5, generation and cutover: `$deserializeEJSON`, `$toObject`, `$toArray`, `$hexHash`, `$percentile`, `$limit`, `$type`, a compound `$group` `_id`, `$convert` options, `$reduce` `valueAs`). - **Find and update generation.** Only aggregation pipelines are generated. -- **Reviewed names** for the 30 unnamed and 4 ambiguous examples. - **The remaining legacy fixtures:** 193 directories. - 98 are locked; 96 are unresolved in `form-review.json`. - 23 are legacy-only in `cutover.json`. @@ -2627,3 +2626,18 @@ no product-documentation changes. Legacy operator AsciiDoc tables are intentiona one-key documents. Fixed in #4571 (2.5 has the same code). - 10 new generated cases (`$top`, `$bottom`, `$topN`, `$bottomN`, `$firstN`, `$maxN`, `$minN`), all sample-dataset cases checking serialization. Core: 689 tests under each mapper; audits: 456. + +## Reviewed example names (2026-11-23) + +- Branch audits-example-names. `audits/catalog/example-names.json` holds 34 reviews, keyed by page, + title and action SHA-256: 30 descriptive names for examples titled `main`, and the owner of 4 + examples several legacy variants match (`bucketAuto`, `currentOp`, `planCacheStats`, `project`). + A review names an example or its owner, never both, and gives a reason; stale reviews are counted + as `reviews.stale`. Ambiguous examples now keep their source blocks for review. +- Inventory: 437 owned, 145 unowned, none unnamed or ambiguous. +- Generator: a reviewed name is the case's title and display name; a hyphenated page name + (`maxN-array-element`) becomes a valid class name (`TestMaxNArrayElement`); `NAMED_ARGUMENTS` is + declared for every named-argument operator it emits, since Morphia chooses their order (it writes + `$maxN` as `{input, n}`). +- One more generated case (`maxN-array-element`, "Find the Top Two Cast Members"); 12 in all. + Core: 690 tests under each mapper; audits: 457.