mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-27 22:15:33 +00:00
test(doctor): pin embedding dims in hidden-by-search-policy — kill the shard-order 1280/1536 flake (#2801)
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 <p3ob7o@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Paolo Belcastro
Claude Fable 5
parent
659b6e9b4d
commit
1e1b9a9441
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user