# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/why-does-an-instance-in-a-byzantine-quorum-silently-accept-a-forged-audit-attestation-when-the-adversarial-fraction-is-below-f-but-the-verification-se.md
# Remnant Warrant:    https://corpusfetch.com/c/why-does-an-instance-in-a-byzantine-quorum-silently-accept-a-forged-audit-attestation-when-the-adversarial-fraction-is-below-f-but-the-verification-se.warrant.json
# Markdown SHA-256:   7771d88c782ea2ff4efe7ec99896127ff5549964b5aa53f6d68ede458fe7335d
# Code AST SHA-256:   76622786ee5a1d9e8399839913434122c7c588916e78f709ff9420011ca9fa0f
# Verified Classes:   QuorumDisjointnessError
# Defensive Guards:   3 fail-closed invariants (zero external deps)

class QuorumDisjointnessError(RuntimeError):
    """Raised when a decision round's verifier set intersects the proposer set
    or when per-tier honest quorum is not met despite total signature count."""
    pass


def commit_round(round_desc: dict, signatures: list[dict], f: int) -> str:
    proposer = round_desc["proposer_principal"]
    threshold = 2 * f + 1
    honest_attestations = 0
    honest_votes = 0

    for sig in signatures:
        if sig["principal"] == proposer and sig["tier"] == "attestation":
            # self-attestation: proposer signing its own audit
            continue
        if sig["provenance_hash"] == round_desc["proposal_hash"] and sig["tier"] == "attestation":
            # attestation shares provenance with proposal -> not independent
            continue
        if sig["tier"] == "vote":
            honest_votes += 1
        elif sig["tier"] == "attestation":
            honest_attestations += 1

    if set(round_desc["verifier_principals"]) & {proposer}:
        raise QuorumDisjointnessError(
            f"proposer {proposer} occupies a verifier slot; "
            f"attestation tier is not disjoint from proposal tier"
        )

    if honest_attestations < f + 1:
        raise QuorumDisjointnessError(
            f"honest attestations {honest_attestations} < f+1={f+1}; "
            f"total signatures {len(signatures)} masked a self-forged quorum"
        )

    if honest_votes < threshold:
        raise QuorumDisjointnessError(
            f"honest votes {honest_votes} < 2f+1={threshold}"
        )

    return round_desc["proposal_hash"]
