Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(search): apply embedding_query_prefix at every query embed outside hybrid (#3783)
garrytan7833f7f40419
diff --git a/src/commands/search-diagnose.ts b/src/commands/search-diagnose.tsindex e81e1346c1..d21ec899c6 100644--- a/src/commands/search-diagnose.ts+++ b/src/commands/search-diagnose.ts@@ -59,7 +59,8 @@ export async function runSearchDiagnose(engine: BrainEngine, args: string[]): Pr// Vector layer (skip if no embedding provider).let vector: LayerProbe;- const { isAvailable, embedQuery } = await import('../core/ai/gateway.ts');+ const { isAvailable } = await import('../core/ai/gateway.ts');+ const { embedQueryWithPrefix } = await import('../core/search/query-prefix.ts');const { factEmbeddingDisabled } = await import('../core/embedding-disabled.ts');if (await factEmbeddingDisabled(engine)) {vector = { rank: null, score: null, top_slug: null, note: 'skipped — embeddings are off on this brain by choice (embedding_disabled); no query text was sent to a provider. `gbrain doctor --json` names the enable command if the user wants semantic search.' };@@ -67,7 +68,7 @@ export async function runSearchDiagnose(engine: BrainEngine, args: string[]): Prvector = { rank: null, score: null, top_slug: null, note: 'skipped — no embedding provider configured' };} else {try {- const qvec = await embedQuery(query);+ const qvec = await embedQueryWithPrefix(engine, query);const vec = await engine.searchVector(qvec, { limit, ...scope });vector = {rank: rankOf(vec.map(r => r.slug), target),diff --git a/src/commands/takes.ts b/src/commands/takes.tsindex c795297235..39661df8c4 100644--- a/src/commands/takes.ts+++ b/src/commands/takes.ts@@ -30,7 +30,7 @@ import { resolveOwnerHolder } from '../core/owner-holder.ts';import { embedStaleTakes } from '../core/embed-takes.ts';import { assertBrainEmbeddingEnabled } from '../core/embedding-dim-check.ts';import { loadConfig } from '../core/config.ts';-import { embedQuery } from '../core/embedding.ts';+import { embedQueryWithPrefix } from '../core/search/query-prefix.ts';import {listPendingProposals,acceptProposal,@@ -184,7 +184,7 @@ async function cmdSearch(engine: BrainEngine, args: string[]): Promise<void> {await assertBrainEmbeddingEnabled(engine, loadConfig());const { validateEmbeddingCreds } = await import('../core/embed-preflight.ts');validateEmbeddingCreds();- const queryEmbedding = await embedQuery(query);+ const queryEmbedding = await embedQueryWithPrefix(engine, query);hits = await engine.searchTakesVector(queryEmbedding, { limit });} else {hits = await engine.searchTakes(query, { limit });diff --git a/src/commands/think.ts b/src/commands/think.tsindex d3e9650f21..590920654a 100644--- a/src/commands/think.ts+++ b/src/commands/think.ts@@ -10,7 +10,7 @@ import { runThink, persistSynthesis, stripGapsSection } from '../core/think/indeimport { loadConfig, isThinClient } from '../core/config.ts';import { callRemoteTool, unpackToolResult } from '../core/mcp-client.ts';import { canonicalLookup } from '../core/model-pricing.ts';-import { embedQuery } from '../core/embedding.ts';+import { embedQueryWithPrefix } from '../core/search/query-prefix.ts';import { keylessThinkNotice } from '../core/interop-notices.ts';import { applyCliOpNotices, captureOpNotice } from '../cli/op-notices.ts';@@ -197,7 +197,7 @@ prints what would have been the input (exit 0).// injection degrades to visibility='world' rows.remote: false,// #3734: activate takes' vector retrieval arm for CLI think.- embedQuestion: (q) => embedQuery(q),+ embedQuestion: (q) => embedQueryWithPrefix(engine, q),// #4508/#4652: thread the validated scope (RunThinkOpts.sourceId /// allowedSources — the array wins inside runGather, same as search)....(sourceId ? { sourceId } : {}),diff --git a/src/core/brainstorm/orchestrator.ts b/src/core/brainstorm/orchestrator.tsindex 90e423ea32..5dc71182b4 100644--- a/src/core/brainstorm/orchestrator.ts+++ b/src/core/brainstorm/orchestrator.ts@@ -32,7 +32,8 @@*/import type { BrainEngine } from '../engine.ts';-import { chat as defaultChat, embedQuery, type ChatResult, type ChatOpts } from '../ai/gateway.ts';+import { chat as defaultChat, type ChatResult, type ChatOpts } from '../ai/gateway.ts';+import { embedQueryWithPrefix } from '../search/query-prefix.ts';import { hybridSearch, hybridSearchCached } from '../search/hybrid.ts';import { INTERNAL_BREADTH_SEARCH_OPTS } from '../search/internal-breadth.ts';import { fetchFar, type CloseRef, type FarPage } from './domain-bank.ts';@@ -661,7 +662,7 @@ async function _runBrainstormInner(const profile = opts.profile ?? BRAINSTORM_PROFILE;const stderr = opts.stderrWrite ?? ((s: string) => { process.stderr.write(s); });const chat = opts.chatFn ?? defaultChat;- const embedFn = opts.embedQueryFn ?? embedQuery;+ const embedFn = opts.embedQueryFn ?? ((q: string) => embedQueryWithPrefix(engine, q));// ---- Phase 0: cost preview + TTY grace ----const { aborted, estimate } = await previewCostAndWait({diff --git a/src/core/cycle/auto-think.ts b/src/core/cycle/auto-think.tsindex 3e66e71735..fc6ce71f97 100644--- a/src/core/cycle/auto-think.ts+++ b/src/core/cycle/auto-think.ts@@ -17,7 +17,7 @@import type { BrainEngine } from '../engine.ts';import { runThink, persistSynthesis, type ThinkLLMClient } from '../think/index.ts';import { resolveModel } from '../model-config.ts';-import { embedQuery } from '../embedding.ts';+import { embedQueryWithPrefix } from '../search/query-prefix.ts';import { BudgetMeter, loadAllowUnpriced, loadPricingOverrides, parseBudgetUsd } from './budget-meter.ts';/**@@ -168,7 +168,7 @@ export async function runPhaseAutoThink(const result = await runThink(engine, {question: q,// #3734: auto-think uses same vector takes retrieval as interactive think.- embedQuestion: (text) => embedQuery(text),+ embedQuestion: (text) => embedQueryWithPrefix(engine, text),save: config.autoCommit,client: opts.client,model: modelId,diff --git a/src/core/ops/search.ts b/src/core/ops/search.tsindex 453798c191..f9a88adeef 100644--- a/src/core/ops/search.ts+++ b/src/core/ops/search.ts@@ -1154,7 +1154,7 @@ const query: Operation = {if (thinkCfg === 'true' && ctx.remote === false) {try {const { runThink } = await import('../think/index.ts');- const { embedQuery } = await import('../embedding.ts');+ const { embedQueryWithPrefix } = await import('../search/query-prefix.ts');const thinkScope = thinkScopeFromQueryScope(querySourceScope);const t = await runThink(ctx.engine, {question: queryText,@@ -1163,7 +1163,7 @@ const query: Operation = {...thinkScope,remote: false,// #3734: activate takes' vector retrieval arm for CRAG think escalation.- embedQuestion: (q) => embedQuery(q),+ embedQuestion: (q) => embedQueryWithPrefix(ctx.engine, q),});crag.think = {answer: t.answer,diff --git a/src/core/ops/takes.ts b/src/core/ops/takes.tsindex 1a27537df9..7d37a7633c 100644--- a/src/core/ops/takes.ts+++ b/src/core/ops/takes.ts@@ -19,7 +19,7 @@ import {enforceClientSlugFence,validatePageSlug,} from './context.ts';-import { embedQuery } from '../embedding.ts';+import { embedQueryWithPrefix } from '../search/query-prefix.ts';import { ALL_SOURCES } from '../source-id.ts';import { privatePagesFilterFragment } from '../search/private-visibility.ts';@@ -283,7 +283,7 @@ const think: Operation = {const result = await runThink(ctx.engine, {question: String(p.question),// #3734: MCP think must populate the question vector for takes retrieval.- embedQuestion: (q) => embedQuery(q),+ embedQuestion: (q) => embedQueryWithPrefix(ctx.engine, q),anchor: p.anchor ? String(p.anchor) : undefined,rounds: typeof p.rounds === 'number' ? (p.rounds as number) : undefined,save: safeSave,diff --git a/src/core/search/eval.ts b/src/core/search/eval.tsindex 6e4959a2f9..0983b58f3f 100644--- a/src/core/search/eval.ts+++ b/src/core/search/eval.ts@@ -10,7 +10,7 @@*/import type { BrainEngine } from '../engine.ts';-import { embedQuery } from '../embedding.ts';+import { embedQueryWithPrefix } from './query-prefix.ts';import { loadConfig, loadConfigWithEngine } from '../config.ts';import { resolveEmbeddingColumn } from './embedding-column.ts';import { hybridSearch } from './hybrid.ts';@@ -248,7 +248,7 @@ async function runQuery(const { assertBrainEmbeddingEnabled } = await import('../embedding-dim-check.ts');await assertBrainEmbeddingEnabled(engine, cfg);const column = resolveEmbeddingColumn(undefined, cfg ?? { engine: 'pglite' });- const embedding = await embedQuery(query, column.embeddingModel+ const embedding = await embedQueryWithPrefix(engine, query, column.embeddingModel? { embeddingModel: column.embeddingModel, dimensions: column.dimensions }: undefined);const results = await engine.searchVector(embedding, { limit, embeddingColumn: column });diff --git a/src/core/search/query-prefix.ts b/src/core/search/query-prefix.tsindex 9b43704159..1955223133 100644--- a/src/core/search/query-prefix.ts+++ b/src/core/search/query-prefix.ts@@ -8,6 +8,7 @@* There is no default: nothing is guessed from the model id at query time.*/import type { BrainEngine } from '../engine.ts';+import { embedQuery } from '../embedding.ts';export const EMBEDDING_QUERY_PREFIX_KEY = 'embedding_query_prefix';@@ -20,6 +21,24 @@ export async function loadEmbeddingQueryPrefix(engine: BrainEngine): Promise<str}}+/**+ * #3783: the query-side embedding for callers outside hybrid search (think,+ * takes, CRAG escalation, auto-think, search diagnose, eval's vector+ * baseline). It loads the selected brain's prefix and embeds with the+ * unbounded `embedQuery`, so each call site keeps its own deadline behavior;+ * hybrid search keeps its bounded `embedQueryBounded`. Every query embed+ * outside these two paths is a bug the call-site guard+ * (test/query-embed-call-sites.test.ts) refuses.+ */+export async function embedQueryWithPrefix(+ engine: BrainEngine,+ text: string,+ opts?: { embeddingModel?: string; dimensions?: number },+): Promise<Float32Array> {+ const queryPrefix = await loadEmbeddingQueryPrefix(engine);+ return embedQuery(text, { ...(opts ?? {}), ...(queryPrefix ? { queryPrefix } : {}) });+}+/** Model families whose model cards ask for a query instruction, with the documented value. */const QUERY_PREFIX_FAMILIES: ReadonlyArray<{ family: string; pattern: RegExp; value: string }> = [{ family: 'Qwen3-Embedding', pattern: /qwen3[-_]?embed/,diff --git a/src/core/verbs.ts b/src/core/verbs.tsindex 81ed2f7c15..8622d7cf0d 100644--- a/src/core/verbs.ts+++ b/src/core/verbs.ts@@ -316,7 +316,7 @@ const synthesize: Operation = {}const scope = sourceScopeOpts(ctx);const { runThink } = await import('./think/index.ts');- const { embedQuery } = await import('./embedding.ts');+ const { embedQueryWithPrefix } = await import('./search/query-prefix.ts');// Remote-safe delegation: save/take are NEVER offered through this verb,// for any caller — the verb is a pure read.const result = await runThink(ctx.engine, {@@ -329,7 +329,7 @@ const synthesize: Operation = {// Fail-closed: only a context that explicitly says local gets local.remote: ctx.remote !== false,// #3734: activate takes' vector retrieval arm for the synthesize verb.- embedQuestion: (q) => embedQuery(q),+ embedQuestion: (q) => embedQueryWithPrefix(ctx.engine, q),});// [c10] runThink degrades gracefully to a no-LLM stub RESULT; the protocoldiff --git a/test/query-embed-call-sites.test.ts b/test/query-embed-call-sites.test.tsnew file mode 100644index 0000000000..c3c8a7ae67--- /dev/null+++ b/test/query-embed-call-sites.test.ts@@ -0,0 +1,89 @@+/**+ * #3783 call-site guard: a query-side embedding outside the two prefix-aware+ * paths skips the brain's `embedding_query_prefix`. The prefix-aware paths+ * are `embedQueryWithPrefix` (search/query-prefix.ts: loads the prefix, then+ * the unbounded `embedQuery`) and hybrid search's bounded+ * `embedQueryBounded`, which receives the prefix hybrid already loaded.+ *+ * This walks the TypeScript AST of src/** and lists every expression-position+ * reference to `embedQuery` / `embedQueryBounded` (calls and function values+ * such as `opts.fn ?? embedQuery`; imports, declarations and type positions+ * are not uses). A file not in ALLOWED fails: route its query embed through+ * `embedQueryWithPrefix(engine, text)`, or add an ALLOWED row with the reason+ * the prefix does not apply and the exact use count.+ */+import { describe, expect, test } from 'bun:test';+import { readdirSync, readFileSync, statSync } from 'node:fs';+import { join, relative, sep } from 'node:path';+import ts from 'typescript';++const ROOT = join(import.meta.dir, '..');+const NAMES = new Set(['embedQuery', 'embedQueryBounded']);++/** file → [uses, why the brain prefix is applied or does not apply there]. */+const ALLOWED: Record<string, [number, string]> = {+ 'src/core/search/query-prefix.ts': [1, 'embedQueryWithPrefix itself: loads the brain prefix and passes it'],+ 'src/core/search/hybrid.ts': [2, 'embedQueryBounded (forwards its embedOpts, prefix included) and the cache-lookup embed, which passes the prefix hybrid loaded'],+ 'src/core/search/hybrid/arms.ts': [1, "the vector arm's embedOneQuery passes opts._queryPrefix in embedOpts"],+ 'src/core/facts/question-recall.ts': [1, 'recall --question passes loadEmbeddingQueryPrefix in the bounded embed'],+ 'src/core/embedding-migration.ts': [1, "the migration's verify smoke embeds a stored chunk under the target model, whose prefix the operator has not set yet; the brain's current prefix belongs to the model being replaced"],+ 'src/eval/longmemeval/diagnostics.ts': [2, 'LongMemEval runs against an isolated in-memory brain per question, which has no embedding_query_prefix'],+};++function sourceFiles(dir: string, out: string[] = []): string[] {+ for (const name of readdirSync(dir)) {+ const path = join(dir, name);+ if (statSync(path).isDirectory()) sourceFiles(path, out);+ else if (name.endsWith('.ts') && !name.endsWith('.d.ts')) out.push(path);+ }+ return out;+}++/** Expression-position references: not an import/export specifier, a declaration name, a property name or a type. */+function isUse(id: ts.Identifier): boolean {+ const parent = id.parent;+ if (ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isExportSpecifier(parent) || ts.isNamespaceImport(parent) || ts.isBindingElement(parent)) return false;+ if ((ts.isFunctionDeclaration(parent) || ts.isVariableDeclaration(parent) || ts.isParameter(parent)+ || ts.isPropertySignature(parent) || ts.isPropertyAssignment(parent) || ts.isMethodDeclaration(parent) || ts.isPropertyDeclaration(parent))+ && parent.name === id) return false;+ if (ts.isPropertyAccessExpression(parent) && parent.name === id) return false;+ if (ts.isTypeQueryNode(parent) || ts.isTypeReferenceNode(parent) || ts.isQualifiedName(parent)) return false;+ return true;+}++function usesIn(text: string, file: string): number[] {+ const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);+ const lines: number[] = [];+ const visit = (node: ts.Node): void => {+ if (ts.isIdentifier(node) && NAMES.has(node.text) && isUse(node)) lines.push(sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1);+ ts.forEachChild(node, visit);+ };+ visit(sf);+ return lines;+}++describe('#3783 query-embed call sites', () => {+ const found = new Map<string, number[]>();+ for (const path of sourceFiles(join(ROOT, 'src'))) {+ const text = readFileSync(path, 'utf8');+ if (!text.includes('embedQuery')) continue;+ const lines = usesIn(text, path);+ if (lines.length) found.set(relative(ROOT, path).split(sep).join('/'), lines);+ }++ test('every query embed outside the prefix-aware paths is allowlisted with its reason and count', () => {+ const unexpected = [...found].filter(([file, lines]) => ALLOWED[file]?.[0] !== lines.length)+ .map(([file, lines]) => `${file}:${lines.join(',')} (allowed ${ALLOWED[file]?.[0] ?? 0})`);+ expect(unexpected).toEqual([]);+ });++ test('every ALLOWED row still matches a real use (stale rows are removed)', () => {+ expect(Object.keys(ALLOWED).filter(file => !found.has(file))).toEqual([]);+ });++ test('the scanner sees the shapes that skip the prefix: a direct call and a function value', () => {+ expect(usesIn("import { embedQuery } from './embedding.ts';\nconst v = await embedQuery(q);", 'a.ts')).toEqual([2]);+ expect(usesIn("const fn = opts.embedQueryFn ?? embedQuery;", 'b.ts')).toEqual([1]);+ expect(usesIn("export async function embedQuery(text: string) {}\ntype T = typeof embedQuery;\nconst { embedQuery: e } = m;", 'c.ts')).toEqual([]);+ });+});diff --git a/test/query-prefix-call-sites.serial.test.ts b/test/query-prefix-call-sites.serial.test.tsnew file mode 100644index 0000000000..163517beca--- /dev/null+++ b/test/query-prefix-call-sites.serial.test.ts@@ -0,0 +1,158 @@+/**+ * #3783: every query-side embedding outside hybrid search applies the brain's+ * `embedding_query_prefix`. Before the fix, think (CLI, MCP `think`, the+ * synthesize verb, CRAG escalation, auto-think), `takes search --semantic`,+ * `search diagnose` and eval's vector baseline embedded the bare question+ * while documents and hybrid search used the instruction, so those paths+ * compared an unprefixed query with a prefix-trained index.+ *+ * Each case records what the (stubbed, $0) embedding transport receives.+ *+ * Serial (*.serial.test.ts): mock.module on think/index.ts leaks across files+ * in a shared bun process (TESTING.md R2).+ */+import { afterAll, afterEach, beforeAll, describe, expect, mock, test } from 'bun:test';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import * as realThink from '../src/core/think/index.ts';+import { configureGateway, resetGateway, __setEmbedTransportForTests, __clearQueryEmbedCacheForTests } from '../src/core/ai/gateway.ts';+import { withEnv } from './helpers/with-env.ts';++const PREFIX = 'query: ';+let engine: PGLiteEngine;+let seen: string[] = [];+let captured: Array<(q: string) => Promise<Float32Array | null>> = [];++mock.module('../src/core/think/index.ts', () => ({+ ...realThink,+ runThink: async (_engine: unknown, opts: { embedQuestion?: (q: string) => Promise<Float32Array | null> }) => {+ if (opts.embedQuestion) captured.push(opts.embedQuestion);+ return {+ answer: 'stub answer', citations: [], gaps: [], warnings: [], modelUsed: 'anthropic:claude-opus-4-7',+ pagesGathered: 0, takesGathered: 0, synthesis_status: 'ok', usage: null,+ };+ },+}));++function configureEmbedding(): void {+ configureGateway({ embedding_model: 'openai:text-embedding-3-large', embedding_dimensions: 1536, env: { OPENAI_API_KEY: 'sk-fake' } });+ __setEmbedTransportForTests((async (args: { values: string[] }) => {+ seen.push(...args.values);+ return { embeddings: args.values.map(() => Array.from({ length: 1536 }, () => 0.01)) };+ }) as never);+}++/** The embedQuestion callback the path handed runThink, invoked with a fresh probe text. */+async function probeCaptured(): Promise<string[]> {+ expect(captured.length).toBe(1);+ seen = [];+ __clearQueryEmbedCacheForTests();+ await captured[0]!('probe question');+ return seen;+}++async function quietly<T>(fn: () => Promise<T>): Promise<T> {+ const log = console.log;+ const err = console.error;+ console.log = () => {};+ console.error = () => {};+ try { return await fn(); } finally { console.log = log; console.error = err; }+}++beforeAll(async () => {+ engine = new PGLiteEngine();+ await engine.connect({});+ await engine.initSchema();+}, 60_000);++afterAll(async () => {+ await engine?.disconnect();+}, 60_000);++afterEach(async () => {+ __setEmbedTransportForTests(null);+ __clearQueryEmbedCacheForTests();+ resetGateway();+ seen = [];+ captured = [];+ for (const key of ['embedding_query_prefix', 'search.crag_think', 'dream.auto_think.enabled', 'dream.auto_think.questions']) {+ await engine.unsetConfig(key);+ }+});++describe('#3783: think entry points embed the question with the brain prefix', () => {+ test('synthesize verb', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ const { operationsByName } = await import('../src/core/operations.ts');+ await operationsByName['synthesize']!.handler({ engine, remote: false } as never, { question: 'what changed?' });+ expect(await probeCaptured()).toEqual([`${PREFIX}probe question`]);+ });++ test('MCP think op', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ const { operationsByName } = await import('../src/core/operations.ts');+ await operationsByName['think']!.handler({ engine, remote: false } as never, { question: 'what changed?' });+ expect(await probeCaptured()).toEqual([`${PREFIX}probe question`]);+ });++ test('CRAG think escalation on a weak query result', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ await engine.setConfig('search.crag_think', 'true');+ const { operationsByName } = await import('../src/core/operations.ts');+ await operationsByName['query']!.handler({ engine, remote: false } as never, { query: 'nothing in this brain matches zebra' });+ expect(await probeCaptured()).toEqual([`${PREFIX}probe question`]);+ });++ test('CLI think', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ const { runThinkCli } = await import('../src/commands/think.ts');+ await quietly(() => runThinkCli(engine, ['what changed?', '--json']));+ expect(await probeCaptured()).toEqual([`${PREFIX}probe question`]);+ });++ test('dream auto-think', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ await engine.setConfig('dream.auto_think.enabled', 'true');+ await engine.setConfig('dream.auto_think.questions', JSON.stringify(['what changed?']));+ const { runPhaseAutoThink } = await import('../src/core/cycle/auto-think.ts');+ await runPhaseAutoThink(engine, { dryRun: false } as never);+ expect(await probeCaptured()).toEqual([`${PREFIX}probe question`]);+ });++ test('a brain without a prefix still embeds the bare question', async () => {+ configureEmbedding();+ const { operationsByName } = await import('../src/core/operations.ts');+ await operationsByName['think']!.handler({ engine, remote: false } as never, { question: 'what changed?' });+ expect(await probeCaptured()).toEqual(['probe question']);+ });+});++describe('#3783: direct query embeds apply the brain prefix', () => {+ test('takes search --semantic', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ const { runTakes } = await import('../src/commands/takes.ts');+ await withEnv({ OPENAI_API_KEY: 'sk-fake' }, () => quietly(() => runTakes(engine, ['search', 'widget roadmap', '--semantic', '--json'])));+ expect(seen).toEqual([`${PREFIX}widget roadmap`]);+ });++ test('search diagnose vector layer', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ const { runSearchDiagnose } = await import('../src/commands/search-diagnose.ts');+ await quietly(() => runSearchDiagnose(engine, ['diagnose', 'widget roadmap', '--target', 'notes/widget-roadmap', '--json']));+ expect(seen).toEqual([`${PREFIX}widget roadmap`]);+ });++ test('eval vector baseline', async () => {+ configureEmbedding();+ await engine.setConfig('embedding_query_prefix', PREFIX);+ const { runEval } = await import('../src/core/search/eval.ts');+ await runEval(engine, [{ query: 'widget roadmap', relevant: ['notes/widget-roadmap'] }], { strategy: 'vector' } as never, 5);+ expect(seen).toEqual([`${PREFIX}widget roadmap`]);+ });+});