diff --git a/test/doctor-hidden-by-search-policy.test.ts b/test/doctor-hidden-by-search-policy.test.ts index 47b28fb0f..b2ed5d4b6 100644 --- a/test/doctor-hidden-by-search-policy.test.ts +++ b/test/doctor-hidden-by-search-policy.test.ts @@ -14,6 +14,7 @@ import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'bun:test'; import { PGLiteEngine } from '../src/core/pglite-engine.ts'; +import { configureGateway, resetGateway } from '../src/core/ai/gateway.ts'; import { resetPgliteState } from './helpers/reset-pglite.ts'; import { withEnv } from './helpers/with-env.ts'; import { checkHiddenBySearchPolicy } from '../src/commands/doctor.ts'; @@ -58,6 +59,23 @@ async function seed( } beforeAll(async () => { + // Pin the embedding dim to 1536 BEFORE initSchema. basisEmbedding() + // hardcodes Float32Array(1536) vectors, but initSchema sizes vector + // columns from process-global gateway state (getEmbeddingDimensions(), + // default 1280 = zeroentropyai). Whether this file passes therefore + // depended on which test files happened to run before it in the shard: a + // predecessor that leaves the gateway configured without dims (or a bare + // CI env) yields vector(1280) and every upsertChunks here dies with + // "expected 1280 dimensions, not 1536". Adding test files to the repo + // reshuffles the weight-packed shards, so unrelated PRs trip it (seen on + // #2800 CI, test (1)). Same fix + rationale as + // engine-find-trajectory.test.ts and cosine-rescore-column.test.ts, which + // document this exact class. + configureGateway({ + embedding_model: 'openai:text-embedding-3-large', + embedding_dimensions: 1536, + env: { OPENAI_API_KEY: 'sk-test-hidden-by-search-policy' }, + }); engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); @@ -65,6 +83,7 @@ beforeAll(async () => { afterAll(async () => { await engine.disconnect(); + resetGateway(); }); beforeEach(async () => {