From 1b6606c7bbda7a6e93971ecde4dbf5eca3891fc8 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 24 Jul 2026 11:02:00 -0700 Subject: [PATCH] =?UTF-8?q?test(facts):=20pin=20embedding=20dims=20in=20fa?= =?UTF-8?q?cts-engine=20=E2=80=94=20kill=20the=20shard-order=201280/1536?= =?UTF-8?q?=20flake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit facts-engine.test.ts hardcodes Float32Array(1536) vectors (vec()) 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/frontmatter-validate-slug-565.test.ts reshuffled the weight-packed shards and tripped it on this PR's CI (test (1): 'expected 1280 dimensions, not 1536' in findCandidateDuplicates cosine ordering). Same fix + rationale as doctor-hidden-by-search-policy.test.ts (#2801), engine-find-trajectory.test.ts and cosine-rescore-column.test.ts: configureGateway(1536) in beforeAll BEFORE initSchema, resetGateway in afterAll. Co-Authored-By: Claude Fable 5 --- test/facts-engine.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/facts-engine.test.ts b/test/facts-engine.test.ts index 32a5b03a4..74ea709f6 100644 --- a/test/facts-engine.test.ts +++ b/test/facts-engine.test.ts @@ -13,10 +13,25 @@ import { describe, test, expect, beforeAll, afterAll } from 'bun:test'; import { PGLiteEngine } from '../src/core/pglite-engine.ts'; +import { configureGateway, resetGateway } from '../src/core/ai/gateway.ts'; let engine: PGLiteEngine; beforeAll(async () => { + // Pin the embedding dim to 1536 BEFORE initSchema. vec() hardcodes + // Float32Array(1536), but initSchema sizes vector columns from + // process-global gateway state (getEmbeddingDimensions(), default 1280). + // Whether this file passes therefore 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 ("expected 1280 + // dimensions, not 1536"). Same fix + rationale as + // doctor-hidden-by-search-policy.test.ts (#2801), + // engine-find-trajectory.test.ts and cosine-rescore-column.test.ts. + configureGateway({ + embedding_model: 'openai:text-embedding-3-large', + embedding_dimensions: 1536, + env: { OPENAI_API_KEY: 'sk-test-facts-engine' }, + }); engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); @@ -24,6 +39,7 @@ beforeAll(async () => { afterAll(async () => { await engine.disconnect(); + resetGateway(); }); const vec = (...vals: number[]): Float32Array => {