From eabede8b9d99a202d62472356a98a03bedcb4bae Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Thu, 23 Jul 2026 15:44:32 -0700 Subject: [PATCH] test: Lane A.7 pins gateway-resolved chunk model, not compiled default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #2846 changed upsertChunks' fallback from DEFAULT_EMBEDDING_MODEL to the gateway-resolved runtime model. Lane A.7 still pinned the old fallback, and the test preload (test/helpers/legacy-embedding-preload.ts) pins the gateway to openai:text-embedding-3-large for every test process — so the original #2846 landing failed this test deterministically and got batch- reverted. The test now asserts the resolved model (the intended #2846 semantics) while keeping the CDX2-4 bare-literal regression guard. Co-Authored-By: Claude Fable 5 --- test/v0_37_gap_fill.serial.test.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/v0_37_gap_fill.serial.test.ts b/test/v0_37_gap_fill.serial.test.ts index c1f275394..022256d21 100644 --- a/test/v0_37_gap_fill.serial.test.ts +++ b/test/v0_37_gap_fill.serial.test.ts @@ -30,11 +30,15 @@ import { configureGateway, resetGateway, __setEmbedTransportForTests } from '../ import { withEnv } from './helpers/with-env.ts'; // ───────────────────────────────────────────────────────────────────── -// Lane A.7 — Chunk-row INSERT model default tracks defaults.ts constant -// (not stale OpenAI literal). Pre-fix `chunk.model || 'text-embedding-3-large'` -// in both engines; post-fix `chunk.model || DEFAULT_EMBEDDING_MODEL`. +// Lane A.7 — Chunk-row INSERT model default tracks the gateway-resolved +// model (not a stale OpenAI literal, not the compile-time constant). +// Pre-fix `chunk.model || 'text-embedding-3-large'` in both engines; +// v0.37 fix `chunk.model || DEFAULT_EMBEDDING_MODEL`; #2846 tightened it +// to the gateway's runtime model so provenance matches the vector's +// actual producer (falls back to DEFAULT_EMBEDDING_MODEL only when the +// gateway is unconfigured). // ───────────────────────────────────────────────────────────────────── -describe('Lane A.7 — chunk-row INSERT default tracks ai/defaults.ts constant', () => { +describe('Lane A.7 — chunk-row INSERT default tracks the gateway-resolved model', () => { let engine: PGLiteEngine; beforeAll(async () => { @@ -47,8 +51,11 @@ describe('Lane A.7 — chunk-row INSERT default tracks ai/defaults.ts constant', await engine.disconnect(); }); - test('upsertChunks without explicit model: row stores DEFAULT_EMBEDDING_MODEL', async () => { - const { DEFAULT_EMBEDDING_MODEL } = await import('../src/core/ai/defaults.ts'); + test('upsertChunks without explicit model: row stores the gateway-resolved model', async () => { + // The test preload (test/helpers/legacy-embedding-preload.ts) pins the + // gateway to 'openai:text-embedding-3-large', so that's what the write + // site must stamp — NOT the compile-time DEFAULT_EMBEDDING_MODEL (#2846). + const { getEmbeddingModel } = await import('../src/core/ai/gateway.ts'); await engine.putPage('test/a7', { type: 'note', title: 'A.7', compiled_truth: 'hello' }); await engine.upsertChunks('test/a7', [ { chunk_index: 0, chunk_text: 'hello', chunk_source: 'compiled_truth' }, @@ -57,9 +64,9 @@ describe('Lane A.7 — chunk-row INSERT default tracks ai/defaults.ts constant', const rows = await engine.executeRaw<{ model: string }>( `SELECT model FROM content_chunks WHERE chunk_index = 0 LIMIT 1`, ); - expect(rows[0]?.model).toBe(DEFAULT_EMBEDDING_MODEL); + expect(rows[0]?.model).toBe(getEmbeddingModel()); // CDX2-4 regression: would have been 'text-embedding-3-large' - // (a literal pre-fix; production write site that was never tested). + // (a bare literal pre-fix; provider-prefixed form is required). expect(rows[0]?.model).not.toBe('text-embedding-3-large'); }); });