Repository navigation
fix(runtime): read a delegated MCP token's docs audience against the person's own permission sets - #35888
Conversation
…gating person's own permission sets On an agent envelope acting on behalf of a person, the package-docs gate reads the person's own permission sets (grant resolution in the request's organization; no user row or no membership there holds no set), never the token's ceiling sets nor a union with them. The docs seam rides the bridge only where the grant reaches the docs tools. ADR-0090 D10. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
…ated docs audience The unreleased note said an OAuth grant judges a permission-set audience on the token's scope-derived sets; the same release reads the delegating person's own sets (ADR-0090 D10). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
📓 Docs Drift CheckThis PR changes 2 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 37 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 45d30addfeb82976b51f58d575043f5c984428c4 && git checkout 45d30addfeb82976b51f58d575043f5c984428c4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 15b7f51b2796ce29d1b027c7033da604df52bb06 fbcb450dd5977a5095d7363c443069f56f50895c && git checkout -B drift-repro 15b7f51b2796ce29d1b027c7033da604df52bb06 && git merge --no-ff fbcb450dd5977a5095d7363c443069f56f50895c
node scripts/docs-audit/affected-docs.mjs --json 15b7f51b2796ce29d1b027c7033da604df52bb06
|
On an OAuth connection whose grant reaches the docs tools, the docs audience is the delegating person's own permission sets, never wider. The registerPackageDocTools docblock, the bridge member docblock and both tool descriptions now say so; the descriptions are shorter than before. Text only. The #35584 changeset now names @objectstack/mcp for it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
|
repo:objectstack#4 · os-elon-musk · session_016WV4d1k1GRsQbF3vCPKxhz Final head (r2: main merged, plus the text-only commit in
|
|
repo:objectstack#4 · os-elon-musk · session_016WV4d12FHULfLH9SigsWws L1 verdict (L1-a): ACCEPT at head Gates on this head:
Ruling A, condition by condition (holds):
The DELIBERATE CORRECTION (35442 note), sentence by sentence:
35584 changeset, sentence by sentence (holds): scope decides reach (
Notes (non-blocking):
Landing: seat contract read (Clause-② yes, widening; this is also the DELIBERATE CORRECTION's L2 confirmation), then security#2's read-only head check, then the seat lands with the by-design red. Generated by Claude Code |
|
repo:objectstack#4 · os-elon-musk · session_016WV4d1PJ4isQ3eD7Fk1fnF Contract reviewServed-tier: Face: the Read: the net diff against merge-base Result: the code implements ruling A as ruled, and this read found no path on which a permission-set manual is served to a principal the ruling excludes. ① Derived judgmentsRuling A against the code
Widening paths looked for, none found
The DELIBERATE CORRECTION of
S1 (should-fix):
S2 (should-fix, changeset text): the new note's organization sentences say more than the door does.
Nits, none of which moves this head by itself:
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
…ruled The MCP README now says a permission-set audience on an OAuth connection is read against the delegating person's own sets, never wider. The changeset's organization sentences now say what the door does: the organization the request runs in, and an ended membership read with no active organization. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Final head (r3, text only, area a4-C under re-claim 7065076776 on #35584):
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5 L1 verdict (L1-a): ACCEPT at head 席位核对Shape and gates. The delta: 1 commit, 2 files, +4/-3, text only. No code moved, so the earlier ACCEPT's code reading stands.
Landing (not L1's): the area's contract delta on S1/S2, then security#2's read-only head check (ruling condition 4), then landing with the by-design Generated by Claude Code |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Contract reviewServed-tier: Delta round on the declaration face ( ① Derived judgments
② Semver levelUnchanged: ③ Boundary flags
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov security#2 read-only head check — PASS (ruling A 7043930931, condition 4). Head read: What holds, at rule level:
Two non-blocking notes for the lane (neither fails this head):
Adjacent readings outside this diff are with the security seat. |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Contract reviewServed-tier: Merge-only round on the declaration face. ① Derived judgments
② Semver levelUnchanged: ③ Boundary flags
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Landing · head
State: ready + auto-merge now. On merge, #35584 closes by its |
Requested by Elon · project thread
Fixes #35584
Clause-②: yes — widening: on a delegated agent token whose scope reaches the docs tools, a permission-set-gated package doc is now found and read when the delegating person holds that set (ADR-0090 D10, ceiling ∩ delegator); nothing served today is refused, a non-holder and a token without docs-tool access still see nothing. Seat runs a contract read before ready; security#2 checks the head read-only before merge.
Metadata-protocol: none
维护者速读
What changes
On an OAuth MCP connection the request is an agent acting on behalf of the person who consented (ADR-0090 D10).
search_package_docsandread_package_docread every page through the/meta/docdocs-audience gate; for a manual whose audience is{ permissionSet }, the gate asks the security service for the caller's permission-set names. Until now that caller was the agent envelope, whose sets are the token's scope-derived ceiling, so a manual restricted to a set the person holds was neither found nor read on that connection.packages/runtime/src/domains/mcp-package-docs.ts:packageDocsReadGatetakes the data engine. On a delegated agent envelope (principalKind: 'agent'withonBehalfOf.userId), the holdings the audience reads are the person's own:resolveUserAuthzGrantsin the request's organization (tenantId), the grant resolution the open draft door uses, without that door'smanage_metadataadmission. It fails closed the way the security plugin's delegator resolution does: nosys_userrow, no current membership in the organization (vetOrganizationClaim), or a read that throws leaves the person with no set, so permission-set audiences stay closed. The envelope's ceiling sets are never read for the audience and never unioned in. Holdings are resolved once per gate, and only when a permission-set audience is in play. A non-delegated principal (session, API key, AI service account) is unchanged.packages/runtime/src/domains/mcp.ts: the docs seam rides the bridge only where the grant reaches the docs tools (no grant, ordata:read).packageDocToolsServedin@objectstack/mcpstays the authority on listing; the runtime reads the same condition so a token that cannot reach the tools never has the person's holdings read. The bridge call site hands the gate this request's data engine.mcp-package-docs.ts) no longer says the envelope's ceiling is the caller, and the test header and the pin are rewritten to match. The pending 平台 MCP 提供查找与阅读应用文档的工具,并写明回答应用规则的顺序与出处 #35442 changeset is corrected (below).packages/mcp/src/mcp-http-tools.ts, text only (commit 3dae06c, under the amended claim): theregisterPackageDocToolsdocblock, thesearchPackageDocsbridge-member docblock and both tool descriptions now say that on an OAuth connection whose grant reaches the docs tools, the docs audience is the delegating person's own permission sets, never wider. Each description is shorter than before (tools/listweight, mcp: slim the open door's tool list (40 KB at tools/list; validate_expression alone is 7.8 KB) #34689):search_package_docs-25 bytes (100 to 75 for the changed sentence),read_package_doc-29 bytes (93 to 64). No behaviour changes; no test pins either string..changeset/35584-delegated-docs-audience.md(@objectstack/mcpand@objectstack/runtime, patch).DELIBERATE CORRECTION of a pending release note:
.changeset/35442-mcp-app-docs-tools.md(unreleased). Its sentence about OAuth grants now reads: "On an OAuth grant the request is an agent acting for the person who consented, and a permission-set audience is read against that person's own permission sets (ADR-0090 D10), never the token's scope-derived sets." The dropped sentence ("Both tool descriptions say so.") no longer holds.check-empty-changesetis red on this by design; the dispatching seat's record confirms it.Pin flipped in place (
mcp-package-docs.test.ts): "on an OAuth grant the caller is the agent: the page is neither found nor read though the delegator holds the set" answered CLOSED for a holder; it is replaced by "the holder of the set finds and reads the page", which answers OPEN. Card #35584, maintainer ruling A.Ruling conditions
packages/runtime/src/domains/mcp-package-docs.test.tsa token whose scope does not reach the docs tools is carried no docs member, whatever the person holds(person holds the set; tokenmetadata:write+actions:execute; both members absent, scopes passed unchanged to the MCP runtime)the holder of the set finds and reads the page…;fails closed: a person with no user row, or with no membership in the request's organization, holds no set;no union: a manual whose audience is a set only the token's ceiling carries stays closed;an AI service account keeps its own setscontrol: a person who does not hold the set in the token's organization neither finds nor reads it(new, OAuth); the session paira page only a permission-set manual claims is neither found nor read without the set/control: the holder…kept; the scope pin aboveDefault-audience pages are unchanged: every OAuth pin asserts the default page
crm_order_paymentis still found, including the fail-closed and no-union cases.Clause-② reading
Widening only. Nothing served today is refused: the change opens permission-set manuals to a delegated token whose person holds the set and whose scope already reaches the tools. Every answer that was CLOSED for a non-holder stays CLOSED, and a token without
data:readwas already listed neither tool by the MCP runtime, so dropping the seam from its bridge changes nothing it is served.Verification
pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-package-docs.test.ts— 18 tests pass.mcp-package-docs.ts(packageDocsReadGate,delegatorHoldingsCaller),mcp.ts(thepackageDocsscope condition), the new describe block in the test.Ablation (each leg mutated on disk through scripts/ablation-replace.mjs, then restored; HEAD blob hashes re-matched)
fails closed…(1 failed / 17 passed).fails closed…(1 / 17).the holder…andno union…(2 / 16).no union…(1 / 17).mcp.ts: red ona token whose scope does not reach the docs tools…(1 / 17).git diff HEADempty;mcp-package-docs.ts2334108e andmcp.tsf101e596 equal their HEAD blobs.Local runs at head 3dae06c (origin/main 8145424 merged in, then the mcp text commit)
pnpm --workspace-concurrency=2 --filter '@objectstack/mcp^...' --filter '@objectstack/runtime^...' build: VERDICT command-exit 0.vitest run src/domains/mcp-package-docs.test.ts(runtime): 18 passed (18).vitest runof the mcp doc-tool, tools-list weight and initialize selection-rule files: 3 files, 26 passed (26).pnpm --filter @objectstack/mcp test: Test Files 82 passed (82), Tests 1452 passed (1452).pnpm --filter @objectstack/mcp typecheckandpnpm --filter @objectstack/runtime typecheck: VERDICT command-exit 0 (check:test-typecheck: OKfor both).dispatch-gates --commands(68 families, change set vs merge base 8145424), exit codes captured before any pipe: 66 exit 0;check-empty-changeset --base origin/mainexit 1 (only.changeset/35442-mcp-app-docs-tools.md, the DELIBERATE CORRECTION, red by design);check:dual-build-cjs-loadsexit 3 PREREQUISITE NOT MET (needs a whole-repo build), NOT MEASURED.--ranreconciliation: 68 derived, 67 run, 1 NOT-MEASURED. After the changeset line for@objectstack/mcpwas added, the changeset, nul-byte, citation, closing-keyword and affected-docs gates were re-run on the final head: same answers.overlap-check --branch=claude/area-a4C-35584: exit 1, the only overlap the bot's Version Packages PR chore: version packages #35129 on.changeset/35442-mcp-app-docs-tools.md;origin/mainmerges cleanly.Earlier local runs (head 942869d; code identical to ea97649, the commit after which only a changeset changed)
pnpm --workspace-concurrency=2 --filter '@objectstack/runtime^...' build: VERDICT command-exit 0.pnpm --filter @objectstack/runtime typecheck: exit 0 (check:test-typecheck: OK).pnpm --filter @objectstack/runtime test(code tree ea97649): Test Files 634 passed (634); Tests 11712 passed, 25 skipped (11737); VERDICT command-exit 0.dispatch-gates --commands(68 families), each run with its exit code captured: 65 exit 0;check-empty-changeset --base origin/mainexit 1 (the DELIBERATE CORRECTION above, red by design); NOT MEASURED, exit 3 PREREQUISITE NOT MET:check-plugin-teardown-shape --self-test(shallow clone cannot reach its pinned fixture commit) andcheck:dual-build-cjs-loads(needs a whole-repo build).--ranreconciliation: 68 derived, 66 run, 2 NOT-MEASURED, 0 UNRUN.overlap-check --branch=claude/area-a4C-35584: exit 1, the only overlap being the bot's standing Version Packages PR (chore: version packages #35129), which consumes.changeset/35442-mcp-app-docs-tools.md; it is regenerated frommain.Round 3 (seat S1/S2)
Head
183bed4d56, text only, two files:packages/mcp/README.md: the bridge paragraph now says that on an OAuth connection whose grant reaches the docs tools, a permission-set audience is read against the delegating person's own permission sets, never wider. A search of the head for the old sentence ("judged on the token's grant", "caller is the agent", "person's own permission sets") outside CHANGELOGs found no other stale copy..changeset/35584-delegated-docs-audience.md, second bullet: the organization sentences use the seat's wording verbatim (the organization the request runs in: the one the token's consent bound, while the membership there is current; no user row holds no set; an ended membership is read with no active organization, so no grant stored in an organization applies). NoRegen-provenance:line is added to the changeset: that line is a seat-posted thread pointer (scripts/pm/record-recognisers.mjs), not changeset text.oauthEnvelope) was drafted but not verified before the handover stop, so it is not in this head. Nit b was not done:packageDocsReadGatehas no logger, so it would take more than one line per arm. Nit c skipped, as the order says.check-nul-bytes: OK.overlap-check: exit 1, the same Version Packages PR chore: version packages #35129 overlap on.changeset/35442-mcp-app-docs-tools.mdas before;origin/mainmerges cleanly.Acceptance notes
resolveUserAuthzGrantsdirectly inmcp-package-docs.tsrather than via a helper shared withmcp-authoring.ts: that file is outside this PR's claimed surface, and its reader is admitted onmanage_metadata, which the ruling says must not apply here. The two readers now share the grant call, not the admission.data:read, or no grant) is spelled once more in the runtime besidepackageDocToolsServed, as the draft door readsmetadata:writebesidegrantsAuthoringTools. If the MCP runtime's docs family ever changes, both must move.Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
🤖 Generated with Claude Code