Skip to content

feat(mcp,service-knowledge): serve search_knowledge on the MCP door, and say when a skill is withheld - #36823

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-36650-mcp-search-knowledge
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-36650-mcp-search-knowledge

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Fixes #36650

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:应用装了知识库服务后,用自带 AI 通过 MCP 连接的客户现在能直接检索应用的知识库;绑定知识检索的技能也会出现在提示列表里。
  • 为什么做:属于「MCP 问数」主线,解决自带 AI 的客户够不到应用知识库、相关技能被悄悄隐藏的问题。
  • 出错会怎样:最坏情况是 MCP 客户看不到知识检索或技能仍被隐藏,不会读到无权查看的记录或被标为不对 AI 开放的知识源;改动可直接回滚。
  • 要你做什么:无。

What changes

Item 1: a knowledge family on the MCP door. search_knowledge registers on both MCP transports wherever the kernel holds a knowledge service that serves the tool's executor and the grant reaches the read family (data:read, or an API key / session with no OAuth grant), like registerDatasetTools / registerPackageDocTools.

  • One definition + one executor (ADR-0149 D2), homed in @objectstack/service-knowledge. knowledge-tools.ts holds the tool's AIToolDefinition (getKnowledgeToolDefinitions: name, description, JSON Schema of query / sourceIds / topK) and its executor (createKnowledgeTools, exposed on the service as KnowledgeService.knowledgeTools(), the structural seam the analytics service's datasetTools already uses). packages/mcp registers the definition as handed over (its JSON Schema through zod's fromJSONSchema, the conversion bridged registry tools already take), so the door keeps no copy of the description or the argument shape. The name is the one PLATFORM_TOOLS_BY_PACKAGE['service-ai'] already lists; no second dialect.
  • The caller's execution context (ADR-0090 D10). runtime/domains/mcp.ts resolves the knowledge service only under the data:read gate (resolveMcpKnowledgeToolsService) and binds searchKnowledge to context.executionContext; the stdio bridge binds it to the principal it resolves per call. The open service then re-checks every object-source hit against that context's row-level security.
  • aiExposed enforcement — where it belongs. Measured on origin/main 65ee4b7: KnowledgeService.resolveSearchTargets filters aiExposed !== false only when sourceIds is empty, so an explicit sourceIds: ['x'] reaches an aiExposed: false source. The enforcement lands in the tool's executor in service-knowledge (the producer of the one definition every door registers), not in an MCP-side patch and not in IKnowledgeService.search: aiExposed is defined as "may search_knowledge expose this source to agents", and search() also serves non-agent platform callers that legitimately name a source explicitly. The executor searches only exposed sources and refuses any other sourceIds entry NOT_FOUND with the same sentence an unknown id gets, so a withheld source's existence is not disclosed.
  • An empty sourceIds is refused (review S1, option a). The definition declares minItems: 1 on sourceIds and the executor refuses [] with VALIDATION_ERROR/400 naming the fix (omit it, or name at least one id). Chosen over reading [] as "omitted" because the loud contract gives an AI author a refusal it can correct: searching nothing would answer no passage, which the tool's description tells the model to report as "nothing matched". The door's schema is converted from that same definition, so it refuses [] before dispatch and agrees with parseInput.
  • MCP_DOOR_TOOL_NAMES (@objectstack/spec/system) gains search_knowledge; the conformance pin in mcp-file-tools.test.ts (wireBridgeTools registers exactly that list) carries the knowledge members.

Item 2: withholding is no longer silent.

  • Lint (ai-skill-tool-unresolved, warning). A skill MCP would project as a prompt (instructions, mcpPrompt not false, active not false) whose tools names one of the ask product's tools no MCP connection serves (PLATFORM_TOOLS_BY_PACKAGE['service-ai'] minus MCP_DOOR_TOOL_NAMES = aggregate_data, query_data, visualize_data) gets a verdict naming the tool and saying MCP withholds the skill. The build product's names are deliberately excluded: a host can serve them over MCP through its authoring family under metadata:write. os explain ai-skill-tool-unresolved carries a paragraph for it. No new gate.
  • Runtime (debug). registerSkillPrompts takes an optional logger; on the HTTP door each prompts/list that withholds a skill logs one debug line naming the skill and each bound tool the connection does not serve.

Docs: content/docs/ai/connect-mcp.mdx (tool table + probe comment), content/docs/ai/knowledge-rag.mdx and content/docs/protocol/knowledge.mdx (the callouts that said knowledge search is in-product only).

Tests

Round 1 ran on head 2c92317254; round 2 (review S1) on f4b486c4f1, the changeset wording following on ad74f6f069.

  • @objectstack/service-knowledge src/__tests__/knowledge-tools.test.ts (new, 16): one definition named as the registry names it; no sourceIds ⇒ only exposed sources searched and listed; a named aiExposed: false source is refused NOT_FOUND/404 with the unknown-id sentence and nothing is searched, with the control that IKnowledgeService.search still reaches it; the caller's context reaches the RLS re-check, which drops an unreadable record; no context ⇒ object hits dropped; default topK; seven malformed-argument refusals, an empty sourceIds among them, and the definition's minItems: 1 (VALIDATION_ERROR/400, nothing searched); all-withheld ⇒ empty answer.
  • @objectstack/mcp src/mcp-knowledge-tools.test.ts (new, 12): registers read-only under the definition's description and closed schema; data:read admits it; a grant without data:read lists it not and a call never reaches the bridge; a bridge missing either member registers nothing else differently; arguments reach the bridge as sent; an undeclared argument, and an empty sourceIds, are refused before the bridge; a bridge refusal comes back as the coded envelope; a skill binding search_knowledge is listed in prompts/list when served and withheld with exactly one debug line naming skill and tool when not; the stdio bridge carries the members only with the executor and runs each call as the resolved principal.
  • @objectstack/runtime src/mcp-knowledge-tools-bridge.test.ts (new, 6): seam resolution (served / no service / older service); no seam ⇒ no members; executor called with the request's ExecutionContext; through the real /mcp route: session ⇒ members bound to its context; data:read token ⇒ members (control: service resolved); token without data:read ⇒ no members and the knowledge service never resolved.
  • @objectstack/lint validate-ai-tool-references.test.ts: the new verdict with four non-projected controls and the search_knowledge / build-product controls; the coverage, one-line and explain pins extended.

Ablation (service-knowledge, run from src): replacing listSources().filter((source) => source.aiExposed !== false) with listSources() through scripts/ablation-replace.mjs turned 4 of 15 pins red (searches only the exposed sources…, refuses a named aiExposed:false source…, passes the caller's context…, answers no hits and no sources…); restored blob == HEAD (e4a69921027d), git diff HEAD empty.

Ablation, round 2: replacing the empty-list guard if (record.sourceIds.length === 0) { with if (false) { turned the empty-sourceIds pin red (1 of 16); restored blob == HEAD (3114dc6ab9ad), git diff HEAD empty.

Package suites, typecheck and build (head 2c92317)
  • pnpm --filter @objectstack/spec --filter @objectstack/lint --filter @objectstack/service-knowledge --filter @objectstack/mcp --filter @objectstack/runtime build then … typecheck (lock VERDICT command-exit 0 after the test-layer type fix; the five typecheck scripts include each package's check:test-typecheck, all OK).

  • pnpm --filter … test, lock VERDICT command-exit 0: spec 883 files / 28106 passed (1 todo); service-knowledge 5 / 64; lint 229 / 9514; mcp 84 / 1492.

  • pnpm --filter @objectstack/runtime test, lock VERDICT command-exit 0: 644 files / 11930 passed (25 skipped).

  • pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date.

  • Round 2 (head f4b486c4f1), lock VERDICT command-exit 0: dependency-closure build, typecheck and test of service-knowledge (5 files / 65) and mcp (84 / 1493).

Derived gates (dispatch-gates --commands, 120)
  • 118 run locally, exit 0 (check-plugin-teardown-shape --self-test first answered 3, a shallow-clone prerequisite; green after git fetch --unshallow).
  • NOT MEASURED locally, reason PREREQUISITE NOT MET (they read built output of packages outside this diff, the client SDKs and 29 more dists): pnpm --filter @objectstack/spec run check:skill-examples, pnpm check:dual-build-cjs-loads. CI's Lint & Repo Gates runs both.
  • dispatch-gates --ran: 120 derived, 118 run, 2 UNRUN (the two above).

Acceptance notes

  • Open-home choice, not a fork. The in-product search_knowledge executor lives in the closed cloud repo, and cloud#4933 records that it is never registered there; this PR does not read that repo (NOT MEASURED). The open definition here is the one ADR-0149 D2 asks for, and cloud#4933 can register getKnowledgeToolDefinitions() / knowledgeTools() rather than a second shape.
  • The withheld-skill verdict covers the ask product's tools only. Two classes it does not cover, stated rather than guessed: a skill bound to a stack.tools record name (no MCP door serves tool records), and a binding served only when an optional service is mounted (search_knowledge with no knowledge service, the dataset pair with no analytics service) — authoring time cannot see what a deployment mounts; the runtime debug line covers those.
  • IKnowledgeService.search semantics are unchanged (explicit sourceIds still reach any registered source for non-agent callers); only the agent tool enforces aiExposed.
  • The long-lived stdio server registers skill prompts without the binding filter, as before; the withholding and its debug line are the HTTP door's.

Verification

Read first (by risk): packages/services/service-knowledge/src/knowledge-tools.ts (the aiExposed refusal and the context hand-off), packages/runtime/src/domains/mcp.ts (the data:read gate and searchKnowledge binding ec), packages/mcp/src/mcp-http-tools.ts (registerKnowledgeTools).

Two-minute check: pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/knowledge-tools.test.ts — expect 16 passed, including refuses a named aiExposed:false source with the sentence an unknown id gets, and searches nothing.


Generated by Claude Code

…say when a skill is withheld

WIP: tests and changeset follow.

Claude-Session: https://claude.ai/code/session_01QSeKYnEwQiHFXyLjP4vcfa
Co-authored-by: Claude <noreply@anthropic.com>
…e withheld-skill verdict

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

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/lint, @objectstack/mcp, @objectstack/runtime, @objectstack/service-knowledge, @objectstack/spec, touching 55 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/services/service-knowledge/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

38 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 8e4ac50d430287fca2fa140e4490c74654d27516.

⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/services/service-knowledge/src/index.ts) — pages documenting those are invisible to this run
  • 15 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 — 186 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 8e4ac50d430287fca2fa140e4490c74654d27516 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 8e4ac50d430287fca2fa140e4490c74654d27516

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 2c923172541d031c834aac4f9c4669c95b68c0f5
Local-runs: none
Scope: packages/spec/src/system/constants/platform-tool-names.ts + packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/index.ts, packages/mcp/src/mcp-http-tools.ts, packages/mcp/src/stdio-data-bridge.ts, packages/mcp/src/plugin.ts, packages/mcp/src/skill-prompts.ts, packages/mcp/src/mcp-server-runtime.ts, packages/runtime/src/domains/mcp.ts, packages/lint/src/validate-ai-tool-references.ts, packages/lint/src/rule-explanations.ts, packages/mcp/src/mcp-file-tools.test.ts (the pin holding MCP_DOOR_TOOL_NAMES equal to what wireBridgeTools registers)
Security-touching: yes
Rule-change-verified: none

PR #36823 for card #36650. Inputs read: the card body and its four comments, the PR body, file list and net diff at this head, the check-runs on this head, and the live tree on main (4c18c43) for the code the diff cites. The remainder of the diff (the four new or changed test files other than the pin above, the three content/docs/** pages, the changeset body) is the lane seat's ACCEPT at TIER_DEFAULT.

① Derived judgments

  1. MCP_DOOR_TOOL_NAMES gains search_knowledge (published constant in @objectstack/spec/system, value widened by one member, sorted position correct between run_action and search_package_docs). Right. The list's maintenance contract is "the exact set wireBridgeTools registers on a bridge carrying every optional member under every scope"; the diff adds registerKnowledgeTools to wireBridgeTools and adds both knowledge members to the full bridge of the conformance pin in mcp-file-tools.test.ts, so the two move together. Lint resolution is unchanged by the new member (search_knowledge already resolved through PLATFORM_TOOLS_BY_PACKAGE['service-ai']); its one new effect is that the name is not in the diff's ASK_TOOLS_THE_MCP_DOOR_LACKS set, which is correct.
  2. MCP tool surface: a new read-family tool on tools/list, on both transports, where the kernel holds a knowledge service carrying knowledgeTools and the grant is data:read or absent. Right, and a widening: every already-declared knowledge source whose aiExposed is unset becomes searchable by MCP clients on upgrade. That is the declared meaning of the default (knowledge-source.zod.ts:159, skills/objectstack-ai/SKILL.md:254) and the changeset says it in its first paragraph.
  3. McpDataBridge gains two OPTIONAL members (searchKnowledge, knowledgeToolDefinitions); StdioDataBridgeDeps gains optional knowledgeTools; buildMcpBridge's seams gains optional knowledgeTools. Right: additive, absent means not registered, same degradation contract as the dataset pair.
  4. @objectstack/service-knowledge publishes five values and five types from knowledge-tools.ts, and KnowledgeService gains the public method knowledgeTools(). Right: additive. IKnowledgeService (spec contract) is untouched, and both hosts detect the seam structurally, so a third-party knowledge service without the method serves no MCP tool rather than a broken one.
  5. Accept set of the new tool: a closed object (query, sourceIds, topK 1..20), and a sourceIds entry that is not an exposed source is refused. Right. It is narrower than IKnowledgeService.search, but on a tool that did not exist: nothing published is narrowed, and search() itself is unchanged (read in the live tree: resolveSearchTargets still returns any registered source named explicitly).
  6. prompts/list on the HTTP door now lists a skill binding search_knowledge where the tool is served. Right: a consequence of 2 through the unchanged skillBindingServed. registerSkillPrompts gains a third optional parameter: additive.
  7. ai-skill-tool-unresolved gains a second verdict at warning severity for a projected skill binding aggregate_data, query_data or visualize_data. Right as a firing set (see ④, N1 for its wording): the accept set of os validate is unchanged, the rule stays advisory (ADR-0078), and projectedOverMcp mirrors projectSkillPrompt clause for clause (active, mcpPrompt, non-blank instructions). The verdict rides a rule id that says "unresolved" for a name that resolves; the explain text carries the distinction, so this is accepted as written.

② Semver level

patch on @objectstack/service-knowledge, mcp, runtime, spec, lint. Matches: the five are exactly the released packages the diff moves; Metadata-protocol: none is correct (no key, accepted value or metadata type an author can write changes: skill.tools took the name before, and no Zod shape moves), and by AGENTS.md Post-Task step 3 the kind none takes patch for a non-protocol widening. All five sit in the one fixed group, so they version together regardless. Check Changeset concluded success on this head.

Clause-②: yes — correct, and present line-initial in both the PR body and the changeset body. The diff enlarges the public surface (items 1 to 6 above) and narrows no published accept set, so no arm is owed.

③ Boundary flags

  • Dev report 7120236221, open_questions: empty. Nothing to answer.
  • out_of_scope_findings 1 (a skill bound to a stack.tools record name is withheld by every MCP connection and the new verdict does not cover it; a binding served only where an optional service is mounted is covered by the debug line alone): confirmed by reading bindingEntryServed and the lint rule; a true gap that needs deployment knowledge authoring time lacks. Answered: accepted as stated, carrier none.
  • out_of_scope_findings 2 (cloud#4933 can register the open definition): the cloud repository is outside this review's inputs. NOT MEASURED here either; answered as a pointer for the cloud lane, no claim made.
  • l2_routing: answered by this record. The tree decides the face: packages/spec/src/system/constants/platform-tool-names.ts is a published-schema path, so CONTRACT_REVIEW_TIER is owed and served.
  • Dev deviations: branch not merged with the three main commits that landed after the branch point (none touch the changed paths; the merge queue re-tests on the merged tree); no dogfood battery (no !, no narrowing arm): both accepted.
  • security_findings: none — not accepted as written; escalated as E1. search_knowledge is the first read on the MCP door that does not pass the door-level gates every other MCP read passes. The knowledge service re-checks each object-source hit by dataEngine.find(object, { where: { id: { $in } }, fields: ['id'], context }): that is row-level (and whatever object-level read the engine enforces) and nothing else. So a caller who may read a ROW receives passage text built from every contentFields member of it, including a field a field-level permission hides from that caller; and the object's MCP/API exposure posture (enforceApiExposure on stdio, the data door's on HTTP, including the disabled-package refusal) is never asked. This is the documented Phase-1 limit of the protocol (content/docs/protocol/knowledge.mdx §7.1 "Field-level masking — Phase 1 enforces row-level only", §9), it is exactly the gate the card's Expected item 1 names, and the author opts in per source through contentFields and aiExposed; so it is not graded against this diff. But this PR is what first puts that limit in front of end-user principals on the open distribution, and packages/qa/dogfood/test/authz-conformance.matrix.ts:529 still states of the MCP door that "RLS / FLS / tenant apply exactly as on REST /data". E1, for the maintainer through the seat: decide whether the MCP knowledge tool keeps the protocol's row-level posture as is, or additionally drops a hit whose object fails the caller's exposure gate or whose content fields the caller cannot read; the seat files the decision card and names it in its ACCEPT. The PR body's 维护者速读 line holds at record level, not at field level, and should be read that way.
  • Observation, not graded (code outside the diff): KnowledgeService.search logs and swallows an adapter failure and answers [], so on a vector-store outage the tool answers "no hits" and its description tells the model to say nothing matched. The MCP door distinguishes outage from miss elsewhere (ADR-0110 D3); the executor cannot from what search() returns. Follow-up material for the knowledge service, not this head.
  • SQL push-down (Prime Directive 5): no finding. The diff adds no id materialisation and no in-app join. The executor filters the in-memory source registry (listSources()), not rows. The one id $in read on the path is applyPermissionFilter, outside the diff and unchanged, and it has its reason: the ids come from the vector adapter's hits, which no SQL statement can join against.
  • Gate verdicts on this head (check-runs read at record time): every completed run concluded success or skipped (among them Governed Surface Queue Guard, Check Changeset, Lint & Repo Gates, Spec property liveness, TypeScript Type Check, Dogfood Regression Gate, Test Core shards 1 to 7, 9 and 10, all Test UI shards), except Test Core (8/10): attempt 1 concluded failure, its rerun is in_progress, and the aggregate Test Core with it. I read attempt 1's log (job 138173799552): four failed tests, all timeouts, one in @objectstack/plugin-audit (comment-reply-notice.integration.test.ts, 5000 ms) and three in @objectstack/plugin-security (delegated-organization-membership.test.ts 5000 ms, org-admin-assignment-boundary.posture.test.ts 5000 ms and 9000 ms). Neither package is in the diff, and neither imports the changed modules beyond @objectstack/spec, whose only change is one string in a constant array. The brief described three 5000 ms timeouts; the log shows four tests, one of them at 9000 ms. This record does not stand in for that shard: the head is not all-green until the rerun concludes, and the seat's pre-landing check reads it.

④ Design judgment

packages/spec/src/system/constants/platform-tool-names.ts (hits). Holds. The new JSDoc clause says search_knowledge is served "where the kernel holds a knowledge service: the knowledge service's one definition and executor, searching only the sources whose aiExposed is not false, as the caller". Each part read against the code it describes: registration is conditional on both bridge members, which both hosts supply only when the kernel's knowledge service has knowledgeTools (plugin.ts#knowledgeToolsService, runtime/domains/mcp.ts#resolveMcpKnowledgeToolsService); the definition and executor are knowledge-tools.ts's; the exposure filter and the context hand-off are in that executor. First consumer, the lint rule: unchanged resolution, correct exclusion from the withheld set. The scenario the card is accepted against (a skill with tools: ['search_knowledge', 'query_records', 'get_record', 'action_…'] listed by prompts/list, and the source searchable): every entry is now served on an admin session with the knowledge service mounted, so skillBindingServed passes.

Break attempts on the implementing files.

  • Can an MCP caller reach an aiExposed: false source? No. The only path from the door to the service is knowledgeTools().searchKnowledge. The executor builds byId from listSources().filter(aiExposed !== false), refuses any sourceIds entry outside it before search() runs, always passes an explicit non-empty target list (so resolveSearchTargets' own implicit filter is not what is relied on), and filters returned hits by byId again. The refusal sentence is the same for an unknown and a withheld id and lists exposed ids only. On a stdio host whose AI registry also registers a search_knowledge, the native tool takes the name in either order (bridgeTools skip, yieldBridgedTool), so the open executor is the one served.
  • Is the caller's context what reaches the row-level re-check? Yes on both transports. HTTP: buildMcpBridge closes over ec = context.executionContext and calls searchKnowledge(input, ec); the executor forwards it as executionContext; applyPermissionFilter passes it to dataEngine.find as context. Stdio: await resolvePrincipal() per call, the same resolution the dataset pair uses. A missing context fails closed on object-source hits (read in the live tree).
  • Registered without data:read, or without a knowledge service? No. knowledgeToolDefinition returns nothing for a grant lacking the scope or a bridge lacking either member, and the runtime does not resolve the service for such a grant at all.
  • ADR-0149 D2, one definition and one executor. Holds in this repository: packages/mcp registers definition.description and definition.parameters as handed over and keeps only the name constant, tied by the conformance pin. It departs from D2's dataset precedent in one respect, accepted: the argument shape is hand-written JSON Schema in the service package with a hand-written parseInput beside it, where D2 put the dataset shapes in spec as zod projected to JSON Schema; and the output shape has no schema. Two descriptions of one accept set in one file is what S1 below falls out of.
  • Does the lint verdict fire correctly, and not on served tools? The firing set is right for the HTTP door: handleHttpRequest never bridges the AI registry, so those three names are served there by nothing in this repository, and the dataset, docs and knowledge names are excluded by construction. See N1 for the claim's reach.
  • skill-prompts.ts: moving projection ahead of the binding test changes no listing (a row that does not project was dropped either way) and limits the debug line to skills that would have been offered. prompts/get passes no reporter, so one listing logs once. Agrees with its JSDoc.

Findings.

S1 (should-fix) — packages/services/service-knowledge/src/knowledge-tools.ts, createKnowledgeTools: a call with sourceIds: [] searches nothing and answers { hits: [], sources } with no refusal. parseInput accepts the empty array (the JSON Schema declares no minItems, so the door's converted schema admits it too), if (sourceIds) is true, targets = sourceIds ?? [...] is [], and the targets.length === 0 early return fires. The service the executor wraps treats the same input as "every exposed source" (resolveSearchTargets: !sourceIds || sourceIds.length === 0), and the tool's own description tells the model that no passage "means nothing the caller may read matched: say so rather than answer from general knowledge". An empty array for an optional list is a routine model output, and the card's acceptance scenario is a small BYO model answering policy questions from this tool: it would be told, falsely and silently, that the knowledge base has no basis. No pin covers the case (the new suite tests an unknown id, a withheld id and the all-withheld registry, not the empty list). Fix in the executor, one of: treat an empty sourceIds as omitted, as search() does; or declare minItems: 1 and refuse the empty list VALIDATION_ERROR. Either way add the pin.

N1 (nit) — packages/lint/src/validate-ai-tool-references.ts and rule-explanations.ts: the verdict says the tool is served "by no MCP connection" and that MCP withholds the skill from prompts/list. That is the HTTP door. The long-lived stdio server bridges the host's AI registry (plugin.ts:449-451, MCPServerRuntime.bridgeTools), so on a host whose ai service registers those tools a stdio connection lists them, and stdio registers skill prompts without the binding filter (the PR body's own acceptance note). Every stack the verdict fires on is withheld on the HTTP door, so the firing set stands; only the sentence over-reaches. Left as an accepted deviation or a follow-up that says "the HTTP door".

N2 (nit) — knowledge-tools.ts module JSDoc states as present fact that "an in-product registry registers the same definition and delegates to the same executor". Nothing in this review's inputs shows that, and the card records cloud#4933 as not registering the tool at all. The sentence describes the intended shape. Accepted deviation.

N3 (nit) — mcp-http-tools.ts#knowledgeToolDefinition calls itself "the one gate" while registerKnowledgeTools has a second way to register nothing (a definition that does not convert to an object schema). No caller reads the former as a served-predicate today, so nothing disagrees yet. Accepted deviation.

One should-fix (S1), no must-fix. S1 earns a delta review of its fix on the head that carries it; E1 goes to the maintainer through the seat and does not wait on that delta.

Implemented-by: claude/issue-36650-mcp-search-knowledge
Reviewed-by: session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — L1 · head 2c923172541d031c834aac4f9c4669c95b68c0f5 · 2026-11-24T03:07Z

REWORK (patch round 1, same claim, same branch, same dev session). One item: S1 of the contract review on this head (comment 7120785446) — sourceIds: [] answers an empty result silently in createKnowledgeTools while IKnowledgeService.search reads it as every exposed source; fix in the executor and pin it. Sent to the dev session session_01QSeKYnEwQiHFXyLjP4vcfa.

Mechanical face (l1-face.mjs) clean on this head: draft, base main, Fixes #36650 delivers both card items, changeset covers all five published packages (patch each, consistent with Metadata-protocol: none), declarations present. Changeset and the three content/docs/** hunks read sentence by sentence against the executor (topK 1–20 default 5, aiExposed filter in the executor, NOT_FOUND/404 and VALIDATION_ERROR/400 refusals): consistent.

CI: Test Core (8/10) red on attempt 1 — four test timeouts in @objectstack/plugin-audit and @objectstack/plugin-security, neither in the diff; the one relay rerun is spent (attempt 2). Every other check on this head is success or expected skip.

Nits N1–N3: accepted deviations as the record grades them. E1 (field-level / exposure posture of knowledge hits): with the maintainer through the seat; it does not block this delta.

…nstead of answering no passage

An empty list searched nothing and answered no hits, which the tool's
description tells the model to report as "nothing matched". The
definition now declares minItems: 1 and the executor refuses [] with
VALIDATION_ERROR, so the door's converted schema and parseInput agree.

Claude-Session: https://claude.ai/code/session_01QSeKYnEwQiHFXyLjP4vcfa
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ad74f6f069849c64cab87c1ad86006fc59b746e4
Local-runs: none
Scope: packages/spec/src/system/constants/platform-tool-names.ts + packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/index.ts, packages/mcp/src/mcp-http-tools.ts, packages/mcp/src/stdio-data-bridge.ts, packages/mcp/src/plugin.ts, packages/mcp/src/skill-prompts.ts, packages/mcp/src/mcp-server-runtime.ts, packages/runtime/src/domains/mcp.ts, packages/lint/src/validate-ai-tool-references.ts, packages/lint/src/rule-explanations.ts, packages/mcp/src/mcp-file-tools.test.ts (the pin holding MCP_DOOR_TOOL_NAMES equal to what wireBridgeTools registers)
Security-touching: yes
Rule-change-verified: none

Delta review of PR #36823 (card #36650) after the record on head 2c923172541d031c834aac4f9c4669c95b68c0f5. Inputs read: the compare 2c923172…ad74f6f0 (status ahead, 2 commits, 0 behind: f4b486c4f1 and ad74f6f069, each one parent, no merge), the dev's rework report 7120914341 on the card, the PR body as patched, and the check-runs on the new head. The first record's ①, ② and ④ stand for every file this delta does not move; only what moved is re-judged here.

What moved, whole: packages/services/service-knowledge/src/knowledge-tools.ts (+12 −1, the one implementing file), two test files (service-knowledge/src/__tests__/knowledge-tools.test.ts +4 −1, mcp/src/mcp-knowledge-tools.test.ts +10 −1), and the changeset body (+1 −1, prose). The hits file and the eleven other implementing files are byte-identical to the reviewed head: none appears in the compare's file list.

① Derived judgments

One change to the first record's item 5. The tool's argument accept set narrows by one value: sourceIds: [] is now refused, by the definition (minItems: 1) and by the executor (VALIDATION_ERROR, 400). Right. The tool is unreleased, so no published accept set narrows and no (narrowing) arm is owed; IKnowledgeService.search is untouched and still reads an empty list as every exposed source. Items 1 to 4, 6 and 7 are unchanged.

② Semver level

Unchanged: patch on the same five packages, Metadata-protocol: none. The delta moves no package the changeset does not already name.

Clause-②: yes — still correct, and still line-initial in the PR body and the changeset body. The changeset's argument sentence now states the refusal, which matches the code.

③ Boundary flags

  • Rework report 7120914341, open_questions: empty. Its one deviation (the spec, lint and runtime suites were not re-run locally because the delta does not touch those packages) is accepted: CI runs them on this head.
  • Its security_findings: none is answered as before: E1 from the first record is untouched by this delta and stays with the maintainer through the seat. It does not wait on this record and this record does not close it.
  • SQL push-down: no finding. The delta adds one length check on an argument; no read, no id materialisation, no join.
  • Gate verdicts on this head, read at record time: 12 check-runs concluded success, 11 skipped, and 18 were still in_progress, among them Build Core, Check Changeset, the Lint · families, the four Type Check · jobs and the two shard planners; no Test Core or Test UI shard had been created yet. None had failed. This record stands in for none of them: the two new pins and the definition pin are proven only when the shards that carry @objectstack/service-knowledge and @objectstack/mcp conclude, and the seat's pre-landing check reads the full set.

④ Design judgment

S1: closed. Read in knowledge-tools.ts at this head: SEARCH_KNOWLEDGE_PARAMETERS.sourceIds declares minItems: 1, and parseInput throws VALIDATION_ERROR/400 when record.sourceIds.length === 0, placed after the array-and-entries check and before the dedupe, so no empty list reaches createKnowledgeTools. The refusal sentence names both ways out (omit it, or name at least one listed id), which is what a model needs to correct the call. The two layers agree: the door converts its schema from this same definition, and the executor refuses independently of the door, so a caller that reaches the executor by another route gets the same answer. The targets.length === 0 early return is now reachable only when no source is exposed, which is the case it was written for. Pins: the service suite adds [] to the malformed-argument table (refused, nothing searched) and holds minItems: 1 on the definition; the mcp suite asserts the listed schema carries minItems: 1 and that a call with [] never reaches the bridge.

Anything new on the hits or implementing files? No. The delta's only non-test code is the schema line, the description sentence and the guard above. I looked for an input the new guard mishandles and found none: a list of blank strings is still refused by the earlier check, and a list that dedupes to one id is non-empty before and after.

One remark, not a finding: the mcp pin drives the door with its own fixture definition, so what it proves is that the door honours a minItems the definition declares; that the real definition declares it is the service suite's pin. Between them the chain is covered.

N1, N2 and N3 from the first record are unchanged and remain accepted deviations or follow-up material.

No must-fix, no should-fix.

Implemented-by: claude/issue-36650-mcp-search-knowledge
Reviewed-by: session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

Conflicts in service-knowledge index.ts and knowledge-service.ts were
import/export blocks only (search_knowledge tool vs the per-source
admission of the main side); both kept.

Claude-Session: https://claude.ai/code/session_01QSeKYnEwQiHFXyLjP4vcfa
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — ACCEPT · L1 · head b5d0b60d247b9a46464c61a480527be2743b46b7 · 2026-11-24T17:12Z

Over the seat's REWORK at 2c923172541 (record ID: 7120809847) and the delta contract review at ad74f6f069 (record ID: 7120942740, PASS, nothing open).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 24, 2026 17:13
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 8aecf6d Nov 24, 2026
71 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36650-mcp-search-knowledge branch November 24, 2026 17:50
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:system size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants