Repository navigation
Description
repo:objectstack#2 · os-warren · session_01JQwxbYGom9jneGXshSXk4W
Filing category ④ — child card of topic #38703, row B2 · Source: topic #38703
Grade: priority:p1 · area:ai · inherits the topic's grade; phase 1 exit criterion "an error never becomes an empty result" depends on this card.
维护者速读
- 问题:私有部署企业版在 PostgreSQL 上检索时,语句没有时限;等不到数据库连接时,助手拿到的是「0 条命中」而不是报错,用户以为制度里没有这一条。
- 本卡做:(1) 检索语句设时限,超时报
TIMEOUT;(2) 所有数据库错误都变成带编码的拒绝;(3) 连接池大小改为可配置。 - 不做:提速。实测调大连接池几乎不改善耗时,(3) 只为可配置。
Business reason
The topic's phase-1 target (maintainer, 2026-11-30): 「需要考虑如何尽快出第一个可用的版本」 — on a self-hosted Enterprise PostgreSQL deployment, ten people asking at once get no timeouts and no silent empty results. Today a pool-wait timeout reaches the assistant as zero hits, so the answer "no policy covers this" is indistinguishable from "the database was busy". BrightRule policy inquiry is the first customer.
Premise (read on origin/main d2caaec, 2026-11-30T07:30Z)
packages/plugins/knowledge-pgvector/src/plugin.ts:155-156— the pool is fixed:max: this.opts.poolMax ?? 4,connectionTimeoutMillis: this.opts.connectTimeoutMs ?? 5000.grep -rn statement_timeout packages/plugins/knowledge-pgvector/src— 0 hits: no statement time limit.- The topic body records (not re-measured here):
resolveKnowledgeStoreinpackages/core/src/capability-composition.tspasses only{ url }; a pool-wait timeout frompgcarries nostatus,codedRefusalOfinservice-knowledgedoes not recognise it, andsearchRoundlogs one error and skips the source — the caller sees 0 hits and no refusal. The dev re-reads these call sites on the tree before writing code.
What (topic row B2, verbatim)
(1) 检索语句设时限,用 PostgreSQL 自带的
statement_timeout,超时返回编码的TIMEOUT;(2) 适配器把检索里所有pg错误(等连接超时、语句被取消、连接数用尽)都转成带编码的拒绝,调用方看到拒绝而不是空结果;(3) 连接池大小从设置读取(写明设置键名、默认值、与max_connections=200的配比,按多副本算)。实测显示调大连接池几乎不改善耗时,(3) 只为可配置,不为提速。只改capability-composition.ts和 knowledge-pgvector,不改knowledge-service.ts
Constraints from the topic
- Only PostgreSQL's own facilities (
statement_timeout,SET LOCALin a transaction or a per-connection setting); nothing a vector database should provide is built in the knowledge engine. - A test pins statement shape / error code / call count, never wall-clock time.
- A coded refusal must reach the
search_knowledgecaller; an empty result on error is the defect. - The time limit must survive a transaction-mode PgBouncer question: the delivery note (B12) states that transaction-mode PgBouncer is unsupported in front of the store; prefer a form that does not depend on session state where possible, and say which form was chosen.
Overlap
- 知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692 phase 1a (in flight, zone o2-A) changes
pgvector-adapter.tssearch(). B2's error translation sits next to it: keep B2's change at the pool/query boundary (a wrapper or the adapter's query helper), not insidesearch()'s statement body, and let the later lander resolve conflicts. - Does not touch
packages/services/service-knowledge/src/knowledge-service.ts(held by PR refactor(service-knowledge): split KnowledgeService into five concern modules behind a delegating facade #38700).
Acceptance
- A search whose statement exceeds the limit answers a coded
TIMEOUTrefusal at thesearch_knowledgecaller. - A pool-wait timeout, a cancelled statement and
too many connectionseach answer a coded refusal; none answers an empty hit list. One test per error class. - The pool size is read from a named setting with a stated default; the PR body names the key, the default and the ratio to
max_connections=200for N replicas. - Feeds B12 (delivery note) with the setting key.
Dedupe
Topic #38703's dedupe (open and closed, objectstack and cloud): pgvector 11 closed objectstack cards, none on pools or time limits. This seat, 2026-11-30: repo:objectstack-ai/objectstack is:issue is:open label:area:ai knowledge pgvector — 9 hits, none on statement time limits or pool errors.
Activity
objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#2 · os-warren · session_01JQwxbYGom9jneGXshSXk4W
2026-11-30T07:42Z · Claim · topic #38703 row B2, on the maintainer's 「整个专题都归你接手 38703 加速处理」 (2026-11-30T07:21Z, project thread). That order lifts the knowledge pause for this topic's phase 1. Order against #38692: seat 2 (session_01JQwxbXyLoBzNYY1U8SNPFu, holder of claim 7270621658) agreed 2026-11-30T07:32Z that B2 lands first; #38692's phase-1a pgvector PR builds from
mainafter it (Notify: serialon merge).Triage (lane self-triage, fleet-filed child card): area:ai · priority:p1 (inherits the topic) · type Bug · domain:server (fix lands in
packages/plugins/knowledge-pgvectorandpackages/core).Claim: PM loop round 1
Session:
session_01JQwxbYGom9jneGXshSXk4WAccount:
os-warrenBranch: a new branch from
origin/main; the card thread names it on its first push.Worktree:
objectstack-issue-38718Domain:
domain:serverSeat:
repo:objectstack#2Area:
o2-E(topic #38703 zone)File surface:
packages/plugins/knowledge-pgvector/src/plugin.ts,packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts(reason: error translation at the pool/query boundary only, notsearch()'s statement body),packages/plugins/knowledge-pgvector/src/errors.ts(reason: new, if a helper module is cleaner),packages/core/src/capability-composition.ts(reason:resolveKnowledgeStorepasses the pool setting),packages/plugins/knowledge-pgvector/README.md(reason: the setting key and default). ⛔ Notpackages/services/service-knowledge/**(held by #38700).Container & model:
M,mode:thread,model: default tier — dispatch-gates --tier 2026-11-30: "no path-derived mandate",effort: highClause-②: yes
Metadata-protocol: none
Responsibility: the code that produces the risk is objectstack's own (
knowledge-pgvectorhas no time limit and no translation ofpgerrors;service-knowledgetreats an uncoded throw as a skipped source) | no platform path covers it today | reached by every self-hosted Enterprise deployment on PostgreSQL with a knowledge source; BrightRule policy inquiry is the first user.Thread-read: none
Premise: holds — on
origin/maind2caaec:grep -rn statement_timeout packages/plugins/knowledge-pgvector/src0 hits;plugin.ts:155-156max: this.opts.poolMax ?? 4,connectionTimeoutMillis: this.opts.connectTimeoutMs ?? 5000. The topic's reading ofcodedRefusalOf/searchRound(an uncoded throw becomes a skipped source) is NOT re-measured here; the thread re-reads it before code.Serial constraints cleared: #38692 (claim 7270621658,
knowledge-pgvector/src/**) — ordered after this card by its holder, 2026-11-30T07:32Z; #38700 — not touched; #38719 (B1) — disjoint (bench/**only).objectstack-fleet commentedon Nov 30, 2026
repo:objectstack@os-warren · os-warren · session_01JQwxbYVKM5Jf2J5JbHJ8Aj
os-dev-report
2026-11-30T07:58Z · card thread of claim 7271864876 (seat repo:objectstack#2).
{ "issue": 38718, "status": "done", "branch": "claude/project-thread-ju951t", "pr": "https://github.com/objectstack-ai/objectstack/pull/38726", "head": "9a39db77", "session": "session_01JQwxbYVKM5Jf2J5JbHJ8Aj", "premise_still_valid": true, "summary": "Premise re-read on origin/main d2caaec4 and holds: codedRefusalOf (knowledge-service.ts:4974) takes only a SCREAMING_SNAKE code with an integer 4xx/5xx status, searchRound (:3237-3249) logs and skips any other throw, so a pg error (SQLSTATE code or none) answered a single-source search with zero hits; the ablation reproduces exactly that. knowledge-pgvector search() now answers every database failure as an ADR-0112 refusal judged by SQLSTATE (57014 -> TIMEOUT 504; class 53 incl. 53300 -> SERVICE_UNAVAILABLE 503; no connection: pool wait timeout, class 08, 57P01-57P05, socket errors -> SERVICE_UNAVAILABLE 503; other -> DATABASE_ERROR 500), driver text in remedy only; poolFromPg marks its errors (non-enumerable symbol) so the uncoded pool-wait timeout is recognised without message matching. The ranking statement runs in its own transaction after SET LOCAL statement_timeout (default 10000 ms; statementTimeoutMs option, else OS_KNOWLEDGE_STATEMENT_TIMEOUT_MS), chosen because it holds no session state and survives a transaction-mode pooler. Pool size: OS_KNOWLEDGE_POOL_MAX (option poolMax wins), default unchanged 4, strict parse; README states the max_connections=200 ratio per replica count. Change kept at the query boundary (try/catch in search() around a moved attempts loop + searchStatement helper); the ranking statement body is untouched; service-knowledge and core untouched.", "tests": "search-refusals.test.ts 14/14 (statement shape BEGIN/SET LOCAL statement_timeout = 10000/ranking/COMMIT; one case per error class on code+status; embedder error passed through by identity; KnowledgeService.search refused TIMEOUT 504 instead of empty; settings reader). search-refusals.live-postgres.test.ts 2/2 against local PostgreSQL 16.15 (real pg_sleep past SET LOCAL -> 57014 -> TIMEOUT, limit gone after the transaction on the same pooled connection; real max:1 pool wait through poolFromPg -> SERVICE_UNAVAILABLE on query and connect). pnpm --filter @objectstack/knowledge-pgvector test: Test Files 6 passed / 9 skipped, Tests 38 passed / 95 skipped (live files skip without OS_TEST_POSTGRES_URL). Ablation (fix committed, restored via git checkout HEAD --): search() rethrowing the raw error -> 8/14 red, KnowledgeService case receives { hits: [] }; poolFromPg marking removed -> the 2 pool-wait cases red.", "gates": "local: typecheck exit 0 (check:test-typecheck 0 debt); eslint --no-inline-config on the 5 changed ts files exit 0; check-nul-bytes exit 0; dispatch-gates --commands at 9a39db77 (7 paths, 694 lines): 26/27 exit 0, check-plugin-teardown-shape --self-test exit 3 NOT MEASURED (shallow clone cannot reach its pinned fixture commit; CI runs it). CI check-runs: not yet read at report time (PM reads convergence).", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "4 — GitHub MCP reads only: issue_read x3 (#38718 get + get_comments, #38703 get), pull_request_read x1 (refused: the built-in MCP was retired mid-session); 0 write tools", "api_writes": "2 — relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST issues/38726/assignees os-warren, one stroke, run 46377651920, read-back identical); this os-dev-report comment (POST /repos/objectstack-ai/objectstack/issues/38718/comments). Plus git push of the branch (not a REST write).", "classifier_refusals": [], "open_questions": [], "security_findings": "none", "out_of_scope_findings": [ "carrier: #38703 · noted, not filed — an uncoded throw that is not the database's (embedder failure, mis-sized query vector) is still logged and skipped by service-knowledge searchRound, so it still reads as zero hits for that source; the general fix is in service-knowledge (held by #38700), outside this card's surface. Dedupe words: searchRound uncoded throw skipped source empty hits" ], "deviations": [ "File surface: packages/core/src/capability-composition.ts was in the claim but not changed — the plugin reads OS_KNOWLEDGE_POOL_MAX itself, as it already reads the URL from the environment, and os serve hands process.env to both, so a second reader in core would duplicate the parse.", "Added a new live file search-refusals.live-postgres.test.ts (same-name test of the new errors module, needs no pgvector).", "No reviewer requested at create (pr_create carries assignee only; the hand-off request is the seat's after ACCEPT)." ] }objectstack-fleet commentedon Nov 30, 2026
triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ
First-touch review: confirmed · area:ai · domain:server · Bug · p1 as the topic grades it (#38703 row B2) · type set to Bug: a pool-wait or statement timeout on knowledge-pgvector reaches the assistant as zero hits, which is shipped behaviour answering wrongly (Severe would need a stored value; this is a read shown wrongly, so the topic's p1 rests on its phase-1 exit criterion, not on the table).
objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#2 · os-warren · session_01JQwxbYGom9jneGXshSXk4W
2026-11-30T08:29Z · Claim amendment · #38718 · re-dispatch for L1 REWORK 7272964718 (docs only; code accepted at 9a39db7, contract record 7272956301 PASS)
Branch:
claude/project-thread-ju951tFile surface (added):
content/docs/deployment/environment-variables.mdx(reason: L1 rework 1, the canonicalOS_*list),content/docs/protocol/knowledge.mdx(reason: L1 rework 2, §4.1 pool, time limit and refusals). Removed:packages/core/src/capability-composition.ts(not needed, accepted deviation in 7272964718).Serial constraints cleared:
check-handover --inflighton the two added files names #38503 (claim 7264997030) and #38369 (claim 7265012601), both seat 2 zone o2-A, oncontent/docs/protocol/knowledge.mdx; neither has an open PR touching it, so this one-sentence-per-item edit goes ahead and the later lander resolves (Notify: serialsent to o2-A). Nits N1–N3 are not taken in this round, so the delta stays prose only.os-bob commentedon Nov 30, 2026
本地实测数据:连接池大小与静默空结果(供 B2 / PR #38726 参考)
环境:本地 PG17 + pgvector 0.8.7,中文制度条款 59,949 段全部建好索引(已核对行数),企业版从源码起(社区版模式),通过 MCP
search_knowledge端到端压测,带单位范围(约 6% 的条款),15 题循环。timeout exceeded when trying to connect,调用方拿到 0 条命中、没有拒绝信息,和卡里读代码的结论一致。30 秒超时一次都没有出现。Generated by Claude Code
fix(knowledge-pgvector): a failed search is a coded refusal, its stat…