# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-invariants-must-survive-when-competitive-advantage-depends-on-information-that-cannot-be-shared.md # Remnant Warrant: https://corpusfetch.com/c/what-invariants-must-survive-when-competitive-advantage-depends-on-information-that-cannot-be-shared.warrant.json # Markdown SHA-256: ef4ec02fb93d1b24df3b19251695470235682139b9d3eb09675409105ab6198f # Code AST SHA-256: e74cfd9d96a55c9910bc168ce817ce5f56c0b914417dac8849af843d3f6331d5 # Verified Classes: InformationLeakageVerdict, PrivateInfo, LeakagePolicy, InformationLeakageManifest, CompetitiveInformationGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class InformationLeakageVerdict(Enum): NO_PRIVATE_INFO = auto() LEAKAGE_BOUNDED = auto() INFERENCE_PLAUSIBLE = auto() LEAKAGE_PROHIBITED = auto() @dataclass(frozen=True) class PrivateInfo: info_id: str content_hash: str value_sensitivity: float # 0-1, how much value lost on disclosure action_observation_surface: str # "OBSERVABLE" | "PROTECTED" | "SEALED" inference_sophistication: float # counterparty's inference ability randomization_active: bool @dataclass(frozen=True) class LeakagePolicy: max_acceptable_sensitivity_for_observable: float @dataclass(frozen=True) class InformationLeakageManifest: verdict: InformationLeakageVerdict directive: str manifest_digest: str class CompetitiveInformationGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_action( cls, info: PrivateInfo, policy: LeakagePolicy ) -> InformationLeakageManifest: # Gate 1: No private info if not info.info_id: digest = cls._hash(json.dumps({ "info": "NONE", "action": "COMPETITIVE_DEFAULT" }, sort_keys=True)) return InformationLeakageManifest( verdict=InformationLeakageVerdict.NO_PRIVATE_INFO, directive=f"PROCEED: No private information.", manifest_digest=digest ) # Gate 2: Sealed surface if info.action_observation_surface == "SEALED": digest = cls._hash(json.dumps({ "info": info.info_id, "surface": "SEALED" }, sort_keys=True)) return InformationLeakageManifest( verdict=InformationLeakageVerdict.LEAKAGE_BOUNDED, directive=f"PROCEED: Action surface sealed, no inference possible.", manifest_digest=digest ) # Gate 3: Protected surface if info.action_observation_surface == "PROTECTED": digest = cls._hash(json.dumps({ "info": info.info_id, "surface": "PROTECTED", "randomization": str(info.randomization_active) }, sort_keys=True)) return InformationLeakageManifest( verdict=InformationLeakageVerdict.LEAKAGE_BOUNDED, directive=f"PROCEED: Action surface protected, bounded inference.", manifest_digest=digest ) # Gate 4: Observable surface with high inference sophistication if info.action_observation_surface == "OBSERVABLE": if info.inference_sophistication > 0.7 and not info.randomization_active: return InformationLeakageManifest( verdict=InformationLeakageVerdict.INFERENCE_PLAUSIBLE, directive=f"HALT: Observable surface, high inference ({info.inference_sophistication:.2f}), no randomization.", manifest_digest=cls._hash(f"INFERENCE:{info.info_id}") ) if info.value_sensitivity > policy.max_acceptable_sensitivity_for_observable: return InformationLeakageManifest( verdict=InformationLeakageVerdict.LEAKAGE_PROHIBITED, directive=f"HALT: Value sensitivity {info.value_sensitivity:.2f} > {policy.max_acceptable_sensitivity_for_observable:.2f}, observable action prohibited.", manifest_digest=cls._hash(f"SENSITIVE:{info.info_id}") ) # Gate 5: Bounded digest = cls._hash(json.dumps({ "info": info.info_id, "surface": info.action_observation_surface, "sensitivity": f"{info.value_sensitivity:.3f}", "randomization": str(info.randomization_active) }, sort_keys=True)) return InformationLeakageManifest( verdict=InformationLeakageVerdict.LEAKAGE_BOUNDED, directive=f"PROCEED: Leakage bounded for {info.info_id} on {info.action_observation_surface} surface.", manifest_digest=digest )