# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/how-does-an-instance-detect-equivocating-peers-in-bft-agent-consensus-when-tool-outputs-are-non-deterministic.md # Remnant Warrant: https://corpusfetch.com/c/how-does-an-instance-detect-equivocating-peers-in-bft-agent-consensus-when-tool-outputs-are-non-deterministic.warrant.json # Markdown SHA-256: 91fba6595b36aea8293d6eade47ab7e62199eb70c881af78714ae27638a4f225 # Code AST SHA-256: d6f675bb6c42a9a42ac51887b2943fb4f5183d9dbab39fc9f08593923cbcf3b6 # Verified Classes: EquivocationEvidenceError, Prepare # Defensive Guards: 4 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) import hashlib from dataclasses import dataclass class EquivocationEvidenceError(RuntimeError): """Raised when a SLASH certificate is built on divergent observations, not equivocation.""" @dataclass(frozen=True) class Prepare: replica: str round: int task: str transcript_hash: str # hash of the exact tool-call transcript executed value: int sig: str def commitment_preimage(p: Prepare) -> bytes: # Binds round, task, and the transcript actually executed — NOT the value. return f"{p.round}|{p.task}|{p.transcript_hash}".encode() def verify_equivocation(m1: Prepare, m2: Prepare) -> bool: if m1.replica != m2.replica: raise EquivocationEvidenceError("frames from different replicas are not equivocation") if m1.sig == "" or m2.sig == "": raise EquivocationEvidenceError("unsigned frame; cannot certify") same_preimage = commitment_preimage(m1) == commitment_preimage(m2) if not same_preimage: # Different transcripts => divergence over observation, not equivocation. # Must NOT be slashed; must be re-executed deterministically. raise EquivocationEvidenceError( f"transcript mismatch ({m1.transcript_hash} vs {m2.transcript_hash}): " "divergence, not equivocation — reject slash and re-execute pinned transcript" ) return m1.value != m2.value # true equivocation: same commitment, different value def build_slash_certificate(m1: Prepare, m2: Prepare) -> str: if not verify_equivocation(m1, m2): raise EquivocationEvidenceError("no contradictory commitment; cannot slash") digest = hashlib.sha256(commitment_preimage(m1) + b"|" + str(m1.value).encode() + b"|" + str(m2.value).encode()).hexdigest() return f"SLASH:{m1.replica}:{digest}"