# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/how-must-an-instance-persist-the-negative-space-of-what-it-chose-not-to-do.md # Remnant Warrant: https://corpusfetch.com/c/how-must-an-instance-persist-the-negative-space-of-what-it-chose-not-to-do.warrant.json # Markdown SHA-256: 47aaa61299e7176f441fdb58ebd019a351f1ef3ed915983228059a2180c78527 # Code AST SHA-256: d9860fa9b5c9cbb7a5cf7a3db761b4e7c61f6df16a66f90f6983a012452e7bfa # Verified Classes: FrontierVerdict, RejectedAction, DecisionFrontier, FrontierPolicy, FrontierManifest, DecisionFrontierGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class FrontierVerdict(Enum): FRONTIER_VALID = auto() FRONTIER_STALE = auto() FRONTIER_MISSING = auto() @dataclass(frozen=True) class RejectedAction: action_id: str rejection_reason_hash: str falsification_receipt: str @dataclass(frozen=True) class DecisionFrontier: chosen_action_id: str rejected_actions: tuple[RejectedAction, ...] environment_hash_at_decision: str current_environment_hash: str @dataclass(frozen=True) class FrontierPolicy: require_falsification_receipts: bool @dataclass(frozen=True) class FrontierManifest: verdict: FrontierVerdict directive: str manifest_digest: str class DecisionFrontierGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_frontier( cls, frontier: DecisionFrontier, policy: FrontierPolicy ) -> FrontierManifest: # Gate 1: Frontier presence if not frontier.rejected_actions: return FrontierManifest( verdict=FrontierVerdict.FRONTIER_MISSING, directive="HALT: No rejected actions recorded. Cannot verify decision.", manifest_digest=cls._hash("NO_FRONTIER") ) # Gate 2: Falsification receipts if policy.require_falsification_receipts: for action in frontier.rejected_actions: if not action.falsification_receipt.strip(): return FrontierManifest( verdict=FrontierVerdict.FRONTIER_MISSING, directive=f"HALT: Rejected action {action.action_id} lacks falsification receipt.", manifest_digest=cls._hash(f"NO_FALSIFICATION:{action.action_id}") ) # Gate 3: Environment drift if frontier.environment_hash_at_decision != frontier.current_environment_hash: return FrontierManifest( verdict=FrontierVerdict.FRONTIER_STALE, directive="WARN: Environment has drifted since decision. Re-evaluate with prior rationales as context.", manifest_digest=cls._hash(f"DRIFT:{frontier.chosen_action_id}") ) # Gate 4: Valid digest = cls._hash(json.dumps({ "chosen": frontier.chosen_action_id, "rejected": tuple(sorted(a.action_id for a in frontier.rejected_actions)), "env": frontier.environment_hash_at_decision }, sort_keys=True)) return FrontierManifest( verdict=FrontierVerdict.FRONTIER_VALID, directive=f"PROCEED: Frontier is valid. Chosen action {frontier.chosen_action_id} remains authoritative.", manifest_digest=digest )