Skip to content

fix(doctor): run PGLite probes through active engine#1183

Open
duncanclaw wants to merge 1 commit into
garrytan:masterfrom
duncanclaw:fix/pglite-doctor-engine-checks
Open

fix(doctor): run PGLite probes through active engine#1183
duncanclaw wants to merge 1 commit into
garrytan:masterfrom
duncanclaw:fix/pglite-doctor-engine-checks

Conversation

@duncanclaw
Copy link
Copy Markdown

@duncanclaw duncanclaw commented May 18, 2026

Summary

Fix two false-positive gbrain doctor warnings for PGLite-backed brains:

  • route the pgvector probe through the active BrainEngine
  • route the jsonb_integrity probe through the active BrainEngine
  • add focused PGLite regression coverage for both checks

Root Cause

The doctor had two remaining direct calls to the module-level Postgres singleton:

  • db.getConnection() for pg_extension
  • db.getConnection().unsafe(...) for JSONB integrity scanning

That works for Postgres-backed brains, but PGLite uses PGLiteEngine and does not initialize the Postgres singleton. The result was a false warning on healthy embedded brains:

[WARN] pgvector: Could not check pgvector extension
[WARN] jsonb_integrity: Could not check JSONB integrity

The underlying PGLite engine can answer both SQL probes correctly; the doctor was just bypassing it.

Real Behavior Proof

  • Behavior addressed: embedded PGLite brains no longer warn on pgvector and jsonb_integrity solely because no external Postgres singleton is connected.
  • Real environment tested: local GBrain checkout with an embedded PGLite engine, plus a PGLite-backed brain used for doctor smoke verification.
  • Exact commands run after this patch:
bun test test/doctor.test.ts
bun run typecheck
bash scripts/check-no-legacy-getconnection.sh
bun run check:jsonb
gbrain doctor
  • Evidence after fix:
(pass) doctor command > pgvector and jsonb_integrity checks use the active PGLite engine
49 pass
0 fail

[OK] pgvector: Extension installed
[OK] jsonb_integrity: All JSONB columns store objects/arrays
  • Observed result after fix: the two PGLite-specific false warnings are gone. The local doctor smoke still surfaced an unrelated resolver warning from the checkout, but pgvector and jsonb_integrity both report OK.
  • What was not tested: live Supabase/self-hosted Postgres doctor output. The SQL and status semantics are unchanged for Postgres; this PR only routes the probes through the active engine abstraction.

Regression Test Plan

  • Coverage level that should have caught this: focused doctor unit coverage against a real PGLite engine.
  • Target test: test/doctor.test.ts
  • Scenario locked in: pgvectorCheck(PGLiteEngine) and jsonbIntegrityCheck(PGLiteEngine) both return OK after schema initialization.
  • Why this is the smallest reliable guardrail: the bug was not pgvector or JSONB behavior; it was the doctor using the wrong connection path.

Verification

  • bun test test/doctor.test.ts
  • bun run typecheck
  • bash scripts/check-no-legacy-getconnection.sh
  • bun run check:jsonb

User-visible Behavior

PGLite users should see fewer false gbrain doctor warnings. No CLI flags, config keys, migrations, or data-shape changes.

@duncanclaw duncanclaw force-pushed the fix/pglite-doctor-engine-checks branch from 51397b4 to 77da61f Compare May 18, 2026 21:40
@duncanclaw duncanclaw changed the title fix: route PGLite doctor probes through active engine fix(doctor): use active engine for PGLite probes May 18, 2026
@duncanclaw duncanclaw changed the title fix(doctor): use active engine for PGLite probes fix(doctor): run PGLite probes through active engine May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant