fix: exclude test-origin queries from the gate (bump core to 0.13.0)#185
Merged
Conversation
The new-query gate flagged Query Doctor's own test read-backs of `project_queries` (e.g. `SELECT normalized_fingerprint ... WHERE hash = $1` from `project-queries.repository.spec.ts`) as new on every run, blocking unrelated PRs — including docs-only ones (Site #3606). Root cause is a client/server version skew of one shared rule. SQLCommenter `file` tags carry a `:line:col` suffix (`…spec.ts:509:10`); `isTestOriginQuery` must strip it before the `$`-anchored `.spec.ts` pattern can match. Core 0.12.1 added that strip. The Site API picked it up (it stopped storing these queries around July 15), but the analyzer bundled an older core, so `compareRuns` never bucketed them into `testOriginExcluded` — they stayed in `newQueries` and the gate fired. Because the server never stores them, no baseline ever contains them, so they re-appear as "new" on every run regardless of rebase. Bump `@query-doctor/core` to ^0.13.0 so the analyzer applies the same test-origin rule as the server. 0.13.0 also adds `runQuery` to the ClientApi RPC surface; the CI `ApiClient` doesn't implement it, so its stub now throws to satisfy the type (it's never invoked). Add a regression test covering a `.spec.ts` file tag with a `:line:col` suffix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Query Doctor Analysis
3 queries analyzed
0 regressed · 0 improved · 0 new · 0 removed
2 pre-existing issues
SELECT "guests"."id", "guests"."session_id", "guests"."username", "guests"."avatar_path", "guests"."color", "guests"."side", "guests"."audio_recording_path", "guests"."audio_recording_public", "gue...
indexassets(event_id, inserted_at desc)
cost 31,003,449 → 1,498 (100% reduction)SELECT * FROM guest_ip_addresses WHERE ip_address = '127.0.0.1';
indexguest_ip_addresses(ip_address)
cost 154,402 → 8 (100% reduction)
Using assumed statistics (10000000 rows/table). For better results, sync production stats.
More detail → get_ci_run({ runId: "019f8640-521a-7a4e-93a2-b35c9108a864" }) · view run · docs
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.
Goal
Stop the new-query gate from phantom-blocking PRs on Query Doctor's own repo — including docs-only ones — with queries that were never added by the PR. Fixes Query-Doctor/Site#3606.
What
Before: the
analyzer / Analyzercheck failed with "N new queries ship with a high-impact index recommendation", listing Query Doctor's own test read-backs ofproject_queries(SELECT "normalized_fingerprint" FROM "project_queries" WHERE "hash" = $1and its full-row sibling, cost 17, 51% cut). These recur on every run against every baseline, so a rebase doesn't clear them.After: those queries are recognized as test-origin and bucketed out of the gate, matching what the Site API already does. A genuinely new query still gates.
How
Root cause is a client/server version skew of one shared rule:
db.select()read-backs inapps/api/src/projects/project-queries.repository.spec.ts(lines 479 and 506, helperreadFingerprint). Their SQLCommenterfiletag is…project-queries.repository.spec.ts:509:10— a:line:colsuffix on the path.isTestOriginQuerymust strip that suffix before the$-anchored.spec.tspattern can match. Core 0.12.1 added the strip. The Site API adopted it (it stopped storing these queries around July 15), but the analyzer bundled an older core (installed0.10.10), socompareRunsnever moved them totestOriginExcluded— they stayed innewQueriesand the gate fired. Since the server never stores them, no stored baseline ever contains them, so they read as "new" run after run.The fix is the dependency bump; there is no gate-logic change. Read
package.jsonfirst, thensrc/remote/api-client.ts, then the test.@query-doctor/core^0.12.0→^0.13.0so the analyzer applies the same test-origin rule as the server.runQueryto theClientApiRPC surface. The CIApiClientdoesn't implement it (nothing calls it there), so its stub now throws to satisfy the new return type rather than silently returningundefined.Verified against the prod Site DB: the two runs behind #3606 store an identical 91-hash set as their baselines (server rollup
new: 0), and the catalog shows these two hashes withlast_seen_source = cifrozen at2026-07-15 01:00— the point the server started dropping them.Tests
compareRunscase: a.spec.tsquery whosefiletag carries a:line:colsuffix is excluded (testOriginExcluded, notnewQueries). Fails on pre-0.12.1 core, passes now.Follow-up (deploy, not in this PR): cut a new analyzer action release so CI runs pick up the bumped core.
🤖 Generated with Claude Code