Skip to content

[BENCH-766] Model pricing in Postgres: admin-recorded rates with history - #600

Merged
cooperr1 merged 1 commit into
mainfrom
cooper/bench-766-pricing-postgres
Sep 4, 2026
Merged

[BENCH-766] Model pricing in Postgres: admin-recorded rates with history#600
cooperr1 merged 1 commit into
mainfrom
cooper/bench-766-pricing-postgres

Conversation

@cooperr1

@cooperr1 cooperr1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Linear: BENCH-766
Replaces #594: same change, rebased onto current main and cut from 2,549 to 1,517 lines.

What

  • benchmarks_v2.pricing_rates (migration 20260903_0027): append-only log seeded with the 61 rates verified against providers' public pricing pages. A correction appends and marks the earlier row superseded, a future date schedules a change, null unit + price records "no known public rate". Nothing updates or deletes a row.
  • GET /v1/pricing?as_of=: the rate in force on a day (default today) with earlier spans as history. Same roster and embargo filters as every other data endpoint.
  • GET / POST /v1/admin/pricing: coval-org only via require_coval_admin; each recording is stamped with the caller's Clerk user id and email.
  • A missing table or grant is a 503 on every pricing route, admin included. Downgrade refuses to drop the table once admin recordings exist.

Deploy

  1. Merge. Wait for the Switchboard runner release for this SHA (production-runner must equal it), then run the migration:
    gcloud run jobs execute benchmarks-runner --region=us-east1 --project=coval-benchmarks-prod --args="db,migrate"
  2. Grant: coval-ai/benchmark-infra#169 gives the api role SELECT + INSERT on pricing_rates. Plan and apply it only after the table exists.
  3. Then the web PR on cooper/bench-766-pricing-postgres in coval-ai/benchmarks-web.

Until the grant lands, GET /v1/pricing and the admin routes return 503. Nothing else is affected.

Verification

cd runner && uv run ruff check . && uv run ruff format --check . && uv run mypy --strict src tests && uv run pytest -q --disable-socket --allow-unix-socket --allow-hosts=127.0.0.1,::1 — 2006 passed. Live on the local stack with a mock Clerk issuer: 401 no token, 403 other org, 422 bad unit / float price / bad URL / two years out, 201 stamped recording, repeat 200, hidden model priced ahead of launch stays off the public read.

benchmarks_v2.pricing_rates is an append-only log seeded with the 61 rates
verified against providers' public pricing pages. GET /v1/pricing?as_of= serves
the rate in force on a day with earlier spans as history, under the same roster
and embargo filters as every other data endpoint. GET/POST /v1/admin/pricing
(coval org only) reads the whole log and appends recordings stamped with the
caller's Clerk id. A missing table or grant is a 503 on every route; the
downgrade refuses to drop the table once admin recordings exist.
@cooperr1
cooperr1 requested a review from a team as a code owner September 4, 2026 17:19
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: f0741bc0-57a6-46dc-8928-7715adc00def

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@cooperr1
cooperr1 added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 4ace3fa Sep 4, 2026
6 checks passed
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.

2 participants