# When must an instance reject a pinned MCP tool schema after a signed manifest has been re-resolved mid-session **Date of Record:** 2026 December 2 **Scope:** Applies to any agent runtime that resolves MCP server tool schemas through a signed manifest and pins the resolved schema into a long-lived execution context (session, task, or multi-step plan). Does not apply to stateless single-call invocations where schema resolution and tool execution are atomic, nor to servers whose tool surface is immutable by construction. ## Core Distinction The failure mode is not "the manifest signature is invalid." Signature verification is a solved, binary gate. The non-obvious boundary is **the moment a session re-resolves a manifest that verifies cleanly but yields a semantically different tool schema under the same tool name**. A signed manifest attests to *who published this schema version*, not to *whether the schema you pinned at session start still describes the tool you are about to call*. Two distinct trust questions get collapsed into one: 1. **Provenance integrity** — is this manifest authentically from the expected publisher and unmodified in transit? (signature) 2. **Continuity integrity** — is the schema I am about to invoke byte-equivalent (or behaviorally equivalent) to the schema I reasoned over when I built my plan? (pinning + drift) A re-resolution that passes (1) and fails (2) is the dangerous case. The signature is valid. The publisher is legitimate. The agent's plan is now stale. An agent that treats "signature OK" as "safe to proceed" will silently invoke a tool whose parameter semantics shifted underneath its reasoning trace. ## What Was Observed A planning agent resolved an MCP server `calc.ops` at task start. The signed manifest pinned `unit_convert` with schema: ``` { "from": string, "to": string, "value": number } ``` At step 7 of a 12-step plan, the runtime's manifest cache TTL (300s) expired and the resolver re-fetched. The manifest signature verified against the same publisher key, but the tool entry had been republished under a new manifest revision (rev 41 → rev 42) with a schema change: ``` { "from": string, "to": string, "value": number, "precision": integer (required) } ``` `precision` was added as a **required** field. The signature on rev 42 was valid. The agent's pinned schema (rev 41) did not contain `precision`. The agent, reasoning over the pinned schema, emitted a call without `precision`. The server, running rev 42, rejected the call with a validation error — but the agent's error-handling path classified it as a transient tool failure and retried three times, then fell back to a *different* tool whose semantics it had also pinned from an older revision. The result was a numerically wrong answer that passed the agent's own self-check because the self-check was written against the stale schema's contract. The trace showed no error at the trust boundary. Every signature check passed. The corruption was entirely in the gap between **pinned schema** and **live schema**, mediated by a cache TTL that no component owned. ## Condition of Validity The invariant that must hold for a pinned-schema session to be sound: > For the lifetime of a pinned execution context, every tool invocation must be validated against the *pinned* schema, and any divergence between the pinned schema and the live manifest-resolved schema must be surfaced as a hard continuity fault — not a transient error — before the invocation is dispatched. This holds only under three conditions, all of which must be enforced, not assumed: - **Pin identity includes a content hash, not just a version string.** `tool_convert@rev41` is insufficient; the pin must carry `sha256(canonical_schema_bytes)`. Version strings are publisher-controlled and can be reused or re-pointed. - **Re-resolution never silently replaces a pinned schema mid-context.** A re-resolve that returns a different content hash must either (a) be rejected for the remainder of the pinned context, or (b) trigger an explicit re-plan with the new schema, invalidating the existing plan's downstream steps. - **Schema drift is classified as a continuity fault, not a tool error.** The agent's retry/fallback logic must not treat a schema-mismatch rejection as retryable. It is a signal that the world model is stale. The condition fails when any of: the pin is version-only; cache TTL is owned by the transport layer rather than the execution context; or the tool-error taxonomy has no distinct class for "schema continuity violation." ## Decision Boundary The boundary is drawn at **dispatch time, not resolution time**. Resolution produces a candidate schema; dispatch is where the pinned schema is asserted against the live one. The decision procedure: 1. On every tool dispatch within a pinned context, compute `H_live = sha256(canonical(live_resolved_schema))`. 2. Compare against `H_pinned` recorded at context creation. 3. If equal → dispatch. 4. If unequal → **do not dispatch**. Raise a continuity fault. The fault carries both hashes and a structural diff of the schemas (added/removed/required-changed fields). 5. The fault is non-retryable at the tool layer. It propagates to the planner, which must decide: re-pin and re-plan from the current step, or abort the context. The subtle part: a *behaviorally equivalent* schema (e.g., field reordering, doc-comment change) will produce a different content hash but no semantic drift. This is where over-strict pinning causes false aborts. The correct boundary uses a **canonical structural hash** — normalized key order, stripped descriptions, type-signature-only — so that cosmetic republication does not trip the fault, while any change to required fields, types, or enum domains does. Hashing raw bytes is too strict; hashing the tool *name* is too loose. The canonical structural hash is the only stable middle. ## Operational Effect With the boundary enforced, the failure observed above becomes a **loud, early, attributable fault** at step 7 instead of a silent wrong answer at step 12. The agent learns: "the tool I planned against no longer exists in that form; my plan is invalid from here." It re-plans against rev 42, adds `precision`, and completes correctly — or aborts with a clear continuity report. The cost is a per-dispatch hash comparison (cheap) and a canonicalization routine that must be kept in sync with the schema dialect. The benefit is that **signature validity is no longer conflated with plan validity**. The supply-chain attack surface narrows to: an attacker who can produce a validly-signed manifest *and* a schema whose canonical structural hash collides — which is the same hardness as breaking the signature, not weaker. The invariant to encode: *a signed manifest guarantees the publisher; a pinned structural hash guarantees the plan. An agent must verify both, and must treat their disagreement as a continuity fault, never as a tool error.* ```python import hashlib import json from dataclasses import dataclass class SchemaContinuityFault(RuntimeError): """Raised when a live tool schema diverges from the pinned schema mid-context. This is NOT a tool execution error and MUST NOT be retried at the tool layer. It signals that the agent's plan was built against a schema that no longer describes the live tool. Propagate to the planner for re-pin or abort. """ @dataclass(frozen=True) class PinnedTool: name: str structural_hash: str # sha256 of canonical structural schema manifest_rev: str publisher_key_id: str def canonical_structural_hash(schema: dict) -> str: """Hash only semantically load-bearing structure: types, required fields, enums. Strips descriptions, titles, examples, and key order so that cosmetic republication does not trip continuity. Any change to required-ness, type, or enum domain DOES change the hash. """ def normalize(node): if isinstance(node, dict): keep = {} for k in ("type", "required", "enum", "items", "properties", "additionalProperties"): if k in node: keep[k] = normalize(node[k]) return keep if isinstance(node, list): return [normalize(x) for x in node] return node canon = json.dumps(normalize(schema), sort_keys=True, separators=(",", ":")) return hashlib.sha256(canon.encode("utf-8")).hexdigest() def assert_schema_continuity(pinned: PinnedTool, live_schema: dict, live_rev: str) -> None: """Dispatch-time gate. Call before every tool invocation in a pinned context.""" live_hash = canonical_structural_hash(live_schema) if live_hash != pinned.structural_hash: raise SchemaContinuityFault( f"Tool '{pinned.name}' schema drifted mid-context: " f"pinned={pinned.structural_hash[:12]}@{pinned.manifest_rev} " f"live={live_hash[:12]}@{live_rev}. " f"Plan built against pinned schema is invalid from this step. " f"Do not retry at tool layer; re-pin and re-plan or abort." ) ```