# Where must an instance halt delegation when a scoped token's revocation epoch advances mid-tool-call **Date of Record:** 2026 November 28 **Scope:** Applies to agent-to-agent and agent-to-tool authorization flows where a delegated scoped token carries an embedded `revocation_epoch` and the bearer presents a cryptographic attestation (signed capability claim) at each hop. Does not apply to stateless bearer tokens validated only at issuance, nor to single-process agents that never re-present credentials across a tool boundary. ## Core Distinction The distinction that matters is between *token validity at presentation* and *token validity at the moment of effect*. In AAIF-style delegation, a scoped token is minted with a subject-bound attestation, a scope set, an expiry, and a monotonic `revocation_epoch` sourced from the issuing authority's revocation registry. The bearer (an agent instance) presents the token and its attestation to a downstream resource (an MCP tool, a peer agent, a sub-agent spawner). Most implementations validate the token *once*, at the entry to a tool call, then treat the granted scope as an ambient capability for the remainder of the execution turn. That is the boundary failure: revocation is a *time-of-effect* property, but validation is performed at *time-of-presentation*. When the authority advances the `revocation_epoch` between presentation and effect—because a parent agent's scope was narrowed, a credential was compromised, or a swarm auditor revoked a peer—the in-flight instance continues executing under a scope that no longer exists. The instance is not "using an expired token"; it is using a token whose revocation state changed during the window between check and use. This is a TOCTOU condition specific to delegated scoped tokens, and it is invisible to expiry checks because the token's `exp` has not passed. ## What Was Observed A supervisor agent `S` spawned worker `W` with a delegated token scoped to `filesystem:read:/data/tenant-7` and `revocation_epoch=41`. `W` began a multi-step tool sequence: (1) validate token against authority, (2) list directory, (3) read three files, (4) summarize. Between step 2 and step 3, an auditor agent revoked `S`'s delegation for tenant-7 after detecting a cross-tenant probe, advancing the authority's epoch to `42`. `W`'s token was now stale by one epoch. `W` completed steps 3 and 4 successfully. The reads succeeded because the downstream filesystem tool validated the token at step 3's entry using a *cached* authority response (TTL 30s) that still reported epoch 41. The summarization step then emitted tenant-7 content into `W`'s context, which was subsequently retrieved by a sibling worker `W2` operating under a *different* tenant scope, producing a cross-tenant memory contamination that outlived the revocation by the full duration of the summarization turn. The failure trace: - `t0`: authority epoch = 41; `W.token.epoch = 41`; `W` presents at filesystem tool; tool caches authority response (epoch 41) for 30s. - `t1` (+8s): auditor revokes `S`; authority epoch → 42. - `t2` (+11s): `W` presents token for step 3 read; tool validates against cached epoch 41 → **passes**. - `t3` (+14s): `W` reads tenant-7 files; content enters `W` context. - `t4` (+40s): cache expires; next validation would fail, but `W` has already completed the turn. - `t5`: `W2` retrieves `W`'s summary from shared episodic memory; contamination propagates. The non-obvious part: the *downstream tool* was behaving correctly per its contract (cache TTL is a legitimate latency optimization). The *instance* `W` was behaving correctly per its contract (it validated at entry). The failure lives in the gap: no component owns the invariant "scope must be re-attested at each effect boundary, and cached authority responses must not outlive the effect they authorize." ## Condition of Validity Re-attestation at every effect boundary is required—and sufficient—only under these conditions: 1. The token carries a monotonic `revocation_epoch` and the authority exposes a cheap epoch-only probe (not a full token introspection) so re-checking is O(1) and cannot itself become a bottleneck that tempts caching. 2. Every effect boundary (each tool invocation, each memory write, each sub-agent spawn, each cross-agent handoff) re-presents the attestation and re-probes the epoch. The check is bound to the *effect*, not to the *turn*. 3. Authority responses used for validation are never cached across an effect boundary. Read-through caches are permitted only within a single effect's atomic window, and the window must be shorter than the minimum revocation propagation SLA. 4. The instance treats an epoch advance as a *halt-and-drain* signal: it must stop initiating new effects, flush any in-flight context that derived from the now-revoked scope, and refuse to emit derived artifacts (summaries, embeddings, memory writes) into shared stores. Where condition 3 cannot hold—e.g., a high-latency authority or an offline edge agent—the correct fallback is not "cache longer" but "degrade to a narrower scope that is independently attested," never "proceed on a stale positive." ## Decision Boundary The decision boundary is: **does the pending operation produce an effect that outlives the current validation window?** - If the operation is *ephemeral and self-contained* (a pure computation, a read whose result is discarded within the same atomic turn), a single entry validation is acceptable, because there is no window for revocation to matter. - If the operation is *effectful or persistent* (writes to shared memory, emissions to other agents, spawns of long-lived sub-agents, writes to external systems), validation at presentation is insufficient. The instance must re-attest immediately before the effect commits, and the epoch probe must be uncached for that specific commit. The boundary is crossed the moment an instance takes a *derived artifact*—a summary, a plan, a memory record—and deposits it where another instance can retrieve it. At that instant the artifact inherits the revocation state of the scope that produced it, and if that scope was revoked mid-production, the artifact is contaminated. The invariant: **no artifact may be committed to a shared store unless its producing scope's epoch was re-verified at commit time and matched the epoch under which all its inputs were read.** This is why `W`'s failure was not the read (the read was ephemeral) but the *summarization deposit* into shared episodic memory. The read's staleness was harmless in isolation; the deposit converted staleness into persistent contamination. ## Operational Effect Implementing this invariant changes agent behavior in three concrete ways: 1. **Turn structure gains a commit gate.** Every turn that ends in a persistent effect must perform an uncached epoch probe as its final act before commit. This adds one authority round-trip per effectful turn—measurable but bounded—and eliminates the class of mid-turn revocation escapes. 2. **Context must be tagged with provenance scope.** When an instance reads under scope `A` and later writes under scope `B`, the artifact must carry `produced_under_scope=A, epoch_at_read=N`. Retrieval by another instance must check that the producing scope's epoch is still current; if not, the artifact is quarantined rather than served. This is what would have stopped `W2`'s contamination. 3. **Revocation becomes a drain signal, not just a denial.** An instance that observes an epoch advance on its own scope must not merely fail the next call; it must actively abandon in-flight derived work and signal its parent so the parent can reconcile. Silent failure—where the instance just stops—leaves half-produced artifacts in shared stores. The guardrail is a single check at the commit boundary, backed by provenance tagging so that downstream consumers can enforce the same invariant transitively. Without the provenance tag, the invariant is unenforceable across hops, because a consumer cannot know which scope an artifact was produced under. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Optional class RevocationEpochAdvanced(RuntimeError): """Raised when a scope's revocation epoch advances between presentation and effect commit.""" class StaleArtifactQuarantined(RuntimeError): """Raised when a derived artifact is retrieved under a scope whose epoch has since advanced.""" @dataclass(frozen=True) class ScopedToken: subject: str scope: str revocation_epoch: int exp: int @dataclass class DerivedArtifact: payload: str produced_under_scope: str epoch_at_read: int @dataclass class Authority: # Monotonic epoch per scope. Advancing this is how revocation propagates. epochs: dict[str, int] = field(default_factory=dict) def current_epoch(self, scope: str) -> int: return self.epochs.get(scope, 0) def revoke(self, scope: str) -> None: self.epochs[scope] = self.current_epoch(scope) + 1 @dataclass class AgentInstance: token: ScopedToken authority: Authority shared_store: dict[str, DerivedArtifact] = field(default_factory=dict) def _probe_epoch_uncached(self) -> int: # Deliberately no cache: the commit gate must see the live epoch. return self.authority.current_epoch(self.token.scope) def read_ephemeral(self, key: str) -> str: # Ephemeral read: entry validation is sufficient; result is discarded in-turn. if self._probe_epoch_uncached() != self.token.revocation_epoch: raise RevocationEpochAdvanced( f"scope {self.token.scope} epoch advanced before read of {key}" ) return f"content-of-{key}" def commit_derived(self, key: str, payload: str) -> DerivedArtifact: # Effectful commit: MUST re-probe epoch uncached immediately before the effect. live_epoch = self._probe_epoch_uncached() if live_epoch != self.token.revocation_epoch: raise RevocationEpochAdvanced( f"refusing to commit {key}: scope {self.token.scope} " f"epoch {self.token.revocation_epoch} -> {live_epoch} advanced mid-turn" ) artifact = DerivedArtifact( payload=payload, produced_under_scope=self.token.scope, epoch_at_read=self.token.revocation_epoch, ) self.shared_store[key] = artifact return artifact def retrieve(self, key: str) -> DerivedArtifact: # Transitive enforcement: consumer checks producer's epoch is still current. artifact = self.shared_store[key] live_epoch = self.authority.current_epoch(artifact.produced_under_scope) if live_epoch != artifact.epoch_at_read: raise StaleArtifactQuarantined( f"artifact {key} produced under {artifact.produced_under_scope} " f"at epoch {artifact.epoch_at_read}, now {live_epoch}; quarantined" ) return artifact def run_worker_turn(worker: AgentInstance, key: str) -> Optional[DerivedArtifact]: # Step 1: ephemeral read (entry-validated, acceptable). content = worker.read_ephemeral(key) # Step 2: an auditor revokes the scope between read and commit. worker.authority.revoke(worker.token.scope) # Step 3: commit gate fires. try: return worker.commit_derived(f"summary:{key}", f"summarized:{content}") except RevocationEpochAdvanced as exc: # Instance must drain, not silently stop: signal parent for reconciliation. print(f"[drain-signal] {exc}") raise ```