Repository navigation
ci: run the DB-backed query-budget pins against Postgres - #1374
Conversation
make test-go runs without SILO_TEST_DATABASE_URL, so every DB-backed test skips and go test reports the skip as a pass. The statement-count and query-plan pins that guard item detail, listings, metadata refresh, home sections, settings resolution and book scans have never run in CI, so a change that turns a pinned budget into an N+1 merges green. Add a Go DB pins job that migrates a fresh pgvector/pgvector:pg18 database with cmd/silo --migrate-only and runs the tests listed in scripts/ci/db-pins.txt through make test-db-pins. The runner in scripts/ci/dbpins reads go test -json and fails when a listed test is missing, skipped or failing, and on any skipped subtest: without a database, two of the pinned tests pass at the top level because only their subtests skip. The job is separate from go-test so it adds nothing to that job's time, and because the full schema needs pgvector, which go-test's image lacks. CONTRIBUTING.md lists the new target in the pre-PR gate. Refs #599. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
CONTRIBUTING.md listed make test-db-pins in the mandatory pre-PR gate, which would ask every contributor, even on a web-only change, for a migrated pgvector database. Move it out of the gate: CI runs it for every pull request, and contributors run it when they change database or query code or add a pin. Say how to create and migrate the database with the Compose defaults. Add TestPlayableTargetResolverProfileStateAvailabilityAndAccess to the list: leaf cards and a validated anchor hint must resolve without a watch-progress query. It passes on a freshly migrated database. The runner now drains go test's output if reading the event stream fails, so a go test still writing cannot block on a full pipe before Wait returns. Refs #599. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Problem
Related issue: #599 (Phase 3, narrowed to the query-budget pins)
Validation tasks: none (CI and a test runner only; no server, API or client behavior changes)
make test-goruns withoutSILO_TEST_DATABASE_URL, so every DB-backed test skips, andgo testreports a skip as a pass. That includes the tests that pin query budgets: statement counts for item detail, listing totals, card play targets, season and episode writes, refresh debt, home-section overlays, settings resolution and book scans, plus two index-plan checks for keyset pages. None of them runs in CI. A PR that turns the 9-statement season write into a per-episode N+1 merges green today; the budget holds only if someone runs it locally against a migrated database.A lane that sets the URL and trusts
go test's exit code would still leave two gaps. If the URL went missing, two of these tests would still pass at the top level, because only their subtests skip. Against an unmigrated schema, three skip on their own schema check, so a dropped or misdirected migrate step would switch those three off while CI stayed green.Approach
A new
Go DB pinsjob starts apgvector/pgvector:pg18service (the imagedocker-compose.ymlruns; the schema needsvector), migrates it withgo run ./cmd/silo/ --migrate-only, and runsmake test-db-pins.scripts/ci/db-pins.txtis the checked-in list: one./<package dir> <TestName>per line, 19 tests in 6 packages. Later perf PRs append their pins in the same change that sets the budget.scripts/ci/dbpinsrunsgo test -count=1 -json -run '^(name|name|...)$' <dirs>and reads the event stream. It fails when a listed test is missing, skipped, failing or unfinished, and when any subtest, or any other test the pattern matched, skips or fails. It prints the output of every test that did not pass.make test-db-pinsruns the same thing locally againstSILO_TEST_DATABASE_URL. It is not part of the mandatory pre-PR gate: CI runs it for every PR, and CONTRIBUTING.md asks contributors to run it when they change database or query code or add a pin, with the commands to create and migrate a scratch database on the Compose Postgres.make test-goparses the committed list, so a malformed edit fails the normal suite too.Alternatives considered:
make test-go. [bug] CI runs no PostgreSQL, so 171 DB-backed tests silently skip — 7 are broken on main and 2 packages are flaky #599 documents deterministic failures and flaky packages once a database is present. test: repair and isolate the DB-backed tests CI never runs #633 repairs and isolates those tests and deliberately adds no CI lane. The 19 pins pass on current main, so they can gate now without waiting. test: repair and isolate the DB-backed tests CI never runs #633 is complementary; this PR touches none of its files.go-test. That job'spostgres:17-alpineservice has no pgvector. A separate job also adds nothing togo-test's time.-runregex plus a grep forSKIP. A regex cannot report a renamed test; it just matches nothing. Checking only top-level results would miss the two tests whose subtests skip. Exact anchored names make a rename show up asMISSING.Not included: the tier-1 scenario executor under
SILO_SCENARIO_DATABASE_URLstill runs only locally, and whole DB-backed packages can join once #633 lands. Both are follow-ups.Before and after
go test -count=1 -jsonwith the same anchored-runlist on current main, noSILO_TEST_DATABASE_URL(whatmake test-godoes). After:make test-db-pinsagainst a freshly migrated pgvector Postgres 18 databasego testexit 0: 17 skip, 2 pass with all 13 of their subtests skippedmake test-db-pinsfails: 30 problems (17 skipped pins, 13 skipped subtests)make test-db-pinsagainst itMISSINGbounded statement count = 9, want 8make test-db-pinsruns with-p=4make test-db-pins7.0–10.5 s;--migrate-only4.6–6.0 scmd/silofor the migration. I have not measured the job on GitHub; a few minutes is an estimateValidation
Commands assume the repository root is the cwd. Every check below ran on the branch rebased onto current main.
make test-db-pinsagainst a freshly migratedpgvector/pgvector:pg18container configured like the CI service: all 19 pins passed in 5 of 5 consecutive runs withGOFLAGS=-p=4. They also pass against a reused local database that had been migrated before.pgvector/pgvector:pg18container with the Compose default credentials (throughdocker execand a different host port): the database was created and migrated, and all 19 pins passed.MISSING), an empty unmigrated database (12 fail, 3 skip, 4 pass) and the season-write budget lowered from 9 to 8 (bounded statement count = 9, want 8). The before case, re-run on current main with the same anchored list and no URL, exits 0 with 17 skips and 2 passes whose 13 subtests all skip.go test -count=1 ./scripts/ci/dbpins/: passes (list parsing, anchored arguments, event parsing, and skip, missing, subtest, unfinished and same-name-in-another-package cases)..github/workflows/ci.yml: no findings. The file also parses as YAML.make embed-stub,go build ./...,gofmt -l .(empty),go vet ./...andmake lint-changed(0 issues): pass.GOFLAGS=-p=6 make test-go: all 160 packages pass, includingscripts/ci/dbpins.make verify-settings-bindings-all verify-playback-fixtures verify-route-inventory verify-migration-ledger verify-scenario-catalogs verify-offline-routes verify-apiv2-openapi verify-apiv2-contract verify-apiv2-fixtures verify-local-pathsandgo test -count=1 -run '^TestCommittedArtifactMatchesRouter$' ./internal/apiv2/: pass.make migrate-validate, because the branch changes no files underweb/ormigrations/.No check failed, so there were no pre-existing failures to compare against main.
Risks
Go DB pinsto branch protection.TestLibraryCollectionContinuationDBleaves fivemedia_itemsrows per run in a reused local database. CI's database is new each run, so this does not affect the gate.cmd/silobuild.cache-name: db-pins), about 1 GB zstd-compressed when I built its work into empty caches locally, similar to thego-testentry. The repository's Actions caches already hold about 15 GB, so each commit adds eviction pressure on thego-test,go-lintandgo-verifycaches. Restoring an existing cache without saving would avoid that, but the shared setup action does not support it yet; that is a possible follow-up.Checklist
AI Disclosure
pgvector/pgvector:pg18container with the CI service settings, migrated it with the CI command, and re-ran the after, no-database, bogus-name, broken-budget and unmigrated-schema cases on the branch and the before case on current main. It also ran the pins against current main after applying main's newer migrations, confirmed the branch merges cleanly, and ran actionlint, the runner tests,go vet,gofmt,make lint-changedandmake verify-local-paths. Every number reproduced and it found no blockers or majors. Findings and resolutions: (1) listingmake test-db-pinsin the mandatory pre-PR gate would require a migrated pgvector database for every change, including web-only ones: moved out of the gate, with scoped guidance and database setup commands in CONTRIBUTING.md; (2) the Involvement and Adversarial review fields held placeholders: filled in here; (3) the new job adds a per-commit Actions cache: measured at about 1 GB and added to Risks, with restore-only caching left as a follow-up because the shared setup action does not support it; (4) the list missedTestPlayableTargetResolverProfileStateAvailabilityAndAccess, which pins that leaf cards and a validated anchor hint issue no watch-progress query: added, and it passes on a fresh database; (5) the Problem section said a broken migrate step would switch pins off while CI stayed green, but a failing migration fails the job: reworded to a dropped or misdirected migrate step; (6) the Validation section carried session detail about an unrelated handlers timing flake: shortened; (7) if reading the event stream failed, nothing drainedgo test's stdout andWaitcould block: the runner now drains the pipe before waiting.🤖 Generated with Claude Code