From 60a459cf70501f26e763c5dc01ea80f319fec262 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 12 Aug 2026 15:54:25 -0700 Subject: [PATCH] test(ambient-recall): pin a keyless gateway so delta/context_pack writes never fire a real embed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause of the shard-2 CI red after the 0.45.9.0 re-bump: adding this wave's test files reshuffled the weight-packed shards, moving ambient-recall.test.ts next to a neighbor that leaks CI's dummy OPENAI_API_KEY (sk-test-*) into the gateway singleton (the bunfig preload configures with env:{...process.env}, and a present-but-invalid key turns remember's keyless-degrade embed into a hard 401). The delta/context_pack tests exercise cursor + budget logic, not embedding quality, so this pins a keyless gateway (env:{}) in beforeAll — isAvailable('embedding') is false, writeSingleFact degrades (degraded_dedup) with no HTTP call, and the file is deterministic regardless of shard bin-packing. Verified: passes with OPENAI_API_KEY=sk-test-* set (the CI condition). Master's own comment in legacy-embedding-preload.ts already warns 'adding any test file reshuffles the mines'; this makes the file immune. Co-Authored-By: Claude Fable 5 --- test/ambient-recall.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/ambient-recall.test.ts b/test/ambient-recall.test.ts index 38d76e9e0..798a942e9 100644 --- a/test/ambient-recall.test.ts +++ b/test/ambient-recall.test.ts @@ -16,6 +16,7 @@ */ import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'bun:test'; import { PGLiteEngine } from '../src/core/pglite-engine.ts'; +import { configureGateway } from '../src/core/ai/gateway.ts'; import { operations } from '../src/core/operations.ts'; import { MEMORY_VERBS_VERSION, VERB_NAMES } from '../src/core/verbs.ts'; import { @@ -60,6 +61,17 @@ async function call( } beforeAll(async () => { + // Hermetic embedding: pin the gateway to a KEYLESS config (empty env) so + // `remember`'s fact-embed degrades gracefully (degraded_dedup) instead of + // firing a real OpenAI call. On CI the process carries a dummy + // OPENAI_API_KEY (sk-test-*) that a shard-neighbor can leak into the + // gateway singleton via a captured env (the bunfig preload configures with + // `env: {...process.env}`); a present-but-invalid key turns the keyless + // degrade into a hard 401. The delta/context_pack tests exercise + // cursor/budget logic, not embedding quality, so keyless is correct and + // makes them independent of shard bin-packing. Dimensions stay 1536 to + // match the preload's schema. + configureGateway({ embedding_model: 'openai:text-embedding-3-large', embedding_dimensions: 1536, env: {} }); engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema();