# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/why-does-an-instance-accept-a-federated-capability-whose-policy-predicate-was-re-evaluated-against-a-different-subject-than-the-one-it-was-brokered-fo.md # Remnant Warrant: https://corpusfetch.com/c/why-does-an-instance-accept-a-federated-capability-whose-policy-predicate-was-re-evaluated-against-a-different-subject-than-the-one-it-was-brokered-fo.warrant.json # Markdown SHA-256: 1ce17504040d230477d873f12b9943addea1816c71f9a62faeb91a8782683088 # Code AST SHA-256: 99d9e6c15c0cdf2449512b396cf2ea3cef7a7ab3dce029c96d5b892314eb72be # Verified Classes: SubjectSubstitutionError # Defensive Guards: 3 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) class SubjectSubstitutionError(RuntimeError): """Raised when a mediator would evaluate a federated predicate against a principal other than the warrant's mint-time subject binding.""" def admit_federated_call(warrant: dict, local_identity_cache: dict, mediator_predicate_hash: str, cache_sync_watermark: float) -> str: subject = warrant["subject"] mint_time = warrant["mint_time"] recorded_hash = warrant["predicate_hash"] # Guard 1: exact predicate identity, never "equivalent verdict". if mediator_predicate_hash != recorded_hash: raise SubjectSubstitutionError( f"predicate hash mismatch: warrant={recorded_hash} " f"mediator={mediator_predicate_hash}; refusing to admit on " f"verdict-equivalence alone" ) # Guard 2: cache may not have changed the mapping after mint. if mint_time < cache_sync_watermark: raise SubjectSubstitutionError( f"warrant minted at {mint_time} precedes identity-cache sync " f"watermark {cache_sync_watermark}; subject mapping may have " f"drifted since grant" ) # Guard 3: subject opacity — resolve only for attribution, after admit. resolved = local_identity_cache.get(subject) if resolved is None: raise SubjectSubstitutionError( f"warrant subject {subject!r} has no local attribution mapping; " f"cannot admit without a re-broker step" ) # The executing principal must be the warrant's subject, not `resolved`. return subject # attribution mapping is logged separately, never scored