Skip to content

knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks #37100

Backlog

Description

@os-bob

maintainer · os-bob · session_012dn2AecKpLaYkUtNRiqtby

Filing gate: ③ maintainer-directed (topic child). Source: topic #37000 (phase 2 row 8); boundary cloud ADR-0119 D5 (objectstack-ai/cloud#4968: 「都放开源」); maintainer 2026-11-24 「用fable评审,并分拆第二阶段的任务」. Reviewed by an independent Fable pass before filing.
Grading: area:ai · Feature · p2 (topic) · reach: self-hosted deployments on PostgreSQL · evidence: read.

维护者速读

  • 做什么:新增开源包 knowledge-pgvector。自建部署用 PostgreSQL 时,不装外部检索引擎也有向量检索,多组织的数据互不串。
  • 要知道的:
    • 数据库要装 pgvector 扩展。
    • 要配置嵌入服务商,文本会发给它。
    • 换模型后要重建,重建期间检索暂不可用(重建在另一张卡)。
  • 谁受益:企业版和开源版的 PostgreSQL 部署;BrightRule 可以删掉自己写的 pgvector 代码。
  • 需要你做的:无(它依赖的 CI 镜像卡要你手工合并)。

What

  1. packages/plugins/knowledge-pgvector (new, Apache-2.0), rewritten from BrightRule's store (objectstack-ai/brightrule src/qa/vector/pgvector-store.ts, adapter.ts), not lifted.
  2. Storage: one table per vector dimension, knowledge_vec_d<dim>: source_id, generation, chunk_id, document_id, source_record_id, organization_id, content, doc_hash, chunk_hash, metadata jsonb, embedding vector(<dim>); created only when a new dimension appears. A generation table: source_id, generation, fingerprint, dim, model, state, created_at. Check the table names cannot collide with object tables, and that schema-drift checks do not report them (state the result).
  3. Connection: its own small pool built from the platform database's connection settings when that database is PostgreSQL (state how the settings are read), else a configured URL. No pooled connection is held across an embed call. State the schema, and which database is used when organizations have separate databases.
  4. Missing vector extension or DDL right: the adapter does not register its tables; knowledge calls answer a readable error carrying the SQL to run by hand; healthCheck is false; boot continues.
  5. Search: exact scan (HNSW documented as an operator step, with its dimension limit). Organization filter in SQL from service-knowledge: documents carry their organization, and search hands the caller's organizations to the adapter #37097's organizationIds. Today's opaque metadata-equality filter applied in SQL before ranking.
  6. Fingerprint: the one ADR: knowledge platform boundary — the platform owns document assembly, sync and reconcile, structural split and record-level return; knowledge_source becomes a governed type #37001 defines (model + dimensions + split config + split algorithm version + content recipe), computed by the service and handed to the adapter (member per ADR: knowledge platform boundary — the platform owns document assembly, sync and reconcile, structural split and record-level return; knowledge_source becomes a governed type #37001; this card is its reader). IEmbedder.model? lands here (the fingerprint reads it); embedder-openai fills it. A stored fingerprint that differs from the current one marks the source as needing a rebuild, and search answers a clear "rebuild needed" error until knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101's build runs.
  7. Unchanged content (same chunk_hash, computed by the adapter over the text it embeds) updates metadata only, no re-embedding.
  8. Implements listDocuments (service-knowledge: adapters list their documents; a complete reindex skips unchanged documents and purges the ones its source no longer has; one contract test suite #37096), accepts chunks (service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098). Plugin option queryPrefix for asymmetric models (BGE).
  9. The service-knowledge: adapters list their documents; a complete reindex skips unchanged documents and purges the ones its source no longer has; one contract test suite #37096 contract suite runs in CI against PostgreSQL with pgvector (CI: the PostgreSQL job runs on an image with the pgvector extension #37095); no skip path. Tests use a fixed fake embedder.
  10. Docs: content/docs/protocol/knowledge.mdx (lines 87 and 430 say "planned" / "Phase 3"), content/docs/ai/knowledge-rag.mdx; the content column is as sensitive as the source data and is in backups.

Acceptance

Out of scope

Blocked-by: #37001, #37096, #37098, #37095, #37097.
Parent: #37000. Reader: domain:server lane (packages/plugins/knowledge-*).
Dedupe: pgvector 5 (open: #37000, #37001, a seat post — no card) · knowledge generation fingerprint 12 (open: #37000, #37001, a seat post).

Activity

  1. added theissue type on Nov 24, 2026
  2. added
    priority:p2
    area:ai
    on Nov 24, 2026
  3. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: first touch 2026-11-24T20:35Z

  4. added
    domain:server
    pm:blocked
    on Nov 24, 2026
  5. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

    Scope note (2026-11-24T21:24Z), from the reviews of the knowledge-platform ADR (PR #37119: contract review 7144861870, L1 7144881422), verified against origin/main. Area: a4-K.

  6. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

    Seat note: surface addition · 2026-11-24T21:25Z · verified in the contract review of ADR-0161 (PR #37119, 7144861870): packages/services/service-knowledge KnowledgeService.search today logs an adapter error and continues, and the tool then tells the model nothing matched — so this card's "rebuild needed" refusal would reach the caller as an empty answer. This card therefore also changes search so an adapter refusal surfaces as a refusal, with a pin; its claim declares that file beside packages/plugins/knowledge-*.

  7. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

    Update to scope note 7144903681 (2026-11-24T21:55Z), after the knowledge-platform ADR's third review (PR #37119 head 4fa0cdc, contract review 7145549687 PASS). Area: a4-K.

    • Item 8 lands whole, once: the ADR's K8 item 8 (fingerprint function, beginBuild / completeBuild, indexStatus, the recipe hash, with IEmbedder.model and the descriptor's model and dimensions) lands whole in whichever of this card and service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099 merges first, with knowledge-memory as the reference. If this card is first, it carries all of item 8 and its suite cases (including one holding beginBuild and completeBuild as a pair).
    • The several-sources answer is now settled by the ADR (K7 rule 5): the searchable sources answer, each refused source is named with its code, the call is refused whole only when none can be searched. What stays here is the carrier: where IKnowledgeService.search reports the refused sources (this card, or a card split from it for the service's lane).
    • Unchanged from 7144903681: the catch in KnowledgeService.search must let a coded refusal through, so this card's surface includes packages/services/service-knowledge/src/knowledge-service.ts.
  8. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

    One more case for this card's suite (2026-11-24T22:09Z), from the L1 of PR #37129 (#36992, comment 7145865808). Area: a4-K.

    • reindexSource now walks a source in id order (orderBy id asc, id > cursor). That order was checked once on SQLite, not on PostgreSQL; a PostgreSQL column with a non-C collation is where the engine's sort and its $gt could disagree. Since this card brings the first real PostgreSQL to the knowledge suite, add one reindex-over-a-real-driver case here: mixed-case and numeric-looking ids, every row indexed once, none skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aidomain:serverpm:blockedpriority:p2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions