Skip to content

refactor(web): remove Snowflake-backed public leaderboard endpoints - #5233

Merged
RSO merged 1 commit into
mainfrom
kill-leaderboard-model-us
Aug 12, 2026
Merged

refactor(web): remove Snowflake-backed public leaderboard endpoints#5233
RSO merged 1 commit into
mainfrom
kill-leaderboard-model-us

Conversation

@RSO

@RSO RSO commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What

Deletes the three public leaderboard API endpoints that read from Snowflake, plus the support code that existed only to serve them.

The Snowflake connection these endpoints depend on is gone, so they currently return 503 Snowflake is not configured (or 502 on query failure) instead of data. They are dead weight and a source of Sentry noise.

Removed

Path Note
apps/web/src/app/api/public/leaderboard-model-usage/route.ts
apps/web/src/app/api/public/leaderboard-model-provider-usage/route.ts
apps/web/src/app/api/public/leaderboard-provider-race/route.ts + route.test.ts
apps/web/src/lib/public-snowflake-report.ts imported only by the three routes above
apps/web/src/lib/public-inference-provider.ts imported only by the model-provider route
3 × public-api:leaderboard-* keys in apps/web/src/lib/redis-keys.ts no other consumers

661 deletions, 0 insertions.

Deliberately kept

  • apps/web/src/lib/snowflake.ts and the 9 SNOWFLAKE_* env vars — apps/web/src/routers/usage-analytics-router.ts is still a consumer, so this stays until that migration lands.
  • api/public/oss-sponsors — Postgres-backed via @/lib/drizzle, unrelated.
  • services/kiloclaw-billing/src/snowflake.ts — a separate, independent Snowflake client. Untouched.
  • Everything matching model-usage in the free/promoted-model-usage admin feature — unrelated naming collision.

Notes

  • Nothing in this monorepo called these endpoints. They are public with Access-Control-Allow-Origin: *, so the consumer was an external property; confirmed no longer in use.
  • Orphaned Redis entries expire on their own within the existing 1h TTL, so no cleanup code is needed.
  • No changes required in vercel.json (no cron warmed these keys — population was lazy-on-request), ENVIRONMENT.md, middleware, tRPC routers, mobile, or extension.

Verification

  • scripts/typecheck-all.sh --changes-only → clean (this always runs tsgo --noEmit -p apps/web/tsconfig.json)
  • pnpm lint in apps/web → 0 warnings, 0 errors across 3582 files
  • pnpm format:changed + git diff --check → clean
  • jest src/lib/redis-keys.test.ts src/app/api/public/oss-sponsors/route.test.ts → 10/10 passing
  • Repo-wide grep for all five deleted identifiers/paths → zero remaining references

Follow-ups (not in this PR)

  1. Once /usage analytics is fully off Snowflake (cf. feat(web): serve /usage analytics from Postgres replica #5223 / reverted in Revert "feat(web): serve /usage analytics from Postgres replica" #5228), lib/snowflake.ts and the 9 SNOWFLAKE_* vars can be removed from apps/web entirely — this PR reduces that file to a single consumer.
  2. Those 9 SNOWFLAKE_* vars read by apps/web/src/lib/snowflake.ts are undocumented in ENVIRONMENT.md (only SNOWFLAKE_MAX_POLL_ATTEMPTS is listed, pointing at the billing service) and absent from scripts/web-env.

The Snowflake connection these endpoints depend on is gone, so all three
public leaderboard reports return 503/502 rather than data.

Removes the endpoints and the support code that only existed for them:

- api/public/leaderboard-model-usage
- api/public/leaderboard-model-provider-usage
- api/public/leaderboard-provider-race
- lib/public-snowflake-report.ts (imported only by the three routes)
- lib/public-inference-provider.ts (imported only by the model-provider route)
- the three public-api:leaderboard-* keys in lib/redis-keys.ts

lib/snowflake.ts stays, since routers/usage-analytics-router.ts is still a
consumer. api/public/oss-sponsors is Postgres-backed and unaffected, as is
the separate Snowflake client in services/kiloclaw-billing.

Orphaned Redis entries expire on their own within the existing 1h TTL, so
no cleanup is required.
@RSO
RSO enabled auto-merge (squash) August 12, 2026 15:34
@kilo-code-bot

kilo-code-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Clean deletion-only removal of three dead Snowflake-backed public leaderboard endpoints and their sole-consumer support code; verified no dangling references remain to any deleted route, module, or Redis key.

Verification performed

  • Repo-wide search confirms zero remaining references to LEADERBOARD_MODEL_PROVIDER_USAGE_REDIS_KEY, LEADERBOARD_MODEL_USAGE_REDIS_KEY, LEADERBOARD_PROVIDER_RACE_REDIS_KEY, public-snowflake-report, public-inference-provider, and the three api/public/leaderboard-* route paths.
  • lib/cached-fetch.ts correctly retained — still consumed by ai-gateway, model-stats, blacklist-domains, and openrouter providers code.
  • lib/snowflake.ts correctly retained — routers/usage-analytics-router.ts still imports it, matching the PR description's stated follow-up.
  • redis-keys.test.ts does not reference the removed keys, and no vercel.json / next.config / middleware / ENVIRONMENT.md references to the removed routes exist.
  • Deletion-only diff (661 deletions, 0 insertions) introduces no new code paths, so no new memory-leak or runtime-risk surface is added; the removed module-level in-process caches go away with the routes.
Files Reviewed (7 files)
  • apps/web/src/app/api/public/leaderboard-model-provider-usage/route.ts (deleted)
  • apps/web/src/app/api/public/leaderboard-model-usage/route.ts (deleted)
  • apps/web/src/app/api/public/leaderboard-provider-race/route.test.ts (deleted)
  • apps/web/src/app/api/public/leaderboard-provider-race/route.ts (deleted)
  • apps/web/src/lib/public-inference-provider.ts (deleted)
  • apps/web/src/lib/public-snowflake-report.ts (deleted)
  • apps/web/src/lib/redis-keys.ts (3 keys removed)

Reviewed by kimi-k3 · Input: 94.7K · Output: 3.6K · Cached: 280.5K

Review guidance: REVIEW.md from base branch main

@RSO
RSO merged commit 6c5c850 into main Aug 12, 2026
13 checks passed
@RSO
RSO deleted the kill-leaderboard-model-us branch August 12, 2026 15:45
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