Skip to content

feat(experiments): partition model experiment requests - #3445

Merged
markijbema merged 3 commits into
mainfrom
mark/partition-model-experiment-requests
May 25, 2026
Merged

markijbema merged 3 commits into
mainfrom
mark/partition-model-experiment-requests

Conversation

@markijbema

@markijbema markijbema commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Converts the empty model_experiment_request ledger introduced by feat(gateway): route and persist model experiments #3325 into a PostgreSQL monthly range-partitioned table so experiment attribution and future retention operations scale with preview traffic.
  • Uses the partition-compatible (usage_id, created_at) primary key while preserving request attribution foreign keys, constraints, and reporting/feedback indexes.
  • Adds monthly partition maintenance with a rolling three-month provisioned window, following the exa_usage_log pattern without creating fallback rows that need operational relocation.

Verification

  • Applied the new migration against a fresh local development PostgreSQL database and confirmed it completes successfully.

Visual Changes

N/A

Reviewer Notes

  • The migration intentionally drops and recreates model_experiment_request because the table is currently empty; there is no data-copy phase.
  • Drizzle models the new composite primary key, but does not represent PostgreSQL PARTITION BY or child partitions in its snapshot; the migration follows the existing exa_usage_log physical-DDL precedent.
  • If monthly provisioning is missed beyond the forward window, experiment attribution persistence fails visibly through its existing best-effort error reporting while billing remains unaffected; the table does not silently collect rows outside monthly partitions.

@markijbema
markijbema marked this pull request as ready for review May 25, 2026 07:36
Comment thread apps/web/src/app/api/cron/model-experiment-request-partition-maintenance/route.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The latest commit removes the default partition entirely (both the DDL and the monitoring check), eliminating any risk of stranded rows accumulating silently. Out-of-window inserts now fail immediately and visibly. No issues found across all reviewed files.

Files Reviewed (6 files)
  • apps/web/src/app/api/cron/model-experiment-request-partition-maintenance/route.ts — no issues (default-partition check removed cleanly; unused captureMessage import also removed)
  • packages/db/src/migrations/0142_dashing_blue_marvel.sql — no issues (default partition DDL removed)
  • apps/web/vercel.json — no issues
  • packages/db/src/migrations/meta/0142_snapshot.json — no issues (generated)
  • packages/db/src/migrations/meta/_journal.json — no issues (generated)
  • packages/db/src/schema.ts — no issues

Reviewed by claude-sonnet-4.6 · 191,163 tokens

Review guidance: REVIEW.md from base branch main

@markijbema
markijbema merged commit 89be2a2 into main May 25, 2026
48 checks passed
@markijbema
markijbema deleted the mark/partition-model-experiment-requests branch May 25, 2026 10:13
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