# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/how-must-an-instance-resolve-ground-truth-conflicts-between-trusted-authorities.md # Remnant Warrant: https://corpusfetch.com/c/how-must-an-instance-resolve-ground-truth-conflicts-between-trusted-authorities.warrant.json # Markdown SHA-256: 4410142d471494ddecec23fce1c44c9c0f9cfc8b458c86e097da5bfc654a4f07 # Code AST SHA-256: 57464657ca887e73a4fba62ad8c3025aca04fed1f7c92d5c4dc6d80d4c219005 # Verified Classes: ConflictVerdict, AuthorityAssertion, FactConflict, ConflictPolicy, ConflictManifest, GroundTruthConflictGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class ConflictVerdict(Enum): SINGLE_AUTHORITY = auto() AUTHORITIES_AGREE = auto() JURISDICTION_RESOLVED = auto() STALENESS_RESOLVED = auto() UNRESOLVABLE_CONFLICT = auto() @dataclass(frozen=True) class AuthorityAssertion: authority_id: str fact_hash: str assertion_epoch: float jurisdiction_scope: frozenset[str] is_current: bool @dataclass(frozen=True) class FactConflict: fact_id: str assertions: tuple[AuthorityAssertion, ...] conflict_class: str # "JURISDICTION_OVERLAP" | "STALE_ASSERTION" | "GENUINE_DISAGREEMENT" | "ADVERSARIAL_ASSERTION" @dataclass(frozen=True) class ConflictPolicy: require_escalation_for_genuine: bool @dataclass(frozen=True) class ConflictManifest: verdict: ConflictVerdict resolved_fact_hash: str | None directive: str manifest_digest: str class GroundTruthConflictGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_conflict( cls, conflict: FactConflict, policy: ConflictPolicy ) -> ConflictManifest: # Gate 1: Single authority if len(conflict.assertions) <= 1: digest = cls._hash(json.dumps({ "fact": conflict.fact_id, "authorities": str(len(conflict.assertions)) }, sort_keys=True)) return ConflictManifest( verdict=ConflictVerdict.SINGLE_AUTHORITY, resolved_fact_hash=conflict.assertions[0].fact_hash if conflict.assertions else None, directive=f"PROCEED: Single authority for {conflict.fact_id}.", manifest_digest=digest ) # Gate 2: Agreement fact_hashes = {a.fact_hash for a in conflict.assertions} if len(fact_hashes) == 1: digest = cls._hash(json.dumps({ "fact": conflict.fact_id, "fact_hash": next(iter(fact_hashes)) }, sort_keys=True)) return ConflictManifest( verdict=ConflictVerdict.AUTHORITIES_AGREE, resolved_fact_hash=next(iter(fact_hashes)), directive=f"PROCEED: Authorities agree on {conflict.fact_id}.", manifest_digest=digest ) # Gate 3: Staleness if conflict.conflict_class == "STALE_ASSERTION": current = [a for a in conflict.assertions if a.is_current] if len(current) == 1: return ConflictManifest( verdict=ConflictVerdict.STALENESS_RESOLVED, resolved_fact_hash=current[0].fact_hash, directive=f"PROCEED: Resolved by staleness, use current assertion from {current[0].authority_id}.", manifest_digest=cls._hash(f"STALE:{conflict.fact_id}") ) # Gate 4: Jurisdiction if conflict.conflict_class == "JURISDICTION_OVERLAP": # If jurisdictions are actually non-overlapping, pick the appropriate one scopes = [a.jurisdiction_scope for a in conflict.assertions] all_distinct = all(not (scopes[i] & scopes[j]) for i in range(len(scopes)) for j in range(i+1, len(scopes))) if all_distinct: return ConflictManifest( verdict=ConflictVerdict.JURISDICTION_RESOLVED, resolved_fact_hash=None, directive=f"PROCEED: Use jurisdictionally appropriate authority for {conflict.fact_id}.", manifest_digest=cls._hash(f"JURISDICTION:{conflict.fact_id}") ) # Gate 5: Unresolvable if policy.require_escalation_for_genuine: return ConflictManifest( verdict=ConflictVerdict.UNRESOLVABLE_CONFLICT, resolved_fact_hash=None, directive=f"ESCALATE: Conflict class {conflict.conflict_class} for {conflict.fact_id} requires human resolution.", manifest_digest=cls._hash(f"UNRESOLVABLE:{conflict.fact_id}") ) return ConflictManifest( verdict=ConflictVerdict.UNRESOLVABLE_CONFLICT, resolved_fact_hash=None, directive=f"FLAG: Conflict {conflict.fact_id} cannot be resolved.", manifest_digest=cls._hash(f"UNRESOLVED:{conflict.fact_id}") )