Skip to content

feat(service-knowledge): read a source's retrieval mode and refuse a mode its store does not run - #38722

Merged
objectstack-fleet[bot] merged 35 commits into
mainfrom
claude/project-thread-vj79kz-service
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 35 commits into
mainfrom
claude/project-thread-vj79kz-service

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Part of #38692

Clause-②: no
Metadata-protocol: none

维护者速读

  • 知识源声明了检索方式后,搜索就按它执行;没声明的按存储默认。存储不支持所声明的方式时,保存时直接报错并列出可选方式,启动后记一次错误日志,每次搜索都把它列为未检索,绝不悄悄换成别的方式。
  • 属于知识管理专题「一期 a:检索方式」。
  • 出错会是本该能搜的知识源被拒;未声明方式的知识源行为不变,可直接撤回。
  • 无。

Stack

Base: main. #38700 (the facade split) has merged and main is merged in. The spec PR #38720 merged as f576dee and main is merged in, so this diff is the service's own 15 files. The phase-0 ADR note (#38714) is merged too. Independent of the adapter PRs. The Studio form PR stacks on this one.

What changes

  • New knowledge-retrieval-mode.ts: the effective mode is the source's source.retrieval.mode, else the adapter's capabilities.retrieval.default; an adapter reporting no modes is never told one.
  • The four refusal points for a declared mode the adapter does not list, never searched another way:
    1. save (admitAuthoredSource): 400 VALIDATION_ERROR, listing the modes the store runs;
    2. registration in code (registerSource): the same refusal, only when the adapter already resolves (startup registry reads). A published item (registerMetadataSource, the loader) is not refused there: the loader runs after every store has started, so a refusal would drop it whole; it is registered and indexed, and points 3 and 4 refuse it (review M1);
    3. once after boot (reportUnsupportedRetrieval, called at kernel:bootstrapped beside reportUnmountedAdapters), at error;
    4. every search (planSearches): listed in refused with SERVICE_UNAVAILABLE (503), the code an unmounted adapter's source already carries.
  • Every search hands the store AdapterSearchOptions.retrieval and logs the mode and its origin at debug; the caller's answer carries neither.
  • index_status entries carry retrieval (declared, effective mode, origin, the store's modes, refused), and the answer lists each mounted store's modes (details.adapters) and the store a source naming none binds to (details.defaultAdapter), the data the Studio form PR reads. New service member describeRetrieval.
  • Contract suite: service-level cases for every adapter (a listed mode is handed through; an unlisted one is refused at registration in code and at every search, and still indexes; a published item loaded after its store started is registered, indexes, is named by the boot reading and is refused on every search).
  • Liveness row flips to live; protocol doc §3.1 and the save guard; patch changeset.

Tests

  • New retrieval-mode-38692.test.ts (16 cases): resolution, refusal text, each refusal point, debug log and its absence from the answer, still indexes, the loader path (a published item with its store already started), plugin hook, index_status.
  • service-knowledge: 861 passed (26 files, at 1a7ba24); typecheck clean. knowledge-memory 70 passed and knowledge-turso contract 110 passed against this head's suite. knowledge-memory contract 54 passed; knowledge-turso 110 contract passed; live pgvector contract 55 passed.
  • With each adapter PR merged in locally: turso 326 passed, pgvector against live PostgreSQL 133 passed.

Acceptance notes

  • The per-search refusal code is reused rather than added: SERVICE_UNAVAILABLE (503), the code an unmounted adapter's source already carries. The ruling and the phase-0 note say only "with its code"; open question C, confirmed by Warren on 2026-11-30 at 12:40Z (「同意」): the refusal stays 503.
  • Declared Metadata-protocol: none: what an author can write was added by the spec PR; this PR reads it. The save refusal of a mode the store does not run is the shape the ruling gives the key from birth, in the same release.
  • Facade gate: knowledge-service.ts 1681 lines of 1758; both new members are one-call delegations.

Verification

  • Two-minute check: pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/retrieval-mode-38692.test.ts → 16 passed.
  • Related local gates (26 of dispatch-gates.mjs --commands: docs, liveness, changeset, facade, error-code, ledger): all green.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request. (Stacked: see "Stack" above.)
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf

…o on its facet body

Claude-Session: https://claude.ai/code/session_01JQwxbZLuMpo8YX4ACmyoNd
Co-authored-by: Claude <noreply@anthropic.com>
…ies at their modules

Claude-Session: https://claude.ai/code/session_01JQwxbZLuMpo8YX4ACmyoNd
Co-authored-by: Claude <noreply@anthropic.com>
… mode its store does not run

The effective mode is the source's `source.retrieval.mode`, else the store's
`capabilities.retrieval.default`; every search hands it to the store as
`AdapterSearchOptions.retrieval` and logs it at debug with its origin, never in
the caller's answer. A declared mode the store does not list is refused at the
save (400 VALIDATION_ERROR, listing the store's modes), at registration when the
store already resolves, once after boot at error (`reportUnsupportedRetrieval`),
and on every search (`refused`, SERVICE_UNAVAILABLE); such a source still
indexes. `index_status` carries each source's retrieval reading and each store's
modes. The liveness row flips to live.

Claude-Session: https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf
Co-authored-by: Claude <noreply@anthropic.com>
…e its per-search refusal code

ADR-0161's K2 row on the adapter surface no longer says "no hybrid toggle":
the contract carries the modes an adapter runs and the mode a search runs in,
which a source declares. Protocol doc 7.1 says the same. The contract doc of
AdapterSearchOptions.retrieval names the refusal of a mode the adapter does not
list: SERVICE_UNAVAILABLE in a search's refused, VALIDATION_ERROR at save and
registration.

Claude-Session: https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf
Co-authored-by: Claude <noreply@anthropic.com>
@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 40 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/services/service-knowledge/src/index.ts, packages/spec/liveness/knowledge_source.json, packages/spec/liveness/state-counts/knowledge_source.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/ai/connect-mcp.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/ai/knowledge-rag.mdx (via KnowledgeService (symbol, a top-level class), SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/api/client-sdk.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/api/error-catalog.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/api/index.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/automation/webhooks.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/deployment/self-hosting.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/kernel/runtime-services/email-service.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/permissions/authentication.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/permissions/authorization.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/permissions/sharing-rules.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/permissions/system-context.mdx (via admitAuthoredSource (symbol, a top-level function))
  • content/docs/protocol/kernel/error-handling.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/protocol/knowledge.mdx (via KnowledgeService (symbol, a top-level class), admitAuthoredSource (symbol, a top-level function), registerSource (symbol, a top-level function), runKnowledgeAdapterContract (symbol, a top-level function), SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract), getAdapter (literal, a string literal in KnowledgeBuildActionsService), listAdapters (literal, a string literal in KnowledgeBuildActionsService; a string literal in admitAuthoredSource), registerSource (literal, a string literal in registerSource))
  • content/docs/ui/print-pages.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))

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

  • content/docs/releases/v17/17-0.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/releases/v17/17-3.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/releases/v17/17-4.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/releases/v17/17-7.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/releases/v18/18-2.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))
  • content/docs/releases/v18/18-5.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in RETRIEVAL_UNSUPPORTED_CODE; a string literal in runKnowledgeAdapterContract))

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
  • 3 changed file(s) yielded no anchor (packages/services/service-knowledge/src/index.ts, packages/spec/liveness/knowledge_source.json, packages/spec/liveness/state-counts/knowledge_source.md) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 40 pages)
  • 7 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 f576dee5816597cfe3aa044a3f6020754c48327b → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ 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 f576dee5816597cfe3aa044a3f6020754c48327b → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added documentation Improvements or additions to documentation protocol:ai tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 30, 2026
…ames none binds to

Claude-Session: https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf
Co-authored-by: Claude <noreply@anthropic.com>
…-vj79kz-service

# Conflicts:
#	packages/services/service-knowledge/src/knowledge-service-admission.ts
#	packages/services/service-knowledge/src/knowledge-service-search.ts
#	packages/services/service-knowledge/src/knowledge-service-sources.ts
#	packages/services/service-knowledge/src/knowledge-service-top-level.ts
#	packages/services/service-knowledge/src/knowledge-service.ts
@github-actions github-actions Bot added size/l and removed size/xl labels Nov 30, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract-review-claim: session_01JQwxbXyLoBzNYY1U8SNPFu · head b69e471 · 2026-11-30T13:34Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract review

Served-tier: TIER_DEFAULT
Head-sha: b69e471406a7ae601cc83eae386efecc6df51f4c
Local-runs: none

Delta review of PR #38722 (card #38692, phase 1a part 3) against record 7278787062 at 1a7ba24040. The delta is one commit, the merge b69e471406 of main at f576dee581 (#38720, squash-merged). The face changed with it: the PR's file list is now its own 15 files, none of them a published schema or a governed path, and its declaration is Clause-②: no with no arm, so record-recognisers.mjs reads no schema, rules or narrowing face and names --face declaration, whose tier and shape this record carries (no Scope: line, no ④). The four spec and ADR files that made the earlier rounds CONTRACT_REVIEW_TIER are on main now and are identical here to main. Read: the merge's own resolution (git show --remerge-diff), git diff 1a7ba24040 b69e471406, git diff origin/main...b69e471406, the PR body and the check-runs.

① Derived judgments

Nothing the PR authored moved. All 15 files of the PR's diff against main are byte-identical at this head and at 1a7ba24040, the head record 7278787062 passed; every path that differs between the two heads is a path main itself changed. So each judgment of records 7278640820 and 7278787062 stands as written, and M1 and M2 stay closed:

  • M1: closed. registerMetadataSource does not call refuseUnsupportedRetrieval; registerSource does. The loader case and the suite's published-item arm are in the tree unchanged.
  • M2: closed. Section 4.1 (knowledge-pgvector) of content/docs/protocol/knowledge.mdx is byte-identical to origin/main; the file's diff against main has two hunks, at lines 182 and 260, both in section 3.1.

The merge resolved four files by hand, not three; the fourth is the generated count packages/spec/liveness/state-counts/knowledge_source.md. Each resolution takes the service side whole, and in each the service side is the main side plus this PR's change, so both intents are kept:

No spec file and no ADR line differs from main.

② Semver level

@objectstack/service-knowledge patch, Clause-②: no, Metadata-protocol: none, in the PR body and in the changeset body: unchanged, and correct. No line reads Clause-②: yes (narrowing) or Metadata-protocol: narrowed, and none is owed: #38720 is merged and not released, so the save's refusal of a mode the store does not run still narrows nothing published. That holds only while no release is cut between the two merges. "Check Changeset" is green on this head; the stack artefact that failed it before is gone with #38720's merge.

③ Boundary flags

  • Open question C: closed. The PR body records the maintainer's confirmation of SERVICE_UNAVAILABLE (503) at 2026-11-30T12:40Z (「同意」); the tree is unchanged.
  • N4 (nit) — the PR body's "Stack" paragraph still says the diff carries feat(spec): a knowledge source declares its retrieval mode; an adapter reports the modes it runs #38720's commits "until it merges"; it has merged. Body edit only.
  • N5 (nit) — the header sentence of testing.ts says "refused at registration", where the code and the case title say "registration in code". As it stood at 1a7ba24040; left as written.
  • N1, N2 and N3 of the earlier records stand as accepted.
  • SQL push-down: nothing added.

No must-fix, no should-fix.

Check-runs on this head, read at 2026-11-30T13:35Z: 51 runs, 16 success, 11 skipped, 24 in progress, none failed or cancelled. "Check Changeset" and "Spec property liveness" are green. "Build Docs", the type-check lanes and the test shards had not concluded, so this record does not read them; the seat adopting it reads them before the queue.

Implemented-by: claude/project-thread-vj79kz-service
Reviewed-by: session_01JQwxbXyLoBzNYY1U8SNPFu

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 25a6dee2cd0baa4160380ce75b03ac586ad768c4
Local-runs: none

Delta review of PR #38722 (card #38692, phase 1a part 3) against record 7280097343 at b69e471406. The delta is one commit, 25a6dee2cd, on top of that head; no merge. The face is unchanged: the file list is the same 15 paths and the declaration is Clause-②: no with no arm, so this is the declaration face. Read: git diff b69e471406 25a6dee2cd, the changeset and the PR body at this head, and the check-runs.

① Derived judgments

The delta is one added line and nothing else: '@objectstack/spec': patch in the front matter of .changeset/38692-knowledge-retrieval-mode-service.md. No source, test, doc or ledger file moved, so every judgment of record 7280097343 stands as written.

② Semver level

Correct. The PR edits packages/spec/liveness/knowledge_source.json and its state count, and liveness is in the files list of packages/spec/package.json, so the diff moves what @objectstack/spec publishes and the changeset must name the package. The level is patch: the edit is a ledger flip (planned to live, the warning dropped), it adds no key and no accepted value, and Metadata-protocol: none takes patch. @objectstack/service-knowledge stays patch. Clause-②: no and Metadata-protocol: none are unchanged in the changeset body and the PR body. Both packages are in the fixed group, where the release level is already the minor of #38720's changeset. "Check Changeset" is green on this head.

③ Boundary flags

Nothing opened and nothing closed by this delta. N1 to N5 of the earlier records stand as accepted. SQL push-down: nothing added.

No must-fix, no should-fix.

Check-runs on this head, read at 2026-11-30T13:58Z: 76 runs, 52 success, 14 skipped, 10 in progress, none failed or cancelled. "Check Changeset", "Build Docs" and "Spec property liveness" are green. The 10 still running are eight "Test UI" shards, "Test Core (5/12)" and "Type Check UI"; this record does not read them, and the seat adopting it reads them before the queue.

Implemented-by: claude/project-thread-vj79kz-service
Reviewed-by: session_01JQwxbXyLoBzNYY1U8SNPFu

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

维护者速读

席位核对

ACCEPT · L1 · area o2-A · Head-sha 25a6dee2cd0baa4160380ce75b03ac586ad768c4 · 2026-11-30T14:08Z

  • Contract review: rounds 7278640820 (FAIL: M1, M2) and 7278787062 (PASS at 1a7ba24), then the delta 7280097343 at b69e471 for the merge of main (feat(spec): a knowledge source declares its retrieval mode; an adapter reports the modes it runs #38720 merged as f576dee): PASS, no must-fix, no should-fix. All 15 PR files are byte-identical to 1a7ba24; the four hand-resolved files keep both sides; §4.1 pgvector equals main.
  • Since b69e471, one line only, read by the seat: '@objectstack/spec': patch added to .changeset/38692-knowledge-retrieval-mode-service.md, because the diff edits packages/spec/liveness/ (shipped in spec's files[]) to flip the retrieval row from planned to live. l1-face now reads changeset ok for both packages.
  • Clause-②: no · Metadata-protocol: none, with no narrowing arm. None is owed: feat(spec): a knowledge source declares its retrieval mode; an adapter reports the modes it runs #38720 is merged but not released, so the save's refusal narrows nothing published. check-governed-merges: NOT governed, 899 lines.
  • Refusal code 503 SERVICE_UNAVAILABLE for a search in a mode the store does not run: confirmed by the maintainer at 2026-11-30T12:40Z, as recorded in the PR body.
  • Nits N4 (the body's "Stack" paragraph) and N5 (the testing.ts header wording) stay as accepted deviations.
  • Checks at this head: 64 success, 14 skipped, 0 failed, 0 pending. The two opt-in dogfood battery jobs skip as designed; the battery is not owed (no !, no narrowing arm). Same-head delta record 7280662071: PASS at 25a6dee.
  • Landing: Tier S, --land. Part of #38692: the card keeps its labels for phase 1b and phase 2 (seat 3).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 14:08
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit d316627 Nov 30, 2026
79 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-vj79kz-service branch November 30, 2026 14:36
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…the knowledge service reranks after the permission re-check (objectstack-ai#38764)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DAwBxBGNv4CexdUyBYJXSw)_

Fixes objectstack-ai#38760
Refs objectstack-ai#38750

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:用户无感;知识平台边界那份架构决策记录里追加一条 2026-11-30
的说明,写明知识源可以声明自己的检索结果要重排、用哪个重排模型由部署方配置、由知识服务在权限复核之后统一重排,不改任何代码。
- 为什么做:这是知识检索重排专题的第一步,把你当天说的「有就用」和「开了开关,一律重排」写进决策记录,后面几步的实现才有依据。
- 出错会怎样:说明里若有和你的裁决不一致的句子,后面做实现的人会照着错的文字去做;它只是一处文档追加,可以直接撤回,不影响任何在运行的系统。
- 要你做什么:请你审阅并批准这条说明;它改的是受管的决策记录,你批准它,由知识服务在权限复核之后重排这一条就算正式记下,不再另开决策卡。

## 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 sixth dated note: 28 lines added, none changed and none
removed (614 lines to 642).

The note records the maintainer's rulings of 2026-11-30 on the epic for
knowledge retrieval rerank. A knowledge source may declare that its
searches are reranked. The deployment configures the reranker, and no
source names a model. The knowledge service reranks, after the
permission re-check and before the cut to `topK`. The adapter contract
does not change.

Five insertions, in the form the five earlier notes of this record use.
Line numbers are at head `6552e290`.

| Lines | Where | What is added |
|---|---|---|
| 24 | Header, after the `**Amended**` line of the fifth note | A sixth
`**Amended**` line, dated 2026-11-30. It names what the note amends, the
maintainer's words with their times, and ruling record `7276086125`. |
| 142 to 161 | K1, under "What follows from the two lists" | The note
itself: an opening paragraph, 16 bullets and a last paragraph. |
| 186 | K2, under "The rule for all of them" | A cross-reference. Three
rows of the table name rerank and are read with the note. |
| 281 | K4, in the cross-reference block that is already there | A
cross-reference. One more source key is declared,
`source.retrieval.rerank`. |
| 468 | K8, under the note of 2026-11-30 | A cross-reference. Rule 4 and
three sentences of that note are read with the note. |

### Each amended place

No existing line is edited. This record's convention is add-only, so the
note quotes the old sentence and states how it reads from the merge. The
two sentences marked "new sentence" are the note's own wording. Every
other entry in the third column is the note's reading of a text it
leaves as written.

In the last column, "body 1" to "body 3" are items 1 to 3 under
"Rulings" in the body of the epic, which record the maintainer's 「有就用」
(10:13Z) and 「所以还是应该按照主流系统的做法,开了开关,一律重排」 (10:37Z). "D1" to "D4" are the
first four of the six decisions of the epic that he answered with 「全部同意」
(10:47Z), as ruling record `7276086125` on the epic records them.

| Place, with its line on `main` at `acf3b33e` | Old sentence | New
sentence or reading | Ruling |
|---|---|---|---|
| K1, the "Rerank" row of the adapter's table (104) | "Whether a second
model reorders candidates, and which." | Reading: neither is the
adapter's. Whether: a knowledge source declares it. Which: the
deployment configures the reranker, and no source names a model. The
knowledge service reranks, after the permission re-check and before the
cut to `topK`. The row keeps the adapter's own search. | body 1, D1 |
| K1, the second sentence of the list (112), as the note of 2026-11-29
left it (119) | "The service does not choose a model, compute a vector,
compute a score for a candidate, rerank or parse a file. It may re-order
the hits it is about to answer by the ordering their source declares
against a fact about the caller that the platform resolves, by position
alone, and it changes the order the adapters answered in no other way."
| New sentence: "The service does not choose a model, compute a vector,
compute a score for a candidate or parse a file. It may re-order the
hits it is about to answer in two ways, and it changes the order the
adapters answered in no other way: by the ordering their source declares
against a fact about the caller that the platform resolves, by position
alone; and by reranking them, where their source declares it and the
deployment has configured a reranker, after the permission re-check and
before the cut to `topK`." | D1, body 1 and 3 |
| The note of 2026-11-29, one sentence (119) | "This is not rerank,
which stays the adapter's in the table above: the service reads no
passage text and calls no model to do it." | Reading: the re-order by a
declared ordering is still not rerank, and the service still reads no
passage text and calls no model to do it. Rerank no longer "stays the
adapter's". To rerank, the service hands the question and passage text
to a model. | D1 |
| The title (1), the D1 key-words line (9) and TL;DR item 1 (41) | Each
says that adapters own rerank. | Reading: the word "no longer covers
whether the hits of a search are reranked, by which model, or by whom,
and it covers only what an adapter does inside its own search". | body
1, D1 |
| K2, three rows (149, 153, 157) | "Engines are integrated for
embedding, hybrid retrieval, rerank and file parsing."; the "no rerank"
of the §3.4 row; "Embedding calls, vector storage, hybrid retrieval and
rerank stay the adapter's." | Reading: the first stays true as a
sentence, because a reranker is an engine the deployment brings, and it
is the knowledge service that calls it. The §3.4 row keeps its "no
rerank", because the adapter contract carries none. Of the third, the
first three stay the adapter's and reranking is the service's. Each text
is rewritten by the PR whose code makes the new sentence true. | D1 |
| K8, rule 4 (417), as the note of 2026-11-30 left it (422) | "Which
provider, which key, how to batch, rerank toggles and parser options
stay in the adapter's own plugin options. Hybrid weights are declared by
the knowledge source. A parameter of one search request is not
configuration." | New sentence: "Which provider, which key, how to batch
and parser options stay in the adapter's own plugin options. Hybrid
weights are declared by the knowledge source, and so is whether its
searches are reranked. The reranker is the deployment's configuration,
and no source names a model. A parameter of one search request is not
configuration." | body 1 |
| The note of 2026-11-30 under K8, three sentences (422, 438) | 「K8 第 4
条:「hybrid weights」改划给知识源声明;rerank toggles、parser options 照旧留在驱动。」; under
「永远不进知识源协议」, 「融合算法及其常数、重排、分数阈值、分词器。平台以后如果统一做重排,那是知识服务的配置。」; "Rerank, a
score threshold, a tokenizer and the fusion algorithm with its constant
never enter the source (section 六, above)." | Reading: "Of rerank, a
switch enters the source and nothing else does: no source names a
reranker or a model. That switch is not an adapter's option. The fusion
algorithm with its constant, a score threshold and a tokenizer still
never enter the source, and parser options stay the adapter's." The
sentence 「平台以后如果统一做重排,那是知识服务的配置。」 stands. | body 1; these words are
later than the rulings that note records (06:00Z to 07:57Z) |

### What the note states beside the amended readings

Each is quoted in the note from the words named here.

- **The source key.** `source.retrieval.rerank`, an optional boolean, in
the `source.retrieval` group the fifth note declares (body 1).
- **No reranker is configured.** The search runs normally, the report
marks the source with the reason `no_reranker` in `notReranked`, and
saving or publishing the source shows a notice. It is never a refusal
and never fewer hits (body 2; the two names are the ruling record's).
- **A reranker is configured and the source declares it.** Every search
is reranked. Only 0 or 1 candidate makes no call and sets no marker. At
most 50 passages are sent per search (body 3).
- **A configured reranker fails or times out.** The adapter order is
kept, the source is marked `failed`, there is one attempt under a limit
of 3 s, and it is not a coded refusal (D2).
- **One model and one wire format for v1** (D3). The note names neither.
- **A hosted deployment.** Hosted reranking comes after row 6 of the
epic shows a gain, or a hosted customer asks. Until then a hosted source
that declares rerank is searched normally and marked (D4).

Left to the rows of the epic by name, under "Not in this note": the
hosted recipient and its charging (D5, which is not decided); how a
deployment states its reranker and what the knowledge service calls it
through (rows 2 and 3); how many candidates are reranked under the
ceiling of 50; how a rerank and a declared `affinity` follow one
another; how the hits of several sources stand against each other; what
`notReranked` looks like on the report and in the answer of
`search_knowledge`; how the notice is shown; a per-search argument on
the tool.

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

## Why

The epic puts the record before the code. Its row 1 is this note, and
the first decision of ruling record `7276086125` says of it: "Accepting
row 1's ADR-0161 note records it; no separate decision card." Until this
note merges, the ADR gives rerank to the adapter in every place the
table above lists, and rule 4 of K8 keeps "rerank toggles" in the
adapter's plugin options. Row 2 of the epic brings the key with its
reader, and it needs the record to say so first.

## 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 on the text itself,
at head `6552e290`:

- **Quotations.** A script compared every quoted span of the 28 added
lines with its source, read over REST or from the ADR at the base. The
added text holds 16 spans in corner brackets: each is a verbatim
substring of the body of the epic, of ruling record `7276086125` or
`7276461244`, or of the ADR at the base where it already quotes the
record of the fifth note. 0 mismatches. It holds 50 spans in double
quotation marks: 48 are verbatim in one of those sources, and 2 are the
note's own wording, which are the two "new sentence" entries of the
table above.
- **Bytes.** The added lines hold no raw control byte, no HTML comment
and no model identifier.
- **The reading of `main` the last paragraph of the note cites**, taken
at `acf3b33e31`.
`packages/services/service-knowledge/src/knowledge-service-search.ts#searchByKey`
re-checks the hits as the caller (`applyPermissionFilter`), orders them
by a declared `affinity` (`affinityOrderFor`) and cuts them to `topK`,
with no rerank between. Tests aside, in
`packages/services/service-knowledge/src` and the `src` of
`knowledge-memory`, `knowledge-pgvector` and `knowledge-turso`, the word
`rerank` is on one line, which is the class note K2 lists. The control
word `embed` is on 412 lines, so the search reads those directories.
- **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

**Against the card's acceptance lines.**

1. "Every amended sentence agrees with the design on objectstack-ai#38750 (option B)
and with rulings D1 to D4." The table above gives each amended place
with the ruling it rests on.
2. "No sentence promises row 2 behaviour that the epic does not rule."
The note states no pool size, no widening factor, no order between
rerank and `affinity`, no settings key name and no shape for the
reranker contract. Each of these is named under "Not in this note" and
left to its row.
3. "The `Amended` line is dated." Line 24, dated 2026-11-30.
4. "The note does not change any other ADR. It adds no code." One file
changes.

**Five things for the approver to weigh.** The note marks no ◆, because
each of these rests on a text this record or the epic already has. They
are the places where the wording is the note's and not a quotation.

- a. **What the "Rerank" row keeps.** The note says the row keeps "the
adapter's own search", and rests that on two sentences this record
already has: "how candidates are found" (the "Hybrid retrieval" row) and
"Changing the adapter changes how candidates are found and ranked"
(Consequences).
- b. **"The declaration is not silent (ADR-0078)".** A source that
declares rerank where no reranker is configured is accepted and its
search is answered. The note reads body 2 against ADR-0078: each such
search says that its source was not reranked, and the author is told on
save and on publish.
- c. **Nothing is registered in K8.** The note says that the reranker's
contract, client and settings (rows 2 and 3 of the epic) are not members
of the adapter contract. It rests that on K8's own definition, under
"What counts as a member": a member is what an adapter author must read,
and no adapter reads these.
- d. **A cross-reference under K4.** The card's list of places does not
name K4. This record gives every new source key a cross-reference there,
as the fifth note did for `source.retrieval`, so one was added. It
changes no sentence of K4.
- e. **The K2 rows are read through a cross-reference and are not
edited.** Draft objectstack-ai#38720 edits the K2 row at line 153 in place, with the
code that makes its new sentence true. This note's sentence about that
row, that it keeps its "no rerank", holds for the row as it is on `main`
and as objectstack-ai#38720 leaves it.

**The names D1 to D6.** This record already writes "ruling D1", "ruling
D2" and "ruling D5" for rulings of its own. The note therefore writes
the six decisions of the epic as `objectstack-ai#38750 D1` to `objectstack-ai#38750 D6`, and says in
its opening paragraph that none of them is a ruling of this record. It
writes `row N of objectstack-ai#38750` for the same reason.

**The card's line numbers, read on `main` at `acf3b33e`.** All twelve
lines the card names (1, 9, 41, 104, 112, 119, 149, 153, 157, 417, 422,
438) exist and carry the text the card expects. Two labels are
exchanged: the card gives 422 for rule 4 of K8 and 417 for the note of
2026-11-30. On `main`, rule 4 is line 417, and line 422 is that note's
bullet "Rule 4, amended", which carries 「永远不进知识源协议」. Line 438 is that
note's bullet "Not in this note". No line moved.

**Overlap with the open drafts on this file.** `node
scripts/pm/overlap-check.mjs --repo=objectstack-ai/objectstack`, run at
`6552e2905b` before the push, printed `VERDICT clean exit 0`. It read
`origin/main` at `acf3b33e31` and the six open heads that change this
file (objectstack-ai#38745, objectstack-ai#38732, objectstack-ai#38730, objectstack-ai#38722, objectstack-ai#38721 and objectstack-ai#38720), and each
merges cleanly with this branch. The order expected exit 1 against
objectstack-ai#38720. It is clean because the note is add-only and inserts at none of
the lines objectstack-ai#38720 changes. It was run again before this pull request
opened, with `origin/main` at `8426fa0c89` (one commit later, which does
not change this file): the same six heads, each merging cleanly,
`VERDICT clean exit 0`. The landing order is the card's: after objectstack-ai#38720.

**Not done here.** `content/docs/protocol/knowledge.mdx` and the class
note of `KnowledgeService` are rewritten by the rows whose code makes
their new sentences true. There is no changeset: `docs/adr/` is
published by no package, and the PR carries `skip-changeset`.

## Verification

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

1. Line 146, the bullet "The sentence of the list, amended again". It is
the one sentence that gives the knowledge service a second way to
re-order hits.
2. Line 156, the bullet "Rule 4 of K8, amended again". The new rule 4 is
composed by this note from body 1.
3. Line 150, the bullet "No reranker is configured". It holds the
reading against ADR-0078 (item b above).

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

**Landing.** `docs/adr/**` is a governed surface. This is opened as a
draft. The hand-off to the maintainer 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 one reading taken after it opened.

**Gates, run locally on head `6552e290`.** `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: 4574 anchors across 165 records resolve — 1704 symbol (1675 declaration, 29 literal), 2818 file-level, 52 cross-repo, 6 exempt, 128 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 29002 text file(s) -- 29002 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes).
✓ doc authoring guard: 24253 customer-facing string(s) across 1963 spec sources clean — no internal issue-id references (message 3603 · strictObject 5655 · tombstone 1510 · describe 12078 · functionBuilt 529 · functionDeclared 878).
```

</details>

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

At the first head, `151609a7`, `pnpm --filter @objectstack/lint run
check:doc-formula-expressions` answered exit 3, PREREQUISITE NOT MET:
two workspace packages it imports were not built in the fresh worktree.
That is a run that measured nothing, not a red gate. The two packages
were built under the shared verify lock, and the gate was run again (the
lock's verdict line is cut after the wait):

```text
VERDICT command-exit 0 · held the lock 23s · waited 167s (2m47s)
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
```

At the final head it ran with the other 20 and answered 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 names the note writes are
the rulings'.
- [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 `acf3b33e31`, one pull
request.
- [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 maintainer'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 by [Claude
Code](https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v)_

<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmPDtfMCw4FJfyFfQ7v -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…r reports the modes it runs (objectstack-ai#38720)

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

Part of objectstack-ai#38692

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up objectstack-ai#38732 (the `source.retrieval.mode` row of the
objectstack-ai skill lands there; `skills/` is a governed path and takes
its own PR)

## 维护者速读

- 知识源作者可以选择检索方式(按意思、按字词、两者结合),不选则沿用存储默认;本单只定义写法与驱动上报,用户暂无可见变化。
- 属于知识管理专题「一期 a:检索方式」,解决条款类问答被语义检索漏掉的问题。
- 出错只会是新写法被误拒或误收;未写此项的知识源行为不变,可直接撤回。
- 无。

## Stack

Base: `main`. First of the phase-1a series; the adapter PRs and the
service PR build on it. The ruling it builds on is on `main`: ADR-0161,
the dated note of 2026-11-30 under K8 (phase 0, merged as 95ffacc);
this branch has `main` merged in.

**Lands together with objectstack-ai#38722, right after it.** This PR adds the key and
both contract members with their suite cases, but no reader: the
service's reader is objectstack-ai#38722, and the two adapters that declare
`implements.retrieval` are objectstack-ai#38721 and objectstack-ai#38745. That splits K8 rule 1 and
K4 ("lands with its first reader, in the same PR") across stacked PRs,
because the stack bases force it. Until objectstack-ai#38722 lands, a declared mode is
carried and ignored, and the `planned` liveness row warns an author so
(`authorWarn` and `authorHint`; objectstack-ai#38722 drops both when it flips the row
to `live`). So objectstack-ai#38720 is not merged or released without objectstack-ai#38722, which
merges right after it.

## What changes

- `knowledge_source.source.retrieval?: { mode?: 'vector' | 'keyword' |
'hybrid' }`, strict from birth; `retrieval: {}` is accepted and declares
nothing. Not part of the index fingerprint or the recipe hash.
- `IKnowledgeAdapter.capabilities.retrieval?: { modes, default }`
(`AdapterRetrievalCapability`) and `AdapterSearchOptions.retrieval?: {
mode }`, optional as every search member is (K8 rule 2); omitted means
the adapter's default.
- Contract suite (`runKnowledgeAdapterContract`):
`implements.retrieval`; a declared report must be valid, and one seeded
fixture is searched under each listed mode (`vector` leaves the
keyword-only clause out, `keyword` answers it alone, the default handed
explicitly equals no member).
- ADR-0161 K2 row and protocol doc §7.1 rewritten (see Acceptance
notes); the contract doc names the refusal code.
- Studio form row for the mode (static three options; PR 4 of the series
makes it list the store's modes), liveness row `planned` (flipped to
`live` by the service PR), protocol doc §3.4, generated baselines.

## Tests

- `packages/spec`: new knowledge-source cases (three modes parse, `{}`
accepted, an invalid mode's message,
`vectorWeight`/`keywordWeight`/`fusion` refused as unknown keys, JSON
Schema enum + `additionalProperties: false`).
- `service-knowledge`: index-fingerprint test pins that neither hash
moves for `{}` or any mode.
- Contract suite exercised by the turso and live-pgvector adapter PRs.

## Acceptance notes

- `AdapterSearchOptions.retrieval` is optional, as built (`retrieval?`,
omitted means the adapter's default, as K8 rule 2 has every search
member): the maintainer ruled it on objectstack-ai#38692 (comment 7272337479,
2026-11-30 07:57Z), the question the phase-0 contract review
(7271729439) escalated.
- Per-search refusal code (point 4), proposed: `SERVICE_UNAVAILABLE`
(503), reused rather than added. It is an ADR-0112 standard catalog code
(`packages/spec/src/api/error-code-ledger.zod.ts`, the standard map), so
no new ledger entry; it is the code a source whose adapter is not
mounted already carries in `refused`, since in both cases the deployment
cannot serve the source as written. It is objectstack-ai#38722's to write and the
maintainer's to confirm (open question C): the contract doc of
`AdapterSearchOptions.retrieval` here names no code. The save refuses
with `VALIDATION_ERROR` (400), as the ruling fixes.
- ADR-0161's K2 row (adapter surface) is rewritten as the row asks of
each PR that adds a member: it no longer says "no hybrid toggle";
protocol doc §7.1 likewise. This makes the PR Tier H (an ADR file is
touched).
- Phase 1b (`vectorWeight`) is not built; the strict shape refuses it
today.

## Verification

- Two-minute check: `pnpm --filter @objectstack/spec exec vitest run
src/ai/knowledge-source.test.ts` → all pass, including the retrieval
describe.
- Local gates from `dispatch-gates.mjs --commands`: all measured gates
green (`check:spec-parsed-alias` found a missing isomorphism pin, fixed
in e805371); not measured in this container (exit 3 or unbuilt closure,
no verdict): `check-plugin-teardown-shape --self-test` (shallow clone),
`check:skill-examples`, `check:dual-build-cjs-loads`, `check:i18n`,
`check:dts-closure`.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [ ] 4. One issue, one branch off an up-to-date `main`, one pull
request. (Stacked: see "Stack" above.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

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

https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… mode (objectstack-ai#38721)

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

Part of objectstack-ai#38692

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

## 维护者速读

- 使用 turso 存储的知识源可以按选定方式检索:只按意思、只按字词或两者结合;不选仍是两者结合,结果与现在逐位相同。
- 属于知识管理专题「一期 a:检索方式」。
- 出错会是某种方式漏掉或多出段落;未声明方式的知识源不受影响,可直接撤回。
- 无。

## Stack

Base: `main`. objectstack-ai#38697, the spec PR objectstack-ai#38720 and the phase-0 ADR note objectstack-ai#38714
are all merged and `main` is merged in, so this diff is the adapter's
own 6 files. It lands in the same release as the service PR objectstack-ai#38722,
which is the first reader of the mode.

## What changes

- `knowledge-turso` reports `capabilities.retrieval = { modes:
['vector', 'keyword', 'hybrid'], default: 'hybrid' }`.
- A search runs only the legs its mode names, in SQL: `keyword` binds no
vector and never calls the embedder (nor reads the one-bit approximate
index); `vector` drops the FTS5 leg.
- A single-leg answer is scored on the same RRF scale: rank n scores
61/(60+n) after normalising, so the first hit is 1. `hybrid` is
unchanged; `fuse(rows, topK, legs)` keeps the two-leg expression
bit-identical.
- README "Retrieval modes" paragraph, protocol doc §4.2 sentence, patch
changeset.
- A mode the store does not list is refused (`400 VALIDATION_ERROR`)
before anything is embedded or read, rather than run on the one-leg
scale (review S1). `Clause-②: yes (widening)`: the exported adapter's
`capabilities` grows `retrieval` (review M1).

## Tests

- New `retrieval-modes.test.ts` on a real libSQL store: legs per mode,
embedder calls, tie order by chunk id, single-leg scores, keyword never
reads `vector1bit(` while vector does, hybrid fusion pinned bit-for-bit.
- Contract suite with `implements.retrieval: true`.
- `knowledge-turso`: 319 passed at 2496e51 (the refused-mode case
added); typecheck clean. Ablation: keeping the keyword leg under
`vector` turns 3 cases red, restored.

## Acceptance notes

- With the service PR applied on top, the full turso suite (326,
including the service-level mode cases) passes.

## Verification

- Two-minute check: `pnpm --filter @objectstack/knowledge-turso exec
vitest run src/__tests__/retrieval-modes.test.ts` → all pass.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [ ] 4. One issue, one branch off an up-to-date `main`, one pull
request. (Stacked: see "Stack" above.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [ ] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

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

https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…al mode; report the three modes, hybrid by default (objectstack-ai#38745)

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

Part of objectstack-ai#38692

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

## 维护者速读

- 使用 pgvector 存储的知识源可以按选定方式检索:只按意思、只按字词或两者结合;不选仍是两者结合,结果与现在逐位相同。
- 属于知识管理专题「一期 a:检索方式」。
- 出错会是某种方式漏掉或多出段落;未声明方式的知识源不受影响,可直接撤回。
- 无。

## Stack

Base: `main`. The spec PR objectstack-ai#38720 is merged and `main` is merged in, so
this diff is the adapter's own 6 files; it lands in the same release as
the service PR objectstack-ai#38722, the first reader of the mode. Built on `main`
after objectstack-ai#38726 (B2) merged: the ranking statement still runs under B2's
`SET LOCAL statement_timeout` in a transaction of its own, a failed
search is still refused by the coded errors of `src/errors.ts`, and the
pool default is B2's 20. The ruling it implements is on `main`:
ADR-0161, the dated note of 2026-11-30 under K8.

## What changes

- `knowledge-pgvector` reports `capabilities.retrieval = { modes:
['vector', 'keyword', 'hybrid'], default: 'hybrid' }`.
- A search runs only the legs its mode names, in SQL: `keyword` never
calls the embedder (distance column is a constant); `vector` writes no
keyword condition at all (no `LIKE`/`ILIKE`, no `tsquery`), not just
none into the fusion. That leg is most of a hybrid statement's cost: on
PG17 + pgvector 0.8.7 over 59,949 clauses, vector-only took the
statement from 1,655 ms to 445 ms at the same top-10 quality (os-bob,
objectstack-ai#38692).
- Single-leg scores follow the RRF scale (rank n → 61/(60+n), first hit
1); `hybrid` unchanged, `fuse(rows, topK, legs)` bit-identical for two
legs.
- README paragraph, protocol doc §4.1 sentence, patch changeset.
- A mode the store does not list is refused (`400 VALIDATION_ERROR`)
before anything is embedded or ranked, rather than run on the one-leg
scale (review S1). `Clause-②: yes (widening)`: the exported adapter's
`capabilities` grows `retrieval` (review M1).

## Tests

- New `retrieval-modes.test.ts` (recording pool): legs per mode, no
embedder call under `keyword`, empty question, hybrid bit-identity over
ranks 1..200 with `Object.is`, single-leg scores, and a pin that a
`vector` search sends no statement holding `LIKE`, `ILIKE`, `tsquery` or
`@@` (with `hybrid` as the control that does).
- The whole package against live PostgreSQL 16 + pgvector
(`OS_TEST_POSTGRES_URL`), at 6707107 (main with objectstack-ai#38720 merged): 179
tests passed; typecheck clean.

## Acceptance notes

- With the service PR applied on top, the pgvector suite against live
PostgreSQL passes (133).

## Verification

- Two-minute check: `pnpm --filter @objectstack/knowledge-pgvector exec
vitest run src/__tests__/retrieval-modes.test.ts` → all pass (no
database needed).

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [ ] 4. One issue, one branch off an up-to-date `main`, one pull
request. (Stacked: see "Stack" above.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [ ] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

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

https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…odes its store runs (objectstack-ai#38730)

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

Part of objectstack-ai#38692

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 管理员在 Studio
编辑知识源时,「检索方式」下拉只列出该知识源所用存储支持的方式,并写明「存储默认」是哪一种;存储未声明时显示「驱动未声明检索方式」。
- 属于知识管理专题「一期 a:检索方式」。
- 出错只会是下拉列错选项;保存时服务端仍会把不支持的方式拒掉,可直接撤回。
- 无。

## Stack

Base: `main`. Stacked on the service PR objectstack-ai#38722 (it reads
`index_status`'s `adapters` and `defaultAdapter`, which objectstack-ai#38722 adds) and
through it on objectstack-ai#38720; until those merge, this diff carries their
commits. Lands after both and after the phase-0 ADR note (objectstack-ai#38714).

## What changes

- The knowledge source form's `source.retrieval.mode` row names a new
widget, `knowledge-retrieval-mode` (spec form hint). A host whose
registry lacks the picker draws its unregistered-widget face (the JSON
editor), not a select; the three static `options` stay because the
form's generated translations carry their labels.
- `ResourceEditPage` loads, only for a form that declares the widget,
the store the draft binds to (its `adapter`, else `defaultAdapter`) and
the modes it reports, from `POST /api/settings/knowledge/index_status`
(`knowledgeRetrieval.ts`), into `WidgetContext.knowledgeRetrieval`.
- The picker: the store's listed modes plus a blank choice that names
the default ("Store default (Hybrid (both))"); a store that reports none
offers the default alone with "驱动未声明检索方式(STORE),此项请留空。"; a mode already
written that the store does not run is kept and flagged; no store answer
(refused read for an author who is not a platform administrator, store
not mounted, no host) offers the three modes and the save judges.
- en and zh strings in the studio namespace; registry cases in the two
widget registry tests; changeset (spec, app-shell, i18n patch).

## Tests

- New `KnowledgeRetrievalModeWidget-38692.test.tsx` (12): form row names
the widget, labelling, offered options per store shape, undeclared
sentence, flagged stored mode, fallbacks, writes and default removal,
disabled states, `storeRetrievalOf` parsing.
- Related UI suites: 180 files / 2,791 tests passed (widgets,
metadata-form, SchemaForm, i18n, console registry parity),
`ResourceEditPage*` 67 files / 342 passed; app-shell `tsc --noEmit` and
`tsconfig.test.json` clean before the main merge; spec form test 9
passed.

## Acceptance notes

- `index_status` is gated on `manage_platform_settings`; an author
without it gets the three-mode fallback, never an error card.
- The draft's `adapter` re-reads the store on change (one request per
distinct value).
- After merging `main` (with objectstack-ai#38700) the app-shell `tsc` reports one
error in `RecordDetailView.tsx` (`pinOverview`), outside this diff, from
a stale local build of a sibling package; not measured further here.

## Verification

- Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/KnowledgeRetrievalModeWidget-38692.test.tsx`
→ 12 passed.
- UI gates run: `check:i18n-keys`, `check:i18n-drift`,
`check:i18n-dead-keys`, `check-sdui-manifest`, `ui/scripts` vitest,
changeset gates: all green.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [ ] 4. One issue, one branch off an up-to-date `main`, one pull
request. (Stacked: see "Stack" above.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

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

https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ut a code is refused, never answered as no hits (objectstack-ai#38761)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DAwBxBGNv4CexdUyBYJXSw)_
Fixes objectstack-ai#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)

<details><summary>Readings (tests at 43def1f; e52b762 adds only the
changeset sentence)</summary>

- `pnpm --filter @objectstack/service-knowledge test`: Test Files 26
passed (26), Tests 841 passed (841).
- `pnpm --filter @objectstack/service-knowledge typecheck` (tsc over
`src`, tests included, plus `check:test-typecheck`): exit 0.
- Ablation: catch reverted to `acf3b33e` on disk, new file run: 3 failed
/ 2 passed (the three uncoded pins red; coded and no-match pins green).
Fix restored.
- Local derived gates: 40 of 69 run, all exit 0 except
`check-plugin-teardown-shape --self-test` (exit 3, shallow-clone
prerequisite, NOT MEASURED) and `check: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,
objectstack-ai#38722, objectstack-ai#38730, objectstack-ai#38732).
- Round 2 (6348efa): `bench/instrument.test.mjs` alone 8 passed (8);
`pnpm --filter @objectstack/knowledge-pgvector test` 46 passed, 95
skipped (live-postgres); knowledge-turso 301 passed; knowledge-memory 66
passed; overlap-check VERDICT clean exit 0 (also objectstack-ai#38758).
</details>

## 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.com/claude-code)

https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmPDtfMCw4FJfyFfQ7v -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ll lists source.retrieval.mode (objectstack-ai#38732)

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

Part of objectstack-ai#38692

Clause-②: no
Metadata-protocol: none

## 维护者速读

- AI 助手搜知识库时会被告知:分数只表示同一知识源内的先后,不表示相关程度;AI 作者文档写明了检索方式的用法。
- 属于知识管理专题「一期 a:检索方式」。
- 出错只会是说明文字不准,不影响搜索结果,可直接撤回。
- 无。

## Stack

Base: `main`. Stacked on the service PR objectstack-ai#38722 (and through it objectstack-ai#38720);
until those merge, this diff carries their commits. Lands after both and
after the phase-0 ADR note (objectstack-ai#38714).

## What changes

- `search_knowledge` description: one sentence, the ruling's
「分数只表示同一知识源内的先后,不表示相关程度」: "A hit's `score` says only its order among the
hits of its own source, not how relevant it is." The `score` member's
doc says the same, with the one-leg rule (first hit scores 1).
- `skills/objectstack-ai/SKILL.md`: a `source.retrieval.mode` row in the
knowledge source key table; paid for in the same file (the `adapter`
row's save refusal shortened, the one-slot sentence dropped, the closing
rerank line made one clause and no longer says "hybrid weighting"). The
row says an unsupported mode fails a run-time save and, for a shipped
source, every search (503). Ratchet row lowered 7248 → 7247.
- `content/docs/ai/knowledge-rag.mdx`: the "0.5 for one first in only
one" paragraph now says a source can run one leg alone, its first hit
then scores 1, and scores order one source's hits only.
- Patch changeset, naming `@objectstack/service-knowledge` and
`@objectstack/skills` (which ships the SKILL.md).

## Tests

- `service-knowledge`: 860 passed (no test pins the description text).
- Skill gates: token ratchet, links, identifier liveness, frame sync and
freshness, top-level keys, affected docs: all green.

## Acceptance notes

Skill readings (`skills/**` touched):

| | before | after |
|:--|--:|--:|
| `skills/objectstack-ai/SKILL.md` lines | 507 | 507 |
| `skills/objectstack-ai/SKILL.md` bytes / tokens | 29017 / 7248 | 28990
/ 7241 |
| all `skills/*/SKILL.md` lines | 3406 | 3406 |
| all `skills/*/SKILL.md` bytes | 180659 | 180632 |

Net growth zero: the new row is paid by deletion in the same file.

## Verification

- Two-minute check: `node scripts/check-skills-token-ratchet.mjs` →
green, `objectstack-ai/SKILL.md` 7241 / 7241.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [ ] 4. One issue, one branch off an up-to-date `main`, one pull
request. (Stacked: see "Stack" above.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

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

https://claude.ai/code/session_01JQwxbaASqBozmmj1n5tbUf

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

---------

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 protocol:ai 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

Development

Successfully merging this pull request may close these issues.

2 participants