From 1e1b9a944147ae415959c69f3598640c848be197 Mon Sep 17 00:00:00 2001 From: Paolo Belcastro <1436372+p3ob7o@users.noreply.github.com> Date: Fri, 17 Jul 2026 01:26:46 +0200 Subject: [PATCH] =?UTF-8?q?test(doctor):=20pin=20embedding=20dims=20in=20h?= =?UTF-8?q?idden-by-search-policy=20=E2=80=94=20kill=20the=20shard-order?= =?UTF-8?q?=201280/1536=20flake=20(#2801)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit doctor-hidden-by-search-policy.test.ts hardcodes Float32Array(1536) vectors (basisEmbedding) but lets initSchema size its vector columns from process-global gateway state (getEmbeddingDimensions(), default 1280). Whether the file passes depends on which test files run before it in the shard; adding test files to the repo reshuffles the weight-packed shards, so unrelated PRs trip it (seen on #2800 CI, test (1): every upsertChunks died with 'expected 1280 dimensions, not 1536'). Same fix + rationale as engine-find-trajectory.test.ts and cosine-rescore-column.test.ts, which document this exact class: configureGateway(1536) in beforeAll BEFORE initSchema, resetGateway in afterAll. The suite is now self-sufficient regardless of predecessor state. Not reproducible outside CI's exact shard packing; the pin removes the order-dependence either way. Co-authored-by: Paolo Belcastro Co-authored-by: Claude Fable 5 --- test/doctor-hidden-by-search-policy.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 () => {