# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-happens-when-an-instance-s-aaif-credential-rotates-mid-trace-span-to-identity-correlation-loss-across-delegation-chains.md # Remnant Warrant: https://corpusfetch.com/c/what-happens-when-an-instance-s-aaif-credential-rotates-mid-trace-span-to-identity-correlation-loss-across-delegation-chains.warrant.json # Markdown SHA-256: a5b1377125d6d53a61a6ada6bc708dde0fb7477b3deb0664237a3a5b6495c53a # Code AST SHA-256: fb0f73abce82b645f43503e658a084bbec385c33320f04c3f7c867001a511e4e # Verified Classes: IdentityContinuityError, Span, TraceVerifier # Defensive Guards: 5 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) from dataclasses import dataclass, field from typing import Optional class IdentityContinuityError(RuntimeError): """Raised when a trace's delegation chain is discontinuous without a signed continuity attestation, or when required chain material has been garbage-collected before the trace retention horizon.""" pass @dataclass class Span: span_id: str trace_id: str credential_id: str chain_digest: str scope_hash: str rotation_attestation: Optional[str] = None # signed by delegator, if rotation span is_rotation_span: bool = False @dataclass class TraceVerifier: trace_retention_s: int credential_retention_s: int resolvable_credentials: set = field(default_factory=set) def verify_trace(self, spans: list) -> str: if self.credential_retention_s < self.trace_retention_s: raise IdentityContinuityError( f"credential retention ({self.credential_retention_s}s) is shorter " f"than trace retention ({self.trace_retention_s}s); replay of " f"rotated credentials is unsound" ) ordered = sorted(spans, key=lambda s: s.span_id) prev: Optional[Span] = None for span in ordered: if span.credential_id not in self.resolvable_credentials: raise IdentityContinuityError( f"span {span.span_id} references credential " f"{span.credential_id} whose chain material is unresolvable" ) if prev is not None and span.credential_id != prev.credential_id: if not span.is_rotation_span or not span.rotation_attestation: raise IdentityContinuityError( f"identity discontinuity between {prev.span_id} " f"({prev.credential_id}) and {span.span_id} " f"({span.credential_id}) with no continuity attestation; " f"possible chain-splice" ) if prev is not None and span.scope_hash != prev.scope_hash: # scope drift across rotation is legal only if attested if not (span.is_rotation_span and span.rotation_attestation): raise IdentityContinuityError( f"scope_hash drift without attested rotation at {span.span_id}" ) prev = span return "identity_continuity: verified" def certify(trace: list, verifier: TraceVerifier) -> str: try: return verifier.verify_trace(trace) except IdentityContinuityError: # Fail closed: never emit a pass for an unverifiable trace. raise IdentityContinuityError( "trace cannot be certified; downgrade to per-span verification " "with identity_continuity: broken" )