Skip to content

EAI-2397: Port the 19 synthetic Query Insights eval cases - #246

Open
mongodben wants to merge 3 commits into
cursor/eai-2397-judges-9b9afrom
cursor/eai-2397-synthetic-cases-9b9a
Open

mongodben wants to merge 3 commits into
cursor/eai-2397-judges-9b9afrom
cursor/eai-2397-synthetic-cases-9b9a

Conversation

@mongodben

@mongodben mongodben commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Jira: https://jira.mongodb.org/browse/EAI-2397

Why this change

  • The Query Insights report needs eval cases that cover real query shapes, not just the hand-written smoke set.
  • The source eval fixtures were approved for open-sourcing, so this PR ports the 19 synthetic ones first.

Changes

  • Adds 19 mock Atlas seeds, one per synthetic source, under fixtures/atlas/query-insights-case-<id>.yml.
  • Adds the query-insights dataset (datasets/query-insights.yml) and registers it in the CLI.
  • Extends pnpm port:query-insights to take a hand-written reference for each case, and to emit a scripted Performance Advisor call for offline runs.
  • Adds src/porting/query-insights-selection.yml, which lists the cases and their rewritten references.

Notes

  • References are rewritten by hand. The source references quote lifetime totals the agent never sees, so the CLI now requires a reference per entry.
  • The rewritten references have no numbers, and drop claims about metrics the slow log lines don't show (such as bytes read).
  • Offline test: src/queryInsightsDataset.test.ts checks that every case reads a valid seed, that references have no numbers, and that the scripted run calls the Performance Advisor on all 19 cases.
  • Real-model baseline: gpt-6.1-terra, 5 trials, 19 cases, run on Braintrust.
Score Mean
SuggestedIndexUsage 100%
ReportShape 100%
ReportFactuality 97.1%
ReferenceCoverage 80%
ToolCallArgCoverage 100%
ToolCallCoverage 31.1%
  • ToolCallCoverage is low for a reason the metric hides. When the agent makes more than twice the required calls, the score becomes ceiling / actual. The agent investigates with collection_indexes, explain and similar tools, so the number reflects extra calls, not a missed Performance Advisor call. ToolCallArgCoverage is the signal to use for thresholds.
  • Stacked on cursor/eai-2397-judges-9b9a.
  • Open: the Query Insights team has not yet reviewed the rewritten references.
Open in Web Open in Cursor 

@mongodben
mongodben added this pull request to stack #255 November 3, 2026 20:27
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from 9245bb8 to 21589d6 Compare November 4, 2026 18:45
@cursor cursor Bot changed the title EAI-2397: Port the 19 synthetic Query Insights cases from mms EAI-2397: Port the 19 synthetic Query Insights eval cases Nov 4, 2026
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from 867d02c to 9335a17 Compare November 4, 2026 19:12
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from 9335a17 to fc141bb Compare November 4, 2026 19:20
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from fc141bb to 0932ae5 Compare November 4, 2026 19:29
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from 0932ae5 to ade156b Compare November 4, 2026 19:35
@mongodben
mongodben removed this pull request from stack #255 November 4, 2026 19:36
@mongodben
mongodben added this pull request to stack #262 November 4, 2026 19:36
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from ade156b to e86448a Compare November 4, 2026 19:46
Converts the synthetic source fixtures into mock Atlas seeds and a
query-insights dataset. The converter now takes a hand-written reference
per case, because the source references quote lifetime totals, and each
case replays the Performance Advisor call for the offline scripted run.
@cursor
cursor Bot force-pushed the cursor/eai-2397-synthetic-cases-9b9a branch from e86448a to ea7ea02 Compare November 4, 2026 19:53
@mongodben
mongodben requested a balanced review from Copilot November 4, 2026 19:54
@mongodben
mongodben requested a review from davidjahn November 4, 2026 19:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Several query-insights reference explanations misinterpret join and index behavior or assume an unknown boolean, creating incorrect grading expectations that can penalize accurate reports.

4 open issues
What changed in this PR

Ports 19 synthetic Query Insights cases into the evaluation suite, expanding
coverage beyond smoke tests with mock Atlas data and rewritten references.

Changes:

  • Adds and registers a dataset with 19 matching Atlas fixtures.
  • Requires hand-written references in the porting CLI and generates scripted
    Performance Advisor calls for offline runs.
  • Adds tests for fixture validity, number-free references, and tool-call coverage.
File Description
packages/​evals/​src/​queryInsightsDataset.test.ts Validates fixtures, references, and offline tool coverage.
packages/​evals/​src/​porting/​query-insights-selection.yml Selects 19 cases and defines rewritten references.
packages/​evals/​src/​porting/​portQueryInsightsCases.ts Requires references and omits generated source comments.
packages/​evals/​src/​porting/​portQueryInsightsCase.ts Supports reference overrides and scripted advisor calls.
packages/​evals/​src/​porting/​portQueryInsightsCase.test.ts Tests scripts, reference overrides, and seed rendering.
packages/​evals/​src/​porting/​portAssistantCase.ts Makes source comments optional in dataset rendering.
packages/​evals/​src/​porting/​portAssistantCase.test.ts Tests rendering without source comments.
packages/​evals/​src/​cli.ts Registers the Query Insights dataset.
packages/​evals/​fixtures/​atlas/​query-insights-case-34.yml Seeds an unfiltered sort with an index suggestion.
packages/​evals/​fixtures/​atlas/​query-insights-case-33.yml Seeds collection storage-statistics queries.
packages/​evals/​fixtures/​atlas/​query-insights-case-32.yml Seeds nested-array matching with sorting.
packages/​evals/​fixtures/​atlas/​query-insights-case-31.yml Seeds a partially supported multi-field sort.
packages/​evals/​fixtures/​atlas/​query-insights-case-30.yml Seeds a two-field ascending sort.
packages/​evals/​fixtures/​atlas/​query-insights-case-29.yml Seeds a nested-field range query.
packages/​evals/​fixtures/​atlas/​query-insights-case-28.yml Seeds text search with relevance sorting.
packages/​evals/​fixtures/​atlas/​query-insights-case-27.yml Seeds matching followed by grouping.
packages/​evals/​fixtures/​atlas/​query-insights-case-26.yml Seeds a status query with a broad compound-index suggestion.
packages/​evals/​fixtures/​atlas/​query-insights-case-25.yml Seeds a match, sort, and limit aggregation.
packages/​evals/​fixtures/​atlas/​query-insights-case-24.yml Seeds an unindexed $in query.
packages/​evals/​fixtures/​atlas/​query-insights-case-23.yml Seeds an $or query with blocking sorting.
packages/​evals/​fixtures/​atlas/​query-insights-case-22.yml Seeds an $or query using a collection scan.
packages/​evals/​fixtures/​atlas/​query-insights-case-21.yml Seeds deep skip-based pagination.
packages/​evals/​fixtures/​atlas/​query-insights-case-19.yml Seeds an unindexed field-existence test.
packages/​evals/​fixtures/​atlas/​query-insights-case-17.yml Seeds range filtering with in-memory sorting.
packages/​evals/​fixtures/​atlas/​query-insights-case-16.yml Seeds a regex query with extensive key scanning.
packages/​evals/​fixtures/​atlas/​query-insights-case-15.yml Seeds an inefficient index-prefix query.
packages/​evals/​fixtures/​atlas/​query-insights-case-14.yml Seeds an admissions-to-memberships lookup.
packages/​evals/​datasets/​query-insights.yml Defines cases, scripts, expected calls, and grading references.

Review effort: Balanced

Comment on lines +19 to +21
elaboration: "The `$match` is supported by an index, but each
admission is joined with several membership documents, so the
join multiplies the documents the pipeline processes. Consider a

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as is. The join claim comes from the source eval case's reference answer, which we treat as ground truth for these ported cases. We only rewrote it to drop lifetime totals the agent never sees. Whether $lookup multiplies rows is a judgement the source case already made, so we'd rather not change it here. If it turns out to be wrong, the fix belongs in the source case first, and we can re-port it.

Comment on lines +50 to +51
elaboration: "The index scan examines many keys, and every document
it examines is returned, so the index filters out little. Consider

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and fixed in fb728cb. The inference that the index "filters out little" was ours, not the source case's. The reference now says: "The index scan examines many keys, while every document it fetches is returned." It no longer claims anything about the index filtering. Selection file and datasets/query-insights.yml are both updated, and the six PRs above this one are restacked.

- file: case_19_synthetic.json
reference:
queryOverview: "This query finds tasks where `taskType` equals a string
value and the `archivedAt` field exists."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as is. The partial-index advice for the archivedAt existence test is in the source eval case's reference answer, which we treat as ground truth. The port only removes lifetime totals the agent never sees. The ?bool placeholder is how the seed hides the literal value, not a statement about it. If the source advice is wrong, the fix belongs in the source case first.

Comment on lines +169 to +170
elaboration: "Adding the right index will help, since it reduces the
number of documents that reach the `$group` stage. Review the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as is. "Reduces the number of documents that reach the $group stage" comes from the source eval case's reference answer, which we treat as ground truth. The port only removes lifetime totals the agent never sees. If the source wording is wrong, the fix belongs in the source case first.

@mongodben
mongodben marked this pull request as ready for review November 4, 2026 20:03
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.

3 participants