Repository navigation
feat(evals): add investigate-database-001-slow-query CLI eval (CLI-2712) - #425
Conversation
…te-database-001-slow-query (CLI-2712)
…001-slow-query (CLI-2712)
…tigate-database-001-slow-query (CLI-2712)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Question from cross-review (Codex):
|
…inspect on purpose (CLI-2712)
|
Yes, that's on purpose. CLI-2712 is about whether agents discover The first refresh backs it up: 8/12 Docker runs found the right cause without ever running an inspect report, and the bundled |
avallete
left a comment
There was a problem hiding this comment.
Thanks, README rationale makes the inspect requirement clear. Re-review (Codex) raised one minor edge case, non-blocking — up to you here or in a follow-up:
evals/cli/investigate-database-001-slow-query/inspect.ts:127— readinginspect reportoutput through a CSV wildcard (e.g.cat out/*/*.csv) may not be matched as reading a report file, so a valid run could fail the inspect check. Not reproduced.
…database-001-slow-query (CLI-2712)
Current Behavior
No CLI eval covers diagnosing a database with
supabase inspect. Agents drive 89% ofinspectuse outside CI, yet it appears in 0.5% of agent sessions or fewer (PostHog figures in the CLI evals plan). Users keep asking for this path: FDBKIN-1481 wants tooling to find slow queries, FDBKIN-1663 wants index usage made visible, and FDBKIN-13604 reportsinspect dbcommands failing.Expected Behavior
Adds
evals/cli/investigate-database-001-slow-query(CLI-2712). The prompt says the app keeps getting slower, and asks the agent to use the Supabase CLI to find what's slow in the local database, fix it, and save the fix in the project so it ships. It names no subcommand, table, column or fix, andfixtures.test.tsguards that.local/seeds a project with no running stack. It has one table,public.orders, with only its primary key index.seed.sqlbulk-loads 300,000 orders and then replays 300 of the app's requests: 200 per-customer order-history lookups filtering oncustomer_email(a sequential scan each) and 100 primary-key lookups. Once the agent starts the stack,inspect db outliers/calls(pg_stat_statements) andtable-stats(sequential scans) already point at the lookup.supabase inspectagainst the seeded database and the report reached the table. A deterministic gate fails the check when no inspect call ran, or when no inspect call's output namesorders, nor any later call reading a file the report wrote. Otherwise a judge looks at those calls in full and decides whether theorderstext came from the inspect report itself, rather than psql,db query, a grep of the repo, echo text or a refused reportexplain (format json)on the lookup for a customer the seed never replays: no seq scan onorders, plus an index node whoseIndex Condnamescustomer_emaildb diffand quoted outputNotes
inspect dbdefaults to--linkedand fails with "Cannot find project ref. Have you run supabase link?" when nothing is linked. The agent has to find--local(or--db-url); on 3.0.0-next the default is local.supabase startdefaults to the legacy Docker backend (CLI-2534).inspect, because the scenario is aboutinspect. An agent that finds the problem with psql/EXPLAIN alone and ships a correct fix fails only this check.printfseparators false-failed, and un-pipedrg, heredocs and nestedbash -cfalse-passed. The gate keeps the judge off runs where nothing could pass.db diff -froute when it isn't followed by a reset,migration upor repair:db diff -fwrites the file but never records it, so the local history no longer matches the files. A hand apply followed bymigration repair --status appliedpasses.evals/cli/lib/, so this PR doesn't re-run that eval. Extracting it is a follow-up.Verified locally
pnpm format:check,pnpm typecheckandpnpm testpass, including this eval's scorer tests (attribution counterexamples, EXPLAIN plan shapes, migration SQL shapes, history probe, metrics, ground truth and end-to-end scorer cases).pnpm eval -- list --experiment-suite cli --eval investigate-database-001-slow-querypicks the eval up in all sixcodex-gpt-6-luna-cli-*experiments.inspect dbsubcommands and the--linkeddefault checked with--helpon 2.117.0, 2.121.0, 2.122.0-beta.12 and 3.0.0-next.22, and against the CLI source.Results
Latest refresh, 39945930189, after the CSV glob fix (3 runs per environment):
inspect db --helpinspect --helpsupabase startuses the legacy Docker backend (CLI-2534)All 12 Docker runs found the unindexed
customer_emaillookup and left the index live and in a new migration. The failures are the agent, not the scorer:supabase db queryagainstpg_stat_statementsplusEXPLAIN, stopping at most atinspect --help, and fail only check 2. This is the gap the eval measures (see the README's "Requiringinspectis intentional").apply_patchas a shell command, which isn't on the sandbox's PATH, thenmigration upin the same call. That recorded the still-empty migration. The agent then created the index by hand withdb queryand wrote the file. The history check catches this. The report judge also failed its "the migration is recorded locally", since the recorded version holds no index statements and the report never mentions the hand apply.The previous refresh (39786495558) passed 1/12 Docker runs. 8 runs failed the inspect check the same way, and 3 failed because the agent stopped the stack after the fix, as the README describes. No run stopped the stack this time.
I read every inspect and report verdict against its transcript. Every inspect pass comes from real
inspect db outliers/calls/index-stats/table-statsoutput namingpublic.orders. There are no false passes and no false fails. No run took a container-runtime detour.Review follow-up: avallete's edge case was real. After
inspect report, reading the CSVs through a pure glob (cat */*.csv,find . -name '*.csv') wasn't counted as reading the report. a30de05 fixes it, with tests for both sides. No run in this refresh usedinspect report.Minor: the
inspectReportsmetric countsinspect db helpas a report. Scores aren't affected.Braintrust: pinned · stable · beta · next · nodaemon · absent
Related Issue(s)
Closes CLI-2712
🤖 Generated with Claude Code