Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: pin buildIndexOnline's row estimate and ANALYZE in the reindex facts swap; type the attended route constant
garrytane2d775fd156e
diff --git a/test/reindex-search-vector.serial.test.ts b/test/reindex-search-vector.serial.test.tsindex 21822739af..64d2dad94c 100644--- a/test/reindex-search-vector.serial.test.ts+++ b/test/reindex-search-vector.serial.test.ts@@ -52,19 +52,24 @@ function makeMockEngine(state: MockState): BrainEngine {return engine;}-/** The facts keyword index swap the command ends with (facts/fts-index.ts on a non-Postgres engine with no index yet): 8 statements. */+/**+ * The facts keyword index swap the command ends with (facts/fts-index.ts on a non-Postgres engine with no index yet): 10+ * statements, including buildIndexOnline's row estimate for its notice and its ANALYZE of facts after the build.+ */function expectFactsSwap(calls: string[], lang: string): void {expect(calls.map(sql => sql.trim().split(/\s+/).slice(0, 6).join(' '))).toEqual(['SELECT i.indisvalid AS valid, pg_get_indexdef(i.indexrelid) AS','SELECT i.indisvalid AS valid, pg_get_indexdef(i.indexrelid) AS','SELECT to_regclass($1) IS NOT NULL AS',+ 'SELECT GREATEST(reltuples, 0)::bigint AS rows FROM','CREATE INDEX IF NOT EXISTS idx_facts_fts_next',+ 'ANALYZE facts','DROP INDEX IF EXISTS idx_facts_fts_old','ALTER INDEX IF EXISTS idx_facts_fts RENAME','ALTER INDEX idx_facts_fts_next RENAME TO idx_facts_fts','DROP INDEX IF EXISTS idx_facts_fts_old',]);- expect(calls[3]).toContain(`USING gin (to_tsvector('${lang}'::regconfig`);+ expect(calls[4]).toContain(`USING gin (to_tsvector('${lang}'::regconfig`);}const MARKER = 'fts.reindex_in_progress';@@ -143,8 +148,8 @@ describe('runReindexSearchVector', () => {// 1 inventory + 2 CREATE + 2 backfill batches (mock returns no rows, so// the keyset loop terminates after the first batch per table) + the facts- // keyword index swap (8) = 13 calls- expect(state.calls.length).toBe(13);+ // keyword index swap (10) = 15 calls+ expect(state.calls.length).toBe(15);expect(state.calls[1]).toContain('CREATE OR REPLACE FUNCTION update_page_search_vector');expect(state.calls[1]).toContain("to_tsvector('pt_br'");expect(state.calls[2]).toContain('CREATE OR REPLACE FUNCTION update_chunk_search_vector');@@ -171,7 +176,7 @@ describe('runReindexSearchVector', () => {expect(result.status).toBe('ok');expect(result.language).toBe('english');- expect(state.calls.length).toBe(13);+ expect(state.calls.length).toBe(15);// Trigger recreates (calls 1, 2) and chunks backfill (call 4) embed the// language literal. Pages backfill (call 3) is UPDATE-to-self that@@ -303,7 +308,7 @@ describe('runReindexSearchVector', () => {expect([...state.config!.keys()]).toEqual([]);// The existing executeRaw shape is untouched (config goes through// get/set/unsetConfig, not executeRaw).- expect(state.calls.length).toBe(13);+ expect(state.calls.length).toBe(15);});test('resumes the chunks backfill from the persisted checkpoint when the marker matches the language', async () => {diff --git a/test/relational-intent-attendance-paraphrase.test.ts b/test/relational-intent-attendance-paraphrase.test.tsindex c0019bc903..2564c0e32c 100644--- a/test/relational-intent-attendance-paraphrase.test.ts+++ b/test/relational-intent-attendance-paraphrase.test.ts@@ -13,12 +13,16 @@* evidence.*/import { describe, test, expect, beforeAll, afterAll } from 'bun:test';-import { parseRelationalQuery } from '../src/core/search/relational-intent.ts';+import { parseRelationalQuery, type RelationalKind, type RelationDirection } from '../src/core/search/relational-intent.ts';import { PGLiteEngine } from '../src/core/pglite-engine.ts';import { buildRelationalArm } from '../src/core/search/relational-recall.ts';import { installFixtureChunks } from './helpers/page-projection.ts';-const ATTENDED = { kind: 'who_rel', linkTypes: ['attended'], direction: 'in' };+const ATTENDED: { kind: RelationalKind; linkTypes: string[]; direction: RelationDirection } = {+ kind: 'who_rel',+ linkTypes: ['attended'],+ direction: 'in',+};const INVEST = ['invested_in', 'led_round'];const FORMS: Array<[string, string]> = [