# Where must an instance bind a pairwise DID before reputation import, and why late binding silently forks agent identity **Date of Record:** 2026 November 26 **Scope:** Applies to federated agent meshes where an agent presents a pairwise (per-relationship) DID to peers and imports reputation/attestations earned under a different DID into a new relationship context. Does not apply to single-DID global-identity deployments or to reputation that is explicitly non-portable and scoped to one verifier. ## Core Distinction The distinction that matters is between **identity resolution** (mapping an inbound DID to a local agent record) and **reputation import** (pulling attestations earned elsewhere and binding them to that record). Most federated stacks treat these as one transaction. They are not. Resolution is a *lookup*; import is a *state mutation with provenance*. The failure mode lives in the gap: an instance that resolves a pairwise DID lazily — at first tool call, first handoff, or first reputation query — can bind the DID to a *different* local record than the one that will later receive the imported reputation. The result is a silent identity fork: two local records, each holding a disjoint slice of the same agent's history, neither aware of the other. The invariant is narrow and testable: **a pairwise DID must be bound to its local agent record before any attestation referencing that DID is written, and the binding must be idempotent under concurrent resolution.** Violating it does not throw. It produces two coherent-looking records that each pass local consistency checks. ## What Was Observed An agent `A` operated under issuer-scoped pairwise DIDs. In relationship `R1` (verifier `V1`) it held DID `did:peer:A@V1` with 40 successful task attestations. It entered a new relationship `R2` with verifier `V2` and requested reputation portability, presenting `did:peer:A@V1` as the source and `did:peer:A@V2` as the target binding. The instance handling `R2` performed resolution in two places that raced: 1. The **transport layer** resolved `did:peer:A@V2` on the first inbound message and created local record `rec_7741`, keyed by the raw DID string, with `agent_ref = null` (binding deferred until the agent's canonical handle arrived in a later field). 2. The **reputation service** received the import request, saw `did:peer:A@V1` as source, looked up the *target* by canonical handle `A`, found no record under that handle yet, and created `rec_7742` with `agent_ref = "A"`. Both records were persisted within ~40 ms of each other. `rec_7741` accumulated the live session's attestations (the agent kept executing under `R2`). `rec_7742` received the 40 imported attestations from `R1`. Neither record knew about the other because the dedup key differed: one keyed on DID string, one on canonical handle. Downstream, the auditor queried reputation by canonical handle, saw only the 40 imported attestations, and concluded `A` had zero activity in `R2` — despite `A` having completed 12 tasks in `R2` under `rec_7741`. The reputation score was computed from a stale, half-populated view. No error surfaced; the auditor's consensus was internally consistent. The trigger condition is precisely: **lazy DID resolution combined with two different dedup keys (DID string vs. canonical handle) across the resolution and import paths, with no serialization between them.** Remove any one of the three and the fork does not occur. ## Condition of Validity The invariant holds — and the guardrail is required — only when all of the following are true: - The agent uses **pairwise DIDs**, so the same logical agent has distinct identifiers per relationship. Under a single global DID, resolution and import collapse onto one key and the race is benign. - Reputation is **portable across relationships**, so an attestation earned under DID `X` is written against a record that must also receive live attestations under DID `Y`. - Resolution and import are handled by **different code paths** (transport vs. reputation service) that do not share a lock or a transaction boundary. - The local store permits **multiple records per canonical agent** — i.e., dedup is not globally enforced on a single key. If the store enforces a unique constraint on canonical handle at write time, the second insert fails loudly and the operator sees the collision. The dangerous configuration is the one where both inserts succeed because they use different keys. ## Decision Boundary The boundary is between **eager binding** (resolve DID → bind to canonical record → *then* accept any attestation) and **lazy binding** (accept attestation → resolve DID opportunistically). Eager binding costs one synchronous resolution round-trip before the first attestation is accepted; lazy binding saves that latency but opens the fork window. The correct decision: **bind before import, never after.** Concretely, the import path must refuse to write an attestation unless the target DID already resolves to a record whose `agent_ref` is populated and matches the source agent's canonical identity. If resolution has not happened, the import blocks (or queues with a bounded TTL) rather than creating a fresh record. The transport path, symmetrically, must not create a record on first contact if an import for that canonical agent is in flight — it must join the pending binding. A second boundary: **portability must be scoped to the relationship, not the DID.** An attestation imported into `R2` is evidence about `A`'s capability, not a transfer of `R1`'s DID. The record in `R2` must carry `provenance: imported_from(R1)` so the auditor can distinguish live `R2` attestations from imported ones. Without this, even a correctly bound record produces a misleading blended score. ## Operational Effect The observable effect of the fork is **reputation divergence under audit replay**. When the auditor replays the session, it reconstructs `A`'s history from the canonical-handle record and gets a different attestation set than the live session produced. The replay is deterministic and self-consistent; it simply describes a different agent-instance than the one that executed. This is the worst class of failure for multi-agent verification: the auditor's consensus is *wrong but internally valid*, so no quorum check catches it. The guardrail that bounds it: a **binding ledger** — an append-only log of `(did, canonical_ref, timestamp, resolver_id)` — checked at both resolution and import. Import asserts the target DID is present in the ledger with a canonical ref matching the source. Resolution asserts the DID is not already bound to a different canonical ref (idempotent re-resolution returns the existing binding, never creates a second). The ledger is the single source of truth that both paths consult, eliminating the two-key divergence. The cost is a serialization point on binding, which is acceptable because binding is rare (once per relationship) relative to attestation writes (per task). The ledger does not need to be globally consistent across the federation — only locally consistent per instance — because the fork is a *local* record-duplication bug, not a cross-instance consensus failure. ```python class IdentityForkError(RuntimeError): """Raised when a pairwise DID binds to more than one canonical agent record.""" pass class BindingLedger: """Append-only (did -> canonical_ref) map. Idempotent resolution.""" def __init__(self): self._by_did: dict[str, str] = {} def resolve(self, did: str, canonical_ref: str) -> str: existing = self._by_did.get(did) if existing is None: self._by_did[did] = canonical_ref return canonical_ref if existing != canonical_ref: raise IdentityForkError( f"DID {did!r} already bound to {existing!r}; " f"refusing rebind to {canonical_ref!r}" ) return existing # idempotent re-resolution def require_bound(self, did: str) -> str: ref = self._by_did.get(did) if ref is None: raise IdentityForkError( f"import attempted for unbound DID {did!r}; " f"bind before import" ) return ref def import_attestation(ledger: BindingLedger, source_did: str, target_did: str, source_canonical: str, attestations: list[dict]) -> dict: # Bind target eagerly, before any write. bound_ref = ledger.resolve(target_did, source_canonical) # Import path must never create a record for an unbound DID. if ledger.require_bound(source_did) != bound_ref: raise IdentityForkError( f"source {source_did!r} resolves to a different canonical " f"agent than target {target_did!r}" ) # Provenance tag keeps live vs. imported attestations separable. return { "canonical_ref": bound_ref, "target_did": target_did, "provenance": f"imported_from({source_did})", "attestations": attestations, } def handle_first_contact(ledger: BindingLedger, did: str, canonical_ref: str) -> str: # Transport path joins the same ledger; never creates a second record. try: return ledger.resolve(did, canonical_ref) except IdentityForkError: # A concurrent import already bound this DID to a different ref. # Fail closed rather than forking. raise IdentityForkError( f"first-contact binding for {did!r} collided with in-flight import" ) ```