fix: detect PgBouncer transaction-mode pooler and set GBRAIN_PREPARE=true#1591
fix: detect PgBouncer transaction-mode pooler and set GBRAIN_PREPARE=true#1591mikeangstadt wants to merge 2 commits into
Conversation
…true (garrytan#1435) When gbrain connects through a PgBouncer transaction-mode pooler (port 6543), it auto-disables prepared statements. This breaks `gbrain search` silently — the /sync-gbrain capability check fails and the GBrain Search Guidance block never gets written to CLAUDE.md. Three-layer fix: 1. **lib/gbrain-exec.ts** — `buildGbrainEnv()` now detects port 6543 in the effective DATABASE_URL and sets `GBRAIN_PREPARE=true` in the env passed to every gbrain spawn. This is the single chokepoint — all gstack gbrain invocations inherit the fix. Caller can opt out with `GBRAIN_PREPARE=false`. 2. **sync-gbrain/SKILL.md{,.tmpl}** — capability check now exports `GBRAIN_PREPARE=true` explicitly and retries search up to 3x with 1s delay for async index propagation under connection pooling. 3. **bin/gstack-gbrain-detect** — surfaces `gbrain_pooler_mode` field ("transaction" | "session" | null) in the preamble probe JSON so /setup-gbrain and /sync-gbrain can advise users about pooler state. Closes garrytan#1435 Built with [ClosedLoop.AI](https://closedloop.ai) | [GitHub](https://github.com/closedloop-ai/claude-plugins) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
This detection is using only port |
|
Resolved on I removed the URL-only To make that metadata available, |
Summary
Fixes #1435 —
/sync-gbraincapability check fails under PgBouncer transaction mode becausegbrain searchsilently returns no results when prepared statements are disabled.lib/gbrain-exec.ts:buildGbrainEnv()now detects port 6543 in DATABASE_URL and auto-setsGBRAIN_PREPARE=truein the env for all gbrain spawns. Single chokepoint fix — every gstack-originated gbrain call inherits it. Callers can override withGBRAIN_PREPARE=false.sync-gbrain/SKILL.md{,.tmpl}: Capability check exportsGBRAIN_PREPARE=trueand retries search up to 3x with 1s delay for async index propagation under connection pooling.bin/gstack-gbrain-detect: Surfacesgbrain_pooler_mode("transaction" | "session" | null) in the preamble probe JSON for downstream skill visibility.Test plan
isTransactionModePooler()— port 6543, 5432, no-port, unparseable, postgres:// schemebuildGbrainEnv()GBRAIN_PREPARE auto-detection — pooler URL sets it, session URL doesn't, caller opt-out respected, already-matching URL still sets itbuildGbrainEnvtests still pass (DATABASE_URL seeding behavior unchanged)/sync-gbrainand verify the capability check passes and## GBrain Search Guidanceblock is written to CLAUDE.mdContinuous collaboration, powered by ClosedLoop.AI (GitHub)
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com