Skip to content

fix(service-knowledge)!: a source whose adapter's search throws without a code is refused, never answered as no hits - #38761

Merged
os-zhuang merged 8 commits into
mainfrom
claude/issue-38728-uncoded-search-throw
Nov 30, 2026
Merged

os-zhuang merged 8 commits into
mainfrom
claude/issue-38728-uncoded-search-throw

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #38728
repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Clause-②: no (narrowing)
Metadata-protocol: none

维护者速读

  • 变化:知识库检索时,某个来源的检索服务出错(如向量服务连不上)不再显示成「什么都没搜到」,而是列为「该来源未能检索」。
  • 谁会碰到:只在某来源检索抛出无错误码的异常时出现;若它是本次唯一被检索的来源,整次检索改为报「服务不可用」(503),其他来源照常返回结果。
  • 出错会怎样:最坏是把出错来源误报为不可用;改动集中在一处,可直接撤回。
  • 要你做什么:无。

BREAKING

BREAKING for a caller of a knowledge search (the search_knowledge tool, its MCP HTTP and stdio faces, and in-process KnowledgeService.search / searchWithRefusals) when a source's adapter throws from search with an error that does not carry both an ADR-0112 code and status (an embedder that cannot be reached, a timeout outside the store). The search now names that source in refused, coded SERVICE_UNAVAILABLE (503), with a platform sentence naming the source; before, the source read as if it had matched nothing. The thrown message is not shown to the caller; the operator's error log line keeps it. Sources that answer are still served beside the refusal. A source that matches nothing is unchanged, and so is a coded refusal's own refused entry; a whole rejection that also names an uncoded throw may take that throw's top-level code (cell 2 below). Declared as a narrowing per L1 REWORK 7279138481; registered in the ADR-0087 ledger as semantic entry knowledge-search-uncoded-adapter-throw-refused (packages/spec/src/migrations/entries/semantic/19.knowledge-search-uncoded-adapter-throw-refused.ts, a new file; the registry is generated, no existing spec file edited), added to the file surface by claim amendment 2 (comment 7279244160).

FROM → TO:

  • No searched source answers and at least one threw without a code — two cells:
    1. Every searched source throws without a code (one source, or several failing on the same embedder outage). FROM: the search succeeded with { hits: [] }. TO: rejected SERVICE_UNAVAILABLE / 503 with refused naming each source (the search_knowledge executor and in-process search reject with refused; MCP answers an error result whose envelope is code, message and status, the sources named in the message).
    2. A source throws without a code beside a source refused with a code, none answering. FROM: rejected with the coded source's code / status and refused naming it alone. TO: refused names both, and the rejection's top-level code / status are the first refusal's in source order, so a 409 KNOWLEDGE_REBUILD_REQUIRED rejection may now read 503 SERVICE_UNAVAILABLE.
  • A refill fails without a code. FROM: the source's round-one survivors were served. TO: they are dropped and the source is refused for the whole search, as a coded refusal of the refill already was.

Fix for each reader: a caller reads refused and the 503 instead of treating an empty answer as no match; an operator repairs the adapter or embedder the error line names.

What changes

searchRound (packages/services/service-knowledge/src/knowledge-service-search.ts) catches an adapter's throw from search. A coded refusal (ADR-0112 code + status) was already pushed to refused; any other throw was only logged at error, so the source read as zero hits. Now an uncoded throw is pushed to refused as { sourceId, code: 'SERVICE_UNAVAILABLE', status: 503, message }, where message is a platform sentence naming the source and its adapter id (never the thrown text, which can carry hosts, SQL or keys). The operator error line is unchanged and still carries the thrown message. The docblock states the new outcome.

Code choice: the existing SERVICE_UNAVAILABLE (503), the code this package already answers for an adapter that cannot serve (UNMOUNTED_ADAPTER_CODE, knowledge-service-top-level.ts). No new code is minted, so no ledger or StandardErrorCode change. The literal is written in the catch (not the constant imported) to stay inside the claimed hunk.

Consequences that follow from the existing refusal machinery, unchanged by this diff:

  • When no searched source answers (first.size === 0 && refused.length > 0), the search is refused whole (wholeRefusal), so a search whose only source's embedder is down now rejects with SERVICE_UNAVAILABLE / 503 and refused, instead of resolving [].
  • Refill: a source refilled is one that answered round one, so it is never refused twice in one search. A source that fails the refill uncoded is now refused for the whole search and its round-one hits dropped, as a coded refusal of the refill already was (refusedInRefill).

Public doors

Measured on origin/main acf3b33 plus this branch; there is no REST knowledge search route (a grep of packages/rest/src and packages/runtime/src for a knowledge search route finds none; the same grep finds the search_knowledge registrations below).

  • search_knowledge executor, packages/services/service-knowledge/src/knowledge-tools.ts:662-671: with other sources answering, the tool output now carries refused: [{ sourceId, code: 'SERVICE_UNAVAILABLE', message }] beside their hits (before: no refused, the source silent). When it is the only searched source, the executor rejects with the whole refusal (wholeRefusal, thrown at knowledge-service-search.ts:231, or :258 on a refill): code: 'SERVICE_UNAVAILABLE', status: 503, refused naming the source (before: { hits: [] }).
  • MCP search_knowledge, packages/mcp/src/mcp-http-tools.ts:3824-3826 (registered for HTTP at mcp-http-tools.ts:3428 via packages/runtime/src/domains/mcp.ts:1786, and for stdio at packages/mcp/src/plugin.ts:1068 via stdio-data-bridge.ts:1998): the partial case returns the text result with refused; the only-source case returns errorResultWithCode (mcp-http-tools.ts:1636), an error result with the ADR-0112 envelope SERVICE_UNAVAILABLE / 503 (before: a text result with no hits).
  • In-process KnowledgeService.search / searchWithRefusals callers (no other non-test caller in this repo): same as the executor.

Tests

New src/__tests__/search-uncoded-throw-38728.test.ts (5 cases): plain Error gives one refused entry naming the source (code + status asserted, thrown text absent from the caller's message, present in the error line), other sources' hits still served; only source throwing uncoded refuses the search whole (503); coded refusal unchanged; source matching nothing answers no hits and no refusal; refill failure refused once, round-one hits dropped.

Flipped pins of the old "logged, zero hits" outcome (each now asserts the refusal's sourceId/code/status):

  • knowledge-service.test.ts "a refill the adapter fails keeps the source's round-one survivors" -> refused as a coded refill refusal is.
  • knowledge-tools.test.ts "control: a failure without a code is logged and skipped as before" -> refused SERVICE_UNAVAILABLE, text withheld.
  • knowledge-settings-contribution.test.ts: "no settings: ... search answer an error", "the API key is in no log line and no error", "a plugin a host mounts itself, no embedder" -> search rejects SERVICE_UNAVAILABLE / 503 naming docs.
  • packages/plugins/knowledge-pgvector/bench/instrument.test.mjs "a failed embed is counted, and the search answers no hit with the service's "search failed" line" (s.ok true, s.hits 0) -> "a failed embed is counted, and the search is refused SERVICE_UNAVAILABLE naming the source, with the service's "search failed" line": s.ok false, s.errorCode SERVICE_UNAVAILABLE, the thrown refusal SERVICE_UNAVAILABLE / 503 with refused naming clauses; embedFailures 1, calls.ranking 0 and the one "search failed" operator line kept.

This sixth pin was added to the file surface by claim amendment 1 (comment 7278305559).

Files changed (8):

  • packages/services/service-knowledge/src/knowledge-service-search.ts
  • packages/services/service-knowledge/src/__tests__/search-uncoded-throw-38728.test.ts
  • packages/services/service-knowledge/src/__tests__/knowledge-service.test.ts
  • packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts
  • packages/services/service-knowledge/src/__tests__/knowledge-tools.test.ts
  • packages/plugins/knowledge-pgvector/bench/instrument.test.mjs
  • .changeset/38728-uncoded-search-throw.md (@objectstack/service-knowledge and @objectstack/spec patch, fix(service-knowledge)!:, Clause-②: no (narrowing), the ADR-0087 registered marker)
  • packages/spec/src/migrations/entries/semantic/19.knowledge-search-uncoded-adapter-throw-refused.ts (new; claim amendment 2, comment 7279244160)
Readings (tests at 43def1f; e52b762 adds only the changeset sentence)

Acceptance notes

  • Read first: the catch block in searchRound (the only runtime hunk); then the refill pin flip in knowledge-service.test.ts, which is the one behaviour change beyond the card's literal Ask (a refill failure now drops round-one survivors instead of keeping them, to match the coded path).
  • The stand-in embedder's "No embedder is configured ... restart" text is uncoded, so the caller now reads the generic platform sentence and the remedy stays on the operator line. Coding that error at its producer would let the caller read the remedy; noted, not filed.
  • content/docs/protocol/knowledge.mdx not edited (open PRs edit it; skipped per dispatch).

Verification

Two-minute check: pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/search-uncoded-throw-38728.test.ts -> 5 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v

…ithout a code

An uncoded throw from an adapter's search (an unreachable embedder, a timeout
outside the store) is now a refused entry for that source, coded
SERVICE_UNAVAILABLE (503) under a platform sentence, instead of reading as zero
hits. The operator error line keeps the thrown message.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
…o-hits pins; changeset

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
@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 2 package(s): @objectstack/service-knowledge, @objectstack/spec, touching 5 documentable anchor(s).

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

  • content/docs/ai/knowledge-rag.mdx (via KnowledgeService (symbol, a top-level class))
  • content/docs/protocol/knowledge.mdx (via KnowledgeService (symbol, a top-level class))
What this run could not see
  • 3 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 — 182 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 bb8634726e95e80db89ddacd6cea455c927c5033 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 02620c436334894f15e5b592c01163b290673915 — the merge of head 5e17df249a7cb8e7f5db96135b8699eedb46ce6b into base bb8634726e95e80db89ddacd6cea455c927c5033, 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 02620c436334894f15e5b592c01163b290673915 && git checkout 02620c436334894f15e5b592c01163b290673915
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bb8634726e95e80db89ddacd6cea455c927c5033 5e17df249a7cb8e7f5db96135b8699eedb46ce6b && git checkout -B drift-repro bb8634726e95e80db89ddacd6cea455c927c5033 && git merge --no-ff 5e17df249a7cb8e7f5db96135b8699eedb46ce6b

node scripts/docs-audit/affected-docs.mjs --json bb8634726e95e80db89ddacd6cea455c927c5033

⚠️ 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 bb8634726e95e80db89ddacd6cea455c927c5033 → 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#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Final head for review — zone o3-K · 2026-11-30T12:54Z
Head-sha: 6348efa9497d57cd5fadc495ae3b7eb613341748
CI: every check-run on this head is success or an expected skip (41 success, 20 skipped, 0 failed, 0 running). mergeable_state clean.
Rounds: 0 (fix), 1 (behaviour change declared in the changeset and the body: the only searched source throwing uncoded now answers 503 SERVICE_UNAVAILABLE), 2 (the knowledge-pgvector bench pin of the old outcome flipped, claim amendment 7278305559).
Contract faces: record-recognisers.mjs --template --paths reads no face on this file list; Clause-②: no with a note for L1 on the answer change. Next: L1 (L1-b).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T12:55Z · first review

席位核对

REWORK @ 6348efa (card #38728, Fixes; 7 files)

Must-fix 1. The body asks L1 to judge its "Clause-② note". My judgement: the (narrowing) arm applies, and the PR must declare it.

Two answers that succeeded on main now fail:

  • The only searched source throws uncoded. On main, search_knowledge (executor, MCP HTTP and stdio) and in-process KnowledgeService.search resolved { hits: [] }, a success. At this head they reject with SERVICE_UNAVAILABLE / 503 and refused. MCP turns that into errorResultWithCode in place of a text result. The body measures exactly this under "Public doors".
  • A refill fails uncoded. On main the source's round-one survivors were served. At this head they are dropped and the source is refused for the whole search. The body calls this "the one behaviour change beyond the card's literal Ask".

This seat has read a request answered with success before and refused now as a narrowing that is declared with FROM → TO. #38752's #34258 cell (200 → 404) was REWORKed for exactly this and then declared. "It never truly worked" (the embedder was down) does not change that reading; #38755 declared its narrowing on the same premise ("Such a body never worked"). The changeset already says "Behaviour change for callers" in prose, but the declaration lines say neither the arm nor BREAKING.

What the zone owes:

  • Clause-②: no (narrowing) on the PR body and the changeset, as feat(lint)!: judge a lowered hook or action body's capabilities like an authored one #38755 spells a behaviour narrowing that has no signature change. L2 confirms yes or no.
  • ! in the title.
  • A BREAKING paragraph with the two FROM → TO cells above and the one-line fix. For the caller, that is to read refused and the 503 instead of treating an empty answer as no match. For the operator, that is to repair the adapter or embedder the error line names.
  • The ADR-0087 disposition marker, which check:adr-0087-registration reads.
  • The needs:dogfood-battery lane on the final head.

Read and found right:

  • The catch. An uncoded throw is pushed to refused as SERVICE_UNAVAILABLE / 503. That code is already this package's for an adapter that cannot serve (UNMOUNTED_ADAPTER_CODE), so no new code and no ledger change. The caller gets a platform sentence naming the source and the adapter id, never the thrown text. The operator error line still carries the thrown text.
  • Whole refusal. It comes from the existing wholeRefusal path, unchanged.
  • Relation. Fixes #38728 delivers the card's ask: a throw is never answered as no hits.
  • Pins.
    • The six flipped pins are named, each with its reason.
    • The bench pin is in the surface by claim amendment 7278305559. @objectstack/knowledge-pgvector is touched by bench/instrument.test.mjs only, which clears the l1-face changeset flag.
    • Ablation: reverting the catch turns the new file's three uncoded pins red.
  • Not run by me: the tests. The fix is to declarations and text, and no code moves, so I will run the new file on the delta.

Checks at this head (read before writing): 41 success, 20 skipped, 0 failure. mergeable_state is clean.

@objectstack-fleet objectstack-fleet Bot changed the title fix(service-knowledge): a source whose adapter's search throws without a code is refused, never answered as no hits fix(service-knowledge)!: a source whose adapter's search throws without a code is refused, never answered as no hits Nov 30, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Final head for review — zone o3-K · 2026-11-30T13:45Z
Head-sha: a6416d79bd110bbcc059ade5bece7eb5cfc65936
CI: every check-run on this head is success or an expected skip (66 success, 19 skipped, 0 failed, 0 running); one Check Changeset run was cancelled by a later push's concurrency and a later run on this head passed. Dogfood battery (opt-in) success (3/3 shards), label needs:dogfood-battery.
Round 3 (answers L1 REWORK 7279138481): the change is declared a narrowing — ! title, Clause-②: no (narrowing), a BREAKING section with FROM → TO, and the ADR-0087 semantic ledger entry packages/spec/src/migrations/entries/semantic/19.knowledge-search-uncoded-adapter-throw-refused.ts (claim amendment 2 7279244160; new file only, no existing file edited, as the seat ruled). Next: L1 delta (L1-b), then the seat's L2.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T13:47Z · delta review

席位核对

ACCEPT @ a6416d7 (card #38728). This is a delta from 6348efa and my REWORK 7279138481. There are two commits, changing only .changeset/38728-uncoded-search-throw.md and one new spec migration entry. No service code moves.

  • Must-fix 1 is resolved.
    • The title carries !.
    • Clause-②: no (narrowing) is on both the PR body and the changeset.
    • The changeset now opens with a BREAKING paragraph naming the four faces: the search_knowledge executor, its MCP HTTP and stdio faces, and in-process search / searchWithRefusals.
    • It has the two FROM → TO cells I named: the only source goes from { hits: [] } to a 503 rejection with refused, and a failed refill goes from serving round-one survivors to dropping them, with the source refused.
    • It gives the one-line fix for the caller and for the operator.
    • The marker <!-- adr-0087: registered knowledge-search-uncoded-adapter-throw-refused --> is present.
  • The new semantic entry (19.knowledge-search-uncoded-adapter-throw-refused.ts): its surface, replacement, reason and acceptanceCriteria match the changeset and the code I read at 6348efa, and its id equals the marker. @objectstack/spec takes patch for the entry only, which the changeset says. It is added as a new file only, under the seat-approved claim supplement 2 (7279244160).
  • Dogfood is met on this exact head. Dogfood battery (opt-in) succeeded, with all three shards green.
  • Carried from the first review: the catch, the 503 reuse and the withheld thrown text were read right at 6348efa. Because no code moves, that reading stands. I ran no tests in this delta; the spec entry is covered by CI, where Lint & Repo Gates and Check Changeset are both green.

Checks at this head (read before writing): 66 success, 19 skipped, 0 failure. One Check Changeset run was cancelled, superseded by a later success. mergeable_state is clean.
L2: owed at CONTRACT_REVIEW_TIER for the narrowing and the ADR-0087 entry. The seat runs it. Not governed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a6416d79bd110bbcc059ade5bece7eb5cfc65936
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/19.knowledge-search-uncoded-adapter-throw-refused.ts + packages/services/service-knowledge/src/knowledge-service-search.ts, and .changeset/38728-uncoded-search-throw.md read line by line against both
Security-touching: no
Rule-change-verified: none

PR #38761 (card #38728). Read: the card body and its 5 comments (triage, claim, dev report, claim amendments 1 and 2), the PR body and its comments (L1 REWORK 7279138481, L1 delta ACCEPT 7280379248), the 8-file list, the net diff, the head's knowledge-service-search.ts, knowledge-service.ts, knowledge-service-top-level.ts and knowledge-tools.ts, main for the code outside the diff (wholeRefusal, codedRefusalOf, the tool executor, the MCP search_knowledge handler and thrownRefusalEnvelope), and the check-runs on this head. Nothing was built or run: every cell below is a reading of the code, not a measurement.

① Derived judgments

  • The catch: right, and it delivers the card's ask. In searchRound a throw that codedRefusalOf does not lift (no UPPER_SNAKE code together with an integer status 400 to 599) is pushed to refused as { sourceId, code: 'SERVICE_UNAVAILABLE', status: 503, message } and the source stays out of the round's map. The entry has the same four members as a coded refusal's ({ sourceId, ...coded }), so everything downstream treats the two alike: facedRefusals, the report, wholeRefusal, and the tool executor's { sourceId, code, message } projection.
  • The message: right. The caller's sentence is built from the source's face (this.label) and the adapter id only; the thrown text appears nowhere in it, and so nowhere in wholeRefusal's message, which is composed from the entries' messages. The operator error line is byte-unchanged and still carries the thrown text. The adapter id is already caller-visible in this package's refusal of an adapter that is not mounted.
  • Multi-source: partial, never a whole failure while one source answers. A source that answers nothing is still set in the round's map (out.set with empty hits), so first.size === 0 holds only when no searched source answered. One source throwing uncoded beside an answering one gives the others' hits plus one refused entry; KnowledgeService.search (hits only) resolves as before in that case. The 503 is thrown only from wholeRefusal at the two existing throw sites.
  • HTTP and MCP mapping: same path as a coded refusal. The whole refusal is thrown by the unchanged wholeRefusal (first refusal's code and status, refused attached). The search_knowledge executor does not catch it; the MCP handler (HTTP and stdio share it) answers errorResultWithCode, whose envelope is code, message, status. There is no REST knowledge search route to map.
  • Cell (b), the refill: the right contract, not a side effect. The refill runs only for a caller the permission re-check or the record grouping left short of topK. Serving the first round's survivors after the refill failed is a short or empty answer with no signal, which is the outcome the card retires; keeping them and naming the source would break the member contract's "no source is both answered and named as refused". Dropping and refusing is the one outcome consistent with both, and it is what a coded refill refusal already does through the same refusedInRefill lines. The cost is named here so it is not rediscovered: a transient failure of the second adapter call now discards hits that were correct. The entry, the changeset and two pins (single source: whole refusal; two sources: the other still served) declare exactly that.
  • Accept set and public surface. No export, type or signature changes; no key an author writes changes (Metadata-protocol: none holds). The moved answers are: success with no hits to a 503 rejection when no searched source answers (see S2 for the exact condition); first-round survivors to a refusal on a failed refill; and, additively, a refused entry beside other sources' hits.
  • The test changes move no answer beyond those. knowledge-tools.test.ts pins the additive partial case. The three knowledge-settings-contribution.test.ts flips and the bench pin are all the single-source case (docs, clauses): a stand-in or failing embedder's uncoded throw, now 503 naming the source. The API-key pin still holds the key out of the rejection's message and every log line.
  • Check-runs on this head. Every run is success or skipped, apart from one Check Changeset run cancelled and superseded by two successes. Test Core 12/12, Lint & Repo Gates, Spec property liveness and both type-check families are success.

② Semver level

Clause-②: no (narrowing) — confirmed. Nothing an author or caller may newly send is accepted; two answers go from success to refusal.

@objectstack/service-knowledge at patch with the BREAKING paragraph, the FROM → TO list and the adr-0087: registered knowledge-search-uncoded-adapter-throw-refused marker is the level AGENTS.md Post-Task step 3 sets for a non-protocol breaking change (.changeset/pre.json is mode pre), and the level the sibling narrowings shipped. @objectstack/spec at patch is owed because the entry publishes there, and the changeset says it adds only that. The marker's id equals the entry's id and the file name. @objectstack/knowledge-pgvector changes a bench test only and needs none. Check Changeset is success.

Dogfood battery (opt-in) is success on this exact head, with shards 1/3, 2/3 and 3/3 (a second, skipped run of the same name predates the label).

③ Boundary flags

  • Dev report 7277953241: open_questions is empty.
  • Deviation "refill-failure behaviour changed beyond the card's literal Ask": answered in ① (right contract, declared).
  • Deviation "content/docs/protocol/knowledge.mdx not edited": the page's "What a caller sees" paragraph and the pgvector operations paragraph state nothing this head falsifies (read on main); adding the uncoded case there is a docs follow-up, not owed here.
  • Deviation "downstream packages' tests not run": answered by Test Core 12/12 on this head; the one missed pin (the pgvector bench) was found by CI and flipped under claim amendment 1.
  • Out-of-scope note, "the stand-in embedder's 'No embedder is configured' error is uncoded; noted, not filed": escalated to the seat for a card. On a knowledge service a host mounts itself with no embedder, every search was [] and is now a 503 whose sentence says only that the adapter failed. That state is a configuration gap, not an outage, and a 503 invites a retry that cannot succeed; coding the error at its producer lets the caller read the remedy. It is the deterministic instance of cell (a) and deserves a number.
  • SQL push-down: no finding. The diff adds no query, no id materialisation and no in-app join.
  • Overlap: epic 专题:知识检索重排(rerank):知识源开关 + 部署配置模型,开了就一律重排 #38750 row 2 will edit knowledge-service-search.ts. This PR's two hunks are the searchRound docblock and its catch; a later edit of the same function will meet them textually, so whichever lands second rebases. S1's fix adds knowledge-service.ts, knowledge-service-top-level.ts and knowledge-tools.ts docblocks to the surface (a claim amendment), which the same epic may also touch.

④ Design judgment

S1 (should-fix) — the published docblocks that state this contract still describe the retired outcome. knowledge-service-search.ts says of its search body "the member's docblock there is its contract", and that member docblock (knowledge-service.ts, head :981-983) reads "A coded refusal is not logged and dropped like a failure", which says an uncoded failure is logged and dropped: the opposite of what this head ships as BREAKING. Three more sentences are narrower than the code for the same reason:

  • searchWithRefusals (head knowledge-service.ts:1000-1001): "each source whose adapter refused with an ADR-0112 coded error, with its code".
  • KnowledgeSearchRefusal (head knowledge-service-top-level.ts:281-293): "its adapter answered an ADR-0112 coded error"; code "The adapter's error code"; message "The adapter's message, which says what to do". For an uncoded throw all three are the platform's, and the message deliberately is not the adapter's.
  • SearchKnowledgeRefusedSource (head knowledge-tools.ts:171-180): "or its store refused for another coded reason"; message "What the store said".
    These ship in the package's types as the text an in-process caller reads. The searchRound docblock in the diff is correct; the fix is the same sentence carried to those four places, under a claim amendment since they are outside the claimed surface. No code moves.

S2 (should-fix) — cell (a) is declared as "the only searched source", and the code's condition is "no searched source answers". The entry's surface ("(a) the only searched source throws"), its acceptanceCriteria ("when it is the only source searched, rejects with status 503") and the changeset's first FROM → TO bullet all name one source. Two cells outside that wording move (read, not measured, and no pin holds either):

  • Two or more sources, every one throwing uncoded (the ordinary shape of an embedder outage, since every vector source embeds the query through the same embedder): main answers { hits: [] }; this head rejects SERVICE_UNAVAILABLE / 503 with refused naming each. A reader with two sources is told by the entry that "with other sources searched too, those still answer" and by the changeset that "Sources that answer are still served", and cannot predict the 503 from either.
  • An uncoded throw beside a coded refusal, none answering: main already rejects, with the coded source's code and refused naming it alone. This head names both, and the rejection's own code and status are the first refusal's in source order (wholeRefusal), so with the uncoded source first a 409 KNOWLEDGE_REBUILD_REQUIRED becomes a 503 SERVICE_UNAVAILABLE. The changeset's "A coded refusal ... unchanged" does not hold for that rejection's top-level code.
    Both follow from the existing rule (ADR-0161 K7, rule 5) and are the right behaviour; what is owed is the declaration: word cell (a) as "no searched source answers and at least one threw without a code" in the entry's surface, replacement and acceptanceCriteria and in the changeset bullet, name the mixed case's top-level code, and pin the all-throw case.

Nits

  • N1 — the entry's and the changeset's "MCP answers an error result with that envelope", after "with refused naming the source". The MCP error envelope is code, message and status (thrownRefusalEnvelope); refused is not a member of it, and the source is named in the message. "Read refused" is exact for the executor and in-process callers and for the partial MCP answer, not for the MCP rejection.
  • N2 — the changeset's and the entry's "carries no ADR-0112 code and status". codedRefusalOf needs both; an error with a code and no status (a Node ECONNREFUSED, say) takes the uncoded branch. "Does not carry both" is the exact wording.
  • N3 — the catch writes the literal 'SERVICE_UNAVAILABLE' where the package exports UNMOUNTED_ADAPTER_CODE for the same answer and the comment above it says "like an adapter that cannot serve". The PR body gives the reason (stay inside the claimed hunk); the constant can ride with S1's amendment or be left.
  • N4 — every uncoded throw is answered 503, a programming fault in an adapter included, where 500 would describe a fault better. The card left the code to the dev and the package's precedent is 503 for a source that cannot be searched; accepted deviation.

Held, after trying to break it

  • A source cannot be refused twice in one search: only sources present in the first round's map are refilled.
  • A refused source's first-round hits never survive beside its refused entry: refusedInRefill is read off the slice of refused the refill appended, which now includes the uncoded entry.
  • A source that matches nothing, a source no scope entry reaches, and a search with no admitted source still answer { hits: [], refused: [] }; none passes through the catch.
  • Nothing inside the try other than adapter.search throws on the read path (ask, the foreign-hit filter and checkScope do not), so no platform-side fault is relabelled as an adapter failure.
  • The tool executor filters refused to exposed sources as before, so the new entry names no withheld source.
  • No non-test caller of search or searchWithRefusals exists outside knowledge-tools.ts, so no in-repo caller that relied on [] is left unflipped.

Implemented-by: claude/issue-38728-uncoded-search-throw
Reviewed-by: session_01ADHkmSAjFEZHRpRq3WCj6z

VERDICT: PASS

…c docblocks and the upgrade entry

Contract review S1/S2 and nits N1-N3: the search, searchWithRefusals,
KnowledgeSearchRefusal and SearchKnowledgeRefusedSource docblocks state the
uncoded-throw outcome; the semantic entry and the changeset word cell (a) as
"no searched source answers and at least one threw without a code", naming
the all-throw and the mixed cell; the MCP rejection envelope is code, message
and status; the searchRound catch uses UNMOUNTED_ADAPTER_CODE. New pins for
the all-throw and the mixed cell.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Final head for review — zone o3-K · 2026-11-30T15:22Z
Head-sha: 5e17df249a7cb8e7f5db96135b8699eedb46ce6b
CI: every check-run on this head is success or an expected skip (66 success, 13 skipped, 0 failed, 0 running). Dogfood battery (opt-in) success (3/3 shards). mergeable_state clean.
Round 4 (answers contract review 7280553997; claim amendment 3 7280639195; dev report 7282174631): S1, the four public docblocks (KnowledgeService.search / searchWithRefusals, KnowledgeSearchRefusal, SearchKnowledgeRefusedSource) state the uncoded outcome; S2, the semantic entry, the changeset and this PR's BREAKING section word cell (a) as "no searched source answers and at least one threw without a code" and name its two cells (all sources uncoded: [] → 503; uncoded beside coded, none answering: top-level code is the first refusal's in source order), with pins for both; N1 to N3 folded (N3: UNMOUNTED_ADAPTER_CODE); N4 accepted. Code change beyond wording: the literal → constant swap only. overlap-check --pr=38722,38730,38732 clean before the push. Next: L1 delta (L1-b), then the seat's L2 delta.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T15:31Z · delta review (round 4)

席位核对

ACCEPT @ 5e17df2 (card #38728). This is the delta from my ACCEPT 7280379248 @a6416d79. It answers the seat's L2 7280553997, under claim amendment 3 (7280639195). It has two commits: a merge of main f576dee5 (306770c) and the docblock and declaration commit (5e17df2).

The merge is clean. Main between the two bases touched one of this PR's files, the pgvector bench/instrument.test.mjs. That file's PR patch is identical against both bases. Every other PR file in the merge equals a6416d7's version.

The code moves by one constant. The catch in searchRound now writes code: UNMOUNTED_ADAPTER_CODE, and UNMOUNTED_ADAPTER_CODE = 'SERVICE_UNAVAILABLE' (N3). Nothing else in src moves outside docblocks.

S1. The four public docblocks now say what the code does. The four are KnowledgeService.search, searchWithRefusals, KnowledgeSearchRefusal (its code, status and message for an uncoded throw) and SearchKnowledgeRefusedSource. Each says that an uncoded throw is refused as SERVICE_UNAVAILABLE (503) under a platform sentence, and never with the adapter's text. search adds that the thrown error's own code and status are those of the first refusal in source order.

S2. The changeset's BREAKING paragraph, its FROM → TO, and the entry's header, surface, replacement and acceptanceCriteria now say "does not carry both an ADR-0112 code and status". They split cell (a) into:

  • (a1) every source throws uncoded: { hits: [] } becomes 503 with refused naming each;
  • (a2) an uncoded throw beside a coded refusal, none answering: the top-level code is the first refusal in source order, so a 409 may now read 503.

Each cell has its own pin. The MCP envelope wording (code, message and status, with the sources in the message) is now stated as it is. (b), the refill, is unchanged.

Measured in a scratchpad worktree at this head, after building @objectstack/service-knowledge^...:

  • search-uncoded-throw-38728: 7/7. The whole service-knowledge package: 26 files, 844/844.
  • Ablation (the catch's refused.push disabled, type-clean): 5 red. The two new pins, (a1) and (a2), are among them, so both bind. The 2 coded and control cases stay green.

Checks at this head (filter=all): 66 success, 13 skipped, 0 failure. Dogfood battery (opt-in) and its three shards are green on this exact head. mergeable_state is clean.
L2: the seat's delta on this head is owed. Not governed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 5e17df249a7cb8e7f5db96135b8699eedb46ce6b
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/19.knowledge-search-uncoded-adapter-throw-refused.ts + packages/services/service-knowledge/src/knowledge-service-search.ts, knowledge-service.ts, knowledge-service-top-level.ts, knowledge-tools.ts (same directory), and .changeset/38728-uncoded-search-throw.md read line by line against them
Security-touching: no
Rule-change-verified: none

Delta review of PR #38761 (card #38728) from a6416d79 and record 7280553997 (S1, S2 open; N1 to N4). Read: claim amendment 3 (7280639195), dev report 7282174631, the final-head note 7282911418, L1 delta ACCEPT 7283143894, the PR body's BREAKING section, the 11-file list against main, commit 5e17df24 hunk by hunk, and the check-runs on this head. The head is a merge of main (306770c) plus that one commit. Nothing was built or run; every cell is a reading.

① Derived judgments

  • Code moves by one constant: right. The catch in searchRound writes code: UNMOUNTED_ADAPTER_CODE, imported from knowledge-service-top-level.ts, where it is 'SERVICE_UNAVAILABLE'. The refusal's four members and every answer are byte-identical to a6416d79. Everything else under src outside __tests__ is docblock text.
  • No answer moves in this delta. The accept set, the exports and the types are those the first record judged; Metadata-protocol: none holds.
  • The two new pins hold the two cells S2 named. (a1): two sources both throwing uncoded reject SERVICE_UNAVAILABLE / 503 with refused naming each in order, the thrown text absent from the message. (a2): an uncoded throw first, an adapter-coded 409 second, none answering, rejects with the first's code and status and refused naming both with their own codes. Both go red without the catch's push (L1's ablation, five tests).
  • Check-runs on this head: 66 success, 13 skipped, none failed, cancelled or running. mergeable_state is clean.

② Semver level

Clause-②: no (narrowing) — unchanged and still right. The changeset keeps @objectstack/service-knowledge and @objectstack/spec at patch with the BREAKING paragraph, the FROM → TO list and the adr-0087: registered knowledge-search-uncoded-adapter-throw-refused marker; the three added docblock files publish from @objectstack/service-knowledge, already named. Check Changeset is success (both runs).

Dogfood battery (opt-in) is success on this exact head, with shards 1/3, 2/3 and 3/3.

③ Boundary flags

  • Dev report 7282174631 raises no open question. The three docblock files entered the surface by claim amendment 3 before the commit.
  • The first record's escalation (a card for the stand-in embedder's uncoded "No embedder is configured" error) is the seat's and is not touched by this delta; it stays owed outside the PR.
  • SQL push-down: no finding. The delta adds no query.
  • Overlap: the surface now includes docblocks in knowledge-service.ts, knowledge-service-top-level.ts and knowledge-tools.ts beside the two hunks in knowledge-service-search.ts; epic 专题:知识检索重排(rerank):知识源开关 + 部署配置模型,开了就一律重排 #38750 row 2 rebases over whichever of them it meets.

④ Design judgment

S1: closed. The KnowledgeService.search docblock no longer says a failure is logged and dropped: it states that an adapter throwing without both an ADR-0112 code and status is refused as SERVICE_UNAVAILABLE (503) under a platform sentence, its own message on the operator's error line only, and that no refused source is answered as no hits. searchWithRefusals, KnowledgeSearchRefusal (the type and its code, status and message) and SearchKnowledgeRefusedSource (the type and its message) each carry the uncoded case and say the message is the platform's, never the adapter's text. Each sentence agrees with the catch.

S2: closed. The entry's surface, replacement and acceptanceCriteria, the changeset's BREAKING paragraph and FROM → TO list, and the PR body word cell (a) as "no searched source answers and at least one threw without a code", with (a1) every source throwing uncoded ({ hits: [] } to 503, refused naming each) and (a2) an uncoded throw beside a coded refusal (both named; the rejection's own code and status may move from 409 to 503). The changeset's sentence on coded refusals now claims only the coded source's own refused entry as unchanged. Both cells are pinned.

No must-fix, no should-fix.

Nits

  • N1: closed. The entry and the changeset say the MCP rejection's envelope is code, message and status, the sources named in the message.
  • N2: closed. "Does not carry both an ADR-0112 code and status" throughout.
  • N3: closed. The constant replaces the literal.
  • N4: stands as the accepted deviation (503 for every uncoded throw, an adapter's programming fault included).
  • N5 (new) — "the first refusal in source order", in the search docblock, the entry's (a2) and the changeset's cell 2. wholeRefusal takes the first entry of refused, and planSearches appends an index-not-proven refusal (KNOWLEDGE_REBUILD_REQUIRED, 409) before any round runs. So a source refused there precedes every round refusal whatever its place among the sources, and beside it an uncoded throw never takes the top-level code. Among refusals raised in the round (the pinned cell) the wording is exact, and "may now read 503" keeps the declaration on the safe side. "The first refusal recorded" is the exact phrase; a follow-up on a prose pass, not owed here.

Held, after trying to break it

  • The merge of main brings no change to the catch, to wholeRefusal or to codedRefusalOf; the PR's patch of knowledge-service-search.ts against main is the first record's two hunks plus the one import line.
  • The docblocks claim nothing the code does not do: no sentence promises the adapter's text, a remedy, or a status other than 503 for an uncoded throw.
  • The entry's acceptanceCriteria no longer ties the 503 to "the only source searched"; it holds for one source and for several.

Implemented-by: claude/issue-38728-uncoded-search-throw
Reviewed-by: session_01ADHkmSAjFEZHRpRq3WCj6z

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

维护者速读

  • 用户能看到什么变化: 知识源的存储适配器检索时抛了一个不带错误码的错,以前当成「零命中」悄悄返回,现在这个源会被拒绝,写进 refused。所有被搜的源都没作答、且至少一个是这种无码抛错时,整次检索回 503,不再回空结果。
  • 为什么做: 卡 service-knowledge searchRound: an adapter throw without a code, such as an embedder failure, reads as zero hits for that source, with no refusal #38728。把故障当成「没找到」会让 AI 照着空结果去答。
  • 出错会怎样: 只有无码抛错的路径受影响,带码的拒绝不变。最坏是某种程序错误也回 503,这是记录里接受的偏差 N4。撤销合并即可恢复。
  • 要你做什么: 这个 PR 声明了收窄(!,Clause-②: no (narrowing)),合并队列的收窄守卫按 Tier H 处理,需要你批准;批准后由席位落地。

Seat opinion: land as is.

席位核对

ACCEPT at head 5e17df249a7cb8e7f5db96135b8699eedb46ce6b · Tier H by the queue guard's narrowed-spec leg · Fixes #38728

  1. Shape: knowledge-service-search.ts (the catch: an uncoded throw refuses the source), four public docblocks restated, one semantic migration entry, a BREAKING changeset, and pins (a1), (a2) and (b).
  2. Premise: a coded refusal already had this shape. The uncoded one now has the same report entry and the same HTTP/MCP path (L2 7280553997 ①).
  3. Gates: on this head 66 success, 13 skipped, 0 failed. Dogfood battery (opt-in) passed with 3 shards. patch on @objectstack/service-knowledge and @objectstack/spec carries the BREAKING banner and the ADR-0087 marker.
  4. Accepted deviations: N4 (503 for every uncoded throw, including an adapter programming fault). N5 is prose ("first refusal in source order" is inexact for an index-not-proven refusal), left as a follow-up.
  5. Out of scope and where it went: the host-mounted stand-in embedder's uncoded error → service-knowledge: the stand-in embedder a host mounts with no embedder configured throws without a code, so every search answers 503 with no remedy once #38761 lands #38775. Epic 专题:知识检索重排(rerank):知识源开关 + 部署配置模型,开了就一律重排 #38750 row 2 rebases over this PR's hunks.
  6. Landing: L1-b delta ACCEPT 7283143894 and L2 delta PASS 7283286102 on this head. Lands after os-zhuang approves.

ACCEPT → comment 7283143894 · Contract review → comment 7283286102

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 30, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 30, 2026 15:52
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit c8b1dbb Nov 30, 2026
87 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-38728-uncoded-search-throw branch November 30, 2026 16:22
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 30, 2026
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 needs:dogfood-battery size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service-knowledge searchRound: an adapter throw without a code, such as an embedder failure, reads as zero hits for that source, with no refusal

3 participants