Skip to content

policy: gate on what a tool says it does - #57

Merged
blakebauman merged 2 commits into
mainfrom
policy/destructive-gating
Aug 13, 2026
Merged

blakebauman merged 2 commits into
mainfrom
policy/destructive-gating

Conversation

@blakebauman

Copy link
Copy Markdown
Member

Phase 3 of docs/design-policy-depth.md, following #55 and #56.

Expressing "read anything, write nothing" meant naming every read-only tool and re-deriving that list per upstream — an allowlist that fails open the moment an upstream adds one. toolKind gates on the MCP annotations fold has been ignoring:

{ "server": "*", "methods": ["tools/call"], "toolKind": "readOnly" }

readOnly requires readOnlyHint; nonDestructive additionally admits tools whose destructiveHint is false. Unlike argument constraints, annotations arrive with the list, so this filters lists as well as denying calls — the enforcement pair stays intact.

What this is not

A hygiene control, not a security boundary. The annotations are declared by the very server being gated, so an upstream that labels delete_everything as read-only is believed. It is for federations your organization operates, where the risk is an operator forgetting to update an allowlist. Against a server you do not control, the boundary is names — the README says this in those words rather than implying the gate holds.

Taking the spec at its word

readOnlyHint defaults to false and destructiveHint to true, so an unannotated tool is neither read-only nor non-destructive and fails both gates. fold does not "improve" those defaults; the improvement would be admitting every unannotated tool to a read-only grant. The integration test drives a real upstream with an unannotated tool for exactly this reason.

Unknown annotations deny — fail-safe in the direction the rest of the engine fails. That covers more than the design anticipated: an upstream whose list caching is disabled (caller-derived credential) has nothing to consult, and so does a name the upstream does not list. Both refuse, so toolKind does not compose with passthrough/token-exchange, which is now documented and tested rather than discovered.

One shape change from the design

There is no separate annotation index. At list time fold already holds the tool, so annotations are read from the item; at call time they resolve from the same cached list the egress path decodes, and only when a rule gates on kind. A second index keyed by upstream and name would have been a third thing to invalidate in step with the cache, in exchange for avoiding a linear scan of an already-decoded slice on a path about to make a network call anyway.

Verification

make check (race) green, make conformance 40/40, per-item decide unchanged at 77 ns / 0 allocs for documents using none of this. Three new policy unit tests (including the full annotation truth table) and two integration tests against an upstream publishing real annotations.

Phase 4 — the docs pass across defaults.md and the rest — is what remains.

🤖 Generated with Claude Code

blakebauman and others added 2 commits August 13, 2026 10:24
Expressing "read anything, write nothing" meant naming every read-only tool
and re-deriving the list per upstream, which fails open the moment an upstream
adds one. toolKind gates on the MCP annotations fold has been ignoring:
readOnly requires readOnlyHint, nonDestructive additionally admits tools whose
destructiveHint is false.

Unlike argument constraints, annotations arrive with the list, so this filters
lists as well as denying calls — the enforcement pair stays intact for it.

The spec's defaults are taken as written rather than improved. readOnlyHint
defaults to false and destructiveHint to true, so an unannotated tool is
neither read-only nor non-destructive and fails both gates. The improvement
nobody should make here is admitting unannotated tools to a read-only grant.

Unknown annotations deny, which is fail-safe in the direction the rest of the
engine already fails. That covers more cases than the design record
anticipated: an upstream whose list caching is disabled because its credential
is caller-derived has nothing to consult, and neither does a name the upstream
does not list. Both refuse, and toolKind therefore does not compose with
passthrough or token-exchange — documented rather than discovered.

There is no separate annotation index, which the design record expected. At
list time fold is already holding the tool, so annotations are read from the
item; at call time they resolve from the same cached list the egress path
decodes, only when a rule actually gates on kind. A second index keyed by
upstream and name would have been a third thing to invalidate in step with the
cache, in exchange for avoiding a linear scan of an already-decoded slice on a
path about to make a network call anyway.

The README says plainly what this is: a hygiene control for federations you
operate, not a security boundary, because the annotations are declared by the
very server being gated. Against an upstream you do not control the boundary
is names, and no amount of toolKind substitutes for it.

Phase 3 of docs/design-policy-depth.md. Per-item decide is unchanged at 77 ns
with zero allocations for documents using none of this; conformance 40/40.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
CI's linter caught what the refactor left behind: listFilter.decide took an
upstream id and a name it no longer used, because each caller's closure
captures the item it is deciding about. Removing them is the whole change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@blakebauman
blakebauman merged commit 98ea4b4 into main Aug 13, 2026
7 checks passed
@blakebauman
blakebauman deleted the policy/destructive-gating branch August 13, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant