Repository navigation
feat(knowledge): knowledge-pgvector, an open vector store on PostgreSQL, and the index fingerprint (#37100) - #37337
Conversation
…ases, tool names refused sources
📓 Docs Drift CheckThis PR changes 5 package(s): 31 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b14edb5aa095c01543b5b52dfd2a317adb16b76b && git checkout b14edb5aa095c01543b5b52dfd2a317adb16b76b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7f62348dfa501bb41c67c20617a0b3bb5ed9931b 065c98ff72750a8bc8f2247bed8f91a1bbb116e3 && git checkout -B drift-repro 7f62348dfa501bb41c67c20617a0b3bb5ed9931b && git merge --no-ff 065c98ff72750a8bc8f2247bed8f91a1bbb116e3
node scripts/docs-audit/affected-docs.mjs --json 7f62348dfa501bb41c67c20617a0b3bb5ed9931b
|
… the package's tests
…hRefusals; memory delete reads a typed map
…mentation they wrap
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 维护者速读
席位核对REWORK — the contract members are the ones ADR-0161 K8 accepted and are additive-safe, but five items are open at this head: two defects in the store's refusal path, a merge of Head-sha: Read whole: 45 files, +3495 / -94, nine commits on 形态
门禁 check-runs (at
逐项核对与消融 (12 single-change ablations, tree restored each time)
完成标准对卡 (#37100, ten items, six acceptance lines)
CI 改动 (
逐句核的散文面
接受的偏差
范围外去向
落地条款
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Findings open at this head: five must-fix (three above; the false changeset export; the CI reading of the live suites at the landing head), eight should-fix (seven above; the inverted database precedence in the prose faces), six nits (four above; two prose sentences in the seat section). Implemented-by: VERDICT: FAIL |
…pgvector hits carry docHash and headingPath Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbX5BF433x8ooJNQVRp
… exact clear-the-source SQL, no adoption of leftovers, operator text kept from callers - search resolves the embedder before comparing fingerprints: no embedder is 503, never a 409 on a healthy index - the clear-the-source remedy is exact statements (each passage table, then the generation row); a first generation deletes passage rows left behind as it opens - refusal messages are one caller sentence; driver text and SQL travel in the error's remedy (healthCheck, boot warning, reindex result, log); an unreachable database is no longer reported as a missing extension - an unchanged passage whose row a concurrent write removed is planned again, not lost - the plugin reads the kernel embedder at each call and sets a connect timeout - service: reindex results carry the remedy; a source refused in the refill round is dropped whole; the chunk target is read once per search; indexExpectation exported - docs, README, changeset and contract TSDoc corrected (url precedence, generation key, shared-database schema) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbX5BF433x8ooJNQVRp
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 维护者速读
席位核对REWORK — the round-1 fix list (PR comment 7172706810) is closed at this head except for one path of its first item, found on re-read; the checks at this head are still running. One small item, then a delta read. Head-sha: Delta review: two commits on 形态
门禁 check-runs (at
逐项核对与消融 (6 single-change ablations at this head, tree restored each time)
逐句核的散文面 (delta sentences)
还开着的
接受的偏差 (round 1's stand; added this round)
范围外去向 (unchanged)
落地条款
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Findings open at this head: no must-fix in the code; one should-fix; three nits, accepted. The CI reading of the live steps is carried as a landing clause. Implemented-by: VERDICT: FAIL |
…he remedy convention stated once - listDocuments asks for the embedder before comparing fingerprints: no embedder is 503, never a 409 with clearing statements - clearSql always includes the width the generation records, so a failed catalogue read never prints the generation row alone - the contract states the coded-refusal remedy convention once, on IKnowledgeAdapter - a service case pins that a remedy reaches the warn log and never refused[].message or the thrown message Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbX5BF433x8ooJNQVRp
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 维护者速读
席位核对ACCEPT — the one item of the round-2 record (PR comment 7174494844) is closed at this head and pinned, its three nits with it, and nothing else moved. Landing waits for the checks still running and for the Tier H approval, on the terms in the landing clause. Head-sha: Delta review: one commit on 形态
门禁 check-runs (at
逐项核对与消融 (2 single-change ablations at this head, tree restored)
逐句核的散文面 (delta sentences)
接受的偏差 (unchanged)
范围外去向 (unchanged)
落地条款
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
No must-fix, no should-fix. The CI reading of the live steps is a landing clause, not a finding in the code. Implemented-by: VERDICT: PASS |
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U Hand-off for approval (Tier H,
|
knowledge-pgvector and the index fingerprint landed on main (#37337). searchWithRefusals validates the scope first, filters the admitted sources by the scope and then by groupBy, and planSearches carries each source's terms beside its fingerprint: searchRound hands the adapter both `index` and `scope`. SearchTarget declares the terms, and sourcesGroupableBy keeps the type of what it filters. The suite, the stubs, knowledge-memory and the protocol sample declare both the generation keys and `scope`. Claude-Session: https://claude.ai/code/session_01JQwxbZmjM1KubX3ZAoJPPm Co-authored-by: Claude <noreply@anthropic.com>
knowledge-pgvector landed first (#37337), so it implements the scope as every in-tree adapter that runs the suite does (#37308 item 4). The terms are a union in the same inner WHERE as the organization filter, before ranking: a record term on source_record_id, a metadata term on the stored jsonb value of its field (a string or number equal to an id as text, or a list with such an element; anything else holds for nothing). Ids and field names go as bound parameters. A scope with no term that has ids ranks nothing. The live contract run declares implements.scope, so the suite's record-term, metadata-term and service-level parent cases run against PostgreSQL. Claude-Session: https://claude.ai/code/session_01JQwxbZmjM1KubX3ZAoJPPm Co-authored-by: Claude <noreply@anthropic.com>
Fixes #37100
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
New package
@objectstack/knowledge-pgvector(Apache-2.0) —KnowledgePgvectorPluginregistersPgvectorKnowledgeAdapter(idpgvector).os_knowledge(optionschema):knowledge_generation(source_id, generation, fingerprint, recipe_hash, dim, model, state, created_at) and one passage table per width,knowledge_vec_dWIDTH(source_id, generation, chunk_id, document_id, source_record_id, organization_id, content, title, heading_path, doc_hash, chunk_hash, metadata jsonb, embedding vector(WIDTH)). Object tables live in the connection'scurrent_schema(), and the driver's introspection /os migrate planread only that schema, so these tables can neither collide with an object table nor be reported as drift.urloption, elseOS_DATABASE_URL/ legacyDATABASE_URLwhen it ispostgres://; its ownpg.Pool(poolMax, default 4;connectTimeoutMs, default 5000, so an unreachable host does not hold boot). Every embed runs before a connection is checked out for the write. The kernel's embedder is read at each call, never cached. Two deployments sharing one database set their ownschema(README). With per-organization databases the store is still the one database the plugin connects to; isolation is theorganization_idcolumn, filtered in SQL.vectorextension and no right to create it, or no right to create the schema): nothing is created past the failing step, the plugin still registers, boot continues,healthCheckanswersok: falseand the boot warning carries the SQL, every call answers503 SERVICE_UNAVAILABLE; the next call retries (no restart). An unreachable database is diagnosed as unreachable, with no SQL.messageis one sentence (no driver text, SQL or schema name). Operator text travels in the error'sremedy, shown byhealthCheck, the boot warning, a reindex result and the service'swarnlog — never inrefused[].messageor a thrown search refusal. The contract TSDoc ofbeginBuildstates this convention.vectortype (no HNSW, so 3072 dims work); organization filter and metadata-equalityfilterin the sameWHERE, beforeORDER BY distance LIMIT topK; a passage with cosine similarity not above 0 is not a hit. Hits carry the storeddocHash(K8 item 3, read by service-knowledge: search returns records, not chunks — granularity and groupBy #37103's record-level freshness check) and the passage'sheadingPath(item 14).queryPrefixoption is prepended to queries only.capabilities.chunks);chunk_hashper passage; an unchanged passage is not re-embedded (row metadata rewritten, the UPDATE checked for its row: one removed by a concurrent write makes the batch plan again, so the passage is embedded, not lost); stale chunks of a document deleted in the same transaction.listDocumentson the write-target generation, byte order (COLLATE "C") for both the order and the cursor.409 KNOWLEDGE_REBUILD_REQUIRED;beginBuildunder the stored fingerprint is a no-op, under another it is refused and itsremedy(the convention is stated once onIKnowledgeAdapter) (carried into the reindex result) is the exact statements that clear the source: oneDELETEper existing passage table, then the generation row (second-generation builds are knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101). A first generation never adopts leftovers: opening it deletes the source's passage rows left without a generation row, in the same transaction, only by the call whose insert opened it;completeBuildrecords the recipe hash;indexStatusreads both back.K8 item 8 (ADR-0161 K7), whole, as the Execution note asks
@objectstack/service-knowledge:computeIndexFingerprint(model, variant, dimensions from the adapter'sembeddingdescriptor; resolved split +SPLIT_ALGORITHM_VERSION; content recipe +ASSEMBLY_RULE_VERSION) andcomputeRecipeHash(where,metadataFields, title field +TITLE_RULE_VERSION, withheld fields), SHA-256 over sorted-key JSON, pinned byindex-fingerprint.test.ts. Every adapter call carries them (AdapterContext.index,AdapterSearchOptions.index).indexExpectationis exported. A complete reindex callsbeginBuildbefore listing or writing (refusal ⇒ok: false, nothing written, the adapter'sremedyin the message) andcompleteBuildafter the purge (a throw ⇒ok: false); a capped or dry-run walk calls neither. The repair of a stale record (service-knowledge: search returns records, not chunks — granularity and groupBy #37103'srepairStale) goes through the event-sync path, whose upsert/delete carryindex. The chunk-target setting is read once per search.@objectstack/spec/contracts:AdapterEmbeddingDescriptor.model/dimensions/variant,AdapterIndexExpectation,AdapterIndexStatus,IKnowledgeAdapter.indexStatus?/beginBuild?/completeBuild?,IEmbedder.model?. All optional.KnowledgeService.searchkeeps its signature (K9 rule 3); a source refused with a coded error (SCREAMING code + 4xx/5xx status) is dropped from the answer and logged by name; when no source answers, the refusal is thrown with its code/status andrefusednaming each source. A source that answers the first round and refuses the refill is refused for the whole search (its first-round hits dropped), so no source is both answered and named as refused.KnowledgeService.searchWithRefusalsreturns{ hits, refused };search_knowledgeaddsrefused(sources the caller can see only) when non-empty.knowledge-memoryis the reference: active + under-construction generations, switch atcompleteBuild, all flags true in its contract run.embedder-openai:modelis public and reported.implementsgainsindexStatus,builds,refusesOtherFingerprint,generationswith 9 cases (carry, fingerprint vs recipe-hash variation, build pair, status, search refusal, write refusal, through-service named/whole refusal, generation switch, rebuild after recipe change).KNOWLEDGE_REBUILD_REQUIREDregistered in the error-code ledger under service-knowledge (the suite asserts it), knowledge-memory and knowledge-pgvector; generated references regenerated.CI (Tier H —
.github/workflows/ci.yml):Temporal Conformancenever runs onpull_request; it runs on the full battery and, for an entry whose diff hits thetemporal_livepaths (this one does), in the merge queue, where it is advisory, not a required check. No existing step ofTemporal Conformance (live PG + MySQL)runs this package, so two steps are added after the runtime leg (build@objectstack/knowledge-pgvector..., thenvitest run live-postgreswithOS_TEST_POSTGRES_URLandOS_EXPECT_LIVE_DIALECT_MATRIX=1, so a missing server is red, never a skip);service-knowledge/src/testing.tsjoins thetemporal_livemerge-queue paths; the build-step count comment says five. The job's image is already pgvector's (#37095).Why
Card #37100 (ADR-0161 Execution row 8a): the open, self-hosted vector store, and the fingerprint that keeps two models' vectors from ever being ranked against each other.
Open question
searchWithRefusalsis a class method ofKnowledgeService, not a member ofIKnowledgeService(K9 rule 3 keepssearch's signature and return type).search_knowledgereads it structurally. Options: (A) keep it on the class (this PR); (B) add an optionalIKnowledgeService.searchWithRefusals?member in a follow-up with its own K9 dated note. Recommendation A until a second consumer needs it.Deviations from the card
titleandheading_pathcolumns beyond the card's list: hits return the document title and, since service-knowledge: search returns records, not chunks — granularity and groupBy #37103 landed, the passage'sheadingPath.recipe_hash(K8 item 8 c).Tests
At head
065c98ff(main merged at83fef223, after #37335 landed as38017753):@objectstack/knowledge-pgvector, live, against the CI job's own image (mirror.gcr.io/pgvector/pgvector:0.8.7-pg16@sha256:484e8380…, run locally in Docker), the CI step's exact command (pnpm --filter @objectstack/knowledge-pgvector exec vitest run live-postgres,OS_EXPECT_LIVE_DIALECT_MATRIX=1):Test Files 3 passed (3),Tests 47 passed (47)(contract suite 34, acceptance 11, real-driver reindex 2). The whole package against PostgreSQL 16 + pgvector 0.6:Test Files 4 passed (4),Tests 57 passed (57)(the above plus 10 unit cases; one of them now also pinslistDocumentsanswering 503 with no embedder).@objectstack/service-knowledge:Test Files 12 passed (12),Tests 315 passed (315)(one case pins that a refusal'sremedyreaches thewarnlog and neverrefused[].messageor the thrown message).@objectstack/knowledge-memory:46 passed.@objectstack/embedder-openai:31 passed.typecheck(source and tests) green for all four; eslint clean.Ablations of the review fixes (one-shot, each restored; each fails exactly one case)
beginBuildignored by the service: the service stub "stops before any listing or write" case fails.completeBuildswallowed: the service stubok: falsecase fails.listDocumentscompares before resolving the embedder: the not-ready no-embedder case fails; the service hands theremedyto the caller: the remedy-boundary case fails.Earlier ablations (organization filter, chunk-hash skip, search fingerprint check) and the docHash/headingPath ablation (3 suite cases fail) are unchanged.
Local derived gates (dispatch-gates --commands, 167 commands)
At
7027f457: 166 exit 0 (the round-2 delta at065c98ffre-ran typecheck, eslint, api-surface, spec docs, engine-double, tenant-audit and system-context censuses: all green). One NOT MEASURED (exit 3, a prerequisite refusal left to CI):check-plugin-teardown-shape --self-test(needs a full clone). The push hook's commit-trailer check is green (the two new commits carry the model-free trailer pair).Acceptance notes
acceptance.live-postgres.test.ts— stores and ranks 3072-wide vectors (column type read back asvector(3072))acceptance…two organizations case; service: contract suite organization cases underisolated/groupnot-ready.test.ts(adapter refusal text, healthCheck false, plugin start resolves and warns, recovery after the SQL runs)acceptance…unchanged passage case (adapter) and second complete reindex case (service)acceptance…changed embedding model case through the service;acceptance…printed statements run as printed, and a first generation that never adopts rows left behind (L1 must-fix 2)contract.live-postgres.test.tsin the new Temporal Conformance stepreindex-real-driver.live-postgres.test.ts— 227 records over 3 walk pages, each indexed once, second reindex writes and embeds nothingVerification
Two-minute check:
OS_TEST_POSTGRES_URL=postgres://… pnpm --filter @objectstack/knowledge-pgvector exec vitest runagainst any PostgreSQL with pgvector available — expectTest Files 4 passed,Tests 57 passed.CI evidence for the two new live steps: the relay lets a seat dispatch no
ci.ymlrun, so the reading above (the CI image by digest, the step's exact command) stands in for it. A maintainer who wants it in CI can runci.ymlbyworkflow_dispatchon this branch; the job is advisory in the merge queue either way.Read first:
packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts(upsert,search,ready),packages/services/service-knowledge/src/knowledge-service.ts(walk build calls,searchWithRefusals),.github/workflows/ci.yml(the two new steps).Overlap: #37335 (#37103) landed first; main is merged here (
83fef223), keeping both intents inknowledge-service.ts(record-level answers and freshness repair from main, the refusal report from here),testing.tsandknowledge-memory/src/index.ts.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code