Skip to content

perf(knowledge): embed the search question once per search, the refill round included - #38798

Merged
objectstack-fleet[bot] merged 11 commits into
mainfrom
claude/project-thread-cxx7uu
Dec 1, 2026
Merged

objectstack-fleet[bot] merged 11 commits into
mainfrom
claude/project-thread-cxx7uu

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #38676

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 员工在知识库里搜索、且需要补查第二轮时(例如按单位分组或权限复查后命中不足),问题现在只生成一次向量;以前补查轮会再请求一次嵌入服务(DashScope 约 200 毫秒),搜索结果本身不变,运维和管理员无感。
  • 这是“知识检索慢”那张卡的第三个原因(补查轮重复生成问题向量);前两个原因已在之前的改动里修好,这次按你选定的“写进约定,一次提问只转一次”收尾。
  • 若出错,碰到的是搜索知识库的员工:最坏情况是某个知识源这次搜索被拒答并写明是哪个来源,不会静默答空;“需要重建索引”这类提示照旧排在前面,不会被嵌入服务的报错盖掉;改动可以直接撤回。
  • 无。

What changes

The question of one knowledge search is embedded at most once for each adapter instance, by the adapter, and the knowledge service carries it back to every search call of that search, the refill round included. Built to the ADR-0161 dated note of 2026-12-01 under K8 (ruling record 7296268226 on the card, with its condition: an adapter's own refusal stays ahead of the embed).

  • Contract (@objectstack/spec/contracts): IKnowledgeAdapter gains an optional embedQuery(query), which embeds a question exactly as that adapter's search does (its embedder, its query prefix); it takes no source. AdapterSearchOptions gains an optional queryVector, typed as a function of no arguments answering a promise of a read-only number array (() => Promise, answering readonly number[]). It is the function, not the vector. Both docblocks cite the note and no longer say the knowledge service embeds. Both members additive and optional.
  • Service (knowledge-service-search.ts, knowledge-service-top-level.ts): planSearches gives every target whose adapter instance has embedQuery one slot per instance for the whole search (SearchQuestion). The first searchRound call to that instance puts one memoised function in it (memoisedQuestion): its first call asks the instance's embedQuery for the query, and every later call in that search answers the same promise, a rejected one too. That one function is handed on every search call to that instance in that search. The service no longer embeds ahead of search, no longer judges whether a call embeds (the earlier keyword and "round ranks nothing" guards are gone) and reads no vector. A rejection is embedQuery's own error, never wrapped.
  • knowledge-turso, knowledge-pgvector: each calls the handed function at the exact line where its search embeds the query today, in place of that call, after every gate it runs first (nothing to rank, store and embedder present, ready, active generation, the fingerprint and width refusal KNOWLEDGE_REBUILD_REQUIRED, topK, the mode, keyword). Absent: it embeds as before, through its own embedQuery. The width check is unchanged, and the answered array is never changed. A failed embed therefore fails inside search, where it failed on main, with main's code and wording (pgvector's searchRefusalOf included).
  • Contract suite (@objectstack/service-knowledge/testing): an optional implements.embedQuery declaration, checked against the adapter, and one case for it (below). knowledge-turso and knowledge-pgvector declare it.
  • Docs: §3.4 of content/docs/protocol/knowledge.mdx is rewritten to the note: the function type, where the adapter calls it, what costs no embedding call, and the suite case.
  • An adapter without embedQuery (for example knowledge-memory) is handed nothing and searched exactly as before.
  • main merged first (9e729ceaad). fix(service-knowledge): a host-mounted service with no embedder answers a search 503 naming the settings to save #38817's behaviour is kept: an embedder error reaches the caller unwrapped, and its test file unconfigured-embedder-code-38775.test.ts is unchanged and green (6 of 6).

Review findings closed by this round: M1 by the note (merged as 13a0d3fedf); S1 by the suite case; S2 by the new shape and its pins (a refusal ahead of the embed is answered, with 0 embedder calls); N4 by the new shape (the embed is back inside search, so pgvector's socket wording is main's again). Nits of contract review 7290045524: N1 by the new shape (the function is handed on every call, so "every call" is literal); N2 by the new shape (an embedder that answers no vector is one embedding call, memoised, and the width check refuses it, where the earlier head made two); N3 by the new shape, wording kept: on the service's path the handed vector is what the adapter's own embedder answered, so "the embedder answered" stays true; a direct caller answers for its function (the note's second diamond).

Tests

All pins count calls; none is wall-clock.

  • packages/services/service-knowledge/src/__tests__/search-question-vector.test.ts (rewritten, 11 cases, over a fake adapter shaped as the two stores): a refilled search hands both rounds one function and calls embedQuery once; two sources of one instance, one function for four calls, one call; the function answers the same promise on every call; two instances, two functions, one call each; two searches, two functions; keyword is handed the function and embeds nothing; a source the adapter refuses behind a failing embedder answers its 409 with 0 calls; no embedQuery, nothing handed; an uncoded embed failure fails the call that asked (503 platform sentence, text to the operator line); a coded one reaches the adapter as the same error object and keeps code and message; a failed embed is shared (one call, both sources refused).
  • packages/plugins/knowledge-turso/src/__tests__/acceptance.test.ts (one top-level describe, 6 cases, real adapter behind KnowledgeService): refilled search, one embedder call, prefixed; refilled search over two sources of one instance, one call; keyword, 0 calls; a source that needs a rebuild (embedder model changed) behind an embedder that fails answers KNOWLEDGE_REBUILD_REQUIRED 409 with 0 embedder calls; the control, the same failing embedder behind a healthy source, called once and refused 503; a handed function is ranked with, a function of another width is refused.
  • packages/plugins/knowledge-pgvector/src/__tests__/question-once.test.ts (new, 5 cases, real adapter and KnowledgeService over a fake pool): the same four pins as turso (the rebuild-required source is an index held under another fingerprint) and the same control.
  • packages/plugins/knowledge-pgvector/src/__tests__/retrieval-modes.test.ts (3 cases, adapter alone): embedQuery embeds the prefixed query; a handed function is asked once and its answer is bound into the ranking statement, embedder not called, with a control; another width is refused.
  • packages/services/service-knowledge/src/testing.ts#runKnowledgeAdapterContract, one case, run only for implements.embedQuery: handed a function answering its own embedQuery, a search answers what it answers without the member and makes no embedding call of its own; handed one answering a vector of another width (wider, then narrower), the search rejects. The count is a spy on the instance's embedQuery (review 7297709290 N1), with a control (the search without the member is seen by the spy once). It asserts a rejection, not a code (N2); no code is added.
  • packages/plugins/knowledge-pgvector/bench/instrument.test.mjs: unchanged since 56feee7fa7, still one embed for a refilled search.
Ablation (each through scripts/ablation-replace.mjs; landing and restore proven by blob hash, git diff HEAD empty after each)
  • The service calls the function ahead of search (the earlier head's order): service 6 failed of 11; turso 2 failed of 6 (keyword, rebuild-required); pgvector 2 failed of 5 (keyword, rebuild-required).
  • The function not memoised: service 5 failed of 11; turso 2 failed of 6 (refilled, two sources); pgvector 2 failed of 5 (refilled, two sources).
  • knowledge-turso ignores the handed function: the contract case fails on both libSQL cells (2 of 2).

Every pin goes red under at least one ablation. The keyword pins also hold on main and on the earlier head: they guard the order, not the count.

Runs at e434583
  • pnpm --filter @objectstack/service-knowledge exec vitest run: Test Files 31 passed (31), Tests 896 passed (896).
  • pnpm --filter @objectstack/knowledge-turso exec vitest run: Test Files 6 passed (6), Tests 335 passed (335).
  • pnpm --filter @objectstack/knowledge-pgvector exec vitest run: Test Files 10 passed, 10 skipped (20); Tests 75 passed, 117 skipped (192). The live-PostgreSQL files skip here (no pgvector server in this container), so the contract case on pgvector is NOT MEASURED locally: CI's live cell runs it.
  • pnpm --filter @objectstack/knowledge-memory exec vitest run src/__tests__/contract.test.ts: 54 passed (the suite change, an adapter without the member).
  • typecheck of spec, service-knowledge, knowledge-turso, knowledge-pgvector: exit 0, test layers included.
  • pnpm --filter @objectstack/spec build then check:generated: all 14 generated artifacts up to date.
  • eslint over the changed source and test files: exit 0.
  • Derived gates (dispatch-gates.mjs --commands, 117 families): 116 exit 0, 1 NOT MEASURED (check:dual-build-cjs-loads, exit 3: needs every package built); --ran: 117 derived, 116 run, 1 NOT-MEASURED, 0 UNRUN.

Acceptance notes

  • The earlier head's note that a source with no built index cost one embed per search is gone: the adapter now asks only past its own gates.
  • One embed serves every source of one adapter instance, so a failed embed refuses each source of that instance that asked, with the same error, where on main each made its own attempt (the note says so).
  • The contract case counts by a spy on embedQuery, so it reads an adapter whose search embeds the query through that method, as both stores do; one that embeds by another path fails the case's control, and the suite's docblock says so.
  • knowledge-memory has no embedQuery and still embeds on every call; adding it there is outside this card.

Verification

Read first, by risk:

  1. packages/services/service-knowledge/src/knowledge-service-search.ts: memoisedQuestion and the queryVector lines at the top of the loop in searchRound. Risk: a call of the function there, ahead of search, would undo the condition.
  2. packages/plugins/knowledge-turso/src/turso-adapter.ts and packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts: the one changed line where search embeds. Risk: it must stay after every refusal above it.
  3. packages/spec/src/contracts/knowledge-adapter.ts: the two members and their docblocks (the contract text).

Two-minute check: pnpm --filter @objectstack/knowledge-turso exec vitest run src/__tests__/acceptance.test.ts -t 'embedded at most once' prints Tests 6 passed; the fourth case asserts a 409 with 0 embedder calls behind a failing embedder.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h

…he vector to every round

The knowledge service now embeds a question at most once per adapter per
search, through the adapter's new optional embedQuery, and hands the vector
to both the first round and the refill as AdapterSearchOptions.queryVector.
turso and pgvector implement embedQuery and rank with a handed vector instead
of embedding again. A keyword search embeds nothing; an adapter without
embedQuery embeds on every call, as before.

Claude-Session: https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 4 package(s): @objectstack/knowledge-pgvector, @objectstack/knowledge-turso, @objectstack/service-knowledge, @objectstack/spec, touching 16 documentable anchor(s).

5 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/knowledge-rag.mdx (via sourceId (literal, a string literal in binding))
  • content/docs/api/data-api.mdx (via sourceId (literal, a string literal in binding))
  • content/docs/automation/flows.mdx (via sourceId (literal, a string literal in binding))
  • content/docs/kernel/runtime-services/sharing-service.mdx (via sourceId (literal, a string literal in binding))
  • content/docs/protocol/knowledge.mdx (via AdapterSearchOptions (symbol, a top-level interface), IKnowledgeAdapter (symbol, a top-level interface), embedQuery (symbol, a field of interface KnowledgeAdapterContractOptions; a method of class PgvectorKnowledgeAdapter; a method of class TursoKnowledgeAdapter; a method of interface IKnowledgeAdapter), runKnowledgeAdapterContract (symbol, a top-level function), embedQuery (literal, a string literal in runKnowledgeAdapterContract), sourceId (literal, a string literal in binding))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v18/18-0.mdx (via sourceId (literal, a string literal in binding))
  • content/docs/releases/v18/18-4.mdx (via sourceId (literal, a string literal in binding))
  • content/docs/releases/v18/18-6.mdx (via sourceId (literal, a string literal in binding))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 183 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 13a0d3fedf45a0d47630e8aa16aaa7d22591795c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 1ddba5052a7ca3c86566feb443079db0d2f89733 — the merge of head e434583729f51a1ed49d6bc4c53f227bd23ea4d1 into base 13a0d3fedf45a0d47630e8aa16aaa7d22591795c, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 1ddba5052a7ca3c86566feb443079db0d2f89733 && git checkout 1ddba5052a7ca3c86566feb443079db0d2f89733
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 13a0d3fedf45a0d47630e8aa16aaa7d22591795c e434583729f51a1ed49d6bc4c53f227bd23ea4d1 && git checkout -B drift-repro 13a0d3fedf45a0d47630e8aa16aaa7d22591795c && git merge --no-ff e434583729f51a1ed49d6bc4c53f227bd23ea4d1

node scripts/docs-audit/affected-docs.mjs --json 13a0d3fedf45a0d47630e8aa16aaa7d22591795c

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 13a0d3fedf45a0d47630e8aa16aaa7d22591795c → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXfgA45f3y5YpDPT5h

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 56feee7fa7c96e7415b9a5a3379175b1ec4600f2
Local-runs: none
Scope: packages/spec/src/contracts/knowledge-adapter.ts + packages/services/service-knowledge/src/knowledge-service-search.ts, packages/services/service-knowledge/src/knowledge-service-top-level.ts, packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts
Security-touching: no
Rule-change-verified: none

Rendered by an isolated review sub-agent of this seat's thread; the seat adopts it as written. PR #38798, card #38676 (cause 3, route A of 7269702419). Read: the card body and its comments, the PR body and file list, the net diff against main (merge base 2fba83493b, 10 files, +406 / -11), and the check-runs on this head. The rest of the diff (three test files, the bench pin, the changeset) is the lane seat's ACCEPT at TIER_DEFAULT.

① Derived judgments

  • IKnowledgeAdapter.embedQuery?(query): a new optional method on a published contract (@objectstack/spec/contracts). Additive: right as a widening. As an adapter-contract member it is wrong on this head: see M1.
  • AdapterSearchOptions.queryVector? (readonly number[]): a new optional key. Additive: right as a widening. Wrong on this head for the same reason: M1.
  • Accept set: no Zod schema, no metadata key, no accepted value moves. Metadata-protocol: none is right.
  • TursoKnowledgeAdapter.embedQuery and PgvectorKnowledgeAdapter.embedQuery: one new public method on each published class. Additive: right.
  • SearchTarget.binding gains the optional question slot; the type is not exported from the package entry: internal, right.
  • Behaviour stated by the PR body: one embed per adapter per search; a failed embed refuses every source of that adapter in the search; a source with no built index costs one embed where it cost none. Right as stated.
  • Behaviour the PR body does not state: the embed precedes every other gate of the adapter's search, and it decides the refusal when both fail: S2.
  • Gates on this head: the test and type-check families were cancelled by the push of 4561e81d0e (prose only, content/docs/protocol/knowledge.mdx) and carry no verdict here; the aggregates TypeScript Type Check and Lint & Repo Gates failed only on those cancelled lanes.

② Semver level

  • .changeset/38676-embed-question-once.md: patch on @objectstack/spec, @objectstack/service-knowledge, @objectstack/knowledge-turso, @objectstack/knowledge-pgvector, the four packages whose src moves. AGENTS.md working rule 3: none takes patch, a non-protocol widening ships patch. Right.
  • Clause-②: yes (widening) and Metadata-protocol: none on the PR body and the changeset alike. Right.

③ Boundary flags

  • Open question of report 7269683344 (where cause 3 lives): answered A by the seat in 7269702419 as "an implementation route, not a maintainer decision". The route adds adapter-contract members, and ADR-0161 K8 rule 5 closes that list. Not answered by any ruling; escalated as M1.
  • Open question of report 7289640633 (the pgvector bench pin): answered A in 7289673906; the pin moved at this head. Answered.
  • Deviation, knowledge-service-top-level.ts edited: admitted in 7289673906. Answered.
  • Out-of-scope note, docs do not describe the members: true at this head; the later head 4561e81d0e edits §3.4.
  • Out-of-scope note, "a source with no built index now costs one embed": wider than stated; graded S2.
  • knowledge-memory has no embedQuery: consistent with the contract. No action.
  • SQL push-down: no new id materialisation and no in-app join. Clean.

④ Design judgment

packages/spec/src/contracts/knowledge-adapter.ts (hits)

M1 (must-fix) — the two members are added to a closed list with no dated note on the record that closes it. ADR-0161 K8, "What counts as a member": "a method or a descriptor on IKnowledgeAdapter, and a key on AdapterContext or AdapterSearchOptions". Rule 5: "The list is closed. A member that is not in the table needs a dated note on this record first." docs/ names neither member at this head, and every other member of the file cites its item or note where these two cite none. Three readings are open and the note is where they are decided:

  • K1, the adapter's row "Embedding calls": "When to call, how to batch, and whether to call at all … are the adapter's." With embedQuery the service decides when the query is embedded, including for a search the adapter would have answered or refused without a call (S2). The docblock's "The knowledge service embeds a question once per search" also stands beside K1's "The service does not … compute a vector". Item 15 ("The adapter embeds, so it knows a query from a passage") is read with it.
  • The shape takes no source and no context: one vector serves every source the search binds to the adapter instance. An adapter whose query embedding depends on the source cannot implement it truthfully, and the docblock does not say so.
  • A handed vector is checked for its width alone; model identity rests on AdapterSearchOptions.index.fingerprint, which a call outside the service does not carry.
    docs/adr/** is Tier H; the note lands by that tier's record, and the docblocks then cite it.

S1 (should-fix) — K8 rule 1: "A member lands with its first reader, in the same PR, and with a case in the contract test suite." packages/services/service-knowledge/src/testing.ts#runKnowledgeAdapterContract has no case for either member at this head; the behaviour is pinned only in each adapter's own tests. One suite case covers it: an adapter with embedQuery, handed its own vector as queryVector, answers what it answers without it, does not call its embedder for the query, and refuses a vector of another width.

Against the scenario accepted (cause 3: a refilled search embedded twice): the member pair removes the second embed, and searchRound reads both members. Held.

packages/services/service-knowledge/src/knowledge-service-search.ts

S2 (should-fix) — the embed now runs before every gate the adapter's search runs ahead of its own embed (store or pool present, embedder present, ready(), an active generation, the fingerprint and width check KNOWLEDGE_REBUILD_REQUIRED, topK, the mode check). A source in any of those states now sends the question to the embedding provider on every search, where it sent nothing; and when the embed throws and one of those gates would have refused, the caller reads the embed's refusal (SERVICE_UNAVAILABLE 503) where it read the gate's (KNOWLEDGE_REBUILD_REQUIRED 409, with its remedy). Plain case: an embedder setting saved with another model and a wrong key moves the fingerprint and fails the embed together. It closes either by the note and the docblock saying so, with a pin, or by keeping the adapter's refusal ahead of the embed.

The rest agrees with the contract sentence by sentence: one slot per adapter instance per planSearches call, filled with ??=; the slot only for a mode that is not keyword; the refill searches the same target objects and so the same slot; the await sits inside the try of adapter.search, a rejected promise is awaited by each later source, none unhandled, and a source refused in the first round is never refilled; the vector goes back only to the instance that made it, and no caller of IKnowledgeService.search can hand one. Tried and held: a vector from one adapter reaching another; another width; another model at the same width after an embedder swap between rounds; a generation switch between rounds; two sources on one adapter under different prefixes; a keyword source beside a hybrid one on one adapter; an adapter that mutates the array (readonly).

N1 (nit) — the queryVector docblock says the service "hands the vector to every call it makes for that search"; a round that ranks nothing is handed none.

N2 (nit) — if the embedder answers no vector, the slot resolves to undefined, the adapter embeds again and refuses "missing-wide": two calls where main made one.

packages/services/service-knowledge/src/knowledge-service-top-level.ts — the slot's docblock agrees with the code. No finding.

packages/plugins/knowledge-turso/src/turso-adapter.ts — embedQuery is the line searchAttempt held on main; present vector ranked with and width-checked, absent embedded as before, keyword never reads it, the generation-switch retry re-checks fingerprint and width. Agrees.

N3 (nit) — a handed vector of another width is refused with "the embedder answered a N-wide query vector" (operator line only).

packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts — same shape as turso; agrees. N3 applies.

N4 (nit) — on main the query embed ran inside search's try and passed searchRefusalOf; now it runs in embedQuery, outside it. For an embedder error carrying a Node socket code and syscall, the wording changes from the pool sentence to the service's; code and status stay SERVICE_UNAVAILABLE 503.

M1 fails the round. M1, S1 and S2 each earn a delta review of their fix.

Implemented-by: claude/project-thread-cxx7uu
Reviewed-by: session_01JQwxbXfgA45f3y5YpDPT5h

VERDICT: FAIL

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXfgA45f3y5YpDPT5h

CI note on head 4561e81d0e: Type Check · workspace (and its aggregate TypeScript Type Check) failed because the runner was shut down mid-job ("The runner has received a shutdown signal", job 142131462578), not on a type error. The relay does not re-run lint.yml, and this PR is parked while #38676 waits on the maintainer's decision (contract review 7290045524), so the next push after that decision runs the full set again.

…ls where it embeds

The knowledge service no longer embeds the question ahead of search. It
hands every search call to an adapter instance that has embedQuery one
memoised function per instance per search; turso and pgvector call it at
the line where they embed today, after every refusal they answer first
(ADR-0161, the dated note of 2026-12-01 under K8).

Claude-Session: https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h
Co-authored-by: Claude <noreply@anthropic.com>
…ce, both stores and the contract suite

Per store: a rebuild-required source behind a failing embedder answers
KNOWLEDGE_REBUILD_REQUIRED 409 with 0 embedder calls; keyword embeds
nothing; a refilled search over two sources of one instance embeds once.
The contract suite gains one embedQuery case, wired into turso and
pgvector (ADR-0161, the dated note of 2026-12-01 under K8).

Claude-Session: https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h
Co-authored-by: Claude <noreply@anthropic.com>
…s the per-search function

Claude-Session: https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l and removed size/m labels Dec 1, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXfgA45f3y5YpDPT5h

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: e434583729f51a1ed49d6bc4c53f227bd23ea4d1
Local-runs: none
Scope: packages/spec/src/contracts/knowledge-adapter.ts + packages/services/service-knowledge/src/knowledge-service-search.ts, packages/services/service-knowledge/src/knowledge-service-top-level.ts, packages/services/service-knowledge/src/testing.ts, packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts
Security-touching: no
Rule-change-verified: none

Delta review, rendered by an isolated review sub-agent of this seat's thread. PR #38798, card #38676 (cause 3, phase 1 of ruling 7296268226). It follows record 7290045524 (FAIL at 56feee7fa7) and record 7297709290 on PR #38812 (the note, PASS).

Read:

  • the card body and all 24 comments, with ruling 7296268226 and dev report 7302286394;
  • the ADR-0161 note of 2026-12-01 under K8 and its K1 cross-reference on main at 13a0d3fedf, with K1, K8 rules 1 to 5 and item 15;
  • the PR body, the file list (15 files, +791 / -14 against merge base 13a0d3fedf), the net diff, and the diff 4561e81d0e..e434583729 without what the merge of main brought;
  • the check-runs on this head.

The test files, the changeset and the docs prose were read only to judge; they are the lane seat's ACCEPT.

① Derived judgments

  • AdapterSearchOptions.queryVector? is now a function of no arguments answering a promise of readonly number[]. It is the type the note's first ◆ bullet fixes. Right.
    • Against main it is a new optional key, so it is additive.
    • Against this PR's earlier head (the vector itself) the type changed. Neither main nor a released package ever carried the member, so no published reader breaks.
    • It is the first function-valued key on the options. The service hands it only to an adapter that has embedQuery, so an older adapter that clones or serialises its options never receives a function.
  • IKnowledgeAdapter.embedQuery?(query: string), answering a promise of number[]: unchanged since the earlier head, and the note's signature. Right.
  • TursoKnowledgeAdapter.embedQuery and PgvectorKnowledgeAdapter.embedQuery: one public method on each published class. Additive. Right.
  • implements.embedQuery?: boolean on runKnowledgeAdapterContract (@objectstack/service-knowledge/testing): a new optional suite option, absent reads false. Right.
    • The declaration check now compares it with typeof adapter.embedQuery.
    • Only an adapter that adds the new method has to declare it, so no existing caller of the suite goes red.
  • SearchQuestion and SearchTarget.binding.question: internal. The package entry index.ts exports neither. Right.
  • Accept set: no Zod schema, metadata key, tool argument or settings key moves, and IKnowledgeService.search is untouched. Metadata-protocol: none is right.
  • Behaviour against main, each as the note states it and as the PR body and changeset repeat it. Right.
    • At most one embedding call for each adapter instance in a search.
    • An adapter's own retry after a generation switch reads that one call.
    • A failed embedding call is shared: each source of the instance that asks is refused by it, where main gave each call its own attempt.
  • Gates on this head, read 2026-12-01T06:02Z: 78 check-runs, 64 success, 14 skipped, 0 failed, 0 running.
    • Success: Test Core (12 of 12 shards), TypeScript Type Check, Lint & Repo Gates, Build Core, Governed Surface Queue Guard, Check Changeset and PR-body guards (both runs of each), Spec property liveness.
    • Skipped, so no verdict: Temporal Conformance (live PG + MySQL), the live-PostgreSQL lane (see ③).
    • The other 13 skips are opt-in jobs, queue-only verdicts, the schedule gate, UI path filters, matrix placeholder rows, and the second Auto Label and Check PR Size runs from the body edit.

② Semver level

  • .changeset/38676-embed-question-once.md is patch on @objectstack/spec, @objectstack/service-knowledge, @objectstack/knowledge-turso and @objectstack/knowledge-pgvector. Those are the four packages whose src moves. Under AGENTS.md working rule 3, Metadata-protocol: none takes patch and a non-protocol widening ships patch. Right.
  • Clause-②: yes (widening) is on the PR body and the changeset alike. Right, also for the member whose type changed.
    • The declaration is measured against what is published.
    • The array-typed queryVector existed only on this PR's unreleased heads.
    • Against main the member is purely added and optional, so there is no narrowing, no BREAKING banner and no ADR-0087 disposition owed.
  • Metadata-protocol: none. Right.
  • The changeset body describes the function type and the shared failure. It agrees with the tree.

③ Boundary flags

Report 7302286394 has no open question. Its deviations:

  • Model-free commit trailers: AGENTS.md prescribes that pair. Answered.
  • The shared checkout used and not removed; one gate batch moved to the background and waited for; seven packages built outside the diff for check:dts-closure: process only, no source outside the file list moved. Answered.
  • The removed service case "a round that ranks nothing embeds nothing". Answered; see N4.
    • It pinned a service-side guard that this PR's earlier head added and that the note removes ("it does not judge whether a call will embed").
    • It was never on main, so the net diff deletes no test and the deletion rule is not engaged.
    • The behaviour is now the adapters' two early returns, the first lines of each search, unchanged from main.
  • SearchTarget.binding.question changed type: internal, judged in ①. Answered.
  • The keyword pins pass on main and on the earlier head too. Answered.
    • They are preservation pins for the docblock's "Under keyword ... never call it".
    • On main no function existed. On the earlier head the service's own guard held them.
    • The dispatch order's "fails without the fix" is a rule of thumb for fix pins, and the report says which pins these are.
    • The ablation counts are the dev's and were not re-run here.
  • No HTML comment added to the PR body: answered.

Its out-of-scope notes:

  • The live pgvector contract cell does not run on pull_request events. Confirmed in .github/workflows/ci.yml: the temporal-conformance job's condition excludes pull_request, and on merge_group it runs when the diff hits temporal_live. This diff hits packages/plugins/knowledge-pgvector/** and packages/services/service-knowledge/src/**.
    • The suite case on pgvector is NOT MEASURED on this head. Its first measurement is the merge queue, where the context is required.
    • Read against pgvector-adapter.ts, the case holds. The live testkit hands the suite the class instance, so the spy on embedQuery intercepts this.embedQuery. A wider or narrower vector throws the uncoded width error, which searchRefusalOf passes on, so the search rejects.
    • Measured green on this head in Test Core: the suite case on both libSQL cells, and pgvector's condition pin and count pins over a fake pool (question-once.test.ts).
    • Answered. Nothing for the maintainer.
  • knowledge-memory has no embedQuery: this is the note's own sentence ("implements neither and is searched as before"). No action.

Further checks:

  • Security-touching: no hunk changes permission, sharing, credential, token or authentication behaviour. The question goes to the same embedder, never more often than on main, and no longer for a source the adapter refuses.
  • SQL push-down: no statement changes; no new id materialisation and no in-app join. Clean.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/contracts/knowledge-adapter.ts (hits): agrees with the note sentence by sentence.

  • Both members are optional (rule 2) and carry no configuration (rule 4). Both docblocks cite the note, and neither says the service embeds.
  • The queryVector docblock states:
    • the means: one function per instance per search, same promise on every later call, a rejected one too;
    • where to call it: in place of the embedding call, after everything decided first;
    • keyword never calls it;
    • the width check, and "never change the array";
    • the direct-caller sentence of the second ◆.
  • The embedQuery docblock states: no source and no context; an adapter whose query embedding differs from source to source does not implement it; presence is the signal.

knowledge-service-search.ts, knowledge-service-top-level.ts: agree.

  • planSearches keeps one slot per adapter instance, in a Map keyed by the instance and local to the call. It gives the slot whenever typeof adapter.embedQuery is function, with no mode judgment.
  • searchRound puts memoisedQuestion in the slot with ??= and hands it on every search call to that instance.
  • The only embedQuery call in the service is inside that closure. Nothing awaits the function or reads a vector.
  • searchRound is the only caller of adapter.search, and searchByKey passes both rounds the same query and the same target objects.

turso-adapter.ts, pgvector-adapter.ts: agree.

  • The one changed line is the line where main embeds.
  • Everything is ahead of it, in main's order:
    • the two ranks-nothing returns;
    • store or pool present, embedder present, ready();
    • the active generation (turso's legacy refusal with it);
    • the fingerprint refusal, then the width refusal, both KNOWLEDGE_REBUILD_REQUIRED 409;
    • pgvector's table check, topK zero, the mode refusal, and keyword.
  • Absent the member, each embeds through its own embedQuery, the same embedder call and prefix as main.
  • The width check and its message are unchanged.

Tried to break it; each held.

  • The function reaching another instance. The slot is found by instance identity, and the closure captures the adapter of the same binding the slot came from. One slot means one instance. Two instances get two functions.
  • A rejected promise across rounds and sources.
    • Only a call of the function can observe the rejection, so a source that never asks (keyword, rebuild-required, no active generation, nothing to rank) cannot be refused by it.
    • A source refused in the first round is absent from first, so it is never refilled.
    • The promise exists only once an adapter has called and awaited it, so no rejection is unhandled.
    • The error object is shared, never changed. codedRefusalOf copies from it. pgvector's searchRefusalOf passes a coded or non-database error on as it is, and builds a new per-source error with cause for a socket-coded one.
  • A call ahead of a gate. There is none in either store, by the order above.
  • keyword. The function is handed and never called; 0 embedding calls in both stores' pins.
  • A generation-switch retry inside search. turso's recursion and pgvector's loop re-run every gate, re-read the same promise and re-check its width against the new generation.
  • An embedder swap between rounds. The refill reads the first round's vector under the fingerprint the search planned, which is the index's.
  • The array mutated. Both stores only read it (every, and vectorLiteral, which maps). Their local is typed readonly.
  • A synchronous throw of embedQuery. The async wrapper makes it the same shared rejection.
  • fix(service-knowledge): a host-mounted service with no embedder answers a search 503 naming the settings to save #38817's unwrapped embedder error. memoisedQuestion adds no wrapper, and the rejection reason is embedQuery's own object. unconfigured-embedder-code-38775.test.ts is byte-identical to main and inside the green Test Core.
  • The condition pin. Each store has it through a real KnowledgeService, with a control:
    • a rebuild-required source behind a failing embedder answers KNOWLEDGE_REBUILD_REQUIRED 409 with 0 embedder calls (turso: the model changed; pgvector: another fingerprint);
    • the same failing embedder behind a healthy source is called once and refused 503.

testing.ts: the case is the note's.

  • It runs only under implements.embedQuery.
  • Handed a function answering its own embedQuery, the search equals the search without the member, the function is called, and the spy sees no call.
  • Handed a wider and then a narrower vector, the search rejects.
  • The count is a spy on the instance's embedQuery, with a control, and it is said in the suite docblock, the option docblock and the PR body. The width case asserts a rejection, not a code, and says so.
  • It is wired into both libSQL cells and the live pgvector cell.

Findings of 7290045524

  • M1: closed. The note merged first, as 13a0d3fedf; the branch carries it unchanged; the docblocks cite it (rule 5).
  • S1: closed. One case in runKnowledgeAdapterContract (rule 1), green on turso here and first measured on pgvector in the queue (③).
  • S2: closed. The embed is the adapter's line again, behind every gate, with the ruling's pin in each store.
  • N1: closed. The function is handed on every call, so "every call" is literal.
  • N2: closed. An embedder that answers no vector is one memoised call and a width refusal.
  • N3: closed. On every conforming path the function's answer is the instance's own embedder's, so "the embedder answered" is true; a direct caller answers for its function (second ◆).
  • N4: closed. pgvector's embed is inside search's try again, so the wording is main's.

Findings of 7297709290

  • N1: closed. The spy was chosen and named.
  • N2: closed. A rejection is asserted, no code added, and it is said.
  • Its N3 is met as written (a pin in each store). Its N4 was the approver's and is settled by the note's merge.

New nits

N1 (nit) — the suite case reads only an adapter whose search embeds through the public embedQuery, under its default mode. One that embeds by a private path, or whose default mode is keyword, fails the control while meeting the note. The option's docblock says the first half. A harness counter on the embedder would read every adapter.

N2 (nit) — the suite holds a third store to less than the member's docblock asks.

  • It does not compare the handed array after the search ("never change the array").
  • It has no refusal-ahead-of-the-embed case. Under refusesOtherFingerprint, a counting function with 0 calls would carry the ruling's condition to every store.
  • The note asks for neither in the suite.
  • The suite's delegating wrapper serviceOver forwards no embedQuery, so its service-level cases run both stores on the member-absent path.

N3 (nit) — no pin mixes, on one instance, a source that asks and fails with one that never asks (keyword or rebuild-required). The code holds it by construction. The service's shared-failure case uses two asking sources, and its refused-source case a single source.

N4 (nit) — "a search that ranks nothing" costs no embedding call in the member's docblock, §3.4 and the changeset. After the removed service case, no count pins it on the handed path. It rests on the two unchanged early returns. Also, the SearchQuestion docblock says the function is "made by the round's first call"; it is made by the search's first call to the instance.

Implemented-by: claude/project-thread-cxx7uu
Reviewed-by: session_01JQwxbXfgA45f3y5YpDPT5h

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXfgA45f3y5YpDPT5h

席位核对

ACCEPT at head e434583729f51a1ed49d6bc4c53f227bd23ea4d1 · not governed (check-governed-merges: 0 of 15 paths hit the register; 805 changed lines ≤ 3000) · Fixes #38676 (cause 3, phase 1 of ruling 7296268226)

  1. Shape: 15 files, +791 / -14 against main at 13a0d3fedf, which carries the ADR-0161 K8 note of 2026-12-01 (docs(adr): ADR-0161 dated note — an adapter embeds a search's question once, and its refusals stay ahead of the embed #38812) this PR builds to. AdapterSearchOptions.queryVector? is the per-search memoised function the note fixes; IKnowledgeAdapter.embedQuery? unchanged; turso and pgvector call the function on the one line where search embeds on main, after every gate; one runKnowledgeAdapterContract case under implements.embedQuery; docblocks cite the note; §3.4 of the protocol page rewritten; changeset patch on four packages, Clause-②: yes (widening), Metadata-protocol: none.
  2. Premise and condition: the ruling's case is pinned in each store through a real KnowledgeService: a rebuild-required source behind a failing embedder answers KNOWLEDGE_REBUILD_REQUIRED 409 with 0 embedder calls, with a control (healthy source, 1 call, 503). Refilled search over two sources of one instance: 1 call. keyword: 0 calls. fix(service-knowledge): a host-mounted service with no embedder answers a search 503 naming the settings to save #38817's unwrapped embedder error kept (its test byte-identical to main, green). Ablations (dev report 7302286394): each pin fails under at least one; the keyword pins are preservation pins, said so.
  3. Gates: check-runs on this head: 78, 64 success, 14 skipped, 0 failed. Local: 116 of 117 derived families exit 0, check:dual-build-cjs-loads NOT MEASURED (prerequisite), left to CI. Temporal Conformance (live PG + MySQL) does not run on pull_request; the suite case on pgvector is first measured in the merge queue, where that context is required.
  4. Accepted deviations: model-free commit trailer pair (AGENTS.md); the earlier head's "round that ranks nothing" service pin removed with the guard the note removed (never on main); L2 nits N1–N4 of 7302448873 (suite-case reach for a third store, mixed asking/non-asking sources on one instance, ranks-nothing count on the handed path, one docblock word) — none touches correctness or the contract.
  5. Out of scope and where it went: knowledge-memory has no embedQuery, as the note says; nothing filed.
  6. Landing: delta L2 PASS 7302448873 on this head closes M1, S1, S2 and N1–N4 of 7290045524 and N1–N2 of 7297709290. Not governed, so this seat lands it: ready, then the merge queue. Merging closes knowledge-turso 检索慢:关键词一路随向量重试重复执行、窄范围下近似检索反而比精确扫描慢、补查轮重复生成问题向量 #38676.

Contract review → comment 7302448873

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 1, 2026 06:05
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 58695bb Dec 1, 2026
79 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-cxx7uu branch December 1, 2026 06:31
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…n once, and its refusals stay ahead of the embed (objectstack-ai#38812)

<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8WwwNJsfXjR7KkaXqjQxjFx)_

Part of objectstack-ai#38676

**Update, head `a28863cef9`.** PR objectstack-ai#38809 (card objectstack-ai#38438) landed first, at
2026-12-01T03:58Z, and took the seventh and eighth `**Amended**` lines
of ADR-0161. This head merges `main` into the branch (merge commit
`a28863cef9`, no rebase): main's lines are kept as they are, this PR's
header line follows them, and its ordinal reads "a ninth dated note".
That one word is the only change to this PR's text (delta report
7300564224 on objectstack-ai#38676); the net diff against `main` is still this note
alone, +17 / -0. The gate readings and the overlap paragraph further
down are of the earlier head `f3cd7dba76`; the 21 derived gates were
re-run at `a28863cef9`, all exit 0.

This is phase 0 of the card's cause 3 and nothing else: the dated note
in ADR-0161. The card stays open for phase 1, the patch round on PR
objectstack-ai#38798, which waits for this note to merge.

Clause-②: yes (widening) — the two optional adapter-contract members the
note registers
Metadata-protocol: none

The two lines above are the claim's (comment `7296290387` on the card)
and cover both phases. This pull request changes no contract file: the
widening is what the note registers and PR objectstack-ai#38798 builds.

## 维护者速读

- 用户能看到什么变化:用户无感;只是在知识平台边界那份架构决策记录里追加一条 2026-12-01
的说明,把你当天选定的「写进约定,一次提问只转一次」和它的附带条件写成文字,不改任何代码。
-
为什么做:这是「知识检索慢」那张卡最后一项(补查时把同一个问题重复转成向量)的前置一步;平台和存储驱动之间的约定是一份封闭清单,要先在决策记录里登记这两项,已经做好的改动才能合并。
- 出错会怎样:说明里若有和你的裁决不一致的句子,接下来改代码的人会照着错的文字去做;它只是一处文档追加,可以直接撤回,不影响任何在运行的系统。
- 要你做什么:请审阅并批准这条说明;其中标了菱形记号的两处是说明自己定的写法,可以一并接受,也可以划掉。

## What changes

One file, add-only.
`docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md`
gains its ninth dated note: 17 lines added, none changed and none
removed (659 lines to 676 on `main` after objectstack-ai#38809). Three commits carry
it, the third being the merge of `main`, `a28863cef9`: `f00518e716`, the
note, and `f3cd7dba76`, a review pass over it (Acceptance notes).

**Ruling.** The maintainer chose option A for cause 3 on
2026-12-01T00:22Z: ruling record
[`7296268226`](objectstack-ai#38676 (comment))
on the card, given on analysis `7290428149`. He ruled by choosing an
option of a decision card, and the note quotes the card's words
unchanged: the option 「写进约定,一次提问只转一次」 and the condition
「附带条件:存储驱动原本会给出的拒绝提示(比如“需要重建索引”)要保持在前面,不能被转向量的报错盖掉。」 Nothing of the
ruling is opened again here.

Three insertions, in the form the six earlier notes of this record use.
Line numbers are at head `a28863cef9`.

| Lines | Where | What is added |
|---|---|---|
| 27 | Header, after the `**Amended**` line of the eighth note | A ninth
`**Amended**` line, dated 2026-12-01: the two members, the texts the
note is read with, the ruling record, the chosen option and the
condition. |
| 166 | K1, under the note of 2026-11-30 on rerank | A cross-reference:
the "Embedding calls" row, and "compute a vector" in the second sentence
of the list, are read with the new note. |
| 483 to 496 | K8, under "Rules for every member" | The note itself: an
opening paragraph, nine bullets and a last paragraph. |

What the note decides:

- **Two optional members, and the list stays closed beyond them** (K8
rules 3 and 5). `IKnowledgeAdapter.embedQuery?(query: string)`, which
answers a promise of a `number[]`, and
`AdapterSearchOptions.queryVector?`. No capability flag: the method's
presence is the signal.
- **The type of the second member.** A function of no arguments that
answers a promise of a read-only `number[]`. It is not the vector
itself. For one search the knowledge service makes one such function for
each adapter instance that has `embedQuery`. The first call of the
function calls that instance's `embedQuery`; every later call in that
search answers the same promise, a rejected one too. An adapter calls it
at the point of its `search` where it embeds the query today. This is
the per-search memoised provider the analysis recommends, and the one
choice the ruling record leaves to the note.
- **The three readings that M1 of contract review
[`7290045524`](objectstack-ai#38798 (comment))
left open.**
1. The adapter still embeds, with its own embedder and query prefix. The
service computes no vector: it carries one back to the instance that
made it, inside one search. The "Embedding calls" row of K1, the second
sentence of the list under it and item 15 of K8 stand as written.
2. One vector serves every source a search binds to that adapter
instance. An adapter whose query embedding depends on the source does
not implement the method.
3. A handed vector is checked by its width. The model is judged on the
index fingerprint, as K7 has it.
- **The condition, as an outcome.** An adapter's refusals are answered
as on `main`, code, status and remedy, and no question is sent to an
embedding provider for a source the adapter refuses. The ruling record's
case: a source that needs a rebuild behind a failing embedder answers
`KNOWLEDGE_REBUILD_REQUIRED` 409 with 0 embedder calls. The function
gives this by construction, because an adapter asks for the vector only
after everything it decides first.
- **What the members land with.** PR objectstack-ai#38798, after this note merges:
both members with their first readers in one PR and one case in the
contract test suite (rule 1). Each is optional (rule 2), and an adapter
without `embedQuery` is searched as before.
- **Not in the note.** A vector handed by a caller of the service or by
a tool argument, a memo an adapter keeps past one search, a source or
context argument on `embedQuery`, and a form that embeds several
questions at once.

No file under `packages/`, `content/`, `skills/` or `ui/` changes, and
no other ADR does. The note declares; it builds nothing.

## Why

K8 rule 5 of this record: "The list is closed. A member that is not in
the table needs a dated note on this record first." PR objectstack-ai#38798 built the
two members before the record named them, and its contract review is
FAIL on that point (M1). The ruling puts the record before the code:
this note first, then the patch round on objectstack-ai#38798.

## Tests

The diff touches no package, so there is no build closure to make and no
package test or type-check owed. What was measured, at head
`f3cd7dba76`:

- **The premise holds.** Read on `main` at `0fc9eab900`, the commit this
branch starts from. A refilled search still embeds the question twice:
-
`packages/services/service-knowledge/src/knowledge-service-search.ts:232`
is the first `searchRound` call and `:245` is the refill's.
- `:957`, inside `searchRound`, calls `adapter.search` once for each
source.
- `packages/plugins/knowledge-turso/src/turso-adapter.ts:741` and
`packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts:657` embed
the query inside that call.
- No line under `packages/`, `content/` or `docs/` names `embedQuery` or
`queryVector` (`git grep` exit 1).
- `origin/main` has since moved one commit, to `d97aaaea9a` (objectstack-ai#38802: one
skill file, one ratchet script and a changeset). It changes none of the
files read here, so each reading holds there too, and this branch merges
with it cleanly. The branch was not merged with it.
- **Quotations.** A script compared every quoted span of the added lines
with its source, read over REST or from the ADR at the base. 9 spans in
corner brackets: each is a verbatim substring of ruling record
`7296268226`. 27 spans in double quotation marks: each is verbatim in
that record, in analysis `7290428149`, in review `7290045524` or in the
ADR at the base. 0 mismatches. (The nested title "What "capabilities"
became" counts as two spans.)
- **Bytes.** The added lines hold no raw control byte, no HTML comment
and no model identifier.
- **What an adapter decides ahead of its embed**, the list in the note's
bullet on the condition, read in both stores on `main` at `0fc9eab900`:
an empty organization set, a scope with no ids and a `topK` of zero
answer no hits; the store and the embedder are present and the store is
ready; the source has an active generation; that generation holds the
searched fingerprint and the embedder's width, or the refusal is
`KNOWLEDGE_REBUILD_REQUIRED` (409, with its remedy); the mode is one the
adapter runs; and `keyword` never embeds. Each is ahead of the embed in
`turso-adapter.ts` (lines 699 to 741) and in `pgvector-adapter.ts`
(lines 581 to 657).
- **PR objectstack-ai#38798 as it stands**, read at head `4561e81d0e`: `queryVector`
is the vector itself there, a read-only `number[]`, and `embedQuery` has
the signature the note writes.
- **Anchors.** Every code citation in the note is a path with a symbol,
never a line number, and `check:adr-symbol-anchors` reads all of them
(its verdict line is below).

No ablation: the diff changes no behaviour a test pins.

## Acceptance notes

**The committed note took the function, not a plain array.** A plain
array has to exist before `search` is called, so the service would have
to embed ahead of every decision the adapter makes. A refused source
would then cost an embedding call, and a failing embedder would answer
in place of the adapter's own refusal. That is the shape review
`7290045524` graded S2, and it cannot meet the condition. The function
can, and the note names it as the means it takes.

**The review pass, commit `f3cd7dba76`.** Two sentences of the note
changed; nothing it decides moved.

1. The opening said that every statement without a diamond is the ruling
record's, the analysis's, what follows from the means, or a reading of
`main`. Some rest on review `7290045524`, on this record's own rules, on
PR objectstack-ai#38798 at its head or on the body of the card. The sentence now lists
them.
2. The signature of `embedQuery` is the one PR objectstack-ai#38798 declares at head
`4561e81d0e`. The bullet on the two members now says so.

**Two things are marked with a diamond, for the approver to accept with
the note or strike.**

- a. The means, and with it the member's type. Three points go with it
and are the note's wording: the name `queryVector` is kept though the
member is now a function; the service hands the function on every
`search` call of that search and does not judge whether a call will
embed; and a rejected promise is shared like a fulfilled one, so one
failed embedding call refuses each source that asked for the vector in
that search.
- b. One sentence added to the third reading: a caller that reaches an
adapter's `search` directly and hands the member answers for the
function, and the adapter does not verify it.

**Wording that is the note's and not a quotation**, each resting on a
text named beside it:

- The suite case is the one review `7290045524` asks for under S1,
rewritten with the function in the vector's place.
- "The condition has its own pin in each of the two stores": the ruling
record says "a pin". Each store orders its own decisions ahead of its
embed, so the note asks for the case in each.
- The English beside the card's Chinese words is a reading aid. The
Chinese is quoted unchanged.

**Overlap with an open draft on this file.** `node
scripts/pm/overlap-check.mjs --repo=objectstack-ai/objectstack`, run at
`f3cd7dba76` against `origin/main` at `d97aaaea9a`, printed `VERDICT
overlap exit 1`: `origin/main` merges cleanly, and draft objectstack-ai#38809 (the
weekly ADR revisions, second part, opened 2026-12-01T00:50Z by another
seat's thread) conflicts with this branch in this file. Both insert
header lines after line 24, and both call their first line "a seventh
dated note" (objectstack-ai#38809 adds a seventh under K7 and an eighth under
Consequences). Its two notes and this one touch no common passage.
Whichever lands second merges `main`, keeps both sets of header lines
and corrects its ordinals. Which lands first is the seats' to settle; it
is put as a question in the report on the card.

**What the note asks of PR objectstack-ai#38798, none of it done here.**

- `queryVector` changes type there, from the vector to the function, and
the service stops calling `embedQuery` ahead of `search`.
- One case in the contract test suite, and a pin in each of the two
stores for the ruling record's case.
- The docblocks cite the note and no longer say that the knowledge
service embeds.

**Text of ADR-0161 that the note is read beside. Listed for the seat,
not changed.**

- "What "capabilities" became" lists the methods whose absence is the
capability signal (listing, dropping, status, the start and end of a
build). `embedQuery` joins them by this note; the paragraph is left as
written.
- The K2 row for §3.4 of the protocol page says what the contract
carries. Its last column gives the rewrite to "each card that adds a
member", so objectstack-ai#38798 rewrites it with its code.

**Not done here.** No changeset: `docs/adr/` is published by no package.
The two earlier note pull requests on this record, objectstack-ai#38714 and objectstack-ai#38764,
each carry the `skip-changeset` label, hung in the stroke that opened
them. This one is opened with no label, as its dispatch order says, so
that label is owed by the seat, and `Check Changeset` has no exemption
until it is hung.

## Verification

**Read first, by risk.** One file changes, so these are its three places
of most risk.

1. Line 476, the bullet marked with a diamond, "The means, and with it
the member's type". It is the one decision the note makes, and it sets
what the patch round on PR objectstack-ai#38798 must build.
2. Line 480, the bullet "The condition, as an outcome". It states the
maintainer's condition and what holds when the embedding call itself
fails.
3. Line 479, the last two sentences of "The third reading": the note's
own sentence on a caller that reaches an adapter directly.

**Two-minute check.** One click: open the "Files changed" tab. Expected:
one file, +17 −0, three hunks, every changed line an addition.

**Landing.** `docs/adr/**` is a governed surface. This is opened as a
draft. The hand-off is the seat's and the approval is the maintainer's.
Nothing here requests a reviewer, marks it ready or arms auto-merge.

**CI.** NOT MEASURED: the check-runs of this pull request, reason: it
did not exist when this body was written. The report on the card carries
the reading taken after it opened.

**Gates, run locally on head `f3cd7dba76`.** `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 21 commands from the diff. All 21
ran in the foreground, each exit code was captured before any pipe, and
all 21 are exit 0. The reconciliation:

```text
Run reconciliation — 21 derived, 21 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a DERIVED zero — all 21 recorded an exit code and none of them is 3).
```

<details>
<summary>The 21 commands and their exit codes</summary>

```text
node scripts/check-adr-links.mjs :: exit 0
node scripts/check-adr-links.mjs --self-test :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:adr-index :: exit 0
pnpm check:adr-symbol-anchors :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:pm-governed-merges :: exit 0
pnpm check:pm-prior-rulings :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:watch-hint-literal :: exit 0
```

</details>

<details>
<summary>Verdict lines of the gates that read the ADR</summary>

```text
✅ check-adr-links: 1284 relative link destination(s) under docs/adr/ resolve
✅ check-adr-symbol-anchors: 4608 anchors across 165 records resolve — 1727 symbol (1698 declaration, 29 literal), 2829 file-level, 52 cross-repo, 6 exempt, 132 continuation. [cut here: the rest of the line is a note on what the count is not]
adr-index --report: OK — docs/adr/README.md is current, every record parsed, self-test 60 assertions green. Report-only: this line never reds the step.
check-nul-bytes: OK (scanned 29077 text file(s) -- 29077 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes).
✓ check-closed-ceremony-text: 6688 shipped file(s) read; none says the ownership ceremony is closed.
✓ comment-mask corpus sweep [scripts/js-comment-mask.mjs]: 24511 files, 0 disagree, 0 unparseable, 211.2s (comparator self-test: 26 cases pass).
```

</details>

<details>
<summary>One gate first read NOT MEASURED, then green</summary>

`pnpm --filter @objectstack/lint run check:doc-formula-expressions`
first answered exit 3, PREREQUISITE NOT MET: two workspace packages it
imports were not built in this worktree. That is a run that measured
nothing, not a red gate. The two packages were built under the shared
verify lock, with the command the gate printed, and the gate was run
again at the same head:

```text
os-verify-lock: VERDICT command-exit 0 · held the lock 100s (1m40s) · waited 0s
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
```

</details>

**Left to CI, not run locally.** The repo-wide lint, the type-check
lanes, the test shards, and the families `dispatch-gates` prints outside
the derived list. The commit trailer gate ran in the pre-push hook on
the pushed range and is green.

## Human Minimum

- [x] 1. No schema and no code changes.
- [x] 2. No new name is declared in code. The two member names are the
ones PR objectstack-ai#38798 and the analysis use.
- [x] 3. No formatter ran. `pnpm lint` is NOT MEASURED locally: the
repo-wide scan is CI's, and the diff is one Markdown file.
- [x] 4. One card, one branch off `main` at `0fc9eab900`, one pull
request for this phase.
- [x] 5. Nothing publishes, so no changeset; both declaration lines are
filled in above.
- [x] 6. `packages/spec` is not touched.
- [x] 7. No edit to `content/docs/references/`, to a `CHANGELOG.md` or
to `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. The card's Chinese
words are quoted unchanged, and the 维护者速读 section is in Chinese as the
fleet's rule asks.
- [x] The *Before Submitting* list is done for what a docs-only diff
reaches; `pnpm lint` is as item 3 says.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h

<!-- signed: repo:objectstack#2 · os-warren ·
session_01JQwxbXfgA45f3y5YpDPT5h -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants