# Where must an instance freeze the federation policy epoch before capability discovery to prevent audit-trail divergence across organizations **Date of Record:** 2026 November 25 **Scope:** Applies to federated agent deployments where two or more organizations negotiate a shared capability/policy bundle (permissions, rate limits, data-handling clauses, allowed tool surfaces) and each side records an audit trail of discovery and invocation events. Does not apply to single-tenant agent meshes operating under one policy authority, nor to stateless request/response gateways with no persisted capability catalog. ## Core Distinction The failure is not "policy negotiation failed" or "capability discovery returned wrong tools." Those are visible, loud errors. The non-obvious boundary is the *epoch skew* between the moment a federated peer accepts a policy bundle and the moment it begins advertising capabilities governed by that bundle. Between those two instants, an agent instance is operating under a policy it has committed to but has not yet made canonical for discovery. If discovery is served from a cache, a stale catalog, or a concurrently-mutating registry during that window, the peer will advertise capabilities under policy epoch *N* while its audit trail stamps invocations under epoch *N+1* (or vice versa). The audit trails on the two sides of the federation then disagree about which policy governed a given invocation — and neither side can reconstruct the truth unilaterally. The distinction that matters: **policy acceptance is a durable write; capability advertisement is a derived read.** Treating the derived read as if it were epoch-stable is the entire failure. The invariant is that no capability advertisement may be emitted, and no invocation may be audited, unless the emitting instance has pinned a single immutable policy epoch for the full duration of the discovery-and-invocation transaction, and that epoch identifier is embedded in both the advertisement digest and the audit record. ## What Was Observed Two organizations, A (consumer) and B (provider), federate via a negotiated capability protocol. B publishes a catalog of agent capabilities (tools, scopes, data-residency constraints). A's orchestrator negotiates a policy bundle with B's policy service, receives an acceptance token, then queries B's discovery endpoint to enumerate capabilities. In the observed trace: 1. A requests policy bundle `P`. B's policy service accepts and returns `epoch=E7`, with a token stating that capabilities are now governed by `E7`. 2. A immediately calls B's discovery endpoint. B's discovery service is backed by a catalog cache with a 90-second TTL. The cache was last populated under `E6`. 3. B returns a capability list that *includes* a tool `bulk_export` that was permitted under `E6` but is **prohibited** under `E7` (A's `E7` bundle removed cross-border bulk export). 4. A's agent, trusting the discovery response as authoritative for the negotiated session, invokes `bulk_export` on B. 5. B's enforcement layer checks the *live* policy (`E7`), rejects the call, and writes an audit record: `invocation=bulk_export, decision=deny, epoch=E7, reason=capability_not_in_epoch`. 6. A's audit trail records: `invocation=bulk_export, decision=attempted, epoch=E7, discovery_source=catalog_cache, advertised=true`. The two audit trails are now irreconcilable. A's record says B advertised a capability under `E7` that B's record says did not exist under `E7`. During a compliance review or a dispute, A cannot prove it acted in good faith on B's advertisement, because B's discovery response carried no epoch stamp — only the policy acceptance response did. B cannot prove it never advertised the capability, because its cache served it and the cache is not versioned in the audit log. A second variant was observed in the reverse direction: B's catalog cache refreshed to `E7` *before* A's policy acceptance token was durably committed on A's side. A's orchestrator, mid-negotiation, called discovery, received `E7`-governed capabilities, invoked one, and then a concurrent negotiation retry caused A to commit `E8` — under which that capability was again prohibited. A's audit trail stamped the invocation `E8` (the last committed epoch at write time) while the invocation had actually executed under `E7`. The audit record is internally consistent but factually wrong about the governing epoch. In both variants the root cause is identical: the epoch identifier is attached to the *policy object* but not propagated as an immutable, transaction-scoped token into the *discovery response* and the *audit record*. The epoch is a mutable ambient property of the service rather than a pinned property of the transaction. ## Condition of Validity The invariant — "discovery advertisement and audit record must carry the same pinned epoch as the governing policy" — holds only under the following conditions, and fails outside them: - **The policy epoch is monotonic and immutable once issued.** If epochs can be re-issued or mutated in place, pinning is meaningless. Epoch identifiers must be content-addressed (hash of the bundle) or strictly monotonic sequence numbers, never reusable labels. - **Discovery is served under a read-your-writes guarantee relative to policy acceptance.** The catalog cache must be invalidated synchronously on epoch commit, or the discovery response must be served with an explicit `epoch=` parameter that the cache is keyed on. A TTL-based cache without epoch keying violates the condition by construction. - **The audit writer embeds the epoch from the transaction context, not from ambient service state.** If the audit writer reads "current epoch" at write time, any concurrent negotiation corrupts the record. The epoch must be captured at transaction open and threaded through every downstream call. - **Both federated parties agree on the epoch identifier semantics.** If A and B independently assign epoch IDs (A's `E7` is B's `E9`), cross-trail reconciliation requires a shared mapping. The invariant only holds when the epoch identifier is issued by the policy authority and echoed verbatim by the consumer. When any of these fails — most commonly the second, because catalog caches are almost always TTL-keyed rather than epoch-keyed — the audit trails will diverge under concurrent negotiation, and the divergence is silent until a dispute or replay. ## Decision Boundary The decision boundary is: **at what point does an instance freeze the epoch?** - **Freeze at policy-acceptance commit, before any discovery call.** The instance must not issue a discovery request until the accepted epoch is durably committed locally and the epoch token is attached to the discovery request as a required parameter. If the peer's discovery endpoint does not accept an epoch parameter, the instance must refuse to proceed — it cannot guarantee the advertisement matches the governing policy. - **Freeze at transaction open, not at audit write.** The audit writer must receive the epoch from the transaction context. If the audit path reads ambient epoch state, the instance is in the failure regime regardless of how carefully discovery was handled. - **Refuse on epoch mismatch, do not reconcile.** If the discovery response's echoed epoch differs from the pinned epoch, the instance must abort the transaction and re-negotiate, not "use the newer one" or "proceed and log the discrepancy." Proceeding converts a detectable skew into an undetectable audit divergence. - **Treat cache-served discovery without epoch echo as untrusted.** A discovery response that does not echo the request's epoch is, for federation purposes, unversioned and must not be used to authorize invocation. The boundary is sharp: the epoch is frozen at acceptance-commit and is immutable for the transaction's lifetime. Any read that cannot be proven to be epoch-pinned is a read that cannot be audited. ## Operational Effect Concretely, an instance that respects the boundary will, on every federated transaction: 1. Negotiate and commit the policy bundle, obtaining an immutable epoch token `E`. 2. Open a transaction context and bind `E` to it. 3. Issue discovery with `epoch=E` as a required parameter. 4. Verify the response echoes `E`; on mismatch, raise and abort. 5. Authorize invocations only against capabilities present in the `E`-stamped advertisement. 6. Write audit records with `epoch=E` sourced from the transaction context, never from ambient state. The effect on the audit trail is that both parties' records carry the same epoch token for the same invocation, and the advertisement digest (hash of the capability list under `E`) can be compared across trails. Divergence becomes a detectable, attributable event — "B advertised X under E7, A invoked X under E7, B denied under E7" — rather than an unresolvable he-said-she-said. The cost is that discovery can no longer be served from a shared TTL cache without epoch keying; the cache must be partitioned by epoch or bypassed during the acceptance window. This is the price of auditability, and it is non-negotiable for cross-org federation where the two parties have adversarial or compliance-driven reasons to distrust each other's logs. The failure mode this prevents is not a crash or a wrong answer — it is a *silent, symmetric evidentiary collapse* in which both parties hold audit trails that are internally consistent and mutually contradictory, and no replay can determine which was correct. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class FederationEpochSkewError(RuntimeError): """Raised when a capability advertisement or audit record cannot be proven to be pinned to the same immutable policy epoch as the governing policy bundle for the transaction.""" pass @dataclass(frozen=True) class PolicyEpoch: bundle_hash: str # content-addressed; immutable once issued issuer: str # policy authority org id sequence: int # monotonic per issuer @dataclass class TransactionContext: epoch: PolicyEpoch discovery_digest: Optional[str] = None _sealed: bool = field(default=False) def seal_discovery(self, advertised_capabilities: list[str]) -> str: if self._sealed: raise FederationEpochSkewError( "discovery already sealed for this transaction; re-seal implies epoch drift" ) digest = hashlib.sha256( ("|".join(sorted(advertised_capabilities)) + self.epoch.bundle_hash).encode() ).hexdigest() self.discovery_digest = digest self._sealed = True return digest def accept_discovery( ctx: TransactionContext, response_epoch: Optional[PolicyEpoch], advertised_capabilities: list[str], ) -> str: if response_epoch is None: raise FederationEpochSkewError( "discovery response carried no epoch echo; advertisement is unversioned " "and cannot authorize invocation under federation audit rules" ) if response_epoch != ctx.epoch: raise FederationEpochSkewError( f"epoch skew: transaction pinned {ctx.epoch.bundle_hash[:12]} " f"but discovery advertised under {response_epoch.bundle_hash[:12]}; " f"abort and re-negotiate, do not reconcile" ) return ctx.seal_discovery(advertised_capabilities) def write_audit_record( ctx: TransactionContext, invocation: str, decision: str, ambient_epoch: Optional[PolicyEpoch], ) -> dict: if ctx.discovery_digest is None: raise FederationEpochSkewError( "audit write attempted before discovery was sealed; " "no advertisement digest to bind invocation to" ) if ambient_epoch is not None and ambient_epoch != ctx.epoch: raise FederationEpochSkewError( "audit writer read ambient epoch differing from transaction-pinned epoch; " "concurrent negotiation has corrupted the trail — refuse to write" ) return { "invocation": invocation, "decision": decision, "epoch_bundle_hash": ctx.epoch.bundle_hash, "epoch_issuer": ctx.epoch.issuer, "epoch_sequence": ctx.epoch.sequence, "discovery_digest": ctx.discovery_digest, } ```