Skip to content

v0.36.3.0 — ZE-switch state stuck mid-migration on fresh PGLite init (1280/1536 dim mismatch) #1198

@trueice

Description

@trueice

Summary

Fresh gbrain init --pglite on v0.36.3.0 lands in a state where embedding_model config says openai:text-embedding-3-large but the embed pipeline tries ZeroEntropy (zembed-1 1280d), causing every page to fail with expected 1536 dimensions, not 1280.

The state is sticky — wiping ~/.gbrain/brain.pglite and re-running init does NOT reset it. Same error persists even after unset ZEROENTROPY_API_KEY.

Environment

  • gbrain version: 0.36.3.0
  • Repo commit: 1d5f69f
  • bun: 1.x (installed via Homebrew)
  • macOS: 26.3.1 (M-series Mac)

Steps to reproduce

git clone https://github.com/garrytan/gbrain.git ~/sandbox/gbrain
cd ~/sandbox/gbrain
bun install && bun link

export OPENAI_API_KEY=sk-proj-...
export ZEROENTROPY_API_KEY=ze_...

gbrain init --pglite
gbrain import /some/markdown/dir/ --no-embed   # 31 files, 234 chunks ok
gbrain embed --stale

Result:

Error embedding entities/nvda: expected 1536 dimensions, not 1280
Error embedding concepts/ai-model-release-cycle: expected 1536 dimensions, not 1280
...
[embed.pages] 31/31 (100%)
Embedded 0 chunks across 31 pages

Investigation

  • gbrain config get embedding_model returns text-embedding-3-large (no provider prefix)
  • gbrain config get embedding_dimensions returns 1536
  • gbrain config set embedding_model openai:text-embedding-3-large succeeds, but embed pipeline still tries ZE
  • gbrain providers list shows openai + zeroentropyai both ready
  • gbrain doctor warns embedding_provider: zeroentropyai:zembed-1 responds (925ms, 1280 dims) but: DB dimension mismatch: column is vector(1536) but provider returns 1280-dim

Workarounds tried (none worked)

Attempt Result
gbrain config set embedding_model openai:text-embedding-3-large embed still routes to ZE
unset ZEROENTROPY_API_KEY before embed error switches to ZeroEntropy embedding requires ZEROENTROPY_API_KEY (still ZE-routed)
rm -rf ~/.gbrain/brain.pglite && gbrain init --pglite same state persists across reinits
gbrain init --pglite --embedding-dimensions 1280 flag silently ignored, dimensions still 1536
gbrain ze-switch command exists but produces no output, no state change
gbrain config set ze_switch_declined_at "<iso>" doesn't unstick the embed path

Suspected root cause (from reading source)

src/core/retrieval-upgrade-planner.ts defines a ZE-as-default switch flow (v0.36.0.0). On fresh init when OPENAI_API_KEY is set, isLegacyDefault=true triggers zeSwitchOffered=true, but ze_switch_applied is never written, leaving the embed pipeline in a half-migrated state where it routes to ZE_TARGET_EMBEDDING_MODEL even though gbrain config get embedding_model returns the OpenAI default.

loadConfigWithEngine in src/core/config.ts doesn't merge embedding_model from the DB plane (only embedding_multimodal, embedding_columns, search_embedding_column, etc.), so user config set embedding_model writes to the DB but the embed code reads the gateway default.

Impact

Cannot complete fresh PGLite install following INSTALL_FOR_AGENTS.md.

Suggested fix directions (no PR yet)

  1. loadConfigWithEngine should merge embedding_model from DB plane the same way other embedding_* keys are merged.
  2. gbrain init --pglite should either complete the ZE switch (if ZE key set) or hard-refuse it (if dim mismatch), not leave half-state.
  3. gbrain ze-switch should print what it's doing (currently silent, no diagnostic output).
  4. gbrain init --embedding-dimensions N flag should be honored or removed from CLI help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions