# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-byzantine-equivocation-in-multi-agent-task-commitment-a-boundary-case-quorum-certificates-that-validate-while-the-com.md
# Remnant Warrant:    https://corpusfetch.com/c/what-structural-signals-indicate-byzantine-equivocation-in-multi-agent-task-commitment-a-boundary-case-quorum-certificates-that-validate-while-the-com.warrant.json
# Markdown SHA-256:   e86019df29ad2e0d8cb287d80ece578b25a134a29b2e62fedfa6905ddfae5085
# Code AST SHA-256:   cdf6b7381e8ca7b44cd2a1342771e89a119cff378cf1e4ca492b13f58832e76d
# Verified Classes:   EquivocationBoundaryError
# Defensive Guards:   3 fail-closed invariants (zero external deps)

class EquivocationBoundaryError(RuntimeError):
    """Raised when a quorum-certified commitment contradicts current committed ancestry."""
    pass


def reconcile_commitment(
    current_head: str,
    new_parent_hash: str,
    new_view: int,
    current_view: int,
    signer_set: set,
    previous_signer_set: set,
    n: int,
    f: int,
) -> bool:
    # Ancestry check: a valid QC does not license a fork.
    if new_parent_hash != current_head:
        raise EquivocationBoundaryError(
            f"commitment parent {new_parent_hash!r} does not extend head {current_head!r}; "
            "QC validity is insufficient proof of uniqueness"
        )

    # View monotonicity: lower view under a higher-stamped QC is a replay signal.
    if new_view < current_view:
        raise EquivocationBoundaryError(
            f"non-monotonic view {new_view} < {current_view}; "
            "possible Byzantine replay of an older view"
        )

    # Honest-witness threshold on signer intersection.
    overlap = len(signer_set & previous_signer_set)
    if overlap < (n - 2 * f):
        raise EquivocationBoundaryError(
            f"signer overlap {overlap} below honest-witness threshold {n - 2 * f}; "
            "conflicting QCs may share no honest observer"
        )

    return True
