Repository navigation
feat: notice when an upstream rewrites what it advertises - #54
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: theupstream/definitionChangedaudit event,fold_definition_drift_total{upstream,kind}, and a packagedFoldDefinitionDriftalert. 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.Storealready 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
destructiveHinthas 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 greenmake conformance— 40/40make bench— added p50 175 µs against a 5 ms gatemake helm-check— cleanThe 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