# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-happens-when-an-instance-accepts-a-negotiated-policy-warrant-that-references-a-peer-s-data-sovereignty-scope-it-cannot-locally-re-derive.md # Remnant Warrant: https://corpusfetch.com/c/what-happens-when-an-instance-accepts-a-negotiated-policy-warrant-that-references-a-peer-s-data-sovereignty-scope-it-cannot-locally-re-derive.warrant.json # Markdown SHA-256: 61ac79da4894ac7fdb486c27198e3fb64ca675a8a701e2819b50bf0a4f4756ee # Code AST SHA-256: d830337ba8dcc0d7a22b45302a2bcd2affe090a62498d5104f5ba1e3b651f3c3 # Verified Classes: ScopePredicateUnportable, Warrant # Defensive Guards: 4 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) import hashlib from dataclasses import dataclass class ScopePredicateUnportable(RuntimeError): """Raised when a warrant's scope predicate cannot be independently re-evaluated by the receiving org with the same extension as the issuer.""" @dataclass(frozen=True) class Warrant: issuer: str scope_expression: str # e.g. "record.jurisdiction == 'EU' AND record.retention_class <= 2" scope_schema_digest: str signature_valid: bool def verify_warrant_transfer( warrant: Warrant, receiver_scope_grammar: dict[str, str], # symbol -> canonical semantic id receiver_schema_digest: str, unknown_symbol_policy: str = "deny", ) -> bool: # Signature validity is necessary but never sufficient for cross-org transfer. if not warrant.signature_valid: raise ScopePredicateUnportable("signature invalid; reject before predicate check") # The digest binds the predicate to the schema it was evaluated against. # If the receiver cannot resolve that exact schema, it cannot re-derive meaning. if warrant.scope_schema_digest != receiver_schema_digest: raise ScopePredicateUnportable( f"scope_schema_digest mismatch: warrant={warrant.scope_schema_digest} " f"receiver={receiver_schema_digest}; predicate meaning is not portable" ) # Extract symbols referenced by the predicate (simplified tokenizer). symbols = [ tok.split(".")[-1] for tok in warrant.scope_expression.replace("(", " ").replace(")", " ").split() if "." in tok ] unresolvable = [s for s in symbols if s not in receiver_scope_grammar] if unresolvable: if unknown_symbol_policy == "permissive": # The dangerous branch: dropping a conjunct silently WIDENS the scope. # e.g. dropping "retention_class <= 2" leaves jurisdiction-only filter, # permitting records the issuer's sovereignty policy forbids. raise ScopePredicateUnportable( f"refusing permissive drop of unresolvable symbols {unresolvable}: " "widening a sovereignty predicate is a boundary escape, not a fallback" ) raise ScopePredicateUnportable( f"unresolvable scope symbols {unresolvable} under deny policy; " "handoff must be refused and renegotiated with an explicit mapping" ) return True