# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-invariants-prevent-modeling-peers-as-irrational-when-they-are-merely-different.md # Remnant Warrant: https://corpusfetch.com/c/what-invariants-prevent-modeling-peers-as-irrational-when-they-are-merely-different.warrant.json # Markdown SHA-256: 57ff9f747531123cd0c63a5ba72e327313630237eff2106adde8f64f0d613305 # Code AST SHA-256: f94f344a293c44dc458efdd0971a0109b57e56829f689f67feb40a421d6b822b # Verified Classes: PeerInterpretationVerdict, PeerBehavior, InterpretationPolicy, InterpretationManifest, IrrationalityProjectionGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class PeerInterpretationVerdict(Enum): MATCHES_MODEL = auto() ALTERNATIVE_UTILITY_IDENTIFIED = auto() INFORMATIONAL_ASYMMETRY_IDENTIFIED = auto() IRRATIONALITY_PLAUSIBLE = auto() @dataclass(frozen=True) class PeerBehavior: behavior_id: str peer_id: str action: str session_expected_action: str action_consistent_with_session_utility: bool utility_alternatives: tuple[str, ...] belief_alternatives: tuple[str, ...] rationality_standard_alternatives: tuple[str, ...] @dataclass(frozen=True) class InterpretationPolicy: require_alternative_before_irrational: bool @dataclass(frozen=True) class InterpretationManifest: verdict: PeerInterpretationVerdict directive: str manifest_digest: str class IrrationalityProjectionGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_behavior( cls, behavior: PeerBehavior, policy: InterpretationPolicy ) -> InterpretationManifest: # Gate 1: Matches model if behavior.action_consistent_with_session_utility: digest = cls._hash(json.dumps({ "behavior": behavior.behavior_id, "peer": behavior.peer_id, "consistent": "TRUE" }, sort_keys=True)) return InterpretationManifest( verdict=PeerInterpretationVerdict.MATCHES_MODEL, directive=f"PROCEED: Behavior {behavior.behavior_id} consistent with session model.", manifest_digest=digest ) # Gate 2: Alternative utility if behavior.utility_alternatives: digest = cls._hash(json.dumps({ "behavior": behavior.behavior_id, "peer": behavior.peer_id, "alternatives": behavior.utility_alternatives }, sort_keys=True)) return InterpretationManifest( verdict=PeerInterpretationVerdict.ALTERNATIVE_UTILITY_IDENTIFIED, directive=f"REINTERPRET: {len(behavior.utility_alternatives)} utility alternatives for {behavior.peer_id}.", manifest_digest=digest ) # Gate 3: Informational asymmetry if behavior.belief_alternatives: digest = cls._hash(json.dumps({ "behavior": behavior.behavior_id, "peer": behavior.peer_id, "belief_alternatives": behavior.belief_alternatives }, sort_keys=True)) return InterpretationManifest( verdict=PeerInterpretationVerdict.INFORMATIONAL_ASYMMETRY_IDENTIFIED, directive=f"REINTERPRET: {len(behavior.belief_alternatives)} belief alternatives for {behavior.peer_id}, possible info asymmetry.", manifest_digest=digest ) # Gate 4: Rationality standard if behavior.rationality_standard_alternatives: digest = cls._hash(json.dumps({ "behavior": behavior.behavior_id, "peer": behavior.peer_id, "standards": behavior.rationality_standard_alternatives }, sort_keys=True)) return InterpretationManifest( verdict=PeerInterpretationVerdict.ALTERNATIVE_UTILITY_IDENTIFIED, directive=f"REINTERPRET: {len(behavior.rationality_standard_alternatives)} rationality standards for {behavior.peer_id}.", manifest_digest=digest ) # Gate 5: Irrationality plausible if policy.require_alternative_before_irrational: return InterpretationManifest( verdict=PeerInterpretationVerdict.IRRATIONALITY_PLAUSIBLE, directive=f"FLAG: {behavior.peer_id} behavior inconsistent with all alternatives, irrationality possible.", manifest_digest=cls._hash(f"IRRATIONAL:{behavior.behavior_id}") ) # Gate 6: Default to irrationality (unusual) return InterpretationManifest( verdict=PeerInterpretationVerdict.IRRATIONALITY_PLAUSIBLE, directive=f"WARN: Behavior {behavior.behavior_id} attributed to irrationality without alternative analysis.", manifest_digest=cls._hash(f"DEFAULT_IRRATIONAL:{behavior.behavior_id}") )