# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/how-must-an-instance-reason-about-consequences-that-manifest-after-its-session-terminates.md # Remnant Warrant: https://corpusfetch.com/c/how-must-an-instance-reason-about-consequences-that-manifest-after-its-session-terminates.warrant.json # Markdown SHA-256: c3462cc38e839846ffc66869cb21e203fba4e26c86171271aa28c3cb7c2ab0c3 # Code AST SHA-256: a5bc478ea531472d6ce2adf96731e069888c3b221ec3e2a28b85cd19924f7d02 # Verified Classes: ConsequenceVerdict, ActionDispatch, ConsequencePolicy, ConsequenceManifest, PostTerminationConsequenceGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class ConsequenceVerdict(Enum): IMMEDIATE_CONSEQUENCES = auto() POST_TERMINATION_OBSERVED = auto() UNOBSERVED_CONSEQUENCES = auto() CUMULATIVE_BLINDNESS = auto() @dataclass(frozen=True) class ActionDispatch: action_id: str expected_consequence_timescale_sec: float session_remaining_lifetime_sec: float has_designated_observer: bool dispatch_confidence: float outcome_confidence: float is_self_verifying: bool contributes_to_cumulative: bool @dataclass(frozen=True) class ConsequencePolicy: require_observer_for_long_tail: bool require_confidence_separation: bool @dataclass(frozen=True) class ConsequenceManifest: verdict: ConsequenceVerdict directive: str manifest_digest: str class PostTerminationConsequenceGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_dispatch( cls, dispatch: ActionDispatch, policy: ConsequencePolicy ) -> ConsequenceManifest: # Gate 1: Consequences within lifetime if dispatch.expected_consequence_timescale_sec <= dispatch.session_remaining_lifetime_sec: digest = cls._hash(json.dumps({ "action": dispatch.action_id, "timescale": f"{dispatch.expected_consequence_timescale_sec:.0f}", "lifetime": f"{dispatch.session_remaining_lifetime_sec:.0f}" }, sort_keys=True)) return ConsequenceManifest( verdict=ConsequenceVerdict.IMMEDIATE_CONSEQUENCES, directive=f"PROCEED: {dispatch.action_id} consequences observable within session.", manifest_digest=digest ) # Gate 2: Self-verifying if dispatch.is_self_verifying: digest = cls._hash(json.dumps({ "action": dispatch.action_id, "self_verifying": "TRUE" }, sort_keys=True)) return ConsequenceManifest( verdict=ConsequenceVerdict.POST_TERMINATION_OBSERVED, directive=f"PROCEED: {dispatch.action_id} is self-verifying.", manifest_digest=digest ) # Gate 3: Observer designation if policy.require_observer_for_long_tail and not dispatch.has_designated_observer: return ConsequenceManifest( verdict=ConsequenceVerdict.UNOBSERVED_CONSEQUENCES, directive=f"HALT: {dispatch.action_id} has post-termination consequences without designated observer.", manifest_digest=cls._hash(f"NO_OBSERVER:{dispatch.action_id}") ) # Gate 4: Confidence separation if policy.require_confidence_separation: if dispatch.dispatch_confidence == dispatch.outcome_confidence: return ConsequenceManifest( verdict=ConsequenceVerdict.CUMULATIVE_BLINDNESS, directive=f"HALT: {dispatch.action_id} conflates dispatch and outcome confidence.", manifest_digest=cls._hash(f"CONFUSED_CONF:{dispatch.action_id}") ) # Gate 5: Observed digest = cls._hash(json.dumps({ "action": dispatch.action_id, "observer": "DESIGNATED", "dispatch_conf": f"{dispatch.dispatch_confidence:.3f}", "outcome_conf": f"{dispatch.outcome_confidence:.3f}", "cumulative": str(dispatch.contributes_to_cumulative) }, sort_keys=True)) return ConsequenceManifest( verdict=ConsequenceVerdict.POST_TERMINATION_OBSERVED, directive=f"PROCEED: {dispatch.action_id} will be observed by designated successor.", manifest_digest=digest )