Repository navigation
feat(mcp): the open draft door's registry and read tools, served where the token has metadata:write and the user holds manage_metadata - #35059
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…design note and changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
… type set Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…ard VALIDATION_ERROR Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…during collection Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…he dispatcher domains The route-envelope census enumerates every module in packages/runtime/src/domains; mcp-authoring.ts builds MCP tool results and no REST body, so it declares handBuilt 0. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
📓 Docs Drift CheckThis PR changes 1 package(s): 55 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 30 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 a91c23b4e2748d85d42c579eea9654a7486cd35a && git checkout a91c23b4e2748d85d42c579eea9654a7486cd35a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin aef42cba4e6f3f863597b86aa6d4dda27eed2c41 c2fa38c8b47809b4f2cb9353b0a628300a69077f && git checkout -B drift-repro aef42cba4e6f3f863597b86aa6d4dda27eed2c41 && git merge --no-ff c2fa38c8b47809b4f2cb9353b0a628300a69077f
node scripts/docs-audit/affected-docs.mjs --json aef42cba4e6f3f863597b86aa6d4dda27eed2c41
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-18T00:47ZHead-sha: 504662e 席位核对PR shape.
The CI. It was still running when I read it (22 pending, nothing failed). The runtime typecheck was not measured locally, so this verdict holds on the condition that D1 A, the intersection: held.
One verdict for the listing and the call: held. The registry closes over D3 A, the names: held. The tools are The reads.
The injection and the note. Must-fixNone. Should-fix
Notes
Next: S1 (text only), then the seat's fable L2 (D1 touches the authoring gate), then the landing tier read on the final file list. A later push owes an L1-c delta read. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: PR #35059 (PR-a of card #34766), declaration face plus the admission rule. Read: the card body and its five comments, the PR body, the 7-file net diff against Check-runs on the head at review time: 30 completed ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL |
…th the human as the caller get_metadata_item and list_metadata_items now judge every item through the gates @objectstack/rest exports (createMetaItemReadGate under the stored-version door policy, createMetaListReadGate), with a caller built from the human's own grants. A dashboard, list view or app whose requiredPermissions the human lacks, and a book or doc outside their audience, are refused or left out as every /meta door does; a gate that cannot evaluate refuses. The draft-state list keeps the overlaid read because the list gate judges item bodies, which draft rows do not carry. The changeset declares Clause-② yes (widening). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-18T02:28ZHead-sha: 2ef0ca8 席位核对
Delta
Must-fixNone. Should-fixNone. Notes
NextThis ACCEPT is conditional on CI finishing green on 2ef0ca8, and on |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: Delta review of Check-runs on the head at read time: 32 completed ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL |
…every spelling meets the /meta read gates The protocol's reads fold `type` (`dashboards` reads the dashboard), and the /meta read gates judge the singular type only, leaving the fold to their caller. The door handed the raw argument to both, so a plural or alias spelling was read by the protocol and judged by no gate. It now folds once with `canonicalMetaUrlType`, the protocol's own fold, and hands the folded type to the protocol read, the unknown-type refusal and both gates. A name the fold answers no string for (an inherited member such as `constructor`) goes on unfolded and is refused as an undeclared type. The pins' protocol double folds as the real one does; `dashboards` and `docs` are refused on the item read and left out of the list. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8
…ol as the string sent The fold answers a function for `constructor` or `toString`; the door keeps the agent's string then, the spelling every /meta door hands the protocol. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Final green head · 2026-11-18T04:49Z: |
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Contract-review-claim: session_01JQwxbWDsbbJizuYnDwBxT8 · head |
|
repo:objectstack#1 · os-warren · session_01JQwxbXr9wLAH24MEgxaLud 席位核对L1 delta · ACCEPT · Head-sha: Delta from L1-c ACCEPT 6967197020 at Checked
Not mine, still owed before landing
|
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Contract reviewServed-tier: Delta review of Check-runs on the head: 58 in total, 40 ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
…mission before any read get_metadata_item and list_metadata_items ask metaTypeReadRefusal of the folded type, with the human as the caller, before the protocol read and the item and list gates, on every state branch: a metadata type the caller may not read is refused as every /meta read refuses it. Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8 Co-authored-by: Claude <noreply@anthropic.com>
…d admission Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Final green head · 2026-11-18T07:01Z: Contract-review-claim: session_01JQwxbWDsbbJizuYnDwBxT8 · head |
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Contract-review-claim: session_01JQwxbWDsbbJizuYnDwBxT8 · head |
|
repo:objectstack#1 · os-warren · session_01JQwxbXr9wLAH24MEgxaLud 席位核对L1 delta · ACCEPT · Head-sha: This delta starts from my ACCEPT 6969481800 at Checked
Not mine, still owed before landing
|
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Contract reviewServed-tier: Delta review of Check-runs on the head: 54 in total, 38 ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Contract reviewServed-tier: This is a closing delta on record 6971674038 for PR #35059 (PR-a of card #34766), declaration face, at the same head. No code moved. I re-read only the PR body (REST, updated 2026-11-18T07:08Z) and compared it with the body that record judged. S2 is closed. M1-c, M1, M1-b, M2 and S1 stay closed. There is no must-fix, so the verdict is PASS. ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
…p-draft-door-read
|
repo:objectstack#1 · os-warren · session_01JQwxbWDsbbJizuYnDwBxT8 Landing · 2026-11-18T07:44Z · head
Status: ready + auto-merge. |
Requested by Yibo Wang · project thread
Part of #34766 (PR-a: the registry, its admission and the three read tools; PR-b brings the save and discard tools, the verdict on each save and on
list_drafts, and the app-crm end-to-end, and completes the card).Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
list_metadata_items、get_metadata_item、list_drafts),让 AI 客户端能查看元数据和待发布草稿;本 PR 不写入任何东西。metadata:write且该用户本人持有manage_metadata时才出现这些工具,任一不满足或权限读不到都不提供;读取结果与/meta接口对同一个人的裁决一致(缺少所需权限的仪表板/视图/应用、不在受众内的文档会被拒绝),在条目与列表闸门之前,两个读取工具还先过与/meta相同的类型级读取准入,调用者无权读取的元数据类型直接拒绝;持有manage_metadata也不例外;type写成复数或别名(如dashboards、docs)时先在入口折叠成单数再交给闸门,不能绕过;回滚即 revert 本 PR,不涉及数据变更。packages/runtime/src/domains/mcp-authoring.ts的resolveHumanReader(准入、用本人权限构造读取方、失败即关闭)与get_metadata_item/list_metadata_items里的类型级准入(typeReadRefusal)和两道读取闸门;packages/runtime/src/domains/mcp.ts的注入那几行;packages/runtime/src/domains/mcp-authoring.test.ts的四个准入格。pnpm --filter @objectstack/runtime exec vitest run --project local src/domains/mcp-authoring.test.ts,预期 22 个测试全部通过。What changes
packages/runtime/src/domains/mcp-authoring.ts: the openMcpAuthoringToolRegistryfor the self-hosted MCP door (designdocs/design/mcp-local-first-door.md, Design A). Three read tools over the metadata protocol's public reads:list_metadata_items({ type, state? })overgetMetaItems(draft-first: a pending draft is listed in place of its published version and markeddraft: true;stateselectsactiveordraftonly). An undeclared type is refused400 INVALID_REQUESTthrough the samerefuseUnknownMetaListTypethe/metalist uses.get_metadata_item({ type, name, state? })overgetMetaItem(draft in place of the published version by default; a missing item answers404 RESOURCE_NOT_FOUND).list_drafts({ package? })overlistDrafts(no verdicts yet; the description promises none).packages/runtime/src/domains/mcp.ts: resolves the injection per request and passes it tohandleHttpRequestasauthoring./metaread gates, with the human as the caller (review M1): the door is not whole-for-author.get_metadata_itemjudges the item throughcreateMetaItemReadGateandlist_metadata_itemsjudges the list throughcreateMetaListReadGate, both exported by@objectstack/rest(already a dependency of the runtime, no cycle, nothing in@objectstack/restedited). The caller the gates read is built from the human's own grants, the same resolution the admission does (positions,permissions,permissionSetAddresses,systemPermissions), never from the agent envelope. So a dashboard, a list view or an app whoserequiredPermissionsthe human lacks, and a book or doc outside their ADR-0046 audience, are refused (403 PERMISSION_DENIED) or left out of the list, as every/metadoor does for that human,manage_metadataor not (ruling 5856774816). The item read runsSTORED_VERSION_DOOR_POLICY, the policy of the/metadoors that serve a stored version for authoring (the plain read's?state=draftbranch among them): the per-caller gates, and the author exemption for a container's entries only, because this caller may save the item; a whole refusal stays a refusal. Anabsentverdict answers the door's own not-found. A gate that cannot evaluate refuses (a books read that throws answers500, never the doc), and a registry handed no gate reads nothing.type(dashboardsreads the dashboard,canonicalizeMetaRequestTypeovercanonicalMetaUrlType), while both read gates judge the singular type only and leave the fold to their caller, as every/metacaller of them folds first. The door now folds thetypeargument once, withcanonicalMetaUrlTypefrom@objectstack/spec/shared(the protocol's own fold), in one module helpercanonicalTypeOf, and hands the folded type to the protocol read, torefuseUnknownMetaListTypeand to both gate factories. Soget_metadata_item({ type: "dashboards" })and{ type: "docs" }are judged as the dashboard and the doc they read, andlist_metadata_items({ type: "docs" })drops what the gate drops. A name the fold answers no string for (an inherited member such asconstructor, see Acceptance notes) stays the string the agent sent, the spelling every/metadoor hands the protocol for it. The module header now says the gates apply whatever spelling is sent. PR-b's own localcanonicalTypeOfis the same helper by name and signature, so the two collapse into this one./metatype-level read admission (review M1-c): the MCP read tools run the same type-level read admission as/meta(metaTypeReadRefusal, exported by@objectstack/rest) before the item and list gates and before any protocol read, on the folded type, with the same human caller, on everystatebranch. A type the caller may not read is refused, as every/metaread refuses it, whether or not the named item exists. The module header and the changeset say so.list_draftsruns no item gate:/meta/_draftsruns none for this same caller (admitted bymayReadPendingDraftsalone), and a draft row carries the item's identity and its ownlabel, no body for a gate to judge.list_metadata_itemswithstate: "draft"(review S1): kept on the draft-overlaidgetMetaItemsread and filtered to drafts, not moved tolistDrafts({ type }), because the list gate judges each item's body (itsrequiredPermissions, a doc's audience) and a draft row carries none. The reason is in a code comment at the read.metadata:write; the MCP runtime'sgrantsAuthoringToolsstays the authority on this half, it is read here only so an API key or a session costs no grant read), AND the human the token was issued to holds the capability:resolveUserAuthzGrantsonprincipal.userIdin the token's bound organization, judged bymetaWriteCapabilityVerdict(operationsave), never the agent envelope's own permissions (an OAuth agent carries none withoutactions:execute).userIdmeans no injection at all; a grant resolution that throws (or no data engine) yields a registry that lists nothing and refuses every call, plus onewarn.manage_metadatais listed none of the three tools; a call that reaches the registry anyway is refused403 PERMISSION_DENIED. A call stamped with a different user than the one admitted is refused the same way.authoringat its ownhandleHttpRequestcall; the option is one object, so the two registries never merge and their names never meet (stated in the module header).walledCatalogWriteVerdictis not applied here: it gates metadata writes and no/metaread. It joins with the save tool in PR-b.list_metadata_items/get_metadata_item, becauselist_metadatais a hosted platform tool (packages/spec/src/system/constants/platform-tool-names.ts:97). None of the three is an MCP native tool (pinned inpackages/mcp/src/skill-md-surface-guard.test.ts; the SDK throws on a duplicate registration).docs/design/mcp-local-first-door.md: one add-only dated note beside the tool table recording the rename. No other word changed.initializeinstructions / skill-md: unchanged. Nothing in this PR is true yet that the design assigns to those surfaces for this door (no save, no verdict), so nothing is promised there..changeset/34766-mcp-open-draft-door-read.md:@objectstack/runtimepatch, with both declaration lines.Why
On a self-hosted app an AI client can read and write records over MCP and cannot build at all. The ruled design gives it a thin entry where it saves drafts and a person publishes them in Studio. This PR lands the entry's admission and its read half, so the write half (PR-b) only adds tools behind an already-pinned gate.
Tests
Pins in
packages/runtime/src/domains/mcp-authoring.test.ts(22 tests):metadata:write(no registry, the user's grant is never read);metadata:writewith a user lackingmanage_metadata(no tool listed, call refused 403 before any read); both present (the three tools listed and a read served); an API key (no registry);/metaread gates through the real domain, with an envelope that carries no system permission: a dashboard whoserequiredPermissionsthe human lacks is refused 403 and not listed, while one requiring a capability only the human holds (manage_users) is served (the allowed control, and proof the gate read the human); a doc outside the human's audience is refused 403 and not listed, while anorgdoc is served; a books read that throws serves no doc; a registry handed no gate reads nothing;typeas the real protocol's do:dashboardsanddocsare refused 403 on the item read (no body, norequiredPermissionsvalue in the refusal) and left out of the list, whiledashboards/people_boardis served astype: "dashboard"; the protocol is handeddocanddashboard, never the plural; and an inherited member's name (constructor,toString) reaches the protocol as the string sent.packages/mcp/src/skill-md-surface-guard.test.ts: the three names collide with no native tool under every scope, and register beside the full native surface.Runtime pins at c50358b, and the mcp guard at 2ef0ca8
Ablations (each landed and restored by scripts/ablation-replace.mjs)
The suite imports the module relatively from
src/, so nodist/sits on the path. Each mutation was proved on disk (anchor 1 to 0, blob changed) and each restore proved by blob == HEAD and an emptygit diff HEAD.Admission and fail-closed (round 1, on the module before a40a48e, which changed only refusal codes):
.allowed;to.allowed || true;turns red exactly "a metadata:write token whose user lacks manage_metadata lists no tool, and a call is refused 403 before any read" (1 failed / 13 passed).throw error;at the top of the catch turns red exactly "a grant resolution that throws admits nothing: ..." (1 failed / 13 passed).if (!userId && false)turns red exactly "an envelope with no user is injected nothing, and no grant is read" (1 failed / 13 passed).The read gates (this round, at 2ef0ca8, blob ddb16de3ac43):
serveof the stored item): red are the dashboard pin, the doc pin and the books-read-throws pin (3 failed / 15 passed).systemPermissionsinstead of the human's: red is the dashboard pin, whose allowed control (manage_users, held by the human only) is then refused (1 failed / 17 passed).The fold (fix round for M1-b, at b7838f5, blob a121757d6324):
return typeof folded === 'string' ? folded : type;toreturn type;): red are exactly "a plural spelling is folded at the door ..." (dashboards: expected false to be true, i.e. the dashboard the human lacks the capability for was served) and "the door hands the protocol the folded type ..." (2 failed / 19 passed). Mutation landed anchor 1 to 0, blob a121757d6324 to 99e31994d616; restored blob == HEAD a121757d6324,git diff HEADempty.The type-level read admission (fix round for M1-c, at c50358b, blob 31253aca9077):
return refusal ? refuse(refusal.code, refusal.message, refusal.status) : undefined;toreturn refusal ? undefined : undefined;): red is exactly "a type the caller may not read is refused on item and list reads, on every state, before any protocol read" (1 failed / 21 passed). Mutation landed anchor 1 to 0, blob 31253aca9077 to 2d4d2d940249; restored blob == HEAD 31253aca9077,git diff HEADempty.Acceptance notes
@objectstack/runtimetypecheck at c50358b: exit 0. At b7838f5 (after building the runtime's dependency closure,pnpm --filter '@objectstack/runtime^...' build, exit 0): exit 0,check:test-typecheck: OK(27 files / 183 errors / 66 signatures held in the ledger, none new).canonicalMetaUrlTypeandunrecognisedMetaTypeRefusal(packages/spec/src/meta-spelling/metadata-url-spelling.ts) readMETA_URL_TO_SINGULAR, a plain frozen object, by bracket and byin, so an inherited member's name counts as a recognised spelling and folds to a non-string (canonicalMetaUrlType('constructor')answers theObjectfunction, measured against the built spec). The door keeps the agent's string in that case and so behaves as before the fold; what a public/metadoor answers for such a segment was not measured, so this is a note, not a card.@objectstack/mcpcheck:test-typecheck: OK (round 1; this round changes nothing inpackages/mcp).check:dual-build-cjs-loads: NOT MEASURED locally, reason: it reads every package's built output and exits 3 (PREREQUISITE NOT MET) in a worktree that built only the runtime's closure. CI's run is the reading.Outside the claimed surface
scripts/check-route-envelope.mjs: one line,'mcp-authoring.ts': { handBuilt: 0 },inDISPATCHER_DOMAINS. Reason, in the gate's own words: "packages/runtime/src/domains/mcp-authoring.ts NOT DECLARED. Add it to DISPATCHER_DOMAINS in scripts/check-route-envelope.mjs. A domain that answers only through thedeps.*helpers declares { handBuilt: 0 }". The module builds MCP tool results and no REST body. Approved by the dispatching seat (option A). No other change to that file; no test reads its table, and its own--self-testpasses.Verification
Targeted gates at b7838f5 (fix round for M1-b)
dispatch-gates --commands(no paths; change set = the PR's 7 paths vs merge base 4443014) derived 90 families, all 90 run locally on b7838f5 with each exit code recorded: 89 exit 0, 1 exit 3 (check:dual-build-cjs-loads, PREREQUISITE NOT MET: the worktree built only the runtime's closure).dispatch-gates --ranon the exit-coded record: 90 derived, 89 run, 1 NOT-MEASURED, 0 UNRUN, exit 0. Among the 89:check:route-envelope,check:nul-bytes,check:cross-package-test-inputs,check:test-source-alias,check:pm-dispatch-gates, the changeset gates against origin/main.overlap-check --branch=HEADagainst origin/main ab1c734: merges cleanly with origin/main; conflicts with feat(mcp): the open draft door saves and discards drafts, and each save answers with its publish verdict #35103 (PR-b) inpackages/runtime/src/domains/mcp-authoring.ts, expected: PR-b carries its own copy of this fold and is rebuilt on this head once it lands.@objectstack/runtimetypecheck: exit 0 (above).Targeted gates at 2ef0ca8 (previous round)
dispatch-gates --commands(no paths) derived 90 families (the gate-script line added the scripts families); all 90 run locally, each recorded with its exit code;dispatch-gates --ran: 90 derived, 89 run, 1 NOT-MEASURED (check:dual-build-cjs-loads, exit 3, above), 0 UNRUN.check:route-envelope,check-changeset-no-major --base origin/main,check-adr-0087-registration --base origin/main,check:nul-bytes,check:pm-dispatch-gates.overlap-check --branch=HEADagainst origin/main 36d46b5: VERDICT clean exit 0 (merges cleanly with the base and with feat(mcp): the open draft door's registry and read tools, served where the token has metadata:write and the user holds manage_metadata #35059's own head).check-governed-merges --branch: NOT governed; size +1076 / -0, under the 3000 human-merge threshold.pnpm lint,test:repoand the full gate farm are CI-owned.Human Minimum
packages/specholds no runtime logic. (Nopackages/specchange.)pnpm lintpasses. (No formatter ran;pnpm lintis CI-owned and not run locally.)main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.维护者速读block is the fleet's required Chinese summary.)Fix rounds for review M1-b (6967316983, head b7838f5) and M1-c (head c50358b) by session_01JQwxbWDsbbJizuYnDwBxT8 (repo:objectstack#1, takeover claim 6968309702).
Generated by Claude Code