Repository navigation
fix(service-knowledge)!: a source whose adapter's search throws without a code is refused, never answered as no hits - #38761
Conversation
…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
📓 Docs Drift CheckThis PR changes 2 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 182 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 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
|
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
…ded refusal Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
|
repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v Final head for review — zone o3-K · 2026-11-30T12:54Z |
|
repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB 席位核对REWORK @ 6348efa (card #38728, Must-fix 1. The body asks L1 to judge its "Clause-② note". My judgement: the Two answers that succeeded on
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:
Read and found right:
Checks at this head (read before writing): 41 success, 20 skipped, 0 failure. |
…ith FROM -> TO Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
… ADR-0087 ledger Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
|
repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v Final head for review — zone o3-K · 2026-11-30T13:45Z |
|
repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB 席位核对ACCEPT @ a6416d7 (card #38728). This is a delta from 6348efa and my REWORK 7279138481. There are two commits, changing only
Checks at this head (read before writing): 66 success, 19 skipped, 0 failure. One |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract reviewServed-tier: 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 ① Derived judgments
② Semver levelClause-②: no (narrowing) — confirmed. Nothing an author or caller may newly send is accepted; two answers go from success to refusal.
③ Boundary flags
④ Design judgmentS1 (should-fix) — the published docblocks that state this contract still describe the retired outcome.
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
Nits
Held, after trying to break it
Implemented-by: VERDICT: PASS |
…coded-search-throw
…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
|
repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v Final head for review — zone o3-K · 2026-11-30T15:22Z |
|
repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB 席位核对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 The merge is clean. Main between the two bases touched one of this PR's files, the pgvector The code moves by one constant. The catch in S1. The four public docblocks now say what the code does. The four are S2. The changeset's BREAKING paragraph, its FROM → TO, and the entry's header,
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
Checks at this head (filter=all): 66 success, 13 skipped, 0 failure. |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract reviewServed-tier: Delta review of PR #38761 (card #38728) from ① Derived judgments
② Semver levelClause-②: no (narrowing) — unchanged and still right. The changeset keeps
③ Boundary flags
④ Design judgmentS1: closed. The S2: closed. The entry's No must-fix, no should-fix. Nits
Held, after trying to break it
Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z 维护者速读
Seat opinion: land as is. 席位核对ACCEPT at head
ACCEPT → comment 7283143894 · Contract review → comment 7283286102 |
Requested by Steve · project thread
Fixes #38728
repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v
Clause-②: no (narrowing)
Metadata-protocol: none
维护者速读
BREAKING
BREAKING for a caller of a knowledge search (the
search_knowledgetool, its MCP HTTP and stdio faces, and in-processKnowledgeService.search/searchWithRefusals) when a source's adapter throws fromsearchwith an error that does not carry both an ADR-0112codeandstatus(an embedder that cannot be reached, a timeout outside the store). The search now names that source inrefused, codedSERVICE_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'serrorlog 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 ownrefusedentry; 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 entryknowledge-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:
{ hits: [] }. TO: rejectedSERVICE_UNAVAILABLE/ 503 withrefusednaming each source (thesearch_knowledgeexecutor and in-processsearchreject withrefused; MCP answers an error result whose envelope iscode,messageandstatus, the sources named in the message).code/statusandrefusednaming it alone. TO:refusednames both, and the rejection's top-levelcode/statusare the first refusal's in source order, so a 409KNOWLEDGE_REBUILD_REQUIREDrejection may now read 503SERVICE_UNAVAILABLE.Fix for each reader: a caller reads
refusedand the 503 instead of treating an empty answer as no match; an operator repairs the adapter or embedder theerrorline names.What changes
searchRound(packages/services/service-knowledge/src/knowledge-service-search.ts) catches an adapter's throw fromsearch. A coded refusal (ADR-0112code+status) was already pushed torefused; any other throw was only logged aterror, so the source read as zero hits. Now an uncoded throw is pushed torefusedas{ sourceId, code: 'SERVICE_UNAVAILABLE', status: 503, message }, wheremessageis a platform sentence naming the source and its adapter id (never the thrown text, which can carry hosts, SQL or keys). The operatorerrorline 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 orStandardErrorCodechange. 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:
first.size === 0 && refused.length > 0), the search is refused whole (wholeRefusal), so a search whose only source's embedder is down now rejects withSERVICE_UNAVAILABLE/ 503 andrefused, instead of resolving[].refusedInRefill).Public doors
Measured on
origin/mainacf3b33 plus this branch; there is no REST knowledge search route (a grep ofpackages/rest/srcandpackages/runtime/srcfor a knowledge search route finds none; the same grep finds thesearch_knowledgeregistrations below).search_knowledgeexecutor,packages/services/service-knowledge/src/knowledge-tools.ts:662-671: with other sources answering, the tool output now carriesrefused: [{ sourceId, code: 'SERVICE_UNAVAILABLE', message }]beside their hits (before: norefused, the source silent). When it is the only searched source, the executor rejects with the whole refusal (wholeRefusal, thrown atknowledge-service-search.ts:231, or:258on a refill):code: 'SERVICE_UNAVAILABLE',status: 503,refusednaming the source (before:{ hits: [] }).search_knowledge,packages/mcp/src/mcp-http-tools.ts:3824-3826(registered for HTTP atmcp-http-tools.ts:3428viapackages/runtime/src/domains/mcp.ts:1786, and for stdio atpackages/mcp/src/plugin.ts:1068viastdio-data-bridge.ts:1998): the partial case returns the text result withrefused; the only-source case returnserrorResultWithCode(mcp-http-tools.ts:1636), an error result with the ADR-0112 envelopeSERVICE_UNAVAILABLE/ 503 (before: a text result with no hits).KnowledgeService.search/searchWithRefusalscallers (no other non-test caller in this repo): same as the executor.Tests
New
src/__tests__/search-uncoded-throw-38728.test.ts(5 cases): plainErrorgives onerefusedentry naming the source (code + status asserted, thrown text absent from the caller's message, present in theerrorline), 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" -> refusedSERVICE_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 rejectsSERVICE_UNAVAILABLE/ 503 namingdocs.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.oktrue,s.hits0) -> "a failed embed is counted, and the search is refused SERVICE_UNAVAILABLE naming the source, with the service's "search failed" line":s.okfalse,s.errorCodeSERVICE_UNAVAILABLE, the thrown refusalSERVICE_UNAVAILABLE/ 503 withrefusednamingclauses;embedFailures1,calls.ranking0 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.tspackages/services/service-knowledge/src/__tests__/search-uncoded-throw-38728.test.tspackages/services/service-knowledge/src/__tests__/knowledge-service.test.tspackages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.tspackages/services/service-knowledge/src/__tests__/knowledge-tools.test.tspackages/plugins/knowledge-pgvector/bench/instrument.test.mjs.changeset/38728-uncoded-search-throw.md(@objectstack/service-knowledgeand@objectstack/specpatch,fix(service-knowledge)!:,Clause-②: no (narrowing), the ADR-0087registeredmarker)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)
pnpm --filter @objectstack/service-knowledge test: Test Files 26 passed (26), Tests 841 passed (841).pnpm --filter @objectstack/service-knowledge typecheck(tsc oversrc, tests included, pluscheck:test-typecheck): exit 0.acf3b33eon disk, new file run: 3 failed / 2 passed (the three uncoded pins red; coded and no-match pins green). Fix restored.check-plugin-teardown-shape --self-test(exit 3, shallow-clone prerequisite, NOT MEASURED) andcheck:type-check-debt(local 100 s timeout, NOT MEASURED). The other 29 are left to CI.overlap-check.mjs: VERDICT clean exit 0 (merges cleanly with main, feat(service-knowledge): read a source's retrieval mode and refuse a mode its store does not run #38722, feat(studio): the knowledge source retrieval-mode picker offers the modes its store runs #38730, docs(knowledge): search_knowledge says what a score means; the AI skill lists source.retrieval.mode #38732).bench/instrument.test.mjsalone 8 passed (8);pnpm --filter @objectstack/knowledge-pgvector test46 passed, 95 skipped (live-postgres); knowledge-turso 301 passed; knowledge-memory 66 passed; overlap-check VERDICT clean exit 0 (also fix(knowledge-pgvector): read only the passages in scope for a metadata-scoped search, through a GIN index on metadata #38758).Acceptance notes
searchRound(the only runtime hunk); then the refill pin flip inknowledge-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).content/docs/protocol/knowledge.mdxnot 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