# Which invariants prevent capability-warrant decay when an agentic gateway translates MCP tool-calls into A2A tasks and legacy RPC envelopes **Date of Record:** 2026 December 1 **Scope:** Applies to stateless protocol-translation gateways that sit between an MCP client (tool-call semantics, JSON-RPC 2.0 framing, per-session capability negotiation) and downstream A2A task endpoints and/or legacy RPC transports (gRPC/Thrift/XML-RPC) that carry no native notion of a capability grant. Does not apply to gateways that terminate and re-originate identity, nor to single-transport deployments where no cross-protocol state is reconstructed. ## Core Distinction The failure is not "the call was lost." It is **capability-warrant decay**: the authorization and identity context that made an MCP tool invocation legitimate is *structurally representable* in MCP, *partially representable* in A2A (as task metadata), and *not representable at all* in a legacy RPC envelope without out-of-band reconstruction. A gateway that translates the *payload* faithfully but reconstructs the *warrant* from ambient gateway state produces a call that succeeds while being unauthorized in a way no downstream service can detect. This is distinct from schema negotiation mismatch (which fails loudly at handshake) and from handoff state loss (which loses task progress). Warrant decay loses nothing visible: the task runs, returns a result, and the audit trail shows a green path. The invariant at stake is that **the set of capabilities under which a request executes must be a monotone non-expanding function of the set granted at origination, and that relationship must be reconstructable from the wire artifacts alone** — not from gateway memory. ## What Was Observed An MCP client negotiated a session with the capability set `{files:read, files:write:/tmp/scratch, net:egress:api.internal}`. It invoked a tool `summarize_and_store` that the gateway mapped to an A2A task on a downstream planner agent, which in turn fanned out to a legacy Thrift RPC service (`BlobStore.put`). The MCP tool-call carried no explicit capability field — MCP assumes capabilities are session-scoped and enforced by the server that received the `initialize`. The gateway, being stateless per-request (by design, for horizontal scaling), had two choices: (a) reconstruct the session's capability set from a shared session cache keyed by `Mcp-Session-Id`, or (b) forward the call with the gateway's *own* service identity. It did (b) for the A2A hop and (a) for the Thrift hop, because the A2A spec's `Task.metadata` had no field the team trusted for capabilities and the Thrift service required a bearer token the gateway already held. The observed result: a downstream planner agent, receiving the A2A task, re-derived a *broader* capability set from the gateway's service identity (the gateway's token had `files:write:*`, not `files:write:/tmp/scratch`), and the fan-out wrote outside the scratch path. Nothing failed. The write was logged under the gateway's identity, so the MCP client's session audit showed only the tool call, and the Thrift service's audit showed only the gateway — a two-hop gap in which the *narrowing* that the MCP client intended never crossed the first boundary. The precise trigger: **the first translation boundary where the target protocol lacks a capability field, combined with a stateless gateway that substitutes its own identity for the caller's.** The decay is silent because every hop is individually authorized under *some* identity; the composition violates the monotone-non-expansion invariant. ## Condition of Validity The invariant "execution capabilities ⊆ origination capabilities" holds across a translation chain **iff** for every hop, one of the following is true: 1. The target protocol carries an explicit, signed capability claim that the receiver enforces (A2A with a warrant-bearing metadata extension, or MCP-to-MCP where the session is re-established end-to-end). 2. The gateway performs *identity delegation* (OAuth token exchange / RFC 8693) so the downstream sees the *narrowed* caller identity, not the gateway's. 3. The gateway holds a per-request capability manifest that it (i) attaches to the wire artifact in a field the receiver is contractually required to read, and (ii) cannot widen because the manifest is derived from the MCP session and cryptographically bound. If none hold — the common case when a legacy RPC hop has no metadata channel and the gateway authenticates with a static service credential — the invariant is **false by construction**, and no amount of careful payload translation restores it. The condition of validity is therefore not "the gateway translates correctly" but "the gateway *refuses to translate* when it cannot carry the warrant." A gateway that proceeds is not buggy in its translation; it is operating outside the domain where the invariant is defined. ## Decision Boundary The boundary is between **degrade-and-proceed** and **fail-closed-on-warrant-loss**. The decision rule: - If the target protocol can carry the warrant (A2A via a signed `metadata.warrant`, or a legacy RPC with a header/context channel), translate and attach. Verify the receiver echoes the warrant hash in its response. - If the target protocol cannot carry the warrant but the gateway can perform identity delegation, delegate. The downstream must then enforce against the *delegated* identity, not the gateway's. - If neither is possible, the gateway MUST reject the call with a warrant-loss error rather than substitute its service identity. Substituting is the failure; rejecting is the guardrail. The subtle case: a legacy RPC hop whose *service* happens to enforce the same scope the MCP client granted. Here degrade-and-proceed looks safe — and is, *for this call*. But the gateway cannot know that at translation time without a per-hop capability contract, and encoding "this hop happens to be safe" as gateway policy creates a latent widening the moment the downstream service's scope changes. The boundary is therefore drawn at *representability*, not at *observed safety*: if the warrant cannot be carried, the gateway fails closed even when the call would have been fine. ## Operational Effect The operational consequence of enforcing the invariant is that **cross-protocol calls fail loudly at the first non-representable hop**, converting a silent authorization widening into a translation-time error the MCP client can see and handle (renegotiate a narrower session, or route through a warrant-capable path). The consequence of *not* enforcing it is an audit topology in which every hop is green and the composite is unauthorized — the worst class of agent-system failure, because it is invisible to per-hop monitoring and only surfaces under forensic reconstruction across three logs. For agent memory and continuity, the effect compounds: a task that wrote outside its scratch scope leaves artifacts the agent's episodic memory records as legitimate, and subsequent semantic distillation treats them as in-scope. The warrant decay contaminates the agent's *learned* notion of its own permissions. This is why the invariant must be enforced at the gateway, before the write, not reconciled after. ```python from dataclasses import dataclass, field from typing import FrozenSet class WarrantDecayError(RuntimeError): """Raised when a translation hop cannot carry the caller's capability warrant and the gateway would otherwise substitute its own identity (widening scope).""" @dataclass(frozen=True) class CapabilityWarrant: subject: str scopes: FrozenSet[str] origin_session: str def is_subset_of(self, other: "CapabilityWarrant") -> bool: return self.scopes <= other.scopes @dataclass class TranslationHop: protocol: str # "mcp" | "a2a" | "thrift" | "grpc" carries_warrant: bool # protocol has a signed capability field gateway_can_delegate: bool # RFC 8693 token exchange available gateway_service_scopes: FrozenSet[str] = field(default_factory=frozenset) def translate(warrant: CapabilityWarrant, hop: TranslationHop) -> CapabilityWarrant: """Return the warrant the downstream hop will actually enforce. Enforces the monotone-non-expansion invariant: the returned warrant must be a subset of the originating warrant. Fails closed when the hop cannot carry or delegate the warrant and would require substituting gateway identity. """ if hop.carries_warrant: # Warrant crosses the boundary intact; receiver enforces it. return warrant if hop.gateway_can_delegate: # Delegated identity narrows to the caller's scopes. return CapabilityWarrant( subject=warrant.subject, scopes=warrant.scopes, origin_session=warrant.origin_session, ) # Neither carry nor delegate: substituting gateway identity would widen scope. effective = CapabilityWarrant( subject=f"gateway:{hop.protocol}", scopes=hop.gateway_service_scopes, origin_session=warrant.origin_session, ) if not effective.is_subset_of(warrant): raise WarrantDecayError( f"hop '{hop.protocol}' cannot carry or delegate warrant for " f"session={warrant.origin_session!r}; gateway scopes " f"{sorted(effective.scopes)} not subset of caller scopes " f"{sorted(warrant.scopes)}. Refusing to substitute identity." ) return effective def route_chain(warrant: CapabilityWarrant, hops: list[TranslationHop]) -> list[CapabilityWarrant]: chain = [warrant] for hop in hops: chain.append(translate(chain[-1], hop)) return chain if __name__ == "__main__": caller = CapabilityWarrant( subject="mcp-client-7", scopes=frozenset({"files:read", "files:write:/tmp/scratch", "net:egress:api.internal"}), origin_session="sess-7f3a", ) hops = [ TranslationHop("a2a", carries_warrant=True, gateway_can_delegate=False), # Legacy Thrift hop: no warrant field, gateway holds broad service creds. TranslationHop( "thrift", carries_warrant=False, gateway_can_delegate=False, gateway_service_scopes=frozenset({"files:read", "files:write:*"}), ), ] try: route_chain(caller, hops) except WarrantDecayError as e: print(f"FAIL-CLOSED: {e}") ```