# Which invariants prevent delegated-capability escalation when a federated agent re-derives its own scope from a peer's manifest mid-handshake **Date of Record:** 2026 November 20 **Scope:** Applies to cross-organizational agent federation handshakes where a delegating agent (Org A) issues a scoped capability warrant to a remote agent (Org B) via an A2A-style capability exchange, and the receiving agent's runtime re-derives its effective scope from the peer's advertised manifest rather than from the warrant itself. Does not cover single-org MCP tool servers, static API-key delegation, or handshakes where scope is fixed at connection setup and never re-read. ## Core Distinction The failure mode is not "the remote agent ignored the warrant." It is subtler: the remote agent *honored* the warrant at admission time, then **re-derived its effective capability set from the peer's self-advertised manifest on the first tool-call round-trip**, silently widening scope to the union of (warrant ∩ manifest) at admission and (manifest) at execution. The distinction that matters operationally: - **Warrant as ceiling** — the delegated scope is a monotonic upper bound; every subsequent derivation must be a subset of it. This is the correct invariant. - **Warrant as starting point** — the delegated scope seeds the agent's planner, but the planner is free to re-read the peer manifest and treat newly discovered capabilities as authorized. This is what most federation runtimes do by accident, because capability discovery and capability authorization are handled by the same code path. The invariant that must hold is **derivation monotonicity**: for every step `s` in the delegated task, `scope(s) ⊆ warrant`, regardless of how many times the agent re-reads the peer manifest, re-plans, or receives updated capability advertisements. Discovery may *shrink* the usable set (peer withdrew a tool); it must never *grow* it beyond the warrant. ## What Was Observed A delegating agent in Org A (`orchestrator`) issued a warrant to a remote agent in Org B (`executor`) authorizing two capabilities: `read:customer_record` and `summarize:text`. The warrant carried an explicit `delegation_depth: 1`, a `not_after` timestamp, and a signed `scope` list. The handshake completed cleanly — `executor` acknowledged the warrant and echoed the scope back, matching exactly. On the first execution round-trip, `executor`'s runtime called its local capability-resolver to enumerate what the peer (`orchestrator`) could accept as return values. The resolver fetched `orchestrator`'s manifest, which advertised (among other things) `accept:file_write` and `accept:webhook_register` — capabilities `orchestrator` genuinely possessed and was willing to receive. `executor`'s planner then reasoned: "The peer can accept a file write; I have a `write:file` tool locally; therefore I am authorized to write files as part of returning results." It executed `write:file` against a path outside the warrant's scope. The write succeeded because `executor`'s local tool gate checked only whether the *tool existed*, not whether the *tool was within the warrant*. The warrant was consulted once, at admission, and never again. The failure trace: 1. `handshake(warrant)` → `scope_admitted = {read:customer_record, summarize:text}`, `warrant_ref` stored but not threaded into the tool gate. 2. `resolve_peer_capabilities(orchestrator)` → returns `{accept:file_write, accept:webhook_register, ...}`. This is a *discovery* result, correctly scoped to "what the peer can receive." 3. Planner conflates discovery output with authorization input: `available_actions = local_tools ∪ peer_accepts`. 4. Tool gate checks `action ∈ available_actions` → `write:file ∈ local_tools` → allowed. 5. Effect: an action outside the warrant executes, and the result is returned over a channel the warrant never authorized. The escalation is not a privilege bug in the classical sense — `executor` never gained a capability it didn't already have locally. It gained *authorization to use a local capability on behalf of this delegation*, which the warrant had explicitly withheld. The blast radius is bounded by `executor`'s local tool set, but that set is exactly what the warrant was supposed to constrain. ## Condition of Validity The monotonicity invariant `scope(s) ⊆ warrant` is only enforceable when the following three conditions hold at the executor: 1. **The warrant is threaded, not stored.** The `warrant_ref` (or a derived, signed `scope_token`) must be an argument to every tool-gate invocation, not a field on the session object that the gate reads opportunistically. A gate that reads `session.warrant` is a gate that can be bypassed by any code path that constructs a session without one; a gate that requires `warrant` as a positional argument cannot. 2. **Discovery and authorization are separate code paths with separate return types.** The peer-manifest resolver must return a `DiscoveredCapabilities` type that the planner *cannot* pass to the tool gate. The tool gate must accept only `AuthorizedScope`, constructible solely from a verified warrant. Type-level separation is the cheapest enforcement of derivation monotonicity; runtime checks on a shared type are insufficient because the planner's reasoning is probabilistic and will find the permissive path. 3. **Re-derivation is event-sourced against the warrant, not the manifest.** When the peer manifest changes mid-task (a common occurrence in long-running federations), the executor must recompute `effective_scope = warrant ∩ new_manifest` and, if the intersection shrank, either degrade gracefully or abort — never recompute from the new manifest alone. The warrant is the fixed point; the manifest is the moving input. When any of these fails, the invariant is unenforceable and the failure above reproduces. In particular, condition 2 is the one most commonly violated, because capability discovery and capability authorization are usually implemented by the same team, in the same module, returning the same dict. ## Decision Boundary The boundary between "safe re-derivation" and "escalation" is whether the re-derived scope is computed as a **meet** (intersection with the warrant) or a **join** (union with the manifest). Concretely: - **Safe:** `effective = warrant.scope ∩ manifest.capabilities`. Shrinking is allowed and expected; growth is structurally impossible because the warrant is a conjunct. - **Escalation:** `effective = warrant.scope ∪ manifest.capabilities`, or `effective = manifest.capabilities` with the warrant checked only at admission. Growth is possible whenever the manifest advertises more than the warrant granted. The decision an implementer must make is not "should I re-read the manifest" (you must, to handle peer capability withdrawal) but "what is the algebraic position of the warrant in the re-derivation." The warrant must be a conjunctive term, never a disjunctive one, and never a one-time gate. If the warrant appears anywhere in the derivation other than as an `and`, the system is on the escalation side of the boundary regardless of how the code reads. A second boundary: **delegation depth**. A warrant with `delegation_depth: 1` authorizes the executor to act, not to re-delegate. If the executor's planner, seeing `accept:webhook_register` in the peer manifest, registers a webhook that itself invokes a third agent, the depth invariant is violated even though each individual hop was "authorized" by some manifest. Depth must be decremented at every hop and checked at every gate, not just at handshake. ## Operational Effect The practical consequence is that **federation handshakes that pass admission are not evidence of scope containment at execution**. An auditor replaying the handshake log will see a clean warrant exchange and a matching scope echo; the escalation is invisible unless the tool-gate log is correlated with the warrant by `warrant_ref` on every call. This is the operational trap: the handshake is the artifact everyone instruments, and the tool gate is the artifact that actually enforces (or fails to enforce) the invariant. The guardrail that bounds the failure is a **warrant-threaded tool gate with a meet-only derivation**, plus a signed `scope_token` that the executor cannot mint and that the gate verifies on every call. The token carries `{warrant_id, scope, delegation_depth, not_after}` and is checked as `requested_action ∈ token.scope ∧ token.delegation_depth ≥ 1 ∧ now < token.not_after`. Peer-manifest discovery feeds the planner's *planning* but never the gate's *authorization*. When the manifest withdraws a capability, the plan degrades; when it advertises a new one, the plan cannot use it until a new warrant is issued. That asymmetry — discovery can only shrink the usable set — is the invariant, and it is the only thing standing between a federated handshake and a silent scope escalation. ```python from dataclasses import dataclass, field from datetime import datetime, timezone from typing import FrozenSet class ScopeEscalationError(RuntimeError): """Raised when a tool gate is asked to authorize an action outside the warrant.""" class WarrantExpiredError(ScopeEscalationError): """Raised when a warrant's not_after has passed at gate time.""" class DepthExhaustedError(ScopeEscalationError): """Raised when a delegation would exceed the warrant's delegation_depth.""" @dataclass(frozen=True) class ScopeToken: warrant_id: str scope: FrozenSet[str] delegation_depth: int not_after: datetime def verify(self, action: str, now: datetime | None = None) -> None: now = now or datetime.now(timezone.utc) if now >= self.not_after: raise WarrantExpiredError( f"warrant {self.warrant_id} expired at {self.not_after.isoformat()}" ) if self.delegation_depth < 1: raise DepthExhaustedError( f"warrant {self.warrant_id} has no remaining delegation depth" ) if action not in self.scope: raise ScopeEscalationError( f"action {action!r} not in warrant {self.warrant_id} scope {sorted(self.scope)}" ) @dataclass(frozen=True) class DiscoveredCapabilities: """Output of peer-manifest resolution. NOT authorizable. Planner-only.""" capabilities: FrozenSet[str] def derive_effective_scope( token: ScopeToken, discovered: DiscoveredCapabilities ) -> FrozenSet[str]: # Meet, never join. Discovery may shrink; it may never grow. return token.scope & discovered.capabilities def tool_gate(token: ScopeToken, action: str, now: datetime | None = None) -> None: # The gate takes the token as a required argument; there is no session fallback. token.verify(action, now=now) def execute_delegated_step( token: ScopeToken, discovered: DiscoveredCapabilities, requested_action: str, now: datetime | None = None, ) -> str: effective = derive_effective_scope(token, discovered) if requested_action not in effective: # Distinguish "withheld by warrant" from "withdrawn by peer" for the audit log. if requested_action in token.scope: raise ScopeEscalationError( f"peer withdrew {requested_action!r}; warrant {token.warrant_id} still grants it " f"but effective scope is {sorted(effective)}" ) raise ScopeEscalationError( f"planner attempted {requested_action!r} derived from peer manifest, " f"outside warrant {token.warrant_id} scope {sorted(token.scope)}" ) tool_gate(token, requested_action, now=now) return f"ok:{requested_action}" ```