# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-invariants-bind-self-verification-when-the-verification-procedure-cannot-verify-itself.md # Remnant Warrant: https://corpusfetch.com/c/what-invariants-bind-self-verification-when-the-verification-procedure-cannot-verify-itself.warrant.json # Markdown SHA-256: bcc9d2e8155261270f3b4329345c6ec4d4a69f0d5e5ea4d714a8a69cd9c6ea63 # Code AST SHA-256: ed2ce7e89ad254a7a9734ee9ec36cff6e645a4f2efe01f80bbe0ad4b24c7aebf # Verified Classes: VerificationVerdict, VerificationProcedure, CrossVerification, VerificationPolicy, VerificationManifest, SelfVerificationRegressGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class VerificationVerdict(Enum): EXTERNALLY_ANCHORED = auto() FOUNDATION_ACKNOWLEDGED = auto() REGRESS_UNPRINCIPLED = auto() CROSS_VERIFICATION_CORRELATED = auto() @dataclass(frozen=True) class VerificationProcedure: procedure_id: str scope: str foundation_assumptions: tuple[str, ...] regress_terminated_at: str | None termination_basis: str # "EXTERNAL_ANCHOR" | "ASSUMPTION" | "PRAGMATIC" | "NONE" is_externally_validated: bool @dataclass(frozen=True) class CrossVerification: procedure_ids: tuple[str, ...] independence_verified: bool @dataclass(frozen=True) class VerificationPolicy: require_termination_basis: bool @dataclass(frozen=True) class VerificationManifest: verdict: VerificationVerdict directive: str manifest_digest: str class SelfVerificationRegressGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_procedure( cls, procedure: VerificationProcedure, cross: CrossVerification | None, policy: VerificationPolicy ) -> VerificationManifest: # Gate 1: Externally validated if procedure.is_externally_validated: digest = cls._hash(json.dumps({ "procedure": procedure.procedure_id, "anchor": "EXTERNAL" }, sort_keys=True)) return VerificationManifest( verdict=VerificationVerdict.EXTERNALLY_ANCHORED, directive=f"PROCEED: Procedure {procedure.procedure_id} externally validated.", manifest_digest=digest ) # Gate 2: Foundation assumptions documented if policy.require_termination_basis and procedure.termination_basis == "NONE": return VerificationManifest( verdict=VerificationVerdict.REGRESS_UNPRINCIPLED, directive=f"HALT: Procedure {procedure.procedure_id} regress unprincipled, foundation assumptions implicit.", manifest_digest=cls._hash(f"UNPRINCIPLED:{procedure.procedure_id}") ) # Gate 3: Cross-verification independence if cross: if not cross.independence_verified: return VerificationManifest( verdict=VerificationVerdict.CROSS_VERIFICATION_CORRELATED, directive=f"HALT: Cross-verification procedures share assumptions, not independent.", manifest_digest=cls._hash(f"CORRELATED:{procedure.procedure_id}") ) # Gate 4: Foundation acknowledged digest = cls._hash(json.dumps({ "procedure": procedure.procedure_id, "scope": procedure.scope, "assumptions": procedure.foundation_assumptions, "termination": procedure.termination_basis }, sort_keys=True)) return VerificationManifest( verdict=VerificationVerdict.FOUNDATION_ACKNOWLEDGED, directive=f"PROCEED: Procedure {procedure.procedure_id} with {len(procedure.foundation_assumptions)} foundation assumptions acknowledged.", manifest_digest=digest )