Skip to content

refactor(evals): share migration-history, psql and stack-lifecycle helpers in cli/lib - #429

Open
Coly010 wants to merge 6 commits into
mainfrom
columferry/share-cli-eval-helpers
Open

Coly010 wants to merge 6 commits into
mainfrom
columferry/share-cli-eval-helpers

Conversation

@Coly010

@Coly010 Coly010 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Four CLI evals had their own copies of the same migration-history query, psql runner and stack start/stop reader. This moves the shared pieces into evals/cli/lib and points the evals at them. Eval behaviour isn't meant to change.

What moved

  • lib/psql.ts (new): queryDatabase(ctx, stack, sql, parse) runs one read-only query with psql -XtAc and hands stdout to a parser. Moved from investigate-database-001.
  • lib/migrations.ts:
    • readMigrationHistory queries supabase_migrations.schema_migrations for a set of versions and returns each one's statements.
    • sortMigrationsByHistory splits migrations into recorded, missing and mismatched using an eval-supplied match function.
    • describeMissingVersions and checkMigrationsRecorded are the shared report and check wrappers.
  • lib/cli-invocations.ts: readStackLifecycle returns the agent's last stack start/stop command and whether it left the stack stopped. Moved from build-database-006; 002 had a text-identical copy.

Evals touched

  • build-database-005-apply-schema-change
  • build-database-006-regenerate-types
  • investigate-database-001-slow-query
  • investigate-database-002-rls-policy-tests

The run-evals-changed label re-runs all four. Pass rates should match their last run on main.

Worth a look

  • ⚠️ History queries in 005 and 002 now run psql -XtAc. 005 previously used -tAc, and 002 used -X -A -t -q -v ON_ERROR_STOP=1 -c. For a single read-only select the output is the same; -X just skips any .psqlrc.
  • Not shared yet:
    • 002's psqlCommand, because its callers pipe scripts or pass extra flags.
    • A compareText one-liner that 001, 005 and 002 each define.
    • A few other inline psql runners whose flags differ.

🤖 Generated with Claude Code

…lpers in cli/lib

Moves the migration-history reader and sorter (build-database-005,
investigate-database-001), the psql runner (investigate-database-001) and
readStackLifecycle (build-database-006) into evals/cli/lib, and points the
evals at them. Pass/fail behaviour is unchanged; 005's history query now
runs psql with -X like the other callers.
…pers

Replace 002's inline migration-history query and parser with
readMigrationHistory and sortMigrationsByHistory, and drop its local
describeMissingVersions and stack-lifecycle reader in favour of the
lib versions. Its lifecycle test cases move to lib/cli-invocations.test.ts.
@Coly010 Coly010 added the run-evals-changed Add to a PR to refresh only the benchmark evals that have had changes label Oct 23, 2026
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
evals Ready Ready Preview Oct 24, 2026 1:35pm UTC

Request Review

@Coly010 Coly010 self-assigned this Oct 23, 2026
@Coly010
Coly010 marked this pull request as ready for review October 23, 2026 13:27
…eval-helpers

# Conflicts:
#	apps/web/src/data/cli-eval-results.json

This branch was successfully deployed

1 active deployment
Preview — 89fd7bfd Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-evals-changed Add to a PR to refresh only the benchmark evals that have had changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant