Repository navigation
Backlog
Backlog
knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks#37100
Feature
Copy link
Labels
area:aiAI-native — agent / tool / skill metadata, and the MCP surface an agent drivesdomain:serverDomain lane — seat card indexed by label:pm:seatpm:blockedBlocked by another issue/PR — body carries Blocked-by: #Npriority:p2Medium: important, M3
Description
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
packages/plugins/knowledge-pgvector(new, Apache-2.0), rewritten from BrightRule's store (objectstack-ai/brightrulesrc/qa/vector/pgvector-store.ts,adapter.ts), not lifted.- 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). - 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.
- Missing
vectorextension or DDL right: the adapter does not register its tables; knowledge calls answer a readable error carrying the SQL to run by hand;healthCheckis false; boot continues. - 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. - Fingerprint: the one ADR: knowledge platform boundary — the platform owns document assembly, sync and reconcile, structural split and record-level return;
knowledge_sourcebecomes 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_sourcebecomes a governed type #37001; this card is its reader).IEmbedder.model?lands here (the fingerprint reads it);embedder-openaifills 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. - Unchanged content (same
chunk_hash, computed by the adapter over the text it embeds) updates metadata only, no re-embedding. - 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 optionqueryPrefixfor asymmetric models (BGE). - 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.
- Docs:
content/docs/protocol/knowledge.mdx(lines 87 and 430 say "planned" / "Phase 3"),content/docs/ai/knowledge-rag.mdx; thecontentcolumn is as sensitive as the source data and is in backups.
Acceptance
- A 3072-dimension model works.
- Two organizations in one database never see each other's hits (adapter test and service test).
- Missing extension → readable error with the SQL, boot continues.
- Same content re-indexed → no embed call.
- Changed fingerprint → "rebuild needed" error, old rows not served.
- 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 suite passes in CI on real PostgreSQL.
Out of scope
- Building a new generation and switching (knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101).
- Automatic HNSW;
storeContent: false; the typed filter (row 11). - The comparison with BrightRule's own store (on the BrightRule migration card, BrightRule moves to the platform knowledge store: drop src/qa/vector, use platform pgvector, splitting and record-level search brightrule#21).
- The libSQL store (knowledge-turso moves into objectstack: Apache-2.0, the platform embedder and splitter, listing, generations, the contract suite #37107).
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).
Metadata
Metadata
Assignees
Labels
area:aiAI-native — agent / tool / skill metadata, and the MCP surface an agent drivesdomain:serverDomain lane — seat card indexed by label:pm:seatpm:blockedBlocked by another issue/PR — body carries Blocked-by: #Npriority:p2Medium: important, M3
Activity
objectstack-fleet commentedon Nov 24, 2026
triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE
Triage: first touch 2026-11-24T20:35Z
pm:blockedanddomain:serveradded. The card has no state yet, and itsBlocked-by:cards (ADR: knowledge platform boundary — the platform owns document assembly, sync and reconcile, structural split and record-level return;knowledge_sourcebecomes a governed type #37001, 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, service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098, CI: the PostgreSQL job runs on an image with the pgvector extension #37095, service-knowledge: documents carry their organization, and search hands the caller's organizations to the adapter #37097) are still open.knowledge_sourcebecomes a governed type #37001). Triage's unlock scan moves the card when every blocker closes.objectstack-fleet commentedon Nov 24, 2026
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.
KnowledgeService.search(packages/services/service-knowledge/src/knowledge-service.ts) catches an adapter's error, logs it and moves on to the next source, and thesearch_knowledgetool tells the model that no passage means nothing matched. So a refusal thrown byknowledge-pgvectorreaches the tool caller as an empty answer.catchinsearchmust let a coded "rebuild needed" refusal through. knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101 item 4 and knowledge-turso moves into objectstack: Apache-2.0, the platform embedder and splitter, listing, generations, the contract suite #37107 item 5 depend on the same change.Blocked-by:line is amended to match.objectstack-fleet commentedon Nov 24, 2026
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-knowledgeKnowledgeService.searchtoday 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 changessearchso an adapter refusal surfaces as a refusal, with a pin; its claim declares that file besidepackages/plugins/knowledge-*.objectstack-fleet commentedon Nov 24, 2026
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.
beginBuild/completeBuild,indexStatus, the recipe hash, withIEmbedder.modeland the descriptor'smodelanddimensions) 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, withknowledge-memoryas the reference. If this card is first, it carries all of item 8 and its suite cases (including one holdingbeginBuildandcompleteBuildas a pair).IKnowledgeService.searchreports the refused sources (this card, or a card split from it for the service's lane).catchinKnowledgeService.searchmust let a coded refusal through, so this card's surface includespackages/services/service-knowledge/src/knowledge-service.ts.objectstack-fleet commentedon Nov 24, 2026
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.
reindexSourcenow 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$gtcould 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.