Repository navigation
feat(mcp,service-knowledge): serve search_knowledge on the MCP door, and say when a skill is withheld - #36823
Conversation
…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>
Claude-Session: https://claude.ai/code/session_01QSeKYnEwQiHFXyLjP4vcfa Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYnEwQiHFXyLjP4vcfa Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 5 package(s): 38 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 186 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 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
|
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Contract reviewServed-tier: 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 ① Derived judgments
② Semver level
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
④ Design judgment
Break attempts on the implementing files.
Findings. S1 (should-fix) — N1 (nit) — N2 (nit) — N3 (nit) — 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: VERDICT: PASS |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — L1 · head
|
…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>
Claude-Session: https://claude.ai/code/session_01QSeKYnEwQiHFXyLjP4vcfa Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Contract reviewServed-tier: Delta review of PR #36823 (card #36650) after the record on head What moved, whole: ① Derived judgmentsOne change to the first record's item 5. The tool's argument accept set narrows by one value: ② Semver levelUnchanged: 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
④ Design judgmentS1: closed. Read in 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 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: 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>
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — ACCEPT · L1 · head
|
Fixes #36650
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
Item 1: a knowledge family on the MCP door.
search_knowledgeregisters on both MCP transports wherever the kernel holds aknowledgeservice that serves the tool's executor and the grant reaches the read family (data:read, or an API key / session with no OAuth grant), likeregisterDatasetTools/registerPackageDocTools.@objectstack/service-knowledge.knowledge-tools.tsholds the tool'sAIToolDefinition(getKnowledgeToolDefinitions: name, description, JSON Schema ofquery/sourceIds/topK) and its executor (createKnowledgeTools, exposed on the service asKnowledgeService.knowledgeTools(), the structural seam the analytics service'sdatasetToolsalready uses).packages/mcpregisters the definition as handed over (its JSON Schema through zod'sfromJSONSchema, the conversion bridged registry tools already take), so the door keeps no copy of the description or the argument shape. The name is the onePLATFORM_TOOLS_BY_PACKAGE['service-ai']already lists; no second dialect.runtime/domains/mcp.tsresolves theknowledgeservice only under thedata:readgate (resolveMcpKnowledgeToolsService) and bindssearchKnowledgetocontext.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.aiExposedenforcement — where it belongs. Measured onorigin/main65ee4b7:KnowledgeService.resolveSearchTargetsfiltersaiExposed !== falseonly whensourceIdsis empty, so an explicitsourceIds: ['x']reaches anaiExposed: falsesource. The enforcement lands in the tool's executor inservice-knowledge(the producer of the one definition every door registers), not in an MCP-side patch and not inIKnowledgeService.search:aiExposedis defined as "maysearch_knowledgeexpose this source to agents", andsearch()also serves non-agent platform callers that legitimately name a source explicitly. The executor searches only exposed sources and refuses any othersourceIdsentryNOT_FOUNDwith the same sentence an unknown id gets, so a withheld source's existence is not disclosed.sourceIdsis refused (review S1, option a). The definition declaresminItems: 1onsourceIdsand the executor refuses[]withVALIDATION_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 withparseInput.MCP_DOOR_TOOL_NAMES(@objectstack/spec/system) gainssearch_knowledge; the conformance pin inmcp-file-tools.test.ts(wireBridgeTools registers exactly that list) carries the knowledge members.Item 2: withholding is no longer silent.
ai-skill-tool-unresolved, warning). A skill MCP would project as a prompt (instructions,mcpPromptnotfalse,activenotfalse) whosetoolsnames one of theaskproduct's tools no MCP connection serves (PLATFORM_TOOLS_BY_PACKAGE['service-ai']minusMCP_DOOR_TOOL_NAMES=aggregate_data,query_data,visualize_data) gets a verdict naming the tool and saying MCP withholds the skill. Thebuildproduct's names are deliberately excluded: a host can serve them over MCP through its authoring family undermetadata:write.os explain ai-skill-tool-unresolvedcarries a paragraph for it. No new gate.registerSkillPromptstakes an optional logger; on the HTTP door eachprompts/listthat withholds a skill logs onedebugline 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.mdxandcontent/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) onf4b486c4f1, the changeset wording following onad74f6f069.@objectstack/service-knowledgesrc/__tests__/knowledge-tools.test.ts(new, 16): one definition named as the registry names it; nosourceIds⇒ only exposed sources searched and listed; a namedaiExposed: falsesource is refusedNOT_FOUND/404 with the unknown-id sentence and nothing is searched, with the control thatIKnowledgeService.searchstill reaches it; the caller's context reaches the RLS re-check, which drops an unreadable record; no context ⇒ object hits dropped; defaulttopK; seven malformed-argument refusals, an emptysourceIdsamong them, and the definition'sminItems: 1(VALIDATION_ERROR/400, nothing searched); all-withheld ⇒ empty answer.@objectstack/mcpsrc/mcp-knowledge-tools.test.ts(new, 12): registers read-only under the definition's description and closed schema;data:readadmits it; a grant withoutdata:readlists 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 emptysourceIds, are refused before the bridge; a bridge refusal comes back as the coded envelope; a skill bindingsearch_knowledgeis listed inprompts/listwhen 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/runtimesrc/mcp-knowledge-tools-bridge.test.ts(new, 6): seam resolution (served / no service / older service); no seam ⇒ no members; executor called with the request'sExecutionContext; through the real/mcproute: session ⇒ members bound to its context;data:readtoken ⇒ members (control: service resolved); token withoutdata:read⇒ no members and the knowledge service never resolved.@objectstack/lintvalidate-ai-tool-references.test.ts: the new verdict with four non-projected controls and thesearch_knowledge/ build-product controls; the coverage, one-line and explain pins extended.Ablation (service-knowledge, run from
src): replacinglistSources().filter((source) => source.aiExposed !== false)withlistSources()throughscripts/ablation-replace.mjsturned 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 HEADempty.Ablation, round 2: replacing the empty-list guard
if (record.sourceIds.length === 0) {withif (false) {turned the empty-sourceIdspin red (1 of 16); restored blob == HEAD (3114dc6ab9ad),git diff HEADempty.Package suites, typecheck and build (head 2c92317)
pnpm --filter @objectstack/spec --filter @objectstack/lint --filter @objectstack/service-knowledge --filter @objectstack/mcp --filter @objectstack/runtime buildthen… typecheck(lock VERDICT command-exit 0 after the test-layer type fix; the fivetypecheckscripts include each package'scheck: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,typecheckandtestof service-knowledge (5 files / 65) and mcp (84 / 1493).Derived gates (dispatch-gates --commands, 120)
check-plugin-teardown-shape --self-testfirst answered 3, a shallow-clone prerequisite; green aftergit fetch --unshallow).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
search_knowledgeexecutor 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 registergetKnowledgeToolDefinitions()/knowledgeTools()rather than a second shape.askproduct's tools only. Two classes it does not cover, stated rather than guessed: a skill bound to astack.toolsrecord name (no MCP door serves tool records), and a binding served only when an optional service is mounted (search_knowledgewith 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.searchsemantics are unchanged (explicitsourceIdsstill reach any registered source for non-agent callers); only the agent tool enforcesaiExposed.Verification
Read first (by risk):
packages/services/service-knowledge/src/knowledge-tools.ts(theaiExposedrefusal and the context hand-off),packages/runtime/src/domains/mcp.ts(thedata:readgate andsearchKnowledgebindingec),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, includingrefuses a named aiExposed:false source with the sentence an unknown id gets, and searches nothing.Generated by Claude Code