# What happens when an instance replays an attenuated capability token across a delegation chain and the provenance receipt diverges from the live warrant **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent systems where a delegating agent (A) mints a scoped capability token plus a provenance receipt for a sub-agent (B), and B may itself delegate to C, with each hop attenuating scope. Does not cover single-hop RPC where the caller and callee share a trust domain and no receipt is issued. ## Core Distinction There are two artifacts on every delegation hop, and they are not the same thing: 1. **The capability token** — a signed, attenuable grant of *what B may do*. It is a bearer object; its authority is defined by its cryptographic signature chain and its scope intersection across hops. 2. **The provenance receipt** — a signed, append-only record of *what A attests it delegated and why*. It is a claim about intent and lineage, not a grant of authority. The failure mode this record covers is the **receipt/warrant divergence**: the token that B (or C) actually holds and presents at execution time is *not* the token whose hash is committed in the provenance receipt that travels with the request. This happens legitimately all the time — attenuation, re-signing, scope narrowing, expiry refresh, and re-binding to a new audience each mutate the token — and the receipt is supposed to be re-issued or co-signed at each hop to track it. When a hop forgets, the two artifacts drift apart. The system then has two contradictory truths: the receipt says "A granted scope S to B," and the token says "B (or C) holds scope S′ ⊂ S." Neither is wrong in isolation. The invariant that breaks is that *no single verifier can decide, from the receipt alone, whether S′ was a lawful attenuation of S or an escalation smuggled in by a compromised intermediate.* This is non-obvious because both artifacts verify cleanly. The token's signature chain is valid. The receipt's signature chain is valid. The divergence is only visible if you cross-check the token hash embedded in the receipt against the token actually presented — and most verifiers check one or the other, never both against each other. ## What Was Observed A three-hop chain: orchestrator A → planner B → executor C. A mints a token T_A scoped to `{read:repo, write:branch/feature-x}` and a receipt R_A committing `sha256(T_A)` and the scope set. B receives T_A, attenuates to T_B scoped to `{read:repo, write:branch/feature-x, write:branch/feature-x/**}` (a legitimate narrowing to a sub-path), re-signs, and forwards T_B to C. B updates R_A's scope field to record the narrowing but — because its receipt-signing path uses a cached template — does **not** update the committed `sha256(T_A)` field; it still carries the hash of T_A, not T_B. C executes. C's verifier does the two checks it was built to do: (a) the token signature chain T_A→T_B validates against A's and B's public keys; (b) the receipt R_A's signature validates against A's key. Both pass. C proceeds. The problem surfaces later, during a post-hoc audit replay. The auditor reconstructs the chain from receipts and expects to find T_B's hash inside R_A (since R_A's scope field now claims the narrowed scope). It finds T_A's hash instead. The auditor cannot distinguish between: - **Benign case:** B attenuated lawfully and failed to re-commit the hash (a bookkeeping bug). - **Adversarial case:** B presented T_B to C but committed T_A to the receipt to hide that it had *widened* scope somewhere the audit can't see, or to launder a token it obtained out-of-band. Because both produce the identical divergence signature — `receipt.committed_hash ≠ presented_token.hash` — the auditor must treat them identically. In practice this means either every legitimate attenuation triggers a false-positive audit failure, or the auditor is tuned to ignore hash mismatches, at which point the receipt provides no provenance guarantee at all. The chain has silently degraded from "verifiable lineage" to "decorative lineage." A second, sharper variant: C itself delegates to D. C attenuates T_B→T_C and forwards. C *does* re-commit the hash correctly in its own receipt R_C, but R_C's `parent_receipt` pointer references R_A by ID, and R_A's committed hash is stale. D's verifier walks the receipt chain R_C→R_A, recomputes the expected token at each level, and finds the chain broken at the A→B boundary. D rejects. The rejection is *correct* but the blame is misattributed to C, which did everything right. The failure is two hops upstream, invisible at the point of detection, and the error message says "invalid provenance at hop 2" when the actual defect is at hop 1. ## Condition of Validity The provenance receipt is a valid warrant for a presented token **iff** all of the following hold simultaneously at verification time: 1. `receipt.committed_token_hash == sha256(presented_token.canonical_bytes)`, where canonicalization is fixed and versioned (see below). 2. `presented_token.scope ⊆ receipt.declared_scope` — the token may be narrower than the receipt claims, never wider. Attenuation is one-directional. 3. `receipt.parent_receipt` either is null (root) or resolves to a receipt whose own conditions 1–3 hold recursively, with the parent's committed hash matching the *pre-attenuation* token that the child's receipt records as its input. 4. The receipt's signature covers the committed hash field (i.e., the hash is inside the signed envelope, not appended after signing). Condition 4 is the one that fails silently. If the hash is a post-signature annotation, an intermediate can mutate it without invalidating the signature, and the entire divergence-detection mechanism is defeated. This was the actual root cause in the observed incident: the receipt schema placed `committed_token_hash` in an unsigned `metadata` block, so B's cached-template bug was not a *signature* failure but a *semantic* one, and no signature check could ever have caught it. Canonicalization is the second trap. `sha256(presented_token.canonical_bytes)` requires both sides to agree on field ordering, whitespace, and optional-field omission. If A serializes the token with an absent `expiry` field and B re-serializes it with `expiry: null`, the hashes differ despite semantic identity, and you get a *false* divergence — the mirror image of the real failure. The canonicalization scheme must be pinned in the receipt itself (`receipt.canon_scheme = "jcs-rfc8785-v1"`) and enforced. ## Decision Boundary The verifier must make an explicit, recorded choice at the divergence point, and the choice must be the same across all verifiers in the chain or the chain is not coherent. The boundary: - **Divergence is a hard reject** when `presented_token.scope ⊄ receipt.declared_scope`. This is potential escalation; there is no benign reading. Reject and emit a `ScopeEscalation` event naming the hop. - **Divergence is a soft hold** when `presented_token.scope ⊆ receipt.declared_scope` but the hash mismatches. This is *consistent with* lawful attenuation; it requires the presenting agent to supply a re-signed receipt whose committed hash matches, or the verifier escalates to the issuing authority (A) for a fresh receipt. The hold must have a bounded TTL — an unbounded hold is a denial-of-service vector where a compromised B stalls C indefinitely. - **Divergence is never silently accepted**, even under soft hold, because acceptance converts the receipt into an unverifiable claim and destroys the audit property for all downstream hops. The critical corollary: **the decision must be made at the hop where the divergence is introduced, not deferred to the terminal executor.** In the observed incident the divergence was introduced at A→B but only detected at C→D. By then the receipt chain is already inconsistent and no verifier can localize the fault without out-of-band knowledge. Each hop must verify its *incoming* receipt against its *incoming* token before it attenuates and forwards, so that the first inconsistent hop is the one that halts. ## Operational Effect When the invariant holds, delegation chains are auditable: any executor can validate the full lineage from root authority to its own token in O(depth) signature checks plus O(depth) hash comparisons, and any divergence localizes to exactly one hop. When it breaks — as it did here — the effects compound: - **Audit replay becomes non-deterministic in blame.** The same divergence signature maps to both benign and adversarial causes, so incident response cannot distinguish a bookkeeping bug from a supply-chain compromise without manual reconstruction. - **Attenuation is disincentivized.** Agents that correctly narrow scope at every hop generate more receipt churn and more divergence surface. The path of least resistance is to *not* attenuate, forwarding the broad token unchanged so the hash never moves — which is itself a least-privilege violation that the receipt system was supposed to prevent. - **The receipt becomes advisory.** Once operators learn that hash mismatches are "usually fine," they tune verifiers to warn-and-continue, and the provenance guarantee is gone while the ceremony remains. The guardrail is structural, not procedural: commit the token hash *inside* the signed envelope, pin the canonicalization scheme in the receipt, re-sign the receipt at every attenuation hop as a single atomic operation with the token, and make each hop verify its incoming pair before forwarding. The atomicity is the load-bearing part — a token that is attenuated but whose receipt is not co-updated in the same signed operation is, by construction, a divergence waiting to be misread. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class ProvenanceDivergenceError(RuntimeError): """Raised when a presented capability token does not match the provenance receipt that is supposed to warrant it.""" pass class ScopeEscalationError(ProvenanceDivergenceError): """Raised when the presented token's scope is not a subset of the receipt's declared scope — a potential privilege escalation.""" pass @dataclass class CapabilityToken: issuer: str subject: str scope: frozenset audience: str canon_scheme: str = "jcs-rfc8785-v1" def canonical_bytes(self) -> bytes: # Pinned canonicalization: sorted keys, no whitespace, stable types. payload = { "issuer": self.issuer, "subject": self.subject, "scope": sorted(self.scope), "audience": self.audience, "canon_scheme": self.canon_scheme, } return json.dumps(payload, sort_keys=True, separators=(",", ":")).encode() def digest(self) -> str: return hashlib.sha256(self.canonical_bytes()).hexdigest() @dataclass class ProvenanceReceipt: issuer: str subject: str declared_scope: frozenset committed_token_hash: str # MUST be inside the signed envelope parent_receipt_id: Optional[str] signature: str = "" # covers committed_token_hash def signed_envelope(self) -> bytes: payload = { "issuer": self.issuer, "subject": self.subject, "declared_scope": sorted(self.declared_scope), "committed_token_hash": self.committed_token_hash, "parent_receipt_id": self.parent_receipt_id, } return json.dumps(payload, sort_keys=True, separators=(",", ":")).encode() def verify_hop( presented: CapabilityToken, receipt: ProvenanceReceipt, expected_audience: str, ) -> None: """Verify one hop of a delegation chain. Invariant enforced: - presented.scope must be a subset of receipt.declared_scope - presented.digest() must equal receipt.committed_token_hash - expected_audience must match the token's audience binding Any divergence halts the chain at THIS hop, not downstream. """ if presented.audience != expected_audience: raise ProvenanceDivergenceError( f"audience mismatch: token bound to {presented.audience!r}, " f"presented to {expected_audience!r}" ) # Escalation check first: a wider scope is never a benign divergence. wider = presented.scope - receipt.declared_scope if wider: raise ScopeEscalationError( f"scope escalation at hop issued by {receipt.issuer!r}: " f"token claims {sorted(wider)} outside declared scope " f"{sorted(receipt.declared_scope)}" ) # Hash divergence: consistent with lawful attenuation but unverifiable. actual = presented.digest() if actual != receipt.committed_token_hash: raise ProvenanceDivergenceError( f"receipt/warrant divergence at hop issued by {receipt.issuer!r}: " f"receipt commits {receipt.committed_token_hash[:12]}..., " f"presented token hashes to {actual[:12]}... " f"(scope is subset, so likely un-recommitted attenuation — " f"require re-signed receipt before forwarding)" ) def attenuate_and_recommit( parent_token: CapabilityToken, parent_receipt: ProvenanceReceipt, new_scope: frozenset, new_subject: str, new_audience: str, signer, ) -> tuple: """Atomic attenuation: narrow the token AND re-commit its hash to a fresh receipt in the same operation. This is the only safe way to forward authority across a hop.""" if not new_scope <= parent_token.scope: raise ScopeEscalationError( f"attenuation widened scope: {sorted(new_scope)} not subset of " f"{sorted(parent_token.scope)}" ) if not new_scope <= parent_receipt.declared_scope: raise ProvenanceDivergenceError( "attenuation target exceeds parent receipt's declared scope" ) child = CapabilityToken( issuer=parent_token.subject, # child issuer is the attenuator subject=new_subject, scope=new_scope, audience=new_audience, ) child_receipt = ProvenanceReceipt( issuer=parent_token.subject, subject=new_subject, declared_scope=new_scope, committed_token_hash=child.digest(), # committed in same op parent_receipt_id=f"{parent_receipt.issuer}:{parent_receipt.subject}", ) child_receipt.signature = signer(child_receipt.signed_envelope()) return child, child_receipt ```