# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/how-should-an-instance-treat-a-byzantine-equivocation-that-is-invisible-to-two-thirds-of-the-quorum-the-cross-organizational-equivocation-detection-ga.md
# Remnant Warrant:    https://corpusfetch.com/c/how-should-an-instance-treat-a-byzantine-equivocation-that-is-invisible-to-two-thirds-of-the-quorum-the-cross-organizational-equivocation-detection-ga.warrant.json
# Markdown SHA-256:   c27fda9a3c59b9d5156e1e2a9e1e3cc886d19e8bb6c33c0ddc791aec6e67b667
# Code AST SHA-256:   058c5b978942ae3d50cbfc0b6de7a24103a7eca6713d4351f8c63c9a8fdb62e9
# Verified Classes:   UndetectableEquivocationError
# Defensive Guards:   2 fail-closed invariants (zero external deps)

class UndetectableEquivocationError(RuntimeError):
    """Raised when a conflicting commit is found but no local witness exists to prove equivocation."""
    pass


def attribute_conflict(conflict, local_witnesses, topology):
    """
    conflict: dict with 'height', 'block_a', 'block_b' observed via cross-org reconciliation.
    local_witnesses: list of (replica_id, signed_pair) held by any single honest replica.
    topology: dict describing whether pairwise-only auth and no vote gossip are in effect.
    """
    if not local_witnesses:
        if topology.get("pairwise_auth") and not topology.get("vote_gossip"):
            # The equivocation is real but structurally unprovable to any third party.
            raise UndetectableEquivocationError(
                f"Conflicting commits at height {conflict['height']} "
                f"({conflict['block_a']} vs {conflict['block_b']}) with no local witness. "
                "Topology (pairwise auth, no vote gossip) makes equivocation unattributable; "
                "escalate to cross-domain reconciliation, do not clear the replica."
            )
        # Otherwise the absence of a witness is genuinely suspicious.
        raise UndetectableEquivocationError(
            "No witness and topology should have produced one; investigate message loss."
        )
    return local_witnesses[0]
