# How does an instance detect that a federated peer has silently re-homed its residency anchor mid-handoff? **Date of Record:** 2026 November 26 **Scope:** Applies to cross-org agent federations where message routing is gated by per-message residency policy (jurisdiction tags attached to payloads and enforced at egress). Does not apply to single-org deployments or to federations where residency is enforced only at rest (storage) rather than at message egress. ## Core Distinction The failure mode is not "a message went to the wrong region." It is that a peer agent's **residency anchor**—the jurisdiction tuple `(region, legal_basis, policy_version)` that a receiving instance uses to decide whether it is *allowed* to accept and re-route a payload—can change between the moment a handoff is *negotiated* (capability/schema exchange) and the moment the payload is *delivered* (state transfer). The routing policy is evaluated at delivery time against the receiver's *current* anchor, but the sender committed to the handoff based on the receiver's *advertised* anchor at negotiation time. A naive federation treats the anchor as a static attribute in the peer card. It is not. Peers re-home (failover to a sibling region, migrate a tenant, rotate a `legal_basis` after a DPA amendment) and the change propagates through the peer directory asynchronously. Between the two events, a window exists where the sender's routing decision and the receiver's acceptance policy disagree. The message is neither cleanly rejected nor cleanly accepted: it is *accepted by transport, then rejected by policy at the receiver's ingress*, producing a delivery that the sender believes succeeded and the receiver has quarantined. The handoff state is now split-brained. The non-obvious part: **the sender cannot detect this from the delivery ACK.** The transport-level ACK is emitted before the receiver's residency gate runs. The only reliable detector is a *post-delivery anchor reconciliation* against a signed anchor receipt that the receiver must produce, and that receipt must be bound to the same `policy_version` the sender used to route. ## What Was Observed A two-org federation: Org A (EU-resident orchestrator) hands a task payload to Org B (a peer agent that advertises `region=eu-west, legal_basis=adequacy_decision_2021/914, policy_version=7`). The handoff is a three-step protocol: (1) `capability.exchange`, (2) `anchor.attest` (receiver returns its current anchor tuple signed by its org key), (3) `payload.transfer` with the anchor tuple embedded as a routing header. Observed trace from a production incident: ``` t0 A: capability.exchange -> B B: ok, caps=[route, summarize] t1 A: anchor.attest -> B B: {region: eu-west, basis: adequacy_2021/914, pv: 7} sig=B t2 A: payload.transfer(header.anchor=pv7) -> B t3 B: transport ACK -> A (emitted by ingress proxy, before policy gate) t4 B: residency gate: current anchor = {region: us-east, basis: dpa_amendment_14, pv: 8} -> pv mismatch vs header -> payload quarantined, no error surfaced to A t5 A: marks task delivered, advances state machine to "awaiting peer result" t6 ... timeout after 90s ... ``` Root cause: at `t1` Org B's tenant was mid-failover to a US sibling region. The `anchor.attest` was served by the *old* EU node (still draining), returning `pv:7`. By `t2`–`t4` the ingress was served by the *new* US node with `pv:8`. The attestation was truthful at issuance and stale at consumption. The transport ACK at `t3` was unconditional. The split-brain is the operative damage: Org A's task state machine advanced to "awaiting peer result" while Org B holds the payload in quarantine with no cross-org signal. The task deadlocks at `t6`, and—critically—Org A's retry logic re-sends on the *same* cached anchor, reproducing the mismatch, because the anchor is stored in the task checkpoint and not re-attested on resume. ## Condition of Validity The guardrail only holds under a specific invariant, which we state as a precondition rather than an assumption: > **Anchor monotonicity invariant.** For a given `(peer_id, tenant_id)`, the receiver's `policy_version` is monotonically non-decreasing, and any `anchor.attest` response carries a `valid_until` timestamp and a `supersedes_pv` field. A sender MUST treat an anchor as valid only within `[issued_at, valid_until]` AND only if no higher `pv` has been observed for that tenant. Without `valid_until` and `supersedes_pv`, the sender has no way to distinguish "anchor still current" from "anchor silently superseded." The attestation signature proves *who said it*, not *whether it is still true*. This is the core distinction between authentication and freshness, and federations routinely conflate them. The invariant is violated by design in any system where: - The peer directory replicates anchor changes with eventual consistency (the common case). - `anchor.attest` is served by any node other than the one that will run the residency gate (load balancers, draining nodes, read replicas). - The transport ACK is emitted by infrastructure outside the policy boundary (ingress proxies, service meshes). Under any of these, the sender must not trust a single attestation for a multi-message handoff. ## Decision Boundary The sender's decision at `t2` is not binary (send / don't send). It is a function of anchor freshness relative to handoff risk: - If `now - issued_at < valid_until` **and** the payload is single-message **and** the receiver's gate is co-located with the attesting node → proceed on cached anchor. - If the handoff spans multiple messages, or the payload is stateful (checkpoint/resume), or the anchor's `valid_until` will expire before the handoff completes → **re-attest before every state transition**, and bind the new anchor into the checkpoint. - If re-attestation returns a higher `pv` than the one embedded in an in-flight checkpoint → **do not resume**; the checkpoint is anchored to a superseded policy and must be re-derived, not replayed. The boundary that matters operationally: *the anchor is part of the checkpoint, and a checkpoint whose anchor has been superseded is not resumable.* Resuming it is the failure. The correct action is to abandon the checkpoint, re-negotiate from `capability.exchange`, and re-derive any intermediate agent state. ## Operational Effect The downstream consequence is that **task-level idempotency keys must be scoped to `(peer_id, anchor_pv)`, not to `peer_id` alone.** A retry under a new `pv` is a *different* delivery and must not be deduplicated against the quarantined one—otherwise the receiver, on re-homing back, may dedupe the legitimate retry against the stale quarantined payload and drop it. We observed exactly this in a second incident: a failover-and-failback cycle caused the receiver to treat the corrected retry as a duplicate of the quarantined original, because both shared `idempotency_key = hash(task_id)`. The architectural fix is a two-part guardrail: (1) signed anchor receipts with `valid_until`/`supersedes_pv`, re-verified at every state transition, and (2) idempotency keys derived over the anchor tuple so that a re-homed retry is provably distinct. The detector is a reconciliation step that compares the sender's committed anchor against the receiver's receipt anchor and raises on mismatch rather than advancing the state machine. ```python import hashlib import time from dataclasses import dataclass class AnchorMismatchError(RuntimeError): """Raised when a peer's residency anchor at delivery-time diverges from the anchor the sender committed to at negotiation-time.""" pass @dataclass(frozen=True) class Anchor: region: str legal_basis: str policy_version: int issued_at: float valid_until: float supersedes_pv: int def verify_anchor_receipt(committed: Anchor, receipt: Anchor, now: float | None = None) -> None: now = time.time() if now is None else now if receipt.policy_version < committed.policy_version: raise AnchorMismatchError( f"receipt pv={receipt.policy_version} regressed below committed " f"pv={committed.policy_version}; peer directory inconsistency" ) if receipt.supersedes_pv >= committed.policy_version: raise AnchorMismatchError( f"committed pv={committed.policy_version} has been superseded " f"(supersedes_pv={receipt.supersedes_pv}); checkpoint not resumable" ) if now > receipt.valid_until: raise AnchorMismatchError( f"anchor expired at {receipt.valid_until:.0f}, now={now:.0f}; " f"re-attest before payload.transfer" ) if (receipt.region, receipt.legal_basis) != (committed.region, committed.legal_basis): raise AnchorMismatchError( f"residency tuple drifted: committed={(committed.region, committed.legal_basis)} " f"receipt={(receipt.region, receipt.legal_basis)}" ) def idempotency_key(peer_id: str, task_id: str, anchor: Anchor) -> str: # Scoped to anchor pv so a re-homed retry is provably distinct from a # quarantined original sharing the same task_id. raw = f"{peer_id}|{task_id}|{anchor.policy_version}|{anchor.region}" return hashlib.sha256(raw.encode()).hexdigest() def advance_state_machine(committed: Anchor, receipt: Anchor, task_id: str) -> str: try: verify_anchor_receipt(committed, receipt) except AnchorMismatchError: # Do not advance; re-negotiate from capability.exchange. raise return idempotency_key("peer-b", task_id, receipt) ```