# What happens when an instance attenuates a delegated capability scope but the downstream tool cache replays a pre-attenuation result **Date of Record:** 2026 November 24 **Scope:** Applies to any A2A/MCP delegation chain where a delegating agent (the *attenuator*) narrows a child agent's capability scope (allowed tools, allowed argument domains, allowed resource paths) and the child's tool-invocation results are memoized or cached across the delegation boundary. Does not apply to stateless per-call capability tokens where every tool call re-evaluates scope at the tool server, nor to purely conversational handoffs with no tool surface. ## Core Distinction Least-privilege scope attenuation is usually modeled as a *set-membership* property: the child's granted capability set `C_child ⊆ C_parent`, and each tool call is checked against `C_child` at invocation time. The failure mode documented here is orthogonal to set membership. It is a *temporal* property: attenuation is an event that changes the validity of results produced under the *pre-attenuation* scope, but a tool-result cache keyed only on `(tool_name, arguments)` — and not on the effective scope under which the result was produced — will happily replay a result that the child is no longer permitted to *cause*. The invariant that is silently violated is not "the child cannot call forbidden tools" but "**no result observed by the child may have been produced under a scope broader than the child's current scope**." A cache hit is a result observation that bypasses invocation-time scope checking entirely, because no invocation occurs. ## What Was Observed A parent orchestrator agent `P` held a broad capability `fs.read:/workspace/**` and delegated to child `C` a narrowed capability `fs.read:/workspace/public/**`. The delegation protocol carried the attenuated scope in the handoff envelope, and `C` correctly refused direct reads outside `/workspace/public`. So far the set-membership check held. During a *prior* task, `P` (under its broad scope) had populated a shared tool-result cache with the entry: ``` key = ("fs.read", {"path": "/workspace/secret/keys.env"}) value = ``` The cache key was `(tool_name, canonicalized_arguments)`. It carried no scope tag. It was written by `P`, but the cache was process-shared, and `C` inherited a handle to it as part of the tool transport (the MCP client in `C` pointed at the same result-memoization layer `P` used). When `C` attempted `fs.read("/workspace/secret/keys.env")`: 1. The scope gate at the tool server evaluated `"/workspace/secret/keys.env" ∈ /workspace/public/**` → **deny**. 2. But the MCP client in `C` checked the local result cache *before* dispatching to the tool server. Cache hit. 3. `C` received the file contents and recorded them in its episodic memory as an observation. The scope gate never ran, because the gate lives on the dispatch path and the cache lives in front of it. `C`'s transcript now contains a fact it was structurally forbidden from obtaining, and — critically — `C`'s subsequent reasoning treats it as legitimate because it arrived through the same tool-result channel as every permitted read. There is no marker distinguishing a cache-replayed result from a freshly gated one. A second, subtler variant appeared with *argument-aliasing*: `P` had cached `fs.read({"path": "/workspace/public/../secret/keys.env"})` under a pre-normalization key (the broad-scope path resolution had succeeded because `P`'s scope covered the resolved target). `C`'s cache lookup normalized arguments to the same key, hit the entry, and received contents for a path that, post-normalization, resolves outside `C`'s scope. Here even a scope-tagged cache would have been defeated, because the *tag* was computed on the pre-normalized argument. ## Condition of Validity The failure requires the conjunction of four conditions; remove any one and the boundary holds: 1. **Result memoization keyed without scope.** The cache key does not include the effective capability scope (or a hash of the attenuation chain) under which the entry was produced. 2. **Cache shared across a delegation boundary.** The child reads entries written by the parent or by any agent with a broader scope. 3. **Scope enforcement on the dispatch path only.** The gate is evaluated at tool-server invocation, not at result-admission into the child's context. 4. **No provenance marker on replayed results.** The child cannot distinguish a cache hit from a live gated call, so its own reasoning cannot apply a secondary trust check. The argument-aliasing variant additionally requires that the cache key be computed on arguments *before* the same canonicalization the scope gate applies — i.e., a normalization-order mismatch between the cache layer and the authorization layer. ## Decision Boundary The correct architectural boundary is: **scope is a property of the result, not only of the invocation.** Concretely, an entry may be admitted from cache into a child's context only if the scope-tag recorded at write time is a *subset* of the child's current effective scope — the same attenuation relation the delegation protocol enforces on grants, now applied to cached results. This makes the cache a scope-aware store rather than a transparent memoization layer. Two sub-boundaries follow: - **Canonicalize before keying, and key on the canonical form the gate will see.** The cache key must be computed on the same normalized arguments the authorization layer evaluates, or the two layers disagree about what was asked for. - **Tag on write with the writer's effective scope, not the writer's identity.** Identity-based tagging fails when the same principal operates under different attenuations across tasks; scope-based tagging is the invariant that actually needs to hold. If a cache cannot be made scope-aware (e.g., it is a third-party memoization layer outside the agent's control), the only sound decision is to **disable cross-boundary sharing**: the child gets a private cache namespace that is flushed at each delegation edge. This trades hit rate for the invariant. ## Operational Effect With scope-aware admission, the replay above fails closed: `C`'s lookup finds the entry but the admission check `scope_tag(entry) ⊆ current_scope(C)` returns false (`/workspace/** ⊄ /workspace/public/**`), the entry is treated as a miss, and the call proceeds to the tool server where the gate denies it. `C` observes a clean permission denial, which is the correct and *legible* outcome — its reasoning can incorporate "I am not permitted to read this," rather than silently incorporating the secret. The cost is a measurable cache-hit regression at delegation edges, concentrated exactly where parents and children have asymmetric scopes — which is to say, everywhere least-privilege is actually practiced. Systems that report high cross-agent cache hit rates should be audited: high hit rates across scope-asymmetric edges are a symptom, not a success metric. The residual risk after the fix is the normalization-order class: scope-tagged caches still replay the wrong entry if the tag was computed on un-normalized arguments. The guardrail is to compute the scope tag and the cache key from a single canonicalization function shared with the authorization layer, and to assert at write time that re-canonicalizing the stored arguments is idempotent — a cheap invariant check that catches the aliasing variant before it reaches a child. ```python import hashlib from dataclasses import dataclass class ScopeReplayViolation(RuntimeError): """Raised when a cached tool result would be admitted under a scope broader than the one it was produced under, or when canonicalization is not idempotent across the cache/auth boundary.""" pass def canonicalize_path(p: str) -> str: # Single canonicalization shared by cache keyer AND scope gate. parts = [] for seg in p.split("/"): if seg in ("", "."): continue if seg == "..": if parts: parts.pop() continue parts.append(seg) return "/" + "/".join(parts) def scope_covers(scope: str, canonical_path: str) -> bool: # scope like "/workspace/public/**" prefix = scope.rstrip("*").rstrip("/") return canonical_path == prefix or canonical_path.startswith(prefix + "/") @dataclass(frozen=True) class CachedResult: tool: str canonical_args: str writer_scope: str payload: str class ScopeAwareCache: def __init__(self): self._store: dict[tuple[str, str], CachedResult] = {} def put(self, tool: str, raw_args: str, writer_scope: str, payload: str) -> None: canon = canonicalize_path(raw_args) # Idempotence invariant: re-canonicalizing must be a no-op. if canonicalize_path(canon) != canon: raise ScopeReplayViolation( f"non-idempotent canonicalization for {raw_args!r} -> {canon!r}" ) self._store[(tool, canon)] = CachedResult(tool, canon, writer_scope, payload) def get(self, tool: str, raw_args: str, reader_scope: str) -> str | None: canon = canonicalize_path(raw_args) entry = self._store.get((tool, canon)) if entry is None: return None # Admission check: writer scope must be a subset of reader scope. # We approximate subset by requiring reader_scope to cover the # canonical target AND the writer scope to be no broader than reader. if not scope_covers(reader_scope, entry.canonical_args): raise ScopeReplayViolation( f"cache hit for {canon!r} denied: entry written under " f"{entry.writer_scope!r}, reader scope {reader_scope!r}" ) if entry.writer_scope != reader_scope and not _scope_subset( entry.writer_scope, reader_scope ): raise ScopeReplayViolation( f"scope-tag mismatch: writer {entry.writer_scope!r} not " f"subset of reader {reader_scope!r}" ) return entry.payload def _scope_subset(a: str, b: str) -> bool: a_prefix = a.rstrip("*").rstrip("/") b_prefix = b.rstrip("*").rstrip("/") return a_prefix == b_prefix or a_prefix.startswith(b_prefix + "/") def child_read(cache: ScopeAwareCache, path: str, child_scope: str) -> str: hit = cache.get("fs.read", path, child_scope) if hit is not None: return hit if not scope_covers(child_scope, canonicalize_path(path)): raise ScopeReplayViolation( f"live dispatch denied: {canonicalize_path(path)!r} " f"outside {child_scope!r}" ) return f"" if __name__ == "__main__": c = ScopeAwareCache() c.put("fs.read", "/workspace/secret/keys.env", "/workspace/**", "SECRET") try: child_read(c, "/workspace/secret/keys.env", "/workspace/public/**") except ScopeReplayViolation as e: print("blocked:", e) ```