CI verify failed: test/postgres-engine-config-cache.test.ts mutated
process.env.GBRAIN_CONFIG_CACHE_TTL_MS directly in beforeEach/afterEach.
Wrap each test body in withEnv() (test/helpers/with-env.ts) instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Takeover of #1694: a single search fires ~85 serial getConfig() reads
(loadConfigWithEngine x2 plus the mode/cache/intent/rerank/graph-signals
resolvers); on a remote pooler each read is a round-trip, dominating query
latency and risking cli.ts's 10s disconnect force-exit truncating stdout.
The first read now batch-loads the whole config table into a process-
lifetime Map (single-flight under concurrency); setConfig/unsetConfig
write through; a 30s TTL bounds multi-writer staleness and
GBRAIN_CONFIG_CACHE_TTL_MS=0 restores per-key reads.
Rebased onto current master: unlike the original diff, both the batch
load and the TTL=0 per-key fallback stay inside connRetry() so the
#1603/#1891 retry+reconnect posture (pooler-drop self-heal) is preserved.
PGLite stays uncached (in-process, zero round-trips; raw-SQL test
fixtures rely on fresh reads). E2E helpers pin the cache off since those
suites seed config via raw SQL.
Co-authored-by: Omerbahari <Omerbahari@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>