Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: follow the SQL cosine re-score and one-statement search settings in two harnesses

garrytan87d11abcb80b
diff --git a/test/keyword-timeout-negative-cache-6495.test.ts b/test/keyword-timeout-negative-cache-6495.test.ts
index 17b496434e..d4560d9d36 100644
--- a/test/keyword-timeout-negative-cache-6495.test.ts
+++ b/test/keyword-timeout-negative-cache-6495.test.ts
@@ -74,7 +74,6 @@ function harness(opts: { ttl?: string | null } = {}): Harness {
async (strings: TemplateStringsArray, ..._values: unknown[]) => {
const sql = strings.join('$');
all.push(sql);
- if (/SET LOCAL enable_seqscan = off/.test(sql)) inRelaxed = true;
return /SHOW enable_seqscan/i.test(sql) ? [{ enable_seqscan: 'on' }] : [];
},
{
@@ -89,13 +88,16 @@ function harness(opts: { ttl?: string | null } = {}): Harness {
},
);
const priv = engine as unknown as {
- withScopedReadTransaction: (ids: unknown, id: unknown, cb: (tx: unknown) => Promise<unknown>) => Promise<unknown>;
+ withScopedReadTransaction: (ids: unknown, id: unknown, cb: (tx: unknown) => Promise<unknown>, o?: { settings?: Record<string, string> }) => Promise<unknown>;
executeRaw: (sql: string, params?: unknown[]) => Promise<unknown[]>;
_savedConfig: Record<string, unknown> | undefined;
_pageTransaction: boolean;
keywordTimeouts: KeywordTimeoutNegativeCache;
};
- priv.withScopedReadTransaction = (_ids, _id, cb) => cb(tx);
+ priv.withScopedReadTransaction = (_ids, _id, cb, o) => {
+ if (o?.settings?.enable_seqscan === 'off') inRelaxed = true;
+ return cb(tx);
+ };
priv.executeRaw = async (sql) => {
all.push(sql);
if (sql.includes(KEYWORD_TIMEOUT_NEGATIVE_CACHE_KEY)) return opts.ttl == null ? [] : [{ value: opts.ttl }];
diff --git a/test/unified-multimodal.serial.test.ts b/test/unified-multimodal.serial.test.ts
index ded0c4cbc1..908bfa87c4 100644
--- a/test/unified-multimodal.serial.test.ts
+++ b/test/unified-multimodal.serial.test.ts
@@ -142,10 +142,16 @@ describe('hybridSearch unified routing (Phase 3)', () => {
);
const columns: string[] = [];
const original = engine.getEmbeddingsByChunkIds.bind(engine);
+ const originalRaw = engine.executeRaw.bind(engine);
(engine as any).getEmbeddingsByChunkIds = async (ids: number[], column?: string) => {
columns.push(column ?? 'embedding');
return original(ids, column);
};
+ (engine as any).executeRaw = async (sql: string, params?: unknown[], opts?: unknown) => {
+ const rescore = /vector_dims\(cc\."?(\w+)"?::vector\)/.exec(sql);
+ if (rescore) columns.push(rescore[1]);
+ return (originalRaw as any)(sql, params, opts);
+ };
try {
const results = await hybridSearch(engine, 'multimodal body', { limit: 5 });
expect(columns).toContain('embedding_multimodal');
@@ -154,6 +160,7 @@ describe('hybridSearch unified routing (Phase 3)', () => {
expect(hit.cosine).toBeCloseTo(1, 5);
} finally {
(engine as any).getEmbeddingsByChunkIds = original;
+ (engine as any).executeRaw = originalRaw;
}
});