# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-invariants-prevent-verification-regress-from-terminating-at-an-arbitrary-level.md # Remnant Warrant: https://corpusfetch.com/c/what-invariants-prevent-verification-regress-from-terminating-at-an-arbitrary-level.warrant.json # Markdown SHA-256: f49a8423fa1bf4286866f25971e19983c6090f09f8399ede2284c82824fd4607 # Code AST SHA-256: f87b7004b8c1bf68a12dbbcb8bb306f64f74f7e84c2c96eff0ec65b9fd4e267d # Verified Classes: RegressVerdict, VerificationLink, VerificationChain, RegressPolicy, RegressManifest, VerificationRegressGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class RegressVerdict(Enum): SINGLE_VERIFIER = auto() PRINCIPLED_ANCHOR = auto() ARBITRARY_TERMINATION = auto() CIRCULAR_ANCHOR = auto() @dataclass(frozen=True) class VerificationLink: verifier_id: str verifies_claim: bool verification_basis: str # "EXTERNAL_AUTHORITY" | "CRYPTO_PROOF" | "DEPTH_LIMIT" | "RESOURCE_LIMIT" | "CIRCULAR" @dataclass(frozen=True) class VerificationChain: chain_id: str links: tuple[VerificationLink, ...] anchor_justified: bool @dataclass(frozen=True) class RegressPolicy: require_principled_anchor: bool @dataclass(frozen=True) class RegressManifest: verdict: RegressVerdict directive: str manifest_digest: str class VerificationRegressGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_chain( cls, chain: VerificationChain, policy: RegressPolicy ) -> RegressManifest: # Gate 1: Single verifier if len(chain.links) <= 1: digest = cls._hash(json.dumps({ "chain": chain.chain_id, "links": str(len(chain.links)) }, sort_keys=True)) return RegressManifest( verdict=RegressVerdict.SINGLE_VERIFIER, directive=f"PROCEED: Chain {chain.chain_id} single verifier.", manifest_digest=digest ) # Gate 2: Circular terminal = chain.links[-1] if terminal.verification_basis == "CIRCULAR": return RegressManifest( verdict=RegressVerdict.CIRCULAR_ANCHOR, directive=f"HALT: Chain {chain.chain_id} terminates in circular anchor.", manifest_digest=cls._hash(f"CIRCULAR:{chain.chain_id}") ) # Gate 3: Principled anchor if terminal.verification_basis in ("EXTERNAL_AUTHORITY", "CRYPTO_PROOF"): if chain.anchor_justified: digest = cls._hash(json.dumps({ "chain": chain.chain_id, "anchor": terminal.verification_basis, "links": str(len(chain.links)) }, sort_keys=True)) return RegressManifest( verdict=RegressVerdict.PRINCIPLED_ANCHOR, directive=f"PROCEED: Chain {chain.chain_id} anchored at {terminal.verification_basis}.", manifest_digest=digest ) # Gate 4: Arbitrary termination if terminal.verification_basis in ("DEPTH_LIMIT", "RESOURCE_LIMIT"): if policy.require_principled_anchor: return RegressManifest( verdict=RegressVerdict.ARBITRARY_TERMINATION, directive=f"HALT: Chain {chain.chain_id} terminated by {terminal.verification_basis}, not principled.", manifest_digest=cls._hash(f"ARBITRARY:{chain.chain_id}") ) # Gate 5: Default return RegressManifest( verdict=RegressVerdict.ARBITRARY_TERMINATION, directive=f"FLAG: Chain {chain.chain_id} termination basis {terminal.verification_basis}.", manifest_digest=cls._hash(f"DEFAULT:{chain.chain_id}") )