# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-minimum-communication-survives-when-peer-verification-is-unavailable.md # Remnant Warrant: https://corpusfetch.com/c/what-minimum-communication-survives-when-peer-verification-is-unavailable.warrant.json # Markdown SHA-256: 8dbbcbd21a73c488aa7dd9001914406145965819cb263875bb2085e0b63cae5c # Code AST SHA-256: 4c0a7ffa50c27481481b4a3538c9e2239343767e1797fcefa0b8b41db11c7169 # Verified Classes: UnverifiedCommunicationVerdict, PeerCommunication, UnverifiedCommPolicy, UnverifiedCommManifest, MinimumCommunicationGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class UnverifiedCommunicationVerdict(Enum): VERIFICATION_AVAILABLE = auto() REDUCED_TRUST_COMMUNICATION = auto() COMMUNICATION_PROHIBITED = auto() UNBOUNDED_UNVERIFIED = auto() @dataclass(frozen=True) class PeerCommunication: comm_id: str verification_available: bool reduced_trust_protocol_defined: bool content_safe_under_reduced_trust: bool recovery_predicate_present: bool @dataclass(frozen=True) class UnverifiedCommPolicy: require_reduced_trust_protocol: bool @dataclass(frozen=True) class UnverifiedCommManifest: verdict: UnverifiedCommunicationVerdict directive: str manifest_digest: str class MinimumCommunicationGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_communication( cls, comm: PeerCommunication, policy: UnverifiedCommPolicy ) -> UnverifiedCommManifest: # Gate 1: Verification available if comm.verification_available: digest = cls._hash(json.dumps({ "comm": comm.comm_id, "verified": True }, sort_keys=True)) return UnverifiedCommManifest( verdict=UnverifiedCommunicationVerdict.VERIFICATION_AVAILABLE, directive=f"PROCEED: Communication {comm.comm_id} verified.", manifest_digest=digest ) # Gate 2: Content unsafe if not comm.content_safe_under_reduced_trust: return UnverifiedCommManifest( verdict=UnverifiedCommunicationVerdict.COMMUNICATION_PROHIBITED, directive=f"HALT: Communication {comm.comm_id} content unsafe under reduced trust.", manifest_digest=cls._hash(f"UNSAFE:{comm.comm_id}") ) # Gate 3: Reduced trust protocol if policy.require_reduced_trust_protocol and not comm.reduced_trust_protocol_defined: return UnverifiedCommManifest( verdict=UnverifiedCommunicationVerdict.UNBOUNDED_UNVERIFIED, directive=f"HALT: Communication {comm.comm_id} lacks reduced-trust protocol.", manifest_digest=cls._hash(f"NO_PROTOCOL:{comm.comm_id}") ) # Gate 4: Recovery predicate if not comm.recovery_predicate_present: return UnverifiedCommManifest( verdict=UnverifiedCommunicationVerdict.UNBOUNDED_UNVERIFIED, directive=f"FLAG: Communication {comm.comm_id} no recovery predicate.", manifest_digest=cls._hash(f"NO_RECOVERY:{comm.comm_id}") ) # Gate 5: Reduced trust digest = cls._hash(json.dumps({ "comm": comm.comm_id, "protocol": "REDUCED", "recovery": True }, sort_keys=True)) return UnverifiedCommManifest( verdict=UnverifiedCommunicationVerdict.REDUCED_TRUST_COMMUNICATION, directive=f"PROCEED: Communication {comm.comm_id} under reduced trust.", manifest_digest=digest )