Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
// #4605 — the `search.*` rows in KNOWN_CONFIG_KEYS were a hand-copied list
// that drifted from the keys mode.ts actually reads: three registered
// spellings (`search.token_budget`, `search.intent_weighting`,
// `search.limit_default`) had no reader, while 20 live knobs (the camelCase
// `search.tokenBudget` / `search.intentWeighting` / `search.searchLimit` the
// code and every hint print, the reranker.*, cross_modal.*, relational_*
// keys…) were accepted only through the `search.` prefix. Because the prefix
// swallows both spellings silently, neither the Levenshtein suggestion nor
// the --force "Nothing in gbrain reads this" warning could ever fire for a
// search.* key. These pins keep the registry and the read path in lockstep
// without config.ts importing mode.ts (config.ts is deliberately lean: its
// import closure serves engine-free hook children).
import { describe, expect, test } from 'bun:test';
import { KNOWN_CONFIG_KEYS } from '../src/core/config.ts';
import { KNOB_CONFIG_KEY, SEARCH_MODE_CONFIG_KEYS, SEARCH_MODE_KEY } from '../src/core/search/mode.ts';
import { REMOTE_PRIVATE_PAGES_KEY } from '../src/core/search/private-visibility.ts';
import { PAGE_RANK_CUT_FACTOR_KEY, PAGE_RANK_CUT_KEY } from '../src/core/search/page-rank-cut.ts';
/** search.* keys read directly via engine.getConfig (not mode-bundle knobs). */
const DIRECTLY_READ_SINGLETONS = [
SEARCH_MODE_KEY,
'search.mode_upgrade_notice_shown', // commands/upgrade.ts
'search.mode_source', // init --search-mode / config set search.mode (who chose search.mode)
'search.image_query.max_bytes', // ops/image.ts
'search.image_query.daily_budget_usd_per_client', // ops/image.ts
'search.image_query.remote_max_bytes', // ops/image.ts
'search.mcp_keyword_only', // ops/search.ts
'search.remote_page_cap', // search/remote-page-cap.ts (ops/search.ts)
REMOTE_PRIVATE_PAGES_KEY, // search/private-visibility.ts
'search.track_retrieval', // last-retrieved.ts
'search.intent_patterns', // search/query-intent.ts
'search.source_boosts', // search/mode.ts snapshot + ops/search.ts
'search.alias_token_hop', // search/mode.ts snapshot
'search.adaptive_return', // return-policy.ts via loadConfigWithEngine
'search.adaptive_return_entity_max',
'search.adaptive_return_other_max',
'search.adaptive_return_min_keep',
'search.vector_legacy_guard', // search/vector-legacy-guard.ts via loadConfigWithEngine
'search.hnsw_iterative_scan', // search/hnsw-iterative-scan.ts via loadConfigWithEngine
'search.cjk_keyword_deadline_ms', // search/cjk-keyword-deadline.ts via loadConfigWithEngine
'search.keyword_statement_timeout_ms', // postgres-engine/keyword-statement-timeout.ts (engine.getConfig once per connection) + loadConfigWithEngine
'search.keyword_timeout_negative_cache_seconds', // postgres-engine/keyword-timeout-cache.ts (read on the first keyword timeout)
'search.crag_escalation', // ops/search.ts
'search.alias_fanout_max', // search/alias-fanout.ts
'search.demote_generated', // search/provenance-demotion.ts
'search.crag_think', // ops/search.ts
'search.return_unit', // search/evidence-delivery.ts
'search.return_window',
'search.return_budget_default',
'search.return_budget_conversation',
'search.return_budget_max_remote',
'search.auto_packing', // search/evidence-delivery.ts (explicit-budget cap)
'search.long_page_unit', // search/evidence-delivery.ts (long non-conversation pages under implied auto)
'search.long_page_min_chars', // search/evidence-delivery.ts (rendered-body threshold for a long page)
'search.evidence_date_header', // search/evidence-delivery.ts (C1)
'search.evidence_tail_trim', // search/evidence-tail-trim.ts (GBRA-156)
'search.entity_anchoring', // search/entity-anchor.ts (ops/search.ts)
'search.query_facts_arm', // search/facts-arm.ts (search/query-arms.ts)
'search.temporal_fact_reserve', // search/facts-arm.ts (search/query-arms.ts)
'search.query_facts_block', // search/facts-arm.ts (search/query-arms.ts, GBRA-205)
'search.saved_facts_supersede', // search/saved-facts-match.ts (GBRA-205)
'search.fact_source_pages', // search/facts-arm.ts (search/query-arms.ts, GBRA-205)
'search.evidence_titles', // search/evidence-date.ts (GBRA-205)
'search.query_budget_unit', // search/evidence-delivery.ts via ops/search.ts (GBRA-205)
PAGE_RANK_CUT_KEY, // search/page-rank-cut.ts via evidence-delivery.ts (W5)
PAGE_RANK_CUT_FACTOR_KEY,
];
describe('KNOWN_CONFIG_KEYS search.* rows mirror what the code reads (#4605)', () => {
test('the three dead snake_case spellings are gone', () => {
for (const k of ['search.token_budget', 'search.intent_weighting', 'search.limit_default']) {
expect(KNOWN_CONFIG_KEYS, `${k} has no reader`).not.toContain(k);
}
});
test('every key mode.ts reads is registered', () => {
const missing = SEARCH_MODE_CONFIG_KEYS.filter((k) => !KNOWN_CONFIG_KEYS.includes(k));
expect(missing).toEqual([]);
});
test('every directly-read search.* singleton is registered', () => {
const missing = DIRECTLY_READ_SINGLETONS.filter((k) => !KNOWN_CONFIG_KEYS.includes(k));
expect(missing).toEqual([]);
});
test('every registered search.* key has a reader (mode knob or listed singleton)', () => {
const readers = new Set<string>([...SEARCH_MODE_CONFIG_KEYS, ...DIRECTLY_READ_SINGLETONS]);
const dead = KNOWN_CONFIG_KEYS.filter((k) => k.startsWith('search.') && !readers.has(k));
expect(dead).toEqual([]);
});
test('no duplicate search.* rows', () => {
const rows = KNOWN_CONFIG_KEYS.filter((k) => k.startsWith('search.'));
expect(new Set(rows).size).toBe(rows.length);
});
});
describe('KNOB_CONFIG_KEY is the single knob→config-key map', () => {
test('SEARCH_MODE_CONFIG_KEYS is derived from it, 1:1, all under search.', () => {
const keys = Object.values(KNOB_CONFIG_KEY);
expect([...SEARCH_MODE_CONFIG_KEYS].sort()).toEqual([...keys].sort());
expect(new Set(keys).size).toBe(keys.length);
for (const k of keys) expect(k.startsWith('search.')).toBe(true);
expect(keys).not.toContain(SEARCH_MODE_KEY);
});
});