feat(storage): pgvector adapter support gated on tier=federated (FED-M1-03) #472
Reference in New Issue
Block a user
Delete Branch "feat/federation-m1-pgvector"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
FED-M1-03 — pgvector support in the postgres storage adapter, gated on
enableVectorflag (set automatically for federated tier). Local and standalone tiers are untouched.Adapter changes:
StorageConfigpostgres variant gains optionalenableVector?: boolean.PostgresAdapter.migrate()runsCREATE EXTENSION IF NOT EXISTS vectorviadb.execute(sql)BEFORE migrations when the flag is true. Idempotent — safe to re-run on an already-installed extension. Order matters: the extension must exist before any migration that creates avector(...)column runs.Schema export:
vectorcustom type in@mosaicstack/db/schemais now exported (it was internal, used bypreferences.embedding). Downstream packages can now declarevector('col', { dimensions: N })in their own schemas.Config wiring:
DEFAULT_FEDERATED_CONFIG.storage.enableVector = trueso the federated default flows through to the adapter.detectFromEnv()restructured soMOSAIC_STORAGE_TIERis checked BEFORE theDATABASE_URLguard. SettingMOSAIC_STORAGE_TIER=federatedalone now returns the federated default config instead of silently misrouting to local (footgun fix raised in code review). Same applies toMOSAIC_STORAGE_TIER=standalone. WithDATABASE_URLset, the URL is honored andenableVectoris preserved.detectFromEnvis now exported for direct test access.Tests added:
toSQL()(public API) with a documented fallback for older Drizzle versions.detectFromEnvtests covering each env-var permutation (no vars / federated alone / federated+DATABASE_URL / standalone alone).DEFAULT_FEDERATED_CONFIGconstant test confirmingenableVector=true.Review chain:
feat/federation-m1-pgvectorfeature-dev:code-reviewer(sonnet) — verdictship-with-followup, raised 2 issues (silent misroute, brittle test assertion)Out of scope (deferred)
Refs #460
Test plan
pnpm --filter @mosaicstack/storage test(31/31)pnpm --filter @mosaicstack/config test(15/15)pnpm typecheck(38/38)pnpm lint(21/21)pnpm format:checkGenerated with Claude Code