test(server): pin migration invariants + embedding-model literal drift guard#1138
Conversation
…t guard Stability-audit follow-up. Adds CI guards so two recently-changed schema invariants can't silently regress in a future migration: - migration-invariants.test.ts: asserts the per-user pending oauth_account unique index from #1121 exists (and the old org-wide index is gone), plus a functional contract test — a user's second parallel pending OAuth flow collides while a distinct user's is allowed. Also asserts event_embeddings carries the embedding_model stamp column (#1069/#1080). - embedding-model-literal.test.ts: the legacy-stamp backfill migration hard-codes the model literal; this fails if it ever drifts from DEFAULT_EMBEDDING_MODEL, which would silently re-open the full-corpus recall regression. Exports DEFAULT_EMBEDDING_MODEL for the assertion.
|
Warning Review limit reached
More reviews will be available in 31 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Follow-up to the 2-week stability audit. Adds two additive CI guards (no prod-code behavior change) so recently-changed, load-bearing invariants can't silently regress in a future migration — directly serving the "reliable and consistent tests" goal.
migration-invariants.test.ts(integration, runs the real baseline→latest chain the harness already applies):oauth_accountunique index from fix(server,db): per-user pending oauth_account uniqueness + clean conflict errors #1121 exists and the old org-wideauth_profiles_pending_uniqueis gonePendingAuthConflictError) while a distinct user's is allowed — the actual fix(server,db): per-user pending oauth_account uniqueness + clean conflict errors #1121 guarantee, not just the DDLevent_embeddings.embedding_modelstamp column exists (fix(embeddings): version-stamp embeddings and batch the sync embed path #1069/fix(embeddings): stamp legacy embedding_model + stop liveness probe killing the embeddings service #1080)embedding-model-literal.test.ts(unit): the legacy-stamp backfill migration hard-codes the model literal (SQL can't import TS). This fails if it ever drifts fromDEFAULT_EMBEDDING_MODEL, which would silently re-open the full-corpus recall regression. ExportsDEFAULT_EMBEDDING_MODELfor the assertion.Audit context
The #1121 "dropped pending-uniqueness for browser_session" concern turned out to be a false positive on closer reading:
browser_sessionrows are created withconnector_key = NULL(manage_auth_profiles.ts:696), and the old dropped index was a standard unique index — Postgres treats NULLs as distinct, so it never enforced uniqueness for that kind.oauth_account(the only reachably-pending kind with non-null keys) is correctly covered. So no code guard was added; the real contract is pinned by the functional test instead.Test plan
vitest runboth files green (5 integration + 1 unit) against embedded PostgresDEFAULT_EMBEDDING_MODELmakes the literal guard fail; reverting restores greentsc --noEmitclean (server); pre-commit biome + typecheck passNeed help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.