fix: detect PgBouncer transaction-mode pooler and set GBRAIN_PREPARE=true#1591
Open
mikeangstadt wants to merge 1 commit into
Open
fix: detect PgBouncer transaction-mode pooler and set GBRAIN_PREPARE=true#1591mikeangstadt wants to merge 1 commit into
mikeangstadt wants to merge 1 commit 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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