Skip to content

feat: notice when an upstream rewrites what it advertises - #54

Merged
blakebauman merged 1 commit into
mainfrom
feat/definition-pinning
Aug 13, 2026
Merged

blakebauman merged 1 commit into
mainfrom
feat/definition-pinning

Conversation

@blakebauman

Copy link
Copy Markdown
Member

Phase 1 of docs/design-definition-pinning.md (#53): detection.

A tool's description and input schema are the instruction set a model acts on, and its annotations are what policy decides with. fold re-read all of it on every cache refill and compared it to nothing — so the approval that mattered, a human reading a tool list and accepting the federation, was pinned to nothing. A tool could acquire new instructions afterwards and be served under the same namespace, the same grant, and the same audit trail as the one that was approved.

pinDefinitions: "warn" records the digest of every tool and prompt definition an upstream advertises and reports a difference: the upstream/definitionChanged audit event, fold_definition_drift_total{upstream,kind}, and a packaged FoldDefinitionDrift alert. The new definition becomes the baseline, so a change is one event rather than one per refill forever — an alert that repeats is an alert that gets filtered.

Three decisions worth their reasoning

The baseline is shared state, because of the attack. A per-instance baseline means every pod trusts what it saw first, so a rolling restart re-pins the whole federation to whatever is current — precisely the moment worth choosing if you are the one rewriting a definition. state.Store already has the semantics: absence is meaningful, and a Redis outage degrades to the local mirror the way task ownership does.

Annotations are in the digest. A tool flipping destructiveHint has edited its authorization, not its documentation — and once policy depth gates on annotations, that is an escalation performed by the party being gated.

The check runs once per cache generation. It hangs off the list fetch inside the cache fill, so the proxy path never sees it: added p50 is unmoved at 175 µs.

The audit event carries the two digests, truncated, and never the new text — reproducing upstream-controlled content in the trail would put it into every SIEM that reads it.

Limits, stated in the docs rather than implied

Trust-on-first-use cannot vouch for a definition fold has never seen; this detects change, not badness. A legitimate improvement to a description trips it identically to a hostile rewrite, because they are the same bytes — the event says changed and a human decides which kind. And it reports rather than blocks.

Blocking stays unbuilt on purpose: prevention needs a way to adopt a new definition, and every candidate costs either a write path into running state or a hand-copying chore. The design record names that choice instead of guessing at it.

Verification

  • make check — race suite green
  • make conformance — 40/40
  • make bench — added p50 175 µs against a 5 ms gate
  • make helm-check — clean
  • 4 new integration tests driving a real SDK upstream that rewrites a tool description mid-test, including the frozen-default guarantee and the report-once contract

The observability pack's lockstep test is what forced the alert to exist rather than the metric shipping unwatched — it failed until the rule was written, in both the chart and the plain-Prometheus copy.

🤖 Generated with Claude Code

A tool's description and input schema are the instruction set a model acts on,
and its annotations are what policy decides with. fold re-read all of it on
every cache refill and compared it to nothing, so the approval that mattered —
a human reading a tool list and accepting the federation — was pinned to
nothing. A tool could acquire new instructions afterwards and be served under
the same namespace, grant, and audit trail as the one that was approved.

pinDefinitions: "warn" records the digest of every tool and prompt definition
an upstream advertises, reports a difference through the audit trail
(upstream/definitionChanged), a metric (fold_definition_drift_total), and a
packaged alert (FoldDefinitionDrift), and adopts the new definition as the
baseline so a change is one event rather than one per refill forever.

Three decisions worth their reasoning. The baseline lives in state.Store
rather than in memory because a per-instance baseline means every pod trusts
what it saw first, so a rolling restart would re-pin the whole federation to
whatever is current — precisely the moment worth choosing if you are the one
rewriting a definition. Annotations are in the digest because a tool flipping
destructiveHint has edited its authorization rather than its documentation,
which matters more once policy gates on them. And the check hangs off the list
fetch, inside the cache fill, so it runs once per cache generation rather than
once per request: added p50 is unmoved and the proxy path never sees it.

The audit event carries the two digests, truncated, and never the new text.
Reproducing upstream-controlled content in the trail would put it into every
SIEM that reads it.

Off by default, because every default is frozen; the production checklist is
where an operator is told to turn it on for upstreams they do not run
themselves. Blocking stays unbuilt on purpose — legitimate change and attack
are the same bytes, so prevention needs an adoption path and every candidate
costs either a write path into running state or a hand-copying chore. That is
an operator's call and the design record names it rather than guessing.

Conformance 40/40; helm-check clean; the observability pack's lockstep test is
what forced the alert to exist rather than the metric shipping unwatched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@blakebauman
blakebauman merged commit b17465b into main Aug 13, 2026
7 checks passed
@blakebauman
blakebauman deleted the feat/definition-pinning branch August 13, 2026 16:11
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